Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
fixing output copy to resolve globs before attempting copy. bump vers…
Browse files Browse the repository at this point in the history
…iosn
  • Loading branch information
ryuyu committed May 10, 2016
1 parent 670f29e commit 9220fa8
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 99 deletions.
192 changes: 98 additions & 94 deletions Tasks/CordovaBuild/lib/cordova-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,34 @@ var deleteKeychain, // Command to delete OSX keychain if needed
processInputs() // Process inputs to task
.then(execBuild) // Run main Cordova build via taco-team-build
.then(function () {
return targetEmulator ? 0 : teambuild.packageProject(platform); // Package apps if configured
})
return targetEmulator ? 0 : teambuild.packageProject(platform); // Package apps if configured
})
.then(copyToOutputFolder)
.fail(function (err) {
var promise = deleteKeychain ? deleteKeychain() : Q(0); // Delete temp keychain if created
if (deleteProfile) { // Delete installed profile only if flag is set
promise = promise.then(function (code) {
return deleteProfile();
});
}
var promise = deleteKeychain ? deleteKeychain() : Q(0); // Delete temp keychain if created
if (deleteProfile) { // Delete installed profile only if flag is set
promise = promise.then(function (code) {
return deleteProfile();
});
}

console.error(err);
return promise.then(function () {
process.exit(1);
});
})
console.error(err);
return promise.then(function () {
process.exit(1);
});
})
.done(function (code) {
process.env['DEVELOPER_DIR'] = origXcodeDeveloperDir; // Return to original developer dir if set
var promise = deleteKeychain ? deleteKeychain() : Q(0); // Delete temp keychain if created
if (deleteProfile) { // Delete installed profile only if flag is set
promise = promise.then(function (code) {
return deleteProfile();
process.env['DEVELOPER_DIR'] = origXcodeDeveloperDir; // Return to original developer dir if set
var promise = deleteKeychain ? deleteKeychain() : Q(0); // Delete temp keychain if created
if (deleteProfile) { // Delete installed profile only if flag is set
promise = promise.then(function (code) {
return deleteProfile();
});
}
return promise.then(function () {
process.exit(code);
});
}
return promise.then(function () {
process.exit(code);
});
});

// Process VSO task inputs and get ready to build
function processInputs() {
Expand Down Expand Up @@ -162,18 +162,18 @@ function iosIdentity(code) {

return xcutils.determineIdentity(input)
.then(function (result) {
console.log('determineIdentity result ' + JSON.stringify(result));
if (result.identity) {
iosXcConfig += 'CODE_SIGN_IDENTITY=' + result.identity + '\n';
iosXcConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*]=' + result.identity + '\n';
} else {
console.log('No explicit signing identity specified in task.')
}
if (result.keychain) {
iosXcConfig += 'OTHER_CODE_SIGN_FLAGS=--keychain=' + result.keychain + '\n';
}
deleteKeychain = result.deleteCommand;
});
console.log('determineIdentity result ' + JSON.stringify(result));
if (result.identity) {
iosXcConfig += 'CODE_SIGN_IDENTITY=' + result.identity + '\n';
iosXcConfig += 'CODE_SIGN_IDENTITY[sdk=iphoneos*]=' + result.identity + '\n';
} else {
console.log('No explicit signing identity specified in task.')
}
if (result.keychain) {
iosXcConfig += 'OTHER_CODE_SIGN_FLAGS=--keychain=' + result.keychain + '\n';
}
deleteKeychain = result.deleteCommand;
});
}

// Process VSO task inputs specific to iOS mobile provisioning profiles
Expand All @@ -187,12 +187,12 @@ function iosProfile(code) {

return xcutils.determineProfile(input)
.then(function (result) {
console.log('determineProfile result ' + JSON.stringify(result));
if (result.uuid) {
iosXcConfig += 'PROVISIONING_PROFILE=' + result.uuid + '\n';
}
deleteProfile = result.deleteCommand;
});
console.log('determineProfile result ' + JSON.stringify(result));
if (result.uuid) {
iosXcConfig += 'PROVISIONING_PROFILE=' + result.uuid + '\n';
}
deleteProfile = result.deleteCommand;
});
}

