CB-9328 Use ios-sim as a node module, not a CLI utility
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/7e68636c Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/7e68636c Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/7e68636c Branch: refs/heads/CB-9328 Commit: 7e68636c93b32d3079fe22c90bf05deb1ab85d56 Parents: 47154c3 Author: Simon MacDonald <simon.macdon...@gmail.com> Authored: Wed Sep 9 00:00:09 2015 -0400 Committer: Simon MacDonald <simon.macdon...@gmail.com> Committed: Wed Sep 16 00:00:25 2015 -0400 ---------------------------------------------------------------------- bin/lib/check_reqs.js | 21 +- bin/node_modules/.bin/ios-sim | 1 + bin/node_modules/ios-sim/.npmignore | 7 + bin/node_modules/ios-sim/CONTRIBUTING.md | 29 + bin/node_modules/ios-sim/LICENSE | 21 + bin/node_modules/ios-sim/README.md | 97 ++++ bin/node_modules/ios-sim/bin/ios-sim | 42 ++ bin/node_modules/ios-sim/bin/ios-sim.cmd | 1 + bin/node_modules/ios-sim/doc/help.txt | 33 ++ bin/node_modules/ios-sim/ios-sim.js | 4 + bin/node_modules/ios-sim/node_modules/.bin/nopt | 1 + .../node_modules/bplist-parser/.npmignore | 8 + .../node_modules/bplist-parser/README.md | 47 ++ .../node_modules/bplist-parser/bplistParser.js | 332 +++++++++++ .../node_modules/bplist-parser/package.json | 52 ++ .../bplist-parser/test/airplay.bplist | Bin 0 -> 341 bytes .../bplist-parser/test/iTunes-small.bplist | Bin 0 -> 24433 bytes .../bplist-parser/test/parseTest.js | 120 ++++ .../bplist-parser/test/sample1.bplist | Bin 0 -> 605 bytes .../bplist-parser/test/sample2.bplist | Bin 0 -> 384 bytes .../node_modules/bplist-parser/test/uid.bplist | Bin 0 -> 365 bytes .../bplist-parser/test/utf16.bplist | Bin 0 -> 1273 bytes .../ios-sim/node_modules/nopt/.npmignore | 0 .../ios-sim/node_modules/nopt/LICENSE | 23 + .../ios-sim/node_modules/nopt/README.md | 206 +++++++ .../ios-sim/node_modules/nopt/bin/nopt.js | 44 ++ .../node_modules/nopt/examples/my-program.js | 30 + .../ios-sim/node_modules/nopt/lib/nopt.js | 530 ++++++++++++++++++ .../nopt/node_modules/abbrev/.npmignore | 4 + .../nopt/node_modules/abbrev/.travis.yml | 5 + .../nopt/node_modules/abbrev/CONTRIBUTING.md | 3 + .../nopt/node_modules/abbrev/LICENSE | 15 + .../nopt/node_modules/abbrev/README.md | 23 + .../nopt/node_modules/abbrev/abbrev.js | 62 +++ .../nopt/node_modules/abbrev/package.json | 48 ++ .../nopt/node_modules/abbrev/test.js | 47 ++ .../ios-sim/node_modules/nopt/package.json | 60 ++ .../ios-sim/node_modules/simctl/.npmignore | 1 + .../ios-sim/node_modules/simctl/LICENSE | 22 + .../ios-sim/node_modules/simctl/README.md | 3 + .../simctl/lib/simctl-extensions.js | 69 +++ .../simctl/lib/simctl-list-parser.js | 198 +++++++ .../node_modules/simctl/node_modules/.bin/shjs | 1 + .../node_modules/shelljs/.documentup.json | 6 + .../simctl/node_modules/shelljs/.jshintrc | 7 + .../simctl/node_modules/shelljs/.npmignore | 2 + .../simctl/node_modules/shelljs/.travis.yml | 5 + .../simctl/node_modules/shelljs/LICENSE | 26 + .../simctl/node_modules/shelljs/README.md | 552 +++++++++++++++++++ .../simctl/node_modules/shelljs/bin/shjs | 51 ++ .../simctl/node_modules/shelljs/global.js | 3 + .../simctl/node_modules/shelljs/make.js | 47 ++ .../simctl/node_modules/shelljs/package.json | 61 ++ .../shelljs/scripts/generate-docs.js | 21 + .../node_modules/shelljs/scripts/run-tests.js | 50 ++ .../simctl/node_modules/shelljs/shell.js | 153 +++++ .../simctl/node_modules/shelljs/src/cat.js | 43 ++ .../simctl/node_modules/shelljs/src/cd.js | 19 + .../simctl/node_modules/shelljs/src/chmod.js | 208 +++++++ .../simctl/node_modules/shelljs/src/common.js | 189 +++++++ .../simctl/node_modules/shelljs/src/cp.js | 200 +++++++ .../simctl/node_modules/shelljs/src/dirs.js | 191 +++++++ .../simctl/node_modules/shelljs/src/echo.js | 20 + .../simctl/node_modules/shelljs/src/error.js | 10 + .../simctl/node_modules/shelljs/src/exec.js | 181 ++++++ .../simctl/node_modules/shelljs/src/find.js | 51 ++ .../simctl/node_modules/shelljs/src/grep.js | 52 ++ .../simctl/node_modules/shelljs/src/ls.js | 126 +++++ .../simctl/node_modules/shelljs/src/mkdir.js | 68 +++ .../simctl/node_modules/shelljs/src/mv.js | 80 +++ .../simctl/node_modules/shelljs/src/popd.js | 1 + .../simctl/node_modules/shelljs/src/pushd.js | 1 + .../simctl/node_modules/shelljs/src/pwd.js | 11 + .../simctl/node_modules/shelljs/src/rm.js | 145 +++++ .../simctl/node_modules/shelljs/src/sed.js | 43 ++ .../simctl/node_modules/shelljs/src/tempdir.js | 56 ++ .../simctl/node_modules/shelljs/src/test.js | 85 +++ .../simctl/node_modules/shelljs/src/to.js | 29 + .../simctl/node_modules/shelljs/src/toEnd.js | 29 + .../simctl/node_modules/shelljs/src/which.js | 79 +++ .../simctl/node_modules/tail/README.md | 72 +++ .../simctl/node_modules/tail/package.json | 57 ++ .../simctl/node_modules/tail/tail.js | 147 +++++ .../ios-sim/node_modules/simctl/package.json | 49 ++ .../ios-sim/node_modules/simctl/simctl.js | 195 +++++++ bin/node_modules/ios-sim/package.json | 45 ++ .../ios-sim/resources/buildbox/build.sh | 3 + bin/node_modules/ios-sim/src/cli.js | 102 ++++ bin/node_modules/ios-sim/src/commands.js | 81 +++ bin/node_modules/ios-sim/src/help.js | 41 ++ bin/node_modules/ios-sim/src/lib.js | 382 +++++++++++++ .../scripts/cordova/lib/list-emulator-images | 10 +- bin/templates/scripts/cordova/lib/run.js | 22 +- 93 files changed, 6278 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/lib/check_reqs.js ---------------------------------------------------------------------- diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js index fe2088c..1ff99f2 100644 --- a/bin/lib/check_reqs.js +++ b/bin/lib/check_reqs.js @@ -25,11 +25,6 @@ var XCODEBUILD_MIN_VERSION = '6.0.0'; var XCODEBUILD_NOT_FOUND_MESSAGE = 'Please install version ' + XCODEBUILD_MIN_VERSION + ' or greater from App Store'; -var IOS_SIM_MIN_VERSION = '4.0.0'; -var IOS_SIM_NOT_FOUND_MESSAGE = - 'Please download, build and install version ' + IOS_SIM_MIN_VERSION + ' or greater' + - ' from https://github.com/phonegap/ios-sim into your path, or do \'npm install -g ios-sim\''; - var IOS_DEPLOY_MIN_VERSION = '1.7.0'; var IOS_DEPLOY_NOT_FOUND_MESSAGE = 'Please download, build and install version ' + IOS_DEPLOY_MIN_VERSION + ' or greater' + @@ -51,14 +46,6 @@ 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.check_os = function () { // Build iOS apps available for OSX platform only, so we reject on others platforms return process.platform === 'darwin' ? @@ -72,7 +59,7 @@ module.exports.help = function () { /** * Checks if specific tool is available. - * @param {String} tool Tool name to check. Known tools are 'xcodebuild', 'ios-sim' and 'ios-deploy' + * @param {String} tool Tool name to check. Known tools are 'xcodebuild' and 'ios-deploy' * @param {Number} minVersion Min allowed tool version. * @param {String} message Message that will be used to reject promise. * @return {Promise} Returns a promise either resolved with tool version or rejected @@ -119,8 +106,7 @@ module.exports.check_all = function() { var requirements = [ new Requirement('os', 'Apple OS X', true), new Requirement('xcode', 'Xcode'), - new Requirement('ios-deploy', 'ios-deploy'), - new Requirement('ios-sim', 'ios-sim') + new Requirement('ios-deploy', 'ios-deploy') ]; var result = []; @@ -129,8 +115,7 @@ module.exports.check_all = function() { var checkFns = [ module.exports.check_os, module.exports.check_xcodebuild, - module.exports.check_ios_deploy, - module.exports.check_ios_sim + module.exports.check_ios_deploy ]; // Then execute requirement checks one-by-one http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/.bin/ios-sim ---------------------------------------------------------------------- diff --git a/bin/node_modules/.bin/ios-sim b/bin/node_modules/.bin/ios-sim new file mode 120000 index 0000000..c435a8c --- /dev/null +++ b/bin/node_modules/.bin/ios-sim @@ -0,0 +1 @@ +../ios-sim/bin/ios-sim \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/.npmignore b/bin/node_modules/ios-sim/.npmignore new file mode 100644 index 0000000..71ffef6 --- /dev/null +++ b/bin/node_modules/ios-sim/.npmignore @@ -0,0 +1,7 @@ +node_modules +build +*.swp +.DS_Store +*.xcworkspace +xcuserdata +node_modules http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/CONTRIBUTING.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/CONTRIBUTING.md b/bin/node_modules/ios-sim/CONTRIBUTING.md new file mode 100644 index 0000000..b132d71 --- /dev/null +++ b/bin/node_modules/ios-sim/CONTRIBUTING.md @@ -0,0 +1,29 @@ +## Contributing to ios-sim + +Github url: + + https://github.com/phonegap/ios-sim + +Git clone url: + + https://github.com/phonegap/ios-sim.git + +## Filing an issue + +Please run the commands below in your Terminal.app and include it in the issue: + +``` +1. sw_vers -productVersion +2. ios-sim --version +3. xcodebuild -version +4. xcode-select --print-path +5. gcc --version +``` +Also include **command line arguments** you used for ios-sim. + + +## Sending a Pull Request + +Please **create a topic branch** for your issue before submitting your pull request. You will be asked to re-submit if your pull request contains unrelated commits. + +Please elaborate regarding the problem the pull request is supposed to solve, and perhaps also link to any relevant issues the pull request is trying to fix. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/LICENSE ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/LICENSE b/bin/node_modules/ios-sim/LICENSE new file mode 100644 index 0000000..f5768b4 --- /dev/null +++ b/bin/node_modules/ios-sim/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Shazron Abdullah + +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. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/README.md b/bin/node_modules/ios-sim/README.md new file mode 100644 index 0000000..addf3c8 --- /dev/null +++ b/bin/node_modules/ios-sim/README.md @@ -0,0 +1,97 @@ +ios-sim +======= + +Supports Xcode 6 only since version 3.x. + +The ios-sim tool is a command-line utility that launches an iOS application on the iOS Simulator. This allows for niceties such as automated testing without having to open Xcode. + +Features +-------- + +* Choose the device family to simulate, i.e. iPhone or iPad. Run using "showdevicetypes" option to see available device types, and pass it in as the "devicetypeid" parameter. + +See the `--help` option for more info. + +The unimplemented options below are in the [backlog](https://github.com/phonegap/ios-sim/milestones/ios-sim%204.2.0) + +Usage +----- + +``` + + Usage: ios-sim <command> <options> [--args ...] + + Commands: + showsdks List the available iOS SDK versions + showdevicetypes List the available device types + launch <application path> Launch the application at the specified path on the iOS Simulator + start Launch iOS Simulator without an app + install <application path> Install the application at the specified path on the iOS Simulator without launching the app + + Options: + --version Print the version of ios-sim + --help Show this help text + --exit Exit after startup + --log <log file path> The path where log of the app running in the Simulator will be redirected to + --devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices. + e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0" + + Removed in version 4.x: + --stdout <stdout file path> The path where stdout of the simulator will be redirected to (defaults to stdout of ios-sim) + --stderr <stderr file path> The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim) + --sdk <sdkversion> The iOS SDK version to run the application on (defaults to the latest) + --family <device family> The device type that should be simulated (defaults to `iphone') + --retina Start a retina device + --tall In combination with --retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-inch)) + --64bit In combination with --retina flag and the --tall flag, start the 64bit version of the tall retina device (e.g. iPhone 5S (4-inch 64bit)) + + Unimplemented in this version: + --verbose Set the output level to verbose + --timeout <seconds> The timeout time to wait for a response from the Simulator. Default value: 30 seconds + --args <...> All following arguments will be passed on to the application + --env <environment file path> A plist file containing environment key-value pairs that should be set + --setenv NAME=VALUE Set an environment variable + +``` + +Installation +------------ + +Choose one of the following installation methods. + +### Node JS + +Install using node.js (at least 0.10.20): + + $ npm install ios-sim -g + +### Zip + +Download a zip file: + + $ curl -L https://github.com/phonegap/ios-sim/archive/master.zip -o ios-sim.zip + $ unzip ios-sim.zip + +### Git + +Download using git clone: + + $ git clone git://github.com/phonegap/ios-sim.git + +Troubleshooting +--------------- + +Make sure you enable Developer Mode on your machine: + + $ DevToolsSecurity -enable + +Make sure multiple instances of launchd_sim are not running: + + $ killall launchd_sim + +License +------- + +This project is available under the MIT license. See [LICENSE][license]. + +[license]: https://github.com/phonegap/ios-sim/blob/master/LICENSE http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/bin/ios-sim ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/bin/ios-sim b/bin/node_modules/ios-sim/bin/ios-sim new file mode 100755 index 0000000..bab9b88 --- /dev/null +++ b/bin/node_modules/ios-sim/bin/ios-sim @@ -0,0 +1,42 @@ +#!/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. +// + +// Set this to 1 to enable timestamp collection via addTs(). +if (0) { + var ts = []; + addTs = function(name) { + ts.push([name, new Date]); + } + process.on('exit', function() { + for (var i = 0; i < ts.length - 1; ++i) { + var e1 = ts[i]; + var e2 = ts[i+1]; + console.log(e1[0] + ' -> ' + e2[0] + ' = ' + (e2[1] - e1[1])); + } + console.log('total: ' + (ts[ts.length-1][1] - ts[0][1])); + }); +} else { + addTs = function() {}; +} + +addTs('start'); +var cli = require('../src/cli'); +cli(process.argv); +addTs('end'); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/bin/ios-sim.cmd ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/bin/ios-sim.cmd b/bin/node_modules/ios-sim/bin/ios-sim.cmd new file mode 100755 index 0000000..18927ed --- /dev/null +++ b/bin/node_modules/ios-sim/bin/ios-sim.cmd @@ -0,0 +1 @@ +@node "%~dpn0" %* http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/doc/help.txt ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/doc/help.txt b/bin/node_modules/ios-sim/doc/help.txt new file mode 100644 index 0000000..925a0f8 --- /dev/null +++ b/bin/node_modules/ios-sim/doc/help.txt @@ -0,0 +1,33 @@ +Usage: ios-sim <command> <options> [--args ...] + +Commands: + showsdks List the available iOS SDK versions + showdevicetypes List the available device types + launch <application path> Launch the application at the specified path on the iOS Simulator + start Launch iOS Simulator without an app + install <application path> Install the application at the specified path on the iOS Simulator without launching the app + +Options: + --version Print the version of ios-sim + --help Show this help text + --exit Exit after startup + --log <log file path> The path where log of the app running in the Simulator will be redirected to + --devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices. + e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0" + +Removed in version 4.x: + --stdout <stdout file path> The path where stdout of the simulator will be redirected to (defaults to stdout of ios-sim) + --stderr <stderr file path> The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim) + --sdk <sdkversion> The iOS SDK version to run the application on (defaults to the latest) + --family <device family> The device type that should be simulated (defaults to `iphone') + --retina Start a retina device + --tall In combination with --retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-inch)) + --64bit In combination with --retina flag and the --tall flag, start the 64bit version of the tall retina device (e.g. iPhone 5S (4-inch 64bit)) + +Unimplemented in version 4.x: + --verbose Set the output level to verbose + --timeout <seconds> The timeout time to wait for a response from the Simulator. Default value: 30 seconds + --args <...> All following arguments will be passed on to the application + --env <environment file path> A plist file containing environment key-value pairs that should be set + --setenv NAME=VALUE Set an environment variable + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/ios-sim.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/ios-sim.js b/bin/node_modules/ios-sim/ios-sim.js new file mode 100644 index 0000000..4547126 --- /dev/null +++ b/bin/node_modules/ios-sim/ios-sim.js @@ -0,0 +1,4 @@ +var iossim = require('./src/lib.js'); +iossim.init(); + +exports = module.exports = iossim; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/.bin/nopt ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/.bin/nopt b/bin/node_modules/ios-sim/node_modules/.bin/nopt new file mode 120000 index 0000000..6b6566e --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/.bin/nopt @@ -0,0 +1 @@ +../nopt/bin/nopt.js \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/.npmignore b/bin/node_modules/ios-sim/node_modules/bplist-parser/.npmignore new file mode 100644 index 0000000..a9b46ea --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/bplist-parser/.npmignore @@ -0,0 +1,8 @@ +/build/* +node_modules +*.node +*.sh +*.swp +.lock* +npm-debug.log +.idea http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/README.md b/bin/node_modules/ios-sim/node_modules/bplist-parser/README.md new file mode 100644 index 0000000..37e5e1c --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/bplist-parser/README.md @@ -0,0 +1,47 @@ +bplist-parser +============= + +Binary Mac OS X Plist (property list) parser. + +## Installation + +```bash +$ npm install bplist-parser +``` + +## Quick Examples + +```javascript +var bplist = require('bplist-parser'); + +bplist.parseFile('myPlist.bplist', function(err, obj) { + if (err) throw err; + + console.log(JSON.stringify(obj)); +}); +``` + +## License + +(The MIT License) + +Copyright (c) 2012 Near Infinity Corporation + +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/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js b/bin/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js new file mode 100644 index 0000000..e818454 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js @@ -0,0 +1,332 @@ +'use strict'; + +// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java + +var fs = require('fs'); +var debug = false; + +exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg +exports.maxObjectCount = 32768; + +// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime(); +// ...but that's annoying in a static initializer because it can throw exceptions, ick. +// So we just hardcode the correct value. +var EPOCH = 978307200000; + +var parseFile = exports.parseFile = function (fileNameOrBuffer, callback) { + function tryParseBuffer(buffer) { + var err = null; + var result; + try { + result = parseBuffer(buffer); + } catch (ex) { + err = ex; + } + callback(err, result); + } + + if (Buffer.isBuffer(fileNameOrBuffer)) { + return tryParseBuffer(fileNameOrBuffer); + } else { + fs.readFile(fileNameOrBuffer, function (err, data) { + if (err) { return callback(err); } + tryParseBuffer(data); + }); + } +}; + +var parseBuffer = exports.parseBuffer = function (buffer) { + var result = {}; + + // check header + var header = buffer.slice(0, 'bplist'.length).toString('utf8'); + if (header !== 'bplist') { + throw new Error("Invalid binary plist. Expected 'bplist' at offset 0."); + } + + // Handle trailer, last 32 bytes of the file + var trailer = buffer.slice(buffer.length - 32, buffer.length); + // 6 null bytes (index 0 to 5) + var offsetSize = trailer.readUInt8(6); + if (debug) { + console.log("offsetSize: " + offsetSize); + } + var objectRefSize = trailer.readUInt8(7); + if (debug) { + console.log("objectRefSize: " + objectRefSize); + } + var numObjects = readUInt64BE(trailer, 8); + if (debug) { + console.log("numObjects: " + numObjects); + } + var topObject = readUInt64BE(trailer, 16); + if (debug) { + console.log("topObject: " + topObject); + } + var offsetTableOffset = readUInt64BE(trailer, 24); + if (debug) { + console.log("offsetTableOffset: " + offsetTableOffset); + } + + if (numObjects > exports.maxObjectCount) { + throw new Error("maxObjectCount exceeded"); + } + + // Handle offset table + var offsetTable = []; + + for (var i = 0; i < numObjects; i++) { + var offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize); + offsetTable[i] = readUInt(offsetBytes, 0); + if (debug) { + console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]"); + } + } + + // Parses an object inside the currently parsed binary property list. + // For the format specification check + // <a href="http://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c"> + // Apple's binary property list parser implementation</a>. + function parseObject(tableOffset) { + var offset = offsetTable[tableOffset]; + var type = buffer[offset]; + var objType = (type & 0xF0) >> 4; //First 4 bits + var objInfo = (type & 0x0F); //Second 4 bits + switch (objType) { + case 0x0: + return parseSimple(); + case 0x1: + return parseInteger(); + case 0x8: + return parseUID(); + case 0x2: + return parseReal(); + case 0x3: + return parseDate(); + case 0x4: + return parseData(); + case 0x5: // ASCII + return parsePlistString(); + case 0x6: // UTF-16 + return parsePlistString(true); + case 0xA: + return parseArray(); + case 0xD: + return parseDictionary(); + default: + throw new Error("Unhandled type 0x" + objType.toString(16)); + } + + function parseSimple() { + //Simple + switch (objInfo) { + case 0x0: // null + return null; + case 0x8: // false + return false; + case 0x9: // true + return true; + case 0xF: // filler byte + return null; + default: + throw new Error("Unhandled simple type 0x" + objType.toString(16)); + } + } + + function parseInteger() { + var length = Math.pow(2, objInfo); + if (length < exports.maxObjectSize) { + return readUInt(buffer.slice(offset + 1, offset + 1 + length)); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseUID() { + var length = objInfo + 1; + if (length < exports.maxObjectSize) { + return readUInt(buffer.slice(offset + 1, offset + 1 + length)); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseReal() { + var length = Math.pow(2, objInfo); + if (length < exports.maxObjectSize) { + var realBuffer = buffer.slice(offset + 1, offset + 1 + length); + if (length === 4) { + return realBuffer.readFloatBE(0); + } + else if (length === 8) { + return realBuffer.readDoubleBE(0); + } + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseDate() { + if (objInfo != 0x3) { + console.error("Unknown date type :" + objInfo + ". Parsing anyway..."); + } + var dateBuffer = buffer.slice(offset + 1, offset + 9); + return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0))); + } + + function parseData() { + var dataoffset = 1; + var length = objInfo; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dataoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length < exports.maxObjectSize) { + return buffer.slice(offset + dataoffset, offset + dataoffset + length); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parsePlistString (isUtf16) { + isUtf16 = isUtf16 || 0; + var enc = "utf8"; + var length = objInfo; + var stroffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.err("UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + var stroffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + // length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16 + length *= (isUtf16 + 1); + if (length < exports.maxObjectSize) { + var plistString = buffer.slice(offset + stroffset, offset + stroffset + length); + if (isUtf16) { + plistString = swapBytes(plistString); + enc = "ucs2"; + } + return plistString.toString(enc); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseArray() { + var length = objInfo; + var arrayoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + arrayoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + var array = []; + for (var i = 0; i < length; i++) { + var objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize)); + array[i] = parseObject(objRef); + } + return array; + } + + function parseDictionary() { + var length = objInfo; + var dictoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dictoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * 2 * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + if (debug) { + console.log("Parsing dictionary #" + tableOffset); + } + var dict = {}; + for (var i = 0; i < length; i++) { + var keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize)); + var valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize)); + var key = parseObject(keyRef); + var val = parseObject(valRef); + if (debug) { + console.log(" DICT #" + tableOffset + ": Mapped " + key + " to " + val); + } + dict[key] = val; + } + return dict; + } + } + + return [ parseObject(topObject) ]; +}; + +function readUInt(buffer, start) { + start = start || 0; + + var l = 0; + for (var i = start; i < buffer.length; i++) { + l <<= 8; + l |= buffer[i] & 0xFF; + } + return l; +} + +// we're just going to toss the high order bits because javascript doesn't have 64-bit ints +function readUInt64BE(buffer, start) { + var data = buffer.slice(start, start + 8); + return data.readUInt32BE(4, 8); +} + +function swapBytes(buffer) { + var len = buffer.length; + for (var i = 0; i < len; i += 2) { + var a = buffer[i]; + buffer[i] = buffer[i+1]; + buffer[i+1] = a; + } + return buffer; +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/package.json ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/package.json b/bin/node_modules/ios-sim/node_modules/bplist-parser/package.json new file mode 100644 index 0000000..f6987ae --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/bplist-parser/package.json @@ -0,0 +1,52 @@ +{ + "name": "bplist-parser", + "version": "0.0.6", + "description": "Binary plist parser.", + "main": "bplistParser.js", + "scripts": { + "test": "./node_modules/nodeunit/bin/nodeunit test" + }, + "keywords": [ + "bplist", + "plist", + "parser" + ], + "author": { + "name": "Joe Ferner", + "email": "joe.fer...@nearinfinity.com" + }, + "license": "MIT", + "devDependencies": { + "nodeunit": "~0.7.4" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/nearinfinity/node-bplist-parser.git" + }, + "gitHead": "a2230a5df3c7014ffbe5761bcb091ea2d061b47b", + "bugs": { + "url": "https://github.com/nearinfinity/node-bplist-parser/issues" + }, + "homepage": "https://github.com/nearinfinity/node-bplist-parser", + "_id": "bplist-parser@0.0.6", + "_shasum": "38da3471817df9d44ab3892e27707bbbd75a11b9", + "_from": "bplist-parser@>=0.0.6 <0.0.7", + "_npmVersion": "1.4.14", + "_npmUser": { + "name": "joeferner", + "email": "j...@fernsroth.com" + }, + "maintainers": [ + { + "name": "joeferner", + "email": "j...@fernsroth.com" + } + ], + "dist": { + "shasum": "38da3471817df9d44ab3892e27707bbbd75a11b9", + "tarball": "http://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz", + "readme": "ERROR: No README data found!" +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist new file mode 100644 index 0000000..931adea Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist new file mode 100644 index 0000000..b7edb14 Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js new file mode 100644 index 0000000..dcb6dd0 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js @@ -0,0 +1,120 @@ +'use strict'; + +// tests are adapted from https://github.com/TooTallNate/node-plist + +var path = require('path'); +var nodeunit = require('nodeunit'); +var bplist = require('../'); + +module.exports = { + 'iTunes Small': function (test) { + var file = path.join(__dirname, "iTunes-small.bplist"); + var startTime1 = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime1) + 'ms'); + var dict = dicts[0]; + test.equal(dict['Application Version'], "9.0.3"); + test.equal(dict['Library Persistent ID'], "6F81D37F95101437"); + test.done(); + }); + }, + + 'sample1': function (test) { + var file = path.join(__dirname, "sample1.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + var dict = dicts[0]; + test.equal(dict['CFBundleIdentifier'], 'com.apple.dictionary.MySample'); + test.done(); + }); + }, + + 'sample2': function (test) { + var file = path.join(__dirname, "sample2.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + var dict = dicts[0]; + test.equal(dict['PopupMenu'][2]['Key'], "\n #import <Cocoa/Cocoa.h>\n\n#import <MacRuby/MacRuby.h>\n\nint main(int argc, char *argv[])\n{\n return macruby_main(\"rb_main.rb\", argc, argv);\n}\n"); + test.done(); + }); + }, + + 'airplay': function (test) { + var file = path.join(__dirname, "airplay.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.equal(dict['duration'], 5555.0495000000001); + test.equal(dict['position'], 4.6269989039999997); + test.done(); + }); + }, + + 'utf16': function (test) { + var file = path.join(__dirname, "utf16.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.equal(dict['CFBundleName'], 'sellStuff'); + test.equal(dict['CFBundleShortVersionString'], '2.6.1'); + test.equal(dict['NSHumanReadableCopyright'], '©2008-2012, sellStuff, Inc.'); + test.done(); + }); + }, + + 'uid': function (test) { + var file = path.join(__dirname, "uid.bplist"); + var startTime = new Date(); + + bplist.parseFile(file, function (err, dicts) { + if (err) { + throw err; + } + + var endTime = new Date(); + console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms'); + + var dict = dicts[0]; + test.deepEqual(dict['$objects'][1]['NS.keys'], [2, 3, 4]); + test.deepEqual(dict['$objects'][1]['NS.objects'], [5, 6, 7]); + test.equal(dict['$top']['root'], 1); + test.done(); + }); + } +}; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist new file mode 100644 index 0000000..5b808ff Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist new file mode 100644 index 0000000..fc42979 Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist new file mode 100644 index 0000000..59f341e Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist new file mode 100644 index 0000000..ba4bcfa Binary files /dev/null and b/bin/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist differ http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/.npmignore b/bin/node_modules/ios-sim/node_modules/nopt/.npmignore new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/LICENSE ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/LICENSE b/bin/node_modules/ios-sim/node_modules/nopt/LICENSE new file mode 100644 index 0000000..05a4010 --- /dev/null +++ b/bin/node_modules/ios-sim/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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/README.md b/bin/node_modules/ios-sim/node_modules/nopt/README.md new file mode 100644 index 0000000..e364799 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/README.md @@ -0,0 +1,206 @@ +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 1000 -fp # unknown opts are ok. +{ blatzk: 1000, flag: true, pick: true } + +$ node my-program.js --blatzk true -fp # but they need a value +{ blatzk: true, 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. +* Number: Must be numeric. +* url: A url. If it doesn't parse, it isn't accepted. +* 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, and numeric values will be +interpreted as a number. + +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. + +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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/bin/nopt.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/bin/nopt.js b/bin/node_modules/ios-sim/node_modules/nopt/bin/nopt.js new file mode 100755 index 0000000..df90c72 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/bin/nopt.js @@ -0,0 +1,44 @@ +#!/usr/bin/env node +var nopt = require("../lib/nopt") + , types = { num: Number + , bool: Boolean + , help: Boolean + , list: Array + , "num-list": [Number, Array] + , "str-list": [String, Array] + , "bool-list": [Boolean, Array] + , str: String } + , 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" ] } + , 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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/examples/my-program.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/examples/my-program.js b/bin/node_modules/ios-sim/node_modules/nopt/examples/my-program.js new file mode 100755 index 0000000..142447e --- /dev/null +++ b/bin/node_modules/ios-sim/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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/lib/nopt.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/lib/nopt.js b/bin/node_modules/ios-sim/node_modules/nopt/lib/nopt.js new file mode 100644 index 0000000..ff41bbc --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/lib/nopt.js @@ -0,0 +1,530 @@ +// 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 } + } + +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} + data.argv.toString = function () { + return this.original.map(JSON.stringify).join(" ") + } + return data +} + +function clean (data, types, typeDefs) { + typeDefs = typeDefs || exports.typeDefs + var remove = {} + , typeDefault = [false, true, null, String, Number] + + 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 + 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 + } + } + + 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) { + 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 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 + } + if (arg.charAt(0) === "-") { + if (arg.indexOf("=") !== -1) { + 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 = false + 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 + + var val + , la = args[i + 1] + + var isBool = no || + types[arg] === Boolean || + Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || + (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 (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 (abbrevs[arg] && !shorthands[arg]) { + return null + } + if (shortAbbr[arg]) { + arg = shortAbbr[arg] + } else { + 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 + } + 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 (shorthands[arg] && !Array.isArray(shorthands[arg])) { + shorthands[arg] = shorthands[arg].split(/\s+/) + } + return shorthands[arg] +} + +if (module === require.main) { +var assert = require("assert") + , util = require("util") + + , 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] + , 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 + } + +; [["-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} + ,[]] + ].forEach(function (test) { + var argv = test[0].split(/\s+/) + , opts = test[1] + , rem = test[2] + , actual = nopt(types, shorthands, argv, 0) + , parsed = actual.argv + delete actual.argv + console.log(util.inspect(actual, false, 2, true), parsed.remain) + for (var i in opts) { + var e = JSON.stringify(opts[i]) + , a = JSON.stringify(actual[i] === undefined ? null : actual[i]) + assert.equal(e, a) + } + assert.deepEqual(rem, parsed.remain) + }) +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.npmignore b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.npmignore new file mode 100644 index 0000000..9d6cd2f --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.npmignore @@ -0,0 +1,4 @@ +.nyc_output +nyc_output +node_modules +coverage http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.travis.yml ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.travis.yml b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.travis.yml new file mode 100644 index 0000000..991d04b --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - '0.10' + - '0.12' + - 'iojs' http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md new file mode 100644 index 0000000..2f30261 --- /dev/null +++ b/bin/node_modules/ios-sim/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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/LICENSE ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/LICENSE b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/LICENSE new file mode 100644 index 0000000..19129e3 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/README.md ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/README.md b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/README.md new file mode 100644 index 0000000..99746fe --- /dev/null +++ b/bin/node_modules/ios-sim/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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/abbrev.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/abbrev.js b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/abbrev.js new file mode 100644 index 0000000..69cfeac --- /dev/null +++ b/bin/node_modules/ios-sim/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/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/package.json ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/package.json b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/package.json new file mode 100644 index 0000000..c13eef4 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/package.json @@ -0,0 +1,48 @@ +{ + "name": "abbrev", + "version": "1.0.7", + "description": "Like ruby's abbrev module, but in js", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i...@izs.me" + }, + "main": "abbrev.js", + "scripts": { + "test": "tap test.js --cov" + }, + "repository": { + "type": "git", + "url": "git+ssh://g...@github.com/isaacs/abbrev-js.git" + }, + "license": "ISC", + "devDependencies": { + "tap": "^1.2.0" + }, + "gitHead": "821d09ce7da33627f91bbd8ed631497ed6f760c2", + "bugs": { + "url": "https://github.com/isaacs/abbrev-js/issues" + }, + "homepage": "https://github.com/isaacs/abbrev-js#readme", + "_id": "abbrev@1.0.7", + "_shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", + "_from": "abbrev@>=1.0.0 <2.0.0", + "_npmVersion": "2.10.1", + "_nodeVersion": "2.0.1", + "_npmUser": { + "name": "isaacs", + "email": "isa...@npmjs.com" + }, + "dist": { + "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", + "tarball": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i...@izs.me" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz", + "readme": "ERROR: No README data found!" +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/test.js ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/test.js b/bin/node_modules/ios-sim/node_modules/nopt/node_modules/abbrev/test.js new file mode 100644 index 0000000..eb30e42 --- /dev/null +++ b/bin/node_modules/ios-sim/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("1..%d", count) http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/nopt/package.json ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/nopt/package.json b/bin/node_modules/ios-sim/node_modules/nopt/package.json new file mode 100644 index 0000000..27c972c --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/nopt/package.json @@ -0,0 +1,60 @@ +{ + "name": "nopt", + "version": "1.0.9", + "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": "node lib/nopt.js" + }, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/nopt.git" + }, + "bin": { + "nopt": "./bin/nopt.js" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/nopt/raw/master/LICENSE" + }, + "dependencies": { + "abbrev": "1" + }, + "_npmUser": { + "name": "isaacs", + "email": "i...@izs.me" + }, + "_id": "nopt@1.0.9", + "devDependencies": {}, + "engines": { + "node": "*" + }, + "_engineSupported": true, + "_npmVersion": "1.0.30", + "_nodeVersion": "v0.5.8-pre", + "_defaultsLoaded": true, + "dist": { + "shasum": "3bc0d7cba7bfb0d5a676dbed7c0ebe48a4fd454e", + "tarball": "http://registry.npmjs.org/nopt/-/nopt-1.0.9.tgz" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i...@izs.me" + } + ], + "directories": {}, + "_shasum": "3bc0d7cba7bfb0d5a676dbed7c0ebe48a4fd454e", + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.9.tgz", + "_from": "nopt@1.0.9", + "bugs": { + "url": "https://github.com/isaacs/nopt/issues" + }, + "readme": "ERROR: No README data found!", + "homepage": "https://github.com/isaacs/nopt#readme" +} http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/simctl/.npmignore ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/simctl/.npmignore b/bin/node_modules/ios-sim/node_modules/simctl/.npmignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/simctl/.npmignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e68636c/bin/node_modules/ios-sim/node_modules/simctl/LICENSE ---------------------------------------------------------------------- diff --git a/bin/node_modules/ios-sim/node_modules/simctl/LICENSE b/bin/node_modules/ios-sim/node_modules/simctl/LICENSE new file mode 100644 index 0000000..3fdbf44 --- /dev/null +++ b/bin/node_modules/ios-sim/node_modules/simctl/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Shazron Abdullah + +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. + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org