Skip to content

chore: Merge release in master #3642

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 8 commits into from
May 29, 2018
1 change: 0 additions & 1 deletion lib/commands/update-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class UpdatePlatformCommand implements ICommand {

for (const arg of args) {
const [ platform, versionToBeInstalled ] = arg.split("@");
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
const argsToCheckEnvironmentRequirements: string[] = [ platform ];
// If version is not specified, we know the command will install the latest compatible Android runtime.
// The latest compatible Android runtime supports Java version, so we do not need to pass it here.
Expand Down
2 changes: 2 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,5 @@ export class ProjectTemplateErrors {
export class Hooks {
public static createProject = "createProject";
}

export const PACKAGE_PLACEHOLDER_NAME = "__PACKAGE__";
20 changes: 16 additions & 4 deletions lib/services/android-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
private $androidDeviceDiscovery: Mobile.IDeviceDiscovery,
private $androidProcessService: Mobile.IAndroidProcessService,
private $net: INet,
private $projectDataService: IProjectDataService) {
private $projectDataService: IProjectDataService,
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
super(device, $devicesService);
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
this._packageName = debugData.applicationIdentifier;
return debugOptions.emulator
? this.debugOnEmulator(debugData, debugOptions)
: this.debugOnDevice(debugData, debugOptions);
const result = debugOptions.emulator
? await this.debugOnEmulator(debugData, debugOptions)
: await this.debugOnDevice(debugData, debugOptions);

if (!debugOptions.justlaunch) {
const pid = await this.$androidProcessService.getAppProcessId(debugData.deviceIdentifier, debugData.applicationIdentifier);
if (pid) {
this.$deviceLogProvider.setApplicationPidForDevice(debugData.deviceIdentifier, pid);
const device = await this.$devicesService.getDevice(debugData.deviceIdentifier);
await device.openDeviceLogStream();
}
}

return result;
}

public async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void> {
Expand Down
5 changes: 4 additions & 1 deletion lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject

try {
// will replace applicationId in app/App_Resources/Android/app.gradle if it has not been edited by the user
shell.sed('-i', /__PACKAGE__/, projectData.projectId, projectData.appGradlePath);
const appGradleContent = this.$fs.readText(projectData.appGradlePath);
if (appGradleContent.indexOf(constants.PACKAGE_PLACEHOLDER_NAME) !== -1) {
shell.sed('-i', new RegExp(constants.PACKAGE_PLACEHOLDER_NAME), projectData.projectId, projectData.appGradlePath);
}
} catch (e) {
this.$logger.warn(`\n${e}.\nCheck if you're using an outdated template and update it.`);
}
Expand Down
21 changes: 17 additions & 4 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
private $processService: IProcessService,
private $socketProxyFactory: ISocketProxyFactory,
private $projectDataService: IProjectDataService) {
private $projectDataService: IProjectDataService,
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
super(device, $devicesService);
this.$processService.attachToProcessExitSignals(this, this.debugStop);
this.$socketProxyFactory.on(CONNECTION_ERROR_EVENT_NAME, (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e));
Expand All @@ -40,8 +41,6 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
}

public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
await this.device.openDeviceLogStream();

if (debugOptions.debugBrk && debugOptions.start) {
this.$errors.failWithoutHelp("Expected exactly one of the --debug-brk or --start options.");
}
Expand All @@ -50,6 +49,20 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
debugOptions.emulator = true;
}

if (!debugOptions.justlaunch) {
let projectName = debugData.projectName;
if (!projectName && debugData.projectDir) {
const projectData = this.$projectDataService.getProjectData(debugData.projectDir);
projectName = projectData.projectName;
}

if (projectName) {
this.$deviceLogProvider.setProjectNameForDevice(debugData.deviceIdentifier, projectName);
}

await this.device.openDeviceLogStream();
}

if (debugOptions.emulator) {
if (debugOptions.start) {
return this.emulatorStart(debugData, debugOptions);
Expand Down Expand Up @@ -108,7 +121,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS

private async emulatorDebugBrk(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
const args = debugOptions.debugBrk ? "--nativescript-debug-brk" : "--nativescript-debug-start";
const launchResult = await this.$iOSEmulatorServices.runApplicationOnEmulator(debugData.pathToAppPackage, {
const launchResult = await this.$iOSEmulatorServices.runApplicationOnEmulator(debugData.pathToAppPackage, {
waitForDebugger: true,
captureStdin: true,
args: args,
Expand Down
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"gaze": "1.1.0",
"iconv-lite": "0.4.11",
"inquirer": "0.9.0",
"ios-device-lib": "0.4.12",
"ios-device-lib": "0.4.13",
"ios-mobileprovision-finder": "1.0.10",
"ios-sim-portable": "3.4.3",
"jimp": "0.2.28",
Expand Down
6 changes: 4 additions & 2 deletions test/services/android-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class AndroidDebugServiceInheritor extends AndroidDebugService {
$androidDeviceDiscovery: Mobile.IDeviceDiscovery,
$androidProcessService: Mobile.IAndroidProcessService,
$net: INet,
$projectDataService: IProjectDataService) {
super(<any>{}, $devicesService, $errors, $logger, $androidDeviceDiscovery, $androidProcessService, $net, $projectDataService);
$projectDataService: IProjectDataService,
$deviceLogProvider: Mobile.IDeviceLogProvider) {
super(<any>{}, $devicesService, $errors, $logger, $androidDeviceDiscovery, $androidProcessService, $net, $projectDataService, $deviceLogProvider);
}

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

return testInjector;
};
Expand Down
7 changes: 5 additions & 2 deletions test/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class IOSDebugServiceInheritor extends IOSDebugService {
$processService: IProcessService,
$socketProxyFactory: ISocketProxyFactory,
$net: INet,
$projectDataService: IProjectDataService) {
$projectDataService: IProjectDataService,
$deviceLogProvider: Mobile.IDeviceLogProvider) {
super(<any>{}, $devicesService, $platformService, $iOSEmulatorServices, $childProcess, $hostInfo, $logger, $errors,
$npmInstallationManager, $iOSDebuggerPortService, $iOSNotification, $iOSSocketRequestExecutor, $processService, $socketProxyFactory, $projectDataService);
$npmInstallationManager, $iOSDebuggerPortService, $iOSNotification, $iOSSocketRequestExecutor, $processService,
$socketProxyFactory, $projectDataService, $deviceLogProvider);
}

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

testInjector.register("projectDataService", {});
testInjector.register("iOSDebuggerPortService", {});
testInjector.register("deviceLogProvider", {});

return testInjector;
};
Expand Down