Skip to content

Fixes and improvements #70

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 1 commit into from
Aug 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/node-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>();
Expand Down
2 changes: 1 addition & 1 deletion lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 28 additions & 4 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
///<reference path="../.d.ts"/>

import Future = require("fibers/future");
import path = require("path");
import shell = require("shelljs");
import util = require("util");
Expand Down Expand Up @@ -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<string>()();
}
Expand Down Expand Up @@ -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");
Expand All @@ -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<void>()();
}

private spawn(command: string, args: string[], event: string, options?: any): IFuture<void> { // event should be exit or close
var future = new Future<void>();
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<void> {
return (() => {
var fileContent = this.$fs.readText(file).wait();
Expand Down
15 changes: 12 additions & 3 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<void>()();
}
Expand Down