// Process VSO task inputs specific to Android
Expand Down Expand Up @@ -294,12 +294,16 @@ function copyToOutputFolder(code) {
}

sources.forEach(function (source) {
if (fileExistsSync(source.directory)) {
console.log('Copying ' + source.fullSource + ' to ' + configOutputDirectory);
// Workaround for shelljs 0.6.0 bug with cp, wildcards, and recursive option
// see https://github.com/shelljs/shelljs/issues/376 for more information
var options = "-" + (fs.existsSync(source.fullSource) && fs.statSync(source.fullSource).isDirectory ? "R" : "") + "f";
shelljs.cp(options, source.fullSource, configOutputDirectory);
var expandedList = glob.sync(source.fullSource);
console.log('Copying ' + source.fullSource + ' to ' + configOutputDirectory);
for (var file in expandedList) {
var testFileOrDirectory = expandedList[file];
if (fileExistsSync(testFileOrDirectory)) {
// Workaround for shelljs 0.6.0 bug with cp, wildcards, and recursive option
// see https://github.com/shelljs/shelljs/issues/376 for more information
var options = "-" + (fs.existsSync(testFileOrDirectory) && fs.statSync(testFileOrDirectory).isDirectory ? "R" : "") + "f";
shelljs.cp(options, testFileOrDirectory, configOutputDirectory);
}
}
});

Expand Down Expand Up @@ -341,65 +345,65 @@ function execBuild(code) {
var updateXcconfig = (iosXcConfig != '');
return teambuild.setupCordova(cordovaConfig)
.then(function (cordova) {
// Add update Xcconfig hook if needed
if (updateXcconfig) {
console.log('Adding Xcconfig update hook')
cordova.on('before_compile', writeVsoXcconfig)
}
// Add update Xcconfig hook if needed
if (updateXcconfig) {
console.log('Adding Xcconfig update hook')
cordova.on('before_compile', writeVsoXcconfig)
}

return teambuild.getNpmVersionFromConfig(cordovaConfig).then(function (cordovaVersion) {
if (antProperties.override) {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '5.0.0')) {
console.log('WARN: Cordova versions < 5.0.0 may see build option warnings when specifying Android signing options. These can be safely ignored and do not affect signing when building with Ant.');
return teambuild.getNpmVersionFromConfig(cordovaConfig).then(function (cordovaVersion) {
if (antProperties.override) {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '5.0.0')) {
console.log('WARN: Cordova versions < 5.0.0 may see build option warnings when specifying Android signing options. These can be safely ignored and do not affect signing when building with Ant.');
}

console.log('Adding ant.properties update hook')
cordova.on('before_compile', writeAntProperties)
}

console.log('Adding ant.properties update hook')
cordova.on('before_compile', writeAntProperties)
}
if (platform === 'android') {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '4.0.0')) {
// Special case: android on cordova versions earlier than v4.0.0 will
// actively fail the build if it encounters unexpected options
console.log('Stripping inapplicable arguments for android on cordova ' + cordovaVersion);
buildArgs = stripNewerAndroidArgs(buildArgs);
}

if (platform === 'android') {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '4.0.0')) {
// Special case: android on cordova versions earlier than v4.0.0 will
// actively fail the build if it encounters unexpected options
console.log('Stripping inapplicable arguments for android on cordova ' + cordovaVersion);
buildArgs = stripNewerAndroidArgs(buildArgs);
if (semver.valid(cordovaVersion) && semver.lte(cordovaVersion, '3.5.0-0.2.7')) {
// Special case: android on cordova versions 3.5.0-0.2.7 need
// "android" to be on the path, so make sure it is there
var currentPath = process.env['PATH'];
var androidHome = process.env['ANDROID_HOME'];
if (currentPath && androidHome && currentPath.indexOf(androidHome) === -1) {
console.log('Appending ANDROID_HOME to the current PATH');
process.env['PATH'] = currentPath + ';' + path.join(androidHome, 'tools');
}
}
}

if (semver.valid(cordovaVersion) && semver.lte(cordovaVersion, '3.5.0-0.2.7')) {
// Special case: android on cordova versions 3.5.0-0.2.7 need
// "android" to be on the path, so make sure it is there
var currentPath = process.env['PATH'];
var androidHome = process.env['ANDROID_HOME'];
if (currentPath && androidHome && currentPath.indexOf(androidHome) === -1) {
console.log('Appending ANDROID_HOME to the current PATH');
process.env['PATH'] = currentPath + ';' + path.join(androidHome, 'tools');
if (platform !== 'ios') {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '3.6.0')) {
// For cordova 3.5.0-0.2.7 or lower, we should remove the --device and --emulator
// flag on non-ios platforms, since they were otherwise unsupported
buildArgs = buildArgs.filter(function (arg) { return arg !== '--device' && arg !== '--emulator'; })
}
}
}

if (platform !== 'ios') {
if (semver.valid(cordovaVersion) && semver.lt(cordovaVersion, '3.6.0')) {
// For cordova 3.5.0-0.2.7 or lower, we should remove the --device and --emulator
// flag on non-ios platforms, since they were otherwise unsupported
buildArgs = buildArgs.filter(function (arg) { return arg !== '--device' && arg !== '--emulator'; })
return Q();
}).then(function () {
return teambuild.buildProject(platform, buildArgs)
}).fin(function () {
// Remove xcconfig hook
if (updateXcconfig) {
console.log('Removing Xcconfig update hook')
cordova.off('before_compile', writeVsoXcconfig)
}
}

return Q();
}).then(function () {
return teambuild.buildProject(platform, buildArgs)
}).fin(function () {
// Remove xcconfig hook
if (updateXcconfig) {
console.log('Removing Xcconfig update hook')
cordova.off('before_compile', writeVsoXcconfig)
}
if (antProperties.override) {
console.log('Removing ant.properties update hook')
cordova.off('before_compile', writeAntProperties)
}
if (antProperties.override) {
console.log('Removing ant.properties update hook')
cordova.off('before_compile', writeAntProperties)
}
});
});
});
}

