diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts index 32ff58f458..f982dd3a14 100644 --- a/lib/node-package-manager.ts +++ b/lib/node-package-manager.ts @@ -63,7 +63,9 @@ export class NodePackageManager implements INodePackageManager { } var incrementedVersion = semver.inc(currentVersion, constants.ReleaseType.MINOR); - packageName = packageName + "@" + "<" + incrementedVersion; + if(packageName.indexOf("@") < 0) { + packageName = packageName + "@<" + incrementedVersion; + } this.$logger.trace("Installing", packageName); var future = new Future(); diff --git a/lib/options.ts b/lib/options.ts index dcb9e8c015..c187f22c0d 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -11,7 +11,7 @@ var knownOpts:any = { "appid" : String, "copy-from": String, "link-to": String, - "release": String, + "release": Boolean, "device": Boolean, "emulator": Boolean, "version": Boolean, diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 43a1698922..8ec562a0b0 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1,5 +1,6 @@ /// +import Future = require("fibers/future"); import path = require("path"); import shell = require("shelljs"); import util = require("util"); @@ -86,9 +87,16 @@ class IOSProjectService implements IPlatformProjectService { return (() => { var appSourceDirectory = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME); var appDestinationDirectory = path.join(platformData.projectRoot, this.$projectData.projectName); + var resDirectory = path.join(platformData.projectRoot, this.$projectData.projectName, "Resources", "icons"); shell.cp("-r", path.join(appSourceDirectory, "*"), appDestinationDirectory); + var appResourcesDirectoryPath = path.join(appDestinationDirectory, constants.APP_RESOURCES_FOLDER_NAME); + if (this.$fs.exists(appResourcesDirectoryPath).wait()) { + shell.cp("-r", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), resDirectory); + this.$fs.deleteDirectory(appResourcesDirectoryPath).wait(); + } + return appDestinationDirectory; }).future()(); } @@ -120,8 +128,7 @@ class IOSProjectService implements IPlatformProjectService { ]); } - var childProcess = this.$childProcess.spawn("xcodebuild", args, {cwd: options, stdio: 'inherit'}); - this.$fs.futureFromEvent(childProcess, "exit").wait(); + this.spawn("xcodebuild", args, "exit", {cwd: options, stdio: 'inherit'}).wait(); if(options.device) { var buildOutputPath = path.join(projectRoot, "build", options.device ? "device" : "emulator"); @@ -134,12 +141,29 @@ class IOSProjectService implements IPlatformProjectService { "-o", path.join(buildOutputPath, this.$projectData.projectName + ".ipa") ]; - var childProcess = this.$childProcess.spawn("xcrun", xcrunArgs, {cwd: options, stdio: 'inherit'}); - this.$fs.futureFromEvent(childProcess, "exit").wait(); + this.spawn("xcrun", xcrunArgs, "exit", {cwd: options, stdio: 'inherit'}).wait(); } }).future()(); } + private spawn(command: string, args: string[], event: string, options?: any): IFuture { // event should be exit or close + var future = new Future(); + var childProcess = this.$childProcess.spawn(command, args, options); + childProcess.once(event, () => { + var args = _.toArray(arguments); + var statusCode = args[0]; + var signal = args[1]; + + if(statusCode !== 0) { + future.throw(util.format("Command %s exited with code %s", command, statusCode)); + } else { + future.return(); + } + }); + + return future; + } + private replaceFileContent(file: string): IFuture { return (() => { var fileContent = this.$fs.readText(file).wait(); diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 614b32550b..71a22b4708 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -104,7 +104,7 @@ export class PlatformService implements IPlatformService { // Need to remove unneeded node_modules folder // One level up is the runtime module and one above is the node_modules folder. - this.$fs.deleteDirectory(path.join("../", frameworkDir)).wait(); + this.$fs.deleteDirectory(path.join(frameworkDir, "../../")).wait(); platformData.platformProjectService.interpolateData(platformData.projectRoot).wait(); platformData.platformProjectService.afterCreateProject(platformData.projectRoot).wait(); @@ -141,8 +141,17 @@ export class PlatformService implements IPlatformService { var appFilesLocation = platformProjectService.prepareProject(platformData).wait(); - this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, constants.APP_FOLDER_NAME))).wait(); - this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, constants.TNS_MODULES_FOLDER_NAME))).wait(); + var appDirectoryPath = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME); + var contents = this.$fs.readDirectory(appDirectoryPath).wait(); + + _.each(contents, d => { + var fsStat = this.$fs.getFsStats(path.join(appDirectoryPath, d)).wait(); + if(fsStat.isDirectory() && d !== constants.APP_RESOURCES_FOLDER_NAME) { + this.processPlatformSpecificFiles(platform, helpers.enumerateFilesInDirectorySync(path.join(appFilesLocation, d))).wait(); + } + }); + + this.$logger.out("Project successfully prepared"); }).future()(); }