Skip to content

Commit 85d46e2

Browse files
Merge pull request #3642 from NativeScript/vladimirov/merge-rel-master
chore: Merge release in master
2 parents 8bb96c3 + b1953f2 commit 85d46e2

9 files changed

+52
-18
lines changed

lib/commands/update-platform.ts

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class UpdatePlatformCommand implements ICommand {
2525

2626
for (const arg of args) {
2727
const [ platform, versionToBeInstalled ] = arg.split("@");
28-
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
2928
const argsToCheckEnvironmentRequirements: string[] = [ platform ];
3029
// If version is not specified, we know the command will install the latest compatible Android runtime.
3130
// The latest compatible Android runtime supports Java version, so we do not need to pass it here.

lib/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ export class ProjectTemplateErrors {
205205
export class Hooks {
206206
public static createProject = "createProject";
207207
}
208+
209+
export const PACKAGE_PLACEHOLDER_NAME = "__PACKAGE__";

lib/services/android-debug-service.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,27 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
1414
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery,
1515
private $androidProcessService: Mobile.IAndroidProcessService,
1616
private $net: INet,
17-
private $projectDataService: IProjectDataService) {
17+
private $projectDataService: IProjectDataService,
18+
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
1819
super(device, $devicesService);
1920
}
2021

2122
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
2223
this._packageName = debugData.applicationIdentifier;
23-
return debugOptions.emulator
24-
? this.debugOnEmulator(debugData, debugOptions)
25-
: this.debugOnDevice(debugData, debugOptions);
24+
const result = debugOptions.emulator
25+
? await this.debugOnEmulator(debugData, debugOptions)
26+
: await this.debugOnDevice(debugData, debugOptions);
27+
28+
if (!debugOptions.justlaunch) {
29+
const pid = await this.$androidProcessService.getAppProcessId(debugData.deviceIdentifier, debugData.applicationIdentifier);
30+
if (pid) {
31+
this.$deviceLogProvider.setApplicationPidForDevice(debugData.deviceIdentifier, pid);
32+
const device = await this.$devicesService.getDevice(debugData.deviceIdentifier);
33+
await device.openDeviceLogStream();
34+
}
35+
}
36+
37+
return result;
2638
}
2739

2840
public async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void> {

lib/services/android-project-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
256256

257257
try {
258258
// will replace applicationId in app/App_Resources/Android/app.gradle if it has not been edited by the user
259-
shell.sed('-i', /__PACKAGE__/, projectData.projectId, projectData.appGradlePath);
259+
const appGradleContent = this.$fs.readText(projectData.appGradlePath);
260+
if (appGradleContent.indexOf(constants.PACKAGE_PLACEHOLDER_NAME) !== -1) {
261+
shell.sed('-i', new RegExp(constants.PACKAGE_PLACEHOLDER_NAME), projectData.projectId, projectData.appGradlePath);
262+
}
260263
} catch (e) {
261264
this.$logger.warn(`\n${e}.\nCheck if you're using an outdated template and update it.`);
262265
}

lib/services/ios-debug-service.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
2929
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
3030
private $processService: IProcessService,
3131
private $socketProxyFactory: ISocketProxyFactory,
32-
private $projectDataService: IProjectDataService) {
32+
private $projectDataService: IProjectDataService,
33+
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
3334
super(device, $devicesService);
3435
this.$processService.attachToProcessExitSignals(this, this.debugStop);
3536
this.$socketProxyFactory.on(CONNECTION_ERROR_EVENT_NAME, (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e));
@@ -40,8 +41,6 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
4041
}
4142

4243
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
43-
await this.device.openDeviceLogStream();
44-
4544
if (debugOptions.debugBrk && debugOptions.start) {
4645
this.$errors.failWithoutHelp("Expected exactly one of the --debug-brk or --start options.");
4746
}
@@ -50,6 +49,20 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
5049
debugOptions.emulator = true;
5150
}
5251

