Skip to content

feat: expose methods to public API #4655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,21 @@ $injector.require("buildArtefactsService", "./services/build-artefacts-service")

$injector.require("deviceInstallAppService", "./services/device/device-install-app-service");

$injector.require("runEmitter", "./emitters/run-emitter");
$injector.require("previewAppEmitter", "./emitters/preview-app-emitter");

$injector.require("platformController", "./controllers/platform-controller");
$injector.require("prepareController", "./controllers/prepare-controller");
$injector.require("buildController", "./controllers/build-controller");
$injector.require("deployController", "./controllers/deploy-controller");
$injector.require("runController", "./controllers/run-controller");
$injector.require("debugController", "./controllers/debug-controller");
$injector.require("previewAppController", "./controllers/preview-app-controller");
$injector.requirePublicClass("buildController", "./controllers/build-controller");
$injector.requirePublicClass("runController", "./controllers/run-controller");
$injector.requirePublicClass("debugController", "./controllers/debug-controller");
$injector.requirePublicClass("previewAppController", "./controllers/preview-app-controller");

$injector.require("prepareDataService", "./services/prepare-data-service");
$injector.require("buildDataService", "./services/build-data-service");

$injector.require("liveSyncServiceResolver", "./resolvers/livesync-service-resolver");

$injector.require("liveSyncProcessDataService", "./services/livesync-process-data-service");
$injector.require("debugDataService", "./services/debug-data-service");
$injector.requirePublicClass("debugService", "./services/debug-service");
$injector.require("iOSDeviceDebugService", "./services/ios-device-debug-service");
$injector.require("androidDeviceDebugService", "./services/android-device-debug-service");

Expand Down Expand Up @@ -162,7 +159,6 @@ $injector.require("androidLiveSyncService", "./services/livesync/android-livesyn
$injector.require("iOSLiveSyncService", "./services/livesync/ios-livesync-service");
$injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
$injector.require("previewAppFilesService", "./services/livesync/playground/preview-app-files-service");
$injector.require("previewAppLiveSyncService", "./services/livesync/playground/preview-app-livesync-service");
$injector.require("previewAppLogProvider", "./services/livesync/playground/preview-app-log-provider");
$injector.require("previewAppPluginsService", "./services/livesync/playground/preview-app-plugins-service");
$injector.require("previewSdkService", "./services/livesync/playground/preview-sdk-service");
Expand Down
9 changes: 3 additions & 6 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements

constructor(private platform: string,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $debugService: IDebugService,
protected $devicesService: Mobile.IDevicesService,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
Expand Down Expand Up @@ -36,19 +35,17 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
deviceId: this.$options.device
});

const debugData = this.$debugDataService.createDebugData(this.$projectData, { device: selectedDeviceForDebug.deviceInfo.identifier });

if (this.$options.start) {
const debugOptions = <IDebugOptions>_.cloneDeep(this.$options.argv);
await this.$debugController.printDebugInformation(await this.$debugService.debug(debugData, debugOptions));
const debugData = this.$debugDataService.getDebugData(selectedDeviceForDebug.deviceInfo.identifier, this.$projectData, debugOptions);
await this.$debugController.printDebugInformation(await this.$debugController.startDebug(debugData));
return;
}

