From 45cef4117e5bc1d2f84b583ca502cad72f8bea48 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Tue, 9 May 2017 09:36:52 +0300 Subject: [PATCH 1/3] Pass correct args to ios-sim-portable's stopApplication (#2778) When Xcode 8 or later is installed, ios-sim-portable will spawn `xcrun simctl terminate ` in order to stop the application. For earlier version the command for stopping the app is `killall `. So pass correct args to the method. Update ios-sim-portable, where the change is implemented. --- lib/commands/debug.ts | 11 +++-------- lib/common | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index e0ac47dd3a..2a026f0bb0 100644 --- a/lib/commands/debug.ts +++ b/lib/commands/debug.ts @@ -6,7 +6,6 @@ export abstract class DebugPlatformCommand implements ICommand { constructor(private debugService: IPlatformDebugService, private $devicesService: Mobile.IDevicesService, private $injector: IInjector, - private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $config: IConfiguration, private $usbLiveSyncService: ILiveSyncService, private $debugDataService: IDebugDataService, @@ -49,11 +48,7 @@ export abstract class DebugPlatformCommand implements ICommand { await this.debugService.debugStop(); let applicationId = deviceAppData.appIdentifier; - if (deviceAppData.device.isEmulator && deviceAppData.platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) { - applicationId = projectData.projectName; - } - - await deviceAppData.device.applicationManager.stopApplication(applicationId); + await deviceAppData.device.applicationManager.stopApplication(applicationId, projectData.projectName); const buildConfig: IBuildConfig = _.merge({ buildForDevice: !deviceAppData.device.isEmulator }, deployOptions); debugData.pathToAppPackage = this.$platformService.lastOutputPath(this.debugService.platform, buildConfig, projectData); @@ -102,7 +97,7 @@ export class DebugIOSCommand extends DebugPlatformCommand { $projectData: IProjectData, $platformsData: IPlatformsData, $iosDeviceOperations: IIOSDeviceOperations) { - super($iOSDebugService, $devicesService, $injector, $devicePlatformsConstants, $config, $usbLiveSyncService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger); + super($iOSDebugService, $devicesService, $injector, $config, $usbLiveSyncService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger); // Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket. // In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket. // That's why the `$ tns debug ios --justlaunch` command will not release the terminal. @@ -136,7 +131,7 @@ export class DebugAndroidCommand extends DebugPlatformCommand { $options: IOptions, $projectData: IProjectData, $platformsData: IPlatformsData) { - super($androidDebugService, $devicesService, $injector, $devicePlatformsConstants, $config, $usbLiveSyncService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger); + super($androidDebugService, $devicesService, $injector, $config, $usbLiveSyncService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger); } public async canExecute(args: string[]): Promise { diff --git a/lib/common b/lib/common index b96484eb79..a6128811a7 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit b96484eb79704a84a6b2e3f94376072ac77065d8 +Subproject commit a6128811a7416268b98aa73023cf725b80348ff4 diff --git a/package.json b/package.json index 25c695373e..b0ff51b42e 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "inquirer": "0.9.0", "ios-device-lib": "0.4.1", "ios-mobileprovision-finder": "1.0.9", - "ios-sim-portable": "~2.0.0", + "ios-sim-portable": "~3.0.0", "lockfile": "1.0.1", "lodash": "4.13.1", "log4js": "1.0.1", From e1333808154317b5e1f213262495d4bf101edb96 Mon Sep 17 00:00:00 2001 From: Dimitar Kerezov Date: Tue, 9 May 2017 10:55:34 +0300 Subject: [PATCH 2/3] Set correct exit code upon ucaught exception (#2777) --- lib/common | 2 +- lib/nativescript-cli.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common b/lib/common index a6128811a7..e5eba381ab 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit a6128811a7416268b98aa73023cf725b80348ff4 +Subproject commit e5eba381ab3c27838fbfe678575d0510b42b9675 diff --git a/lib/nativescript-cli.ts b/lib/nativescript-cli.ts index 143c5268d5..1f30074c49 100644 --- a/lib/nativescript-cli.ts +++ b/lib/nativescript-cli.ts @@ -3,7 +3,7 @@ import * as shelljs from "shelljs"; shelljs.config.silent = true; shelljs.config.fatal = true; import { installUncaughtExceptionListener } from "./common/errors"; -installUncaughtExceptionListener(process.exit); +installUncaughtExceptionListener(process.exit.bind(process, ErrorCodes.UNCAUGHT)); import { settlePromises } from "./common/helpers"; From 6ab0cfe352937657dd751e3f868f557dff3a98d8 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Tue, 9 May 2017 20:15:35 +0300 Subject: [PATCH 3/3] Fix installation of tns-core-modules during project creation (#2790) CLI tries to install `tns-core-modules` during project creation. In case the template does not have `tns-core-modules` in it, CLI will install latest version of `tns-core-modules` which may (and most probably is) be incompatible with the runtime and other dependencies of the project. In such cases ensure the CLI installs version of tns-core-modules that matches its own version, i.e. when CLI is 2.5.2, it should install latest 2.5.x core modules. Also ensure exact versions are installed and persisted by `npmInstallationManager`. --- lib/npm-installation-manager.ts | 2 +- lib/services/project-service.ts | 11 +++++++---- test/project-service.ts | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/npm-installation-manager.ts b/lib/npm-installation-manager.ts index d295cec3db..1fc8015910 100644 --- a/lib/npm-installation-manager.ts +++ b/lib/npm-installation-manager.ts @@ -108,7 +108,7 @@ export class NpmInstallationManager implements INpmInstallationManager { packageName = packageName + (version ? `@${version}` : ""); - let npmOptions: any = { silent: true }; + let npmOptions: any = { silent: true, "save-exact": true }; if (dependencyType) { npmOptions[dependencyType] = true; diff --git a/lib/services/project-service.ts b/lib/services/project-service.ts index 150430e873..9bc4b1ba25 100644 --- a/lib/services/project-service.ts +++ b/lib/services/project-service.ts @@ -14,7 +14,8 @@ export class ProjectService implements IProjectService { private $projectHelper: IProjectHelper, private $projectNameService: IProjectNameService, private $projectTemplatesService: IProjectTemplatesService, - private $staticConfig: IStaticConfig) { } + private $staticConfig: IStaticConfig, + private $npmInstallationManager: INpmInstallationManager) { } @exported("projectService") public async createProject(projectOptions: IProjectSettings): Promise { @@ -50,10 +51,12 @@ export class ProjectService implements IProjectService { await this.ensureAppResourcesExist(projectDir); - let packageName = constants.TNS_CORE_MODULES_NAME; - await this.$npm.install(packageName, projectDir, { save: true, "save-exact": true }); - let templatePackageJsonData = this.getDataFromJson(templatePath); + + if (!(templatePackageJsonData && templatePackageJsonData.dependencies && templatePackageJsonData.dependencies[constants.TNS_CORE_MODULES_NAME])) { + await this.$npmInstallationManager.install(constants.TNS_CORE_MODULES_NAME, projectDir, { dependencyType: "save" }); + } + this.mergeProjectAndTemplateProperties(projectDir, templatePackageJsonData); //merging dependencies from template (dev && prod) this.removeMergedDependencies(projectDir, templatePackageJsonData); diff --git a/test/project-service.ts b/test/project-service.ts index a4bac957e1..8a1c7b0ad4 100644 --- a/test/project-service.ts +++ b/test/project-service.ts @@ -114,7 +114,7 @@ class ProjectIntegrationTest { this.testInjector.register("fs", FileSystem); this.testInjector.register("projectDataService", ProjectDataServiceLib.ProjectDataService); this.testInjector.register("staticConfig", StaticConfig); - this.testInjector.register("analyticsService", { track: async () => undefined }); + this.testInjector.register("analyticsService", { track: async (): Promise => undefined }); this.testInjector.register("npmInstallationManager", NpmInstallationManager); this.testInjector.register("npm", NpmLib.NodePackageManager); @@ -130,6 +130,7 @@ class ProjectIntegrationTest { return dummyString; } }); + this.testInjector.register("npmInstallationManager", NpmInstallationManager); } } @@ -471,6 +472,7 @@ describe("Project Service Tests", () => { testInjector.register("projectTemplatesService", {}); testInjector.register("staticConfig", {}); testInjector.register("projectHelper", {}); + testInjector.register("npmInstallationManager", {}); return testInjector; };