52+
if (!debugOptions.justlaunch) {
53+
let projectName = debugData.projectName;
54+
if (!projectName && debugData.projectDir) {
55+
const projectData = this.$projectDataService.getProjectData(debugData.projectDir);
56+
projectName = projectData.projectName;
57+
}
58+
59+
if (projectName) {
60+
this.$deviceLogProvider.setProjectNameForDevice(debugData.deviceIdentifier, projectName);
61+
}
62+
63+
await this.device.openDeviceLogStream();
64+
}
65+
5366
if (debugOptions.emulator) {
5467
if (debugOptions.start) {
5568
return this.emulatorStart(debugData, debugOptions);
@@ -108,7 +121,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
108121

109122
private async emulatorDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
110123
const args = debugOptions.debugBrk ? "--nativescript-debug-brk" : "--nativescript-debug-start";
111-
const launchResult = await this.$iOSEmulatorServices.runApplicationOnEmulator(debugData.pathToAppPackage, {
124+
const launchResult = await this.$iOSEmulatorServices.runApplicationOnEmulator(debugData.pathToAppPackage, {
112125
waitForDebugger: true,
113126
captureStdin: true,
114127
args: args,

npm-shrinkwrap.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"gaze": "1.1.0",
4242
"iconv-lite": "0.4.11",
4343
"inquirer": "0.9.0",
44-
"ios-device-lib": "0.4.12",
44+
"ios-device-lib": "0.4.13",
4545
"ios-mobileprovision-finder": "1.0.10",
4646
"ios-sim-portable": "3.4.3",
4747
"jimp": "0.2.28",

test/services/android-debug-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class AndroidDebugServiceInheritor extends AndroidDebugService {
1212
$androidDeviceDiscovery: Mobile.IDeviceDiscovery,
1313
$androidProcessService: Mobile.IAndroidProcessService,
1414
$net: INet,
15-
$projectDataService: IProjectDataService) {
16-
super(<any>{}, $devicesService, $errors, $logger, $androidDeviceDiscovery, $androidProcessService, $net, $projectDataService);
15+
$projectDataService: IProjectDataService,
16+
$deviceLogProvider: Mobile.IDeviceLogProvider) {
17+
super(<any>{}, $devicesService, $errors, $logger, $androidDeviceDiscovery, $androidProcessService, $net, $projectDataService, $deviceLogProvider);
1718
}
1819

1920
public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
@@ -30,6 +31,7 @@ const createTestInjector = (): IInjector => {
3031
testInjector.register("androidProcessService", {});
3132
testInjector.register("net", {});
3233
testInjector.register("projectDataService", {});
34+
testInjector.register("deviceLogProvider", {});
3335

3436
return testInjector;
3537
};

test/services/ios-debug-service.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ class IOSDebugServiceInheritor extends IOSDebugService {
2020
$processService: IProcessService,
2121
$socketProxyFactory: ISocketProxyFactory,
2222
$net: INet,
23-
$projectDataService: IProjectDataService) {
23+
$projectDataService: IProjectDataService,
24+
$deviceLogProvider: Mobile.IDeviceLogProvider) {
2425
super(<any>{}, $devicesService, $platformService, $iOSEmulatorServices, $childProcess, $hostInfo, $logger, $errors,
25-
$npmInstallationManager, $iOSDebuggerPortService, $iOSNotification, $iOSSocketRequestExecutor, $processService, $socketProxyFactory, $projectDataService);
26+
$npmInstallationManager, $iOSDebuggerPortService, $iOSNotification, $iOSSocketRequestExecutor, $processService,
27+
$socketProxyFactory, $projectDataService, $deviceLogProvider);
2628
}
2729

2830
public getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
@@ -58,6 +60,7 @@ const createTestInjector = (): IInjector => {
5860

5961
testInjector.register("projectDataService", {});
6062
testInjector.register("iOSDebuggerPortService", {});
63+
testInjector.register("deviceLogProvider", {});
6164

6265
return testInjector;
6366
};

0 commit comments

Comments
 (0)