You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/09/25 17:54:48 UTC
[1/3] git commit: First pass
Updated Branches:
refs/heads/master cebd77692 -> aa09f1817
First pass
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/0a825921
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/0a825921
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/0a825921
Branch: refs/heads/master
Commit: 0a8259214e1996c1ec51a5f0cfa7889aa07a037c
Parents: cebd776
Author: Braden Shepherdson <br...@gmail.com>
Authored: Tue Sep 24 15:30:24 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Tue Sep 24 15:30:24 2013 -0400
----------------------------------------------------------------------
src/cli.js | 14 +++++++++++++-
src/compile.js | 5 +++--
src/create.js | 6 +++---
src/emulate.js | 4 ++--
src/hooker.js | 10 +++++-----
src/lazy_load.js | 6 ++++--
src/metadata/android_parser.js | 12 ++++++------
src/metadata/blackberry10_parser.js | 6 +++---
src/metadata/ios_parser.js | 12 ++++++------
src/metadata/wp7_parser.js | 8 ++++----
src/metadata/wp8_parser.js | 4 ++--
src/platform.js | 6 +++---
src/plugin.js | 6 +++---
src/prepare.js | 8 ++++----
src/run.js | 5 +++--
15 files changed, 64 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 4faff80..9dd18f8 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -26,6 +26,7 @@ module.exports = function CLI(inputArgs) {
.boolean('verbose')
.boolean('v')
.boolean('version')
+ .boolean('silent')
.argv;
if (args.v || args.version) {
@@ -51,12 +52,19 @@ module.exports = function CLI(inputArgs) {
});
cordova.on('results', console.log);
- if (opts.verbose) {
+ if (!opts.silent) {
cordova.on('log', console.log);
cordova.on('warn', console.warn);
var plugman = require('plugman');
plugman.on('log', console.log);
plugman.on('warn', console.warn);
+ }
+
+ if (opts.verbose) {
+ // Add handlers for verbose logging.
+ cordova.on('verbose', console.log);
+ require('plugman').on('verbose', console.log);
+
//Remove the corresponding token
if(args.d && args.verbose) {
tokens.splice(Math.min(tokens.indexOf("-d"), tokens.indexOf("--verbose")), 1);
@@ -65,7 +73,11 @@ module.exports = function CLI(inputArgs) {
} else if (args.verbose) {
tokens.splice(tokens.indexOf("--verbose"), 1);
}
+ }
+ if (opts.silent) {
+ // Remove the token.
+ tokens.splice(tokens.indexOf('--silent'));
}
cmd = tokens && tokens.length ? tokens.splice(0,1) : undefined;
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 9716224..0069b45 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -26,10 +26,11 @@ var cordova_util = require('./util'),
// Returns a promise.
function shell_out_to_build(projectRoot, platform, options) {
var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'build') + (options.length ? '" ' + options.join(" ") : '"');
- events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
+ events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '"');
var d = Q.defer();
child_process.exec(cmd, function(err, stdout, stderr) {
- events.emit('log', stdout);
+ events.emit('verbose', stdout);
+ events.emit('verbose', stderr);
if (err) {
d.reject(new Error('An error occurred while building the ' + platform + ' project. ' + stderr));
} else {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 6ec73db..4b2b950 100644
--- a/src/create.js
+++ b/src/create.js
@@ -140,15 +140,15 @@ module.exports = function create (dir, id, name) {
events.emit('log', 'Using custom www assets ('+config_json.lib.www.id+').');
return lazy_load.custom(config_json.lib.www.uri, config_json.lib.www.id, 'www', config_json.lib.www.version)
.then(function() {
- events.emit('log', 'Copying custom www assets into "' + www_dir + '"');
+ events.emit('verbose', 'Copying custom www assets into "' + www_dir + '"');
return finalize(path.join(util.libDirectory, 'www', config_json.lib.www.id, config_json.lib.www.version));
});
} else {
// Nope, so use stock cordova-hello-world-app one.
- events.emit('log', 'Using stock cordova hello-world application.');
+ events.emit('verbose', 'Using stock cordova hello-world application.');
return lazy_load.cordova('www')
.then(function() {
- events.emit('log', 'Copying stock Cordova www assets into "' + www_dir + '"');
+ events.emit('verbose', 'Copying stock Cordova www assets into "' + www_dir + '"');
return finalize(path.join(util.libDirectory, 'www', 'cordova', platforms.www.version));
});
}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 5122182..b7e2c13 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -26,10 +26,10 @@ var cordova_util = require('./util'),
// Returns a promise.
function shell_out_to_emulate(root, platform, options) {
var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" ' + (options.length ? options.join(" ") : '--emulator');
- events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
+ events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '"');
var d = Q.defer();
child_process.exec(cmd, function(err, stdout, stderr) {
- events.emit('log', stdout);
+ events.emit('verbose', stdout + stderr);
if (err) {
d.reject(new Error('An error occurred while emulating/deploying the ' + platform + ' project.' + stdout + stderr));
} else {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index 58dcf6d..d359887 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -69,7 +69,7 @@ function execute_scripts_serially(scripts, root, dir) {
var s = scripts.shift();
var fullpath = path.join(dir, s);
if (fs.statSync(fullpath).isDirectory()) {
- events.emit('log', 'skipped directory "' + fullpath + '" within hook directory');
+ events.emit('verbose', 'skipped directory "' + fullpath + '" within hook directory');
return execute_scripts_serially(scripts, root, dir); // skip directories if they're in there.
} else {
var command = fullpath + ' "' + root + '"';
@@ -83,7 +83,7 @@ function execute_scripts_serially(scripts, root, dir) {
var hookCmd, shMatch;
var shebangMatch = fileChunk.match(/^#!(\/usr\/bin\/env )?([^\r\n]+)/m);
if (octetsRead == 4096 && !fileChunk.match(/[\r\n]/))
- events.emit('log', 'shebang is too long for "' + fullpath + '"');
+ events.emit('warn', 'shebang is too long for "' + fullpath + '"');
if (shebangMatch)
hookCmd = shebangMatch[2];
if (hookCmd)
@@ -99,7 +99,7 @@ function execute_scripts_serially(scripts, root, dir) {
if (sExt.match(/^.(bat|wsf|vbs|js|ps1)$/)) {
if (os.platform() != 'win32' && !hookCmd) {
- events.emit('log', 'hook file "' + fullpath + '" skipped');
+ events.emit('verbose', 'hook file "' + fullpath + '" skipped');
// found windows script, without shebang this script definitely
// will not run on unix
return execute_scripts_serially(scripts, root, dir);
@@ -111,10 +111,10 @@ function execute_scripts_serially(scripts, root, dir) {
command = hookCmd + ' ' + command;
}
- events.emit('log', 'Executing hook "' + command + '" (output to follow)...');
+ events.emit('verbose', 'Executing hook "' + command + '" (output to follow)...');
var d = Q.defer();
child_process.exec(command, function(err, stdout, stderr) {
- events.emit('log', stdout);
+ events.emit('verbose', stdout, stderr);
if (err) {
d.reject(new Error('Script "' + fullpath + '" exited with non-zero status code. Aborting. Output: ' + stdout + stderr));
} else {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/lazy_load.js
----------------------------------------------------------------------
diff --git a/src/lazy_load.js b/src/lazy_load.js
index c3d7f52..9a982ea 100644
--- a/src/lazy_load.js
+++ b/src/lazy_load.js
@@ -50,6 +50,7 @@ module.exports = {
events.emit('log', id + ' library for "' + platform + '" already exists. No need to download. Continuing.');
return Q();
}
+ events.emit('log', 'Downloading ' + id + ' library for ' + platform + '...');
return hooker.fire('before_library_download', {
platform:platform,
url:url,
@@ -74,7 +75,7 @@ module.exports = {
if (proxy) {
request_options.proxy = proxy;
}
- events.emit('log', 'Requesting ' + JSON.stringify(request_options) + '...');
+ events.emit('verbose', 'Requesting ' + JSON.stringify(request_options) + '...');
var req = request.get(request_options, function(err, res, body) {
if (err) {
shell.rm('-rf', download_dir);
@@ -94,7 +95,8 @@ module.exports = {
d.reject(err);
})
.on('end', function() {
- events.emit('log', 'Downloaded, unzipped and extracted ' + size + ' byte response.');
+ events.emit('verbose', 'Downloaded, unzipped and extracted ' + size + ' byte response.');
+ events.emit('log', 'Download complete');
var entries = fs.readdirSync(download_dir);
var entry = path.join(download_dir, entries[0]);
shell.mv('-f', path.join(entry, (platform=='blackberry10'?'blackberry10':''), '*'), download_dir);
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index fde7e4b..ace8275 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -46,10 +46,10 @@ module.exports = function android_parser(project) {
module.exports.check_requirements = function(project_root) {
events.emit('log', 'Checking Android requirements...');
var command = 'android list target';
- events.emit('log', 'Running "' + command + '" (output to follow)');
+ events.emit('verbose', 'Running "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(command, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output);
if (err) {
d.reject(new Error('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + output));
} else {
@@ -64,10 +64,10 @@ module.exports.check_requirements = function(project_root) {
framework_path = path.join(util.libDirectory, 'android', 'cordova', require('../../platforms').android.version, 'framework');
}
var cmd = 'android update project -p "' + framework_path + '" -t android-17';
- events.emit('log', 'Running "' + cmd + '" (output to follow)...');
+ events.emit('verbose', 'Running "' + cmd + '" (output to follow)...');
var d2 = Q.defer();
child_process.exec(cmd, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output + stderr);
if (err) {
d2.reject(new Error('Error updating the Cordova library to work with your Android environment. Command run: "' + cmd + '", output: ' + output));
} else {
@@ -91,7 +91,7 @@ module.exports.prototype = {
var strings = xml.parseElementtreeSync(this.strings);
strings.find('string[@name="app_name"]').text = name;
fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
- events.emit('log', 'Wrote out Android application name to "' + name + '"');
+ events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
var manifest = xml.parseElementtreeSync(this.manifest);
// Update the version by changing the AndroidManifest android:versionName
@@ -115,7 +115,7 @@ module.exports.prototype = {
var new_javs = path.join(pkgDir, orig_java_class);
var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
- events.emit('log', 'Wrote out Android package name to "' + pkg + '"');
+ events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
fs.writeFileSync(new_javs, javs_contents, 'utf-8');
// Update whitelist by changing res/xml/config.xml
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/metadata/blackberry10_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry10_parser.js b/src/metadata/blackberry10_parser.js
index 6b8476d..3093233 100644
--- a/src/metadata/blackberry10_parser.js
+++ b/src/metadata/blackberry10_parser.js
@@ -57,11 +57,11 @@ module.exports.prototype = {
} else throw new Error('update_from_config requires a config_parser object');
this.xml.name(config.name());
- events.emit('log', 'Wrote out BlackBerry application name to "' + config.name() + '"');
+ events.emit('verbose', 'Wrote out BlackBerry application name to "' + config.name() + '"');
this.xml.packageName(config.packageName());
- events.emit('log', 'Wrote out BlackBerry package name to "' + config.packageName() + '"');
+ events.emit('verbose', 'Wrote out BlackBerry package name to "' + config.packageName() + '"');
this.xml.version(config.version());
- events.emit('log', 'Wrote out BlackBerry version to "' + config.version() + '"');
+ events.emit('verbose', 'Wrote out BlackBerry version to "' + config.version() + '"');
this.xml.access.remove();
config.access.getAttributes().forEach(function(attribs) {
self.xml.access.add(attribs.uri || attribs.origin, attribs.subdomains);
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index c1e1351..b61307c 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -67,10 +67,10 @@ module.exports.check_requirements = function(project_root) {
events.emit('log', 'Checking iOS requirements...');
// Check xcode + version.
var command = 'xcodebuild -version';
- events.emit('log', 'Running "' + command + '" (output to follow)');
+ events.emit('verbose', 'Running "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(command, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output+stderr);
if (err) {
d.reject(new Error('Xcode is (probably) not installed, specifically the command `xcodebuild` is unavailable or erroring out. Output of `'+command+'` is: ' + output + stderr));
} else {
@@ -107,8 +107,8 @@ module.exports.prototype = {
var info_contents = plist.build(infoPlist);
info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
fs.writeFileSync(plistFile, info_contents, 'utf-8');
- events.emit('log', 'Wrote out iOS Bundle Identifier to "' + pkg + '"');
- events.emit('log', 'Wrote out iOS Bundle Version to "' + version + '"');
+ events.emit('verbose', 'Wrote out iOS Bundle Identifier to "' + pkg + '"');
+ events.emit('verbose', 'Wrote out iOS Bundle Version to "' + version + '"');
// Update whitelist
var self = this;
@@ -168,13 +168,13 @@ module.exports.prototype = {
var pbx_contents = fs.readFileSync(parser.pbxproj, 'utf-8');
pbx_contents = pbx_contents.split(old_name).join(name);
fs.writeFileSync(parser.pbxproj, pbx_contents, 'utf-8');
- events.emit('log', 'Wrote out iOS Product Name and updated XCode project file names from "'+old_name+'" to "' + name + '".');
+ events.emit('verbose', 'Wrote out iOS Product Name and updated XCode project file names from "'+old_name+'" to "' + name + '".');
d.resolve();
}
});
return d.promise;
} else {
- events.emit('log', 'iOS Product Name has not changed (still "' + this.originalName + '")');
+ events.emit('verbose', 'iOS Product Name has not changed (still "' + this.originalName + '")');
return Q();
}
},
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/metadata/wp7_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/wp7_parser.js b/src/metadata/wp7_parser.js
index cb60d9c..91697e9 100644
--- a/src/metadata/wp7_parser.js
+++ b/src/metadata/wp7_parser.js
@@ -52,10 +52,10 @@ module.exports.check_requirements = function(project_root) {
var custom_path = config.has_custom_path(project_root, 'wp7');
if (custom_path) lib_path = custom_path;
var command = '"' + path.join(lib_path, 'bin', 'check_reqs') + '"';
- events.emit('log', 'Running "' + command + '" (output to follow)');
+ events.emit('verbose', 'Running "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(command, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output+stderr);
if (err) {
d.reject(new Error('Error while checking requirements: ' + output + stderr));
} else {
@@ -82,7 +82,7 @@ module.exports.prototype = {
var name = config.name();
var prev_name = manifest.find('.//App[@Title]')['attrib']['Title'];
if(prev_name != name) {
- events.emit('log', "Updating app name from " + prev_name + " to " + name);
+ events.emit('verbose', "Updating app name from " + prev_name + " to " + name);
manifest.find('.//App').attrib.Title = name;
manifest.find('.//App').attrib.Publisher = name + " Publisher";
manifest.find('.//App').attrib.Author = name + " Author";
@@ -112,7 +112,7 @@ module.exports.prototype = {
var csproj = xml.parseElementtreeSync(this.csproj_path);
prev_name = csproj.find('.//RootNamespace').text;
if(prev_name != pkg) {
- events.emit('log', "Updating package name from " + prev_name + " to " + pkg);
+ events.emit('verbose', "Updating package name from " + prev_name + " to " + pkg);
//CordovaAppProj.csproj
csproj.find('.//RootNamespace').text = pkg;
csproj.find('.//AssemblyName').text = pkg;
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/metadata/wp8_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/wp8_parser.js b/src/metadata/wp8_parser.js
index bb2f862..8dc121b 100644
--- a/src/metadata/wp8_parser.js
+++ b/src/metadata/wp8_parser.js
@@ -51,10 +51,10 @@ module.exports.check_requirements = function(project_root) {
var custom_path = config.has_custom_path(project_root, 'wp8');
if (custom_path) lib_path = custom_path;
var command = '"' + path.join(lib_path, 'bin', 'check_reqs') + '"';
- events.emit('log', 'Running "' + command + '" (output to follow)');
+ events.emit('verbose', 'Running "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(command, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output);
if (err) {
d.reject(new Error('Error while checking requirements: ' + output + stderr));
} else {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 24f16aa..3da1de9 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -243,11 +243,11 @@ function call_into_create(target, projectRoot, cfg, id, version, template_dir) {
if (template_dir) {
command += ' "' + template_dir + '"';
}
- events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
+ events.emit('verbose', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(command, function(err, create_output, stderr) {
- events.emit('log', create_output);
+ events.emit('verbose', create_output);
if (err) {
d.reject(new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output));
} else {
@@ -262,7 +262,7 @@ function call_into_create(target, projectRoot, cfg, id, version, template_dir) {
var parser = new platforms[target].parser(output);
if (!plugins) return Q();
var promises = plugins.map(function(plugin) {
- events.emit('log', 'Installing plugin "' + plugin + '" following successful platform add of ' + target);
+ events.emit('verbose', 'Installing plugin "' + plugin + '" following successful platform add of ' + target);
return require('plugman').install(target, output, path.basename(plugin), plugins_dir, { www_dir: parser.staging_dir() });
});
return promises.reduce(function(soFar, f) {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index e352ab8..d7cac8e 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -86,7 +86,7 @@ module.exports = function plugin(command, targets) {
}
// Fetch the plugin first.
- events.emit('log', 'Calling plugman.fetch on plugin "' + target + '"');
+ events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
var plugman = require('plugman');
return plugman.raw.fetch(target, pluginsDir, {})
.fail(function(err) {
@@ -116,7 +116,7 @@ module.exports = function plugin(command, targets) {
}
}
- events.emit('log', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '" with options "' + JSON.stringify(options) + '"');
+ events.emit('verbose', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '" with options "' + JSON.stringify(options) + '"');
return plugman.raw.install(platform, platformRoot, path.basename(dir), pluginsDir, options);
}));
});
@@ -143,7 +143,7 @@ module.exports = function plugin(command, targets) {
var platformRoot = path.join(projectRoot, 'platforms', platform);
var platforms = require('../platforms');
var parser = new platforms[platform].parser(platformRoot);
- events.emit('log', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+ events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
})
).then(function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 3927cea..b6928b9 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -73,20 +73,20 @@ module.exports = function prepare(options) {
}).then(function() {
// Call plugman --prepare for this platform. sets up js-modules appropriately.
var plugins_dir = path.join(projectRoot, 'plugins');
- events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
+ events.emit('verbose', 'Calling plugman.prepare for platform "' + platform + '"');
plugman.prepare(platformPath, platform, plugins_dir);
// Make sure that config changes for each existing plugin is in place
var plugins = cordova_util.findPlugins(plugins_dir);
var platform_json = plugman.config_changes.get_platform_json(plugins_dir, platform);
plugins && plugins.forEach(function(plugin_id) {
if (platform_json.installed_plugins[plugin_id]) {
- events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
+ events.emit('verbose', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
} else if (platform_json.dependent_plugins[plugin_id]) {
- events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
+ events.emit('verbose', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
}
- events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
+ events.emit('verbose', 'Plugin "' + plugin_id + '" is good to go.');
});
});
})).then(function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0a825921/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index 61ac0f3..f6a8b9f 100644
--- a/src/run.js
+++ b/src/run.js
@@ -41,10 +41,11 @@ function shell_out_to_run(projectRoot, platform, options) {
}
}
*/
- events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
+ events.emit('log', 'Running app on ' + platform);
+ events.emit('verbose', 'Run command: "' + command + '" (output to follow)');
var d = Q.defer();
child_process.exec(cmd, function(err, output, stderr) {
- events.emit('log', output);
+ events.emit('verbose', output);
if (err) {
d.reject(new Error('An error occurred while running the ' + platform + ' project. ' + output + stderr));
} else {
[2/3] git commit: Fix busted test.
Posted by br...@apache.org.
Fix busted test.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/f2574b23
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/f2574b23
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/f2574b23
Branch: refs/heads/master
Commit: f2574b2353f2fbc37fd8ced0a11c64df6575476d
Parents: 0a82592
Author: Braden Shepherdson <br...@gmail.com>
Authored: Tue Sep 24 16:00:38 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Tue Sep 24 16:00:38 2013 -0400
----------------------------------------------------------------------
spec/run.spec.js | 1 +
src/run.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f2574b23/spec/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/run.spec.js b/spec/run.spec.js
index 302c425..5b377df 100644
--- a/spec/run.spec.js
+++ b/spec/run.spec.js
@@ -67,6 +67,7 @@ describe('run command', function() {
expect(exec).toHaveBeenCalledWith('"' + path.join(project_dir, 'platforms', 'android', 'cordova', 'run') + '" --device', jasmine.any(Function));
expect(exec).toHaveBeenCalledWith('"' + path.join(project_dir, 'platforms', 'ios', 'cordova', 'run') + '" --device', jasmine.any(Function));
}, function(err) {
+ console.log(err);
expect(err).toBeUndefined();
}).fin(done);
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f2574b23/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index f6a8b9f..0f77d43 100644
--- a/src/run.js
+++ b/src/run.js
@@ -42,7 +42,7 @@ function shell_out_to_run(projectRoot, platform, options) {
}
*/
events.emit('log', 'Running app on ' + platform);
- events.emit('verbose', 'Run command: "' + command + '" (output to follow)');
+ events.emit('verbose', 'Run command: "' + cmd + '" (output to follow)');
var d = Q.defer();
child_process.exec(cmd, function(err, output, stderr) {
events.emit('verbose', output);
[3/3] git commit: [CB-4877]: Add basic logging, --silent flag.
Posted by br...@apache.org.
[CB-4877]: Add basic logging, --silent flag.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/aa09f181
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/aa09f181
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/aa09f181
Branch: refs/heads/master
Commit: aa09f18171d36493f6bd73c06132cdc92fe77e5b
Parents: f2574b2
Author: Braden Shepherdson <br...@gmail.com>
Authored: Wed Sep 25 11:53:12 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Wed Sep 25 11:53:12 2013 -0400
----------------------------------------------------------------------
src/cli.js | 12 +++---
src/compile.js | 2 +-
src/lazy_load.js | 2 +-
src/platform.js | 3 +-
src/plugin.js | 110 ++++++++++++++++++++++++++------------------------
5 files changed, 67 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/aa09f181/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 9dd18f8..6e82f99 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -37,7 +37,8 @@ module.exports = function CLI(inputArgs) {
opts = {
platforms: [],
options: [],
- verbose: (args.d || args.verbose)
+ verbose: (args.d || args.verbose),
+ silent: args.silent
},
cmd;
@@ -58,8 +59,12 @@ module.exports = function CLI(inputArgs) {
var plugman = require('plugman');
plugman.on('log', console.log);
plugman.on('warn', console.warn);
+ } else {
+ // Remove the token.
+ tokens.splice(tokens.indexOf('--silent'), 1);
}
+
if (opts.verbose) {
// Add handlers for verbose logging.
cordova.on('verbose', console.log);
@@ -75,11 +80,6 @@ module.exports = function CLI(inputArgs) {
}
}
- if (opts.silent) {
- // Remove the token.
- tokens.splice(tokens.indexOf('--silent'));
- }
-
cmd = tokens && tokens.length ? tokens.splice(0,1) : undefined;
if (cmd === undefined) {
return cordova.help();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/aa09f181/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 0069b45..34c24fe 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -26,7 +26,7 @@ var cordova_util = require('./util'),
// Returns a promise.
function shell_out_to_build(projectRoot, platform, options) {
var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'build') + (options.length ? '" ' + options.join(" ") : '"');
- events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '"');
+ events.emit('log', 'Compiling ' + platform + ' project.');
var d = Q.defer();
child_process.exec(cmd, function(err, stdout, stderr) {
events.emit('verbose', stdout);
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/aa09f181/src/lazy_load.js
----------------------------------------------------------------------
diff --git a/src/lazy_load.js b/src/lazy_load.js
index 9a982ea..b34105d 100644
--- a/src/lazy_load.js
+++ b/src/lazy_load.js
@@ -47,7 +47,7 @@ module.exports = {
var download_dir = (platform == 'wp7' || platform == 'wp8' ? path.join(util.libDirectory, 'wp', id, version) :
path.join(util.libDirectory, platform, id, version));
if (fs.existsSync(download_dir)) {
- events.emit('log', id + ' library for "' + platform + '" already exists. No need to download. Continuing.');
+ events.emit('verbose', id + ' library for "' + platform + '" already exists. No need to download. Continuing.');
return Q();
}
events.emit('log', 'Downloading ' + id + ' library for ' + platform + '...');
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/aa09f181/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 3da1de9..3b4adac 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -228,7 +228,7 @@ function call_into_create(target, projectRoot, cfg, id, version, template_dir) {
return Q.reject(new Error('Platform ' + target + ' already added'));
} else {
// Make sure we have minimum requirements to work with specified platform
- events.emit('log', 'Checking if platform "' + target + '" passes minimum requirements...');
+ events.emit('verbose', 'Checking if platform "' + target + '" passes minimum requirements...');
return module.exports.supports(projectRoot, target)
.then(function() {
// Create a platform app using the ./bin/create scripts that exist in each repo.
@@ -243,6 +243,7 @@ function call_into_create(target, projectRoot, cfg, id, version, template_dir) {
if (template_dir) {
command += ' "' + template_dir + '"';
}
+ events.emit('log', 'Creating ' + target + ' project...');
events.emit('verbose', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
var d = Q.defer();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/aa09f181/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index d7cac8e..0139393 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -78,49 +78,52 @@ module.exports = function plugin(command, targets) {
case 'add':
return hooks.fire('before_plugin_add', opts)
.then(function() {
- return Q.all(opts.plugins.map(function(target, index) {
+ return opts.plugins.reduce(function(soFar, target) {
var pluginsDir = path.join(projectRoot, 'plugins');
+ return soFar.then(function() {
+ if (target[target.length - 1] == path.sep) {
+ target = target.substring(0, target.length - 1);
+ }
- if (target[target.length - 1] == path.sep) {
- target = target.substring(0, target.length - 1);
- }
-
- // Fetch the plugin first.
- events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
- var plugman = require('plugman');
- return plugman.raw.fetch(target, pluginsDir, {})
+ // Fetch the plugin first.
+ events.emit('verbose', 'Calling plugman.fetch on plugin "' + target + '"');
+ var plugman = require('plugman');
+ return plugman.raw.fetch(target, pluginsDir, {})
+ })
.fail(function(err) {
return Q.reject(new Error('Error fetching plugin: ' + err));
})
.then(function(dir) {
// Iterate (in serial!) over all platforms in the project and install the plugin.
- return Q.all(platformList.map(function(platform) {
- var platforms = require('../platforms');
- var platformRoot = path.join(projectRoot, 'platforms', platform),
- parser = new platforms[platform].parser(platformRoot),
- options = {
- www_dir: parser.staging_dir(),
- cli_variables: {}
- },
- tokens,
- key,
- i;
- //parse variables into cli_variables
- for (i=0; i< opts.options.length; i++) {
- if (opts.options[i] === "--variable" && typeof opts.options[++i] === "string") {
- tokens = opts.options[i].split('=');
- key = tokens.shift().toUpperCase();
- if (/^[\w-_]+$/.test(key)) {
- options.cli_variables[key] = tokens.join('=');
+ return platformList.reduce(function(soFar, platform) {
+ return soFar.then(function() {
+ var platforms = require('../platforms');
+ var platformRoot = path.join(projectRoot, 'platforms', platform),
+ parser = new platforms[platform].parser(platformRoot),
+ options = {
+ www_dir: parser.staging_dir(),
+ cli_variables: {}
+ },
+ tokens,
+ key,
+ i;
+ //parse variables into cli_variables
+ for (i=0; i< opts.options.length; i++) {
+ if (opts.options[i] === "--variable" && typeof opts.options[++i] === "string") {
+ tokens = opts.options[i].split('=');
+ key = tokens.shift().toUpperCase();
+ if (/^[\w-_]+$/.test(key)) {
+ options.cli_variables[key] = tokens.join('=');
+ }
}
}
- }
- events.emit('verbose', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '" with options "' + JSON.stringify(options) + '"');
- return plugman.raw.install(platform, platformRoot, path.basename(dir), pluginsDir, options);
- }));
+ events.emit('verbose', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '" with options "' + JSON.stringify(options) + '"');
+ return plugman.raw.install(platform, platformRoot, path.basename(dir), pluginsDir, options);
+ });
+ }, Q());
});
- })); // end Q.all
+ }, Q()); // end Q.all
}).then(function() {
return hooks.fire('after_plugin_add', opts);
});
@@ -129,30 +132,31 @@ module.exports = function plugin(command, targets) {
case 'remove':
return hooks.fire('before_plugin_rm', opts)
.then(function() {
- return Q.all(opts.plugins.map(function(target, index) {
+ return opts.plugins.reduce(function(soFar, target) {
// Check if we have the plugin.
- if (plugins.indexOf(target) > -1) {
- var targetPath = path.join(pluginPath, target);
- // Iterate over all installed platforms and uninstall.
- // If this is a web-only or dependency-only plugin, then
- // there may be nothing to do here except remove the
- // reference from the platform's plugin config JSON.
- var plugman = require('plugman');
- return Q.all(
- platformList.map(function(platform) {
- var platformRoot = path.join(projectRoot, 'platforms', platform);
- var platforms = require('../platforms');
- var parser = new platforms[platform].parser(platformRoot);
- events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
- return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
- })
- ).then(function() {
- return plugman.raw.uninstall.uninstallPlugin(target, path.join(projectRoot, 'plugins'));
- });
- } else {
+ if (plugins.indexOf(target) < 0) {
return Q.reject(new Error('Plugin "' + target + '" not added to project.'));
}
- }));
+
+ var targetPath = path.join(pluginPath, target);
+ // Iterate over all installed platforms and uninstall.
+ // If this is a web-only or dependency-only plugin, then
+ // there may be nothing to do here except remove the
+ // reference from the platform's plugin config JSON.
+ var plugman = require('plugman');
+ return platformList.reduce(function(soFar, platform) {
+ return soFar.then(function() {
+ var platformRoot = path.join(projectRoot, 'platforms', platform);
+ var platforms = require('../platforms');
+ var parser = new platforms[platform].parser(platformRoot);
+ events.emit('verbose', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+ return plugman.raw.uninstall.uninstallPlatform(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
+ });
+ }, Q())
+ .then(function() {
+ return plugman.raw.uninstall.uninstallPlugin(target, path.join(projectRoot, 'plugins'));
+ });
+ }, Q());
}).then(function() {
return hooks.fire('after_plugin_rm', opts);
});