cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [24/51] [abbrv] [partial] cordova-lib git commit: CB-11980: added missing node modules for test fixtures
Date Wed, 07 Jun 2017 06:04:15 GMT
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaError/CordovaExternalToolErrorContext.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaError/CordovaExternalToolErrorContext.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaError/CordovaExternalToolErrorContext.js
new file mode 100644
index 0000000..ca9a4aa
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaError/CordovaExternalToolErrorContext.js
@@ -0,0 +1,48 @@
+/**
+ 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.
+ */
+
+/* jshint proto:true */
+
+var path = require('path');
+
+/**
+ * @param {String} cmd Command full path
+ * @param {String[]} args Command args
+ * @param {String} [cwd] Command working directory
+ * @constructor
+ */
+function CordovaExternalToolErrorContext(cmd, args, cwd) {
+    this.cmd = cmd;
+    // Helper field for readability
+    this.cmdShortName = path.basename(cmd);
+    this.args = args;
+    this.cwd = cwd;
+}
+
+CordovaExternalToolErrorContext.prototype.toString = function(isVerbose) {
+    if(isVerbose) {
+        return 'External tool \'' + this.cmdShortName + '\'' +
+            '\nCommand full path: ' + this.cmd + '\nCommand args: ' + this.args +
+            (typeof this.cwd !== 'undefined' ? '\nCommand cwd: ' + this.cwd : '');
+    }
+
+    return this.cmdShortName;
+};
+
+module.exports = CordovaExternalToolErrorContext;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaLogger.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaLogger.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaLogger.js
new file mode 100644
index 0000000..dc49a4b
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/CordovaLogger.js
@@ -0,0 +1,220 @@
+/*
+ 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;
+};
+
+/**
+ * Adjusts the current logger level according to the passed options.
+ *
+ * @param   {Object|Array}  opts  An object or args array with options
+ *
+ * @return  {CordovaLogger}     Current instance, to allow calls chaining.
+ */
+CordovaLogger.prototype.adjustLevel = function (opts) {
+    if (opts.verbose || (Array.isArray(opts) && opts.indexOf('--verbose') !== -1)) {
+        this.setLevel('verbose');
+    } else if (opts.silent || (Array.isArray(opts) && opts.indexOf('--silent') !== -1)) {
+        this.setLevel('error');
+    }
+
+    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 (typeof message === 'string' && message.toUpperCase().indexOf('ERROR:') !== 0) {
+        // Needed for backward compatibility with external tools
+        message = 'Error: ' + message;
+    }
+
+    return message;
+}
+
+module.exports = CordovaLogger;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/FileUpdater.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/FileUpdater.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/FileUpdater.js
new file mode 100644
index 0000000..8b6876b
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/FileUpdater.js
@@ -0,0 +1,416 @@
+/**
+    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.
+*/
+
+"use strict";
+
+var fs = require("fs");
+var path = require("path");
+var shell = require("shelljs");
+var minimatch = require("minimatch");
+
+/**
+ * Logging callback used in the FileUpdater methods.
+ * @callback loggingCallback
+ * @param {string} message A message describing a single file update operation.
+ */
+
+/**
+ * Updates a target file or directory with a source file or directory. (Directory updates are
+ * not recursive.) Stats for target and source items must be passed in. This is an internal
+ * helper function used by other methods in this module.
+ *
+ * @param {?string} sourcePath Source file or directory to be used to update the
+ *     destination. If the source is null, then the destination is deleted if it exists.
+ * @param {?fs.Stats} sourceStats An instance of fs.Stats for the source path, or null if
+ *     the source does not exist.
+ * @param {string} targetPath Required destination file or directory to be updated. If it does
+ *     not exist, it will be created.
+ * @param {?fs.Stats} targetStats An instance of fs.Stats for the target path, or null if
+ *     the target does not exist.
+ * @param {Object} [options] Optional additional parameters for the update.
+ * @param {string} [options.rootDir] Optional root directory (such as a project) to which target
+ *     and source path parameters are relative; may be omitted if the paths are absolute. The
+ *     rootDir is always omitted from any logged paths, to make the logs easier to read.
+ * @param {boolean} [options.all] If true, all files are copied regardless of last-modified times.
+ *     Otherwise, a file is copied if the source's last-modified time is greather than or
+ *     equal to the target's last-modified time, or if the file sizes are different.
+ * @param {loggingCallback} [log] Optional logging callback that takes a string message
+ *     describing any file operations that are performed.
+ * @return {boolean} true if any changes were made, or false if the force flag is not set
+ *     and everything was up to date
+ */
+function updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, options, log) {
+    var updated = false;
+
+    var rootDir = (options && options.rootDir) || "";
+    var copyAll = (options && options.all) || false;
+
+    var targetFullPath = path.join(rootDir || "", targetPath);
+
+    if (sourceStats) {
+        var sourceFullPath = path.join(rootDir || "", sourcePath);
+
+        if (targetStats) {
+            // The target exists. But if the directory status doesn't match the source, delete it.
+            if (targetStats.isDirectory() && !sourceStats.isDirectory()) {
+                log("rmdir  " + targetPath + " (source is a file)");
+                shell.rm("-rf", targetFullPath);
+                targetStats = null;
+                updated = true;
+            } else if (!targetStats.isDirectory() && sourceStats.isDirectory()) {
+                log("delete " + targetPath + " (source is a directory)");
+                shell.rm("-f", targetFullPath);
+                targetStats = null;
+                updated = true;
+            }
+        }
+
+        if (!targetStats) {
+            if (sourceStats.isDirectory()) {
+                // The target directory does not exist, so it should be created.
+                log("mkdir " + targetPath);
+                shell.mkdir("-p", targetFullPath);
+                updated = true;
+            } else if (sourceStats.isFile()) {
+                // The target file does not exist, so it should be copied from the source.
+                log("copy  " + sourcePath + " " + targetPath + (copyAll ? "" : " (new file)"));
+                shell.cp("-f", sourceFullPath, targetFullPath);
+                updated = true;
+            }
+        } else if (sourceStats.isFile() && targetStats.isFile()) {
+            // The source and target paths both exist and are files.
+            if (copyAll) {
+                // The caller specified all files should be copied.
+                log("copy  " + sourcePath + " " + targetPath);
+                shell.cp("-f", sourceFullPath, targetFullPath);
+                updated = true;
+            } else {
+                // Copy if the source has been modified since it was copied to the target, or if
+                // the file sizes are different. (The latter catches most cases in which something
+                // was done to the file after copying.) Comparison is >= rather than > to allow
+                // for timestamps lacking sub-second precision in some filesystems.
+                if (sourceStats.mtime.getTime() >= targetStats.mtime.getTime() ||
+                        sourceStats.size !== targetStats.size) {
+                    log("copy  " + sourcePath + " " + targetPath + " (updated file)");
+                    shell.cp("-f", sourceFullPath, targetFullPath);
+                    updated = true;
+                }
+            }
+        }
+    } else if (targetStats) {
+        // The target exists but the source is null, so the target should be deleted.
+        if (targetStats.isDirectory()) {
+            log("rmdir  " + targetPath + (copyAll ? "" : " (no source)"));
+            shell.rm("-rf", targetFullPath);
+        } else {
+            log("delete " + targetPath + (copyAll ? "" : " (no source)"));
+            shell.rm("-f", targetFullPath);
+        }
+        updated = true;
+    }
+
+    return updated;
+}
+
+/**
+ * Helper for updatePath and updatePaths functions. Queries stats for source and target
+ * and ensures target directory exists before copying a file.
+ */
+function updatePathInternal(sourcePath, targetPath, options, log) {
+    var rootDir = (options && options.rootDir) || "";
+    var targetFullPath = path.join(rootDir, targetPath);
+    var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
+    var sourceStats = null;
+
+    if (sourcePath) {
+        // A non-null source path was specified. It should exist.
+        var sourceFullPath = path.join(rootDir, sourcePath);
+        if (!fs.existsSync(sourceFullPath)) {
+            throw new Error("Source path does not exist: " + sourcePath);
+        }
+
+        sourceStats = fs.statSync(sourceFullPath);
+
+        // Create the target's parent directory if it doesn't exist.
+        var parentDir = path.dirname(targetFullPath);
+        if (!fs.existsSync(parentDir)) {
+            shell.mkdir("-p", parentDir);
+        }
+    }
+
+    return updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, options, log);
+}
+
+/**
+ * Updates a target file or directory with a source file or directory. (Directory updates are
+ * not recursive.)
+ *
+ * @param {?string} sourcePath Source file or directory to be used to update the
+ *     destination. If the source is null, then the destination is deleted if it exists.
+ * @param {string} targetPath Required destination file or directory to be updated. If it does
+ *     not exist, it will be created.
+ * @param {Object} [options] Optional additional parameters for the update.
+ * @param {string} [options.rootDir] Optional root directory (such as a project) to which target
+ *     and source path parameters are relative; may be omitted if the paths are absolute. The
+ *     rootDir is always omitted from any logged paths, to make the logs easier to read.
+ * @param {boolean} [options.all] If true, all files are copied regardless of last-modified times.
+ *     Otherwise, a file is copied if the source's last-modified time is greather than or
+ *     equal to the target's last-modified time, or if the file sizes are different.
+ * @param {loggingCallback} [log] Optional logging callback that takes a string message
+ *     describing any file operations that are performed.
+ * @return {boolean} true if any changes were made, or false if the force flag is not set
+ *     and everything was up to date
+ */
+function updatePath(sourcePath, targetPath, options, log) {
+    if (sourcePath !== null && typeof sourcePath !== "string") {
+        throw new Error("A source path (or null) is required.");
+    }
+
+    if (!targetPath || typeof targetPath !== "string") {
+        throw new Error("A target path is required.");
+    }
+
+    log = log || function(message) { };
+
+    return updatePathInternal(sourcePath, targetPath, options, log);
+}
+
+/**
+ * Updates files and directories based on a mapping from target paths to source paths. Targets
+ * with null sources in the map are deleted.
+ *
+ * @param {Object} pathMap A dictionary mapping from target paths to source paths.
+ * @param {Object} [options] Optional additional parameters for the update.
+ * @param {string} [options.rootDir] Optional root directory (such as a project) to which target
+ *     and source path parameters are relative; may be omitted if the paths are absolute. The
+ *     rootDir is always omitted from any logged paths, to make the logs easier to read.
+ * @param {boolean} [options.all] If true, all files are copied regardless of last-modified times.
+ *     Otherwise, a file is copied if the source's last-modified time is greather than or
+ *     equal to the target's last-modified time, or if the file sizes are different.
+ * @param {loggingCallback} [log] Optional logging callback that takes a string message
+ *     describing any file operations that are performed.
+ * @return {boolean} true if any changes were made, or false if the force flag is not set
+ *     and everything was up to date
+ */
+function updatePaths(pathMap, options, log) {
+    if (!pathMap || typeof pathMap !== "object" || Array.isArray(pathMap)) {
+        throw new Error("An object mapping from target paths to source paths is required.");
+    }
+
+    log = log || function(message) { };
+
+    var updated = false;
+
+    // Iterate in sorted order to ensure directories are created before files under them.
+    Object.keys(pathMap).sort().forEach(function (targetPath) {
+        var sourcePath = pathMap[targetPath];
+        updated = updatePathInternal(sourcePath, targetPath, options, log) || updated;
+    });
+
+    return updated;
+}
+
+/**
+ * Updates a target directory with merged files and subdirectories from source directories.
+ *
+ * @param {string|string[]} sourceDirs Required source directory or array of source directories
+ *     to be merged into the target. The directories are listed in order of precedence; files in
+ *     directories later in the array supersede files in directories earlier in the array
+ *     (regardless of timestamps).
+ * @param {string} targetDir Required destination directory to be updated. If it does not exist,
+ *     it will be created. If it exists, newer files from source directories will be copied over,
+ *     and files missing in the source directories will be deleted.
+ * @param {Object} [options] Optional additional parameters for the update.
+ * @param {string} [options.rootDir] Optional root directory (such as a project) to which target
+ *     and source path parameters are relative; may be omitted if the paths are absolute. The
+ *     rootDir is always omitted from any logged paths, to make the logs easier to read.
+ * @param {boolean} [options.all] If true, all files are copied regardless of last-modified times.
+ *     Otherwise, a file is copied if the source's last-modified time is greather than or
+ *     equal to the target's last-modified time, or if the file sizes are different.
+ * @param {string|string[]} [options.include] Optional glob string or array of glob strings that
+ *     are tested against both target and source relative paths to determine if they are included
+ *     in the merge-and-update. If unspecified, all items are included.
+ * @param {string|string[]} [options.exclude] Optional glob string or array of glob strings that
+ *     are tested against both target and source relative paths to determine if they are excluded
+ *     from the merge-and-update. Exclusions override inclusions. If unspecified, no items are
+ *     excluded.
+ * @param {loggingCallback} [log] Optional logging callback that takes a string message
+ *     describing any file operations that are performed.
+ * @return {boolean} true if any changes were made, or false if the force flag is not set
+ *     and everything was up to date
+ */
+function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
+    if (sourceDirs && typeof sourceDirs === "string") {
+        sourceDirs = [ sourceDirs ];
+    } else if (!Array.isArray(sourceDirs)) {
+        throw new Error("A source directory path or array of paths is required.");
+    }
+
+    if (!targetDir || typeof targetDir !== "string") {
+        throw new Error("A target directory path is required.");
+    }
+
+    log = log || function(message) { };
+
+    var rootDir = (options && options.rootDir) || "";
+
+    var include = (options && options.include) || [ "**" ];
+    if (typeof include === "string") {
+        include = [ include ];
+    } else if (!Array.isArray(include)) {
+        throw new Error("Include parameter must be a glob string or array of glob strings.");
+    }
+
+    var exclude = (options && options.exclude) || [];
+    if (typeof exclude === "string") {
+        exclude = [ exclude ];
+    } else if (!Array.isArray(exclude)) {
+        throw new Error("Exclude parameter must be a glob string or array of glob strings.");
+    }
+
+    // Scan the files in each of the source directories.
+    var sourceMaps = sourceDirs.map(function (sourceDir) {
+            return path.join(rootDir, sourceDir);
+        }).map(function (sourcePath) {
+            if (!fs.existsSync(sourcePath)) {
+                throw new Error("Source directory does not exist: " + sourcePath);
+            }
+            return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
+        });
+
+    // Scan the files in the target directory, if it exists.
+    var targetMap = {};
+    var targetFullPath = path.join(rootDir, targetDir);
+    if (fs.existsSync(targetFullPath)) {
+        targetMap = mapDirectory(rootDir, targetDir, include, exclude);
+    }
+
+    var pathMap = mergePathMaps(sourceMaps, targetMap, targetDir);
+
+    var updated = false;
+
+    // Iterate in sorted order to ensure directories are created before files under them.
+    Object.keys(pathMap).sort().forEach(function (subPath) {
+        var entry = pathMap[subPath];
+        updated = updatePathWithStats(
+            entry.sourcePath,
+            entry.sourceStats,
+            entry.targetPath,
+            entry.targetStats,
+            options,
+            log) || updated;
+    });
+
+    return updated;
+}
+
+/**
+ * Creates a dictionary map of all files and directories under a path.
+ */
+function mapDirectory(rootDir, subDir, include, exclude) {
+    var dirMap = { "": { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
+    mapSubdirectory(rootDir, subDir, "", include, exclude, dirMap);
+    return dirMap;
+
+    function mapSubdirectory(rootDir, subDir, relativeDir, include, exclude, dirMap) {
+        var itemMapped = false;
+        var items = fs.readdirSync(path.join(rootDir, subDir, relativeDir));
+
+        items.forEach(function(item) {
+            var relativePath = path.join(relativeDir, item);
+            if(!matchGlobArray(relativePath, exclude)) {
+                // Stats obtained here (required at least to know where to recurse in directories)
+                // are saved for later, where the modified times may also be used. This minimizes
+                // the number of file I/O operations performed.
+                var fullPath = path.join(rootDir, subDir, relativePath);
+                var stats = fs.statSync(fullPath);
+
+                if (stats.isDirectory()) {
+                    // Directories are included if either something under them is included or they
+                    // match an include glob.
+                    if (mapSubdirectory(rootDir, subDir, relativePath, include, exclude, dirMap) ||
+                            matchGlobArray(relativePath, include)) {
+                        dirMap[relativePath] = { subDir: subDir, stats: stats };
+                        itemMapped = true;
+                    }
+                } else if (stats.isFile()) {
+                    // Files are included only if they match an include glob.
+                    if (matchGlobArray(relativePath, include)) {
+                        dirMap[relativePath] = { subDir: subDir, stats: stats };
+                        itemMapped = true;
+                    }
+                }
+            }
+        });
+        return itemMapped;
+    }
+
+    function matchGlobArray(path, globs) {
+        return globs.some(function(elem) {
+            return minimatch(path, elem, {dot:true});
+        });
+    }
+}
+
+/**
+ * Merges together multiple source maps and a target map into a single mapping from
+ * relative paths to objects with target and source paths and stats.
+ */
+function mergePathMaps(sourceMaps, targetMap, targetDir) {
+    // Merge multiple source maps together, along with target path info.
+    // Entries in later source maps override those in earlier source maps.
+    // Target stats will be filled in below for targets that exist.
+    var pathMap = {};
+    sourceMaps.forEach(function (sourceMap) {
+        Object.keys(sourceMap).forEach(function(sourceSubPath){
+            var sourceEntry = sourceMap[sourceSubPath];
+            pathMap[sourceSubPath] = {
+                targetPath: path.join(targetDir, sourceSubPath),
+                targetStats: null,
+                sourcePath: path.join(sourceEntry.subDir, sourceSubPath),
+                sourceStats: sourceEntry.stats
+            };
+        });
+    });
+
+    // Fill in target stats for targets that exist, and create entries
+    // for targets that don't have any corresponding sources.
+    Object.keys(targetMap).forEach(function(subPath){
+        var entry = pathMap[subPath];
+        if (entry) {
+            entry.targetStats = targetMap[subPath].stats;
+        } else {
+            pathMap[subPath] = {
+                targetPath: path.join(targetDir, subPath),
+                targetStats: targetMap[subPath].stats,
+                sourcePath: null,
+                sourceStats: null
+            };
+        }
+    });
+
+    return pathMap;
+}
+
+module.exports = {
+    updatePath: updatePath,
+    updatePaths: updatePaths,
+    mergeAndUpdateDir: mergeAndUpdateDir
+};
+

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PlatformJson.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PlatformJson.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PlatformJson.js
new file mode 100644
index 0000000..137bd21
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PlatformJson.js
@@ -0,0 +1,278 @@
+/*
+ * Licensed 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.
+ *
+*/
+/* jshint sub:true */
+
+var fs = require('fs');
+var path = require('path');
+var shelljs = require('shelljs');
+var mungeutil = require('./ConfigChanges/munge-util');
+var pluginMappernto = require('cordova-registry-mapper').newToOld;
+var pluginMapperotn = require('cordova-registry-mapper').oldToNew;
+
+function PlatformJson(filePath, platform, root) {
+    this.filePath = filePath;
+    this.platform = platform;
+    this.root = fix_munge(root || {});
+}
+
+PlatformJson.load = function(plugins_dir, platform) {
+    var filePath = path.join(plugins_dir, platform + '.json');
+    var root = null;
+    if (fs.existsSync(filePath)) {
+        root = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
+    }
+    return new PlatformJson(filePath, platform, root);
+};
+
+PlatformJson.prototype.save = function() {
+    shelljs.mkdir('-p', path.dirname(this.filePath));
+    fs.writeFileSync(this.filePath, JSON.stringify(this.root, null, 2), 'utf-8');
+};
+
+/**
+ * Indicates whether the specified plugin is installed as a top-level (not as
+ *  dependency to others)
+ * @method function
+ * @param  {String} pluginId A plugin id to check for.
+ * @return {Boolean} true if plugin installed as top-level, otherwise false.
+ */
+PlatformJson.prototype.isPluginTopLevel = function(pluginId) {
+    var installedPlugins = this.root.installed_plugins;
+    return installedPlugins[pluginId] ||
+        installedPlugins[pluginMappernto[pluginId]] ||
+        installedPlugins[pluginMapperotn[pluginId]];
+};
+
+/**
+ * Indicates whether the specified plugin is installed as a dependency to other
+ *  plugin.
+ * @method function
+ * @param  {String} pluginId A plugin id to check for.
+ * @return {Boolean} true if plugin installed as a dependency, otherwise false.
+ */
+PlatformJson.prototype.isPluginDependent = function(pluginId) {
+    var dependentPlugins = this.root.dependent_plugins;
+    return dependentPlugins[pluginId] ||
+        dependentPlugins[pluginMappernto[pluginId]] ||
+        dependentPlugins[pluginMapperotn[pluginId]];
+};
+
+/**
+ * Indicates whether plugin is installed either as top-level or as dependency.
+ * @method function
+ * @param  {String} pluginId A plugin id to check for.
+ * @return {Boolean} true if plugin installed, otherwise false.
+ */
+PlatformJson.prototype.isPluginInstalled = function(pluginId) {
+    return this.isPluginTopLevel(pluginId) ||
+        this.isPluginDependent(pluginId);
+};
+
+PlatformJson.prototype.addPlugin = function(pluginId, variables, isTopLevel) {
+    var pluginsList = isTopLevel ?
+        this.root.installed_plugins :
+        this.root.dependent_plugins;
+
+    pluginsList[pluginId] = variables;
+
+    return this;
+};
+
+/**
+ * @chaining
+ * Generates and adds metadata for provided plugin into associated <platform>.json file
+ *
+ * @param   {PluginInfo}  pluginInfo  A pluginInfo instance to add metadata from
+ * @returns {this} Current PlatformJson instance to allow calls chaining
+ */
+PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
+
+    var installedModules = this.root.modules || [];
+
+    var installedPaths = installedModules.map(function (installedModule) {
+        return installedModule.file;
+    });
+
+    var modulesToInstall = pluginInfo.getJsModules(this.platform)
+    .map(function (module) {
+        return new ModuleMetadata(pluginInfo.id, module);
+    })
+    .filter(function (metadata) {
+        // Filter out modules which are already added to metadata
+        return installedPaths.indexOf(metadata.file) === -1;
+    });
+
+    this.root.modules = installedModules.concat(modulesToInstall);
+
+    this.root.plugin_metadata = this.root.plugin_metadata || {};
+    this.root.plugin_metadata[pluginInfo.id] = pluginInfo.version;
+
+    return this;
+};
+
+PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {
+    var pluginsList = isTopLevel ?
+        this.root.installed_plugins :
+        this.root.dependent_plugins;
+
+    delete pluginsList[pluginId];
+
+    return this;
+};
+
+/**
+ * @chaining
+ * Removes metadata for provided plugin from associated file
+ *
+ * @param   {PluginInfo}  pluginInfo A PluginInfo instance to which modules' metadata
+ *   we need to remove
+ *
+ * @returns {this} Current PlatformJson instance to allow calls chaining
+ */
+PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
+    var modulesToRemove = pluginInfo.getJsModules(this.platform)
+    .map(function (jsModule) {
+        return  ['plugins', pluginInfo.id, jsModule.src].join('/');
+    });
+
+    var installedModules = this.root.modules || [];
+    this.root.modules = installedModules
+    .filter(function (installedModule) {
+        // Leave only those metadatas which 'file' is not in removed modules
+        return (modulesToRemove.indexOf(installedModule.file) === -1);
+    });
+
+    if (this.root.plugin_metadata) {
+        delete this.root.plugin_metadata[pluginInfo.id];
+    }
+
+    return this;
+};
+
+PlatformJson.prototype.addInstalledPluginToPrepareQueue = function(pluginDirName, vars, is_top_level, force) {
+    this.root.prepare_queue.installed.push({'plugin':pluginDirName, 'vars':vars, 'topLevel':is_top_level, 'force':force});
+};
+
+PlatformJson.prototype.addUninstalledPluginToPrepareQueue = function(pluginId, is_top_level) {
+    this.root.prepare_queue.uninstalled.push({'plugin':pluginId, 'id':pluginId, 'topLevel':is_top_level});
+};
+
+/**
+ * Moves plugin, specified by id to top-level plugins. If plugin is top-level
+ *  already, then does nothing.
+ * @method function
+ * @param  {String} pluginId A plugin id to make top-level.
+ * @return {PlatformJson} PlatformJson instance.
+ */
+PlatformJson.prototype.makeTopLevel = function(pluginId) {
+    var plugin = this.root.dependent_plugins[pluginId];
+    if (plugin) {
+        delete this.root.dependent_plugins[pluginId];
+        this.root.installed_plugins[pluginId] = plugin;
+    }
+    return this;
+};
+
+/**
+ * Generates a metadata for all installed plugins and js modules. The resultant
+ *   string is ready to be written to 'cordova_plugins.js'
+ *
+ * @returns {String} cordova_plugins.js contents
+ */
+PlatformJson.prototype.generateMetadata = function () {
+    return [
+        'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {',
+        'module.exports = ' + JSON.stringify(this.root.modules, null, 2) + ';',
+        'module.exports.metadata = ',
+        '// TOP OF METADATA',
+        JSON.stringify(this.root.plugin_metadata, null, 2) + ';',
+        '// BOTTOM OF METADATA',
+        '});' // Close cordova.define.
+    ].join('\n');
+};
+
+/**
+ * @chaining
+ * Generates and then saves metadata to specified file. Doesn't check if file exists.
+ *
+ * @param {String} destination  File metadata will be written to
+ * @return {PlatformJson} PlatformJson instance
+ */
+PlatformJson.prototype.generateAndSaveMetadata = function (destination) {
+    var meta = this.generateMetadata();
+    shelljs.mkdir('-p', path.dirname(destination));
+    fs.writeFileSync(destination, meta, 'utf-8');
+
+    return this;
+};
+
+// convert a munge from the old format ([file][parent][xml] = count) to the current one
+function fix_munge(root) {
+    root.prepare_queue = root.prepare_queue || {installed:[], uninstalled:[]};
+    root.config_munge = root.config_munge || {files: {}};
+    root.installed_plugins = root.installed_plugins || {};
+    root.dependent_plugins = root.dependent_plugins || {};
+
+    var munge = root.config_munge;
+    if (!munge.files) {
+        var new_munge = { files: {} };
+        for (var file in munge) {
+            for (var selector in munge[file]) {
+                for (var xml_child in munge[file][selector]) {
+                    var val = parseInt(munge[file][selector][xml_child]);
+                    for (var i = 0; i < val; i++) {
+                        mungeutil.deep_add(new_munge, [file, selector, { xml: xml_child, count: val }]);
+                    }
+                }
+            }
+        }
+        root.config_munge = new_munge;
+    }
+
+    return root;
+}
+
+/**
+ * @constructor
+ * @class ModuleMetadata
+ *
+ * Creates a ModuleMetadata object that represents module entry in 'cordova_plugins.js'
+ *   file at run time
+ *
+ * @param {String}  pluginId  Plugin id where this module installed from
+ * @param (JsModule|Object)  jsModule  A js-module entry from PluginInfo class to generate metadata for
+ */
+function ModuleMetadata (pluginId, jsModule) {
+
+    if (!pluginId) throw new TypeError('pluginId argument must be a valid plugin id');
+    if (!jsModule.src && !jsModule.name) throw new TypeError('jsModule argument must contain src or/and name properties');
+
+    this.id  = pluginId + '.' + ( jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1] );
+    this.file = ['plugins', pluginId, jsModule.src].join('/');
+    this.pluginId = pluginId;
+
+    if (jsModule.clobbers && jsModule.clobbers.length > 0) {
+        this.clobbers = jsModule.clobbers.map(function(o) { return o.target; });
+    }
+    if (jsModule.merges && jsModule.merges.length > 0) {
+        this.merges = jsModule.merges.map(function(o) { return o.target; });
+    }
+    if (jsModule.runs) {
+        this.runs = true;
+    }
+}
+
+module.exports = PlatformJson;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
new file mode 100644
index 0000000..44501fa
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfo.js
@@ -0,0 +1,425 @@
+/**
+    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.
+*/
+
+/* jshint sub:true, laxcomma:true, laxbreak:true */
+
+/*
+A class for holidng the information currently stored in plugin.xml
+It should also be able to answer questions like whether the plugin
+is compatible with a given engine version.
+
+TODO (kamrik): refactor this to not use sync functions and return promises.
+*/
+
+
+var path = require('path')
+  , fs = require('fs')
+  , xml_helpers = require('../util/xml-helpers')
+  , CordovaError = require('../CordovaError/CordovaError')
+  ;
+
+function PluginInfo(dirname) {
+    var self = this;
+
+    // METHODS
+    // Defined inside the constructor to avoid the "this" binding problems.
+
+    // <preference> tag
+    // Example: <preference name="API_KEY" />
+    // Used to require a variable to be specified via --variable when installing the plugin.
+    // returns { key : default | null}
+    self.getPreferences = getPreferences;
+    function getPreferences(platform) {
+        return _getTags(self._et, 'preference', platform, _parsePreference)
+        .reduce(function (preferences, pref) {
+            preferences[pref.preference] = pref.default;
+            return preferences;
+        }, {});
+    }
+
+    function _parsePreference(prefTag) {
+        var name = prefTag.attrib.name.toUpperCase();
+        var def = prefTag.attrib.default || null;
+        return {preference: name, default: def};
+    }
+
+    // <asset>
+    self.getAssets = getAssets;
+    function getAssets(platform) {
+        var assets = _getTags(self._et, 'asset', platform, _parseAsset);
+        return assets;
+    }
+
+    function _parseAsset(tag) {
+        var src = tag.attrib.src;
+        var target = tag.attrib.target;
+
+        if ( !src || !target) {
+            var msg =
+                'Malformed <asset> tag. Both "src" and "target" attributes'
+                + 'must be specified in\n'
+                + self.filepath
+                ;
+            throw new Error(msg);
+        }
+
+        var asset = {
+            itemType: 'asset',
+            src: src,
+            target: target
+        };
+        return asset;
+    }
+
+
+    // <dependency>
+    // Example:
+    // <dependency id="com.plugin.id"
+    //     url="https://github.com/myuser/someplugin"
+    //     commit="428931ada3891801"
+    //     subdir="some/path/here" />
+    self.getDependencies = getDependencies;
+    function getDependencies(platform) {
+        var deps = _getTags(
+                self._et,
+                'dependency',
+                platform,
+                _parseDependency
+        );
+        return deps;
+    }
+
+    function _parseDependency(tag) {
+        var dep =
+            { id : tag.attrib.id
+            , url : tag.attrib.url || ''
+            , subdir : tag.attrib.subdir || ''
+            , commit : tag.attrib.commit
+            };
+
+        dep.git_ref = dep.commit;
+
+        if ( !dep.id ) {
+            var msg =
+                '<dependency> tag is missing id attribute in '
+                + self.filepath
+                ;
+            throw new CordovaError(msg);
+        }
+        return dep;
+    }
+
+
+    // <config-file> tag
+    self.getConfigFiles = getConfigFiles;
+    function getConfigFiles(platform) {
+        var configFiles = _getTags(self._et, 'config-file', platform, _parseConfigFile);
+        return configFiles;
+    }
+
+    function _parseConfigFile(tag) {
+        var configFile =
+            { target : tag.attrib['target']
+            , parent : tag.attrib['parent']
+            , after : tag.attrib['after']
+            , xmls : tag.getchildren()
+            // To support demuxing via versions
+            , versions : tag.attrib['versions']
+            , deviceTarget: tag.attrib['device-target']
+            };
+        return configFile;
+    }
+
+    self.getEditConfigs = getEditConfigs;
+    function getEditConfigs(platform) {
+        var editConfigs = _getTags(self._et, 'edit-config', platform, _parseEditConfigs);
+        return editConfigs;
+    }
+
+    function _parseEditConfigs(tag) {
+        var editConfig =
+        { file : tag.attrib['file']
+        , target : tag.attrib['target']
+        , mode : tag.attrib['mode']
+        , xmls : tag.getchildren()
+        };
+        return editConfig;
+    }
+
+    // <info> tags, both global and within a <platform>
+    // TODO (kamrik): Do we ever use <info> under <platform>? Example wanted.
+    self.getInfo = getInfo;
+    function getInfo(platform) {
+        var infos = _getTags(
+                self._et,
+                'info',
+                platform,
+                function(elem) { return elem.text; }
+        );
+        // Filter out any undefined or empty strings.
+        infos = infos.filter(Boolean);
+        return infos;
+    }
+
+    // <source-file>
+    // Examples:
+    // <source-file src="src/ios/someLib.a" framework="true" />
+    // <source-file src="src/ios/someLib.a" compiler-flags="-fno-objc-arc" />
+    self.getSourceFiles = getSourceFiles;
+    function getSourceFiles(platform) {
+        var sourceFiles = _getTagsInPlatform(self._et, 'source-file', platform, _parseSourceFile);
+        return sourceFiles;
+    }
+
+    function _parseSourceFile(tag) {
+        return {
+            itemType: 'source-file',
+            src: tag.attrib.src,
+            framework: isStrTrue(tag.attrib.framework),
+            weak: isStrTrue(tag.attrib.weak),
+            compilerFlags: tag.attrib['compiler-flags'],
+            targetDir: tag.attrib['target-dir']
+        };
+    }
+
+    // <header-file>
+    // Example:
+    // <header-file src="CDVFoo.h" />
+    self.getHeaderFiles = getHeaderFiles;
+    function getHeaderFiles(platform) {
+        var headerFiles = _getTagsInPlatform(self._et, 'header-file', platform, function(tag) {
+            return {
+                itemType: 'header-file',
+                src: tag.attrib.src,
+                targetDir: tag.attrib['target-dir']
+            };
+        });
+        return headerFiles;
+    }
+
+    // <resource-file>
+    // Example:
+    // <resource-file src="FooPluginStrings.xml" target="res/values/FooPluginStrings.xml" device-target="win" arch="x86" versions="&gt;=8.1" />
+    self.getResourceFiles = getResourceFiles;
+    function getResourceFiles(platform) {
+        var resourceFiles = _getTagsInPlatform(self._et, 'resource-file', platform, function(tag) {
+            return {
+                itemType: 'resource-file',
+                src: tag.attrib.src,
+                target: tag.attrib.target,
+                versions: tag.attrib.versions,
+                deviceTarget: tag.attrib['device-target'],
+                arch: tag.attrib.arch,
+                reference: tag.attrib.reference
+            };
+        });
+        return resourceFiles;
+    }
+
+    // <lib-file>
+    // Example:
+    // <lib-file src="src/BlackBerry10/native/device/libfoo.so" arch="device" />
+    self.getLibFiles = getLibFiles;
+    function getLibFiles(platform) {
+        var libFiles = _getTagsInPlatform(self._et, 'lib-file', platform, function(tag) {
+            return {
+                itemType: 'lib-file',
+                src: tag.attrib.src,
+                arch: tag.attrib.arch,
+                Include: tag.attrib.Include,
+                versions: tag.attrib.versions,
+                deviceTarget: tag.attrib['device-target'] || tag.attrib.target
+            };
+        });
+        return libFiles;
+    }
+
+    // <hook>
+    // Example:
+    // <hook type="before_build" src="scripts/beforeBuild.js" />
+    self.getHookScripts = getHookScripts;
+    function getHookScripts(hook, platforms) {
+        var scriptElements =  self._et.findall('./hook');
+
+        if(platforms) {
+            platforms.forEach(function (platform) {
+                scriptElements = scriptElements.concat(self._et.findall('./platform[@name="' + platform + '"]/hook'));
+            });
+        }
+
+        function filterScriptByHookType(el) {
+            return el.attrib.src && el.attrib.type && el.attrib.type.toLowerCase() === hook;
+        }
+
+        return scriptElements.filter(filterScriptByHookType);
+    }
+
+    self.getJsModules = getJsModules;
+    function getJsModules(platform) {
+        var modules = _getTags(self._et, 'js-module', platform, _parseJsModule);
+        return modules;
+    }
+
+    function _parseJsModule(tag) {
+        var ret = {
+            itemType: 'js-module',
+            name: tag.attrib.name,
+            src: tag.attrib.src,
+            clobbers: tag.findall('clobbers').map(function(tag) { return { target: tag.attrib.target }; }),
+            merges: tag.findall('merges').map(function(tag) { return { target: tag.attrib.target }; }),
+            runs: tag.findall('runs').length > 0
+        };
+
+        return ret;
+    }
+
+    self.getEngines = function() {
+        return self._et.findall('engines/engine').map(function(n) {
+            return {
+                name: n.attrib.name,
+                version: n.attrib.version,
+                platform: n.attrib.platform,
+                scriptSrc: n.attrib.scriptSrc
+            };
+        });
+    };
+
+    self.getPlatforms = function() {
+        return self._et.findall('platform').map(function(n) {
+            return { name: n.attrib.name };
+        });
+    };
+
+    self.getPlatformsArray = function() {
+        return self._et.findall('platform').map(function(n) {
+            return n.attrib.name;
+        });
+    };
+    self.getFrameworks = function(platform) {
+        return _getTags(self._et, 'framework', platform, function(el) {
+            var ret = {
+                itemType: 'framework',
+                type: el.attrib.type,
+                parent: el.attrib.parent,
+                custom: isStrTrue(el.attrib.custom),
+                src: el.attrib.src,
+                spec: el.attrib.spec,
+                weak: isStrTrue(el.attrib.weak),
+                versions: el.attrib.versions,
+                targetDir: el.attrib['target-dir'],
+                deviceTarget: el.attrib['device-target'] || el.attrib.target,
+                arch: el.attrib.arch,
+                implementation: el.attrib.implementation
+            };
+            return ret;
+        });
+    };
+
+    self.getFilesAndFrameworks = getFilesAndFrameworks;
+    function getFilesAndFrameworks(platform) {
+        // Please avoid changing the order of the calls below, files will be
+        // installed in this order.
+        var items = [].concat(
+            self.getSourceFiles(platform),
+            self.getHeaderFiles(platform),
+            self.getResourceFiles(platform),
+            self.getFrameworks(platform),
+            self.getLibFiles(platform)
+        );
+        return items;
+    }
+    ///// End of PluginInfo methods /////
+
+
+    ///// PluginInfo Constructor logic  /////
+    self.filepath = path.join(dirname, 'plugin.xml');
+    if (!fs.existsSync(self.filepath)) {
+        throw new CordovaError('Cannot find plugin.xml for plugin "' + path.basename(dirname) + '". Please try adding it again.');
+    }
+
+    self.dir = dirname;
+    var et = self._et = xml_helpers.parseElementtreeSync(self.filepath);
+    var pelem = et.getroot();
+    self.id = pelem.attrib.id;
+    self.version = pelem.attrib.version;
+
+    // Optional fields
+    self.name = pelem.findtext('name');
+    self.description = pelem.findtext('description');
+    self.license = pelem.findtext('license');
+    self.repo = pelem.findtext('repo');
+    self.issue = pelem.findtext('issue');
+    self.keywords = pelem.findtext('keywords');
+    self.info = pelem.findtext('info');
+    if (self.keywords) {
+        self.keywords = self.keywords.split(',').map( function(s) { return s.trim(); } );
+    }
+    self.getKeywordsAndPlatforms = function () {
+        var ret = self.keywords || [];
+        return ret.concat('ecosystem:cordova').concat(addCordova(self.getPlatformsArray()));
+    };
+}  // End of PluginInfo constructor.
+
+// Helper function used to prefix every element of an array with cordova-
+// Useful when we want to modify platforms to be cordova-platform
+function addCordova(someArray) {
+    var newArray = someArray.map(function(element) {
+        return 'cordova-' + element;
+    });
+    return newArray;
+}
+
+// Helper function used by most of the getSomething methods of PluginInfo.
+// Get all elements of a given name. Both in root and in platform sections
+// for the given platform. If transform is given and is a function, it is
+// applied to each element.
+function _getTags(pelem, tag, platform, transform) {
+    var platformTag = pelem.find('./platform[@name="' + platform + '"]');
+    var tagsInRoot = pelem.findall(tag);
+    tagsInRoot = tagsInRoot || [];
+    var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
+    var tags = tagsInRoot.concat(tagsInPlatform);
+    if ( typeof transform === 'function' ) {
+        tags = tags.map(transform);
+    }
+    return tags;
+}
+
+// Same as _getTags() but only looks inside a platform section.
+function _getTagsInPlatform(pelem, tag, platform, transform) {
+    var platformTag = pelem.find('./platform[@name="' + platform + '"]');
+    var tags = platformTag ? platformTag.findall(tag) : [];
+    if ( typeof transform === 'function' ) {
+        tags = tags.map(transform);
+    }
+    return tags;
+}
+
+// Check if x is a string 'true'.
+function isStrTrue(x) {
+    return String(x).toLowerCase() == 'true';
+}
+
+module.exports = PluginInfo;
+// Backwards compat:
+PluginInfo.PluginInfo = PluginInfo;
+PluginInfo.loadPluginsDir = function(dir) {
+    var PluginInfoProvider = require('./PluginInfoProvider');
+    return new PluginInfoProvider().getAllWithinSearchPath(dir);
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js
new file mode 100644
index 0000000..6240119
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginInfo/PluginInfoProvider.js
@@ -0,0 +1,82 @@
+/**
+    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.
+*/
+
+/* jshint sub:true, laxcomma:true, laxbreak:true */
+
+var fs = require('fs');
+var path = require('path');
+var PluginInfo = require('./PluginInfo');
+var events = require('../events');
+
+function PluginInfoProvider() {
+    this._cache = {};
+    this._getAllCache = {};
+}
+
+PluginInfoProvider.prototype.get = function(dirName) {
+    var absPath = path.resolve(dirName);
+    if (!this._cache[absPath]) {
+        this._cache[absPath] = new PluginInfo(dirName);
+    }
+    return this._cache[absPath];
+};
+
+// Normally you don't need to put() entries, but it's used
+// when copying plugins, and in unit tests.
+PluginInfoProvider.prototype.put = function(pluginInfo) {
+    var absPath = path.resolve(pluginInfo.dir);
+    this._cache[absPath] = pluginInfo;
+};
+
+// Used for plugin search path processing.
+// Given a dir containing multiple plugins, create a PluginInfo object for
+// each of them and return as array.
+// Should load them all in parallel and return a promise, but not yet.
+PluginInfoProvider.prototype.getAllWithinSearchPath = function(dirName) {
+    var absPath = path.resolve(dirName);
+    if (!this._getAllCache[absPath]) {
+        this._getAllCache[absPath] = getAllHelper(absPath, this);
+    }
+    return this._getAllCache[absPath];
+};
+
+function getAllHelper(absPath, provider) {
+    if (!fs.existsSync(absPath)){
+        return [];
+    }
+    // If dir itself is a plugin, return it in an array with one element.
+    if (fs.existsSync(path.join(absPath, 'plugin.xml'))) {
+        return [provider.get(absPath)];
+    }
+    var subdirs = fs.readdirSync(absPath);
+    var plugins = [];
+    subdirs.forEach(function(subdir) {
+        var d = path.join(absPath, subdir);
+        if (fs.existsSync(path.join(d, 'plugin.xml'))) {
+            try {
+                plugins.push(provider.get(d));
+            } catch (e) {
+                events.emit('warn', 'Error parsing ' + path.join(d, 'plugin.xml.\n' + e.stack));
+            }
+        }
+    });
+    return plugins;
+}
+
+module.exports = PluginInfoProvider;

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginManager.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginManager.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginManager.js
new file mode 100644
index 0000000..0bcaf59
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/PluginManager.js
@@ -0,0 +1,152 @@
+/*
+       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 Q = require('q');
+var fs = require('fs');
+var path = require('path');
+
+var ActionStack = require('./ActionStack');
+var PlatformJson = require('./PlatformJson');
+var CordovaError = require('./CordovaError/CordovaError');
+var PlatformMunger = require('./ConfigChanges/ConfigChanges').PlatformMunger;
+var PluginInfoProvider = require('./PluginInfo/PluginInfoProvider');
+
+/**
+ * @constructor
+ * @class PluginManager
+ * Represents an entity for adding/removing plugins for platforms
+ *
+ * @param {String} platform Platform name
+ * @param {Object} locations - Platform files and directories
+ * @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
+ */
+function PluginManager(platform, locations, ideProject) {
+    this.platform = platform;
+    this.locations = locations;
+    this.project = ideProject;
+
+    var platformJson = PlatformJson.load(locations.root, platform);
+    this.munger = new PlatformMunger(platform, locations.root, platformJson, new PluginInfoProvider());
+}
+
+
+/**
+ * @constructs PluginManager
+ * A convenience shortcut to new PluginManager(...)
+ *
+ * @param {String} platform Platform name
+ * @param {Object} locations - Platform files and directories
+ * @param {IDEProject} ideProject The IDE project to add/remove plugin changes to/from
+ * @returns new PluginManager instance
+ */
+PluginManager.get = function(platform, locations, ideProject) {
+    return new PluginManager(platform, locations, ideProject);
+};
+
+PluginManager.INSTALL = 'install';
+PluginManager.UNINSTALL = 'uninstall';
+
+module.exports = PluginManager;
+
+/**
+ * Describes and implements common plugin installation/uninstallation routine. The flow is the following:
+ *  * Validate and set defaults for options. Note that options are empty by default. Everything
+ *    needed for platform IDE project must be passed from outside. Plugin variables (which
+ *    are the part of the options) also must be already populated with 'PACKAGE_NAME' variable.
+ *  * Collect all plugin's native and web files, get installers/uninstallers and process
+ *    all these via ActionStack.
+ *  * Save the IDE project, so the changes made by installers are persisted.
+ *  * Generate config changes munge for plugin and apply it to all required files
+ *  * Generate metadata for plugin and plugin modules and save it to 'cordova_plugins.js'
+ *
+ * @param {PluginInfo} plugin A PluginInfo structure representing plugin to install
+ * @param {Object} [options={}] An installation options. It is expected but is not necessary
+ *   that options would contain 'variables' inner object with 'PACKAGE_NAME' field set by caller.
+ *
+ * @returns {Promise} Returns a Q promise, either resolved in case of success, rejected otherwise.
+ */
+PluginManager.prototype.doOperation = function (operation, plugin, options) {
+    if (operation !== PluginManager.INSTALL && operation !== PluginManager.UNINSTALL)
+        return Q.reject(new CordovaError('The parameter is incorrect. The opeation must be either "add" or "remove"'));
+
+    if (!plugin || plugin.constructor.name !== 'PluginInfo')
+        return Q.reject(new CordovaError('The parameter is incorrect. The first parameter should be a PluginInfo instance'));
+
+    // Set default to empty object to play safe when accesing properties
+    options = options || {};
+
+    var self = this;
+    var actions = new ActionStack();
+
+    // gather all files need to be handled during operation ...
+    plugin.getFilesAndFrameworks(this.platform)
+        .concat(plugin.getAssets(this.platform))
+        .concat(plugin.getJsModules(this.platform))
+    // ... put them into stack ...
+    .forEach(function(item) {
+        var installer = self.project.getInstaller(item.itemType);
+        var uninstaller = self.project.getUninstaller(item.itemType);
+        var actionArgs = [item, plugin, self.project, options];
+
+        var action;
+        if (operation === PluginManager.INSTALL) {
+            action = actions.createAction.apply(actions, [installer, actionArgs, uninstaller, actionArgs]);
+        } else /* op === PluginManager.UNINSTALL */{
+            action = actions.createAction.apply(actions, [uninstaller, actionArgs, installer, actionArgs]);
+        }
+        actions.push(action);
+    });
+
+    // ... and run through the action stack
+    return actions.process(this.platform)
+    .then(function () {
+        if (self.project.write) {
+            self.project.write();
+        }
+
+        if (operation === PluginManager.INSTALL) {
+            // Ignore passed `is_top_level` option since platform itself doesn't know
+            // anything about managing dependencies - it's responsibility of caller.
+            self.munger.add_plugin_changes(plugin, options.variables, /*is_top_level=*/true, /*should_increment=*/true, options.force);
+            self.munger.platformJson.addPluginMetadata(plugin);
+        } else {
+            self.munger.remove_plugin_changes(plugin, /*is_top_level=*/true);
+            self.munger.platformJson.removePluginMetadata(plugin);
+        }
+
+        // Save everything (munge and plugin/modules metadata)
+        self.munger.save_all();
+
+        var metadata = self.munger.platformJson.generateMetadata();
+        fs.writeFileSync(path.join(self.locations.www, 'cordova_plugins.js'), metadata, 'utf-8');
+
+        // CB-11022 save plugin metadata to both www and platform_www if options.usePlatformWww is specified
+        if (options.usePlatformWww) {
+            fs.writeFileSync(path.join(self.locations.platformWww, 'cordova_plugins.js'), metadata, 'utf-8');
+        }
+    });
+};
+
+PluginManager.prototype.addPlugin = function (plugin, installOptions) {
+    return this.doOperation(PluginManager.INSTALL, plugin, installOptions);
+};
+
+PluginManager.prototype.removePlugin = function (plugin, uninstallOptions) {
+    return this.doOperation(PluginManager.UNINSTALL, plugin, uninstallOptions);
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/events.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/events.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/events.js
new file mode 100644
index 0000000..e702bd8
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/events.js
@@ -0,0 +1,72 @@
+/**
+    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 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 can be redirected to another EventEmitter instance only');
+
+    // CB-10940 Skipping forwarding to self to avoid infinite recursion.
+    // This is the case when the modules are npm-linked.
+    if (this !== eventEmitter) {
+        EVENTS_RECEIVER = eventEmitter;
+    } else {
+        // Reset forwarding if we are subscribing to self
+        EVENTS_RECEIVER = undefined;
+    }
+};
+
+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);
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/superspawn.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/superspawn.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/superspawn.js
new file mode 100644
index 0000000..96ec09d
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/superspawn.js
@@ -0,0 +1,190 @@
+/**
+    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 child_process = require('child_process');
+var fs = require('fs');
+var path = require('path');
+var _ = require('underscore');
+var Q = require('q');
+var shell = require('shelljs');
+var events = require('./events');
+var iswin32 = process.platform == 'win32';
+
+// On Windows, spawn() for batch files requires absolute path & having the extension.
+function resolveWindowsExe(cmd) {
+    var winExtensions = ['.exe', '.bat', '.cmd', '.js', '.vbs'];
+    function isValidExe(c) {
+        return winExtensions.indexOf(path.extname(c)) !== -1 && fs.existsSync(c);
+    }
+    if (isValidExe(cmd)) {
+        return cmd;
+    }
+    cmd = shell.which(cmd) || cmd;
+    if (!isValidExe(cmd)) {
+        winExtensions.some(function(ext) {
+            if (fs.existsSync(cmd + ext)) {
+                cmd = cmd + ext;
+                return true;
+            }
+        });
+    }
+    return cmd;
+}
+
+function maybeQuote(a) {
+    if (/^[^"].*[ &].*[^"]/.test(a)) return '"' + a + '"';
+    return a;
+}
+
+/**
+ * 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 || {};
+    var spawnOpts = {};
+    var d = Q.defer();
+
+    if (iswin32) {
+        cmd = resolveWindowsExe(cmd);
+        // If we couldn't find the file, likely we'll end up failing,
+        // but for things like "del", cmd will do the trick.
+        if (path.extname(cmd) != '.exe') {
+            var cmdArgs = '"' + [cmd].concat(args).map(maybeQuote).join(' ') + '"';
+            // We need to use /s to ensure that spaces are parsed properly with cmd spawned content
+            args = [['/s', '/c', cmdArgs].join(' ')];
+            cmd = 'cmd';
+            spawnOpts.windowsVerbatimArguments = true;
+        } else if (!fs.existsSync(cmd)) {
+            // We need to use /s to ensure that spaces are parsed properly with cmd spawned content
+            args = ['/s', '/c', cmd].concat(args).map(maybeQuote);
+        }
+    }
+
+    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)
+            fs.chmodSync(cmd, '755');
+        } catch (e) {
+            // If the perms weren't set right, then this will come as an error upon execution.
+        }
+    }
+
+    events.emit(opts.printCommand ? 'log' : 'verbose', 'Running command: ' + maybeQuote(cmd) + ' ' + args.map(maybeQuote).join(' '));
+
+    var child = child_process.spawn(cmd, args, spawnOpts);
+    var capturedOut = '';
+    var capturedErr = '';
+
+    if (child.stdout) {
+        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});
+        });
+    }
+
+    child.on('close', whenDone);
+    child.on('error', whenDone);
+    function whenDone(arg) {
+        child.removeListener('close', whenDone);
+        child.removeListener('error', whenDone);
+        var code = typeof arg == 'number' ? arg : arg && arg.code;
+
+        events.emit('verbose', 'Command finished with error code ' + code + ': ' + cmd + ' ' + args);
+        if (code === 0) {
+            d.resolve(capturedOut.trim());
+        } else {
+            var errMsg = cmd + ': Command failed with exit code ' + code;
+            if (capturedErr) {
+                errMsg += ' Error output:\n' + capturedErr.trim();
+            }
+            var err = new Error(errMsg);
+            if (capturedErr) {
+                err.stderr = capturedErr;
+            }
+            if (capturedOut) {
+                err.stdout = capturedOut;
+            }
+            err.code = code;
+            d.reject(err);
+        }
+    }
+
+    return d.promise;
+};
+
+exports.maybeSpawn = function(cmd, args, opts) {
+    if (fs.existsSync(cmd)) {
+        return exports.spawn(cmd, args, opts);
+    }
+    return Q(null);
+};
+

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/addProperty.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/addProperty.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/addProperty.js
new file mode 100644
index 0000000..7dc4dc1
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/addProperty.js
@@ -0,0 +1,32 @@
+/*
+       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.
+*/
+
+module.exports = function addProperty(module, property, modulePath, obj) {
+    
+    obj = obj || module.exports;
+    // Add properties as getter to delay load the modules on first invocation
+    Object.defineProperty(obj, property, {
+        configurable: true,
+        get: function () {
+            var delayLoadedModule = module.require(modulePath);
+            obj[property] = delayLoadedModule;
+            return delayLoadedModule;
+        }
+    });
+};

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cef2959c/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/plist-helpers.js b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/plist-helpers.js
new file mode 100644
index 0000000..38eb31b
--- /dev/null
+++ b/spec-plugman/projects/android/cordova/node_modules/cordova-common/src/util/plist-helpers.js
@@ -0,0 +1,101 @@
+/**
+    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.
+*/ 
+
+// contains PLIST utility functions
+var __     = require('underscore');
+var plist = require('plist');
+
+// adds node to doc at selector
+module.exports.graftPLIST = graftPLIST;
+function graftPLIST(doc, xml, selector) {
+    var obj = plist.parse('<plist>'+xml+'</plist>');
+
+    var node = doc[selector];
+    if (node && Array.isArray(node) && Array.isArray(obj)){
+        node = node.concat(obj);
+        for (var i =0;i<node.length; i++){
+            for (var j=i+1; j<node.length; ++j) {
+              if (nodeEqual(node[i], node[j]))
+                    node.splice(j--,1);
+            }
+        }
+        doc[selector] = node;
+    } else {
+        //plist uses objects for <dict>. If we have two dicts we merge them instead of
+        // overriding the old one. See CB-6472
+        if (node && __.isObject(node) && __.isObject(obj) && !__.isDate(node) && !__.isDate(obj)){//arrays checked above
+            __.extend(obj,node);
+        }
+        doc[selector] = obj;
+    }
+
+    return true;
+}
+
+// removes node from doc at selector
+module.exports.prunePLIST = prunePLIST;
+function prunePLIST(doc, xml, selector) {
+    var obj = plist.parse('<plist>'+xml+'</plist>');
+
+    pruneOBJECT(doc, selector, obj);
+
+    return true;
+}
+
+function pruneOBJECT(doc, selector, fragment) {
+    if (Array.isArray(fragment) && Array.isArray(doc[selector])) {
+        var empty = true;
+        for (var i in fragment) {
+            for (var j in doc[selector]) {
+                empty = pruneOBJECT(doc[selector], j, fragment[i]) && empty;
+            }
+        }
+        if (empty)
+        {
+            delete doc[selector];
+            return true;
+        }
+    }
+    else if (nodeEqual(doc[selector], fragment)) {
+        delete doc[selector];
+        return true;
+    }
+
+    return false;
+}
+
+function nodeEqual(node1, node2) {
+    if (typeof node1 != typeof node2)
+        return false;
+    else if (typeof node1 == 'string') {
+        node2 = escapeRE(node2).replace(new RegExp('\\$[a-zA-Z0-9-_]+','gm'),'(.*?)');
+        return new RegExp('^' + node2 + '$').test(node1);
+    }
+    else {
+        for (var key in node2) {
+            if (!nodeEqual(node1[key], node2[key])) return false;
+        }
+        return true;
+    }
+}
+
+// escape string for use in regex
+function escapeRE(str) {
+    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '$&');
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message