From c2c2e564ba32bdb3599b31d36e705acc9d015c3b Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Wed, 20 Aug 2014 14:00:56 +0400 Subject: [PATCH] CB-7341 Port tooling/platform scripts from WSH to NodeJS --- .gitignore | 11 - wp8/bin/check_reqs | 54 +- wp8/bin/check_reqs.bat | 7 +- wp8/bin/check_reqs.js | 76 - wp8/bin/create | 38 + wp8/bin/create.bat | 7 +- wp8/bin/create.js | 287 --- wp8/bin/createTemplates.bat | 1 - wp8/bin/lib/check_reqs.js | 35 + wp8/bin/lib/create.js | 123 ++ wp8/bin/lib/update.js | 68 + wp8/bin/update | 34 + wp8/bin/update.bat | 9 +- wp8/bin/update.js | 353 --- wp8/node_modules/.bin/nopt | 15 + wp8/node_modules/.bin/nopt.cmd | 5 + wp8/node_modules/.bin/shjs | 15 + wp8/node_modules/.bin/shjs.cmd | 5 + wp8/node_modules/node-uuid/.npmignore | 2 + wp8/node_modules/node-uuid/LICENSE.md | 2 + wp8/node_modules/node-uuid/README.md | 207 ++ .../node-uuid/benchmark/README.md | 53 + .../node-uuid/benchmark/bench.gnu | 174 ++ wp8/node_modules/node-uuid/benchmark/bench.sh | 34 + .../node-uuid/benchmark/benchmark-native.c | 34 + .../node-uuid/benchmark/benchmark.js | 84 + wp8/node_modules/node-uuid/component.json | 18 + wp8/node_modules/node-uuid/package.json | 36 + wp8/node_modules/node-uuid/test/compare_v1.js | 63 + wp8/node_modules/node-uuid/test/test.html | 17 + wp8/node_modules/node-uuid/test/test.js | 228 ++ wp8/node_modules/node-uuid/uuid.js | 245 +++ wp8/node_modules/nopt/.npmignore | 1 + wp8/node_modules/nopt/LICENSE | 23 + wp8/node_modules/nopt/README.md | 209 ++ wp8/node_modules/nopt/examples/my-program.js | 30 + wp8/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 | 29 + .../nopt/node_modules/abbrev/test.js | 47 + wp8/node_modules/nopt/package.json | 41 + wp8/node_modules/nopt/test/basic.js | 251 +++ wp8/node_modules/q/CONTRIBUTING.md | 40 + wp8/node_modules/q/LICENSE | 18 + wp8/node_modules/q/README.md | 820 +++++++ .../q/benchmark/compare-with-callbacks.js | 71 + wp8/node_modules/q/benchmark/scenarios.js | 36 + wp8/node_modules/q/package.json | 93 + wp8/node_modules/q/q.js | 1904 +++++++++++++++++ wp8/node_modules/q/queue.js | 35 + wp8/node_modules/shelljs/.documentup.json | 6 + wp8/node_modules/shelljs/.npmignore | 1 + wp8/node_modules/shelljs/.travis.yml | 5 + wp8/node_modules/shelljs/LICENSE | 26 + wp8/node_modules/shelljs/README.md | 513 +++++ wp8/node_modules/shelljs/global.js | 3 + wp8/node_modules/shelljs/jshint.json | 4 + wp8/node_modules/shelljs/make.js | 48 + wp8/node_modules/shelljs/package.json | 46 + wp8/node_modules/shelljs/scripts/docs.js | 15 + wp8/node_modules/shelljs/scripts/run-tests.js | 50 + wp8/node_modules/shelljs/shell.js | 1901 ++++++++++++++++ wp8/node_modules/shelljs/test/.npmignore | 2 + wp8/node_modules/shelljs/test/cat.js | 57 + wp8/node_modules/shelljs/test/cd.js | 64 + wp8/node_modules/shelljs/test/chmod.js | 81 + wp8/node_modules/shelljs/test/config.js | 50 + wp8/node_modules/shelljs/test/cp.js | 143 ++ wp8/node_modules/shelljs/test/dirs.js | 37 + wp8/node_modules/shelljs/test/echo.js | 50 + wp8/node_modules/shelljs/test/env.js | 19 + wp8/node_modules/shelljs/test/exec.js | 109 + wp8/node_modules/shelljs/test/find.js | 56 + wp8/node_modules/shelljs/test/grep.js | 59 + wp8/node_modules/shelljs/test/ls.js | 202 ++ wp8/node_modules/shelljs/test/make.js | 20 + wp8/node_modules/shelljs/test/mkdir.js | 79 + wp8/node_modules/shelljs/test/mv.js | 130 ++ wp8/node_modules/shelljs/test/popd.js | 118 + wp8/node_modules/shelljs/test/pushd.js | 228 ++ wp8/node_modules/shelljs/test/pwd.js | 28 + wp8/node_modules/shelljs/test/resources/a.txt | 11 + .../test/resources/chmod/a/b/c/.npmignore | 0 .../test/resources/chmod/b/a/b/.npmignore | 0 .../test/resources/chmod/c/a/b/.npmignore | 0 .../shelljs/test/resources/chmod/file1 | 2 + wp8/node_modules/shelljs/test/resources/cp/a | 1 + wp8/node_modules/shelljs/test/resources/cp/b | 1 + .../shelljs/test/resources/cp/dir_a/z | 1 + .../resources/cp/dir_b/dir_b_a/dir_b_a_a/z | 1 + .../test/resources/external/node_script.js | 2 + wp8/node_modules/shelljs/test/resources/file1 | 1 + .../shelljs/test/resources/file1.js | 1 + .../shelljs/test/resources/file1.txt | 1 + wp8/node_modules/shelljs/test/resources/file2 | 1 + .../shelljs/test/resources/file2.js | 1 + .../shelljs/test/resources/file2.txt | 1 + .../shelljs/test/resources/find/.hidden | 1 + .../shelljs/test/resources/find/a | 1 + .../shelljs/test/resources/find/b | 1 + .../shelljs/test/resources/find/dir1/a_dir1 | 1 + .../test/resources/find/dir1/dir11/a_dir11 | 1 + .../shelljs/test/resources/find/dir2/a_dir1 | 1 + .../shelljs/test/resources/issue44/main.js | 1 + .../test/resources/ls/.hidden_dir/nada | 1 + .../shelljs/test/resources/ls/.hidden_file | 1 + .../test/resources/ls/a_dir/.hidden_dir/nada | 1 + .../shelljs/test/resources/ls/a_dir/b_dir/z | 1 + .../shelljs/test/resources/ls/a_dir/nada | 1 + .../shelljs/test/resources/ls/file1 | 1 + .../shelljs/test/resources/ls/file1.js | 1 + .../shelljs/test/resources/ls/file2 | 1 + .../shelljs/test/resources/ls/file2.js | 1 + ...ilename(with)[chars$]^that.must+be-escaped | 1 + .../shelljs/test/resources/pushd/a/dummy | 1 + .../shelljs/test/resources/pushd/b/c/dummy | 1 + wp8/node_modules/shelljs/test/rm.js | 183 ++ wp8/node_modules/shelljs/test/sed.js | 58 + wp8/node_modules/shelljs/test/tempdir.js | 27 + wp8/node_modules/shelljs/test/test.js | 91 + wp8/node_modules/shelljs/test/to.js | 39 + wp8/node_modules/shelljs/test/which.js | 38 + wp8/package.json | 6 + wp8/template/cordova/build | 34 + wp8/template/cordova/build.bat | 9 +- wp8/template/cordova/clean | 27 + wp8/template/cordova/clean.bat | 7 +- .../lib/CordovaDeploy/CordovaDeploy.sln | 38 - .../CordovaDeploy/CordovaDeploy.csproj | 96 - .../CordovaDeploy/CordovaDeploy/Program.cs | 333 --- .../CordovaDeploy/Properties/AssemblyInfo.cs | 50 - .../CordovaDeploy/CordovaDeploy/app.config | 21 - wp8/template/cordova/lib/MSBuildTools.js | 73 + wp8/template/cordova/lib/build.js | 333 +-- wp8/template/cordova/lib/clean.js | 82 +- wp8/template/cordova/lib/deploy.js | 422 ---- wp8/template/cordova/lib/device.js | 54 + wp8/template/cordova/lib/install-device.bat | 7 +- wp8/template/cordova/lib/install-emulator.bat | 7 +- wp8/template/cordova/lib/list-devices.bat | 3 +- .../cordova/lib/list-emulator-images.bat | 3 +- .../cordova/lib/list-started-emulators.bat | 1 - wp8/template/cordova/lib/log.js | 77 - wp8/template/cordova/lib/package.js | 63 + wp8/template/cordova/lib/run.js | 88 + wp8/template/cordova/lib/start-emulator.bat | 1 - wp8/template/cordova/lib/target-list.js | 241 +-- wp8/template/cordova/lib/utils.js | 120 ++ wp8/template/cordova/lib/win_os_version.js | 23 +- wp8/template/cordova/lib/win_sdk_version.js | 68 +- wp8/template/cordova/node_modules/.bin/nopt | 15 + .../cordova/node_modules/.bin/nopt.cmd | 5 + wp8/template/cordova/node_modules/.bin/shjs | 15 + .../cordova/node_modules/.bin/shjs.cmd | 5 + .../cordova/node_modules/nopt/.npmignore | 1 + .../cordova/node_modules/nopt/LICENSE | 23 + .../cordova/node_modules/nopt/README.md | 209 ++ .../node_modules/nopt/examples/my-program.js | 30 + .../cordova/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 | 29 + .../nopt/node_modules/abbrev/test.js | 47 + .../cordova/node_modules/nopt/package.json | 41 + .../cordova/node_modules/nopt/test/basic.js | 251 +++ .../cordova/node_modules/q/CONTRIBUTING.md | 40 + wp8/template/cordova/node_modules/q/LICENSE | 18 + wp8/template/cordova/node_modules/q/README.md | 820 +++++++ .../q/benchmark/compare-with-callbacks.js | 71 + .../node_modules/q/benchmark/scenarios.js | 36 + .../cordova/node_modules/q/package.json | 93 + wp8/template/cordova/node_modules/q/q.js | 1904 +++++++++++++++++ wp8/template/cordova/node_modules/q/queue.js | 35 + .../node_modules/shelljs/.documentup.json | 6 + .../cordova/node_modules/shelljs/.jshintrc | 7 + .../cordova/node_modules/shelljs/.npmignore | 2 + .../cordova/node_modules/shelljs/.travis.yml | 5 + .../cordova/node_modules/shelljs/LICENSE | 26 + .../cordova/node_modules/shelljs/README.md | 569 +++++ .../cordova/node_modules/shelljs/global.js | 3 + .../cordova/node_modules/shelljs/make.js | 47 + .../cordova/node_modules/shelljs/package.json | 47 + .../shelljs/scripts/generate-docs.js | 21 + .../node_modules/shelljs/scripts/run-tests.js | 50 + .../cordova/node_modules/shelljs/shell.js | 157 ++ .../cordova/node_modules/shelljs/src/cat.js | 43 + .../cordova/node_modules/shelljs/src/cd.js | 19 + .../cordova/node_modules/shelljs/src/chmod.js | 208 ++ .../node_modules/shelljs/src/common.js | 203 ++ .../cordova/node_modules/shelljs/src/cp.js | 201 ++ .../cordova/node_modules/shelljs/src/dirs.js | 191 ++ .../cordova/node_modules/shelljs/src/echo.js | 20 + .../cordova/node_modules/shelljs/src/error.js | 10 + .../cordova/node_modules/shelljs/src/exec.js | 181 ++ .../cordova/node_modules/shelljs/src/find.js | 51 + .../cordova/node_modules/shelljs/src/grep.js | 52 + .../cordova/node_modules/shelljs/src/ln.js | 53 + .../cordova/node_modules/shelljs/src/ls.js | 126 ++ .../cordova/node_modules/shelljs/src/mkdir.js | 68 + .../cordova/node_modules/shelljs/src/mv.js | 80 + .../cordova/node_modules/shelljs/src/popd.js | 1 + .../cordova/node_modules/shelljs/src/pushd.js | 1 + .../cordova/node_modules/shelljs/src/pwd.js | 11 + .../cordova/node_modules/shelljs/src/rm.js | 145 ++ .../cordova/node_modules/shelljs/src/sed.js | 43 + .../node_modules/shelljs/src/tempdir.js | 56 + .../cordova/node_modules/shelljs/src/test.js | 85 + .../cordova/node_modules/shelljs/src/to.js | 29 + .../cordova/node_modules/shelljs/src/toEnd.js | 29 + .../cordova/node_modules/shelljs/src/which.js | 83 + wp8/template/cordova/run | 34 + wp8/template/cordova/run.bat | 7 +- wp8/template/cordova/win_os_version.bat | 3 +- wp8/template/cordova/win_sdk_version.bat | 3 +- 219 files changed, 18171 insertions(+), 2448 deletions(-) delete mode 100644 wp8/bin/check_reqs.js create mode 100644 wp8/bin/create delete mode 100644 wp8/bin/create.js create mode 100644 wp8/bin/lib/check_reqs.js create mode 100644 wp8/bin/lib/create.js create mode 100644 wp8/bin/lib/update.js create mode 100644 wp8/bin/update delete mode 100644 wp8/bin/update.js create mode 100644 wp8/node_modules/.bin/nopt create mode 100644 wp8/node_modules/.bin/nopt.cmd create mode 100644 wp8/node_modules/.bin/shjs create mode 100644 wp8/node_modules/.bin/shjs.cmd create mode 100644 wp8/node_modules/node-uuid/.npmignore create mode 100644 wp8/node_modules/node-uuid/LICENSE.md create mode 100644 wp8/node_modules/node-uuid/README.md create mode 100644 wp8/node_modules/node-uuid/benchmark/README.md create mode 100644 wp8/node_modules/node-uuid/benchmark/bench.gnu create mode 100644 wp8/node_modules/node-uuid/benchmark/bench.sh create mode 100644 wp8/node_modules/node-uuid/benchmark/benchmark-native.c create mode 100644 wp8/node_modules/node-uuid/benchmark/benchmark.js create mode 100644 wp8/node_modules/node-uuid/component.json create mode 100644 wp8/node_modules/node-uuid/package.json create mode 100644 wp8/node_modules/node-uuid/test/compare_v1.js create mode 100644 wp8/node_modules/node-uuid/test/test.html create mode 100644 wp8/node_modules/node-uuid/test/test.js create mode 100644 wp8/node_modules/node-uuid/uuid.js create mode 100644 wp8/node_modules/nopt/.npmignore create mode 100644 wp8/node_modules/nopt/LICENSE create mode 100644 wp8/node_modules/nopt/README.md create mode 100644 wp8/node_modules/nopt/examples/my-program.js create mode 100644 wp8/node_modules/nopt/lib/nopt.js create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/LICENSE create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/README.md create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/abbrev.js create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/package.json create mode 100644 wp8/node_modules/nopt/node_modules/abbrev/test.js create mode 100644 wp8/node_modules/nopt/package.json create mode 100644 wp8/node_modules/nopt/test/basic.js create mode 100644 wp8/node_modules/q/CONTRIBUTING.md create mode 100644 wp8/node_modules/q/LICENSE create mode 100644 wp8/node_modules/q/README.md create mode 100644 wp8/node_modules/q/benchmark/compare-with-callbacks.js create mode 100644 wp8/node_modules/q/benchmark/scenarios.js create mode 100644 wp8/node_modules/q/package.json create mode 100644 wp8/node_modules/q/q.js create mode 100644 wp8/node_modules/q/queue.js create mode 100644 wp8/node_modules/shelljs/.documentup.json create mode 100644 wp8/node_modules/shelljs/.npmignore create mode 100644 wp8/node_modules/shelljs/.travis.yml create mode 100644 wp8/node_modules/shelljs/LICENSE create mode 100644 wp8/node_modules/shelljs/README.md create mode 100644 wp8/node_modules/shelljs/global.js create mode 100644 wp8/node_modules/shelljs/jshint.json create mode 100644 wp8/node_modules/shelljs/make.js create mode 100644 wp8/node_modules/shelljs/package.json create mode 100644 wp8/node_modules/shelljs/scripts/docs.js create mode 100644 wp8/node_modules/shelljs/scripts/run-tests.js create mode 100644 wp8/node_modules/shelljs/shell.js create mode 100644 wp8/node_modules/shelljs/test/.npmignore create mode 100644 wp8/node_modules/shelljs/test/cat.js create mode 100644 wp8/node_modules/shelljs/test/cd.js create mode 100644 wp8/node_modules/shelljs/test/chmod.js create mode 100644 wp8/node_modules/shelljs/test/config.js create mode 100644 wp8/node_modules/shelljs/test/cp.js create mode 100644 wp8/node_modules/shelljs/test/dirs.js create mode 100644 wp8/node_modules/shelljs/test/echo.js create mode 100644 wp8/node_modules/shelljs/test/env.js create mode 100644 wp8/node_modules/shelljs/test/exec.js create mode 100644 wp8/node_modules/shelljs/test/find.js create mode 100644 wp8/node_modules/shelljs/test/grep.js create mode 100644 wp8/node_modules/shelljs/test/ls.js create mode 100644 wp8/node_modules/shelljs/test/make.js create mode 100644 wp8/node_modules/shelljs/test/mkdir.js create mode 100644 wp8/node_modules/shelljs/test/mv.js create mode 100644 wp8/node_modules/shelljs/test/popd.js create mode 100644 wp8/node_modules/shelljs/test/pushd.js create mode 100644 wp8/node_modules/shelljs/test/pwd.js create mode 100644 wp8/node_modules/shelljs/test/resources/a.txt create mode 100644 wp8/node_modules/shelljs/test/resources/chmod/a/b/c/.npmignore create mode 100644 wp8/node_modules/shelljs/test/resources/chmod/b/a/b/.npmignore create mode 100644 wp8/node_modules/shelljs/test/resources/chmod/c/a/b/.npmignore create mode 100644 wp8/node_modules/shelljs/test/resources/chmod/file1 create mode 100644 wp8/node_modules/shelljs/test/resources/cp/a create mode 100644 wp8/node_modules/shelljs/test/resources/cp/b create mode 100644 wp8/node_modules/shelljs/test/resources/cp/dir_a/z create mode 100644 wp8/node_modules/shelljs/test/resources/cp/dir_b/dir_b_a/dir_b_a_a/z create mode 100644 wp8/node_modules/shelljs/test/resources/external/node_script.js create mode 100644 wp8/node_modules/shelljs/test/resources/file1 create mode 100644 wp8/node_modules/shelljs/test/resources/file1.js create mode 100644 wp8/node_modules/shelljs/test/resources/file1.txt create mode 100644 wp8/node_modules/shelljs/test/resources/file2 create mode 100644 wp8/node_modules/shelljs/test/resources/file2.js create mode 100644 wp8/node_modules/shelljs/test/resources/file2.txt create mode 100644 wp8/node_modules/shelljs/test/resources/find/.hidden create mode 100644 wp8/node_modules/shelljs/test/resources/find/a create mode 100644 wp8/node_modules/shelljs/test/resources/find/b create mode 100644 wp8/node_modules/shelljs/test/resources/find/dir1/a_dir1 create mode 100644 wp8/node_modules/shelljs/test/resources/find/dir1/dir11/a_dir11 create mode 100644 wp8/node_modules/shelljs/test/resources/find/dir2/a_dir1 create mode 100644 wp8/node_modules/shelljs/test/resources/issue44/main.js create mode 100644 wp8/node_modules/shelljs/test/resources/ls/.hidden_dir/nada create mode 100644 wp8/node_modules/shelljs/test/resources/ls/.hidden_file create mode 100644 wp8/node_modules/shelljs/test/resources/ls/a_dir/.hidden_dir/nada create mode 100644 wp8/node_modules/shelljs/test/resources/ls/a_dir/b_dir/z create mode 100644 wp8/node_modules/shelljs/test/resources/ls/a_dir/nada create mode 100644 wp8/node_modules/shelljs/test/resources/ls/file1 create mode 100644 wp8/node_modules/shelljs/test/resources/ls/file1.js create mode 100644 wp8/node_modules/shelljs/test/resources/ls/file2 create mode 100644 wp8/node_modules/shelljs/test/resources/ls/file2.js create mode 100644 wp8/node_modules/shelljs/test/resources/ls/filename(with)[chars$]^that.must+be-escaped create mode 100644 wp8/node_modules/shelljs/test/resources/pushd/a/dummy create mode 100644 wp8/node_modules/shelljs/test/resources/pushd/b/c/dummy create mode 100644 wp8/node_modules/shelljs/test/rm.js create mode 100644 wp8/node_modules/shelljs/test/sed.js create mode 100644 wp8/node_modules/shelljs/test/tempdir.js create mode 100644 wp8/node_modules/shelljs/test/test.js create mode 100644 wp8/node_modules/shelljs/test/to.js create mode 100644 wp8/node_modules/shelljs/test/which.js create mode 100644 wp8/template/cordova/build create mode 100644 wp8/template/cordova/clean delete mode 100644 wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy.sln delete mode 100644 wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj delete mode 100644 wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs delete mode 100644 wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs delete mode 100644 wp8/template/cordova/lib/CordovaDeploy/CordovaDeploy/app.config create mode 100644 wp8/template/cordova/lib/MSBuildTools.js delete mode 100644 wp8/template/cordova/lib/deploy.js create mode 100644 wp8/template/cordova/lib/device.js delete mode 100644 wp8/template/cordova/lib/log.js create mode 100644 wp8/template/cordova/lib/package.js create mode 100644 wp8/template/cordova/lib/run.js create mode 100644 wp8/template/cordova/lib/utils.js create mode 100644 wp8/template/cordova/node_modules/.bin/nopt create mode 100644 wp8/template/cordova/node_modules/.bin/nopt.cmd create mode 100644 wp8/template/cordova/node_modules/.bin/shjs create mode 100644 wp8/template/cordova/node_modules/.bin/shjs.cmd create mode 100644 wp8/template/cordova/node_modules/nopt/.npmignore create mode 100644 wp8/template/cordova/node_modules/nopt/LICENSE create mode 100644 wp8/template/cordova/node_modules/nopt/README.md create mode 100644 wp8/template/cordova/node_modules/nopt/examples/my-program.js create mode 100644 wp8/template/cordova/node_modules/nopt/lib/nopt.js create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/LICENSE create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/README.md create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/abbrev.js create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/package.json create mode 100644 wp8/template/cordova/node_modules/nopt/node_modules/abbrev/test.js create mode 100644 wp8/template/cordova/node_modules/nopt/package.json create mode 100644 wp8/template/cordova/node_modules/nopt/test/basic.js create mode 100644 wp8/template/cordova/node_modules/q/CONTRIBUTING.md create mode 100644 wp8/template/cordova/node_modules/q/LICENSE create mode 100644 wp8/template/cordova/node_modules/q/README.md create mode 100644 wp8/template/cordova/node_modules/q/benchmark/compare-with-callbacks.js create mode 100644 wp8/template/cordova/node_modules/q/benchmark/scenarios.js create mode 100644 wp8/template/cordova/node_modules/q/package.json create mode 100644 wp8/template/cordova/node_modules/q/q.js create mode 100644 wp8/template/cordova/node_modules/q/queue.js create mode 100644 wp8/template/cordova/node_modules/shelljs/.documentup.json create mode 100644 wp8/template/cordova/node_modules/shelljs/.jshintrc create mode 100644 wp8/template/cordova/node_modules/shelljs/.npmignore create mode 100644 wp8/template/cordova/node_modules/shelljs/.travis.yml create mode 100644 wp8/template/cordova/node_modules/shelljs/LICENSE create mode 100644 wp8/template/cordova/node_modules/shelljs/README.md create mode 100644 wp8/template/cordova/node_modules/shelljs/global.js create mode 100644 wp8/template/cordova/node_modules/shelljs/make.js create mode 100644 wp8/template/cordova/node_modules/shelljs/package.json create mode 100644 wp8/template/cordova/node_modules/shelljs/scripts/generate-docs.js create mode 100644 wp8/template/cordova/node_modules/shelljs/scripts/run-tests.js create mode 100644 wp8/template/cordova/node_modules/shelljs/shell.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/cat.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/cd.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/chmod.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/common.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/cp.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/dirs.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/echo.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/error.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/exec.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/find.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/grep.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/ln.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/ls.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/mkdir.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/mv.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/popd.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/pushd.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/pwd.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/rm.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/sed.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/tempdir.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/test.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/to.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/toEnd.js create mode 100644 wp8/template/cordova/node_modules/shelljs/src/which.js create mode 100644 wp8/template/cordova/run diff --git a/.gitignore b/.gitignore index f770a39a..1bc763b5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,6 @@ Thumbs.db # Ignore template zip files *.zip - - # Other useful stuff *.bak @@ -24,14 +22,5 @@ Thumbs.db *.DS_Store -wp8/node_modules/ - - #We want to allow some bin folders ... !wp8/bin/ - - - - - - \ No newline at end of file diff --git a/wp8/bin/check_reqs b/wp8/bin/check_reqs index d1b9bc03..ab8b3131 100755 --- a/wp8/bin/check_reqs +++ b/wp8/bin/check_reqs @@ -1,24 +1,34 @@ -#! /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 -echo "ERROR: Cordova tooling for Windows Phone requires a Windows OS with the 'msbuild' command " -echo " in the PATH environment variable as well as having .NET Framework 4.0 (from WP SDK's)" -exit 1 \ No newline at end of file + 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 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(function success(msbuild) { + console.log('Environment is supported; found MSBuild Tools version ' + msbuild.version + ' at ' + msbuild.path); + }, function (err) { + console.error('Failed to check requirements due to', err); + process.exit(2); + }); +} \ No newline at end of file diff --git a/wp8/bin/check_reqs.bat b/wp8/bin/check_reqs.bat index f339c958..a68cfd92 100644 --- a/wp8/bin/check_reqs.bat +++ b/wp8/bin/check_reqs.bat @@ -19,11 +19,12 @@ goto endheader # under the License. # :endheader -SET script_path="%~dp0check_reqs.js" + +SET script_path="%~dp0check_reqs" IF EXIST %script_path% ( - cscript %script_path% %* //nologo + node %script_path% %* ) ELSE ( ECHO. - ECHO ERROR: Could not find 'check_reqs.js' in 'bin' folder, aborting...>&2 + ECHO ERROR: Could not find 'check_reqs' in 'bin' folder, aborting...>&2 EXIT /B 1 ) \ No newline at end of file diff --git a/wp8/bin/check_reqs.js b/wp8/bin/check_reqs.js deleted file mode 100644 index fa54707a..00000000 --- a/wp8/bin/check_reqs.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - 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 args = WScript.Arguments; -var wscript_shell = WScript.CreateObject("WScript.Shell"); - -function Usage() { - Log("Usage: [ check_reqs | cscript check_reqs.js ]"); - Log("examples:"); - Log(" cscript C:\\Users\\anonymous\\cordova-wp8\\bin\\check_reqs.js"); - Log(" CordovaWindowsPhone\\bin\\check_reqs"); - -} - -// log to stdout or stderr -function Log(msg, error) { - if (error) { - WScript.StdErr.WriteLine(msg); - } - else { - WScript.StdOut.WriteLine(msg); - } -} - -if (args.Count() > 0) { - // support help flags - if (args(0).indexOf("help") > -1 || args(0) == "/?" || args(0) == "-h") { - Usage(); - WScript.Quit(1); - } - else { - Log('Error : Did not recognize argument ' + args(0), true); - Usage(); - WScript.Quit(1); - } -} -else { -/* The tooling for cordova windows phone requires these commands - * in the environment PATH variable. - * - msbuild (ex. C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319) - */ - var version; - - try { - version = wscript_shell.RegRead("HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0\\MSBuildRuntimeVersion"); - if(version != null && version.indexOf("4.0") == 0) { - // All good! - Log(version); - } - else { - throw(new Error("version not 4.0")); - } - } - catch(err) { - Log('Please install the .NET Framework v4.0 (part of the latest windows phone SDK\'s).', true); - WScript.Quit(2); - } -} - diff --git a/wp8/bin/create b/wp8/bin/create new file mode 100644 index 00000000..a687b3b9 --- /dev/null +++ b/wp8/bin/create @@ -0,0 +1,38 @@ +#!/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. +*/ + +/* + * create a cordova/windows8 project + * USAGE + * ./create [path package activity] + * ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject" + */ + +var create = require('./lib/create'); + +if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { + create.help(); +} else { + create.run(process.argv).done(null, function (err) { + console.error('Failed to create project due to', err); + process.exit(2); + }); +} diff --git a/wp8/bin/create.bat b/wp8/bin/create.bat index 3e3dbdff..4dcf3373 100644 --- a/wp8/bin/create.bat +++ b/wp8/bin/create.bat @@ -19,11 +19,12 @@ goto endheader # under the License. # :endheader + SET full_path=%~dp0 -IF EXIST "%full_path%create.js" ( - cscript "%full_path%create.js" %* //nologo +IF EXIST "%full_path%create" ( + node "%full_path%create" %* ) ELSE ( ECHO. - ECHO ERROR: Could not find 'create.js' in 'bin' folder, aborting...>&2 + ECHO ERROR: Could not find 'create' in 'bin' folder, aborting...>&2 EXIT /B 1 ) diff --git a/wp8/bin/create.js b/wp8/bin/create.js deleted file mode 100644 index fdadf090..00000000 --- a/wp8/bin/create.js +++ /dev/null @@ -1,287 +0,0 @@ -/* - 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. -*/ - -/* - * create a cordova/wp8 project - * - * USAGE - * ./create [path package activity] - - ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject" - */ - - -var fso=WScript.CreateObject("Scripting.FileSystemObject"); -var wscript_shell = WScript.CreateObject("WScript.Shell"); -// working dir -var platformRoot = WScript.ScriptFullName.split('\\bin\\create.js').join(''); -var repoRoot = fso.GetParentFolderName(platformRoot); -var args = WScript.Arguments; -var destPath; - - -Log("platformRoot = " + platformRoot); -Log("repoRoot = " + repoRoot); - - -function Usage() { - Log("Usage: create PathToNewProject [ PackageName AppName TemplatePath ]"); - Log(" PathToNewProject : The path to where you wish to create the project"); - Log(" PackageName : The namespace for the project (default is Cordova.Example)"); - Log(" AppName : The name of the application (default is CordovaAppProj)"); - Log(" TemplatePath : The path to project template (default is ..\\template)"); - Log("examples:"); - Log(" create C:\\Users\\anonymous\\Desktop\\MyProject"); - Log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp"); -} - -// logs messaged to stdout and stderr -function Log(msg, error) { - if (error) { - WScript.StdErr.WriteLine(msg); - } - else { - WScript.StdOut.WriteLine(msg); - } -} - -var ForReading = 1, ForWriting = 2, ForAppending = 8; -var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; - -function read(filename) { - var f=fso.OpenTextFile(filename, 1,2); - var s=f.ReadAll(); - f.Close(); - return s; -} - -// Reads content of utf-8 encoded file, removing BOM, if exist. -function readUTF8 (filename) { - var inStream = WScript.CreateObject("ADODB.Stream"); - inStream.Charset = "UTF-8"; - inStream.Open(); - inStream.LoadFromFile(filename); - var text = inStream.ReadText(); - inStream.Close(); - return text; -} - -function write(filename, contents) { - var f=fso.OpenTextFile(filename, ForWriting, TristateTrue); - f.Write(contents); - f.Close(); -} - -// Writes content to utf-8 encoded file. Adds BOM if necessary. -function writeUTF8 (filename, contents) { - var outStream = WScript.CreateObject("ADODB.Stream"); - outStream.Mode = 3; - outStream.Open(); - outStream.Charset = "UTF-8"; - outStream.WriteText(contents); - outStream.SaveToFile(filename, 2); - outStream.Close(); -} - -function replaceInFile(filename, regexp, replacement) { - write(filename,read(filename).replace(regexp,replacement)); -} - -function replaceInUTF8 (filename, regexp, replacement) { - writeUTF8(filename, readUTF8(filename).replace(regexp, replacement)); -} - -// deletes file if it exists -function deleteFileIfExists(path) { - if(fso.FileExists(path)) { - fso.DeleteFile(path); - } -} - - -// executes a commmand in the shell -function exec(command) { - var oShell=wscript_shell.Exec(command); - while (oShell.Status == 0) { - WScript.sleep(100); - } -} - -// executes a commmand in the shell -function exec_verbose(command) { - //Log("Command: " + command); - var oShell=wscript_shell.Exec(command); - while (oShell.Status == 0) { - //Wait a little bit so we're not super looping - WScript.sleep(100); - //Print any stdout output from the script - if (!oShell.StdOut.AtEndOfStream) { - var line = oShell.StdOut.ReadLine(); - Log(line); - } - } - //Check to make sure our scripts did not encounter an error - if (!oShell.StdErr.AtEndOfStream) { - var line = oShell.StdErr.ReadAll(); - Log("ERROR: command failed in create.js : " + command); - Log(line, true); - WScript.Quit(1); - } -} - -//generate guid for the project -function genGuid() { - var TypeLib = WScript.CreateObject("Scriptlet.TypeLib"); - strGuid = TypeLib.Guid.split("}")[0]; // there is extra crap after the } that is causing file streams to break, probably an EOF ... - strGuid = strGuid.replace(/[\{\}]/g,""); - return strGuid; -} - -// creates new project in path, with the given package and app name -function create(path, namespace, name, templatePath) { - Log("Creating Cordova-WP8 Project:"); - Log("\tPathToNewProject : " + path); - Log("\tPackageName : " + namespace); - Log("\tAppName : " + name); - Log("\tTemplatePath : " + templatePath); - - // test for valid identifiers, alpha-numeric + _$ - if(!/^[a-zA-Z0-9._$]+$/g.test(namespace)) { - namespace = namespace.replace("-","_"); - Log("Replaced '-' with '_' in PackageName : " + namespace); - } - // if replacing the - with a _ does not work, give up - if(!/^[a-zA-Z0-9._$]+$/g.test(namespace)) { - Log("Error : Invalid identifier! PackageName may only include letters, numbers, _ and $"); - Usage(); - WScript.Quit(1); - } - - // Copy the template source files to the new destination - fso.CopyFolder(templatePath, path); - // copy over common files - //fso.CopyFolder(repoRoot + "\\common", path); - // copy the version file - fso.CopyFile(repoRoot +'\\VERSION',path + "\\" ); - - fso.CopyFile(platformRoot +'\\bin\\check_reqs.bat',path + "\\cordova\\" ); - fso.CopyFile(platformRoot +'\\bin\\check_reqs.js',path + "\\cordova\\" ); - - // copy the defaults.xml into config.xml so this project can be built when create is called minus the cordova-cli - fso.CopyFile(path + "\\cordova\\defaults.xml", path + "\\config.xml"); - - // remove template cruft - deleteFileIfExists(path + "\\__PreviewImage.jpg"); - deleteFileIfExists(path + "\\__TemplateIcon.png"); - deleteFileIfExists(path + "\\MyTemplate.vstemplate"); - - var newProjGuid = genGuid(); - // replace the guid in the AppManifest - replaceInUTF8(path + "\\Properties\\WMAppManifest.xml","$guid1$",newProjGuid); - // replace safe-project-name in AppManifest - replaceInUTF8(path + "\\Properties\\WMAppManifest.xml",/\$safeprojectname\$/g,name); - replaceInUTF8(path + "\\Properties\\WMAppManifest.xml",/\$projectname\$/g,name); - - replaceInUTF8(path + "\\App.xaml",/\$safeprojectname\$/g,namespace); - replaceInUTF8(path + "\\App.xaml.cs",/\$safeprojectname\$/g,namespace); - - replaceInUTF8(path + "\\MainPage.xaml",/\$safeprojectname\$/g,namespace); - replaceInUTF8(path + "\\MainPage.xaml.cs",/\$safeprojectname\$/g,namespace); - replaceInUTF8(path + "\\CordovaWP8AppProj.csproj",/\$safeprojectname\$/g,namespace); - - if (name != "CordovaWP8AppProj") { - var valid_name = name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'); - replaceInUTF8(path + "\\CordovaWP8Solution.sln", /CordovaWP8AppProj/g, valid_name); - // rename project and solution - exec('%comspec% /c ren "' + path + '\\CordovaWP8Solution.sln" ' + valid_name + '.sln'); - exec('%comspec% /c ren "' + path + '\\CordovaWP8AppProj.csproj" ' + valid_name + '.csproj'); - } - - //clean up any Bin/obj or other generated files - exec('cscript "' + path + '\\cordova\\lib\\clean.js" //nologo'); - - // delete any .user and .sou files if any - if (fso.FolderExists(path)) { - var proj_folder = fso.GetFolder(path); - var proj_files = new Enumerator(proj_folder.Files); - for (;!proj_files.atEnd(); proj_files.moveNext()) { - if (fso.GetExtensionName(proj_files.item()) == 'user') { - fso.DeleteFile(proj_files.item()); - } else if (fso.GetExtensionName(proj_files.item()) == 'sou') { - fso.DeleteFile(proj_files.item()); - } - } - } - - Log("CREATE SUCCESS : " + path); - -} - -// MAIN - -if (args.Count() > 0) { - // support help flags - if (args(0) == "--help" || args(0) == "/?" || - args(0) == "help" || args(0) == "-help" || args(0) == "/help" || args(0) == "-h") { - Usage(); - WScript.Quit(1); - } - - destPath = args(0); - if (fso.FolderExists(destPath)) { - Log("Project directory already exists:", true); - Log("\t" + destPath, true); - Log("CREATE FAILED.", true); - WScript.Quit(1); - } - else { - // Fix trailing slash issue - while(destPath.length && destPath.substr(destPath.length - 1,1) == "\\") { - destPath = destPath.substr(0,destPath.length - 1); - } - if(!destPath.length) { - Log("Invalid destination specified: " + args(0),true); - WScript.Quit(1); - } - } - - - - var packageName = "Cordova.Example"; - if (args.Count() > 1) { - packageName = args(1); - } - - var projName = "CordovaWP8AppProj"; - if (args.Count() > 2) { - projName = args(2); - } - - var templatePath = platformRoot + "\\template"; - if (args.Count() > 3) { - templatePath = args(3); - } - - create(destPath, packageName, projName, templatePath); -} -else { - Usage(); - WScript.Quit(1); -} - diff --git a/wp8/bin/createTemplates.bat b/wp8/bin/createTemplates.bat index 6aa8f809..98245528 100644 --- a/wp8/bin/createTemplates.bat +++ b/wp8/bin/createTemplates.bat @@ -20,5 +20,4 @@ goto endheader # :endheader -@echo off cscript "%~dp0\createTemplates.js" %* //nologo \ No newline at end of file diff --git a/wp8/bin/lib/check_reqs.js b/wp8/bin/lib/check_reqs.js new file mode 100644 index 00000000..8a480e56 --- /dev/null +++ b/wp8/bin/lib/check_reqs.js @@ -0,0 +1,35 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var Q = require('Q'), + os = require('os'), + MSBuildTools = require('../../template/cordova/lib/MSBuildTools'); + +module.exports.run = function () { + if (os.platform() != 'win32'){ + // Build Universal windows apps available for windows platform only, so we reject on others platforms + return Q.reject("ERROR: Cordova tooling for Windows requires Windows OS"); + } + // Check whther MSBuild Tools are available + return MSBuildTools.findAvailableVersion(); +}; + +module.exports.help = function () { + console.log("Usage: check_reqs or node check_reqs"); +}; diff --git a/wp8/bin/lib/create.js b/wp8/bin/lib/create.js new file mode 100644 index 00000000..b42f03a8 --- /dev/null +++ b/wp8/bin/lib/create.js @@ -0,0 +1,123 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var Q = require('Q'), + fs = require('fs'), + path = require('path'), + shell = require('shelljs'), + uuid = require('node-uuid'); + +var defaultAppName = "CordovaWP8AppProj"; +var defaultSlnName = "CordovaWP8Solution"; + +// Creates cordova-windows project at specified path with specified namespace, app name and GUID +module.exports.run = function (argv) { + + // Get script args + var args = argv.slice(2); + + // Set and validate parameters/defaults for create + + var projectPath = args[0]; + if (fs.existsSync(projectPath)){ + return Q.reject("Project directory already exists:\n\t" + projectPath); + } + + // Package name can't contain dashes, so replace it with underscores + // if replacing the - with a _ does not work, give up + var packageName = args[1] ? args[1].replace("-", "_") : "Cordova.Example"; + if(!/^[a-zA-Z0-9._$]+$/g.test(packageName)) { + return Q.reject("Invalid identifier. PackageName may only include letters, numbers, _ and $"); + } + + var appName = args[2] || defaultAppName, + safeAppName = appName.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'), + platformRoot = path.join(__dirname, '..', '..'), + templatePath = path.join(platformRoot, "template"), + customTemplate = args[3]; + + console.log("Creating Cordova Windows Project:"); + console.log("\tApp Name : " + appName); + console.log("\tNamespace : " + packageName); + console.log("\tPath : " + projectPath); + if (customTemplate) { + console.log("Custom template path: " + customTemplate); + } + + console.log('Copying necessary files to ' + projectPath); + // Copy the template source files to the new destination + shell.cp("-rf", path.join(templatePath, '*'), projectPath); + // Copy our unique VERSION file, so peeps can tell what version this project was created from. + shell.cp("-rf", path.join(platformRoot, "..", 'VERSION'), projectPath); + // copy the defaults.xml into config.xml so this project can be built when create is called minus the cordova-cli + shell.cp(path.join(projectPath, "cordova", "defaults.xml"), path.join(projectPath, "config.xml")); + + // if any custom template is provided, just copy it over created project + if (customTemplate && fs.existsSync(customTemplate)) { + console.log('Copying template overrides from ' + customTemplate + ' to ' + projectPath); + shell.cp("-rf", customTemplate, projectPath); + } + + console.log("Updating project files"); + // replace values in the AppManifest + var wmAppManifest = path.join(projectPath, "Properties", "WMAppManifest.xml"), + guid = uuid.v1(); + + shell.sed("-i", /\$guid1\$/g, guid, wmAppManifest); + shell.sed("-i", /\$safeprojectname\$/g, appName, wmAppManifest); + + //replace projectname in project files + ["App.xaml", "App.xaml.cs", "MainPage.xaml", "MainPage.xaml.cs", defaultAppName + ".csproj"].forEach(function (file) { + shell.sed("-i", /\$safeprojectname\$/g, packageName, path.join(projectPath, file)); + }); + + if (appName != defaultAppName) { + var slnFile = path.join(projectPath, defaultSlnName + ".sln"), + csprojFile = path.join(projectPath, defaultAppName + ".csproj"); + + shell.sed("-i", new RegExp(defaultAppName, "g"), safeAppName, slnFile); + // rename project and solution + shell.mv("-f", slnFile, path.join(projectPath, safeAppName + ".sln")); + shell.mv("-f", csprojFile, path.join(projectPath, safeAppName + ".csproj")); + } + + // remove template cruft + ["__PreviewImage.jpg", "__TemplateIcon.png", "MyTemplate.vstemplate"].forEach(function (file) { + shell.rm(path.join(projectPath, file)); + }); + + // Delete bld forder and bin folder + ["bld", "bin", "*.user", "*.suo"].forEach(function (file) { + shell.rm('-rf', path.join(projectPath, file)); + }); + + return Q.resolve(); +}; + +module.exports.help = function () { + console.log("Usage: create PathToNewProject [ PackageName [ AppName [ CustomTemplate ] ] ]"); + console.log(" PathToNewProject : The path to where you wish to create the project"); + console.log(" PackageName : The namespace for the project (default is Cordova.Example)"); + console.log(" AppName : The name of the application (default is CordovaAppProj)"); + console.log(" CustomTemplate : The path to project template overrides"); + console.log(" (will be copied over default platform template files)"); + console.log("examples:"); + console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject"); + console.log(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp"); +}; \ No newline at end of file diff --git a/wp8/bin/lib/update.js b/wp8/bin/lib/update.js new file mode 100644 index 00000000..530852b9 --- /dev/null +++ b/wp8/bin/lib/update.js @@ -0,0 +1,68 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var Q = require('Q'), + fs = require('fs'), + path = require('path'), + shell = require('shelljs'), + create = require('./create'); + +// returns package metadata from config.xml with fields 'namespace' and 'name' +function extractMetadata(projectPath) { + if (!fs.existsSync(path.join(projectPath, 'config.xml'))){ + return Q.reject('config.xml does not exist'); + } + + var meta = { // default values + namespace: 'io.cordova.hellocordova', + name: 'HelloCordova' + }; + + // TODO: read real values from config.xml + // in case of Cordova CLI all values will be automatically updated by cli for you + // but the script could be used w/o CLI so we should correctly populate meta + + return Q.resolve(meta); +} + +module.exports.help = function () { + console.log("WARNING : Make sure to back up your project before updating!"); + console.log("Usage: update PathToProject "); + console.log(" PathToProject : The path the project you would like to update."); + console.log("examples:"); + console.log(" update C:\\Users\\anonymous\\Desktop\\MyProject"); +}; + +// updates the cordova.js in project along with the cordova tooling. +module.exports.run = function (argv) { + var projectPath = argv[2]; + if (!fs.existsSync(projectPath)){ + // if specified project path is not valid then reject promise + Q.reject("The given path to the project does not exist." + + " Please provide a path to the project you would like to update."); + } + + return extractMetadata(projectPath).then(function (metadata) { + shell.rm('-rf', projectPath); + + // setup args for create.run which requires process.argv-like array + var createArgs = argv.concat([metadata.namespace, metadata.name]); + return create.run(createArgs); + }); +}; \ No newline at end of file diff --git a/wp8/bin/update b/wp8/bin/update new file mode 100644 index 00000000..f3e8287b --- /dev/null +++ b/wp8/bin/update @@ -0,0 +1,34 @@ +#!/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 update = require('./lib/update'); + +// check for help flag +if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) { + update.help(); +} else { + update.run(process.argv).done(function () { + console.log('Successfully updated windows project.'); + }, function (err) { + console.error('Failed to check requirements due to', err); + process.exit(2); + }); +} diff --git a/wp8/bin/update.bat b/wp8/bin/update.bat index d39069da..122b0822 100644 --- a/wp8/bin/update.bat +++ b/wp8/bin/update.bat @@ -19,11 +19,12 @@ goto endheader # under the License. # :endheader -SET full_path=%~dp0 -IF EXIST %full_path%update.js ( - cscript "%full_path%update.js" %* //nologo + +SET script_path="%~dp0update" +IF EXIST %script_path% ( + node %script_path% %* ) ELSE ( ECHO. - ECHO ERROR: Could not find 'update.js' in 'bin' folder, aborting...>&2 + ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2 EXIT /B 1 ) \ No newline at end of file diff --git a/wp8/bin/update.js b/wp8/bin/update.js deleted file mode 100644 index f2acd6f4..00000000 --- a/wp8/bin/update.js +++ /dev/null @@ -1,353 +0,0 @@ -/* - 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 fso = WScript.CreateObject("Scripting.FileSystemObject"); -var wscript_shell = WScript.CreateObject("WScript.Shell"); -var shell = WScript.CreateObject("shell.application"); -var args = WScript.Arguments; -// working dir -var ROOT = WScript.ScriptFullName.split('\\bin\\update.js').join(''); -//Get version number -var VERSION = read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,''); -var plugins_folder = "\\Plugins"; -var template_folder = "\\templates\\standalone"; -// anything thats missing to the project -var overwrite = false; -var replace = false; - -// usage function -function Usage() { - Log("WARNING : Make sure to back up your project before updating!") - Log("Usage: update Path-To-Project ");//[ -f | -r ] "); - Log(" Path-To-Old-Project : The path the project you would like to update."); - //Log(" -f : Will forcefully overwrite and add all core components of the application."); - //Log(" -r : Will create an updated project, only keeping the www assets. *NOTE: no native code will be preserved*"); - Log("examples:"); - Log(" update C:\\Users\\anonymous\\Desktop\\MyProject"); -} - -// logs messaged to stdout and stderr -function Log(msg, error) { - if (error) { - WScript.StdErr.WriteLine(msg); - } - else { - WScript.StdOut.WriteLine(msg); - } -} - -// executes a commmand in the shell -function exec(command) { - Log("Command : " + command); - var oShell=wscript_shell.Exec(command); - while (oShell.Status === 0) { - WScript.sleep(100); - } -} - -// executes a commmand in the shell -function exec_verbose(command) { - Log("Command: " + command); - var oShell=wscript_shell.Exec(command); - while (oShell.Status == 0) { - //Wait a little bit so we're not super looping - WScript.sleep(100); - //Print any stdout output from the script - if (!oShell.StdOut.AtEndOfStream) { - var line = oShell.StdOut.ReadAll(); - Log(line); - } - } - //Check to make sure our scripts did not encounter an error - if (!oShell.StdErr.AtEndOfStream) { - var line = oShell.StdErr.ReadAll(); - Log(line, true); - WScript.Quit(2); - } -} - -var ForReading = 1, ForWriting = 2, ForAppending = 8; -var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; - -// returns the contents of a file -function read(filename) { - if (fso.FileExists(filename)) { - var f=fso.OpenTextFile(filename, 1, 2); - var s=f.ReadAll(); - f.Close(); - return s; - } - else { - Log('Cannot read non-existant file : ' + filename, true); - WScript.Quit(2); - } - return null; -} - -// writes the contents to the specified file -function write(filename, contents) { - var f=fso.OpenTextFile(filename, ForWriting, TristateTrue); - f.Write(contents); - f.Close(); -} - -// replaces the matches of regexp with replacement -function replaceInFile(filename, regexp, replacement) { - var text = read(filename).replace(regexp,replacement); - write(filename,text); -} - -// returns true if the given path is the root of a cordova windows phone project -// currently returns true if the folder contains a .csproj file. -function is_windows_phone_project(path) { - if (fso.FolderExists(path)) { - var proj_folder = fso.GetFolder(path); - var proj_files = new Enumerator(proj_folder.Files); - for (;!proj_files.atEnd(); proj_files.moveNext()) { - if (fso.GetExtensionName(proj_files.item()) == 'csproj') { - return true; - } - } - } - return false; -} - -// returns the name of the application -function get_app_name(path) { - var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n'); - for (line in WMAppManifest) { - if (WMAppManifest[line].match(/Title\=\"/)) { - return WMAppManifest[line].split('Title="')[1].split('"')[0]; - } - } - Log("Error : unable to find applicaiton name in the project.", true); - Log(" Path : " + path, true); - WScript.Quit(2); -} - -// returns the name of the application package -function get_package_name(path) { - var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n'); - for (line in WMAppManifest) { - if (WMAppManifest[line].match(/Title\=\"/)) { - return WMAppManifest[line].split('Title="')[1].split('"')[0]; - } - } - Log("Error : unable to find applicaiton name in the project.", true); - Log(" Path : " + path, true); - WScript.Quit(2); -} - -// returns the GUID ame of the application -function get_app_GUID(path) { - var AppXAML = read(path + '\\App.xaml').split('\n'); - for (line in AppXAML) { - if (AppXAML[line].match(/x\:Class\=\"/)) { - return AppXAML[line].split('Class="')[1].split('"')[0]; - } - } - Log("Error : unable to find package name in the project.", true); - Log(" Path : " + path, true); - WScript.Quit(2); -} - -// updates the cordova.js and all references in the given project with this repositories version -function update_cordova_js(path) { - // remove old cordova.js - var www_contents = shell.NameSpace(path + '\\www').Items(); - for(i = 0; i < www_contents.Count; i++) - { - if(www_contents.Item(i).Name.match(/cordova\-(\d+)[.](\d+)[.](\d+)(rc\d)?[.]js/)) - { - fso.DeleteFile(path + '\\www\\' + www_contents.Item(i).Name); - } - } - // update version file - copy_to(ROOT + "\\VERSION", path + "\\VERSION"); - // copy over new cordova.js - copy_to(ROOT + template_folder + "\\www\\cordova.js", path + "\\www\\cordova.js"); - - // update corodva references - var cordova_regex = /cordova-(\d+)[.](\d+)[.](\d+)(rc\d)?/g; //Matches *first* cordova-x.x.x[rcx] (just ad g at end to make global) - // update references in index.html - replaceInFile(path + '\\www\\index.html', cordova_regex, "cordova"); - version_regex = /return\s*\"(\d+)[.](\d+)[.](\d+)(rc\d)?/; //Matches return "x.x.x[rcx] - // update references in Device.cs - replaceInFile(path + '\\Plugins\\Device.cs', version_regex, "return \"" + VERSION); -} - -// Copies assets that need to be saved from source to desination. -// TODO : Add all critical assets here -function save_restore(source, destination) { - fso.CreateFolder(destination + '\\www'); - copy_to(source + '\\www', destination + '\\www'); - copy_to(source + '\\SplashScreenImage.jpg', destination + '\\SplashScreenImage.jpg'); - copy_to(source + '\\Background.png', destination + '\\Background.png'); - copy_to(source + '\\ApplicationIcon.png', destination + '\\ApplicationIcon.png'); - copy_to(source + '\\config.xml', destination + '\\config.xml'); -} - -// deletes the path element if it exists -function delete_if_exists(path) { - if (fso.FolderExists(path)) { - fso.DeleteFolder(path); - } - else if (fso.FileExists(path)) { - fso.DeleteFile(path); - } -} - -// copies a folder or file from source to destination -function copy_to(source, destination) { - // check that source exists - if (!fso.FolderExists(source)) { - if (!fso.FileExists(source)) { - Log("Error : Could not copy file/folder because it doesn't exist.", true); - Log(" File/Folder : " + source, true); - WScript.Quit(2); - } - } - // if source is a folder, then copy all folder contents - if (fso.FolderExists(source)) { - fso.CopyFolder(source, destination, true); - } - // if it's a file, just copy it. - else { - exec('%comspec% /c copy /Y /V ' + source + ' ' + destination); - } -} - -// updates the cordova.js in project along with the cordova tooling. -function update_project(path) { - // update cordova folder - delete_if_exists(path + '\\cordova'); - fso.CreateFolder(path + '\\cordova'); - copy_to(ROOT + template_folder + '\\cordova', path + '\\cordova'); - // clean project (all generated files) - exec(path + '\\cordova\\clean.bat'); - - // update core cordovalib - delete_if_exists(path + '\\cordovalib'); - fso.CreateFolder(path + '\\cordovalib'); - copy_to(ROOT + template_folder + '\\cordovalib', path + '\\cordovalib'); - - // update core plugins - // TODO : Remove for 3.0.0 - delete_if_exists(path + '\\Plugins'); - fso.CreateFolder(path + '\\Plugins'); - copy_to(ROOT + template_folder + '\\Plugins', path + '\\Plugins'); - - // update cordova.js - update_cordova_js(path); -} - -// Replaces the current project with a newly created project, keeping important assets to preserve the app. -// TODO: Things that need to be kept other then www -// - WMAppManifest (capabilities etc...) -// - GUID (for marketplace apps etc...) -// - Splashscreen and other images etc... -// - Find more things that should be kept -function replace_project(path) { - //create new project and move www assets into it. - Log("WARNING : Upgrading your app with the \'-r\' flag will delete all native and plugin"); - Log(" components of your application and replace them with the updated core components given"); - Log(" by this platforms \'bin\\create\' script. It is *HIGHLY RECOMMENDED* to back up your app"); - Log(" before continuing. The name and package name along with all of the www assets will be"); - Log(" preserved. Are you sure you wish to continue? (Y/N)"); - var response; - while (response != 'Y') { - response = WScript.StdIn.ReadLine(); - if (response == 'N') { - WScript.Quit(2); - } else if (response != "Y") { - Log("Error : did not recognize '" + response + "'"); - Log("Are you sure you wish to continue? (Y/N)"); - } - } - // place all assets to be preserved in a temperary folder - delete_if_exists(ROOT + '\\temp'); - fso.CreateFolder(ROOT + '\\temp'); - save_restore(path, ROOT + '\\temp'); - - // get app name from WMAppManifest - var app_name = get_app_name(path); - // get package name from App.xaml - var package_name = get_package_name(path); - // get the GUID so that app stays the same - var app_GUID = get_app_GUID(path); - // delete previous project - delete_if_exists(path); - // create the new project from the current repository - exec(ROOT + '\\bin\\create.bat ' + path + ' ' + app_name + ' ' + package_name); - // remove default www assets - delete_if_exists(path + '\\www'); - // move www assets back to project folder - save_restore(ROOT + '\\temp', path); - // cleanup temp folder - delete_if_exists(ROOT + '\\temp'); -} - - - -if (args.Count() > 0) { - if(args.Count() > 2) { - Log("Error : too many arguments provided.", true); - WScript.Quit(1); - } - - if (args(0).indexOf("--help") > -1 || - args(0).indexOf("/?") > -1 ) { - Usage(); - WScript.Quit(1); - } - else if (fso.FolderExists(args(0)) && is_windows_phone_project(args(0))) { - if(args.Count() > 1) { - /*if(args(1) == '-f' || args(1) == '--force') { - //TODO: do something for this - Log("ERROR : NOT IMPLEMENTED", true); - WScript.Quit(2); - } - else if(args(1) == '-r' || args(1) == '--replace') { - replace_project(args(0)); - } - else { - Log('Error : \'' + args(1) + '\' is not regognized as an update option', true); - }*/ - Usage(); - Log('Error : too many arguments', true); - } else if (args.Count() == 1) { - update_project(args(0)); - } - } - else if (fso.FolderExists(args(0))) { - Log("The path provided is not a path to a cordova windows phone project.", true); - Log(" Please provide the path to the root folder of your cordova windows phone project.", true); - WScript.Quit(2); - } - else { - Log("The given path to the project does not exist.", true); - Log(" Please provide a path to the project you would like to update.", true); - Usage(); - WScript.Quit(2); - } -} -else { - Usage(); - WScript.Quit(1); -} \ No newline at end of file diff --git a/wp8/node_modules/.bin/nopt b/wp8/node_modules/.bin/nopt new file mode 100644 index 00000000..25995f38 --- /dev/null +++ b/wp8/node_modules/.bin/nopt @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../nopt/bin/nopt.js" "$@" + ret=$? +else + node "$basedir/../nopt/bin/nopt.js" "$@" + ret=$? +fi +exit $ret diff --git a/wp8/node_modules/.bin/nopt.cmd b/wp8/node_modules/.bin/nopt.cmd new file mode 100644 index 00000000..c8e82169 --- /dev/null +++ b/wp8/node_modules/.bin/nopt.cmd @@ -0,0 +1,5 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\nopt\bin\nopt.js" %* +) ELSE ( + node "%~dp0\..\nopt\bin\nopt.js" %* +) \ No newline at end of file diff --git a/wp8/node_modules/.bin/shjs b/wp8/node_modules/.bin/shjs new file mode 100644 index 00000000..99086759 --- /dev/null +++ b/wp8/node_modules/.bin/shjs @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../shelljs/bin/shjs" "$@" + ret=$? +else + node "$basedir/../shelljs/bin/shjs" "$@" + ret=$? +fi +exit $ret diff --git a/wp8/node_modules/.bin/shjs.cmd b/wp8/node_modules/.bin/shjs.cmd new file mode 100644 index 00000000..9ce460a8 --- /dev/null +++ b/wp8/node_modules/.bin/shjs.cmd @@ -0,0 +1,5 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\shelljs\bin\shjs" %* +) ELSE ( + node "%~dp0\..\shelljs\bin\shjs" %* +) \ No newline at end of file diff --git a/wp8/node_modules/node-uuid/.npmignore b/wp8/node_modules/node-uuid/.npmignore new file mode 100644 index 00000000..fd4f2b06 --- /dev/null +++ b/wp8/node_modules/node-uuid/.npmignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/wp8/node_modules/node-uuid/LICENSE.md b/wp8/node_modules/node-uuid/LICENSE.md new file mode 100644 index 00000000..f039427f --- /dev/null +++ b/wp8/node_modules/node-uuid/LICENSE.md @@ -0,0 +1,2 @@ +Copyright (c) 2010-2012 Robert Kieffer +MIT License - http://opensource.org/licenses/mit-license.php diff --git a/wp8/node_modules/node-uuid/README.md b/wp8/node_modules/node-uuid/README.md new file mode 100644 index 00000000..e436a89f --- /dev/null +++ b/wp8/node_modules/node-uuid/README.md @@ -0,0 +1,207 @@ +# node-uuid + +Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS. + +Features: + +* Generate RFC4122 version 1 or version 4 UUIDs +* Runs in node.js and all browsers. +* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid'). +* Cryptographically strong random # generation on supporting platforms +* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! ) +* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html) + +## Getting Started + +Install it in your browser: + +```html + +``` + +Or in node.js: + +``` +npm install node-uuid +``` + +```javascript +var uuid = require('node-uuid'); +``` + +Then create some ids ... + +```javascript +// Generate a v1 (time-based) id +uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' + +// Generate a v4 (random) id +uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1' +``` + +## API + +### uuid.v1([`options` [, `buffer` [, `offset`]]]) + +Generate and return a RFC4122 v1 (timestamp-based) UUID. + +* `options` - (Object) Optional uuid state to apply. Properties may include: + + * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1. + * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used. + * `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used. + * `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2. + +* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. +* `offset` - (Number) Starting index in `buffer` at which to begin writing. + +Returns `buffer`, if specified, otherwise the string form of the UUID + +Notes: + +1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.) + +Example: Generate string UUID with fully-specified options + +```javascript +uuid.v1({ + node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], + clockseq: 0x1234, + msecs: new Date('2011-11-01').getTime(), + nsecs: 5678 +}); // -> "710b962e-041c-11e1-9234-0123456789ab" +``` + +Example: In-place generation of two binary IDs + +```javascript +// Generate two ids in an array +var arr = new Array(32); // -> [] +uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15] +uuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15] + +// Optionally use uuid.unparse() to get stringify the ids +uuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115' +uuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115' +``` + +### uuid.v4([`options` [, `buffer` [, `offset`]]]) + +Generate and return a RFC4122 v4 UUID. + +* `options` - (Object) Optional uuid state to apply. Properties may include: + + * `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values + * `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values. + +* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. +* `offset` - (Number) Starting index in `buffer` at which to begin writing. + +Returns `buffer`, if specified, otherwise the string form of the UUID + +Example: Generate string UUID with fully-specified options + +```javascript +uuid.v4({ + random: [ + 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea, + 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36 + ] +}); +// -> "109156be-c4fb-41ea-b1b4-efe1671c5836" +``` + +Example: Generate two IDs in a single buffer + +```javascript +var buffer = new Array(32); // (or 'new Buffer' in node.js) +uuid.v4(null, buffer, 0); +uuid.v4(null, buffer, 16); +``` + +### uuid.parse(id[, buffer[, offset]]) +### uuid.unparse(buffer[, offset]) + +Parse and unparse UUIDs + + * `id` - (String) UUID(-like) string + * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used + * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0 + +Example parsing and unparsing a UUID string + +```javascript +var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> +var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10' +``` + +### uuid.noConflict() + +(Browsers only) Set `uuid` property back to it's previous value. + +Returns the node-uuid object. + +Example: + +```javascript +var myUuid = uuid.noConflict(); +myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a' +``` + +## Deprecated APIs + +Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version. + +### uuid([format [, buffer [, offset]]]) + +uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary). + +### uuid.BufferClass + +The class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API. + +## Testing + +In node.js + +``` +> cd test +> node test.js +``` + +In Browser + +``` +open test/test.html +``` + +### Benchmarking + +Requires node.js + +``` +npm install uuid uuid-js +node benchmark/benchmark.js +``` + +For a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark) + +For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance). + +## Release notes + +### 1.4.0 + +* Improved module context detection +* Removed public RNG functions + +### 1.3.2 + +* Improve tests and handling of v1() options (Issue #24) +* Expose RNG option to allow for perf testing with different generators + +### 1.3.0 + +* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)! +* Support for node.js crypto API +* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code diff --git a/wp8/node_modules/node-uuid/benchmark/README.md b/wp8/node_modules/node-uuid/benchmark/README.md new file mode 100644 index 00000000..aaeb2ea0 --- /dev/null +++ b/wp8/node_modules/node-uuid/benchmark/README.md @@ -0,0 +1,53 @@ +# node-uuid Benchmarks + +### Results + +To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark + +### Run them yourself + +node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`. + +To prepare and run the benchmark issue; + +``` +npm install uuid uuid-js +node benchmark/benchmark.js +``` + +You'll see an output like this one: + +``` +# v4 +nodeuuid.v4(): 854700 uuids/second +nodeuuid.v4('binary'): 788643 uuids/second +nodeuuid.v4('binary', buffer): 1336898 uuids/second +uuid(): 479386 uuids/second +uuid('binary'): 582072 uuids/second +uuidjs.create(4): 312304 uuids/second + +# v1 +nodeuuid.v1(): 938086 uuids/second +nodeuuid.v1('binary'): 683060 uuids/second +nodeuuid.v1('binary', buffer): 1644736 uuids/second +uuidjs.create(1): 190621 uuids/second +``` + +* The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library. +* The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK. + +If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file: + +``` +for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done; +``` + +If you're interested in how performance varies between different node versions, you can issue the above command multiple times. + +You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot: + +``` +(cd benchmark/ && ./bench.sh) +``` + +This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then. diff --git a/wp8/node_modules/node-uuid/benchmark/bench.gnu b/wp8/node_modules/node-uuid/benchmark/bench.gnu new file mode 100644 index 00000000..a342fbbe --- /dev/null +++ b/wp8/node_modules/node-uuid/benchmark/bench.gnu @@ -0,0 +1,174 @@ +#!/opt/local/bin/gnuplot -persist +# +# +# G N U P L O T +# Version 4.4 patchlevel 3 +# last modified March 2011 +# System: Darwin 10.8.0 +# +# Copyright (C) 1986-1993, 1998, 2004, 2007-2010 +# Thomas Williams, Colin Kelley and many others +# +# gnuplot home: http://www.gnuplot.info +# faq, bugs, etc: type "help seeking-assistance" +# immediate help: type "help" +# plot window: hit 'h' +set terminal postscript eps noenhanced defaultplex \ + leveldefault color colortext \ + solid linewidth 1.2 butt noclip \ + palfuncparam 2000,0.003 \ + "Helvetica" 14 +set output 'bench.eps' +unset clip points +set clip one +unset clip two +set bar 1.000000 front +set border 31 front linetype -1 linewidth 1.000 +set xdata +set ydata +set zdata +set x2data +set y2data +set timefmt x "%d/%m/%y,%H:%M" +set timefmt y "%d/%m/%y,%H:%M" +set timefmt z "%d/%m/%y,%H:%M" +set timefmt x2 "%d/%m/%y,%H:%M" +set timefmt y2 "%d/%m/%y,%H:%M" +set timefmt cb "%d/%m/%y,%H:%M" +set boxwidth +set style fill empty border +set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1 +set style circle radius graph 0.02, first 0, 0 +set dummy x,y +set format x "% g" +set format y "% g" +set format x2 "% g" +set format y2 "% g" +set format z "% g" +set format cb "% g" +set angles radians +unset grid +set key title "" +set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox +set key noinvert samplen 4 spacing 1 width 0 height 0 +set key maxcolumns 2 maxrows 0 +unset label +unset arrow +set style increment default +unset style line +set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0 +unset style arrow +set style histogram clustered gap 2 title offset character 0, 0, 0 +unset logscale +set offsets graph 0.05, 0.15, 0, 0 +set pointsize 1.5 +set pointintervalbox 1 +set encoding default +unset polar +unset parametric +unset decimalsign +set view 60, 30, 1, 1 +set samples 100, 100 +set isosamples 10, 10 +set surface +unset contour +set clabel '%8.3g' +set mapping cartesian +set datafile separator whitespace +unset hidden3d +set cntrparam order 4 +set cntrparam linear +set cntrparam levels auto 5 +set cntrparam points 5 +set size ratio 0 1,1 +set origin 0,0 +set style data points +set style function lines +set xzeroaxis linetype -2 linewidth 1.000 +set yzeroaxis linetype -2 linewidth 1.000 +set zzeroaxis linetype -2 linewidth 1.000 +set x2zeroaxis linetype -2 linewidth 1.000 +set y2zeroaxis linetype -2 linewidth 1.000 +set ticslevel 0.5 +set mxtics default +set mytics default +set mztics default +set mx2tics default +set my2tics default +set mcbtics default +set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set xtics norangelimit +set xtics () +set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set ytics autofreq norangelimit +set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0 +set ztics autofreq norangelimit +set nox2tics +set noy2tics +set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 +set cbtics autofreq norangelimit +set title "" +set title offset character 0, 0, 0 font "" norotate +set timestamp bottom +set timestamp "" +set timestamp offset character 0, 0, 0 font "" norotate +set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) +set autoscale rfixmin +set autoscale rfixmax +set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] ) +set autoscale tfixmin +set autoscale tfixmax +set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale ufixmin +set autoscale ufixmax +set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale vfixmin +set autoscale vfixmax +set xlabel "" +set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate +set x2label "" +set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate +set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] ) +set autoscale xfixmin +set autoscale xfixmax +set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] ) +set autoscale x2fixmin +set autoscale x2fixmax +set ylabel "" +set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set y2label "" +set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] ) +set autoscale yfixmin +set autoscale yfixmax +set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] ) +set autoscale y2fixmin +set autoscale y2fixmax +set zlabel "" +set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate +set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) +set autoscale zfixmin +set autoscale zfixmax +set cblabel "" +set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 +set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) +set autoscale cbfixmin +set autoscale cbfixmax +set zero 1e-08 +set lmargin -1 +set bmargin -1 +set rmargin -1 +set tmargin -1 +set pm3d explicit at s +set pm3d scansautomatic +set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean +set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB +set palette rgbformulae 7, 5, 15 +set colorbox default +set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault +set loadpath +set fontpath +set fit noerrorvariables +GNUTERM = "aqua" +plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2 +# EOF diff --git a/wp8/node_modules/node-uuid/benchmark/bench.sh b/wp8/node_modules/node-uuid/benchmark/bench.sh new file mode 100644 index 00000000..d870a0cb --- /dev/null +++ b/wp8/node_modules/node-uuid/benchmark/bench.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# for a given node version run: +# for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done; + +PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte') +FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es) +INDICES=(2 3 2 3 2 2 2 2 2) +VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " ) +TMPJOIN="tmp_join" +OUTPUT="bench_results.txt" + +for I in ${!FILES[*]}; do + F=${FILES[$I]} + P=${PATTERNS[$I]} + INDEX=${INDICES[$I]} + echo "version $F" > $F + for V in $VERSIONS; do + (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F + done + if [ $I == 0 ]; then + cat $F > $TMPJOIN + else + join $TMPJOIN $F > $OUTPUT + cp $OUTPUT $TMPJOIN + fi + rm $F +done + +rm $TMPJOIN + +gnuplot bench.gnu +convert -density 200 -resize 800x560 -flatten bench.eps bench.png +rm bench.eps diff --git a/wp8/node_modules/node-uuid/benchmark/benchmark-native.c b/wp8/node_modules/node-uuid/benchmark/benchmark-native.c new file mode 100644 index 00000000..dbfc75f6 --- /dev/null +++ b/wp8/node_modules/node-uuid/benchmark/benchmark-native.c @@ -0,0 +1,34 @@ +/* +Test performance of native C UUID generation + +To Compile: cc -luuid benchmark-native.c -o benchmark-native +*/ + +#include +#include +#include +#include + +int main() { + uuid_t myid; + char buf[36+1]; + int i; + struct timeval t; + double start, finish; + + gettimeofday(&t, NULL); + start = t.tv_sec + t.tv_usec/1e6; + + int n = 2e5; + for (i = 0; i < n; i++) { + uuid_generate(myid); + uuid_unparse(myid, buf); + } + + gettimeofday(&t, NULL); + finish = t.tv_sec + t.tv_usec/1e6; + double dur = finish - start; + + printf("%d uuids/sec", (int)(n/dur)); + return 0; +} diff --git a/wp8/node_modules/node-uuid/benchmark/benchmark.js b/wp8/node_modules/node-uuid/benchmark/benchmark.js new file mode 100644 index 00000000..40e6efbe --- /dev/null +++ b/wp8/node_modules/node-uuid/benchmark/benchmark.js @@ -0,0 +1,84 @@ +try { + var nodeuuid = require('../uuid'); +} catch (e) { + console.error('node-uuid require failed - skipping tests'); +} + +try { + var uuid = require('uuid'); +} catch (e) { + console.error('uuid require failed - skipping tests'); +} + +try { + var uuidjs = require('uuid-js'); +} catch (e) { + console.error('uuid-js require failed - skipping tests'); +} + +var N = 5e5; + +function rate(msg, t) { + console.log(msg + ': ' + + (N / (Date.now() - t) * 1e3 | 0) + + ' uuids/second'); +} + +console.log('# v4'); + +// node-uuid - string form +if (nodeuuid) { + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4(); + rate('nodeuuid.v4() - using node.js crypto RNG', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG}); + rate('nodeuuid.v4() - using Math.random() RNG', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary'); + rate('nodeuuid.v4(\'binary\')', t); + + var buffer = new nodeuuid.BufferClass(16); + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer); + rate('nodeuuid.v4(\'binary\', buffer)', t); +} + +// libuuid - string form +if (uuid) { + for (var i = 0, t = Date.now(); i < N; i++) uuid(); + rate('uuid()', t); + + for (var i = 0, t = Date.now(); i < N; i++) uuid('binary'); + rate('uuid(\'binary\')', t); +} + +// uuid-js - string form +if (uuidjs) { + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4); + rate('uuidjs.create(4)', t); +} + +// 140byte.es +for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)}); +rate('140byte.es_v4', t); + +console.log(''); +console.log('# v1'); + +// node-uuid - v1 string form +if (nodeuuid) { + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1(); + rate('nodeuuid.v1()', t); + + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary'); + rate('nodeuuid.v1(\'binary\')', t); + + var buffer = new nodeuuid.BufferClass(16); + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer); + rate('nodeuuid.v1(\'binary\', buffer)', t); +} + +// uuid-js - v1 string form +if (uuidjs) { + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1); + rate('uuidjs.create(1)', t); +} diff --git a/wp8/node_modules/node-uuid/component.json b/wp8/node_modules/node-uuid/component.json new file mode 100644 index 00000000..ace21348 --- /dev/null +++ b/wp8/node_modules/node-uuid/component.json @@ -0,0 +1,18 @@ +{ + "name": "node-uuid", + "repo": "broofa/node-uuid", + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", + "version": "1.4.0", + "author": "Robert Kieffer ", + "contributors": [ + {"name": "Christoph Tavan ", "github": "https://github.com/ctavan"} + ], + "keywords": ["uuid", "guid", "rfc4122"], + "dependencies": {}, + "development": {}, + "main": "uuid.js", + "scripts": [ + "uuid.js" + ], + "license": "MIT" +} \ No newline at end of file diff --git a/wp8/node_modules/node-uuid/package.json b/wp8/node_modules/node-uuid/package.json new file mode 100644 index 00000000..cc5d2c11 --- /dev/null +++ b/wp8/node_modules/node-uuid/package.json @@ -0,0 +1,36 @@ +{ + "name": "node-uuid", + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", + "url": "http://github.com/broofa/node-uuid", + "keywords": [ + "uuid", + "guid", + "rfc4122" + ], + "author": { + "name": "Robert Kieffer", + "email": "robert@broofa.com" + }, + "contributors": [ + { + "name": "Christoph Tavan", + "email": "dev@tavan.de" + } + ], + "lib": ".", + "main": "./uuid.js", + "repository": { + "type": "git", + "url": "https://github.com/broofa/node-uuid.git" + }, + "version": "1.4.1", + "readme": "# node-uuid\n\nSimple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.\n\nFeatures:\n\n* Generate RFC4122 version 1 or version 4 UUIDs\n* Runs in node.js and all browsers.\n* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid').\n* Cryptographically strong random # generation on supporting platforms\n* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )\n* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)\n\n## Getting Started\n\nInstall it in your browser:\n\n```html\n\n```\n\nOr in node.js:\n\n```\nnpm install node-uuid\n```\n\n```javascript\nvar uuid = require('node-uuid');\n```\n\nThen create some ids ...\n\n```javascript\n// Generate a v1 (time-based) id\nuuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n\n// Generate a v4 (random) id\nuuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'\n```\n\n## API\n\n### uuid.v1([`options` [, `buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v1 (timestamp-based) UUID.\n\n* `options` - (Object) Optional uuid state to apply. Properties may include:\n\n * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.\n * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.\n * `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.\n * `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - (Number) Starting index in `buffer` at which to begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of the UUID\n\nNotes:\n\n1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)\n\nExample: Generate string UUID with fully-specified options\n\n```javascript\nuuid.v1({\n node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],\n clockseq: 0x1234,\n msecs: new Date('2011-11-01').getTime(),\n nsecs: 5678\n}); // -> \"710b962e-041c-11e1-9234-0123456789ab\"\n```\n\nExample: In-place generation of two binary IDs\n\n```javascript\n// Generate two ids in an array\nvar arr = new Array(32); // -> []\nuuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]\nuuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]\n\n// Optionally use uuid.unparse() to get stringify the ids\nuuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115'\nuuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115'\n```\n\n### uuid.v4([`options` [, `buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v4 UUID.\n\n* `options` - (Object) Optional uuid state to apply. Properties may include:\n\n * `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values\n * `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - (Number) Starting index in `buffer` at which to begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of the UUID\n\nExample: Generate string UUID with fully-specified options\n\n```javascript\nuuid.v4({\n random: [\n 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,\n 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36\n ]\n});\n// -> \"109156be-c4fb-41ea-b1b4-efe1671c5836\"\n```\n\nExample: Generate two IDs in a single buffer\n\n```javascript\nvar buffer = new Array(32); // (or 'new Buffer' in node.js)\nuuid.v4(null, buffer, 0);\nuuid.v4(null, buffer, 16);\n```\n\n### uuid.parse(id[, buffer[, offset]])\n### uuid.unparse(buffer[, offset])\n\nParse and unparse UUIDs\n\n * `id` - (String) UUID(-like) string\n * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used\n * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0\n\nExample parsing and unparsing a UUID string\n\n```javascript\nvar bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> \nvar string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'\n```\n\n### uuid.noConflict()\n\n(Browsers only) Set `uuid` property back to it's previous value.\n\nReturns the node-uuid object.\n\nExample:\n\n```javascript\nvar myUuid = uuid.noConflict();\nmyUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n```\n\n## Deprecated APIs\n\nSupport for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.\n\n### uuid([format [, buffer [, offset]]])\n\nuuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).\n\n### uuid.BufferClass\n\nThe class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API.\n\n## Testing\n\nIn node.js\n\n```\n> cd test\n> node test.js\n```\n\nIn Browser\n\n```\nopen test/test.html\n```\n\n### Benchmarking\n\nRequires node.js\n\n```\nnpm install uuid uuid-js\nnode benchmark/benchmark.js\n```\n\nFor a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)\n\nFor browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).\n\n## Release notes\n\n### 1.4.0\n\n* Improved module context detection\n* Removed public RNG functions\n\n### 1.3.2\n\n* Improve tests and handling of v1() options (Issue #24)\n* Expose RNG option to allow for perf testing with different generators\n\n### 1.3.0\n\n* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!\n* Support for node.js crypto API\n* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/broofa/node-uuid/issues" + }, + "homepage": "https://github.com/broofa/node-uuid", + "_id": "node-uuid@1.4.1", + "_from": "node-uuid@~1.4", + "scripts": {} +} diff --git a/wp8/node_modules/node-uuid/test/compare_v1.js b/wp8/node_modules/node-uuid/test/compare_v1.js new file mode 100644 index 00000000..05af8221 --- /dev/null +++ b/wp8/node_modules/node-uuid/test/compare_v1.js @@ -0,0 +1,63 @@ +var assert = require('assert'), + nodeuuid = require('../uuid'), + uuidjs = require('uuid-js'), + libuuid = require('uuid').generate, + util = require('util'), + exec = require('child_process').exec, + os = require('os'); + +// On Mac Os X / macports there's only the ossp-uuid package that provides uuid +// On Linux there's uuid-runtime which provides uuidgen +var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t'; + +function compare(ids) { + console.log(ids); + for (var i = 0; i < ids.length; i++) { + var id = ids[i].split('-'); + id = [id[2], id[1], id[0]].join(''); + ids[i] = id; + } + var sorted = ([].concat(ids)).sort(); + + if (sorted.toString() !== ids.toString()) { + console.log('Warning: sorted !== ids'); + } else { + console.log('everything in order!'); + } +} + +// Test time order of v1 uuids +var ids = []; +while (ids.length < 10e3) ids.push(nodeuuid.v1()); + +var max = 10; +console.log('node-uuid:'); +ids = []; +for (var i = 0; i < max; i++) ids.push(nodeuuid.v1()); +compare(ids); + +console.log(''); +console.log('uuidjs:'); +ids = []; +for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString()); +compare(ids); + +console.log(''); +console.log('libuuid:'); +ids = []; +var count = 0; +var last = function() { + compare(ids); +} +var cb = function(err, stdout, stderr) { + ids.push(stdout.substring(0, stdout.length-1)); + count++; + if (count < max) { + return next(); + } + last(); +}; +var next = function() { + exec(uuidCmd, cb); +}; +next(); diff --git a/wp8/node_modules/node-uuid/test/test.html b/wp8/node_modules/node-uuid/test/test.html new file mode 100644 index 00000000..d80326ec --- /dev/null +++ b/wp8/node_modules/node-uuid/test/test.html @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/wp8/node_modules/node-uuid/test/test.js b/wp8/node_modules/node-uuid/test/test.js new file mode 100644 index 00000000..24692256 --- /dev/null +++ b/wp8/node_modules/node-uuid/test/test.js @@ -0,0 +1,228 @@ +if (!this.uuid) { + // node.js + uuid = require('../uuid'); +} + +// +// x-platform log/assert shims +// + +function _log(msg, type) { + type = type || 'log'; + + if (typeof(document) != 'undefined') { + document.write('
' + msg.replace(/\n/g, '
') + '
'); + } + if (typeof(console) != 'undefined') { + var color = { + log: '\033[39m', + warn: '\033[33m', + error: '\033[31m' + }; + console[type](color[type] + msg + color.log); + } +} + +function log(msg) {_log(msg, 'log');} +function warn(msg) {_log(msg, 'warn');} +function error(msg) {_log(msg, 'error');} + +function assert(res, msg) { + if (!res) { + error('FAIL: ' + msg); + } else { + log('Pass: ' + msg); + } +} + +// +// Unit tests +// + +// Verify ordering of v1 ids created with explicit times +var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00 + +function compare(name, ids) { + ids = ids.map(function(id) { + return id.split('-').reverse().join('-'); + }).sort(); + var sorted = ([].concat(ids)).sort(); + + assert(sorted.toString() == ids.toString(), name + ' have expected order'); +} + +// Verify ordering of v1 ids created using default behavior +compare('uuids with current time', [ + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1(), + uuid.v1() +]); + +// Verify ordering of v1 ids created with explicit times +compare('uuids with time option', [ + uuid.v1({msecs: TIME - 10*3600*1000}), + uuid.v1({msecs: TIME - 1}), + uuid.v1({msecs: TIME}), + uuid.v1({msecs: TIME + 1}), + uuid.v1({msecs: TIME + 28*24*3600*1000}) +]); + +assert( + uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}), + 'IDs created at same msec are different' +); + +// Verify throw if too many ids created +var thrown = false; +try { + uuid.v1({msecs: TIME, nsecs: 10000}); +} catch (e) { + thrown = true; +} +assert(thrown, 'Exception thrown when > 10K ids created in 1 ms'); + +// Verify clock regression bumps clockseq +var uidt = uuid.v1({msecs: TIME}); +var uidtb = uuid.v1({msecs: TIME - 1}); +assert( + parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1, + 'Clock regression by msec increments the clockseq' +); + +// Verify clock regression bumps clockseq +var uidtn = uuid.v1({msecs: TIME, nsecs: 10}); +var uidtnb = uuid.v1({msecs: TIME, nsecs: 9}); +assert( + parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1, + 'Clock regression by nsec increments the clockseq' +); + +// Verify explicit options produce expected id +var id = uuid.v1({ + msecs: 1321651533573, + nsecs: 5432, + clockseq: 0x385c, + node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ] +}); +assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id'); + +// Verify adjacent ids across a msec boundary are 1 time unit apart +var u0 = uuid.v1({msecs: TIME, nsecs: 9999}); +var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0}); + +var before = u0.split('-')[0], after = u1.split('-')[0]; +var dt = parseInt(after, 16) - parseInt(before, 16); +assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart'); + +// +// Test parse/unparse +// + +id = '00112233445566778899aabbccddeeff'; +assert(uuid.unparse(uuid.parse(id.substr(0,10))) == + '00112233-4400-0000-0000-000000000000', 'Short parse'); +assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) == + '00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse'); + +// +// Perf tests +// + +var generators = { + v1: uuid.v1, + v4: uuid.v4 +}; + +var UUID_FORMAT = { + v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i, + v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i +}; + +var N = 1e4; + +// Get %'age an actual value differs from the ideal value +function divergence(actual, ideal) { + return Math.round(100*100*(actual - ideal)/ideal)/100; +} + +function rate(msg, t) { + log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second'); +} + +for (var version in generators) { + var counts = {}, max = 0; + var generator = generators[version]; + var format = UUID_FORMAT[version]; + + log('\nSanity check ' + N + ' ' + version + ' uuids'); + for (var i = 0, ok = 0; i < N; i++) { + id = generator(); + if (!format.test(id)) { + throw Error(id + ' is not a valid UUID string'); + } + + if (id != uuid.unparse(uuid.parse(id))) { + assert(fail, id + ' is not a valid id'); + } + + // Count digits for our randomness check + if (version == 'v4') { + var digits = id.replace(/-/g, '').split(''); + for (var j = digits.length-1; j >= 0; j--) { + var c = digits[j]; + max = Math.max(max, counts[c] = (counts[c] || 0) + 1); + } + } + } + + // Check randomness for v4 UUIDs + if (version == 'v4') { + // Limit that we get worried about randomness. (Purely empirical choice, this!) + var limit = 2*100*Math.sqrt(1/N); + + log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)'); + + for (var i = 0; i < 16; i++) { + var c = i.toString(16); + var bar = '', n = counts[c], p = Math.round(n/max*100|0); + + // 1-3,5-8, and D-F: 1:16 odds over 30 digits + var ideal = N*30/16; + if (i == 4) { + // 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1 + 30/16); + } else if (i >= 8 && i <= 11) { + // 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits + ideal = N*(1/4 + 30/16); + } else { + // Otherwise: 1:16 odds on 30 digits + ideal = N*30/16; + } + var d = divergence(n, ideal); + + // Draw bar using UTF squares (just for grins) + var s = n/max*50 | 0; + while (s--) bar += '='; + + assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)'); + } + } +} + +// Perf tests +for (var version in generators) { + log('\nPerformance testing ' + version + ' UUIDs'); + var generator = generators[version]; + var buf = new uuid.BufferClass(16); + + for (var i = 0, t = Date.now(); i < N; i++) generator(); + rate('uuid.' + version + '()', t); + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary'); + rate('uuid.' + version + '(\'binary\')', t); + + for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf); + rate('uuid.' + version + '(\'binary\', buffer)', t); +} diff --git a/wp8/node_modules/node-uuid/uuid.js b/wp8/node_modules/node-uuid/uuid.js new file mode 100644 index 00000000..2fac6dc4 --- /dev/null +++ b/wp8/node_modules/node-uuid/uuid.js @@ -0,0 +1,245 @@ +// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php + +(function() { + var _global = this; + + // Unique ID creation requires a high quality random # generator. We feature + // detect to determine the best RNG source, normalizing to a function that + // returns 128-bits of randomness, since that's what's usually required + var _rng; + + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html + // + // Moderately fast, high quality + if (typeof(require) == 'function') { + try { + var _rb = require('crypto').randomBytes; + _rng = _rb && function() {return _rb(16);}; + } catch(e) {} + } + + if (!_rng && _global.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + _rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; + } + + if (!_rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + _rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; + } + + // Buffer class to use + var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array; + + // Maps for number <-> hex string conversion + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } + + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; + } + + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; + } + + // **`v1()` - Generate time-based UUID** + // + // Inspired by https://github.com/LiosK/UUID.js + // and http://docs.python.org/library/uuid.html + + // random #'s we need to init node and clockseq + var _seedBytes = _rng(); + + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] + ]; + + // Per 4.2.2, randomize (14 bit) clockseq + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + + // Previous uuid creation time + var _lastMSecs = 0, _lastNSecs = 0; + + // See https://github.com/broofa/node-uuid for API details + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq != null ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs != null ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq == null) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); + } + + // **`v4()` - Generate random UUID** + + // See https://github.com/broofa/node-uuid for API details + function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new BufferClass(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); + } + + // Export public API + var uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + uuid.BufferClass = BufferClass; + + if (typeof define === 'function' && define.amd) { + // Publish as AMD module + define(function() {return uuid;}); + } else if (typeof(module) != 'undefined' && module.exports) { + // Publish as node.js module + module.exports = uuid; + } else { + // Publish as global (in browsers) + var _previousRoot = _global.uuid; + + // **`noConflict()` - (browser only) to reset global 'uuid' var** + uuid.noConflict = function() { + _global.uuid = _previousRoot; + return uuid; + }; + + _global.uuid = uuid; + } +}).call(this); diff --git a/wp8/node_modules/nopt/.npmignore b/wp8/node_modules/nopt/.npmignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/wp8/node_modules/nopt/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/wp8/node_modules/nopt/LICENSE b/wp8/node_modules/nopt/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/wp8/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. diff --git a/wp8/node_modules/nopt/README.md b/wp8/node_modules/nopt/README.md new file mode 100644 index 00000000..5aba088b --- /dev/null +++ b/wp8/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. diff --git a/wp8/node_modules/nopt/examples/my-program.js b/wp8/node_modules/nopt/examples/my-program.js new file mode 100644 index 00000000..142447e1 --- /dev/null +++ b/wp8/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)) diff --git a/wp8/node_modules/nopt/lib/nopt.js b/wp8/node_modules/nopt/lib/nopt.js new file mode 100644 index 00000000..5309a00f --- /dev/null +++ b/wp8/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] +} diff --git a/wp8/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md b/wp8/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md new file mode 100644 index 00000000..2f302612 --- /dev/null +++ b/wp8/node_modules/nopt/node_modules/abbrev/CONTRIBUTING.md @@ -0,0 +1,3 @@ + To get started, sign the + Contributor License Agreement. diff --git a/wp8/node_modules/nopt/node_modules/abbrev/LICENSE b/wp8/node_modules/nopt/node_modules/abbrev/LICENSE new file mode 100644 index 00000000..05a40109 --- /dev/null +++ b/wp8/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. diff --git a/wp8/node_modules/nopt/node_modules/abbrev/README.md b/wp8/node_modules/nopt/node_modules/abbrev/README.md new file mode 100644 index 00000000..99746fe6 --- /dev/null +++ b/wp8/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. diff --git a/wp8/node_modules/nopt/node_modules/abbrev/abbrev.js b/wp8/node_modules/nopt/node_modules/abbrev/abbrev.js new file mode 100644 index 00000000..69cfeac5 --- /dev/null +++ b/wp8/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 +} diff --git a/wp8/node_modules/nopt/node_modules/abbrev/package.json b/wp8/node_modules/nopt/node_modules/abbrev/package.json new file mode 100644 index 00000000..b1890206 --- /dev/null +++ b/wp8/node_modules/nopt/node_modules/abbrev/package.json @@ -0,0 +1,29 @@ +{ + "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", + "_from": "abbrev@1" +} diff --git a/wp8/node_modules/nopt/node_modules/abbrev/test.js b/wp8/node_modules/nopt/node_modules/abbrev/test.js new file mode 100644 index 00000000..d5a7303e --- /dev/null +++ b/wp8/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) diff --git a/wp8/node_modules/nopt/package.json b/wp8/node_modules/nopt/package.json new file mode 100644 index 00000000..85bafefa --- /dev/null +++ b/wp8/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\").Stream\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 support 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 one 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 boolean 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@~3", + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.1.tgz" +} diff --git a/wp8/node_modules/nopt/test/basic.js b/wp8/node_modules/nopt/test/basic.js new file mode 100644 index 00000000..2f9088cf --- /dev/null +++ b/wp8/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() +}) diff --git a/wp8/node_modules/q/CONTRIBUTING.md b/wp8/node_modules/q/CONTRIBUTING.md new file mode 100644 index 00000000..500ab17b --- /dev/null +++ b/wp8/node_modules/q/CONTRIBUTING.md @@ -0,0 +1,40 @@ + +For pull requests: + +- Be consistent with prevalent style and design decisions. +- Add a Jasmine spec to `specs/q-spec.js`. +- Use `npm test` to avoid regressions. +- Run tests in `q-spec/run.html` in as many supported browsers as you + can find the will to deal with. +- Do not build minified versions; we do this each release. +- If you would be so kind, add a note to `CHANGES.md` in an + appropriate section: + + - `Next Major Version` if it introduces backward incompatibilities + to code in the wild using documented features. + - `Next Minor Version` if it adds a new feature. + - `Next Patch Version` if it fixes a bug. + +For releases: + +- Run `npm test`. +- Run tests in `q-spec/run.html` in a representative sample of every + browser under the sun. +- Run `npm run cover` and make sure you're happy with the results. +- Run `npm run minify` and be sure to commit the resulting `q.min.js`. +- Note the Gzipped size output by the previous command, and update + `README.md` if it has changed to 1 significant digit. +- Stash any local changes. +- Update `CHANGES.md` to reflect all changes in the differences + between `HEAD` and the previous tagged version. Give credit where + credit is due. +- Update `README.md` to address all new, non-experimental features. +- Update the API reference on the Wiki to reflect all non-experimental + features. +- Use `npm version major|minor|patch` to update `package.json`, + commit, and tag the new version. +- Use `npm publish` to send up a new release. +- Send an email to the q-continuum mailing list announcing the new + release and the notes from the change log. This helps folks + maintaining other package ecosystems. + diff --git a/wp8/node_modules/q/LICENSE b/wp8/node_modules/q/LICENSE new file mode 100644 index 00000000..8a706b59 --- /dev/null +++ b/wp8/node_modules/q/LICENSE @@ -0,0 +1,18 @@ +Copyright 2009–2014 Kristopher Michael Kowal. 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. diff --git a/wp8/node_modules/q/README.md b/wp8/node_modules/q/README.md new file mode 100644 index 00000000..bdd4168c --- /dev/null +++ b/wp8/node_modules/q/README.md @@ -0,0 +1,820 @@ +[![Build Status](https://secure.travis-ci.org/kriskowal/q.png?branch=master)](http://travis-ci.org/kriskowal/q) + + + Promises/A+ logo + + +*This is Q version 1, from the `v1` branch in Git. This documentation applies to +the latest of both the version 1 and version 0.9 release trains. These releases +are stable. There will be no further releases of 0.9 after 0.9.7 which is nearly +equivalent to version 1.0.0. All further releases of `q@~1.0` will be backward +compatible. The version 2 release train introduces significant but +backward-incompatible changes and is experimental at this time.* + +If a function cannot return a value or throw an exception without +blocking, it can return a promise instead. A promise is an object +that represents the return value or the thrown exception that the +function may eventually provide. A promise can also be used as a +proxy for a [remote object][Q-Connection] to overcome latency. + +[Q-Connection]: https://github.com/kriskowal/q-connection + +On the first pass, promises can mitigate the “[Pyramid of +Doom][POD]”: the situation where code marches to the right faster +than it marches forward. + +[POD]: http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/ + +```javascript +step1(function (value1) { + step2(value1, function(value2) { + step3(value2, function(value3) { + step4(value3, function(value4) { + // Do something with value4 + }); + }); + }); +}); +``` + +With a promise library, you can flatten the pyramid. + +```javascript +Q.fcall(promisedStep1) +.then(promisedStep2) +.then(promisedStep3) +.then(promisedStep4) +.then(function (value4) { + // Do something with value4 +}) +.catch(function (error) { + // Handle any error from all above steps +}) +.done(); +``` + +With this approach, you also get implicit error propagation, just like `try`, +`catch`, and `finally`. An error in `promisedStep1` will flow all the way to +the `catch` function, where it’s caught and handled. (Here `promisedStepN` is +a version of `stepN` that returns a promise.) + +The callback approach is called an “inversion of control”. +A function that accepts a callback instead of a return value +is saying, “Don’t call me, I’ll call you.”. Promises +[un-invert][IOC] the inversion, cleanly separating the input +arguments from control flow arguments. This simplifies the +use and creation of API’s, particularly variadic, +rest and spread arguments. + +[IOC]: http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript + + +## Getting Started + +The Q module can be loaded as: + +- A ``