You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/03/06 23:27:37 UTC

[05/31] ios commit: CB-8197 Convert all bash scripts to node.js (close #126)

CB-8197 Convert all bash scripts to node.js (close #126)

* adds check_ios_deploy and check_ios_sim methods to exports for future use in build/run scripts
* adds get_ios_deploy_version and get_ios_sim_version methods to versions module
* fixes get_apple_xcode_version method to return version value, not just print it to console.


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/985fb6e9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/985fb6e9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/985fb6e9

Branch: refs/heads/wkwebview
Commit: 985fb6e98f740a6b62b1130cadf847e91e2f1d5f
Parents: 3543c9e
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Mon Dec 22 11:58:54 2014 +0300
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 23 10:38:51 2015 -0500

----------------------------------------------------------------------
 bin/apple_xcode_version                         |   6 +-
 bin/check_reqs                                  |  58 ++-
 bin/check_reqs.bat                              |  25 ++
 bin/lib/check_reqs.js                           |  94 +++++
 bin/lib/create.js                               |   1 +
 bin/lib/versions.js                             |  95 ++++-
 bin/node_modules/nopt/.npmignore                |   1 +
 bin/node_modules/nopt/LICENSE                   |  23 ++
 bin/node_modules/nopt/README.md                 | 209 ++++++++++
 bin/node_modules/nopt/bin/nopt.js               |  54 +++
 bin/node_modules/nopt/examples/my-program.js    |  30 ++
 bin/node_modules/nopt/lib/nopt.js               | 414 +++++++++++++++++++
 .../nopt/node_modules/abbrev/CONTRIBUTING.md    |   3 +
 .../nopt/node_modules/abbrev/LICENSE            |  23 ++
 .../nopt/node_modules/abbrev/README.md          |  23 ++
 .../nopt/node_modules/abbrev/abbrev.js          |  62 +++
 .../nopt/node_modules/abbrev/package.json       |  31 ++
 .../nopt/node_modules/abbrev/test.js            |  47 +++
 bin/node_modules/nopt/package.json              |  41 ++
 bin/node_modules/nopt/test/basic.js             | 251 +++++++++++
 bin/templates/scripts/cordova/build             |  92 ++---
 bin/templates/scripts/cordova/clean             |  69 ++--
 bin/templates/scripts/cordova/clean.bat         |  25 ++
 bin/templates/scripts/cordova/emulate           |  59 ---
 bin/templates/scripts/cordova/lib/build.js      | 147 +++++++
 bin/templates/scripts/cordova/lib/clean.js      |  46 +++
 .../scripts/cordova/lib/install-device          |  52 ---
 .../scripts/cordova/lib/install-emulator        |  91 ----
 bin/templates/scripts/cordova/lib/list-devices  |  85 ++--
 .../scripts/cordova/lib/list-emulator-images    |  92 +++--
 .../scripts/cordova/lib/list-started-emulators  |  81 ++--
 bin/templates/scripts/cordova/lib/run.js        | 177 ++++++++
 bin/templates/scripts/cordova/lib/spawn.js      |  50 +++
 bin/templates/scripts/cordova/run               | 222 ++--------
 bin/templates/scripts/cordova/run.bat           |  25 ++
 tests/spec/create.spec.js                       |   4 +
 36 files changed, 2191 insertions(+), 617 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/apple_xcode_version
----------------------------------------------------------------------
diff --git a/bin/apple_xcode_version b/bin/apple_xcode_version
index 5dfe501..112eba3 100755
--- a/bin/apple_xcode_version
+++ b/bin/apple_xcode_version
@@ -21,7 +21,9 @@
 
 var versions = require('./lib/versions.js');
 
-versions.get_apple_xcode_version().done(null, function(err) {
-    console.log(err);
+versions.get_apple_xcode_version().done(function (version) {
+    console.log(version);
+}, function(err) {
+    console.error(err);
     process.exit(2);
 });

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/check_reqs
----------------------------------------------------------------------
diff --git a/bin/check_reqs b/bin/check_reqs
index 4fc0bc3..ba68ceb 100755
--- a/bin/check_reqs
+++ b/bin/check_reqs
@@ -1,34 +1,32 @@
-#! /bin/sh
+#!/usr/bin/env node
 
-#
-# 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.
-#
+/*
+       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
 
-XCODEBUILD_LOCATION=$(which xcodebuild)
-if [ $? != 0 ]; then
-	echo "Xcode is (probably) not installed, specifically the command 'xcodebuild' is unavailable."
-	exit 2
-fi
+         http://www.apache.org/licenses/LICENSE-2.0
 
-XCODEBUILD_MIN_VERSION="4.6"
-XCODEBUILD_VERSION=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
+       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.
+*/
 
-if [[ "$XCODEBUILD_VERSION" < "$XCODEBUILD_MIN_VERSION" ]]; then
-	echo "Cordova can only run in Xcode version $XCODEBUILD_MIN_VERSION or greater."
-	exit 2
-fi
+var check_reqs = require('./lib/check_reqs');
+
+// check for help flag
+if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
+    check_reqs.help();
+} else {
+  check_reqs.run().done(null, function (err) {
+      console.error('Failed to check requirements due to ' + err);
+      process.exit(2);
+  });
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/bin/check_reqs.bat b/bin/check_reqs.bat
new file mode 100644
index 0000000..683914b
--- /dev/null
+++ b/bin/check_reqs.bat
@@ -0,0 +1,25 @@
+:: 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
+@ECHO OFF
+SET script_path="%~dp0check_reqs"
+IF EXIST %script_path% (
+        node "%script_path%" %*
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'check_reqs' script in 'bin' folder, aborting...>&2
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
new file mode 100644
index 0000000..6b4cce5
--- /dev/null
+++ b/bin/lib/check_reqs.js
@@ -0,0 +1,94 @@
+/*
+       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 node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
+          indent:4, unused:vars, latedef:nofunc,
+          sub:true, laxcomma:true, laxbreak:true
+*/
+
+var Q     = require('Q'),
+    os    = require('os'),
+    shell = require('shelljs'),
+    versions = require('./versions');
+
+var XCODEBUILD_MIN_VERSION = '4.6.0';
+
+var IOS_SIM_MIN_VERSION = '3.0.0';
+var IOS_SIM_NOT_FOUND_MESSAGE = 'ios-sim was not found. Please download, build and install version ' + IOS_SIM_MIN_VERSION +
+    ' or greater from https://github.com/phonegap/ios-sim into your path.' +
+    ' Or \'npm install -g ios-sim\' using node.js: http://nodejs.org';
+
+var IOS_DEPLOY_MIN_VERSION = '1.2.0';
+var IOS_DEPLOY_NOT_FOUND_MESSAGE = 'ios-deploy was not found. Please download, build and install version ' + IOS_DEPLOY_MIN_VERSION +
+    ' or greater from https://github.com/phonegap/ios-deploy into your path.' +
+    ' Or \'npm install -g ios-deploy\' using node.js: http://nodejs.org';
+
+/**
+ * Checks if xcode util is available
+ * @return {Promise} Returns a promise either resolved with xcode version or rejected
+ */
+module.exports.run = module.exports.check_xcodebuild = function () {
+    return checkTool('xcodebuild', XCODEBUILD_MIN_VERSION);
+};
+
+/**
+ * Checks if ios-deploy util is available
+ * @return {Promise} Returns a promise either resolved with ios-deploy version or rejected
+ */
+module.exports.check_ios_deploy = function () {
+    return checkTool('ios-deploy', IOS_DEPLOY_MIN_VERSION, IOS_DEPLOY_NOT_FOUND_MESSAGE);
+};
+
+/**
+ * Checks if ios-sim util is available
+ * @return {Promise} Returns a promise either resolved with ios-sim version or rejected
+ */
+module.exports.check_ios_sim = function () {
+    return checkTool('ios-sim', IOS_SIM_MIN_VERSION, IOS_SIM_NOT_FOUND_MESSAGE);
+};
+
+module.exports.help = function () {
+    console.log('Usage: check_reqs or node check_reqs');
+};
+
+/**
+ * Checks if specific tool is available.
+ * @param  {String} tool       Tool name to check. Known tools are 'xcodebuild', 'ios-sim' and 'ios-deploy'
+ * @param  {Number} minVersion Min allowed tool version.
+ * @param  {String} optMessage Message that will be used to reject promise.
+ * @return {Promise}           Returns a promise either resolved with tool version or rejected
+ */
+function checkTool (tool, minVersion, optMessage) {
+    if (os.platform() !== 'darwin'){
+        // Build iOS apps available for OSX platform only, so we reject on others platforms
+        return Q.reject('Cordova tooling for iOS requires Apple OS X');
+    }
+    // Check whether tool command is available at all
+    var tool_command = shell.which(tool);
+    if (!tool_command) {
+        return Q.reject(optMessage || (tool + 'command is unavailable.'));
+    }
+    // check if tool version is greater than specified one
+    return versions.get_tool_version(tool).then(function (version) {
+        return versions.compareVersions(version, minVersion) >= 0 ?
+            Q.resolve(version) :
+            Q.reject('Cordova needs ' + tool + ' version ' + minVersion +
+              ' or greater, you have version ' + version + '.');
+    });
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 8c37c80..a3371be 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -192,6 +192,7 @@ exports.createProject = function(argv) {
 
     //copy the check_reqs script
     shell.cp(path.join(bin_dir, 'check_reqs'), path.join(project_path, 'cordova'));
+    shell.cp(path.join(bin_dir, 'lib', 'check_reqs.js'), path.join(project_path, 'cordova', 'lib'));
 
     //copy the version scripts script
     shell.cp(path.join(bin_dir, 'apple_ios_version'), path.join(project_path, 'cordova'));

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/lib/versions.js
----------------------------------------------------------------------
diff --git a/bin/lib/versions.js b/bin/lib/versions.js
index 9a8eaec..78f3ec5 100755
--- a/bin/lib/versions.js
+++ b/bin/lib/versions.js
@@ -83,19 +83,96 @@ exports.get_apple_osx_version = function() {
 exports.get_apple_xcode_version = function() {
     var d = Q.defer();
     child_process.exec('xcodebuild -version', function(error, stdout, stderr) {
-        if (error) {
+        var versionMatch = /Xcode (.*)/.exec(stdout);
+        if (error || !versionMatch) {
             d.reject(stderr);
+        } else {
+            d.resolve(versionMatch[1]);
         }
-        else {
+    });
+    return d.promise;
+};
+
+/**
+ * Gets ios-deploy util version
+ * @return {Promise} Promise that either resolved with ios-deploy version
+ *                           or rejected in case of error
+ */
+exports.get_ios_deploy_version = function() {
+    var d = Q.defer();
+    child_process.exec('ios-deploy --version', function(error, stdout, stderr) {
+        if (error) {
+            d.reject(stderr);
+        } else {
             d.resolve(stdout);
         }
     });
+    return d.promise;
+};
 
-    return d.promise.then(function(output) {
-        output = output.split('\n');
-        console.log(output[0].slice(6));
-        return Q();
-    }, function(stderr) {
-        return Q.reject(stderr);
+/**
+ * Gets ios-sim util version
+ * @return {Promise} Promise that either resolved with ios-sim version
+ *                           or rejected in case of error
+ */
+exports.get_ios_sim_version = function() {
+    var d = Q.defer();
+    child_process.exec('ios-sim --version', function(error, stdout, stderr) {
+        if (error) {
+            d.reject(stderr);
+        } else {
+            d.resolve(stdout);
+        }
     });
-}
+    return d.promise;
+};
+
+/**
+ * Gets specific tool version
+ * @param  {String} toolName Tool name to check. Known tools are 'xcodebuild', 'ios-sim' and 'ios-deploy'
+ * @return {Promise}         Promise that either resolved with tool version
+ *                                   or rejected in case of error
+ */
+exports.get_tool_version = function (toolName) {
+    switch (toolName) {
+        case 'xcodebuild': return exports.get_apple_xcode_version();
+        case 'ios-sim': return exports.get_ios_sim_version();
+        case 'ios-deploy': return exports.get_ios_deploy_version();
+        default: return Q.reject(toolName + ' is not valid tool name. Valid names are: \'xcodebuild\', \'ios-sim\' and \'ios-deploy\'');
+    }
+};
+
+/**
+ * Compares two semver-notated version strings. Returns number
+ * that indicates equality of provided version strings.
+ * @param  {String} version1 Version to compare
+ * @param  {String} version2 Another version to compare
+ * @return {Number}          Negative number if first version is lower than the second,
+ *                                    positive otherwise and 0 if versions are equal.
+ */
+exports.compareVersions = function (version1, version2) {
+    function parseVer (version) {
+        return version.split('.').map(function (value) {
+            // try to convert version segment to Number
+            var parsed = Number(value);
+            // Number constructor is strict enough and will return NaN
+            // if conversion fails. In this case we won't be able to compare versions properly
+            if (isNaN(parsed)) {
+                throw "Version should contain only numbers and dots";
+            }
+            return parsed;
+        });
+    }
+    var parsedVer1 = parseVer(version1);
+    var parsedVer2 = parseVer(version2);
+
+    // Compare corresponding segments of each version
+    for (var i = 0; i < Math.max(parsedVer1.length, parsedVer2.length); i++) {
+        // if segment is not specified, assume that it is 0
+        // E.g. 3.1 is equal to 3.1.0
+        var ret = (parsedVer1[i] || 0) - (parsedVer2[i] || 0);
+        // if segments are not equal, we're finished
+        if (ret !== 0) return ret;
+    }
+    return 0;
+};

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/.npmignore
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/.npmignore b/bin/node_modules/nopt/.npmignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/bin/node_modules/nopt/.npmignore
@@ -0,0 +1 @@
+node_modules

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/LICENSE
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/LICENSE b/bin/node_modules/nopt/LICENSE
new file mode 100644
index 0000000..05a4010
--- /dev/null
+++ b/bin/node_modules/nopt/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/README.md
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/README.md b/bin/node_modules/nopt/README.md
new file mode 100644
index 0000000..5aba088
--- /dev/null
+++ b/bin/node_modules/nopt/README.md
@@ -0,0 +1,209 @@
+If you want to write an option parser, and have it be good, there are
+two ways to do it.  The Right Way, and the Wrong Way.
+
+The Wrong Way is to sit down and write an option parser.  We've all done
+that.
+
+The Right Way is to write some complex configurable program with so many
+options that you go half-insane just trying to manage them all, and put
+it off with duct-tape solutions until you see exactly to the core of the
+problem, and finally snap and write an awesome option parser.
+
+If you want to write an option parser, don't write an option parser.
+Write a package manager, or a source control system, or a service
+restarter, or an operating system.  You probably won't end up with a
+good one of those, but if you don't give up, and you are relentless and
+diligent enough in your procrastination, you may just end up with a very
+nice option parser.
+
+## USAGE
+
+    // my-program.js
+    var nopt = require("nopt")
+      , Stream = require("stream").Stream
+      , path = require("path")
+      , knownOpts = { "foo" : [String, null]
+                    , "bar" : [Stream, Number]
+                    , "baz" : path
+                    , "bloo" : [ "big", "medium", "small" ]
+                    , "flag" : Boolean
+                    , "pick" : Boolean
+                    , "many" : [String, Array]
+                    }
+      , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
+                     , "b7" : ["--bar", "7"]
+                     , "m" : ["--bloo", "medium"]
+                     , "p" : ["--pick"]
+                     , "f" : ["--flag"]
+                     }
+                 // everything is optional.
+                 // knownOpts and shorthands default to {}
+                 // arg list defaults to process.argv
+                 // slice defaults to 2
+      , parsed = nopt(knownOpts, shortHands, process.argv, 2)
+    console.log(parsed)
+
+This would give you support for any of the following:
+
+```bash
+$ node my-program.js --foo "blerp" --no-flag
+{ "foo" : "blerp", "flag" : false }
+
+$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag
+{ bar: 7, foo: "Mr. Hand", flag: true }
+
+$ node my-program.js --foo "blerp" -f -----p
+{ foo: "blerp", flag: true, pick: true }
+
+$ node my-program.js -fp --foofoo
+{ foo: "Mr. Foo", flag: true, pick: true }
+
+$ node my-program.js --foofoo -- -fp  # -- stops the flag parsing.
+{ foo: "Mr. Foo", argv: { remain: ["-fp"] } }
+
+$ node my-program.js --blatzk -fp # unknown opts are ok.
+{ blatzk: true, flag: true, pick: true }
+
+$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value
+{ blatzk: 1000, flag: true, pick: true }
+
+$ node my-program.js --no-blatzk -fp # unless they start with "no-"
+{ blatzk: false, flag: true, pick: true }
+
+$ node my-program.js --baz b/a/z # known paths are resolved.
+{ baz: "/Users/isaacs/b/a/z" }
+
+# if Array is one of the types, then it can take many
+# values, and will always be an array.  The other types provided
+# specify what types are allowed in the list.
+
+$ node my-program.js --many 1 --many null --many foo
+{ many: ["1", "null", "foo"] }
+
+$ node my-program.js --many foo
+{ many: ["foo"] }
+```
+
+Read the tests at the bottom of `lib/nopt.js` for more examples of
+what this puppy can do.
+
+## Types
+
+The following types are supported, and defined on `nopt.typeDefs`
+
+* String: A normal string.  No parsing is done.
+* path: A file system path.  Gets resolved against cwd if not absolute.
+* url: A url.  If it doesn't parse, it isn't accepted.
+* Number: Must be numeric.
+* Date: Must parse as a date. If it does, and `Date` is one of the options,
+  then it will return a Date object, not a string.
+* Boolean: Must be either `true` or `false`.  If an option is a boolean,
+  then it does not need a value, and its presence will imply `true` as
+  the value.  To negate boolean flags, do `--no-whatever` or `--whatever
+  false`
+* NaN: Means that the option is strictly not allowed.  Any value will
+  fail.
+* Stream: An object matching the "Stream" class in node.  Valuable
+  for use when validating programmatically.  (npm uses this to let you
+  supply any WriteStream on the `outfd` and `logfd` config options.)
+* Array: If `Array` is specified as one of the types, then the value
+  will be parsed as a list of options.  This means that multiple values
+  can be specified, and that the value will always be an array.
+
+If a type is an array of values not on this list, then those are
+considered valid values.  For instance, in the example above, the
+`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`,
+and any other value will be rejected.
+
+When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be
+interpreted as their JavaScript equivalents.
+
+You can also mix types and values, or multiple types, in a list.  For
+instance `{ blah: [Number, null] }` would allow a value to be set to
+either a Number or null.  When types are ordered, this implies a
+preference, and the first type that can be used to properly interpret
+the value will be used.
+
+To define a new type, add it to `nopt.typeDefs`.  Each item in that
+hash is an object with a `type` member and a `validate` method.  The
+`type` member is an object that matches what goes in the type list.  The
+`validate` method is a function that gets called with `validate(data,
+key, val)`.  Validate methods should assign `data[key]` to the valid
+value of `val` if it can be handled properly, or return boolean
+`false` if it cannot.
+
+You can also call `nopt.clean(data, types, typeDefs)` to clean up a
+config object and remove its invalid properties.
+
+## Error Handling
+
+By default, nopt outputs a warning to standard error when invalid
+options are found.  You can change this behavior by assigning a method
+to `nopt.invalidHandler`.  This method will be called with
+the offending `nopt.invalidHandler(key, val, types)`.
+
+If no `nopt.invalidHandler` is assigned, then it will console.error
+its whining.  If it is assigned to boolean `false` then the warning is
+suppressed.
+
+## Abbreviations
+
+Yes, they are supported.  If you define options like this:
+
+```javascript
+{ "foolhardyelephants" : Boolean
+, "pileofmonkeys" : Boolean }
+```
+
+Then this will work:
+
+```bash
+node program.js --foolhar --pil
+node program.js --no-f --pileofmon
+# etc.
+```
+
+## Shorthands
+
+Shorthands are a hash of shorter option names to a snippet of args that
+they expand to.
+
+If multiple one-character shorthands are all combined, and the
+combination does not unambiguously match any other option or shorthand,
+then they will be broken up into their constituent parts.  For example:
+
+```json
+{ "s" : ["--loglevel", "silent"]
+, "g" : "--global"
+, "f" : "--force"
+, "p" : "--parseable"
+, "l" : "--long"
+}
+```
+
+```bash
+npm ls -sgflp
+# just like doing this:
+npm ls --loglevel silent --global --force --long --parseable
+```
+
+## The Rest of the args
+
+The config object returned by nopt is given a special member called
+`argv`, which is an object with the following fields:
+
+* `remain`: The remaining args after all the parsing has occurred.
+* `original`: The args as they originally appeared.
+* `cooked`: The args after flags and shorthands are expanded.
+
+## Slicing
+
+Node programs are called with more or less the exact argv as it appears
+in C land, after the v8 and node-specific options have been plucked off.
+As such, `argv[0]` is always `node` and `argv[1]` is always the
+JavaScript program being run.
+
+That's usually not very useful to you.  So they're sliced off by
+default.  If you want them, then you can pass in `0` as the last
+argument, or any other number that you'd like to slice off the start of
+the list.

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/bin/nopt.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/bin/nopt.js b/bin/node_modules/nopt/bin/nopt.js
new file mode 100644
index 0000000..3232d4c
--- /dev/null
+++ b/bin/node_modules/nopt/bin/nopt.js
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+var nopt = require("../lib/nopt")
+  , path = require("path")
+  , types = { num: Number
+            , bool: Boolean
+            , help: Boolean
+            , list: Array
+            , "num-list": [Number, Array]
+            , "str-list": [String, Array]
+            , "bool-list": [Boolean, Array]
+            , str: String
+            , clear: Boolean
+            , config: Boolean
+            , length: Number
+            , file: path
+            }
+  , shorthands = { s: [ "--str", "astring" ]
+                 , b: [ "--bool" ]
+                 , nb: [ "--no-bool" ]
+                 , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ]
+                 , "?": ["--help"]
+                 , h: ["--help"]
+                 , H: ["--help"]
+                 , n: [ "--num", "125" ]
+                 , c: ["--config"]
+                 , l: ["--length"]
+                 , f: ["--file"]
+                 }
+  , parsed = nopt( types
+                 , shorthands
+                 , process.argv
+                 , 2 )
+
+console.log("parsed", parsed)
+
+if (parsed.help) {
+  console.log("")
+  console.log("nopt cli tester")
+  console.log("")
+  console.log("types")
+  console.log(Object.keys(types).map(function M (t) {
+    var type = types[t]
+    if (Array.isArray(type)) {
+      return [t, type.map(function (type) { return type.name })]
+    }
+    return [t, type && type.name]
+  }).reduce(function (s, i) {
+    s[i[0]] = i[1]
+    return s
+  }, {}))
+  console.log("")
+  console.log("shorthands")
+  console.log(shorthands)
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/examples/my-program.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/examples/my-program.js b/bin/node_modules/nopt/examples/my-program.js
new file mode 100644
index 0000000..142447e
--- /dev/null
+++ b/bin/node_modules/nopt/examples/my-program.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+//process.env.DEBUG_NOPT = 1
+
+// my-program.js
+var nopt = require("../lib/nopt")
+  , Stream = require("stream").Stream
+  , path = require("path")
+  , knownOpts = { "foo" : [String, null]
+                , "bar" : [Stream, Number]
+                , "baz" : path
+                , "bloo" : [ "big", "medium", "small" ]
+                , "flag" : Boolean
+                , "pick" : Boolean
+                }
+  , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
+                 , "b7" : ["--bar", "7"]
+                 , "m" : ["--bloo", "medium"]
+                 , "p" : ["--pick"]
+                 , "f" : ["--flag", "true"]
+                 , "g" : ["--flag"]
+                 , "s" : "--flag"
+                 }
+             // everything is optional.
+             // knownOpts and shorthands default to {}
+             // arg list defaults to process.argv
+             // slice defaults to 2
+  , parsed = nopt(knownOpts, shortHands, process.argv, 2)
+
+console.log("parsed =\n"+ require("util").inspect(parsed))

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/lib/nopt.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/lib/nopt.js b/bin/node_modules/nopt/lib/nopt.js
new file mode 100644
index 0000000..5309a00
--- /dev/null
+++ b/bin/node_modules/nopt/lib/nopt.js
@@ -0,0 +1,414 @@
+// info about each config option.
+
+var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG
+  ? function () { console.error.apply(console, arguments) }
+  : function () {}
+
+var url = require("url")
+  , path = require("path")
+  , Stream = require("stream").Stream
+  , abbrev = require("abbrev")
+
+module.exports = exports = nopt
+exports.clean = clean
+
+exports.typeDefs =
+  { String  : { type: String,  validate: validateString  }
+  , Boolean : { type: Boolean, validate: validateBoolean }
+  , url     : { type: url,     validate: validateUrl     }
+  , Number  : { type: Number,  validate: validateNumber  }
+  , path    : { type: path,    validate: validatePath    }
+  , Stream  : { type: Stream,  validate: validateStream  }
+  , Date    : { type: Date,    validate: validateDate    }
+  }
+
+function nopt (types, shorthands, args, slice) {
+  args = args || process.argv
+  types = types || {}
+  shorthands = shorthands || {}
+  if (typeof slice !== "number") slice = 2
+
+  debug(types, shorthands, args, slice)
+
+  args = args.slice(slice)
+  var data = {}
+    , key
+    , remain = []
+    , cooked = args
+    , original = args.slice(0)
+
+  parse(args, data, remain, types, shorthands)
+  // now data is full
+  clean(data, types, exports.typeDefs)
+  data.argv = {remain:remain,cooked:cooked,original:original}
+  Object.defineProperty(data.argv, 'toString', { value: function () {
+    return this.original.map(JSON.stringify).join(" ")
+  }, enumerable: false })
+  return data
+}
+
+function clean (data, types, typeDefs) {
+  typeDefs = typeDefs || exports.typeDefs
+  var remove = {}
+    , typeDefault = [false, true, null, String, Array]
+
+  Object.keys(data).forEach(function (k) {
+    if (k === "argv") return
+    var val = data[k]
+      , isArray = Array.isArray(val)
+      , type = types[k]
+    if (!isArray) val = [val]
+    if (!type) type = typeDefault
+    if (type === Array) type = typeDefault.concat(Array)
+    if (!Array.isArray(type)) type = [type]
+
+    debug("val=%j", val)
+    debug("types=", type)
+    val = val.map(function (val) {
+      // if it's an unknown value, then parse false/true/null/numbers/dates
+      if (typeof val === "string") {
+        debug("string %j", val)
+        val = val.trim()
+        if ((val === "null" && ~type.indexOf(null))
+            || (val === "true" &&
+               (~type.indexOf(true) || ~type.indexOf(Boolean)))
+            || (val === "false" &&
+               (~type.indexOf(false) || ~type.indexOf(Boolean)))) {
+          val = JSON.parse(val)
+          debug("jsonable %j", val)
+        } else if (~type.indexOf(Number) && !isNaN(val)) {
+          debug("convert to number", val)
+          val = +val
+        } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) {
+          debug("convert to date", val)
+          val = new Date(val)
+        }
+      }
+
+      if (!types.hasOwnProperty(k)) {
+        return val
+      }
+
+      // allow `--no-blah` to set 'blah' to null if null is allowed
+      if (val === false && ~type.indexOf(null) &&
+          !(~type.indexOf(false) || ~type.indexOf(Boolean))) {
+        val = null
+      }
+
+      var d = {}
+      d[k] = val
+      debug("prevalidated val", d, val, types[k])
+      if (!validate(d, k, val, types[k], typeDefs)) {
+        if (exports.invalidHandler) {
+          exports.invalidHandler(k, val, types[k], data)
+        } else if (exports.invalidHandler !== false) {
+          debug("invalid: "+k+"="+val, types[k])
+        }
+        return remove
+      }
+      debug("validated val", d, val, types[k])
+      return d[k]
+    }).filter(function (val) { return val !== remove })
+
+    if (!val.length) delete data[k]
+    else if (isArray) {
+      debug(isArray, data[k], val)
+      data[k] = val
+    } else data[k] = val[0]
+
+    debug("k=%s val=%j", k, val, data[k])
+  })
+}
+
+function validateString (data, k, val) {
+  data[k] = String(val)
+}
+
+function validatePath (data, k, val) {
+  if (val === true) return false
+  if (val === null) return true
+
+  val = String(val)
+  var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\//
+  if (val.match(homePattern) && process.env.HOME) {
+    val = path.resolve(process.env.HOME, val.substr(2))
+  }
+  data[k] = path.resolve(String(val))
+  return true
+}
+
+function validateNumber (data, k, val) {
+  debug("validate Number %j %j %j", k, val, isNaN(val))
+  if (isNaN(val)) return false
+  data[k] = +val
+}
+
+function validateDate (data, k, val) {
+  debug("validate Date %j %j %j", k, val, Date.parse(val))
+  var s = Date.parse(val)
+  if (isNaN(s)) return false
+  data[k] = new Date(val)
+}
+
+function validateBoolean (data, k, val) {
+  if (val instanceof Boolean) val = val.valueOf()
+  else if (typeof val === "string") {
+    if (!isNaN(val)) val = !!(+val)
+    else if (val === "null" || val === "false") val = false
+    else val = true
+  } else val = !!val
+  data[k] = val
+}
+
+function validateUrl (data, k, val) {
+  val = url.parse(String(val))
+  if (!val.host) return false
+  data[k] = val.href
+}
+
+function validateStream (data, k, val) {
+  if (!(val instanceof Stream)) return false
+  data[k] = val
+}
+
+function validate (data, k, val, type, typeDefs) {
+  // arrays are lists of types.
+  if (Array.isArray(type)) {
+    for (var i = 0, l = type.length; i < l; i ++) {
+      if (type[i] === Array) continue
+      if (validate(data, k, val, type[i], typeDefs)) return true
+    }
+    delete data[k]
+    return false
+  }
+
+  // an array of anything?
+  if (type === Array) return true
+
+  // NaN is poisonous.  Means that something is not allowed.
+  if (type !== type) {
+    debug("Poison NaN", k, val, type)
+    delete data[k]
+    return false
+  }
+
+  // explicit list of values
+  if (val === type) {
+    debug("Explicitly allowed %j", val)
+    // if (isArray) (data[k] = data[k] || []).push(val)
+    // else data[k] = val
+    data[k] = val
+    return true
+  }
+
+  // now go through the list of typeDefs, validate against each one.
+  var ok = false
+    , types = Object.keys(typeDefs)
+  for (var i = 0, l = types.length; i < l; i ++) {
+    debug("test type %j %j %j", k, val, types[i])
+    var t = typeDefs[types[i]]
+    if (t && type === t.type) {
+      var d = {}
+      ok = false !== t.validate(d, k, val)
+      val = d[k]
+      if (ok) {
+        // if (isArray) (data[k] = data[k] || []).push(val)
+        // else data[k] = val
+        data[k] = val
+        break
+      }
+    }
+  }
+  debug("OK? %j (%j %j %j)", ok, k, val, types[i])
+
+  if (!ok) delete data[k]
+  return ok
+}
+
+function parse (args, data, remain, types, shorthands) {
+  debug("parse", args, data, remain)
+
+  var key = null
+    , abbrevs = abbrev(Object.keys(types))
+    , shortAbbr = abbrev(Object.keys(shorthands))
+
+  for (var i = 0; i < args.length; i ++) {
+    var arg = args[i]
+    debug("arg", arg)
+
+    if (arg.match(/^-{2,}$/)) {
+      // done with keys.
+      // the rest are args.
+      remain.push.apply(remain, args.slice(i + 1))
+      args[i] = "--"
+      break
+    }
+    var hadEq = false
+    if (arg.charAt(0) === "-" && arg.length > 1) {
+      if (arg.indexOf("=") !== -1) {
+        hadEq = true
+        var v = arg.split("=")
+        arg = v.shift()
+        v = v.join("=")
+        args.splice.apply(args, [i, 1].concat([arg, v]))
+      }
+
+      // see if it's a shorthand
+      // if so, splice and back up to re-parse it.
+      var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs)
+      debug("arg=%j shRes=%j", arg, shRes)
+      if (shRes) {
+        debug(arg, shRes)
+        args.splice.apply(args, [i, 1].concat(shRes))
+        if (arg !== shRes[0]) {
+          i --
+          continue
+        }
+      }
+      arg = arg.replace(/^-+/, "")
+      var no = null
+      while (arg.toLowerCase().indexOf("no-") === 0) {
+        no = !no
+        arg = arg.substr(3)
+      }
+
+      if (abbrevs[arg]) arg = abbrevs[arg]
+
+      var isArray = types[arg] === Array ||
+        Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1
+
+      // allow unknown things to be arrays if specified multiple times.
+      if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) {
+        if (!Array.isArray(data[arg]))
+          data[arg] = [data[arg]]
+        isArray = true
+      }
+
+      var val
+        , la = args[i + 1]
+
+      var isBool = typeof no === 'boolean' ||
+        types[arg] === Boolean ||
+        Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 ||
+        (typeof types[arg] === 'undefined' && !hadEq) ||
+        (la === "false" &&
+         (types[arg] === null ||
+          Array.isArray(types[arg]) && ~types[arg].indexOf(null)))
+
+      if (isBool) {
+        // just set and move along
+        val = !no
+        // however, also support --bool true or --bool false
+        if (la === "true" || la === "false") {
+          val = JSON.parse(la)
+          la = null
+          if (no) val = !val
+          i ++
+        }
+
+        // also support "foo":[Boolean, "bar"] and "--foo bar"
+        if (Array.isArray(types[arg]) && la) {
+          if (~types[arg].indexOf(la)) {
+            // an explicit type
+            val = la
+            i ++
+          } else if ( la === "null" && ~types[arg].indexOf(null) ) {
+            // null allowed
+            val = null
+            i ++
+          } else if ( !la.match(/^-{2,}[^-]/) &&
+                      !isNaN(la) &&
+                      ~types[arg].indexOf(Number) ) {
+            // number
+            val = +la
+            i ++
+          } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) {
+            // string
+            val = la
+            i ++
+          }
+        }
+
+        if (isArray) (data[arg] = data[arg] || []).push(val)
+        else data[arg] = val
+
+        continue
+      }
+
+      if (types[arg] === String && la === undefined)
+        la = ""
+
+      if (la && la.match(/^-{2,}$/)) {
+        la = undefined
+        i --
+      }
+
+      val = la === undefined ? true : la
+      if (isArray) (data[arg] = data[arg] || []).push(val)
+      else data[arg] = val
+
+      i ++
+      continue
+    }
+    remain.push(arg)
+  }
+}
+
+function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
+  // handle single-char shorthands glommed together, like
+  // npm ls -glp, but only if there is one dash, and only if
+  // all of the chars are single-char shorthands, and it's
+  // not a match to some other abbrev.
+  arg = arg.replace(/^-+/, '')
+
+  // if it's an exact known option, then don't go any further
+  if (abbrevs[arg] === arg)
+    return null
+
+  // if it's an exact known shortopt, same deal
+  if (shorthands[arg]) {
+    // make it an array, if it's a list of words
+    if (shorthands[arg] && !Array.isArray(shorthands[arg]))
+      shorthands[arg] = shorthands[arg].split(/\s+/)
+
+    return shorthands[arg]
+  }
+
+  // first check to see if this arg is a set of single-char shorthands
+  var singles = shorthands.___singles
+  if (!singles) {
+    singles = Object.keys(shorthands).filter(function (s) {
+      return s.length === 1
+    }).reduce(function (l,r) {
+      l[r] = true
+      return l
+    }, {})
+    shorthands.___singles = singles
+    debug('shorthand singles', singles)
+  }
+
+  var chrs = arg.split("").filter(function (c) {
+    return singles[c]
+  })
+
+  if (chrs.join("") === arg) return chrs.map(function (c) {
+    return shorthands[c]
+  }).reduce(function (l, r) {
+    return l.concat(r)
+  }, [])
+
+
+  // if it's an arg abbrev, and not a literal shorthand, then prefer the arg
+  if (abbrevs[arg] && !shorthands[arg])
+    return null
+
+  // if it's an abbr for a shorthand, then use that
+  if (shortAbbr[arg])
+    arg = shortAbbr[arg]
+
+  // make it an array, if it's a list of words
+  if (shorthands[arg] && !Array.isArray(shorthands[arg]))
+    shorthands[arg] = shorthands[arg].split(/\s+/)
+
+  return shorthands[arg]
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/bin/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md
new file mode 100644
index 0000000..2f30261
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md
@@ -0,0 +1,3 @@
+ To get started, <a
+ href="http://www.clahub.com/agreements/isaacs/abbrev-js">sign the
+ Contributor License Agreement</a>.

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/LICENSE
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/LICENSE b/bin/node_modules/nopt/node_modules/abbrev/LICENSE
new file mode 100644
index 0000000..05a4010
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/README.md
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/README.md b/bin/node_modules/nopt/node_modules/abbrev/README.md
new file mode 100644
index 0000000..99746fe
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/README.md
@@ -0,0 +1,23 @@
+# abbrev-js
+
+Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).
+
+Usage:
+
+    var abbrev = require("abbrev");
+    abbrev("foo", "fool", "folding", "flop");
+    
+    // returns:
+    { fl: 'flop'
+    , flo: 'flop'
+    , flop: 'flop'
+    , fol: 'folding'
+    , fold: 'folding'
+    , foldi: 'folding'
+    , foldin: 'folding'
+    , folding: 'folding'
+    , foo: 'foo'
+    , fool: 'fool'
+    }
+
+This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/abbrev.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/abbrev.js b/bin/node_modules/nopt/node_modules/abbrev/abbrev.js
new file mode 100644
index 0000000..69cfeac
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/abbrev.js
@@ -0,0 +1,62 @@
+
+module.exports = exports = abbrev.abbrev = abbrev
+
+abbrev.monkeyPatch = monkeyPatch
+
+function monkeyPatch () {
+  Object.defineProperty(Array.prototype, 'abbrev', {
+    value: function () { return abbrev(this) },
+    enumerable: false, configurable: true, writable: true
+  })
+
+  Object.defineProperty(Object.prototype, 'abbrev', {
+    value: function () { return abbrev(Object.keys(this)) },
+    enumerable: false, configurable: true, writable: true
+  })
+}
+
+function abbrev (list) {
+  if (arguments.length !== 1 || !Array.isArray(list)) {
+    list = Array.prototype.slice.call(arguments, 0)
+  }
+  for (var i = 0, l = list.length, args = [] ; i < l ; i ++) {
+    args[i] = typeof list[i] === "string" ? list[i] : String(list[i])
+  }
+
+  // sort them lexicographically, so that they're next to their nearest kin
+  args = args.sort(lexSort)
+
+  // walk through each, seeing how much it has in common with the next and previous
+  var abbrevs = {}
+    , prev = ""
+  for (var i = 0, l = args.length ; i < l ; i ++) {
+    var current = args[i]
+      , next = args[i + 1] || ""
+      , nextMatches = true
+      , prevMatches = true
+    if (current === next) continue
+    for (var j = 0, cl = current.length ; j < cl ; j ++) {
+      var curChar = current.charAt(j)
+      nextMatches = nextMatches && curChar === next.charAt(j)
+      prevMatches = prevMatches && curChar === prev.charAt(j)
+      if (!nextMatches && !prevMatches) {
+        j ++
+        break
+      }
+    }
+    prev = current
+    if (j === cl) {
+      abbrevs[current] = current
+      continue
+    }
+    for (var a = current.substr(0, j) ; j <= cl ; j ++) {
+      abbrevs[a] = current
+      a += current.charAt(j)
+    }
+  }
+  return abbrevs
+}
+
+function lexSort (a, b) {
+  return a === b ? 0 : a > b ? 1 : -1
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/package.json
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/package.json b/bin/node_modules/nopt/node_modules/abbrev/package.json
new file mode 100644
index 0000000..91f1dd9
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/package.json
@@ -0,0 +1,31 @@
+{
+  "name": "abbrev",
+  "version": "1.0.5",
+  "description": "Like ruby's abbrev module, but in js",
+  "author": {
+    "name": "Isaac Z. Schlueter",
+    "email": "i@izs.me"
+  },
+  "main": "abbrev.js",
+  "scripts": {
+    "test": "node test.js"
+  },
+  "repository": {
+    "type": "git",
+    "url": "http://github.com/isaacs/abbrev-js"
+  },
+  "license": {
+    "type": "MIT",
+    "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE"
+  },
+  "readme": "# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n    var abbrev = require(\"abbrev\");\n    abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n    \n    // returns:\n    { fl: 'flop'\n    , flo: 'flop'\n    , flop: 'flop'\n    , fol: 'folding'\n    , fold: 'folding'\n    , foldi: 'folding'\n    , foldin: 'folding'\n    , folding: 'folding'\n    , foo: 'foo'\n    , fool: 'fool'\n    }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n",
+  "readmeFilename": "README.md",
+  "bugs": {
+    "url": "https://github.com/isaacs/abbrev-js/issues"
+  },
+  "homepage": "https://github.com/isaacs/abbrev-js",
+  "_id": "abbrev@1.0.5",
+  "_shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03",
+  "_from": "abbrev@1",
+  "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz"
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/node_modules/abbrev/test.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/node_modules/abbrev/test.js b/bin/node_modules/nopt/node_modules/abbrev/test.js
new file mode 100644
index 0000000..d5a7303
--- /dev/null
+++ b/bin/node_modules/nopt/node_modules/abbrev/test.js
@@ -0,0 +1,47 @@
+var abbrev = require('./abbrev.js')
+var assert = require("assert")
+var util = require("util")
+
+console.log("TAP Version 13")
+var count = 0
+
+function test (list, expect) {
+  count++
+  var actual = abbrev(list)
+  assert.deepEqual(actual, expect,
+    "abbrev("+util.inspect(list)+") === " + util.inspect(expect) + "\n"+
+    "actual: "+util.inspect(actual))
+  actual = abbrev.apply(exports, list)
+  assert.deepEqual(abbrev.apply(exports, list), expect,
+    "abbrev("+list.map(JSON.stringify).join(",")+") === " + util.inspect(expect) + "\n"+
+    "actual: "+util.inspect(actual))
+  console.log('ok - ' + list.join(' '))
+}
+
+test([ "ruby", "ruby", "rules", "rules", "rules" ],
+{ rub: 'ruby'
+, ruby: 'ruby'
+, rul: 'rules'
+, rule: 'rules'
+, rules: 'rules'
+})
+test(["fool", "foom", "pool", "pope"],
+{ fool: 'fool'
+, foom: 'foom'
+, poo: 'pool'
+, pool: 'pool'
+, pop: 'pope'
+, pope: 'pope'
+})
+test(["a", "ab", "abc", "abcd", "abcde", "acde"],
+{ a: 'a'
+, ab: 'ab'
+, abc: 'abc'
+, abcd: 'abcd'
+, abcde: 'abcde'
+, ac: 'acde'
+, acd: 'acde'
+, acde: 'acde'
+})
+
+console.log("0..%d", count)

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/package.json
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/package.json b/bin/node_modules/nopt/package.json
new file mode 100644
index 0000000..62d0fe8
--- /dev/null
+++ b/bin/node_modules/nopt/package.json
@@ -0,0 +1,41 @@
+{
+  "name": "nopt",
+  "version": "3.0.1",
+  "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
+  "author": {
+    "name": "Isaac Z. Schlueter",
+    "email": "i@izs.me",
+    "url": "http://blog.izs.me/"
+  },
+  "main": "lib/nopt.js",
+  "scripts": {
+    "test": "tap test/*.js"
+  },
+  "repository": {
+    "type": "git",
+    "url": "http://github.com/isaacs/nopt"
+  },
+  "bin": {
+    "nopt": "./bin/nopt.js"
+  },
+  "license": {
+    "type": "MIT",
+    "url": "https://github.com/isaacs/nopt/raw/master/LICENSE"
+  },
+  "dependencies": {
+    "abbrev": "1"
+  },
+  "devDependencies": {
+    "tap": "~0.4.8"
+  },
+  "readme": "If you want to write an option parser, and have it be good, there are\ntwo ways to do it.  The Right Way, and the Wrong Way.\n\nThe Wrong Way is to sit down and write an option parser.  We've all done\nthat.\n\nThe Right Way is to write some complex configurable program with so many\noptions that you go half-insane just trying to manage them all, and put\nit off with duct-tape solutions until you see exactly to the core of the\nproblem, and finally snap and write an awesome option parser.\n\nIf you want to write an option parser, don't write an option parser.\nWrite a package manager, or a source control system, or a service\nrestarter, or an operating system.  You probably won't end up with a\ngood one of those, but if you don't give up, and you are relentless and\ndiligent enough in your procrastination, you may just end up with a very\nnice option parser.\n\n## USAGE\n\n    // my-program.js\n    var nopt = require(\"nopt\")\n      , Stream = require(\"stream\").Strea
 m\n      , path = require(\"path\")\n      , knownOpts = { \"foo\" : [String, null]\n                    , \"bar\" : [Stream, Number]\n                    , \"baz\" : path\n                    , \"bloo\" : [ \"big\", \"medium\", \"small\" ]\n                    , \"flag\" : Boolean\n                    , \"pick\" : Boolean\n                    , \"many\" : [String, Array]\n                    }\n      , shortHands = { \"foofoo\" : [\"--foo\", \"Mr. Foo\"]\n                     , \"b7\" : [\"--bar\", \"7\"]\n                     , \"m\" : [\"--bloo\", \"medium\"]\n                     , \"p\" : [\"--pick\"]\n                     , \"f\" : [\"--flag\"]\n                     }\n                 // everything is optional.\n                 // knownOpts and shorthands default to {}\n                 // arg list defaults to process.argv\n                 // slice defaults to 2\n      , parsed = nopt(knownOpts, shortHands, process.argv, 2)\n    console.log(parsed)\n\nThis would give you su
 pport for any of the following:\n\n```bash\n$ node my-program.js --foo \"blerp\" --no-flag\n{ \"foo\" : \"blerp\", \"flag\" : false }\n\n$ node my-program.js ---bar 7 --foo \"Mr. Hand\" --flag\n{ bar: 7, foo: \"Mr. Hand\", flag: true }\n\n$ node my-program.js --foo \"blerp\" -f -----p\n{ foo: \"blerp\", flag: true, pick: true }\n\n$ node my-program.js -fp --foofoo\n{ foo: \"Mr. Foo\", flag: true, pick: true }\n\n$ node my-program.js --foofoo -- -fp  # -- stops the flag parsing.\n{ foo: \"Mr. Foo\", argv: { remain: [\"-fp\"] } }\n\n$ node my-program.js --blatzk -fp # unknown opts are ok.\n{ blatzk: true, flag: true, pick: true }\n\n$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value\n{ blatzk: 1000, flag: true, pick: true }\n\n$ node my-program.js --no-blatzk -fp # unless they start with \"no-\"\n{ blatzk: false, flag: true, pick: true }\n\n$ node my-program.js --baz b/a/z # known paths are resolved.\n{ baz: \"/Users/isaacs/b/a/z\" }\n\n# if Array is o
 ne of the types, then it can take many\n# values, and will always be an array.  The other types provided\n# specify what types are allowed in the list.\n\n$ node my-program.js --many 1 --many null --many foo\n{ many: [\"1\", \"null\", \"foo\"] }\n\n$ node my-program.js --many foo\n{ many: [\"foo\"] }\n```\n\nRead the tests at the bottom of `lib/nopt.js` for more examples of\nwhat this puppy can do.\n\n## Types\n\nThe following types are supported, and defined on `nopt.typeDefs`\n\n* String: A normal string.  No parsing is done.\n* path: A file system path.  Gets resolved against cwd if not absolute.\n* url: A url.  If it doesn't parse, it isn't accepted.\n* Number: Must be numeric.\n* Date: Must parse as a date. If it does, and `Date` is one of the options,\n  then it will return a Date object, not a string.\n* Boolean: Must be either `true` or `false`.  If an option is a boolean,\n  then it does not need a value, and its presence will imply `true` as\n  the value.  To negate boolea
 n flags, do `--no-whatever` or `--whatever\n  false`\n* NaN: Means that the option is strictly not allowed.  Any value will\n  fail.\n* Stream: An object matching the \"Stream\" class in node.  Valuable\n  for use when validating programmatically.  (npm uses this to let you\n  supply any WriteStream on the `outfd` and `logfd` config options.)\n* Array: If `Array` is specified as one of the types, then the value\n  will be parsed as a list of options.  This means that multiple values\n  can be specified, and that the value will always be an array.\n\nIf a type is an array of values not on this list, then those are\nconsidered valid values.  For instance, in the example above, the\n`--bloo` option can only be one of `\"big\"`, `\"medium\"`, or `\"small\"`,\nand any other value will be rejected.\n\nWhen parsing unknown fields, `\"true\"`, `\"false\"`, and `\"null\"` will be\ninterpreted as their JavaScript equivalents.\n\nYou can also mix types and values, or multiple types, in a list.
   For\ninstance `{ blah: [Number, null] }` would allow a value to be set to\neither a Number or null.  When types are ordered, this implies a\npreference, and the first type that can be used to properly interpret\nthe value will be used.\n\nTo define a new type, add it to `nopt.typeDefs`.  Each item in that\nhash is an object with a `type` member and a `validate` method.  The\n`type` member is an object that matches what goes in the type list.  The\n`validate` method is a function that gets called with `validate(data,\nkey, val)`.  Validate methods should assign `data[key]` to the valid\nvalue of `val` if it can be handled properly, or return boolean\n`false` if it cannot.\n\nYou can also call `nopt.clean(data, types, typeDefs)` to clean up a\nconfig object and remove its invalid properties.\n\n## Error Handling\n\nBy default, nopt outputs a warning to standard error when invalid\noptions are found.  You can change this behavior by assigning a method\nto `nopt.invalidHandler`.  This
  method will be called with\nthe offending `nopt.invalidHandler(key, val, types)`.\n\nIf no `nopt.invalidHandler` is assigned, then it will console.error\nits whining.  If it is assigned to boolean `false` then the warning is\nsuppressed.\n\n## Abbreviations\n\nYes, they are supported.  If you define options like this:\n\n```javascript\n{ \"foolhardyelephants\" : Boolean\n, \"pileofmonkeys\" : Boolean }\n```\n\nThen this will work:\n\n```bash\nnode program.js --foolhar --pil\nnode program.js --no-f --pileofmon\n# etc.\n```\n\n## Shorthands\n\nShorthands are a hash of shorter option names to a snippet of args that\nthey expand to.\n\nIf multiple one-character shorthands are all combined, and the\ncombination does not unambiguously match any other option or shorthand,\nthen they will be broken up into their constituent parts.  For example:\n\n```json\n{ \"s\" : [\"--loglevel\", \"silent\"]\n, \"g\" : \"--global\"\n, \"f\" : \"--force\"\n, \"p\" : \"--parseable\"\n, \"l\" : \"--long\"\
 n}\n```\n\n```bash\nnpm ls -sgflp\n# just like doing this:\nnpm ls --loglevel silent --global --force --long --parseable\n```\n\n## The Rest of the args\n\nThe config object returned by nopt is given a special member called\n`argv`, which is an object with the following fields:\n\n* `remain`: The remaining args after all the parsing has occurred.\n* `original`: The args as they originally appeared.\n* `cooked`: The args after flags and shorthands are expanded.\n\n## Slicing\n\nNode programs are called with more or less the exact argv as it appears\nin C land, after the v8 and node-specific options have been plucked off.\nAs such, `argv[0]` is always `node` and `argv[1]` is always the\nJavaScript program being run.\n\nThat's usually not very useful to you.  So they're sliced off by\ndefault.  If you want them, then you can pass in `0` as the last\nargument, or any other number that you'd like to slice off the start of\nthe list.\n",
+  "readmeFilename": "README.md",
+  "bugs": {
+    "url": "https://github.com/isaacs/nopt/issues"
+  },
+  "homepage": "https://github.com/isaacs/nopt",
+  "_id": "nopt@3.0.1",
+  "_shasum": "bce5c42446a3291f47622a370abbf158fbbacbfd",
+  "_from": "nopt@",
+  "_resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.1.tgz"
+}

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/node_modules/nopt/test/basic.js
----------------------------------------------------------------------
diff --git a/bin/node_modules/nopt/test/basic.js b/bin/node_modules/nopt/test/basic.js
new file mode 100644
index 0000000..2f9088c
--- /dev/null
+++ b/bin/node_modules/nopt/test/basic.js
@@ -0,0 +1,251 @@
+var nopt = require("../")
+  , test = require('tap').test
+
+
+test("passing a string results in a string", function (t) {
+  var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0)
+  t.same(parsed.key, "myvalue")
+  t.end()
+})
+
+// https://github.com/npm/nopt/issues/31
+test("Empty String results in empty string, not true", function (t) {
+  var parsed = nopt({ empty: String }, {}, ["--empty"], 0)
+  t.same(parsed.empty, "")
+  t.end()
+})
+
+test("~ path is resolved to $HOME", function (t) {
+  var path = require("path")
+  if (!process.env.HOME) process.env.HOME = "/tmp"
+  var parsed = nopt({key: path}, {}, ["--key=~/val"], 0)
+  t.same(parsed.key, path.resolve(process.env.HOME, "val"))
+  t.end()
+})
+
+// https://github.com/npm/nopt/issues/24
+test("Unknown options are not parsed as numbers", function (t) {
+    var parsed = nopt({"parse-me": Number}, null, ['--leave-as-is=1.20', '--parse-me=1.20'], 0)
+    t.equal(parsed['leave-as-is'], '1.20')
+    t.equal(parsed['parse-me'], 1.2)
+    t.end()
+});
+
+test("other tests", function (t) {
+
+  var util = require("util")
+    , Stream = require("stream")
+    , path = require("path")
+    , url = require("url")
+
+    , shorthands =
+      { s : ["--loglevel", "silent"]
+      , d : ["--loglevel", "info"]
+      , dd : ["--loglevel", "verbose"]
+      , ddd : ["--loglevel", "silly"]
+      , noreg : ["--no-registry"]
+      , reg : ["--registry"]
+      , "no-reg" : ["--no-registry"]
+      , silent : ["--loglevel", "silent"]
+      , verbose : ["--loglevel", "verbose"]
+      , h : ["--usage"]
+      , H : ["--usage"]
+      , "?" : ["--usage"]
+      , help : ["--usage"]
+      , v : ["--version"]
+      , f : ["--force"]
+      , desc : ["--description"]
+      , "no-desc" : ["--no-description"]
+      , "local" : ["--no-global"]
+      , l : ["--long"]
+      , p : ["--parseable"]
+      , porcelain : ["--parseable"]
+      , g : ["--global"]
+      }
+
+    , types =
+      { aoa: Array
+      , nullstream: [null, Stream]
+      , date: Date
+      , str: String
+      , browser : String
+      , cache : path
+      , color : ["always", Boolean]
+      , depth : Number
+      , description : Boolean
+      , dev : Boolean
+      , editor : path
+      , force : Boolean
+      , global : Boolean
+      , globalconfig : path
+      , group : [String, Number]
+      , gzipbin : String
+      , logfd : [Number, Stream]
+      , loglevel : ["silent","win","error","warn","info","verbose","silly"]
+      , long : Boolean
+      , "node-version" : [false, String]
+      , npaturl : url
+      , npat : Boolean
+      , "onload-script" : [false, String]
+      , outfd : [Number, Stream]
+      , parseable : Boolean
+      , pre: Boolean
+      , prefix: path
+      , proxy : url
+      , "rebuild-bundle" : Boolean
+      , registry : url
+      , searchopts : String
+      , searchexclude: [null, String]
+      , shell : path
+      , t: [Array, String]
+      , tag : String
+      , tar : String
+      , tmp : path
+      , "unsafe-perm" : Boolean
+      , usage : Boolean
+      , user : String
+      , username : String
+      , userconfig : path
+      , version : Boolean
+      , viewer: path
+      , _exit : Boolean
+      , path: path
+      }
+
+  ; [["-v", {version:true}, []]
+    ,["---v", {version:true}, []]
+    ,["ls -s --no-reg connect -d",
+      {loglevel:"info",registry:null},["ls","connect"]]
+    ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]]
+    ,["ls --registry blargle", {}, ["ls"]]
+    ,["--no-registry", {registry:null}, []]
+    ,["--no-color true", {color:false}, []]
+    ,["--no-color false", {color:true}, []]
+    ,["--no-color", {color:false}, []]
+    ,["--color false", {color:false}, []]
+    ,["--color --logfd 7", {logfd:7,color:true}, []]
+    ,["--color=true", {color:true}, []]
+    ,["--logfd=10", {logfd:10}, []]
+    ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]]
+    ,["--tmp=tmp -tar=gtar",
+      {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]]
+    ,["--logfd x", {}, []]
+    ,["a -true -- -no-false", {true:true},["a","-no-false"]]
+    ,["a -no-false", {false:false},["a"]]
+    ,["a -no-no-true", {true:true}, ["a"]]
+    ,["a -no-no-no-false", {false:false}, ["a"]]
+    ,["---NO-no-No-no-no-no-nO-no-no"+
+      "-No-no-no-no-no-no-no-no-no"+
+      "-no-no-no-no-NO-NO-no-no-no-no-no-no"+
+      "-no-body-can-do-the-boogaloo-like-I-do"
+     ,{"body-can-do-the-boogaloo-like-I-do":false}, []]
+    ,["we are -no-strangers-to-love "+
+      "--you-know=the-rules --and=so-do-i "+
+      "---im-thinking-of=a-full-commitment "+
+      "--no-you-would-get-this-from-any-other-guy "+
+      "--no-gonna-give-you-up "+
+      "-no-gonna-let-you-down=true "+
+      "--no-no-gonna-run-around false "+
+      "--desert-you=false "+
+      "--make-you-cry false "+
+      "--no-tell-a-lie "+
+      "--no-no-and-hurt-you false"
+     ,{"strangers-to-love":false
+      ,"you-know":"the-rules"
+      ,"and":"so-do-i"
+      ,"you-would-get-this-from-any-other-guy":false
+      ,"gonna-give-you-up":false
+      ,"gonna-let-you-down":false
+      ,"gonna-run-around":false
+      ,"desert-you":false
+      ,"make-you-cry":false
+      ,"tell-a-lie":false
+      ,"and-hurt-you":false
+      },["we", "are"]]
+    ,["-t one -t two -t three"
+     ,{t: ["one", "two", "three"]}
+     ,[]]
+    ,["-t one -t null -t three four five null"
+     ,{t: ["one", "null", "three"]}
+     ,["four", "five", "null"]]
+    ,["-t foo"
+     ,{t:["foo"]}
+     ,[]]
+    ,["--no-t"
+     ,{t:["false"]}
+     ,[]]
+    ,["-no-no-t"
+     ,{t:["true"]}
+     ,[]]
+    ,["-aoa one -aoa null -aoa 100"
+     ,{aoa:["one", null, '100']}
+     ,[]]
+    ,["-str 100"
+     ,{str:"100"}
+     ,[]]
+    ,["--color always"
+     ,{color:"always"}
+     ,[]]
+    ,["--no-nullstream"
+     ,{nullstream:null}
+     ,[]]
+    ,["--nullstream false"
+     ,{nullstream:null}
+     ,[]]
+    ,["--notadate=2011-01-25"
+     ,{notadate: "2011-01-25"}
+     ,[]]
+    ,["--date 2011-01-25"
+     ,{date: new Date("2011-01-25")}
+     ,[]]
+    ,["-cl 1"
+     ,{config: true, length: 1}
+     ,[]
+     ,{config: Boolean, length: Number, clear: Boolean}
+     ,{c: "--config", l: "--length"}]
+    ,["--acount bla"
+     ,{"acount":true}
+     ,["bla"]
+     ,{account: Boolean, credentials: Boolean, options: String}
+     ,{a:"--account", c:"--credentials",o:"--options"}]
+    ,["--clear"
+     ,{clear:true}
+     ,[]
+     ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean}
+     ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}]
+    ,["--file -"
+     ,{"file":"-"}
+     ,[]
+     ,{file:String}
+     ,{}]
+    ,["--file -"
+     ,{"file":true}
+     ,["-"]
+     ,{file:Boolean}
+     ,{}]
+    ,["--path"
+     ,{"path":null}
+     ,[]]
+    ,["--path ."
+     ,{"path":process.cwd()}
+     ,[]]
+    ].forEach(function (test) {
+      var argv = test[0].split(/\s+/)
+        , opts = test[1]
+        , rem = test[2]
+        , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0)
+        , parsed = actual.argv
+      delete actual.argv
+      for (var i in opts) {
+        var e = JSON.stringify(opts[i])
+          , a = JSON.stringify(actual[i] === undefined ? null : actual[i])
+        if (e && typeof e === "object") {
+          t.deepEqual(e, a)
+        } else {
+          t.equal(e, a)
+        }
+      }
+      t.deepEqual(rem, parsed.remain)
+    })
+  t.end()
+})

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/build
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/build b/bin/templates/scripts/cordova/build
index 9df2be0..5007627 100755
--- a/bin/templates/scripts/cordova/build
+++ b/bin/templates/scripts/cordova/build
@@ -1,56 +1,36 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-#
-# compile and launch a Cordova/iOS project to the simulator
-#
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-source "$CORDOVA_PATH/check_reqs"
-
-cd "$PROJECT_PATH"
-
-APP=build/$PROJECT_NAME.app
-
-CONFIGURATION=Debug
-EMULATOR=1
-DEVICE=0
-while [[ $# -gt 0 ]]; do
-    case "$1" in
-        --debug) ;;
-        --release) CONFIGURATION=Release;;
-        --device) EMULATOR=0;;
-        --emulator) ;;
-        *) echo "Unrecognized flag: $1"; exit 2;;
-    esac
-    shift
-done
-
-if (( $EMULATOR )); then
-    exec xcodebuild -project "$PROJECT_NAME.xcodeproj" -arch i386 -target "$PROJECT_NAME" -configuration $CONFIGURATION -sdk iphonesimulator build VALID_ARCHS="i386" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/emulator" SHARED_PRECOMPS_DIR="$PROJECT_PATH/build/sharedpch"
-else
-    exec xcodebuild -xcconfig "$CORDOVA_PATH/build$(echo -$CONFIGURATION | tr '[:upper:]' '[:lower:]').xcconfig" -project "$PROJECT_NAME.xcodeproj" ARCHS="armv7 armv7s arm64" -target "$PROJECT_NAME" -configuration $CONFIGURATION -sdk iphoneos build VALID_ARCHS="armv7 armv7s arm64" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/device" SHARED_PRECOMPS_DIR="$PROJECT_PATH/build/sharedpch"
-fi
-
+#!/usr/bin/env node
+
+/*
+       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 build = require('./lib/build'),
+    args  = process.argv;
+
+// Handle help flag
+if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[2]) > -1) {
+    build.help();
+} else {
+    build.run(args).done(function() {
+        console.log('** BUILD SUCCEEDED **');
+    }, function(err) {
+        var errorMessage = (err && err.stack) ? err.stack : err;
+        console.error(errorMessage);
+        process.exit(2);
+    });
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/clean
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/clean b/bin/templates/scripts/cordova/clean
index b7c2e27..ae61078 100755
--- a/bin/templates/scripts/cordova/clean
+++ b/bin/templates/scripts/cordova/clean
@@ -1,40 +1,29 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-#
-# Clean a Cordova/iOS project
-#
-
-set -e
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-source "$CORDOVA_PATH/check_reqs"
-
-cd "$PROJECT_PATH"
-
-xcodebuild -project "$PROJECT_NAME.xcodeproj" -configuration Debug -alltargets clean
-xcodebuild -project "$PROJECT_NAME.xcodeproj" -configuration Release -alltargets clean
-
-rm -rf "build"
\ No newline at end of file
+#!/usr/bin/env node
+
+/*
+       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 clean = require('./lib/clean');
+
+clean.run(process.argv).done(function () {
+    console.log('** CLEAN SUCCEEDED **');
+}, function(err) {
+    console.error(err);
+    process.exit(2);
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/clean.bat b/bin/templates/scripts/cordova/clean.bat
new file mode 100644
index 0000000..25f1790
--- /dev/null
+++ b/bin/templates/scripts/cordova/clean.bat
@@ -0,0 +1,25 @@
+:: 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
+@ECHO OFF
+SET script_path="%~dp0clean"
+IF EXIST %script_path% (
+        node %script_path% %*
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/emulate
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/emulate b/bin/templates/scripts/cordova/emulate
deleted file mode 100755
index 5c68a82..0000000
--- a/bin/templates/scripts/cordova/emulate
+++ /dev/null
@@ -1,59 +0,0 @@
-#! /bin/bash
-#
-# 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.
-#
-
-SDK=`xcodebuild -showsdks | grep Sim | tail -1 | awk '{print $6}'`
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj  )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-source "$CORDOVA_PATH/check_reqs"
-
-APP_PATH=${1:-$PROJECT_PATH/build/emulator/$(xcodebuild -project "$PROJECT_PATH/$PROJECT_NAME.xcodeproj" -arch i386 -target "$PROJECT_NAME" -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')}
-
-TARGET=${2:-${TARGET:-iPhone-6}}
-
-IOS_SIM_MIN_VERSION="3.0"
-IOS_SIM_LOCATION=$(which ios-sim)
-if [ $? != 0 ]; then
-    echo -e "\033[31mError: ios-sim was not found. Please download, build and install version $IOS_SIM_MIN_VERSION or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/\033[m" 1>&2; 
-	exit 1;
-fi
-
-IOS_SIM_VERSION=$(ios-sim --version)
-
-if [[ "$IOS_SIM_VERSION" < "$IOS_SIM_MIN_VERSION" ]]; then
-	echo "Cordova needs ios-sim version $IOS_SIM_MIN_VERSION or greater, you have version $IOS_SIM_VERSION." 1>&2;
-	exit 1
-fi
-
-if [ ! -d "$APP_PATH" ]; then
-	echo "Project '$APP_PATH' is not built. Building."
-    "$CORDOVA_PATH/build" || exit $?
-fi
-
-if [ ! -d "$APP_PATH" ]; then
-	echo "$APP_PATH not found to emulate." 1>&2;
-	exit 1
-fi
-
-# launch using ios-sim
-ios-sim launch "$APP_PATH" --devicetypeid "com.apple.CoreSimulator.SimDeviceType.$TARGET" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" --exit

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
new file mode 100644
index 0000000..b7a6bd0
--- /dev/null
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -0,0 +1,147 @@
+/**
+ * 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 node: true*/
+
+var Q     = require('q'),
+    nopt  = require('nopt'),
+    path  = require('path'),
+    shell = require('shelljs'),
+    spawn = require('./spawn'),
+    check_reqs = require('./check_reqs');
+
+var projectPath = path.join(__dirname, '..', '..');
+
+module.exports.run = function (argv) {
+
+    var args = nopt({
+        // "archs": String,     // TODO: add support for building different archs
+        'debug': Boolean,
+        'release': Boolean,
+        'device': Boolean,
+        'emulator': Boolean,
+    }, {'-r': '--release'}, argv);
+
+    if (args.debug && args.release) {
+        return Q.reject('Only one of "debug"/"release" options should be specified');
+    }
+
+    if (args.device && args.emulator) {
+        return Q.reject('Only one of "device"/"emulator" options should be specified');
+    }
+    
+    return check_reqs.run().then(function () {
+        return findXCodeProjectIn(projectPath);
+    }).then(function (projectName) {
+        var configuration = args.release ? 'Release' : 'Debug';
+
+        console.log("Building project  : " + path.join(projectPath, projectName + '.xcodeproj'));
+        console.log("\tConfiguration : " + configuration);
+        console.log("\tPlatform      : " + (args.device ? 'device' : 'emulator'));
+
+        var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration, args.device);
+        return spawn('xcodebuild', xcodebuildArgs, projectPath);
+    });
+};
+
+/**
+ * Searches for first XCode project in specified folder
+ * @param  {String} projectPath Path where to search project
+ * @return {Promise}            Promise either fulfilled with project name or rejected
+ */
+function findXCodeProjectIn(projectPath) {
+    // 'Searching for Xcode project in ' + projectPath);
+    var xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
+        return path.extname(name) === '.xcodeproj';
+    });
+    
+    if (xcodeProjFiles.length === 0) {
+        return Q.reject("No Xcode project found in " + projectPath);
+    }
+    if (xcodeProjFiles.length > 1) {
+        console.warn('Found multiple .xcodeproj directories in \n' +
+            projectPath + '\nUsing first one');
+    }
+
+    var projectName = path.basename(xcodeProjFiles[0], '.xcodeproj');
+    return Q.resolve(projectName);
+}
+
+module.exports.findXCodeProjectIn = findXCodeProjectIn;
+
+/**
+ * Returns array of arguments for xcodebuild
+ * @param  {String}  projectName   Name of xcode project
+ * @param  {String}  projectPath   Path to project file. Will be used to set CWD for xcodebuild
+ * @param  {String}  configuration Configuration name: debug|release
+ * @param  {Boolean} isDevice      Flag that specify target for package (device/emulator)
+ * @return {Array}                 Array of arguments that could be passed directly to spawn method
+ */
+function getXcodeArgs(projectName, projectPath, configuration, isDevice) {
+    var xcodebuildArgs;
+    if (isDevice) {
+        xcodebuildArgs = [
+            '-xcconfig', path.join(__dirname, '..', 'build-' + configuration.toLowerCase() + '.xcconfig'),
+            '-project', projectName + '.xcodeproj',
+            'ARCHS="armv7 armv7s arm64"',
+            '-target', projectName,
+            '-configuration', configuration,
+            '-sdk', 'iphoneos',
+            'build',
+            'VALID_ARCHS="armv7 armv7s arm64"',
+            'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
+            'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
+        ];
+    } else { // emulator
+        xcodebuildArgs = [
+            '-project', projectName + '.xcodeproj',
+            'ARCHS="i386"',
+            '-target', projectName ,
+            '-configuration', configuration,
+            '-sdk', 'iphonesimulator',
+            'build',
+            'VALID_ARCHS="i386"',
+            'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'emulator'),
+            'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
+        ];
+    }
+    return xcodebuildArgs;
+}
+
+// help/usage function
+module.exports.help = function help() {
+    console.log("");
+    console.log("Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"] [--device | --simulator]");
+    console.log("    --help    : Displays this dialog.");
+    console.log("    --debug   : Builds project in debug mode. (Default)");
+    console.log("    --release : Builds project in release mode.");
+    console.log("    -r        : Shortcut :: builds project in release mode.");
+    // TODO: add support for building different archs
+    // console.log("    --archs   : Builds project binaries for specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
+    console.log("    --device, --simulator");
+    console.log("              : Specifies, what type of project to build");
+    console.log("examples:");
+    console.log("    build ");
+    console.log("    build --debug");
+    console.log("    build --release");
+    // TODO: add support for building different archs
+    // console.log("    build --release --archs=\"armv7\"");
+    console.log("");
+    process.exit(0);
+};

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/985fb6e9/bin/templates/scripts/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/clean.js b/bin/templates/scripts/cordova/lib/clean.js
new file mode 100644
index 0000000..75ac18e
--- /dev/null
+++ b/bin/templates/scripts/cordova/lib/clean.js
@@ -0,0 +1,46 @@
+/**
+ * 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 node: true*/
+
+var Q     = require('q'),
+    path  = require('path'),
+    shell = require('shelljs'),
+    spawn = require('./spawn'),
+    check_reqs = require('./check_reqs');
+
+var projectPath = path.join(__dirname, '..', '..');
+
+module.exports.run = function() {
+    var projectName = shell.ls(projectPath).filter(function (name) {
+        return path.extname(name) === '.xcodeproj';
+    })[0];
+
+    if (!projectName) {
+        return Q.reject("No Xcode project found in " + projectPath);
+    }
+
+    return check_reqs.run().then(function() {
+        return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Debug', '-alltargets', 'clean'], projectPath);
+    }).then(function () {
+        return spawn('xcodebuild', ['-project', projectName, '-configuration', 'Release', '-alltargets', 'clean'], projectPath);
+    }).then(function () {
+        return shell.rm('-rf', path.join(projectPath, 'build'));
+    });
+};


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