Skip to content

Commit 4d6b990

Browse files
TsvetanMilanovDimitar Kerezov
authored andcommitted
WIP
1 parent 96af540 commit 4d6b990

File tree

11 files changed

+30
-17
lines changed

11 files changed

+30
-17
lines changed

lib/bootstrap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ $injector.require("platformsData", "./platforms-data");
2424
$injector.require("platformService", "./services/platform-service");
2525

2626
$injector.require("debugDataService", "./services/debug-data-service");
27+
$injector.requirePublicClass("debugService", "./services/debug-service");
2728
$injector.require("iOSDebugService", "./services/ios-debug-service");
2829
$injector.require("androidDebugService", "./services/android-debug-service");
2930

@@ -104,6 +105,7 @@ $injector.require("devicePathProvider", "./device-path-provider");
104105
$injector.requireCommand("platform|clean", "./commands/platform-clean");
105106

106107
$injector.require("liveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
108+
$injector.require("debugLiveSyncService", "./services/livesync/debug-livesync-service");
107109
$injector.require("androidLiveSyncService", "./services/livesync/android-livesync-service");
108110
$injector.require("iOSLiveSyncService", "./services/livesync/ios-livesync-service");
109111
$injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const SYNC_DIR_NAME = "sync";
7070
export const REMOVEDSYNC_DIR_NAME = "removedsync";
7171
export const FULLSYNC_DIR_NAME = "fullsync";
7272
export const IOS_DEVICE_PROJECT_ROOT_PATH = "Library/Application Support/LiveSync/app";
73+
export const IOS_DEVICE_SYNC_ZIP_PATH = "Library/Application Support/LiveSync/sync.zip";
7374
export const ANGULAR_NAME = "angular";
7475
export const TYPESCRIPT_NAME = "typescript";
7576
export const BUILD_OUTPUT_EVENT_NAME = "buildOutput";

lib/definitions/debug.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ interface IDebugDataService {
8989
/**
9090
* Describes methods for debug operation.
9191
*/
92-
interface IDebugService extends NodeJS.EventEmitter {
92+
interface IDebugServiceBase extends NodeJS.EventEmitter {
9393
/**
9494
* Starts debug operation based on the specified debug data.
9595
* @param {IDebugData} debugData Describes information for device and application that will be debugged.
@@ -99,10 +99,14 @@ interface IDebugService extends NodeJS.EventEmitter {
9999
debug<T>(debugData: IDebugData, debugOptions: IDebugOptions): Promise<T>;
100100
}
101101

102+
interface IDebugService {
103+
getDebugService(device: Mobile.IDevice): IPlatformDebugService;
104+
}
105+
102106
/**
103107
* Describes actions required for debugging on specific platform (Android or iOS).
104108
*/
105-
interface IPlatformDebugService extends IDebugService {
109+
interface IPlatformDebugService extends IDebugServiceBase {
106110
/**
107111
* Starts debug operation.
108112
* @param {IDebugData} debugData Describes information for device and application that will be debugged.

lib/definitions/livesync.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,5 @@ interface IDeviceProjectRootOptions {
214214
interface IDevicePathProvider {
215215
getDeviceBuildInfoDirname(device: Mobile.IDevice, appIdentifier: string): Promise<string>;
216216
getDeviceProjectRootPath(device: Mobile.IDevice, options: IDeviceProjectRootOptions): Promise<string>;
217+
getDeviceSyncZipPath(device: Mobile.IDevice): string;
217218
}

lib/device-path-provider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fromWindowsRelativePathToUnix } from "./common/helpers";
2-
import { IOS_DEVICE_PROJECT_ROOT_PATH, SYNC_DIR_NAME, FULLSYNC_DIR_NAME } from "./constants";
2+
import { IOS_DEVICE_SYNC_ZIP_PATH, IOS_DEVICE_PROJECT_ROOT_PATH, SYNC_DIR_NAME, FULLSYNC_DIR_NAME } from "./constants";
33
import { AndroidDeviceLiveSyncService } from "./services/livesync/android-device-livesync-service";
44
import * as path from "path";
55

@@ -12,7 +12,7 @@ export class DevicePathProvider implements IDevicePathProvider {
1212
public async getDeviceBuildInfoDirname(device: Mobile.IDevice, appIdentifier: string): Promise<string> {
1313
let result = "";
1414
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
15-
result = path.basename(await this.getDeviceProjectRootPath(device, { appIdentifier }));
15+
result = path.dirname(await this.getDeviceProjectRootPath(device, { appIdentifier }));
1616
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
1717
result = `/data/local/tmp/${appIdentifier}`;
1818
}
@@ -39,6 +39,10 @@ export class DevicePathProvider implements IDevicePathProvider {
3939

4040
return fromWindowsRelativePathToUnix(projectRoot);
4141
}
42+
43+
public getDeviceSyncZipPath(device: Mobile.IDevice): string {
44+
return this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) && !device.isEmulator ? IOS_DEVICE_SYNC_ZIP_PATH : undefined;
45+
}
4246
}
4347

4448
$injector.register("devicePathProvider", DevicePathProvider);

lib/device-sockets/ios/socket-proxy-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
7575

7676
public async createWebSocketProxy(factory: () => Promise<net.Socket>): Promise<ws.Server> {
7777
// NOTE: We will try to provide command line options to select ports, at least on the localhost.
78-
const localPort = await this.$net.getAvailablePortInRange(8080);
78+
const localPort = await this.$net.getFreePort();
7979

8080
this.$logger.info("\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n");
8181

lib/nativescript-cli-lib-bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ $injector.requirePublic("companionAppsService", "./common/appbuilder/services/li
99
$injector.requirePublicClass("deviceEmitter", "./common/appbuilder/device-emitter");
1010
$injector.requirePublicClass("deviceLogProvider", "./common/appbuilder/device-log-provider");
1111
$injector.requirePublicClass("localBuildService", "./services/local-build-service");
12-
$injector.requirePublicClass("debugService", "./services/debug-service");
1312

1413
// We need this because some services check if (!$options.justlaunch) to start the device log after some operation.
1514
// We don't want this behaviour when the CLI is required as library.

lib/services/debug-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class DebugService extends EventEmitter implements IDebugService {
6767
return _.first(result);
6868
}
6969

70-
private getDebugService(device: Mobile.IDevice): IPlatformDebugService {
70+
public getDebugService(device: Mobile.IDevice): IPlatformDebugService {
7171
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
7272
return this.$iOSDebugService;
7373
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {

lib/services/livesync/debug-livesync-service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class DebugLiveSyncService extends LiveSyncService {
1515
private $options: IOptions,
1616
private $debugDataService: IDebugDataService,
1717
private $projectData: IProjectData,
18-
private debugService: IPlatformDebugService,
18+
private $debugService: IDebugService,
1919
private $config: IConfiguration) {
2020

2121
super($platformService,
@@ -43,25 +43,26 @@ export class DebugLiveSyncService extends LiveSyncService {
4343
};
4444

4545
let debugData = this.$debugDataService.createDebugData(this.$projectData, this.$options);
46+
const debugService = this.$debugService.getDebugService(liveSyncResultInfo.deviceAppData.device);
4647

4748
await this.$platformService.trackProjectType(this.$projectData);
4849

4950
if (this.$options.start) {
50-
return this.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
51+
return this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
5152
}
5253

5354
const deviceAppData = liveSyncResultInfo.deviceAppData;
5455
this.$config.debugLivesync = true;
5556

56-
await this.debugService.debugStop();
57+
await debugService.debugStop();
5758

5859
let applicationId = deviceAppData.appIdentifier;
5960
await deviceAppData.device.applicationManager.stopApplication(applicationId, projectData.projectName);
6061

6162
const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions);
62-
debugData.pathToAppPackage = this.$platformService.lastOutputPath(this.debugService.platform, buildConfig, projectData);
63+
debugData.pathToAppPackage = this.$platformService.lastOutputPath(debugService.platform, buildConfig, projectData);
6364

64-
this.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
65+
this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
6566
}
6667

6768
protected printDebugInformation(information: string[]): void {

lib/services/livesync/platform-livesync-service-base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export abstract class PlatformLiveSyncServiceBase {
104104
device: syncInfo.device,
105105
platform: syncInfo.device.deviceInfo.platform,
106106
getDeviceProjectRootPath: () => this.$devicePathProvider.getDeviceProjectRootPath(syncInfo.device, deviceProjectRootOptions),
107+
deviceSyncZipPath: this.$devicePathProvider.getDeviceSyncZipPath(syncInfo.device),
107108
isLiveSyncSupported: async () => true
108109
};
109110
}

0 commit comments

Comments
 (0)