function stripNewerAndroidArgs(args) {
Expand Down
4 changes: 2 additions & 2 deletions Tasks/CordovaBuild/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vsts-task-cordova-build",
"version": "1.2.0",
"version": "1.2.13",
"description": "A VSTS build task for building Cordova apps.",
"author": "Microsoft",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"minimatch": "^2.0.10",
"q": "^1.4.1",
"semver": "^5.0.3",
"shelljs": "^0.6.0",
"shelljs": "^0.7.0",
"taco-team-build": "^0.2.1",
"vsts-task-lib": "^0.6.2"
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/CordovaBuild/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"version": {
"Major": 1,
"Minor": 2,
"Patch": 9
"Patch": 13
},
"demands": [
"npm"
Expand Down
2 changes: 1 addition & 1 deletion mobiledevopscordovaextension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "cordova-extension",
"name": "Cordova Build",
"version": "1.3.7",
"version": "1.3.11",
"publisher": "ms-vsclient",
"description": "Streamline CI setup for your Apache Cordova, PhoneGap, Ionic, or Cordova CLI compatible app using a set of useful pre-defined build steps.",
"categories": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vsts-cordova-tasks",
"version": "1.3.0",
"version": "1.3.11",
"description": "A set of VSTS task for building Cordova apps.",
"author": "Microsoft",
"license": "MIT",
Expand Down

0 comments on commit 9220fa8

Please sign in to comment.