updated cordova-common dependnecy to 1.1.0

This commit is contained in:
Steve Gill
2016-02-24 09:50:07 -08:00
parent ce2525d4d8
commit 1d7ccaece6
696 changed files with 3515 additions and 1715 deletions
+3 -5
View File
@@ -106,8 +106,8 @@ function remove_plugin_changes(pluginInfo, is_top_level) {
// CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
// New windows template separate manifest files for Windows8, Windows8.1 and WP8.1
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.windows10.appxmanifest'];
// New windows template separate manifest files for Windows10, Windows8.1 and WP8.1
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
/* jshint loopfunc:true */
substs.forEach(function(subst) {
events.emit('verbose', 'Applying munge to ' + subst);
@@ -149,7 +149,7 @@ function add_plugin_changes(pluginInfo, plugin_vars, is_top_level, should_increm
// CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest', 'package.windows10.appxmanifest'];
var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows10.appxmanifest'];
/* jshint loopfunc:true */
substs.forEach(function(subst) {
events.emit('verbose', 'Applying munge to ' + subst);
@@ -203,7 +203,6 @@ function generate_plugin_config_munge(pluginInfo, vars) {
{
var manifests = {
'windows': {
'8.0.0': 'package.windows80.appxmanifest',
'8.1.0': 'package.windows.appxmanifest',
'10.0.0': 'package.windows10.appxmanifest'
},
@@ -212,7 +211,6 @@ function generate_plugin_config_munge(pluginInfo, vars) {
'10.0.0': 'package.windows10.appxmanifest'
},
'all': {
'8.0.0': 'package.windows80.appxmanifest',
'8.1.0': ['package.windows.appxmanifest', 'package.phone.appxmanifest'],
'10.0.0': 'package.windows10.appxmanifest'
}
+203
View File
@@ -0,0 +1,203 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var ansi = require('ansi');
var EventEmitter = require('events').EventEmitter;
var CordovaError = require('./CordovaError/CordovaError');
var EOL = require('os').EOL;
var INSTANCE;
/**
* @class CordovaLogger
*
* Implements logging facility that anybody could use. Should not be
* instantiated directly, `CordovaLogger.get()` method should be used instead
* to acquire logger instance
*/
function CordovaLogger () {
this.levels = {};
this.colors = {};
this.stdout = process.stdout;
this.stderr = process.stderr;
this.stdoutCursor = ansi(this.stdout);
this.stderrCursor = ansi(this.stderr);
this.addLevel('verbose', 1000, 'grey');
this.addLevel('normal' , 2000);
this.addLevel('warn' , 2000, 'yellow');
this.addLevel('info' , 3000, 'blue');
this.addLevel('error' , 5000, 'red');
this.addLevel('results' , 10000);
this.setLevel('normal');
}
/**
* Static method to create new or acquire existing instance.
*
* @return {CordovaLogger} Logger instance
*/
CordovaLogger.get = function () {
return INSTANCE || (INSTANCE = new CordovaLogger());
};
CordovaLogger.VERBOSE = 'verbose';
CordovaLogger.NORMAL = 'normal';
CordovaLogger.WARN = 'warn';
CordovaLogger.INFO = 'info';
CordovaLogger.ERROR = 'error';
CordovaLogger.RESULTS = 'results';
/**
* Emits log message to process' stdout/stderr depending on message's severity
* and current log level. If severity is less than current logger's level,
* then the message is ignored.
*
* @param {String} logLevel The message's log level. The logger should have
* corresponding level added (via logger.addLevel), otherwise
* `CordovaLogger.NORMAL` level will be used.
* @param {String} message The message, that should be logged to process'
* stdio
*
* @return {CordovaLogger} Current instance, to allow calls chaining.
*/
CordovaLogger.prototype.log = function (logLevel, message) {
// if there is no such logLevel defined, or provided level has
// less severity than active level, then just ignore this call and return
if (!this.levels[logLevel] || this.levels[logLevel] < this.levels[this.logLevel])
// return instance to allow to chain calls
return this;
var isVerbose = this.logLevel === 'verbose';
var cursor = this.stdoutCursor;
if(message instanceof Error || logLevel === CordovaLogger.ERROR) {
message = formatError(message, isVerbose);
cursor = this.stderrCursor;
}
var color = this.colors[logLevel];
if (color) {
cursor.bold().fg[color]();
}
cursor.write(message).reset().write(EOL);
return this;
};
/**
* Adds a new level to logger instance. This method also creates a shortcut
* method to log events with the level provided (i.e. after adding new level
* 'debug', the method `debug(message)`, equal to logger.log('debug', message),
* will be added to logger instance)
*
* @param {String} level A log level name. The levels with the following
* names added by default to every instance: 'verbose', 'normal', 'warn',
* 'info', 'error', 'results'
* @param {Number} severity A number that represents level's severity.
* @param {String} color A valid color name, that will be used to log
* messages with this level. Any CSS color code or RGB value is allowed
* (according to ansi documentation:
* https://github.com/TooTallNate/ansi.js#features)
*
* @return {CordovaLogger} Current instance, to allow calls chaining.
*/
CordovaLogger.prototype.addLevel = function (level, severity, color) {
this.levels[level] = severity;
if (color) {
this.colors[level] = color;
}
// Define own method with corresponding name
if (!this[level]) {
this[level] = this.log.bind(this, level);
}
return this;
};
/**
* Sets the current logger level to provided value. If logger doesn't have level
* with this name, `CordovaLogger.NORMAL` will be used.
*
* @param {String} logLevel Level name. The level with this name should be
* added to logger before.
*
* @return {CordovaLogger} Current instance, to allow calls chaining.
*/
CordovaLogger.prototype.setLevel = function (logLevel) {
this.logLevel = this.levels[logLevel] ? logLevel : CordovaLogger.NORMAL;
return this;
};
/**
* Attaches logger to EventEmitter instance provided.
*
* @param {EventEmitter} eventEmitter An EventEmitter instance to attach
* logger to.
*
* @return {CordovaLogger} Current instance, to allow calls chaining.
*/
CordovaLogger.prototype.subscribe = function (eventEmitter) {
if (!(eventEmitter instanceof EventEmitter))
throw new Error('Subscribe method only accepts an EventEmitter instance as argument');
eventEmitter.on('verbose', this.verbose)
.on('log', this.normal)
.on('info', this.info)
.on('warn', this.warn)
.on('warning', this.warn)
// Set up event handlers for logging and results emitted as events.
.on('results', this.results);
return this;
};
function formatError(error, isVerbose) {
var message = '';
if(error instanceof CordovaError) {
message = error.toString(isVerbose);
} else if(error instanceof Error) {
if(isVerbose) {
message = error.stack;
} else {
message = error.message;
}
} else {
// Plain text error message
message = error;
}
if(message.toUpperCase().indexOf('ERROR:') !== 0) {
// Needed for backward compatibility with external tools
message = 'Error: ' + message;
}
return message;
}
module.exports = CordovaLogger;
-6
View File
@@ -376,9 +376,6 @@ function addCordova(someArray) {
// applied to each element.
function _getTags(pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
if (platform == 'windows' && !platformTag) {
platformTag = pelem.find('platform[@name="' + 'windows8' + '"]');
}
var tagsInRoot = pelem.findall(tag);
tagsInRoot = tagsInRoot || [];
var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
@@ -392,9 +389,6 @@ function _getTags(pelem, tag, platform, transform) {
// Same as _getTags() but only looks inside a platfrom section.
function _getTagsInPlatform(pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
if (platform == 'windows' && !platformTag) {
platformTag = pelem.find('platform[@name="' + 'windows8' + '"]');
}
var tags = platformTag ? platformTag.findall(tag) : [];
if ( typeof transform === 'function' ) {
tags = tags.map(transform);
+47 -1
View File
@@ -16,4 +16,50 @@
specific language governing permissions and limitations
under the License.
*/
module.exports = new (require('events').EventEmitter)();
var EventEmitter = require('events').EventEmitter;
var INSTANCE = new EventEmitter();
var EVENTS_RECEIVER;
module.exports = INSTANCE;
/**
* Sets up current instance to forward emitted events to another EventEmitter
* instance.
*
* @param {EventEmitter} [eventEmitter] The emitter instance to forward
* events to. Falsy value, when passed, disables forwarding.
*/
module.exports.forwardEventsTo = function (eventEmitter) {
// If no argument is specified disable events forwarding
if (!eventEmitter) {
EVENTS_RECEIVER = undefined;
return;
}
if (!(eventEmitter instanceof EventEmitter))
throw new Error('Cordova events could be redirected to another EventEmitter instance only');
EVENTS_RECEIVER = eventEmitter;
};
var emit = INSTANCE.emit;
/**
* This method replaces original 'emit' method to allow events forwarding.
*
* @return {eventEmitter} Current instance to allow calls chaining, as
* original 'emit' does
*/
module.exports.emit = function () {
var args = Array.prototype.slice.call(arguments);
if (EVENTS_RECEIVER) {
EVENTS_RECEIVER.emit.apply(EVENTS_RECEIVER, args);
}
return emit.apply(this, args);
};
+44 -14
View File
@@ -28,7 +28,7 @@ var iswin32 = process.platform == 'win32';
// On Windows, spawn() for batch files requires absolute path & having the extension.
function resolveWindowsExe(cmd) {
var winExtensions = ['.exe', '.cmd', '.bat', '.js', '.vbs'];
var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs'];
function isValidExe(c) {
return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c);
}
@@ -52,15 +52,39 @@ function maybeQuote(a) {
return a;
}
// opts:
// printCommand: Whether to log the command (default: false)
// stdio: 'default' is to capture output and returning it as a string to success (same as exec)
// 'ignore' means don't bother capturing it
// 'inherit' means pipe the input & output. This is required for anything that prompts.
// env: Map of extra environment variables.
// cwd: Working directory for the command.
// chmod: If truthy, will attempt to set the execute bit before executing on non-Windows platforms.
// Returns a promise that succeeds only for return code = 0.
/**
* A special implementation for child_process.spawn that handles
* Windows-specific issues with batch files and spaces in paths. Returns a
* promise that succeeds only for return code 0. It is also possible to
* subscribe on spawned process' stdout and stderr streams using progress
* handler for resultant promise.
*
* @example spawn('mycommand', [], {stdio: 'pipe'}) .progress(function (stdio){
* if (stdio.stderr) { console.error(stdio.stderr); } })
* .then(function(result){ // do other stuff })
*
* @param {String} cmd A command to spawn
* @param {String[]} [args=[]] An array of arguments, passed to spawned
* process
* @param {Object} [opts={}] A configuration object
* @param {String|String[]|Object} opts.stdio Property that configures how
* spawned process' stdio will behave. Has the same meaning and possible
* values as 'stdio' options for child_process.spawn method
* (https://nodejs.org/api/child_process.html#child_process_options_stdio).
* @param {Object} [env={}] A map of extra environment variables
* @param {String} [cwd=process.cwd()] Working directory for the command
* @param {Boolean} [chmod=false] If truthy, will attempt to set the execute
* bit before executing on non-Windows platforms
*
* @return {Promise} A promise that is either fulfilled if the spawned
* process is exited with zero error code or rejected otherwise. If the
* 'stdio' option set to 'default' or 'pipe', the promise also emits progress
* messages with the following contents:
* {
* 'stdout': ...,
* 'stderr': ...
* }
*/
exports.spawn = function(cmd, args, opts) {
args = args || [];
opts = opts || {};
@@ -83,17 +107,19 @@ exports.spawn = function(cmd, args, opts) {
}
}
if (opts.stdio == 'ignore') {
spawnOpts.stdio = 'ignore';
} else if (opts.stdio == 'inherit') {
spawnOpts.stdio = 'inherit';
if (opts.stdio !== 'default') {
// Ignore 'default' value for stdio because it corresponds to child_process's default 'pipe' option
spawnOpts.stdio = opts.stdio;
}
if (opts.cwd) {
spawnOpts.cwd = opts.cwd;
}
if (opts.env) {
spawnOpts.env = _.extend(_.extend({}, process.env), opts.env);
}
if (opts.chmod && !iswin32) {
try {
// This fails when module is installed in a system directory (e.g. via sudo npm install)
@@ -113,11 +139,15 @@ exports.spawn = function(cmd, args, opts) {
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
capturedOut += data;
d.notify({'stdout': data});
});
}
if (child.stderr) {
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(data) {
capturedErr += data;
d.notify({'stderr': data});
});
}