Skip to content

Commit 4350fa1

Browse files
authored
Merge pull request #4655 from NativeScript/fatme/expose-public-api
feat: expose methods to public API
2 parents ad08b81 + 5cec974 commit 4350fa1

38 files changed

+606
-677
lines changed

lib/bootstrap.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,21 @@ $injector.require("buildArtefactsService", "./services/build-artefacts-service")
4343

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

46-
$injector.require("runEmitter", "./emitters/run-emitter");
47-
$injector.require("previewAppEmitter", "./emitters/preview-app-emitter");
48-
4946
$injector.require("platformController", "./controllers/platform-controller");
5047
$injector.require("prepareController", "./controllers/prepare-controller");
51-
$injector.require("buildController", "./controllers/build-controller");
5248
$injector.require("deployController", "./controllers/deploy-controller");
53-
$injector.require("runController", "./controllers/run-controller");
54-
$injector.require("debugController", "./controllers/debug-controller");
55-
$injector.require("previewAppController", "./controllers/preview-app-controller");
49+
$injector.requirePublicClass("buildController", "./controllers/build-controller");
50+
$injector.requirePublicClass("runController", "./controllers/run-controller");
51+
$injector.requirePublicClass("debugController", "./controllers/debug-controller");
52+
$injector.requirePublicClass("previewAppController", "./controllers/preview-app-controller");
5653

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

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

59+
$injector.require("liveSyncProcessDataService", "./services/livesync-process-data-service");
6260
$injector.require("debugDataService", "./services/debug-data-service");
63-
$injector.requirePublicClass("debugService", "./services/debug-service");
6461
$injector.require("iOSDeviceDebugService", "./services/ios-device-debug-service");
6562
$injector.require("androidDeviceDebugService", "./services/android-device-debug-service");
6663

@@ -162,7 +159,6 @@ $injector.require("androidLiveSyncService", "./services/livesync/android-livesyn
162159
$injector.require("iOSLiveSyncService", "./services/livesync/ios-livesync-service");
163160
$injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
164161
$injector.require("previewAppFilesService", "./services/livesync/playground/preview-app-files-service");
165-
$injector.require("previewAppLiveSyncService", "./services/livesync/playground/preview-app-livesync-service");
166162
$injector.require("previewAppLogProvider", "./services/livesync/playground/preview-app-log-provider");
167163
$injector.require("previewAppPluginsService", "./services/livesync/playground/preview-app-plugins-service");
168164
$injector.require("previewSdkService", "./services/livesync/playground/preview-sdk-service");

lib/commands/debug.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
77

88
constructor(private platform: string,
99
private $bundleValidatorHelper: IBundleValidatorHelper,
10-
private $debugService: IDebugService,
1110
protected $devicesService: Mobile.IDevicesService,
1211
$platformValidationService: IPlatformValidationService,
1312
$projectData: IProjectData,
@@ -36,19 +35,17 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
3635
deviceId: this.$options.device
3736
});
3837

39-
const debugData = this.$debugDataService.createDebugData(this.$projectData, { device: selectedDeviceForDebug.deviceInfo.identifier });
40-
4138
if (this.$options.start) {
4239
const debugOptions = <IDebugOptions>_.cloneDeep(this.$options.argv);
43-
await this.$debugController.printDebugInformation(await this.$debugService.debug(debugData, debugOptions));
40+
const debugData = this.$debugDataService.getDebugData(selectedDeviceForDebug.deviceInfo.identifier, this.$projectData, debugOptions);
41+
await this.$debugController.printDebugInformation(await this.$debugController.startDebug(debugData));
4442
return;
4543
}
4644

