You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/03/27 22:57:16 UTC
[1/8] git commit: CB-6357 call_into_create: support no output
Repository: cordova-cli
Updated Branches:
refs/heads/master 22b14f4e7 -> 58cb274c7
CB-6357 call_into_create: support no output
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/39eabf8d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/39eabf8d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/39eabf8d
Branch: refs/heads/master
Commit: 39eabf8dd8423dacae425d2ed9035628e8006942
Parents: 40efd93
Author: Josh Soref <js...@blackberry.com>
Authored: Wed Mar 26 21:49:03 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:47 2014 -0400
----------------------------------------------------------------------
src/platform.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/39eabf8d/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 9eb5825..dc5f378 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -55,7 +55,11 @@ function add(hooks, projectRoot, targets, opts) {
return lazy_load.based_on_config(projectRoot, t)
.then(function(libDir) {
var template = config_json.lib && config_json.lib[t] && config_json.lib[t].template || null;
- return call_into_create(t, projectRoot, cfg, libDir, template);
+ var copts = null;
+ if ('spawnoutput' in opts) {
+ copts = opts.spawnoutput;
+ }
+ return call_into_create(t, projectRoot, cfg, libDir, template, copts);
}, function(err) {
throw new CordovaError('Unable to fetch platform ' + t + ': ' + err);
});
@@ -275,7 +279,7 @@ function createOverrides(projectRoot, target) {
};
// Returns a promise.
-function call_into_create(target, projectRoot, cfg, libDir, template_dir) {
+function call_into_create(target, projectRoot, cfg, libDir, template_dir, opts) {
var output = path.join(projectRoot, 'platforms', target);
// Check if output directory already exists.
@@ -309,7 +313,7 @@ function call_into_create(target, projectRoot, cfg, libDir, template_dir) {
if (template_dir) {
args.push(template_dir);
}
- return superspawn.spawn(bin, args, { stdio: 'inherit' })
+ return superspawn.spawn(bin, args, opts || { stdio: 'inherit' })
.then(function() {
return require('../cordova').raw.prepare(target);
})
[2/8] git commit: CB-6357 platform: provide exports for functions
Posted by st...@apache.org.
CB-6357 platform: provide exports for functions
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/40efd93b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/40efd93b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/40efd93b
Branch: refs/heads/master
Commit: 40efd93b3376854271f2bcb74c3c3a2fb52f81b3
Parents: 10d073b
Author: Josh Soref <js...@blackberry.com>
Authored: Mon Mar 24 17:30:46 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:47 2014 -0400
----------------------------------------------------------------------
src/platform.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/40efd93b/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 96add30..9eb5825 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -246,7 +246,7 @@ module.exports = function platform(command, targets) {
*
*/
-module.exports.supports = function(project_root, name) {
+function supports(project_root, name) {
// required parameters
if (!name) return Q.reject(new CordovaError('requires a platform name parameter'));
@@ -284,6 +284,7 @@ function call_into_create(target, projectRoot, cfg, libDir, template_dir) {
} else {
// Make sure we have minimum requirements to work with specified platform
events.emit('verbose', 'Checking if platform "' + target + '" passes minimum requirements...');
+ /* XXX this is calling the public symbol so that Jasmine Spy can attack it */
return module.exports.supports(projectRoot, target)
.then(function() {
events.emit('log', 'Creating ' + target + ' project...');
@@ -332,3 +333,10 @@ function call_into_create(target, projectRoot, cfg, libDir, template_dir) {
});
}
}
+
+module.exports.add = add;
+module.exports.remove = remove;
+module.exports.update = update;
+module.exports.check = check;
+module.exports.list = list;
+module.exports.supports = supports;
[4/8] git commit: CB-6357 minor style changes
Posted by st...@apache.org.
CB-6357 minor style changes
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/22e5826a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/22e5826a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/22e5826a
Branch: refs/heads/master
Commit: 22e5826a3c780f2b6cfcd4dfc6cf624e1073a2be
Parents: bdb34e6
Author: Josh Soref <js...@blackberry.com>
Authored: Wed Mar 26 23:55:02 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:48 2014 -0400
----------------------------------------------------------------------
src/platform.js | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/22e5826a/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 8a8c9f4..bd439b5 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -38,6 +38,9 @@ function getVersionFromScript(script, defaultValue) {
var versionPromise = Q(defaultValue);
if (fs.existsSync(script)) {
versionPromise = superspawn.spawn(script);
+ } else {
+ /* if you are here, it's probably because you're in Jasmine: fix your existsSync stub */
+ versionPromise = Q(defaultValue);
}
return versionPromise;
}
@@ -141,17 +144,10 @@ function check(hooks, projectRoot) {
Q.all(platforms_on_fs.map(function(p) {
var d = Q.defer();
add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
- .catch(function () {
- /* If a platform doesn't install, then we can't realistically suggest updating */
- d.resolve();
- }).then(function() {
+ .then(function() {
var d_avail = Q.defer(),
d_cur = Q.defer();
getVersionFromScript(path.join(scratch, 'platforms', p, 'cordova', 'version'), null)
- .catch(function () {
- /* Platform version script failed, we can't work with this */
- d_avail.resolve('');
- })
.then(function(avail) {
if (!avail) {
/* Platform version script was silent, we can't work with this */
@@ -159,6 +155,10 @@ function check(hooks, projectRoot) {
} else {
d_avail.resolve(avail);
}
+ })
+ .catch(function () {
+ /* Platform version script failed, we can't work with this */
+ d_avail.resolve('');
});
getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
.catch(function () {
@@ -178,6 +178,10 @@ function check(hooks, projectRoot) {
return '?';
})
.done();
+ })
+ .catch(function () {
+ /* If a platform doesn't install, then we can't realistically suggest updating */
+ d.resolve();
});
return d.promise;
})).then(function() {
[7/8] git commit: CB-6357 platform check: sort output
Posted by st...@apache.org.
CB-6357 platform check: sort output
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/69856ced
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/69856ced
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/69856ced
Branch: refs/heads/master
Commit: 69856ced27c10a89c82392b3226e84976cfaf73f
Parents: 4bc9e70
Author: Josh Soref <js...@blackberry.com>
Authored: Wed Mar 26 21:55:14 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:48 2014 -0400
----------------------------------------------------------------------
src/platform.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/69856ced/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 0470569..54b9dbf 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -185,7 +185,7 @@ function check(hooks, projectRoot) {
events._events = listeners;
shell.rm('-rf', scratch);
if (platformsText) {
- results = platformsText.filter(function (p) {return !!p}).join('\n');
+ results = platformsText.filter(function (p) {return !!p}).sort().join('\n');
}
if (!results) {
results = 'All platforms are up-to-date.';
[5/8] git commit: CB-6357 platform: fix indentation
Posted by st...@apache.org.
CB-6357 platform: fix indentation
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/bdb34e6b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/bdb34e6b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/bdb34e6b
Branch: refs/heads/master
Commit: bdb34e6b9a430536e1b4777f271349175f890491
Parents: 69856ce
Author: Josh Soref <js...@blackberry.com>
Authored: Wed Mar 26 21:56:44 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:48 2014 -0400
----------------------------------------------------------------------
src/platform.js | 336 +++++++++++++++++++++++++--------------------------
1 file changed, 168 insertions(+), 168 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bdb34e6b/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 54b9dbf..8a8c9f4 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -45,199 +45,199 @@ function getVersionFromScript(script, defaultValue) {
function add(hooks, projectRoot, targets, opts) {
var xml = cordova_util.projectConfig(projectRoot);
var cfg = new ConfigParser(xml);
- if (!targets || !targets.length) {
- return Q.reject(new CordovaError('No platform specified. Please specify a platform to add. See "platform list".'));
- }
- var config_json = config.read(projectRoot);
+ if (!targets || !targets.length) {
+ return Q.reject(new CordovaError('No platform specified. Please specify a platform to add. See "platform list".'));
+ }
+ var config_json = config.read(projectRoot);
- return hooks.fire('before_platform_add', opts)
- .then(function() {
- return targets.reduce(function(soFar, t) {
- return soFar.then(function() {
- return lazy_load.based_on_config(projectRoot, t)
- .then(function(libDir) {
- var template = config_json.lib && config_json.lib[t] && config_json.lib[t].template || null;
- var copts = null;
- if ('spawnoutput' in opts) {
- copts = opts.spawnoutput;
- }
- return call_into_create(t, projectRoot, cfg, libDir, template, copts);
- }, function(err) {
- throw new CordovaError('Unable to fetch platform ' + t + ': ' + err);
- });
- });
- }, Q());
- })
- .then(function() {
- return hooks.fire('after_platform_add', opts);
+ return hooks.fire('before_platform_add', opts)
+ .then(function() {
+ return targets.reduce(function(soFar, t) {
+ return soFar.then(function() {
+ return lazy_load.based_on_config(projectRoot, t)
+ .then(function(libDir) {
+ var template = config_json.lib && config_json.lib[t] && config_json.lib[t].template || null;
+ var copts = null;
+ if ('spawnoutput' in opts) {
+ copts = opts.spawnoutput;
+ }
+ return call_into_create(t, projectRoot, cfg, libDir, template, copts);
+ }, function(err) {
+ throw new CordovaError('Unable to fetch platform ' + t + ': ' + err);
+ });
});
+ }, Q());
+ })
+ .then(function() {
+ return hooks.fire('after_platform_add', opts);
+ });
};
function remove(hooks, projectRoot, targets, opts) {
- if (!targets || !targets.length) {
- return Q.reject(new CordovaError('No platform[s] specified. Please specify platform[s] to remove. See "platform list".'));
- }
- return hooks.fire('before_platform_rm', opts)
- .then(function() {
- targets.forEach(function(target) {
- shell.rm('-rf', path.join(projectRoot, 'platforms', target));
- var plugins_json = path.join(projectRoot, 'plugins', target + '.json');
- if (fs.existsSync(plugins_json)) shell.rm(plugins_json);
- });
- }).then(function() {
- return hooks.fire('after_platform_rm', opts);
- });
+ if (!targets || !targets.length) {
+ return Q.reject(new CordovaError('No platform[s] specified. Please specify platform[s] to remove. See "platform list".'));
+ }
+ return hooks.fire('before_platform_rm', opts)
+ .then(function() {
+ targets.forEach(function(target) {
+ shell.rm('-rf', path.join(projectRoot, 'platforms', target));
+ var plugins_json = path.join(projectRoot, 'plugins', target + '.json');
+ if (fs.existsSync(plugins_json)) shell.rm(plugins_json);
+ });
+ }).then(function() {
+ return hooks.fire('after_platform_rm', opts);
+ });
}
function update(hooks, projectRoot, targets, opts) {
- // Shell out to the update script provided by the named platform.
- if (!targets || !targets.length) {
- return Q.reject(new CordovaError('No platform specified. Please specify a platform to update. See "platform list".'));
- } else if (targets.length > 1) {
- return Q.reject(new CordovaError('Platform update can only be executed on one platform at a time.'));
- } else {
- var plat = targets[0];
- var platformPath = path.join(projectRoot, 'platforms', plat);
- var installed_platforms = cordova_util.listPlatforms(projectRoot);
- if (installed_platforms.indexOf(plat) < 0) {
- return Q.reject(new CordovaError('Platform "' + plat + '" is not installed. See "platform list".'));
- }
+ // Shell out to the update script provided by the named platform.
+ if (!targets || !targets.length) {
+ return Q.reject(new CordovaError('No platform specified. Please specify a platform to update. See "platform list".'));
+ } else if (targets.length > 1) {
+ return Q.reject(new CordovaError('Platform update can only be executed on one platform at a time.'));
+ } else {
+ var plat = targets[0];
+ var platformPath = path.join(projectRoot, 'platforms', plat);
+ var installed_platforms = cordova_util.listPlatforms(projectRoot);
+ if (installed_platforms.indexOf(plat) < 0) {
+ return Q.reject(new CordovaError('Platform "' + plat + '" is not installed. See "platform list".'));
+ }
- function copyCordovaJs() {
- var parser = new platforms[plat].parser(platformPath);
- var platform_www = path.join(platformPath, 'platform_www');
- shell.mkdir('-p', platform_www);
- shell.cp('-f', path.join(parser.www_dir(), 'cordova.js'), path.join(platform_www, 'cordova.js'));
- }
+ function copyCordovaJs() {
+ var parser = new platforms[plat].parser(platformPath);
+ var platform_www = path.join(platformPath, 'platform_www');
+ shell.mkdir('-p', platform_www);
+ shell.cp('-f', path.join(parser.www_dir(), 'cordova.js'), path.join(platform_www, 'cordova.js'));
+ }
- // First, lazy_load the latest version.
- return hooks.fire('before_platform_update', opts)
- .then(function() {
- return lazy_load.based_on_config(projectRoot, plat);
- }).then(function(libDir) {
- // Call the platform's update script.
- var script = path.join(libDir, 'bin', 'update');
- return superspawn.spawn(script, [platformPath], { stdio: 'inherit' })
- .then(function() {
- // Copy the new cordova.js from www -> platform_www.
- copyCordovaJs();
- // Leave it to the update script to log out "updated to v FOO".
- });
- });
- }
+ // First, lazy_load the latest version.
+ return hooks.fire('before_platform_update', opts)
+ .then(function() {
+ return lazy_load.based_on_config(projectRoot, plat);
+ }).then(function(libDir) {
+ // Call the platform's update script.
+ var script = path.join(libDir, 'bin', 'update');
+ return superspawn.spawn(script, [platformPath], { stdio: 'inherit' })
+ .then(function() {
+ // Copy the new cordova.js from www -> platform_www.
+ copyCordovaJs();
+ // Leave it to the update script to log out "updated to v FOO".
+ });
+ });
+ }
}
function check(hooks, projectRoot) {
- var platformsText = [],
- platforms_on_fs = cordova_util.listPlatforms(projectRoot),
- scratch = path.join(os.tmpdir(), "cordova-platform-check-"+Date.now()),
- listeners = events._events;
- events._events = {};
- var result = Q.defer();
- cordova.raw.create(scratch)
- .then(function () {
- var h = new hooker(scratch);
- // Acquire the version number of each platform we have installed, and output that too.
- Q.all(platforms_on_fs.map(function(p) {
- var d = Q.defer();
- add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
+ var platformsText = [],
+ platforms_on_fs = cordova_util.listPlatforms(projectRoot),
+ scratch = path.join(os.tmpdir(), "cordova-platform-check-"+Date.now()),
+ listeners = events._events;
+ events._events = {};
+ var result = Q.defer();
+ cordova.raw.create(scratch)
+ .then(function () {
+ var h = new hooker(scratch);
+ // Acquire the version number of each platform we have installed, and output that too.
+ Q.all(platforms_on_fs.map(function(p) {
+ var d = Q.defer();
+ add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
+ .catch(function () {
+ /* If a platform doesn't install, then we can't realistically suggest updating */
+ d.resolve();
+ }).then(function() {
+ var d_avail = Q.defer(),
+ d_cur = Q.defer();
+ getVersionFromScript(path.join(scratch, 'platforms', p, 'cordova', 'version'), null)
.catch(function () {
- /* If a platform doesn't install, then we can't realistically suggest updating */
- d.resolve();
- }).then(function() {
- var d_avail = Q.defer(),
- d_cur = Q.defer();
- getVersionFromScript(path.join(scratch, 'platforms', p, 'cordova', 'version'), null)
- .catch(function () {
- /* Platform version script failed, we can't work with this */
+ /* Platform version script failed, we can't work with this */
+ d_avail.resolve('');
+ })
+ .then(function(avail) {
+ if (!avail) {
+ /* Platform version script was silent, we can't work with this */
d_avail.resolve('');
- })
- .then(function(avail) {
- if (!avail) {
- /* Platform version script was silent, we can't work with this */
- d_avail.resolve('');
- } else {
- d_avail.resolve(avail);
- }
- });
- getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
- .catch(function () {
- d_cur.resolve('broken');
- }).then(function(v) {
- d_cur.resolve(v || '');
- });
- Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
- var m;
- if (avail && (!v || v == 'broken' || semver.gt(avail, v))) {
- m = p + ' @ ' + (v || 'unknown') + ' could be updated to: ' + avail;
- platformsText.push(m);
- }
- d.resolve(m);
- })
- .catch(function () {
- return '?';
- })
- .done();
+ } else {
+ d_avail.resolve(avail);
+ }
});
- return d.promise;
- })).then(function() {
- var results = '';
- events._events = listeners;
- shell.rm('-rf', scratch);
- if (platformsText) {
- results = platformsText.filter(function (p) {return !!p}).sort().join('\n');
- }
- if (!results) {
- results = 'All platforms are up-to-date.';
- }
- events.emit('results', results);
- result.resolve();
- })
- .done();
- }).catch(function (){
+ getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
+ .catch(function () {
+ d_cur.resolve('broken');
+ }).then(function(v) {
+ d_cur.resolve(v || '');
+ });
+ Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
+ var m;
+ if (avail && (!v || v == 'broken' || semver.gt(avail, v))) {
+ m = p + ' @ ' + (v || 'unknown') + ' could be updated to: ' + avail;
+ platformsText.push(m);
+ }
+ d.resolve(m);
+ })
+ .catch(function () {
+ return '?';
+ })
+ .done();
+ });
+ return d.promise;
+ })).then(function() {
+ var results = '';
events._events = listeners;
shell.rm('-rf', scratch);
+ if (platformsText) {
+ results = platformsText.filter(function (p) {return !!p}).sort().join('\n');
+ }
+ if (!results) {
+ results = 'All platforms are up-to-date.';
+ }
+ events.emit('results', results);
+ result.resolve();
})
.done();
- return result.promise;
+ }).catch(function (){
+ events._events = listeners;
+ shell.rm('-rf', scratch);
+ })
+ .done();
+ return result.promise;
}
function list(hooks, projectRoot) {
- var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
- return hooks.fire('before_platform_ls')
- .then(function() {
- // Acquire the version number of each platform we have installed, and output that too.
- return Q.all(platforms_on_fs.map(function(p) {
- return getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
- .then(function(v) {
- if (!v) return p;
- return p + ' ' + v;
- }, function(v) {
- return p + ' broken';
- });
- }));
- }).then(function(platformsText) {
- var results = 'Installed platforms: ' + platformsText.join(', ') + '\n';
- var available = ['android', 'blackberry10', 'firefoxos'];
- if (process.platform === 'darwin')
- available.push('ios');
- if (process.platform.slice(0, 3) === 'win') {
- available.push('wp7');
- available.push('wp8');
- available.push('windows8');
- }
- if (process.platform === 'linux')
- available.push('ubuntu');
+ var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
+ return hooks.fire('before_platform_ls')
+ .then(function() {
+ // Acquire the version number of each platform we have installed, and output that too.
+ return Q.all(platforms_on_fs.map(function(p) {
+ return getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
+ .then(function(v) {
+ if (!v) return p;
+ return p + ' ' + v;
+ }, function(v) {
+ return p + ' broken';
+ });
+ }));
+ }).then(function(platformsText) {
+ var results = 'Installed platforms: ' + platformsText.join(', ') + '\n';
+ var available = ['android', 'blackberry10', 'firefoxos'];
+ if (process.platform === 'darwin')
+ available.push('ios');
+ if (process.platform.slice(0, 3) === 'win') {
+ available.push('wp7');
+ available.push('wp8');
+ available.push('windows8');
+ }
+ if (process.platform === 'linux')
+ available.push('ubuntu');
- available = available.filter(function(p) {
- return platforms_on_fs.indexOf(p) < 0; // Only those not already installed.
- });
- results += 'Available platforms: ' + available.join(', ');
+ available = available.filter(function(p) {
+ return platforms_on_fs.indexOf(p) < 0; // Only those not already installed.
+ });
+ results += 'Available platforms: ' + available.join(', ');
- events.emit('results', results);
- }).then(function() {
- return hooks.fire('after_platform_ls');
- });
+ events.emit('results', results);
+ }).then(function() {
+ return hooks.fire('after_platform_ls');
+ });
}
// Returns a promise.
[8/8] git commit: Merge branch 'cb_6357' of
github.com:blackberry/cordova-cli
Posted by st...@apache.org.
Merge branch 'cb_6357' of github.com:blackberry/cordova-cli
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/58cb274c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/58cb274c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/58cb274c
Branch: refs/heads/master
Commit: 58cb274c74beb4584086053bd1cae6ff4c10976b
Parents: 22b14f4 22e5826
Author: Steven Gill <st...@gmail.com>
Authored: Thu Mar 27 14:51:36 2014 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Thu Mar 27 14:51:36 2014 -0700
----------------------------------------------------------------------
spec/platform.spec.js | 34 ++++-
src/platform.js | 373 ++++++++++++++++++++++++++-------------------
2 files changed, 249 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
[6/8] git commit: CB-6357 platform check - install each platform to
determine working + version number
Posted by st...@apache.org.
CB-6357 platform check - install each platform to determine working + version number
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4bc9e701
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4bc9e701
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4bc9e701
Branch: refs/heads/master
Commit: 4bc9e7017d61a5c3e02ba7a2d2037a5e4f21e38c
Parents: 39eabf8
Author: Josh Soref <js...@blackberry.com>
Authored: Wed Mar 26 10:43:21 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:48 2014 -0400
----------------------------------------------------------------------
spec/platform.spec.js | 34 +++++++++++++++---
src/platform.js | 87 ++++++++++++++++++++++++++++++++++------------
2 files changed, 93 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4bc9e701/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index 0ad2fee..65a22b7 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -172,6 +172,12 @@ describe('platform command', function() {
});
});
describe('`add`', function() {
+ beforeEach(function() {
+ supported_platforms.forEach(function(p) {
+ platforms[p].parser.check_requirements = function(){return Q();};
+ });
+ });
+
it('should shell out to specified platform\'s bin/create, using the version that is specified in platforms manifest', function(done) {
cordova.raw.platform('add', 'android').then(function() {
expect(spawn.mostRecentCall.args.join()).toMatch(/lib.android.cordova.\d.\d.\d[\d\-\w]*.bin.create/gi);
@@ -303,17 +309,17 @@ describe('platform command', function() {
current: {
uri: "https://localhost",
version: "3.3.0",
- parser: undefined
+ parser: function(){}
},
stale: {
uri: "https://localhost",
version: "3.3.0",
- parser: undefined
+ parser: function(){}
},
newer: {
uri: "https://localhost",
version: "3.3.0",
- parser: undefined
+ parser: function(){}
}
};
beforeEach(function() {
@@ -336,10 +342,22 @@ describe('platform command', function() {
});
});
it('check platforms current, stale, newer', function() {
- existsSync.andReturn(true);
+ existsSync.andCallFake(function(dir) {
+ if (/cordova-platform-check.*version/.test(dir)) {
+ return true;
+ }
+ if (/cordova-platform-check/.test(dir)) {
+ return false;
+ }
+ return true;
+ });
+ var create = spyOn(cordova.raw, 'create').andCallFake(function() { return Q() });
+
spawn.andCallFake(function(cmd) {
var out;
- if (/current/.test(cmd)) {
+ if (/cordova-platform-check/.test(cmd)) {
+ out = '3.3.0';
+ } else if (/current/.test(cmd)) {
out = '3.3.0';
} else if (/stale/.test(cmd)) {
out = '3.2.0';
@@ -387,6 +405,12 @@ describe('platform command', function() {
});
});
describe('add hooks', function() {
+ beforeEach(function() {
+ supported_platforms.forEach(function(p) {
+ platforms[p].parser.check_requirements = function(){return Q();};
+ });
+ });
+
it('should fire before and after hooks through the hooker module', function(done) {
cordova.raw.platform('add', 'android').then(function() {
expect(fire).toHaveBeenCalledWith('before_platform_add', {platforms:['android']});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4bc9e701/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index dc5f378..0470569 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -17,10 +17,12 @@
under the License.
*/
var config = require('./config'),
+ cordova = require('../cordova'),
cordova_util = require('./util'),
ConfigParser = require('./ConfigParser'),
util = require('util'),
fs = require('fs'),
+ os = require('os'),
path = require('path'),
hooker = require('./hooker'),
events = require('./events'),
@@ -126,39 +128,78 @@ function update(hooks, projectRoot, targets, opts) {
}
function check(hooks, projectRoot) {
- var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
- return hooks.fire('before_platform_ls')
- .then(function() {
- // Acquire the version number of each platform we have installed, and output that too.
- return Q.all(platforms_on_fs.map(function(p) {
- return getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
- .then(function(v) {
- if (!v) {
- return null;
- }
- var avail = platforms[p].version;
- if (semver.gt(avail, v)) {
- return p + ' @ ' + v + ' could be updated to: ' + avail;
+ var platformsText = [],
+ platforms_on_fs = cordova_util.listPlatforms(projectRoot),
+ scratch = path.join(os.tmpdir(), "cordova-platform-check-"+Date.now()),
+ listeners = events._events;
+ events._events = {};
+ var result = Q.defer();
+ cordova.raw.create(scratch)
+ .then(function () {
+ var h = new hooker(scratch);
+ // Acquire the version number of each platform we have installed, and output that too.
+ Q.all(platforms_on_fs.map(function(p) {
+ var d = Q.defer();
+ add(h, scratch, [p], {spawnoutput: {stdio: 'ignore'}})
+ .catch(function () {
+ /* If a platform doesn't install, then we can't realistically suggest updating */
+ d.resolve();
+ }).then(function() {
+ var d_avail = Q.defer(),
+ d_cur = Q.defer();
+ getVersionFromScript(path.join(scratch, 'platforms', p, 'cordova', 'version'), null)
+ .catch(function () {
+ /* Platform version script failed, we can't work with this */
+ d_avail.resolve('');
+ })
+ .then(function(avail) {
+ if (!avail) {
+ /* Platform version script was silent, we can't work with this */
+ d_avail.resolve('');
+ } else {
+ d_avail.resolve(avail);
}
- return '';
- }, function(v) {
- var avail = platforms[p].version;
- return p + ' @ broken could be updated to: ' + avail
});
- }));
- }).then(function(platformsText) {
+ getVersionFromScript(path.join(projectRoot, 'platforms', p, 'cordova', 'version'), null)
+ .catch(function () {
+ d_cur.resolve('broken');
+ }).then(function(v) {
+ d_cur.resolve(v || '');
+ });
+ Q.all([d_avail.promise, d_cur.promise]).spread(function (avail, v) {
+ var m;
+ if (avail && (!v || v == 'broken' || semver.gt(avail, v))) {
+ m = p + ' @ ' + (v || 'unknown') + ' could be updated to: ' + avail;
+ platformsText.push(m);
+ }
+ d.resolve(m);
+ })
+ .catch(function () {
+ return '?';
+ })
+ .done();
+ });
+ return d.promise;
+ })).then(function() {
var results = '';
+ events._events = listeners;
+ shell.rm('-rf', scratch);
if (platformsText) {
results = platformsText.filter(function (p) {return !!p}).join('\n');
}
if (!results) {
results = 'All platforms are up-to-date.';
}
-
events.emit('results', results);
- }).then(function() {
- return hooks.fire('after_platform_ls');
- });
+ result.resolve();
+ })
+ .done();
+ }).catch(function (){
+ events._events = listeners;
+ shell.rm('-rf', scratch);
+ })
+ .done();
+ return result.promise;
}
function list(hooks, projectRoot) {
[3/8] git commit: CB-6357 platform: Refactor into distinct functions
Posted by st...@apache.org.
CB-6357 platform: Refactor into distinct functions
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/10d073b4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/10d073b4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/10d073b4
Branch: refs/heads/master
Commit: 10d073b40f2e453702182aeadd70680adbc2b0ba
Parents: 55c278c
Author: Josh Soref <js...@blackberry.com>
Authored: Mon Mar 24 17:29:57 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Thu Mar 27 00:03:47 2014 -0400
----------------------------------------------------------------------
src/platform.js | 92 +++++++++++++++++++++++++++++-----------------------
1 file changed, 51 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/10d073b4/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index cd2d29a..96add30 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -40,36 +40,9 @@ function getVersionFromScript(script, defaultValue) {
return versionPromise;
}
-// Returns a promise.
-module.exports = function platform(command, targets) {
- var projectRoot = cordova_util.cdProjectRoot();
-
- var hooks = new hooker(projectRoot);
-
- if (arguments.length === 0) command = 'ls';
- if (targets) {
- if (!(targets instanceof Array)) targets = [targets];
- var err;
- targets.forEach(function(t) {
- if (!(t in platforms)) {
- err = new CordovaError('Platform "' + t + '" not recognized as a core cordova platform. See "platform list".');
- }
- });
- if (err) return Q.reject(err);
- } else {
- if (command == 'add' || command == 'rm') {
- return Q.reject(new CordovaError('You need to qualify `add` or `remove` with one or more platforms!'));
- }
- }
-
+function add(hooks, projectRoot, targets, opts) {
var xml = cordova_util.projectConfig(projectRoot);
var cfg = new ConfigParser(xml);
- var opts = {
- platforms:targets
- };
-
- switch(command) {
- case 'add':
if (!targets || !targets.length) {
return Q.reject(new CordovaError('No platform specified. Please specify a platform to add. See "platform list".'));
}
@@ -92,10 +65,9 @@ module.exports = function platform(command, targets) {
.then(function() {
return hooks.fire('after_platform_add', opts);
});
+};
- break;
- case 'rm':
- case 'remove':
+function remove(hooks, projectRoot, targets, opts) {
if (!targets || !targets.length) {
return Q.reject(new CordovaError('No platform[s] specified. Please specify platform[s] to remove. See "platform list".'));
}
@@ -109,10 +81,9 @@ module.exports = function platform(command, targets) {
}).then(function() {
return hooks.fire('after_platform_rm', opts);
});
+}
- break;
- case 'update':
- case 'up':
+function update(hooks, projectRoot, targets, opts) {
// Shell out to the update script provided by the named platform.
if (!targets || !targets.length) {
return Q.reject(new CordovaError('No platform specified. Please specify a platform to update. See "platform list".'));
@@ -148,8 +119,9 @@ module.exports = function platform(command, targets) {
});
});
}
- break;
- case 'check':
+}
+
+function check(hooks, projectRoot) {
var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
return hooks.fire('before_platform_ls')
.then(function() {
@@ -183,11 +155,9 @@ module.exports = function platform(command, targets) {
}).then(function() {
return hooks.fire('after_platform_ls');
});
+}
- break;
- case 'ls':
- case 'list':
- default:
+function list(hooks, projectRoot) {
var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
return hooks.fire('before_platform_ls')
.then(function() {
@@ -223,8 +193,48 @@ module.exports = function platform(command, targets) {
}).then(function() {
return hooks.fire('after_platform_ls');
});
+}
+
+// Returns a promise.
+module.exports = function platform(command, targets) {
+ var projectRoot = cordova_util.cdProjectRoot();
+
+ var hooks = new hooker(projectRoot);
+
+ if (arguments.length === 0) command = 'ls';
+ if (targets) {
+ if (!(targets instanceof Array)) targets = [targets];
+ var err;
+ targets.forEach(function(t) {
+ if (!(t in platforms)) {
+ err = new CordovaError('Platform "' + t + '" not recognized as a core cordova platform. See "platform list".');
+ }
+ });
+ if (err) return Q.reject(err);
+ } else {
+ if (command == 'add' || command == 'rm') {
+ return Q.reject(new CordovaError('You need to qualify `add` or `remove` with one or more platforms!'));
+ }
+ }
- break;
+ var opts = {
+ platforms:targets
+ };
+ switch(command) {
+ case 'add':
+ return add(hooks, projectRoot, targets, opts);
+ case 'rm':
+ case 'remove':
+ return remove(hooks, projectRoot, targets, opts);
+ case 'update':
+ case 'up':
+ return update(hooks, projectRoot, targets, opts);
+ case 'check':
+ return check(hooks, projectRoot);
+ case 'ls':
+ case 'list':
+ default:
+ return list(hooks, projectRoot);
}
};