diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index 834c0eda31..7165a38905 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 b1d69ec132..6e4c95ebbf 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit b1d69ec132cd7fdc74ea86c7dcc791be0829107d +Subproject commit 6e4c95ebbfbf118c463f1e09f39505d5ceb8e48c 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"; diff --git a/lib/npm-installation-manager.ts b/lib/npm-installation-manager.ts index 0add11ef09..815533a3f2 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 bae198342f..f75f5b1d57 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,16 +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, - disableNpmInstall: false, - frameworkPath: null, - ignoreScripts: projectOptions.ignoreScripts - }); - 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/package.json b/package.json index 65babf004d..fb6610091f 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", 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; };