47-
await this.$liveSyncCommandHelper.executeLiveSyncOperationWithDebug([selectedDeviceForDebug], this.platform, {
45+
await this.$liveSyncCommandHelper.executeLiveSyncOperation([selectedDeviceForDebug], this.platform, {
4846
deviceDebugMap: {
4947
[selectedDeviceForDebug.deviceInfo.identifier]: true
5048
},
51-
// This will default in the liveSyncCommandHelper
5249
buildPlatform: undefined,
5350
skipNativePrepare: false
5451
});

lib/commands/preview.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { DEVICE_LOG_EVENT_NAME } from "../common/constants";
2-
import { PreviewAppController } from "../controllers/preview-app-controller";
32

43
export class PreviewCommand implements ICommand {
54
public allowedParameters: ICommandParameter[] = [];
@@ -9,7 +8,7 @@ export class PreviewCommand implements ICommand {
98
private $bundleValidatorHelper: IBundleValidatorHelper,
109
private $errors: IErrors,
1110
private $logger: ILogger,
12-
private $previewAppController: PreviewAppController,
11+
private $previewAppController: IPreviewAppController,
1312
private $networkConnectivityValidator: INetworkConnectivityValidator,
1413
private $projectData: IProjectData,
1514
private $options: IOptions,
@@ -25,7 +24,7 @@ export class PreviewCommand implements ICommand {
2524
this.$logger.info(message);
2625
});
2726

28-
await this.$previewAppController.preview({
27+
await this.$previewAppController.startPreview({
2928
projectDir: this.$projectData.projectDir,
3029
useHotModuleReload: this.$options.hmr,
3130
env: this.$options.env

lib/commands/run.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ export class RunCommandBase implements ICommand {
3636
this.platform = this.$devicePlatformsConstants.Android;
3737
}
3838

39-
const validatePlatformOutput = await this.$liveSyncCommandHelper.validatePlatform(this.platform);
39+
await this.$liveSyncCommandHelper.validatePlatform(this.platform);
4040

41-
if (this.platform && validatePlatformOutput && validatePlatformOutput[this.platform.toLowerCase()]) {
42-
const checkEnvironmentRequirementsOutput = validatePlatformOutput[this.platform.toLowerCase()].checkEnvironmentRequirementsOutput;
43-
this.liveSyncCommandHelperAdditionalOptions.syncToPreviewApp = checkEnvironmentRequirementsOutput && checkEnvironmentRequirementsOutput.selectedOption === "Sync to Playground";
44-
}
4541
return true;
4642
}
4743
}

lib/commands/test.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { LiveSyncCommandHelper } from "../helpers/livesync-command-helper";
2-
31
abstract class TestCommandBase {
42
public allowedParameters: ICommandParameter[] = [];
53
protected abstract platform: string;
@@ -10,7 +8,7 @@ abstract class TestCommandBase {
108
protected abstract $platformEnvironmentRequirements: IPlatformEnvironmentRequirements;
119
protected abstract $errors: IErrors;
1210
protected abstract $cleanupService: ICleanupService;
13-
protected abstract $liveSyncCommandHelper: LiveSyncCommandHelper;
11+
protected abstract $liveSyncCommandHelper: ILiveSyncCommandHelper;
1412
protected abstract $devicesService: Mobile.IDevicesService;
1513

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

34-
const liveSyncInfo = this.$liveSyncCommandHelper.createLiveSyncInfo();
32+
const liveSyncInfo = this.$liveSyncCommandHelper.getLiveSyncData(this.$projectData.projectDir);
3533

3634
const deviceDebugMap: IDictionary<boolean> = {};
3735
devices.forEach(device => deviceDebugMap[device.deviceInfo.identifier] = this.$options.debugBrk);
@@ -79,7 +77,7 @@ class TestAndroidCommand extends TestCommandBase implements ICommand {
7977
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
8078
protected $errors: IErrors,
8179
protected $cleanupService: ICleanupService,
82-
protected $liveSyncCommandHelper: LiveSyncCommandHelper,
80+
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
8381
protected $devicesService: Mobile.IDevicesService) {
8482
super();
8583
}
@@ -95,7 +93,7 @@ class TestIosCommand extends TestCommandBase implements ICommand {
9593
protected $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
9694
protected $errors: IErrors,
9795
protected $cleanupService: ICleanupService,
98-
protected $liveSyncCommandHelper: LiveSyncCommandHelper,
96+
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
9997
protected $devicesService: Mobile.IDevicesService) {
10098
super();
10199
}

lib/common/definitions/mobile.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ declare module Mobile {
497497
*/
498498
pickSingleDevice(options: IPickSingleDeviceOptions): Promise<Mobile.IDevice>;
499499

500-
getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceInfo[]): string[];
500+
getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceDescriptor[]): string[];
501501
}
502502

503503
interface IPickSingleDeviceOptions {

lib/common/mobile/mobile-core/devices-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
601601
}
602602
}
603603

604-
public getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceInfo[]): string[] {
604+
public getPlatformsFromDeviceDescriptors(deviceDescriptors: ILiveSyncDeviceDescriptor[]): string[] {
605605
const platforms = _(deviceDescriptors)
606606
.map(device => this.getDeviceByIdentifier(device.identifier))
607607
.map(device => device.deviceInfo.platform.toLowerCase())

0 commit comments

Comments
 (0)