Skip to content

Commit 6c00599

Browse files
committed
Remove breaking change from debug data.
1 parent ad87f08 commit 6c00599

File tree

7 files changed

+22
-20
lines changed

7 files changed

+22
-20
lines changed

lib/commands/debug.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ export class DebugPlatformCommand implements ICommand {
2424
public async execute(args: string[]): Promise<void> {
2525
const debugOptions = <IDebugOptions>_.cloneDeep(this.$options.argv);
2626

27-
const debugData = this.$debugDataService.createDebugData(this.$projectData, this.$options);
28-
2927
await this.$platformService.trackProjectType(this.$projectData);
3028
const selectedDeviceForDebug = await this.getDeviceForDebug();
31-
debugData.deviceIdentifier = selectedDeviceForDebug.deviceInfo.identifier;
29+
30+
const debugData = this.$debugDataService.createDebugData(this.$projectData, {device: selectedDeviceForDebug.deviceInfo.identifier});
3231

3332
if (this.$options.start) {
3433
await this.$liveSyncService.printDebugInformation(await this.$debugService.debug(debugData, debugOptions));

lib/definitions/debug.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface IDebugData extends Mobile.IDeviceIdentifier {
55
/**
66
* Application identifier of the app that it will be debugged.
77
*/
8-
applicationIdentifier: IProjectIdentifier;
8+
applicationIdentifier: string;
99

1010
/**
1111
* Path to .app built for iOS Simulator.

lib/services/android-debug-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
1818
}
1919

2020
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
21-
this._packageName = debugData.applicationIdentifier.android;
21+
this._packageName = debugData.applicationIdentifier;
2222
return debugOptions.emulator
2323
? this.debugOnEmulator(debugData, debugOptions)
2424
: this.debugOnDevice(debugData, debugOptions);
2525
}
2626

2727
public async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void> {
2828
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
29-
const action = (device: Mobile.IAndroidDevice): Promise<void> => this.debugStartCore(debugData.applicationIdentifier.android, debugOptions);
29+
const action = (device: Mobile.IAndroidDevice): Promise<void> => this.debugStartCore(debugData.applicationIdentifier, debugOptions);
3030

3131
await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
3232
}
@@ -91,7 +91,7 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
9191

9292
await this.$devicesService.initialize({ platform: this.platform, deviceId: debugData.deviceIdentifier });
9393

94-
const action = (device: Mobile.IAndroidDevice): Promise<string> => this.debugCore(device, packageFile, debugData.applicationIdentifier.android, debugOptions);
94+
const action = (device: Mobile.IAndroidDevice): Promise<string> => this.debugCore(device, packageFile, debugData.applicationIdentifier, debugOptions);
9595

9696
const deviceActionResult = await this.$devicesService.execute(action, this.getCanExecuteAction(debugData.deviceIdentifier));
9797
return deviceActionResult[0].result;

lib/services/debug-data-service.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
export class DebugDataService implements IDebugDataService {
2+
constructor(
3+
private $devicesService: Mobile.IDevicesService
4+
) { }
25
public createDebugData(projectData: IProjectData, options: IDeviceIdentifier): IDebugData {
6+
const device = this.$devicesService.getDeviceByIdentifier(options.device);
7+
38
return {
4-
applicationIdentifier: projectData.projectIdentifiers,
9+
applicationIdentifier: projectData.projectIdentifiers[device.deviceInfo.platform.toLowerCase()],
510
projectDir: projectData.projectDir,
611
deviceIdentifier: options.device,
712
projectName: projectData.projectName

lib/services/debug-service.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ export class DebugService extends EventEmitter implements IDebugService {
3535
projectDir: debugData.projectDir
3636
});
3737

38-
const devicePlatform = device.deviceInfo.platform;
39-
40-
if (!(await device.applicationManager.isApplicationInstalled(debugData.applicationIdentifier[devicePlatform.toLowerCase()]))) {
41-
this.$errors.failWithoutHelp(`The application ${debugData.applicationIdentifier[devicePlatform.toLowerCase()]} is not installed on device with identifier ${debugData.deviceIdentifier}.`);
38+
if (!(await device.applicationManager.isApplicationInstalled(debugData.applicationIdentifier))) {
39+
this.$errors.failWithoutHelp(`The application ${debugData.applicationIdentifier} is not installed on device with identifier ${debugData.deviceIdentifier}.`);
4240
}
4341

4442
const debugOptions: IDebugOptions = _.cloneDeep(options);

lib/services/ios-debug-service.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
118118
waitForDebugger: true,
119119
captureStdin: true,
120120
args: args,
121-
appId: debugData.applicationIdentifier.ios,
121+
appId: debugData.applicationIdentifier,
122122
skipInstall: true
123123
});
124124

@@ -127,8 +127,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
127127

128128
lineStream.on('data', (line: NodeBuffer) => {
129129
const lineText = line.toString();
130-
if (lineText && _.startsWith(lineText, debugData.applicationIdentifier.ios)) {
131-
const pid = getPidFromiOSSimulatorLogs(debugData.applicationIdentifier.ios, lineText);
130+
if (lineText && _.startsWith(lineText, debugData.applicationIdentifier)) {
131+
const pid = getPidFromiOSSimulatorLogs(debugData.applicationIdentifier, lineText);
132132
if (!pid) {
133133
this.$logger.trace(`Line ${lineText} does not contain PID of the application ${debugData.applicationIdentifier}.`);
134134
return;
@@ -151,7 +151,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
151151
private async emulatorStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
152152
const result = await this.wireDebuggerClient(debugData, debugOptions);
153153

154-
const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier.ios);
154+
const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier);
155155

156156
const iOSEmulator = <Mobile.IiOSSimulatorService>this.$iOSEmulatorServices;
157157
await iOSEmulator.postDarwinNotification(attachRequestMessage);
@@ -172,7 +172,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
172172
};
173173

174174
const promisesResults = await Promise.all<any>([
175-
this.$platformService.startApplication(this.platform, runOptions, debugData.applicationIdentifier.ios),
175+
this.$platformService.startApplication(this.platform, runOptions, debugData.applicationIdentifier),
176176
this.debugBrkCore(device, debugData, debugOptions)
177177
]);
178178

@@ -184,7 +184,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
184184
}
185185

186186
private async debugBrkCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
187-
await this.$iOSSocketRequestExecutor.executeLaunchRequest(device.deviceInfo.identifier, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier.ios, debugOptions.debugBrk);
187+
await this.$iOSSocketRequestExecutor.executeLaunchRequest(device.deviceInfo.identifier, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier, debugOptions.debugBrk);
188188
return this.wireDebuggerClient(debugData, debugOptions, device);
189189
}
190190

@@ -196,7 +196,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
196196
}
197197

198198
private async deviceStartCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
199-
await this.$iOSSocketRequestExecutor.executeAttachRequest(device, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier.ios);
199+
await this.$iOSSocketRequestExecutor.executeAttachRequest(device, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier);
200200
return this.wireDebuggerClient(debugData, debugOptions, device);
201201
}
202202

test/services/debug-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("debugService", () => {
103103
describe("debug", () => {
104104
const getDebugData = (deviceIdentifier?: string): IDebugData => ({
105105
deviceIdentifier: deviceIdentifier || defaultDeviceIdentifier,
106-
applicationIdentifier: { ios: "org.nativescript.app1", android: "org.nativescript.app1"},
106+
applicationIdentifier: "org.nativescript.app1",
107107
projectDir: "/Users/user/app1",
108108
projectName: "app1"
109109
});

0 commit comments

Comments
 (0)