You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/08/29 22:57:18 UTC
git commit: asyncblock is better. explicitly checks out tag 2.1.0rc1
now after cloning libs.
Updated Branches:
refs/heads/cordova-client aa5803f46 -> 78df059e7
asyncblock is better. explicitly checks out tag 2.1.0rc1 now after cloning libs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/78df059e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/78df059e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/78df059e
Branch: refs/heads/cordova-client
Commit: 78df059e792fcbb03814ec89e82eb6cd21e39373
Parents: aa5803f
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Aug 29 13:57:08 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed Aug 29 13:57:08 2012 -0700
----------------------------------------------------------------------
src/platform.js | 116 +++++++++++++++++++++++++++++---------------------
src/plugin.js | 18 ++++----
src/util.js | 4 +-
3 files changed, 79 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/78df059e/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 5c4bf63..28cee54 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -1,39 +1,18 @@
var config_parser = require('./config_parser'),
- cordova_util = require('./util'),
- util = require('util'),
- fs = require('fs'),
- wrench = require('wrench'),
- rmrf = wrench.rmdirSyncRecursive,
- exec = require('child_process').exec,
- path = require('path');
+ cordova_util = require('./util'),
+ util = require('util'),
+ fs = require('fs'),
+ wrench = require('wrench'),
+ rmrf = wrench.rmdirSyncRecursive,
+ exec = require('child_process').exec,
+ path = require('path'),
+ asyncblock = require('asyncblock');
var repos = {
ios:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios.git',
android:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-android.git'
};
-// Creates a platform app using the ./bin/create scripts that exist in
-// each repo.
-// TODO: eventually refactor to allow multiple versions to be created.
-// Currently only checks out HEAD.
-function create(target, dir, cfg, callback) {
- // Check if it already exists.
- try {
- fs.lstatSync(dir);
- } catch(e) {
- // Doesn't exist, continue.
- var bin = path.join(__dirname, '..', 'lib', target, 'bin', 'create');
- var pkg = cfg.packageName();
- var name = cfg.name().replace(/\W/g,'_');
- var cmd = util.format('%s "%s" "%s" "%s"', bin, dir, pkg, name);
- exec(cmd, function(err, stderr, stdout) {
- if (err) {
- cfg.remove_platform(target);
- throw 'An error occured during creation of ' + target + ' sub-project. ' + err + ' ' + stderr;
- } else if (callback) callback();
- });
- }
-}
module.exports = function platform(command, target, callback) {
var projectRoot = cordova_util.isCordova(process.cwd());
@@ -54,28 +33,69 @@ module.exports = function platform(command, target, callback) {
} else return 'No platforms added. Use `cordova platform add <platform>`.';
break;
case 'add':
- // Add the platform to the config.xml
- cfg.add_platform(target);
+ asyncblock(function(flow) {
+ // Add the platform to the config.xml
+ cfg.add_platform(target);
+
+ var output = path.join(projectRoot, 'platforms', target);
+
+ // Do we have the cordova library for this platform?
+ if (!cordova_util.havePlatformLib(target)) {
+ // Shell out to git.
+ var outPath = path.join(__dirname, '..', 'lib', target);
+ var cmd = util.format('git clone %s %s', repos[target], outPath);
+
+ console.log('Cloning ' + repos[target] + ', this may take a while...');
+ exec(cmd, flow.set({
+ key:'cloning',
+ firstArgIsError:false,
+ responseFormat:['err', 'stdout', 'stderr']
+ }));
+ var buffers = flow.get('cloning');
+ if (buffers.err) {
+ cfg.remove_platform(target);
+ throw ('An error occured during git-clone of ' + repos[target] + '. ' + buffers.err);
+ }
+
+ // Check out the right version. Currently: 2.1.0rc1.
+ cmd = util.format('cd "%s" && git checkout 2.1.0rc1', outPath);
+ exec(cmd, flow.set({
+ key:'tagcheckout',
+ firstArgIsError:false,
+ responseFormat:['err', 'stdout', 'stderr']
+ }));
+ buffers = flow.get('tagcheckout');
+ if (buffers.err) {
+ cfg.remove_platform(target);
+ throw ('An error occured during git-checkout of ' + outPath + ' to tag 2.1.0rc1. ' + buffers.err);
+ }
+ }
- var output = path.join(projectRoot, 'platforms', target);
+ // Create a platform app using the ./bin/create scripts that exist in each repo.
+ // TODO: eventually refactor to allow multiple versions to be created.
+ // Check if output dir already exists.
+ try {
+ fs.lstatSync(output);
+ // TODO: this platform dir already exists. what do we do?
+ } catch(e) {
+ // Doesn't exist, continue.
+ var bin = path.join(__dirname, '..', 'lib', target, 'bin', 'create');
+ var pkg = cfg.packageName();
+ var name = cfg.name().replace(/\W/g,'_');
+ var command = util.format('%s "%s" "%s" "%s"', bin, output, pkg, name);
+ exec(command, flow.set({
+ key:'create',
+ firstArgIsError:false,
+ responseFormat:['err', 'stdout', 'stderr']
+ }));
- // Do we have the cordova library for this platform?
- if (!cordova_util.havePlatformLib(target)) {
- // Shell out to git.
- var outPath = path.join(__dirname, '..', 'lib', target);
- var cmd = util.format('git clone %s %s', repos[target], outPath);
-
- console.log('Cloning ' + repos[target] + ', this may take a while...');
- exec(cmd, function(err, stderr, stdout) {
- if (err) {
+ var bfrs = flow.get('create');
+ if (bfrs.err) {
cfg.remove_platform(target);
- throw 'An error occured during git-clone of ' + repos[target] + '. ' + err;
+ throw ('An error occured during creation of ' + target + ' sub-project. ' + bfrs.err);
}
- create(target, output, cfg, callback);
- });
- } else {
- create(target, output, cfg, callback);
- }
+ }
+ });
break;
case 'remove':
// Remove the platform from the config.xml
@@ -87,6 +107,6 @@ module.exports = function platform(command, target, callback) {
} catch(e) {}
break;
default:
- throw 'Unrecognized command "' + command + '". Use either `add`, `remove`, or `ls`.';
+ throw ('Unrecognized command "' + command + '". Use either `add`, `remove`, or `ls`.');
}
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/78df059e/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 46da082..bb6664f 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -1,13 +1,13 @@
-var cordova_util = require('./util'),
- util = require('util'),
- wrench = require('wrench'),
- cpr = wrench.copyDirSyncRecursive,
- fs = require('fs'),
- path = require('path'),
+var cordova_util = require('./util'),
+ util = require('util'),
+ wrench = require('wrench'),
+ cpr = wrench.copyDirSyncRecursive,
+ fs = require('fs'),
+ path = require('path'),
config_parser = require('./config_parser'),
- exec = require('child_process').exec,
- asyncblock = require('asyncblock'),
- ls = fs.readdirSync;
+ exec = require('child_process').exec,
+ asyncblock = require('asyncblock'),
+ ls = fs.readdirSync;
module.exports = function plugin(command, target, callback) {
var projectRoot = cordova_util.isCordova(process.cwd());
http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/78df059e/src/util.js
----------------------------------------------------------------------
diff --git a/src/util.js b/src/util.js
index b4c7b8f..46a7d8d 100644
--- a/src/util.js
+++ b/src/util.js
@@ -1,5 +1,5 @@
-var fs = require('fs'),
- path = require('path');
+var fs = require('fs'),
+ path = require('path');
module.exports = {
// Runs up the directory chain looking for a .cordova directory.