await this.$liveSyncCommandHelper.executeLiveSyncOperationWithDebug([selectedDeviceForDebug], this.platform, {
await this.$liveSyncCommandHelper.executeLiveSyncOperation([selectedDeviceForDebug], this.platform, {
deviceDebugMap: {
[selectedDeviceForDebug.deviceInfo.identifier]: true
},
// This will default in the liveSyncCommandHelper
buildPlatform: undefined,
skipNativePrepare: false
});
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DEVICE_LOG_EVENT_NAME } from "../common/constants";
import { PreviewAppController } from "../controllers/preview-app-controller";

export class PreviewCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
Expand All @@ -9,7 +8,7 @@ export class PreviewCommand implements ICommand {
private $bundleValidatorHelper: IBundleValidatorHelper,
private $errors: IErrors,
private $logger: ILogger,
private $previewAppController: PreviewAppController,
private $previewAppController: IPreviewAppController,
private $networkConnectivityValidator: INetworkConnectivityValidator,
private $projectData: IProjectData,
private $options: IOptions,
Expand All @@ -25,7 +24,7 @@ export class PreviewCommand implements ICommand {
this.$logger.info(message);
});

await this.$previewAppController.preview({
await this.$previewAppController.startPreview({
projectDir: this.$projectData.projectDir,
useHotModuleReload: this.$options.hmr,
env: this.$options.env
Expand Down
6 changes: 1 addition & 5 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ export class RunCommandBase implements ICommand {
this.platform = this.$devicePlatformsConstants.Android;
}

const validatePlatformOutput = await this.$liveSyncCommandHelper.validatePlatform(this.platform);
await this.$liveSyncCommandHelper.validatePlatform(this.platform);

if (this.platform && validatePlatformOutput && validatePlatformOutput[this.platform.toLowerCase()]) {
const checkEnvironmentRequirementsOutput = validatePlatformOutput[this.platform.toLowerCase()].checkEnvironmentRequirementsOutput;
this.liveSyncCommandHelperAdditionalOptions.syncToPreviewApp = checkEnvironmentRequirementsOutput && checkEnvironmentRequirementsOutput.selectedOption === "Sync to Playground";
}
return true;
}
}
Expand Down
10 changes: 4 additions & 6 deletions lib/commands/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { LiveSyncCommandHelper } from "../helpers/livesync-command-helper";

abstract class TestCommandBase {
public allowedParameters: ICommandParameter[] = [];
protected abstract platform: string;
Expand All @@ -10,7 +8,7 @@ abstract class TestCommandBase {
protected abstract $platformEnvironmentRequirements: IPlatformEnvironmentRequirements;
protected abstract $errors: IErrors;
protected abstract $cleanupService: ICleanupService;
protected abstract $liveSyncCommandHelper: LiveSyncCommandHelper;
protected abstract $liveSyncCommandHelper: ILiveSyncCommandHelper;
protected abstract $devicesService: Mobile.IDevicesService;

async execute(args: string[]): Promise<void> {
Expand All @@ -31,7 +29,7 @@ abstract class TestCommandBase {
if (!this.$options.env) { this.$options.env = { }; }
this.$options.env.unitTesting = true;

const liveSyncInfo = this.$liveSyncCommandHelper.createLiveSyncInfo();
const liveSyncInfo = this.$liveSyncCommandHelper.getLiveSyncData(this.$projectData.projectDir);

const deviceDebugMap: IDictionary<boolean> = {};
devices.forEach(device => deviceDebugMap[device.deviceInfo.identifier] = this.$options.debugBrk);
Expand Down Expand Up @@ -79,7 +77,7 @@ class TestAndroidCommand extends TestCommandBase implements ICommand {
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
protected $errors: IErrors,
protected $cleanupService: ICleanupService,
protected $liveSyncCommandHelper: LiveSyncCommandHelper,
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
protected $devicesService: Mobile.IDevicesService) {
super();
}
Expand All @@ -95,7 +93,7 @@ class TestIosCommand extends TestCommandBase implements ICommand {
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
protected $errors: IErrors,
protected $cleanupService: ICleanupService,
protected $liveSyncCommandHelper: LiveSyncCommandHelper,
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
protected $devicesService: Mobile.IDevicesService) {
super();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/definitions/mobile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ declare module Mobile {
*/
pickSingleDevice(options: IPickSingleDeviceOptions): Promise<Mobile.IDevice>;

getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceInfo[]): string[];
getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceDescriptor[]): string[];
}

interface IPickSingleDeviceOptions {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/mobile/mobile-core/devices-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
}
}

public getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceInfo[]): string[] {
public getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceDescriptor[]): string[] {
const platforms = _(deviceDescriptors)
.map(device => this.getDeviceByIdentifier(device.identifier))
.map(device => device.deviceInfo.platform.toLowerCase())
Expand Down
Loading