@corellium/corellium-cli 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.gitlab-ci.yml +17 -3
- package/coverage/cobertura-coverage.xml +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/node_modules/@babel/cli/LICENSE +22 -0
- package/node_modules/@babel/cli/README.md +19 -0
- package/node_modules/@babel/cli/bin/babel-external-helpers.js +3 -0
- package/node_modules/@babel/cli/bin/babel.js +3 -0
- package/node_modules/@babel/cli/index.js +1 -0
- package/node_modules/@babel/cli/lib/babel/dir.js +285 -0
- package/node_modules/@babel/cli/lib/babel/file.js +273 -0
- package/node_modules/@babel/cli/lib/babel/index.js +20 -0
- package/node_modules/@babel/cli/lib/babel/options.js +285 -0
- package/node_modules/@babel/cli/lib/babel/util.js +181 -0
- package/node_modules/@babel/cli/lib/babel/watcher.js +162 -0
- package/node_modules/@babel/cli/lib/babel-external-helpers.js +43 -0
- package/node_modules/@babel/cli/node_modules/commander/CHANGELOG.md +436 -0
- package/node_modules/@babel/cli/node_modules/commander/LICENSE +22 -0
- package/node_modules/@babel/cli/node_modules/commander/Readme.md +713 -0
- package/node_modules/@babel/cli/node_modules/commander/index.js +1649 -0
- package/node_modules/@babel/cli/node_modules/commander/package.json +41 -0
- package/node_modules/@babel/cli/node_modules/commander/typings/index.d.ts +311 -0
- package/node_modules/@babel/cli/node_modules/make-dir/index.d.ts +39 -0
- package/node_modules/@babel/cli/node_modules/make-dir/index.js +139 -0
- package/node_modules/@babel/cli/node_modules/make-dir/license +9 -0
- package/node_modules/@babel/cli/node_modules/make-dir/package.json +59 -0
- package/node_modules/@babel/cli/node_modules/make-dir/readme.md +123 -0
- package/node_modules/@babel/cli/node_modules/pify/index.js +68 -0
- package/node_modules/@babel/cli/node_modules/pify/license +9 -0
- package/node_modules/@babel/cli/node_modules/pify/package.json +51 -0
- package/node_modules/@babel/cli/node_modules/pify/readme.md +145 -0
- package/node_modules/@babel/cli/node_modules/semver/CHANGELOG.md +39 -0
- package/node_modules/@babel/cli/node_modules/semver/LICENSE +15 -0
- package/node_modules/@babel/cli/node_modules/semver/README.md +412 -0
- package/node_modules/@babel/cli/node_modules/semver/bin/semver +160 -0
- package/node_modules/@babel/cli/node_modules/semver/package.json +28 -0
- package/node_modules/@babel/cli/node_modules/semver/range.bnf +16 -0
- package/node_modules/@babel/cli/node_modules/semver/semver.js +1483 -0
- package/node_modules/@babel/cli/node_modules/slash/index.js +11 -0
- package/node_modules/@babel/cli/node_modules/slash/license +9 -0
- package/node_modules/@babel/cli/node_modules/slash/package.json +34 -0
- package/node_modules/@babel/cli/node_modules/slash/readme.md +44 -0
- package/node_modules/@babel/cli/package.json +55 -0
- package/node_modules/@corellium/client-api/README.md +209 -0
- package/node_modules/@corellium/client-api/dist/ApiClient.js +780 -0
- package/node_modules/@corellium/client-api/dist/api/CorelliumApi.js +1744 -0
- package/node_modules/@corellium/client-api/dist/index.js +295 -0
- package/node_modules/@corellium/client-api/dist/model/ApiConflictError.js +114 -0
- package/node_modules/@corellium/client-api/dist/model/ApiError.js +101 -0
- package/node_modules/@corellium/client-api/dist/model/ApiNotFoundError.js +111 -0
- package/node_modules/@corellium/client-api/dist/model/ApiToken.js +78 -0
- package/node_modules/@corellium/client-api/dist/model/Bit.js +50 -0
- package/node_modules/@corellium/client-api/dist/model/Credentials.js +91 -0
- package/node_modules/@corellium/client-api/dist/model/Firmware.js +208 -0
- package/node_modules/@corellium/client-api/dist/model/GpioStateDefinition.js +93 -0
- package/node_modules/@corellium/client-api/dist/model/Image.js +249 -0
- package/node_modules/@corellium/client-api/dist/model/Instance.js +313 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceBootOptions.js +134 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceConsoleEndpoint.js +76 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceCreateOptions.js +224 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceNetmonState.js +75 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceReturn.js +92 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceServices.js +77 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceStartOptions.js +76 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceState.js +64 -0
- package/node_modules/@corellium/client-api/dist/model/InstanceStopOptions.js +76 -0
- package/node_modules/@corellium/client-api/dist/model/Model.js +165 -0
- package/node_modules/@corellium/client-api/dist/model/ModelSoftware.js +122 -0
- package/node_modules/@corellium/client-api/dist/model/PeripheralsData.js +147 -0
- package/node_modules/@corellium/client-api/dist/model/Project.js +122 -0
- package/node_modules/@corellium/client-api/dist/model/ProjectQuota.js +93 -0
- package/node_modules/@corellium/client-api/dist/model/ProjectSettings.js +93 -0
- package/node_modules/@corellium/client-api/dist/model/ProjectUsage.js +102 -0
- package/node_modules/@corellium/client-api/dist/model/Snapshot.js +145 -0
- package/node_modules/@corellium/client-api/dist/model/SnapshotCreationOptions.js +79 -0
- package/node_modules/@corellium/client-api/dist/model/SnapshotStatus.js +84 -0
- package/node_modules/@corellium/client-api/dist/model/Token.js +88 -0
- package/node_modules/@corellium/client-api/dist/model/UserError.js +114 -0
- package/node_modules/@corellium/client-api/dist/model/V1SetStateBody.js +80 -0
- package/node_modules/@corellium/client-api/dist/model/VolumeOptions.js +94 -0
- package/node_modules/@corellium/client-api/dist/model/VpnDefinition.js +84 -0
- package/node_modules/@corellium/client-api/package.json +46 -0
- package/node_modules/@jridgewell/resolve-uri/LICENSE +19 -0
- package/node_modules/@jridgewell/resolve-uri/README.md +40 -0
- package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs +242 -0
- package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs.map +1 -0
- package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js +250 -0
- package/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js.map +1 -0
- package/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts +4 -0
- package/node_modules/@jridgewell/resolve-uri/package.json +69 -0
- package/node_modules/@jridgewell/sourcemap-codec/LICENSE +21 -0
- package/node_modules/@jridgewell/sourcemap-codec/README.md +200 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +164 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +175 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +6 -0
- package/node_modules/@jridgewell/sourcemap-codec/package.json +75 -0
- package/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +198 -0
- package/node_modules/@jridgewell/trace-mapping/LICENSE +19 -0
- package/node_modules/@jridgewell/trace-mapping/README.md +252 -0
- package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +552 -0
- package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs.map +1 -0
- package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js +566 -0
- package/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js.map +1 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts +8 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/binary-search.d.ts +32 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/by-source.d.ts +7 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/resolve.d.ts +1 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/sort.d.ts +2 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/strip-filename.d.ts +4 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/node_modules/@jridgewell/trace-mapping/package.json +75 -0
- package/node_modules/@nicolo-ribaudo/chokidar-2/README.md +3 -0
- package/node_modules/@nicolo-ribaudo/chokidar-2/build-chokidar.sh +30 -0
- package/node_modules/@nicolo-ribaudo/chokidar-2/dist/main.js +2086 -0
- package/node_modules/@nicolo-ribaudo/chokidar-2/package.json +36 -0
- package/node_modules/@nicolo-ribaudo/chokidar-2/types.d.ts +191 -0
- package/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/anymatch/LICENSE +15 -0
- package/node_modules/anymatch/README.md +87 -0
- package/node_modules/anymatch/index.d.ts +19 -0
- package/node_modules/anymatch/index.js +104 -0
- package/node_modules/anymatch/package.json +48 -0
- package/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +63 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/axios/CHANGELOG.md +943 -0
- package/node_modules/axios/LICENSE +19 -0
- package/node_modules/axios/README.md +991 -0
- package/node_modules/axios/SECURITY.md +5 -0
- package/node_modules/axios/UPGRADE_GUIDE.md +168 -0
- package/node_modules/axios/dist/axios.js +2595 -0
- package/node_modules/axios/dist/axios.map +1 -0
- package/node_modules/axios/dist/axios.min.js +3 -0
- package/node_modules/axios/dist/axios.min.map +1 -0
- package/node_modules/axios/index.d.ts +254 -0
- package/node_modules/axios/index.js +1 -0
- package/node_modules/axios/lib/adapters/README.md +37 -0
- package/node_modules/axios/lib/adapters/http.js +424 -0
- package/node_modules/axios/lib/adapters/xhr.js +222 -0
- package/node_modules/axios/lib/axios.js +64 -0
- package/node_modules/axios/lib/cancel/CancelToken.js +119 -0
- package/node_modules/axios/lib/cancel/CanceledError.js +22 -0
- package/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/axios/lib/core/Axios.js +160 -0
- package/node_modules/axios/lib/core/AxiosError.js +86 -0
- package/node_modules/axios/lib/core/InterceptorManager.js +54 -0
- package/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/axios/lib/core/buildFullPath.js +20 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +87 -0
- package/node_modules/axios/lib/core/mergeConfig.js +100 -0
- package/node_modules/axios/lib/core/settle.js +25 -0
- package/node_modules/axios/lib/core/transformData.js +22 -0
- package/node_modules/axios/lib/defaults/env/FormData.js +2 -0
- package/node_modules/axios/lib/defaults/index.js +146 -0
- package/node_modules/axios/lib/defaults/transitional.js +7 -0
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/data.js +3 -0
- package/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/axios/lib/helpers/bind.js +11 -0
- package/node_modules/axios/lib/helpers/buildURL.js +70 -0
- package/node_modules/axios/lib/helpers/combineURLs.js +14 -0
- package/node_modules/axios/lib/helpers/cookies.js +53 -0
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/node_modules/axios/lib/helpers/isAxiosError.js +13 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/node_modules/axios/lib/helpers/null.js +2 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
- package/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/node_modules/axios/lib/helpers/spread.js +27 -0
- package/node_modules/axios/lib/helpers/toFormData.js +72 -0
- package/node_modules/axios/lib/helpers/validator.js +86 -0
- package/node_modules/axios/lib/utils.js +470 -0
- package/node_modules/axios/package.json +87 -0
- package/node_modules/axios/tsconfig.json +14 -0
- package/node_modules/axios/tslint.json +6 -0
- package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- package/node_modules/balanced-match/LICENSE.md +21 -0
- package/node_modules/balanced-match/README.md +97 -0
- package/node_modules/balanced-match/index.js +62 -0
- package/node_modules/balanced-match/package.json +48 -0
- package/node_modules/binary-extensions/binary-extensions.json +260 -0
- package/node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
- package/node_modules/binary-extensions/index.d.ts +14 -0
- package/node_modules/binary-extensions/index.js +1 -0
- package/node_modules/binary-extensions/license +9 -0
- package/node_modules/binary-extensions/package.json +38 -0
- package/node_modules/binary-extensions/readme.md +41 -0
- package/node_modules/brace-expansion/LICENSE +21 -0
- package/node_modules/brace-expansion/README.md +129 -0
- package/node_modules/brace-expansion/index.js +201 -0
- package/node_modules/brace-expansion/package.json +47 -0
- package/node_modules/braces/CHANGELOG.md +184 -0
- package/node_modules/braces/LICENSE +21 -0
- package/node_modules/braces/README.md +593 -0
- package/node_modules/braces/index.js +170 -0
- package/node_modules/braces/lib/compile.js +57 -0
- package/node_modules/braces/lib/constants.js +57 -0
- package/node_modules/braces/lib/expand.js +113 -0
- package/node_modules/braces/lib/parse.js +333 -0
- package/node_modules/braces/lib/stringify.js +32 -0
- package/node_modules/braces/lib/utils.js +112 -0
- package/node_modules/braces/package.json +77 -0
- package/node_modules/call-bind/.eslintignore +1 -0
- package/node_modules/call-bind/.eslintrc +17 -0
- package/node_modules/call-bind/.github/FUNDING.yml +12 -0
- package/node_modules/call-bind/.nycrc +13 -0
- package/node_modules/call-bind/CHANGELOG.md +42 -0
- package/node_modules/call-bind/LICENSE +21 -0
- package/node_modules/call-bind/README.md +2 -0
- package/node_modules/call-bind/callBound.js +15 -0
- package/node_modules/call-bind/index.js +47 -0
- package/node_modules/call-bind/package.json +80 -0
- package/node_modules/call-bind/test/callBound.js +55 -0
- package/node_modules/call-bind/test/index.js +66 -0
- package/node_modules/chokidar/LICENSE +21 -0
- package/node_modules/chokidar/README.md +308 -0
- package/node_modules/chokidar/index.js +973 -0
- package/node_modules/chokidar/lib/constants.js +65 -0
- package/node_modules/chokidar/lib/fsevents-handler.js +524 -0
- package/node_modules/chokidar/lib/nodefs-handler.js +654 -0
- package/node_modules/chokidar/package.json +85 -0
- package/node_modules/chokidar/types/index.d.ts +188 -0
- package/node_modules/cliui/CHANGELOG.md +121 -0
- package/node_modules/cliui/LICENSE.txt +14 -0
- package/node_modules/cliui/README.md +141 -0
- package/node_modules/cliui/build/index.cjs +302 -0
- package/node_modules/cliui/build/lib/index.js +287 -0
- package/node_modules/cliui/build/lib/string-utils.js +27 -0
- package/node_modules/cliui/index.mjs +13 -0
- package/node_modules/cliui/package.json +83 -0
- package/node_modules/color-convert/CHANGELOG.md +54 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/combined-stream/License +19 -0
- package/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/combined-stream/package.json +25 -0
- package/node_modules/combined-stream/yarn.lock +17 -0
- package/node_modules/component-emitter/History.md +75 -0
- package/node_modules/component-emitter/LICENSE +24 -0
- package/node_modules/component-emitter/Readme.md +74 -0
- package/node_modules/component-emitter/index.js +175 -0
- package/node_modules/component-emitter/package.json +27 -0
- package/node_modules/concat-map/.travis.yml +4 -0
- package/node_modules/concat-map/LICENSE +18 -0
- package/node_modules/concat-map/README.markdown +62 -0
- package/node_modules/concat-map/example/map.js +6 -0
- package/node_modules/concat-map/index.js +13 -0
- package/node_modules/concat-map/package.json +43 -0
- package/node_modules/concat-map/test/map.js +39 -0
- package/node_modules/convert-source-map/LICENSE +23 -0
- package/node_modules/convert-source-map/README.md +120 -0
- package/node_modules/convert-source-map/index.js +136 -0
- package/node_modules/convert-source-map/package.json +44 -0
- package/node_modules/cookiejar/LICENSE +9 -0
- package/node_modules/cookiejar/cookiejar.js +276 -0
- package/node_modules/cookiejar/package.json +26 -0
- package/node_modules/cookiejar/readme.md +60 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +59 -0
- package/node_modules/debug/src/browser.js +269 -0
- package/node_modules/debug/src/common.js +274 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/delayed-stream/License +19 -0
- package/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/delayed-stream/package.json +27 -0
- package/node_modules/dotenv/CHANGELOG.md +356 -0
- package/node_modules/dotenv/LICENSE +23 -0
- package/node_modules/dotenv/README.md +408 -0
- package/node_modules/dotenv/config.d.ts +1 -0
- package/node_modules/dotenv/config.js +9 -0
- package/node_modules/dotenv/lib/cli-options.js +11 -0
- package/node_modules/dotenv/lib/env-options.js +20 -0
- package/node_modules/dotenv/lib/main.d.ts +73 -0
- package/node_modules/dotenv/lib/main.js +109 -0
- package/node_modules/dotenv/package.json +56 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/escalade/dist/index.js +22 -0
- package/node_modules/escalade/dist/index.mjs +22 -0
- package/node_modules/escalade/index.d.ts +3 -0
- package/node_modules/escalade/license +9 -0
- package/node_modules/escalade/package.json +61 -0
- package/node_modules/escalade/readme.md +211 -0
- package/node_modules/escalade/sync/index.d.ts +2 -0
- package/node_modules/escalade/sync/index.js +18 -0
- package/node_modules/escalade/sync/index.mjs +18 -0
- package/node_modules/fast-safe-stringify/.travis.yml +8 -0
- package/node_modules/fast-safe-stringify/CHANGELOG.md +17 -0
- package/node_modules/fast-safe-stringify/LICENSE +23 -0
- package/node_modules/fast-safe-stringify/benchmark.js +137 -0
- package/node_modules/fast-safe-stringify/index.d.ts +23 -0
- package/node_modules/fast-safe-stringify/index.js +229 -0
- package/node_modules/fast-safe-stringify/package.json +46 -0
- package/node_modules/fast-safe-stringify/readme.md +170 -0
- package/node_modules/fast-safe-stringify/test-stable.js +404 -0
- package/node_modules/fast-safe-stringify/test.js +397 -0
- package/node_modules/fill-range/LICENSE +21 -0
- package/node_modules/fill-range/README.md +237 -0
- package/node_modules/fill-range/index.js +249 -0
- package/node_modules/fill-range/package.json +69 -0
- package/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/follow-redirects/README.md +155 -0
- package/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/follow-redirects/index.js +598 -0
- package/node_modules/follow-redirects/package.json +59 -0
- package/node_modules/form-data/License +19 -0
- package/node_modules/form-data/README.md.bak +358 -0
- package/node_modules/form-data/Readme.md +358 -0
- package/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/form-data/lib/browser.js +2 -0
- package/node_modules/form-data/lib/form_data.js +501 -0
- package/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/form-data/package.json +68 -0
- package/node_modules/formidable/LICENSE +7 -0
- package/node_modules/formidable/Readme.md +448 -0
- package/node_modules/formidable/lib/file.js +81 -0
- package/node_modules/formidable/lib/incoming_form.js +564 -0
- package/node_modules/formidable/lib/index.js +3 -0
- package/node_modules/formidable/lib/json_parser.js +30 -0
- package/node_modules/formidable/lib/multipart_parser.js +332 -0
- package/node_modules/formidable/lib/octet_parser.js +20 -0
- package/node_modules/formidable/lib/querystring_parser.js +27 -0
- package/node_modules/formidable/package.json +29 -0
- package/node_modules/fs-readdir-recursive/LICENSE +22 -0
- package/node_modules/fs-readdir-recursive/README.md +61 -0
- package/node_modules/fs-readdir-recursive/index.js +29 -0
- package/node_modules/fs-readdir-recursive/package.json +26 -0
- package/node_modules/fs.realpath/LICENSE +43 -0
- package/node_modules/fs.realpath/README.md +33 -0
- package/node_modules/fs.realpath/index.js +66 -0
- package/node_modules/fs.realpath/old.js +303 -0
- package/node_modules/fs.realpath/package.json +26 -0
- package/node_modules/function-bind/.editorconfig +20 -0
- package/node_modules/function-bind/.eslintrc +15 -0
- package/node_modules/function-bind/.jscs.json +176 -0
- package/node_modules/function-bind/.npmignore +22 -0
- package/node_modules/function-bind/.travis.yml +168 -0
- package/node_modules/function-bind/LICENSE +20 -0
- package/node_modules/function-bind/README.md +48 -0
- package/node_modules/function-bind/implementation.js +52 -0
- package/node_modules/function-bind/index.js +5 -0
- package/node_modules/function-bind/package.json +63 -0
- package/node_modules/function-bind/test/.eslintrc +9 -0
- package/node_modules/function-bind/test/index.js +252 -0
- package/node_modules/get-caller-file/LICENSE.md +6 -0
- package/node_modules/get-caller-file/README.md +41 -0
- package/node_modules/get-caller-file/index.d.ts +2 -0
- package/node_modules/get-caller-file/index.js +22 -0
- package/node_modules/get-caller-file/index.js.map +1 -0
- package/node_modules/get-caller-file/package.json +42 -0
- package/node_modules/get-intrinsic/.eslintrc +37 -0
- package/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/node_modules/get-intrinsic/.nycrc +9 -0
- package/node_modules/get-intrinsic/CHANGELOG.md +91 -0
- package/node_modules/get-intrinsic/LICENSE +21 -0
- package/node_modules/get-intrinsic/README.md +71 -0
- package/node_modules/get-intrinsic/index.js +334 -0
- package/node_modules/get-intrinsic/package.json +88 -0
- package/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/node_modules/glob/LICENSE +21 -0
- package/node_modules/glob/README.md +378 -0
- package/node_modules/glob/common.js +238 -0
- package/node_modules/glob/glob.js +790 -0
- package/node_modules/glob/package.json +55 -0
- package/node_modules/glob/sync.js +486 -0
- package/node_modules/glob-parent/CHANGELOG.md +110 -0
- package/node_modules/glob-parent/LICENSE +15 -0
- package/node_modules/glob-parent/README.md +137 -0
- package/node_modules/glob-parent/index.js +42 -0
- package/node_modules/glob-parent/package.json +48 -0
- package/node_modules/has/LICENSE-MIT +22 -0
- package/node_modules/has/README.md +18 -0
- package/node_modules/has/package.json +48 -0
- package/node_modules/has/src/index.js +5 -0
- package/node_modules/has/test/index.js +10 -0
- package/node_modules/has-symbols/.eslintrc +11 -0
- package/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/node_modules/has-symbols/.nycrc +9 -0
- package/node_modules/has-symbols/CHANGELOG.md +75 -0
- package/node_modules/has-symbols/LICENSE +21 -0
- package/node_modules/has-symbols/README.md +46 -0
- package/node_modules/has-symbols/index.js +13 -0
- package/node_modules/has-symbols/package.json +101 -0
- package/node_modules/has-symbols/shams.js +42 -0
- package/node_modules/has-symbols/test/index.js +22 -0
- package/node_modules/has-symbols/test/shams/core-js.js +28 -0
- package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +28 -0
- package/node_modules/has-symbols/test/tests.js +56 -0
- package/node_modules/inflight/LICENSE +15 -0
- package/node_modules/inflight/README.md +37 -0
- package/node_modules/inflight/inflight.js +54 -0
- package/node_modules/inflight/package.json +29 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/is-binary-path/index.d.ts +17 -0
- package/node_modules/is-binary-path/index.js +7 -0
- package/node_modules/is-binary-path/license +9 -0
- package/node_modules/is-binary-path/package.json +40 -0
- package/node_modules/is-binary-path/readme.md +34 -0
- package/node_modules/is-extglob/LICENSE +21 -0
- package/node_modules/is-extglob/README.md +107 -0
- package/node_modules/is-extglob/index.js +20 -0
- package/node_modules/is-extglob/package.json +69 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/is-glob/LICENSE +21 -0
- package/node_modules/is-glob/README.md +206 -0
- package/node_modules/is-glob/index.js +150 -0
- package/node_modules/is-glob/package.json +81 -0
- package/node_modules/is-number/LICENSE +21 -0
- package/node_modules/is-number/README.md +187 -0
- package/node_modules/is-number/index.js +18 -0
- package/node_modules/is-number/package.json +82 -0
- package/node_modules/lru-cache/LICENSE +15 -0
- package/node_modules/lru-cache/README.md +166 -0
- package/node_modules/lru-cache/index.js +334 -0
- package/node_modules/lru-cache/package.json +34 -0
- package/node_modules/methods/HISTORY.md +29 -0
- package/node_modules/methods/LICENSE +24 -0
- package/node_modules/methods/README.md +51 -0
- package/node_modules/methods/index.js +69 -0
- package/node_modules/methods/package.json +36 -0
- package/node_modules/mime/CHANGELOG.md +296 -0
- package/node_modules/mime/LICENSE +21 -0
- package/node_modules/mime/Mime.js +97 -0
- package/node_modules/mime/README.md +187 -0
- package/node_modules/mime/cli.js +46 -0
- package/node_modules/mime/index.js +4 -0
- package/node_modules/mime/lite.js +4 -0
- package/node_modules/mime/package.json +52 -0
- package/node_modules/mime/types/other.js +1 -0
- package/node_modules/mime/types/standard.js +1 -0
- package/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-db/db.json +8519 -0
- package/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-db/package.json +60 -0
- package/node_modules/mime-types/HISTORY.md +397 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +113 -0
- package/node_modules/mime-types/index.js +188 -0
- package/node_modules/mime-types/package.json +44 -0
- package/node_modules/minimatch/LICENSE +15 -0
- package/node_modules/minimatch/README.md +230 -0
- package/node_modules/minimatch/minimatch.js +947 -0
- package/node_modules/minimatch/package.json +33 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +37 -0
- package/node_modules/ms/readme.md +60 -0
- package/node_modules/multi-progress/.gitattributes +17 -0
- package/node_modules/multi-progress/CHANGELOG.md +56 -0
- package/node_modules/multi-progress/LICENSE.txt +21 -0
- package/node_modules/multi-progress/multi-progress.js +98 -0
- package/node_modules/multi-progress/package.json +28 -0
- package/node_modules/multi-progress/readme.md +33 -0
- package/node_modules/normalize-path/LICENSE +21 -0
- package/node_modules/normalize-path/README.md +127 -0
- package/node_modules/normalize-path/index.js +35 -0
- package/node_modules/normalize-path/package.json +77 -0
- package/node_modules/object-inspect/.eslintrc +53 -0
- package/node_modules/object-inspect/.github/FUNDING.yml +12 -0
- package/node_modules/object-inspect/.nycrc +13 -0
- package/node_modules/object-inspect/CHANGELOG.md +360 -0
- package/node_modules/object-inspect/LICENSE +21 -0
- package/node_modules/object-inspect/example/all.js +23 -0
- package/node_modules/object-inspect/example/circular.js +6 -0
- package/node_modules/object-inspect/example/fn.js +5 -0
- package/node_modules/object-inspect/example/inspect.js +10 -0
- package/node_modules/object-inspect/index.js +512 -0
- package/node_modules/object-inspect/package-support.json +20 -0
- package/node_modules/object-inspect/package.json +94 -0
- package/node_modules/object-inspect/readme.markdown +86 -0
- package/node_modules/object-inspect/test/bigint.js +58 -0
- package/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/node_modules/object-inspect/test/circular.js +16 -0
- package/node_modules/object-inspect/test/deep.js +12 -0
- package/node_modules/object-inspect/test/element.js +53 -0
- package/node_modules/object-inspect/test/err.js +48 -0
- package/node_modules/object-inspect/test/fakes.js +29 -0
- package/node_modules/object-inspect/test/fn.js +76 -0
- package/node_modules/object-inspect/test/has.js +15 -0
- package/node_modules/object-inspect/test/holes.js +15 -0
- package/node_modules/object-inspect/test/indent-option.js +271 -0
- package/node_modules/object-inspect/test/inspect.js +139 -0
- package/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/node_modules/object-inspect/test/number.js +58 -0
- package/node_modules/object-inspect/test/quoteStyle.js +17 -0
- package/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/node_modules/object-inspect/test/undef.js +12 -0
- package/node_modules/object-inspect/test/values.js +211 -0
- package/node_modules/object-inspect/test-core-js.js +26 -0
- package/node_modules/object-inspect/util.inspect.js +1 -0
- package/node_modules/once/LICENSE +15 -0
- package/node_modules/once/README.md +79 -0
- package/node_modules/once/once.js +42 -0
- package/node_modules/once/package.json +33 -0
- package/node_modules/path-is-absolute/index.js +20 -0
- package/node_modules/path-is-absolute/license +21 -0
- package/node_modules/path-is-absolute/package.json +43 -0
- package/node_modules/path-is-absolute/readme.md +59 -0
- package/node_modules/picomatch/CHANGELOG.md +136 -0
- package/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/picomatch/README.md +708 -0
- package/node_modules/picomatch/index.js +3 -0
- package/node_modules/picomatch/lib/constants.js +179 -0
- package/node_modules/picomatch/lib/parse.js +1091 -0
- package/node_modules/picomatch/lib/picomatch.js +342 -0
- package/node_modules/picomatch/lib/scan.js +391 -0
- package/node_modules/picomatch/lib/utils.js +64 -0
- package/node_modules/picomatch/package.json +81 -0
- package/node_modules/progress/CHANGELOG.md +115 -0
- package/node_modules/progress/LICENSE +22 -0
- package/node_modules/progress/Makefile +8 -0
- package/node_modules/progress/Readme.md +146 -0
- package/node_modules/progress/index.js +1 -0
- package/node_modules/progress/lib/node-progress.js +236 -0
- package/node_modules/progress/package.json +26 -0
- package/node_modules/qs/.editorconfig +43 -0
- package/node_modules/qs/.eslintrc +38 -0
- package/node_modules/qs/.github/FUNDING.yml +12 -0
- package/node_modules/qs/.nycrc +13 -0
- package/node_modules/qs/CHANGELOG.md +546 -0
- package/node_modules/qs/LICENSE.md +29 -0
- package/node_modules/qs/README.md +625 -0
- package/node_modules/qs/dist/qs.js +2054 -0
- package/node_modules/qs/lib/formats.js +23 -0
- package/node_modules/qs/lib/index.js +11 -0
- package/node_modules/qs/lib/parse.js +263 -0
- package/node_modules/qs/lib/stringify.js +326 -0
- package/node_modules/qs/lib/utils.js +252 -0
- package/node_modules/qs/package.json +77 -0
- package/node_modules/qs/test/parse.js +855 -0
- package/node_modules/qs/test/stringify.js +909 -0
- package/node_modules/qs/test/utils.js +136 -0
- package/node_modules/readdirp/LICENSE +21 -0
- package/node_modules/readdirp/README.md +122 -0
- package/node_modules/readdirp/index.d.ts +43 -0
- package/node_modules/readdirp/index.js +287 -0
- package/node_modules/readdirp/package.json +122 -0
- package/node_modules/require-directory/.jshintrc +67 -0
- package/node_modules/require-directory/.npmignore +1 -0
- package/node_modules/require-directory/.travis.yml +3 -0
- package/node_modules/require-directory/LICENSE +22 -0
- package/node_modules/require-directory/README.markdown +184 -0
- package/node_modules/require-directory/index.js +86 -0
- package/node_modules/require-directory/package.json +40 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +568 -0
- package/node_modules/semver/bin/semver.js +183 -0
- package/node_modules/semver/classes/comparator.js +136 -0
- package/node_modules/semver/classes/index.js +5 -0
- package/node_modules/semver/classes/range.js +519 -0
- package/node_modules/semver/classes/semver.js +287 -0
- package/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/semver/functions/cmp.js +52 -0
- package/node_modules/semver/functions/coerce.js +52 -0
- package/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/semver/functions/diff.js +23 -0
- package/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/semver/functions/inc.js +18 -0
- package/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/semver/functions/major.js +3 -0
- package/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/semver/functions/parse.js +33 -0
- package/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/semver/index.js +48 -0
- package/node_modules/semver/internal/constants.js +17 -0
- package/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/semver/internal/parse-options.js +11 -0
- package/node_modules/semver/internal/re.js +182 -0
- package/node_modules/semver/package.json +75 -0
- package/node_modules/semver/preload.js +2 -0
- package/node_modules/semver/range.bnf +16 -0
- package/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/semver/ranges/min-version.js +61 -0
- package/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/semver/ranges/simplify.js +47 -0
- package/node_modules/semver/ranges/subset.js +244 -0
- package/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/semver/ranges/valid.js +11 -0
- package/node_modules/side-channel/.eslintignore +1 -0
- package/node_modules/side-channel/.eslintrc +11 -0
- package/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel/.nycrc +13 -0
- package/node_modules/side-channel/CHANGELOG.md +65 -0
- package/node_modules/side-channel/LICENSE +21 -0
- package/node_modules/side-channel/README.md +2 -0
- package/node_modules/side-channel/index.js +124 -0
- package/node_modules/side-channel/package.json +67 -0
- package/node_modules/side-channel/test/index.js +78 -0
- package/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/string-width/index.js +47 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +56 -0
- package/node_modules/string-width/readme.md +50 -0
- package/node_modules/string_decoder/.travis.yml +50 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +31 -0
- package/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/superagent/.browserslistrc +5 -0
- package/node_modules/superagent/.dist.babelrc +10 -0
- package/node_modules/superagent/.dist.eslintrc +35 -0
- package/node_modules/superagent/.editorconfig +9 -0
- package/node_modules/superagent/.gitattributes +1 -0
- package/node_modules/superagent/.lib.babelrc +11 -0
- package/node_modules/superagent/.lib.eslintrc +24 -0
- package/node_modules/superagent/.remarkignore +3 -0
- package/node_modules/superagent/.zuul.yml +16 -0
- package/node_modules/superagent/CONTRIBUTING.md +7 -0
- package/node_modules/superagent/HISTORY.md +692 -0
- package/node_modules/superagent/LICENSE +22 -0
- package/node_modules/superagent/Makefile +60 -0
- package/node_modules/superagent/README.md +266 -0
- package/node_modules/superagent/dist/superagent.js +2418 -0
- package/node_modules/superagent/dist/superagent.min.js +1 -0
- package/node_modules/superagent/docs/head.html +11 -0
- package/node_modules/superagent/docs/images/bg.png +0 -0
- package/node_modules/superagent/docs/index.md +736 -0
- package/node_modules/superagent/docs/style.css +87 -0
- package/node_modules/superagent/docs/tail.html +36 -0
- package/node_modules/superagent/docs/test.html +5072 -0
- package/node_modules/superagent/index.html +47 -0
- package/node_modules/superagent/lib/agent-base.js +42 -0
- package/node_modules/superagent/lib/client.js +1020 -0
- package/node_modules/superagent/lib/is-object.js +17 -0
- package/node_modules/superagent/lib/node/agent.js +113 -0
- package/node_modules/superagent/lib/node/http2wrapper.js +218 -0
- package/node_modules/superagent/lib/node/index.js +1376 -0
- package/node_modules/superagent/lib/node/parsers/image.js +13 -0
- package/node_modules/superagent/lib/node/parsers/index.js +12 -0
- package/node_modules/superagent/lib/node/parsers/json.js +26 -0
- package/node_modules/superagent/lib/node/parsers/text.js +11 -0
- package/node_modules/superagent/lib/node/parsers/urlencoded.js +22 -0
- package/node_modules/superagent/lib/node/response.js +126 -0
- package/node_modules/superagent/lib/node/unzip.js +72 -0
- package/node_modules/superagent/lib/request-base.js +757 -0
- package/node_modules/superagent/lib/response-base.js +131 -0
- package/node_modules/superagent/lib/utils.js +71 -0
- package/node_modules/superagent/node_modules/form-data/License +19 -0
- package/node_modules/superagent/node_modules/form-data/README.md.bak +356 -0
- package/node_modules/superagent/node_modules/form-data/Readme.md +356 -0
- package/node_modules/superagent/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/superagent/node_modules/form-data/lib/browser.js +2 -0
- package/node_modules/superagent/node_modules/form-data/lib/form_data.js +498 -0
- package/node_modules/superagent/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/superagent/node_modules/form-data/package.json +68 -0
- package/node_modules/superagent/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/superagent/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/superagent/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/superagent/node_modules/readable-stream/README.md +106 -0
- package/node_modules/superagent/node_modules/readable-stream/errors-browser.js +127 -0
- package/node_modules/superagent/node_modules/readable-stream/errors.js +116 -0
- package/node_modules/superagent/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/_stream_duplex.js +139 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/_stream_passthrough.js +39 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/_stream_readable.js +1124 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/_stream_transform.js +201 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/_stream_writable.js +697 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/async_iterator.js +207 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/buffer_list.js +210 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/destroy.js +105 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +104 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/from.js +64 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/pipeline.js +97 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/state.js +27 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/superagent/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/superagent/node_modules/readable-stream/package.json +68 -0
- package/node_modules/superagent/node_modules/readable-stream/readable-browser.js +9 -0
- package/node_modules/superagent/node_modules/readable-stream/readable.js +16 -0
- package/node_modules/superagent/package.json +222 -0
- package/node_modules/to-regex-range/LICENSE +21 -0
- package/node_modules/to-regex-range/README.md +305 -0
- package/node_modules/to-regex-range/index.js +288 -0
- package/node_modules/to-regex-range/package.json +88 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/node_modules/uuid/CHANGELOG.md +229 -0
- package/node_modules/uuid/CONTRIBUTING.md +18 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +505 -0
- package/node_modules/uuid/dist/bin/uuid +2 -0
- package/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
- package/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
- package/node_modules/uuid/dist/esm-browser/rng.js +19 -0
- package/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/node_modules/uuid/dist/esm-browser/stringify.js +30 -0
- package/node_modules/uuid/dist/esm-browser/v1.js +95 -0
- package/node_modules/uuid/dist/esm-browser/v3.js +4 -0
- package/node_modules/uuid/dist/esm-browser/v35.js +64 -0
- package/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/node_modules/uuid/dist/esm-browser/v5.js +4 -0
- package/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/node_modules/uuid/dist/esm-node/index.js +9 -0
- package/node_modules/uuid/dist/esm-node/md5.js +13 -0
- package/node_modules/uuid/dist/esm-node/nil.js +1 -0
- package/node_modules/uuid/dist/esm-node/parse.js +35 -0
- package/node_modules/uuid/dist/esm-node/regex.js +1 -0
- package/node_modules/uuid/dist/esm-node/rng.js +12 -0
- package/node_modules/uuid/dist/esm-node/sha1.js +13 -0
- package/node_modules/uuid/dist/esm-node/stringify.js +29 -0
- package/node_modules/uuid/dist/esm-node/v1.js +95 -0
- package/node_modules/uuid/dist/esm-node/v3.js +4 -0
- package/node_modules/uuid/dist/esm-node/v35.js +64 -0
- package/node_modules/uuid/dist/esm-node/v4.js +24 -0
- package/node_modules/uuid/dist/esm-node/v5.js +4 -0
- package/node_modules/uuid/dist/esm-node/validate.js +7 -0
- package/node_modules/uuid/dist/esm-node/version.js +11 -0
- package/node_modules/uuid/dist/index.js +79 -0
- package/node_modules/uuid/dist/md5-browser.js +223 -0
- package/node_modules/uuid/dist/md5.js +23 -0
- package/node_modules/uuid/dist/nil.js +8 -0
- package/node_modules/uuid/dist/parse.js +45 -0
- package/node_modules/uuid/dist/regex.js +8 -0
- package/node_modules/uuid/dist/rng-browser.js +26 -0
- package/node_modules/uuid/dist/rng.js +24 -0
- package/node_modules/uuid/dist/sha1-browser.js +104 -0
- package/node_modules/uuid/dist/sha1.js +23 -0
- package/node_modules/uuid/dist/stringify.js +39 -0
- package/node_modules/uuid/dist/umd/uuid.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidNIL.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidParse.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidStringify.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidValidate.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidVersion.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv1.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv3.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv4.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv5.min.js +1 -0
- package/node_modules/uuid/dist/uuid-bin.js +85 -0
- package/node_modules/uuid/dist/v1.js +107 -0
- package/node_modules/uuid/dist/v3.js +16 -0
- package/node_modules/uuid/dist/v35.js +78 -0
- package/node_modules/uuid/dist/v4.js +37 -0
- package/node_modules/uuid/dist/v5.js +16 -0
- package/node_modules/uuid/dist/validate.js +17 -0
- package/node_modules/uuid/dist/version.js +21 -0
- package/node_modules/uuid/package.json +135 -0
- package/node_modules/uuid/wrapper.mjs +10 -0
- package/node_modules/wrap-ansi/index.js +216 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +62 -0
- package/node_modules/wrap-ansi/readme.md +91 -0
- package/node_modules/wrappy/LICENSE +15 -0
- package/node_modules/wrappy/README.md +36 -0
- package/node_modules/wrappy/package.json +29 -0
- package/node_modules/wrappy/wrappy.js +33 -0
- package/node_modules/y18n/CHANGELOG.md +100 -0
- package/node_modules/y18n/LICENSE +13 -0
- package/node_modules/y18n/README.md +127 -0
- package/node_modules/y18n/build/index.cjs +203 -0
- package/node_modules/y18n/build/lib/cjs.js +6 -0
- package/node_modules/y18n/build/lib/index.js +174 -0
- package/node_modules/y18n/build/lib/platform-shims/node.js +19 -0
- package/node_modules/y18n/index.mjs +8 -0
- package/node_modules/y18n/package.json +70 -0
- package/node_modules/yallist/LICENSE +15 -0
- package/node_modules/yallist/README.md +204 -0
- package/node_modules/yallist/iterator.js +8 -0
- package/node_modules/yallist/package.json +29 -0
- package/node_modules/yallist/yallist.js +426 -0
- package/node_modules/yargs/LICENSE +21 -0
- package/node_modules/yargs/README.md +204 -0
- package/node_modules/yargs/browser.mjs +7 -0
- package/node_modules/yargs/build/index.cjs +1 -0
- package/node_modules/yargs/build/lib/argsert.js +62 -0
- package/node_modules/yargs/build/lib/command.js +447 -0
- package/node_modules/yargs/build/lib/completion-templates.js +48 -0
- package/node_modules/yargs/build/lib/completion.js +236 -0
- package/node_modules/yargs/build/lib/middleware.js +88 -0
- package/node_modules/yargs/build/lib/parse-command.js +32 -0
- package/node_modules/yargs/build/lib/typings/common-types.js +9 -0
- package/node_modules/yargs/build/lib/typings/yargs-parser-types.js +1 -0
- package/node_modules/yargs/build/lib/usage.js +579 -0
- package/node_modules/yargs/build/lib/utils/apply-extends.js +59 -0
- package/node_modules/yargs/build/lib/utils/is-promise.js +5 -0
- package/node_modules/yargs/build/lib/utils/levenshtein.js +34 -0
- package/node_modules/yargs/build/lib/utils/maybe-async-result.js +17 -0
- package/node_modules/yargs/build/lib/utils/obj-filter.js +10 -0
- package/node_modules/yargs/build/lib/utils/process-argv.js +17 -0
- package/node_modules/yargs/build/lib/utils/set-blocking.js +12 -0
- package/node_modules/yargs/build/lib/utils/which-module.js +10 -0
- package/node_modules/yargs/build/lib/validation.js +305 -0
- package/node_modules/yargs/build/lib/yargs-factory.js +1497 -0
- package/node_modules/yargs/build/lib/yerror.js +9 -0
- package/node_modules/yargs/helpers/helpers.mjs +10 -0
- package/node_modules/yargs/helpers/index.js +14 -0
- package/node_modules/yargs/helpers/package.json +3 -0
- package/node_modules/yargs/index.cjs +53 -0
- package/node_modules/yargs/index.mjs +8 -0
- package/node_modules/yargs/lib/platform-shims/browser.mjs +95 -0
- package/node_modules/yargs/lib/platform-shims/esm.mjs +73 -0
- package/node_modules/yargs/locales/be.json +46 -0
- package/node_modules/yargs/locales/de.json +46 -0
- package/node_modules/yargs/locales/en.json +51 -0
- package/node_modules/yargs/locales/es.json +46 -0
- package/node_modules/yargs/locales/fi.json +49 -0
- package/node_modules/yargs/locales/fr.json +53 -0
- package/node_modules/yargs/locales/hi.json +49 -0
- package/node_modules/yargs/locales/hu.json +46 -0
- package/node_modules/yargs/locales/id.json +50 -0
- package/node_modules/yargs/locales/it.json +46 -0
- package/node_modules/yargs/locales/ja.json +51 -0
- package/node_modules/yargs/locales/ko.json +49 -0
- package/node_modules/yargs/locales/nb.json +44 -0
- package/node_modules/yargs/locales/nl.json +49 -0
- package/node_modules/yargs/locales/nn.json +44 -0
- package/node_modules/yargs/locales/pirate.json +13 -0
- package/node_modules/yargs/locales/pl.json +49 -0
- package/node_modules/yargs/locales/pt.json +45 -0
- package/node_modules/yargs/locales/pt_BR.json +48 -0
- package/node_modules/yargs/locales/ru.json +51 -0
- package/node_modules/yargs/locales/th.json +46 -0
- package/node_modules/yargs/locales/tr.json +48 -0
- package/node_modules/yargs/locales/uk_UA.json +51 -0
- package/node_modules/yargs/locales/uz.json +52 -0
- package/node_modules/yargs/locales/zh_CN.json +48 -0
- package/node_modules/yargs/locales/zh_TW.json +51 -0
- package/node_modules/yargs/package.json +123 -0
- package/node_modules/yargs/yargs +9 -0
- package/node_modules/yargs/yargs.mjs +10 -0
- package/node_modules/yargs-parser/CHANGELOG.md +287 -0
- package/node_modules/yargs-parser/LICENSE.txt +14 -0
- package/node_modules/yargs-parser/README.md +518 -0
- package/node_modules/yargs-parser/browser.js +29 -0
- package/node_modules/yargs-parser/build/index.cjs +1048 -0
- package/node_modules/yargs-parser/build/lib/index.js +60 -0
- package/node_modules/yargs-parser/build/lib/string-utils.js +65 -0
- package/node_modules/yargs-parser/build/lib/tokenize-arg-string.js +40 -0
- package/node_modules/yargs-parser/build/lib/yargs-parser-types.js +12 -0
- package/node_modules/yargs-parser/build/lib/yargs-parser.js +1045 -0
- package/node_modules/yargs-parser/package.json +88 -0
- package/package.json +1 -1
@@ -0,0 +1,1649 @@
|
|
1
|
+
/**
|
2
|
+
* Module dependencies.
|
3
|
+
*/
|
4
|
+
|
5
|
+
var EventEmitter = require('events').EventEmitter;
|
6
|
+
var spawn = require('child_process').spawn;
|
7
|
+
var path = require('path');
|
8
|
+
var dirname = path.dirname;
|
9
|
+
var basename = path.basename;
|
10
|
+
var fs = require('fs');
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Inherit `Command` from `EventEmitter.prototype`.
|
14
|
+
*/
|
15
|
+
|
16
|
+
require('util').inherits(Command, EventEmitter);
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Expose the root command.
|
20
|
+
*/
|
21
|
+
|
22
|
+
exports = module.exports = new Command();
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Expose `Command`.
|
26
|
+
*/
|
27
|
+
|
28
|
+
exports.Command = Command;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Expose `Option`.
|
32
|
+
*/
|
33
|
+
|
34
|
+
exports.Option = Option;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Initialize a new `Option` with the given `flags` and `description`.
|
38
|
+
*
|
39
|
+
* @param {String} flags
|
40
|
+
* @param {String} description
|
41
|
+
* @api public
|
42
|
+
*/
|
43
|
+
|
44
|
+
function Option(flags, description) {
|
45
|
+
this.flags = flags;
|
46
|
+
this.required = flags.indexOf('<') >= 0; // A value must be supplied when the option is specified.
|
47
|
+
this.optional = flags.indexOf('[') >= 0; // A value is optional when the option is specified.
|
48
|
+
this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.
|
49
|
+
this.negate = flags.indexOf('-no-') !== -1;
|
50
|
+
flags = flags.split(/[ ,|]+/);
|
51
|
+
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
|
52
|
+
this.long = flags.shift();
|
53
|
+
this.description = description || '';
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Return option name.
|
58
|
+
*
|
59
|
+
* @return {String}
|
60
|
+
* @api private
|
61
|
+
*/
|
62
|
+
|
63
|
+
Option.prototype.name = function() {
|
64
|
+
return this.long.replace(/^--/, '');
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Return option name, in a camelcase format that can be used
|
69
|
+
* as a object attribute key.
|
70
|
+
*
|
71
|
+
* @return {String}
|
72
|
+
* @api private
|
73
|
+
*/
|
74
|
+
|
75
|
+
Option.prototype.attributeName = function() {
|
76
|
+
return camelcase(this.name().replace(/^no-/, ''));
|
77
|
+
};
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Check if `arg` matches the short or long flag.
|
81
|
+
*
|
82
|
+
* @param {String} arg
|
83
|
+
* @return {Boolean}
|
84
|
+
* @api private
|
85
|
+
*/
|
86
|
+
|
87
|
+
Option.prototype.is = function(arg) {
|
88
|
+
return this.short === arg || this.long === arg;
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* CommanderError class
|
93
|
+
* @class
|
94
|
+
*/
|
95
|
+
class CommanderError extends Error {
|
96
|
+
/**
|
97
|
+
* Constructs the CommanderError class
|
98
|
+
* @param {Number} exitCode suggested exit code which could be used with process.exit
|
99
|
+
* @param {String} code an id string representing the error
|
100
|
+
* @param {String} message human-readable description of the error
|
101
|
+
* @constructor
|
102
|
+
*/
|
103
|
+
constructor(exitCode, code, message) {
|
104
|
+
super(message);
|
105
|
+
// properly capture stack trace in Node.js
|
106
|
+
Error.captureStackTrace(this, this.constructor);
|
107
|
+
this.name = this.constructor.name;
|
108
|
+
this.code = code;
|
109
|
+
this.exitCode = exitCode;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
exports.CommanderError = CommanderError;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Initialize a new `Command`.
|
117
|
+
*
|
118
|
+
* @param {String} [name]
|
119
|
+
* @api public
|
120
|
+
*/
|
121
|
+
|
122
|
+
function Command(name) {
|
123
|
+
this.commands = [];
|
124
|
+
this.options = [];
|
125
|
+
this._execs = new Set();
|
126
|
+
this._allowUnknownOption = false;
|
127
|
+
this._args = [];
|
128
|
+
this._name = name || '';
|
129
|
+
this._optionValues = {};
|
130
|
+
this._storeOptionsAsProperties = true; // backwards compatible by default
|
131
|
+
this._passCommandToAction = true; // backwards compatible by default
|
132
|
+
this._actionResults = [];
|
133
|
+
|
134
|
+
this._helpFlags = '-h, --help';
|
135
|
+
this._helpDescription = 'output usage information';
|
136
|
+
this._helpShortFlag = '-h';
|
137
|
+
this._helpLongFlag = '--help';
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Define a command.
|
142
|
+
*
|
143
|
+
* There are two styles of command: pay attention to where to put the description.
|
144
|
+
*
|
145
|
+
* Examples:
|
146
|
+
*
|
147
|
+
* // Command implemented using action handler (description is supplied separately to `.command`)
|
148
|
+
* program
|
149
|
+
* .command('clone <source> [destination]')
|
150
|
+
* .description('clone a repository into a newly created directory')
|
151
|
+
* .action((source, destination) => {
|
152
|
+
* console.log('clone command called');
|
153
|
+
* });
|
154
|
+
*
|
155
|
+
* // Command implemented using separate executable file (description is second parameter to `.command`)
|
156
|
+
* program
|
157
|
+
* .command('start <service>', 'start named service')
|
158
|
+
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
159
|
+
*
|
160
|
+
* @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
161
|
+
* @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
|
162
|
+
* @param {Object} [execOpts] - configuration options (for executable)
|
163
|
+
* @return {Command} returns new command for action handler, or top-level command for executable command
|
164
|
+
* @api public
|
165
|
+
*/
|
166
|
+
|
167
|
+
Command.prototype.command = function(nameAndArgs, actionOptsOrExecDesc, execOpts) {
|
168
|
+
var desc = actionOptsOrExecDesc;
|
169
|
+
var opts = execOpts;
|
170
|
+
if (typeof desc === 'object' && desc !== null) {
|
171
|
+
opts = desc;
|
172
|
+
desc = null;
|
173
|
+
}
|
174
|
+
opts = opts || {};
|
175
|
+
var args = nameAndArgs.split(/ +/);
|
176
|
+
var cmd = new Command(args.shift());
|
177
|
+
|
178
|
+
if (desc) {
|
179
|
+
cmd.description(desc);
|
180
|
+
this.executables = true;
|
181
|
+
this._execs.add(cmd._name);
|
182
|
+
if (opts.isDefault) this.defaultExecutable = cmd._name;
|
183
|
+
}
|
184
|
+
cmd._noHelp = !!opts.noHelp;
|
185
|
+
cmd._helpFlags = this._helpFlags;
|
186
|
+
cmd._helpDescription = this._helpDescription;
|
187
|
+
cmd._helpShortFlag = this._helpShortFlag;
|
188
|
+
cmd._helpLongFlag = this._helpLongFlag;
|
189
|
+
cmd._exitCallback = this._exitCallback;
|
190
|
+
cmd._storeOptionsAsProperties = this._storeOptionsAsProperties;
|
191
|
+
cmd._passCommandToAction = this._passCommandToAction;
|
192
|
+
|
193
|
+
cmd._executableFile = opts.executableFile; // Custom name for executable file
|
194
|
+
this.commands.push(cmd);
|
195
|
+
cmd.parseExpectedArgs(args);
|
196
|
+
cmd.parent = this;
|
197
|
+
|
198
|
+
if (desc) return this;
|
199
|
+
return cmd;
|
200
|
+
};
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Define argument syntax for the top-level command.
|
204
|
+
*
|
205
|
+
* @api public
|
206
|
+
*/
|
207
|
+
|
208
|
+
Command.prototype.arguments = function(desc) {
|
209
|
+
return this.parseExpectedArgs(desc.split(/ +/));
|
210
|
+
};
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Add an implicit `help [cmd]` subcommand
|
214
|
+
* which invokes `--help` for the given command.
|
215
|
+
*
|
216
|
+
* @api private
|
217
|
+
*/
|
218
|
+
|
219
|
+
Command.prototype.addImplicitHelpCommand = function() {
|
220
|
+
this.command('help [cmd]', 'display help for [cmd]');
|
221
|
+
};
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Parse expected `args`.
|
225
|
+
*
|
226
|
+
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
|
227
|
+
*
|
228
|
+
* @param {Array} args
|
229
|
+
* @return {Command} for chaining
|
230
|
+
* @api public
|
231
|
+
*/
|
232
|
+
|
233
|
+
Command.prototype.parseExpectedArgs = function(args) {
|
234
|
+
if (!args.length) return;
|
235
|
+
var self = this;
|
236
|
+
args.forEach(function(arg) {
|
237
|
+
var argDetails = {
|
238
|
+
required: false,
|
239
|
+
name: '',
|
240
|
+
variadic: false
|
241
|
+
};
|
242
|
+
|
243
|
+
switch (arg[0]) {
|
244
|
+
case '<':
|
245
|
+
argDetails.required = true;
|
246
|
+
argDetails.name = arg.slice(1, -1);
|
247
|
+
break;
|
248
|
+
case '[':
|
249
|
+
argDetails.name = arg.slice(1, -1);
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
|
253
|
+
if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
|
254
|
+
argDetails.variadic = true;
|
255
|
+
argDetails.name = argDetails.name.slice(0, -3);
|
256
|
+
}
|
257
|
+
if (argDetails.name) {
|
258
|
+
self._args.push(argDetails);
|
259
|
+
}
|
260
|
+
});
|
261
|
+
return this;
|
262
|
+
};
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Register callback to use as replacement for calling process.exit.
|
266
|
+
*
|
267
|
+
* @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
|
268
|
+
* @return {Command} for chaining
|
269
|
+
* @api public
|
270
|
+
*/
|
271
|
+
|
272
|
+
Command.prototype.exitOverride = function(fn) {
|
273
|
+
if (fn) {
|
274
|
+
this._exitCallback = fn;
|
275
|
+
} else {
|
276
|
+
this._exitCallback = function(err) {
|
277
|
+
if (err.code !== 'commander.executeSubCommandAsync') {
|
278
|
+
throw err;
|
279
|
+
} else {
|
280
|
+
// Async callback from spawn events, not useful to throw.
|
281
|
+
}
|
282
|
+
};
|
283
|
+
}
|
284
|
+
return this;
|
285
|
+
};
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Call process.exit, and _exitCallback if defined.
|
289
|
+
*
|
290
|
+
* @param {Number} exitCode exit code for using with process.exit
|
291
|
+
* @param {String} code an id string representing the error
|
292
|
+
* @param {String} message human-readable description of the error
|
293
|
+
* @return never
|
294
|
+
* @api private
|
295
|
+
*/
|
296
|
+
|
297
|
+
Command.prototype._exit = function(exitCode, code, message) {
|
298
|
+
if (this._exitCallback) {
|
299
|
+
this._exitCallback(new CommanderError(exitCode, code, message));
|
300
|
+
// Expecting this line is not reached.
|
301
|
+
}
|
302
|
+
process.exit(exitCode);
|
303
|
+
};
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Register callback `fn` for the command.
|
307
|
+
*
|
308
|
+
* Examples:
|
309
|
+
*
|
310
|
+
* program
|
311
|
+
* .command('help')
|
312
|
+
* .description('display verbose help')
|
313
|
+
* .action(function() {
|
314
|
+
* // output help here
|
315
|
+
* });
|
316
|
+
*
|
317
|
+
* @param {Function} fn
|
318
|
+
* @return {Command} for chaining
|
319
|
+
* @api public
|
320
|
+
*/
|
321
|
+
|
322
|
+
Command.prototype.action = function(fn) {
|
323
|
+
var self = this;
|
324
|
+
var listener = function(args, unknown) {
|
325
|
+
// Parse any so-far unknown options
|
326
|
+
args = args || [];
|
327
|
+
unknown = unknown || [];
|
328
|
+
|
329
|
+
var parsed = self.parseOptions(unknown);
|
330
|
+
|
331
|
+
// Output help if necessary
|
332
|
+
outputHelpIfRequested(self, parsed.unknown);
|
333
|
+
self._checkForMissingMandatoryOptions();
|
334
|
+
|
335
|
+
// If there are still any unknown options, then we simply
|
336
|
+
// die, unless someone asked for help, in which case we give it
|
337
|
+
// to them, and then we die.
|
338
|
+
if (parsed.unknown.length > 0) {
|
339
|
+
self.unknownOption(parsed.unknown[0]);
|
340
|
+
}
|
341
|
+
|
342
|
+
// Leftover arguments need to be pushed back. Fixes issue #56
|
343
|
+
if (parsed.args.length) args = parsed.args.concat(args);
|
344
|
+
|
345
|
+
self._args.forEach(function(arg, i) {
|
346
|
+
if (arg.required && args[i] == null) {
|
347
|
+
self.missingArgument(arg.name);
|
348
|
+
} else if (arg.variadic) {
|
349
|
+
if (i !== self._args.length - 1) {
|
350
|
+
self.variadicArgNotLast(arg.name);
|
351
|
+
}
|
352
|
+
|
353
|
+
args[i] = args.splice(i);
|
354
|
+
}
|
355
|
+
});
|
356
|
+
|
357
|
+
// The .action callback takes an extra parameter which is the command itself.
|
358
|
+
var expectedArgsCount = self._args.length;
|
359
|
+
var actionArgs = args.slice(0, expectedArgsCount);
|
360
|
+
if (self._passCommandToAction) {
|
361
|
+
actionArgs[expectedArgsCount] = self;
|
362
|
+
} else {
|
363
|
+
actionArgs[expectedArgsCount] = self.opts();
|
364
|
+
}
|
365
|
+
// Add the extra arguments so available too.
|
366
|
+
if (args.length > expectedArgsCount) {
|
367
|
+
actionArgs.push(args.slice(expectedArgsCount));
|
368
|
+
}
|
369
|
+
|
370
|
+
const actionResult = fn.apply(self, actionArgs);
|
371
|
+
// Remember result in case it is async. Assume parseAsync getting called on root.
|
372
|
+
let rootCommand = self;
|
373
|
+
while (rootCommand.parent) {
|
374
|
+
rootCommand = rootCommand.parent;
|
375
|
+
}
|
376
|
+
rootCommand._actionResults.push(actionResult);
|
377
|
+
};
|
378
|
+
var parent = this.parent || this;
|
379
|
+
var name = parent === this ? '*' : this._name;
|
380
|
+
parent.on('command:' + name, listener);
|
381
|
+
if (this._alias) parent.on('command:' + this._alias, listener);
|
382
|
+
return this;
|
383
|
+
};
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Internal implementation shared by .option() and .requiredOption()
|
387
|
+
*
|
388
|
+
* @param {Object} config
|
389
|
+
* @param {String} flags
|
390
|
+
* @param {String} description
|
391
|
+
* @param {Function|*} [fn] - custom option processing function or default vaue
|
392
|
+
* @param {*} [defaultValue]
|
393
|
+
* @return {Command} for chaining
|
394
|
+
* @api private
|
395
|
+
*/
|
396
|
+
|
397
|
+
Command.prototype._optionEx = function(config, flags, description, fn, defaultValue) {
|
398
|
+
var self = this,
|
399
|
+
option = new Option(flags, description),
|
400
|
+
oname = option.name(),
|
401
|
+
name = option.attributeName();
|
402
|
+
option.mandatory = !!config.mandatory;
|
403
|
+
|
404
|
+
// default as 3rd arg
|
405
|
+
if (typeof fn !== 'function') {
|
406
|
+
if (fn instanceof RegExp) {
|
407
|
+
// This is a bit simplistic (especially no error messages), and probably better handled by caller using custom option processing.
|
408
|
+
// No longer documented in README, but still present for backwards compatibility.
|
409
|
+
var regex = fn;
|
410
|
+
fn = function(val, def) {
|
411
|
+
var m = regex.exec(val);
|
412
|
+
return m ? m[0] : def;
|
413
|
+
};
|
414
|
+
} else {
|
415
|
+
defaultValue = fn;
|
416
|
+
fn = null;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
420
|
+
// preassign default value for --no-*, [optional], <required>, or plain flag if boolean value
|
421
|
+
if (option.negate || option.optional || option.required || typeof defaultValue === 'boolean') {
|
422
|
+
// when --no-foo we make sure default is true, unless a --foo option is already defined
|
423
|
+
if (option.negate) {
|
424
|
+
const positiveLongFlag = option.long.replace(/^--no-/, '--');
|
425
|
+
defaultValue = self.optionFor(positiveLongFlag) ? self._getOptionValue(name) : true;
|
426
|
+
}
|
427
|
+
// preassign only if we have a default
|
428
|
+
if (defaultValue !== undefined) {
|
429
|
+
self._setOptionValue(name, defaultValue);
|
430
|
+
option.defaultValue = defaultValue;
|
431
|
+
}
|
432
|
+
}
|
433
|
+
|
434
|
+
// register the option
|
435
|
+
this.options.push(option);
|
436
|
+
|
437
|
+
// when it's passed assign the value
|
438
|
+
// and conditionally invoke the callback
|
439
|
+
this.on('option:' + oname, function(val) {
|
440
|
+
// coercion
|
441
|
+
if (val !== null && fn) {
|
442
|
+
val = fn(val, self._getOptionValue(name) === undefined ? defaultValue : self._getOptionValue(name));
|
443
|
+
}
|
444
|
+
|
445
|
+
// unassigned or boolean value
|
446
|
+
if (typeof self._getOptionValue(name) === 'boolean' || typeof self._getOptionValue(name) === 'undefined') {
|
447
|
+
// if no value, negate false, and we have a default, then use it!
|
448
|
+
if (val == null) {
|
449
|
+
self._setOptionValue(name, option.negate
|
450
|
+
? false
|
451
|
+
: defaultValue || true);
|
452
|
+
} else {
|
453
|
+
self._setOptionValue(name, val);
|
454
|
+
}
|
455
|
+
} else if (val !== null) {
|
456
|
+
// reassign
|
457
|
+
self._setOptionValue(name, option.negate ? false : val);
|
458
|
+
}
|
459
|
+
});
|
460
|
+
|
461
|
+
return this;
|
462
|
+
};
|
463
|
+
|
464
|
+
/**
|
465
|
+
* Define option with `flags`, `description` and optional
|
466
|
+
* coercion `fn`.
|
467
|
+
*
|
468
|
+
* The `flags` string should contain both the short and long flags,
|
469
|
+
* separated by comma, a pipe or space. The following are all valid
|
470
|
+
* all will output this way when `--help` is used.
|
471
|
+
*
|
472
|
+
* "-p, --pepper"
|
473
|
+
* "-p|--pepper"
|
474
|
+
* "-p --pepper"
|
475
|
+
*
|
476
|
+
* Examples:
|
477
|
+
*
|
478
|
+
* // simple boolean defaulting to undefined
|
479
|
+
* program.option('-p, --pepper', 'add pepper');
|
480
|
+
*
|
481
|
+
* program.pepper
|
482
|
+
* // => undefined
|
483
|
+
*
|
484
|
+
* --pepper
|
485
|
+
* program.pepper
|
486
|
+
* // => true
|
487
|
+
*
|
488
|
+
* // simple boolean defaulting to true (unless non-negated option is also defined)
|
489
|
+
* program.option('-C, --no-cheese', 'remove cheese');
|
490
|
+
*
|
491
|
+
* program.cheese
|
492
|
+
* // => true
|
493
|
+
*
|
494
|
+
* --no-cheese
|
495
|
+
* program.cheese
|
496
|
+
* // => false
|
497
|
+
*
|
498
|
+
* // required argument
|
499
|
+
* program.option('-C, --chdir <path>', 'change the working directory');
|
500
|
+
*
|
501
|
+
* --chdir /tmp
|
502
|
+
* program.chdir
|
503
|
+
* // => "/tmp"
|
504
|
+
*
|
505
|
+
* // optional argument
|
506
|
+
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
507
|
+
*
|
508
|
+
* @param {String} flags
|
509
|
+
* @param {String} description
|
510
|
+
* @param {Function|*} [fn] - custom option processing function or default vaue
|
511
|
+
* @param {*} [defaultValue]
|
512
|
+
* @return {Command} for chaining
|
513
|
+
* @api public
|
514
|
+
*/
|
515
|
+
|
516
|
+
Command.prototype.option = function(flags, description, fn, defaultValue) {
|
517
|
+
return this._optionEx({}, flags, description, fn, defaultValue);
|
518
|
+
};
|
519
|
+
|
520
|
+
/*
|
521
|
+
* Add a required option which must have a value after parsing. This usually means
|
522
|
+
* the option must be specified on the command line. (Otherwise the same as .option().)
|
523
|
+
*
|
524
|
+
* The `flags` string should contain both the short and long flags, separated by comma, a pipe or space.
|
525
|
+
*
|
526
|
+
* @param {String} flags
|
527
|
+
* @param {String} description
|
528
|
+
* @param {Function|*} [fn] - custom option processing function or default vaue
|
529
|
+
* @param {*} [defaultValue]
|
530
|
+
* @return {Command} for chaining
|
531
|
+
* @api public
|
532
|
+
*/
|
533
|
+
|
534
|
+
Command.prototype.requiredOption = function(flags, description, fn, defaultValue) {
|
535
|
+
return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
|
536
|
+
};
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Allow unknown options on the command line.
|
540
|
+
*
|
541
|
+
* @param {Boolean} arg if `true` or omitted, no error will be thrown
|
542
|
+
* for unknown options.
|
543
|
+
* @api public
|
544
|
+
*/
|
545
|
+
Command.prototype.allowUnknownOption = function(arg) {
|
546
|
+
this._allowUnknownOption = arguments.length === 0 || arg;
|
547
|
+
return this;
|
548
|
+
};
|
549
|
+
|
550
|
+
/**
|
551
|
+
* Whether to store option values as properties on command object,
|
552
|
+
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
553
|
+
*
|
554
|
+
* @param {boolean} value
|
555
|
+
* @return {Command} Command for chaining
|
556
|
+
* @api public
|
557
|
+
*/
|
558
|
+
|
559
|
+
Command.prototype.storeOptionsAsProperties = function(value) {
|
560
|
+
this._storeOptionsAsProperties = (value === undefined) || value;
|
561
|
+
if (this.options.length) {
|
562
|
+
// This is for programmer, not end user.
|
563
|
+
console.error('Commander usage error: call storeOptionsAsProperties before adding options');
|
564
|
+
}
|
565
|
+
return this;
|
566
|
+
};
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Whether to pass command to action handler,
|
570
|
+
* or just the options (specify false).
|
571
|
+
*
|
572
|
+
* @param {boolean} value
|
573
|
+
* @return {Command} Command for chaining
|
574
|
+
* @api public
|
575
|
+
*/
|
576
|
+
|
577
|
+
Command.prototype.passCommandToAction = function(value) {
|
578
|
+
this._passCommandToAction = (value === undefined) || value;
|
579
|
+
return this;
|
580
|
+
};
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Store option value
|
584
|
+
*
|
585
|
+
* @param {String} key
|
586
|
+
* @param {Object} value
|
587
|
+
* @api private
|
588
|
+
*/
|
589
|
+
|
590
|
+
Command.prototype._setOptionValue = function(key, value) {
|
591
|
+
if (this._storeOptionsAsProperties) {
|
592
|
+
this[key] = value;
|
593
|
+
} else {
|
594
|
+
this._optionValues[key] = value;
|
595
|
+
}
|
596
|
+
};
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Retrieve option value
|
600
|
+
*
|
601
|
+
* @param {String} key
|
602
|
+
* @return {Object} value
|
603
|
+
* @api private
|
604
|
+
*/
|
605
|
+
|
606
|
+
Command.prototype._getOptionValue = function(key) {
|
607
|
+
if (this._storeOptionsAsProperties) {
|
608
|
+
return this[key];
|
609
|
+
}
|
610
|
+
return this._optionValues[key];
|
611
|
+
};
|
612
|
+
|
613
|
+
/**
|
614
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
615
|
+
*
|
616
|
+
* @param {Array} argv
|
617
|
+
* @return {Command} for chaining
|
618
|
+
* @api public
|
619
|
+
*/
|
620
|
+
|
621
|
+
Command.prototype.parse = function(argv) {
|
622
|
+
// implicit help
|
623
|
+
if (this.executables) this.addImplicitHelpCommand();
|
624
|
+
|
625
|
+
// store raw args
|
626
|
+
this.rawArgs = argv;
|
627
|
+
|
628
|
+
// guess name
|
629
|
+
this._name = this._name || basename(argv[1], '.js');
|
630
|
+
|
631
|
+
// github-style sub-commands with no sub-command
|
632
|
+
if (this.executables && argv.length < 3 && !this.defaultExecutable) {
|
633
|
+
// this user needs help
|
634
|
+
argv.push(this._helpLongFlag);
|
635
|
+
}
|
636
|
+
|
637
|
+
// process argv
|
638
|
+
var normalized = this.normalize(argv.slice(2));
|
639
|
+
var parsed = this.parseOptions(normalized);
|
640
|
+
var args = this.args = parsed.args;
|
641
|
+
|
642
|
+
var result = this.parseArgs(this.args, parsed.unknown);
|
643
|
+
|
644
|
+
if (args[0] === 'help' && args.length === 1) this.help();
|
645
|
+
|
646
|
+
// Note for future: we could return early if we found an action handler in parseArgs, as none of following code needed?
|
647
|
+
|
648
|
+
// <cmd> --help
|
649
|
+
if (args[0] === 'help') {
|
650
|
+
args[0] = args[1];
|
651
|
+
args[1] = this._helpLongFlag;
|
652
|
+
} else {
|
653
|
+
// If calling through to executable subcommand we could check for help flags before failing,
|
654
|
+
// but a somewhat unlikely case since program options not passed to executable subcommands.
|
655
|
+
// Wait for reports to see if check needed and what usage pattern is.
|
656
|
+
this._checkForMissingMandatoryOptions();
|
657
|
+
}
|
658
|
+
|
659
|
+
// executable sub-commands
|
660
|
+
// (Debugging note for future: args[0] is not right if an action has been called)
|
661
|
+
var name = result.args[0];
|
662
|
+
var subCommand = null;
|
663
|
+
|
664
|
+
// Look for subcommand
|
665
|
+
if (name) {
|
666
|
+
subCommand = this.commands.find(function(command) {
|
667
|
+
return command._name === name;
|
668
|
+
});
|
669
|
+
}
|
670
|
+
|
671
|
+
// Look for alias
|
672
|
+
if (!subCommand && name) {
|
673
|
+
subCommand = this.commands.find(function(command) {
|
674
|
+
return command.alias() === name;
|
675
|
+
});
|
676
|
+
if (subCommand) {
|
677
|
+
name = subCommand._name;
|
678
|
+
args[0] = name;
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
682
|
+
// Look for default subcommand
|
683
|
+
if (!subCommand && this.defaultExecutable) {
|
684
|
+
name = this.defaultExecutable;
|
685
|
+
args.unshift(name);
|
686
|
+
subCommand = this.commands.find(function(command) {
|
687
|
+
return command._name === name;
|
688
|
+
});
|
689
|
+
}
|
690
|
+
|
691
|
+
if (this._execs.has(name)) {
|
692
|
+
return this.executeSubCommand(argv, args, parsed.unknown, subCommand ? subCommand._executableFile : undefined);
|
693
|
+
}
|
694
|
+
|
695
|
+
return result;
|
696
|
+
};
|
697
|
+
|
698
|
+
/**
|
699
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
700
|
+
*
|
701
|
+
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
702
|
+
*
|
703
|
+
* @param {Array} argv
|
704
|
+
* @return {Promise}
|
705
|
+
* @api public
|
706
|
+
*/
|
707
|
+
Command.prototype.parseAsync = function(argv) {
|
708
|
+
this.parse(argv);
|
709
|
+
return Promise.all(this._actionResults);
|
710
|
+
};
|
711
|
+
|
712
|
+
/**
|
713
|
+
* Execute a sub-command executable.
|
714
|
+
*
|
715
|
+
* @param {Array} argv
|
716
|
+
* @param {Array} args
|
717
|
+
* @param {Array} unknown
|
718
|
+
* @param {String} executableFile
|
719
|
+
* @api private
|
720
|
+
*/
|
721
|
+
|
722
|
+
Command.prototype.executeSubCommand = function(argv, args, unknown, executableFile) {
|
723
|
+
args = args.concat(unknown);
|
724
|
+
|
725
|
+
if (!args.length) this.help();
|
726
|
+
|
727
|
+
var isExplicitJS = false; // Whether to use node to launch "executable"
|
728
|
+
|
729
|
+
// executable
|
730
|
+
var pm = argv[1];
|
731
|
+
// name of the subcommand, like `pm-install`
|
732
|
+
var bin = basename(pm, path.extname(pm)) + '-' + args[0];
|
733
|
+
if (executableFile != null) {
|
734
|
+
bin = executableFile;
|
735
|
+
// Check for same extensions as we scan for below so get consistent launch behaviour.
|
736
|
+
var executableExt = path.extname(executableFile);
|
737
|
+
isExplicitJS = executableExt === '.js' || executableExt === '.ts' || executableExt === '.mjs';
|
738
|
+
}
|
739
|
+
|
740
|
+
// In case of globally installed, get the base dir where executable
|
741
|
+
// subcommand file should be located at
|
742
|
+
var baseDir;
|
743
|
+
|
744
|
+
var resolvedLink = fs.realpathSync(pm);
|
745
|
+
|
746
|
+
baseDir = dirname(resolvedLink);
|
747
|
+
|
748
|
+
// prefer local `./<bin>` to bin in the $PATH
|
749
|
+
var localBin = path.join(baseDir, bin);
|
750
|
+
|
751
|
+
// whether bin file is a js script with explicit `.js` or `.ts` extension
|
752
|
+
if (exists(localBin + '.js')) {
|
753
|
+
bin = localBin + '.js';
|
754
|
+
isExplicitJS = true;
|
755
|
+
} else if (exists(localBin + '.ts')) {
|
756
|
+
bin = localBin + '.ts';
|
757
|
+
isExplicitJS = true;
|
758
|
+
} else if (exists(localBin + '.mjs')) {
|
759
|
+
bin = localBin + '.mjs';
|
760
|
+
isExplicitJS = true;
|
761
|
+
} else if (exists(localBin)) {
|
762
|
+
bin = localBin;
|
763
|
+
}
|
764
|
+
|
765
|
+
args = args.slice(1);
|
766
|
+
|
767
|
+
var proc;
|
768
|
+
if (process.platform !== 'win32') {
|
769
|
+
if (isExplicitJS) {
|
770
|
+
args.unshift(bin);
|
771
|
+
// add executable arguments to spawn
|
772
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
773
|
+
|
774
|
+
proc = spawn(process.argv[0], args, { stdio: 'inherit' });
|
775
|
+
} else {
|
776
|
+
proc = spawn(bin, args, { stdio: 'inherit' });
|
777
|
+
}
|
778
|
+
} else {
|
779
|
+
args.unshift(bin);
|
780
|
+
// add executable arguments to spawn
|
781
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
782
|
+
proc = spawn(process.execPath, args, { stdio: 'inherit' });
|
783
|
+
}
|
784
|
+
|
785
|
+
var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
|
786
|
+
signals.forEach(function(signal) {
|
787
|
+
process.on(signal, function() {
|
788
|
+
if (proc.killed === false && proc.exitCode === null) {
|
789
|
+
proc.kill(signal);
|
790
|
+
}
|
791
|
+
});
|
792
|
+
});
|
793
|
+
|
794
|
+
// By default terminate process when spawned process terminates.
|
795
|
+
// Suppressing the exit if exitCallback defined is a bit messy and of limited use, but does allow process to stay running!
|
796
|
+
const exitCallback = this._exitCallback;
|
797
|
+
if (!exitCallback) {
|
798
|
+
proc.on('close', process.exit.bind(process));
|
799
|
+
} else {
|
800
|
+
proc.on('close', () => {
|
801
|
+
exitCallback(new CommanderError(process.exitCode || 0, 'commander.executeSubCommandAsync', '(close)'));
|
802
|
+
});
|
803
|
+
}
|
804
|
+
proc.on('error', function(err) {
|
805
|
+
if (err.code === 'ENOENT') {
|
806
|
+
console.error('error: %s(1) does not exist, try --help', bin);
|
807
|
+
} else if (err.code === 'EACCES') {
|
808
|
+
console.error('error: %s(1) not executable. try chmod or run with root', bin);
|
809
|
+
}
|
810
|
+
if (!exitCallback) {
|
811
|
+
process.exit(1);
|
812
|
+
} else {
|
813
|
+
const wrappedError = new CommanderError(1, 'commander.executeSubCommandAsync', '(error)');
|
814
|
+
wrappedError.nestedError = err;
|
815
|
+
exitCallback(wrappedError);
|
816
|
+
}
|
817
|
+
});
|
818
|
+
|
819
|
+
// Store the reference to the child process
|
820
|
+
this.runningCommand = proc;
|
821
|
+
};
|
822
|
+
|
823
|
+
/**
|
824
|
+
* Normalize `args`, splitting joined short flags. For example
|
825
|
+
* the arg "-abc" is equivalent to "-a -b -c".
|
826
|
+
* This also normalizes equal sign and splits "--abc=def" into "--abc def".
|
827
|
+
*
|
828
|
+
* @param {Array} args
|
829
|
+
* @return {Array}
|
830
|
+
* @api private
|
831
|
+
*/
|
832
|
+
|
833
|
+
Command.prototype.normalize = function(args) {
|
834
|
+
var ret = [],
|
835
|
+
arg,
|
836
|
+
lastOpt,
|
837
|
+
index,
|
838
|
+
short,
|
839
|
+
opt;
|
840
|
+
|
841
|
+
for (var i = 0, len = args.length; i < len; ++i) {
|
842
|
+
arg = args[i];
|
843
|
+
if (i > 0) {
|
844
|
+
lastOpt = this.optionFor(args[i - 1]);
|
845
|
+
}
|
846
|
+
|
847
|
+
if (arg === '--') {
|
848
|
+
// Honor option terminator
|
849
|
+
ret = ret.concat(args.slice(i));
|
850
|
+
break;
|
851
|
+
} else if (lastOpt && lastOpt.required) {
|
852
|
+
ret.push(arg);
|
853
|
+
} else if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {
|
854
|
+
short = arg.slice(0, 2);
|
855
|
+
opt = this.optionFor(short);
|
856
|
+
if (opt && (opt.required || opt.optional)) {
|
857
|
+
ret.push(short);
|
858
|
+
ret.push(arg.slice(2));
|
859
|
+
} else {
|
860
|
+
arg.slice(1).split('').forEach(function(c) {
|
861
|
+
ret.push('-' + c);
|
862
|
+
});
|
863
|
+
}
|
864
|
+
} else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {
|
865
|
+
ret.push(arg.slice(0, index), arg.slice(index + 1));
|
866
|
+
} else {
|
867
|
+
ret.push(arg);
|
868
|
+
}
|
869
|
+
}
|
870
|
+
|
871
|
+
return ret;
|
872
|
+
};
|
873
|
+
|
874
|
+
/**
|
875
|
+
* Parse command `args`.
|
876
|
+
*
|
877
|
+
* When listener(s) are available those
|
878
|
+
* callbacks are invoked, otherwise the "*"
|
879
|
+
* event is emitted and those actions are invoked.
|
880
|
+
*
|
881
|
+
* @param {Array} args
|
882
|
+
* @return {Command} for chaining
|
883
|
+
* @api private
|
884
|
+
*/
|
885
|
+
|
886
|
+
Command.prototype.parseArgs = function(args, unknown) {
|
887
|
+
var name;
|
888
|
+
|
889
|
+
if (args.length) {
|
890
|
+
name = args[0];
|
891
|
+
if (this.listeners('command:' + name).length) {
|
892
|
+
this.emit('command:' + args.shift(), args, unknown);
|
893
|
+
} else {
|
894
|
+
this.emit('command:*', args, unknown);
|
895
|
+
}
|
896
|
+
} else {
|
897
|
+
outputHelpIfRequested(this, unknown);
|
898
|
+
|
899
|
+
// If there were no args and we have unknown options,
|
900
|
+
// then they are extraneous and we need to error.
|
901
|
+
if (unknown.length > 0 && !this.defaultExecutable) {
|
902
|
+
this.unknownOption(unknown[0]);
|
903
|
+
}
|
904
|
+
if (this.commands.length === 0 &&
|
905
|
+
this._args.filter(function(a) { return a.required; }).length === 0) {
|
906
|
+
this.emit('command:*');
|
907
|
+
}
|
908
|
+
}
|
909
|
+
|
910
|
+
return this;
|
911
|
+
};
|
912
|
+
|
913
|
+
/**
|
914
|
+
* Return an option matching `arg` if any.
|
915
|
+
*
|
916
|
+
* @param {String} arg
|
917
|
+
* @return {Option}
|
918
|
+
* @api private
|
919
|
+
*/
|
920
|
+
|
921
|
+
Command.prototype.optionFor = function(arg) {
|
922
|
+
for (var i = 0, len = this.options.length; i < len; ++i) {
|
923
|
+
if (this.options[i].is(arg)) {
|
924
|
+
return this.options[i];
|
925
|
+
}
|
926
|
+
}
|
927
|
+
};
|
928
|
+
|
929
|
+
/**
|
930
|
+
* Display an error message if a mandatory option does not have a value.
|
931
|
+
*
|
932
|
+
* @api private
|
933
|
+
*/
|
934
|
+
|
935
|
+
Command.prototype._checkForMissingMandatoryOptions = function() {
|
936
|
+
// Walk up hierarchy so can call from action handler after checking for displaying help.
|
937
|
+
for (var cmd = this; cmd; cmd = cmd.parent) {
|
938
|
+
cmd.options.forEach((anOption) => {
|
939
|
+
if (anOption.mandatory && (cmd._getOptionValue(anOption.attributeName()) === undefined)) {
|
940
|
+
cmd.missingMandatoryOptionValue(anOption);
|
941
|
+
}
|
942
|
+
});
|
943
|
+
}
|
944
|
+
};
|
945
|
+
|
946
|
+
/**
|
947
|
+
* Parse options from `argv` returning `argv`
|
948
|
+
* void of these options.
|
949
|
+
*
|
950
|
+
* @param {Array} argv
|
951
|
+
* @return {{args: Array, unknown: Array}}
|
952
|
+
* @api public
|
953
|
+
*/
|
954
|
+
|
955
|
+
Command.prototype.parseOptions = function(argv) {
|
956
|
+
var args = [],
|
957
|
+
len = argv.length,
|
958
|
+
literal,
|
959
|
+
option,
|
960
|
+
arg;
|
961
|
+
|
962
|
+
var unknownOptions = [];
|
963
|
+
|
964
|
+
// parse options
|
965
|
+
for (var i = 0; i < len; ++i) {
|
966
|
+
arg = argv[i];
|
967
|
+
|
968
|
+
// literal args after --
|
969
|
+
if (literal) {
|
970
|
+
args.push(arg);
|
971
|
+
continue;
|
972
|
+
}
|
973
|
+
|
974
|
+
if (arg === '--') {
|
975
|
+
literal = true;
|
976
|
+
continue;
|
977
|
+
}
|
978
|
+
|
979
|
+
// find matching Option
|
980
|
+
option = this.optionFor(arg);
|
981
|
+
|
982
|
+
// option is defined
|
983
|
+
if (option) {
|
984
|
+
// requires arg
|
985
|
+
if (option.required) {
|
986
|
+
arg = argv[++i];
|
987
|
+
if (arg == null) return this.optionMissingArgument(option);
|
988
|
+
this.emit('option:' + option.name(), arg);
|
989
|
+
// optional arg
|
990
|
+
} else if (option.optional) {
|
991
|
+
arg = argv[i + 1];
|
992
|
+
if (arg == null || (arg[0] === '-' && arg !== '-')) {
|
993
|
+
arg = null;
|
994
|
+
} else {
|
995
|
+
++i;
|
996
|
+
}
|
997
|
+
this.emit('option:' + option.name(), arg);
|
998
|
+
// flag
|
999
|
+
} else {
|
1000
|
+
this.emit('option:' + option.name());
|
1001
|
+
}
|
1002
|
+
continue;
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
// looks like an option
|
1006
|
+
if (arg.length > 1 && arg[0] === '-') {
|
1007
|
+
unknownOptions.push(arg);
|
1008
|
+
|
1009
|
+
// If the next argument looks like it might be
|
1010
|
+
// an argument for this option, we pass it on.
|
1011
|
+
// If it isn't, then it'll simply be ignored
|
1012
|
+
if ((i + 1) < argv.length && (argv[i + 1][0] !== '-' || argv[i + 1] === '-')) {
|
1013
|
+
unknownOptions.push(argv[++i]);
|
1014
|
+
}
|
1015
|
+
continue;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
// arg
|
1019
|
+
args.push(arg);
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
return { args: args, unknown: unknownOptions };
|
1023
|
+
};
|
1024
|
+
|
1025
|
+
/**
|
1026
|
+
* Return an object containing options as key-value pairs
|
1027
|
+
*
|
1028
|
+
* @return {Object}
|
1029
|
+
* @api public
|
1030
|
+
*/
|
1031
|
+
Command.prototype.opts = function() {
|
1032
|
+
if (this._storeOptionsAsProperties) {
|
1033
|
+
// Preserve original behaviour so backwards compatible when still using properties
|
1034
|
+
var result = {},
|
1035
|
+
len = this.options.length;
|
1036
|
+
|
1037
|
+
for (var i = 0; i < len; i++) {
|
1038
|
+
var key = this.options[i].attributeName();
|
1039
|
+
result[key] = key === this._versionOptionName ? this._version : this[key];
|
1040
|
+
}
|
1041
|
+
return result;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
return this._optionValues;
|
1045
|
+
};
|
1046
|
+
|
1047
|
+
/**
|
1048
|
+
* Argument `name` is missing.
|
1049
|
+
*
|
1050
|
+
* @param {String} name
|
1051
|
+
* @api private
|
1052
|
+
*/
|
1053
|
+
|
1054
|
+
Command.prototype.missingArgument = function(name) {
|
1055
|
+
const message = `error: missing required argument '${name}'`;
|
1056
|
+
console.error(message);
|
1057
|
+
this._exit(1, 'commander.missingArgument', message);
|
1058
|
+
};
|
1059
|
+
|
1060
|
+
/**
|
1061
|
+
* `Option` is missing an argument, but received `flag` or nothing.
|
1062
|
+
*
|
1063
|
+
* @param {Option} option
|
1064
|
+
* @param {String} [flag]
|
1065
|
+
* @api private
|
1066
|
+
*/
|
1067
|
+
|
1068
|
+
Command.prototype.optionMissingArgument = function(option, flag) {
|
1069
|
+
let message;
|
1070
|
+
if (flag) {
|
1071
|
+
message = `error: option '${option.flags}' argument missing, got '${flag}'`;
|
1072
|
+
} else {
|
1073
|
+
message = `error: option '${option.flags}' argument missing`;
|
1074
|
+
}
|
1075
|
+
console.error(message);
|
1076
|
+
this._exit(1, 'commander.optionMissingArgument', message);
|
1077
|
+
};
|
1078
|
+
|
1079
|
+
/**
|
1080
|
+
* `Option` does not have a value, and is a mandatory option.
|
1081
|
+
*
|
1082
|
+
* @param {Option} option
|
1083
|
+
* @api private
|
1084
|
+
*/
|
1085
|
+
|
1086
|
+
Command.prototype.missingMandatoryOptionValue = function(option) {
|
1087
|
+
const message = `error: required option '${option.flags}' not specified`;
|
1088
|
+
console.error(message);
|
1089
|
+
this._exit(1, 'commander.missingMandatoryOptionValue', message);
|
1090
|
+
};
|
1091
|
+
|
1092
|
+
/**
|
1093
|
+
* Unknown option `flag`.
|
1094
|
+
*
|
1095
|
+
* @param {String} flag
|
1096
|
+
* @api private
|
1097
|
+
*/
|
1098
|
+
|
1099
|
+
Command.prototype.unknownOption = function(flag) {
|
1100
|
+
if (this._allowUnknownOption) return;
|
1101
|
+
const message = `error: unknown option '${flag}'`;
|
1102
|
+
console.error(message);
|
1103
|
+
this._exit(1, 'commander.unknownOption', message);
|
1104
|
+
};
|
1105
|
+
|
1106
|
+
/**
|
1107
|
+
* Variadic argument with `name` is not the last argument as required.
|
1108
|
+
*
|
1109
|
+
* @param {String} name
|
1110
|
+
* @api private
|
1111
|
+
*/
|
1112
|
+
|
1113
|
+
Command.prototype.variadicArgNotLast = function(name) {
|
1114
|
+
const message = `error: variadic arguments must be last '${name}'`;
|
1115
|
+
console.error(message);
|
1116
|
+
this._exit(1, 'commander.variadicArgNotLast', message);
|
1117
|
+
};
|
1118
|
+
|
1119
|
+
/**
|
1120
|
+
* Set the program version to `str`.
|
1121
|
+
*
|
1122
|
+
* This method auto-registers the "-V, --version" flag
|
1123
|
+
* which will print the version number when passed.
|
1124
|
+
*
|
1125
|
+
* You can optionally supply the flags and description to override the defaults.
|
1126
|
+
*
|
1127
|
+
* @param {String} str
|
1128
|
+
* @param {String} [flags]
|
1129
|
+
* @param {String} [description]
|
1130
|
+
* @return {Command} for chaining
|
1131
|
+
* @api public
|
1132
|
+
*/
|
1133
|
+
|
1134
|
+
Command.prototype.version = function(str, flags, description) {
|
1135
|
+
if (arguments.length === 0) return this._version;
|
1136
|
+
this._version = str;
|
1137
|
+
flags = flags || '-V, --version';
|
1138
|
+
description = description || 'output the version number';
|
1139
|
+
var versionOption = new Option(flags, description);
|
1140
|
+
this._versionOptionName = versionOption.long.substr(2) || 'version';
|
1141
|
+
this.options.push(versionOption);
|
1142
|
+
var self = this;
|
1143
|
+
this.on('option:' + this._versionOptionName, function() {
|
1144
|
+
process.stdout.write(str + '\n');
|
1145
|
+
self._exit(0, 'commander.version', str);
|
1146
|
+
});
|
1147
|
+
return this;
|
1148
|
+
};
|
1149
|
+
|
1150
|
+
/**
|
1151
|
+
* Set the description to `str`.
|
1152
|
+
*
|
1153
|
+
* @param {String} str
|
1154
|
+
* @param {Object} [argsDescription]
|
1155
|
+
* @return {String|Command}
|
1156
|
+
* @api public
|
1157
|
+
*/
|
1158
|
+
|
1159
|
+
Command.prototype.description = function(str, argsDescription) {
|
1160
|
+
if (arguments.length === 0) return this._description;
|
1161
|
+
this._description = str;
|
1162
|
+
this._argsDescription = argsDescription;
|
1163
|
+
return this;
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
/**
|
1167
|
+
* Set an alias for the command
|
1168
|
+
*
|
1169
|
+
* @param {String} alias
|
1170
|
+
* @return {String|Command}
|
1171
|
+
* @api public
|
1172
|
+
*/
|
1173
|
+
|
1174
|
+
Command.prototype.alias = function(alias) {
|
1175
|
+
var command = this;
|
1176
|
+
if (this.commands.length !== 0) {
|
1177
|
+
command = this.commands[this.commands.length - 1];
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
if (arguments.length === 0) return command._alias;
|
1181
|
+
|
1182
|
+
if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
|
1183
|
+
|
1184
|
+
command._alias = alias;
|
1185
|
+
return this;
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
/**
|
1189
|
+
* Set / get the command usage `str`.
|
1190
|
+
*
|
1191
|
+
* @param {String} [str]
|
1192
|
+
* @return {String|Command}
|
1193
|
+
* @api public
|
1194
|
+
*/
|
1195
|
+
|
1196
|
+
Command.prototype.usage = function(str) {
|
1197
|
+
var args = this._args.map(function(arg) {
|
1198
|
+
return humanReadableArgName(arg);
|
1199
|
+
});
|
1200
|
+
|
1201
|
+
var usage = '[options]' +
|
1202
|
+
(this.commands.length ? ' [command]' : '') +
|
1203
|
+
(this._args.length ? ' ' + args.join(' ') : '');
|
1204
|
+
|
1205
|
+
if (arguments.length === 0) return this._usage || usage;
|
1206
|
+
this._usage = str;
|
1207
|
+
|
1208
|
+
return this;
|
1209
|
+
};
|
1210
|
+
|
1211
|
+
/**
|
1212
|
+
* Get or set the name of the command
|
1213
|
+
*
|
1214
|
+
* @param {String} [str]
|
1215
|
+
* @return {String|Command}
|
1216
|
+
* @api public
|
1217
|
+
*/
|
1218
|
+
|
1219
|
+
Command.prototype.name = function(str) {
|
1220
|
+
if (arguments.length === 0) return this._name;
|
1221
|
+
this._name = str;
|
1222
|
+
return this;
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
/**
|
1226
|
+
* Return prepared commands.
|
1227
|
+
*
|
1228
|
+
* @return {Array}
|
1229
|
+
* @api private
|
1230
|
+
*/
|
1231
|
+
|
1232
|
+
Command.prototype.prepareCommands = function() {
|
1233
|
+
return this.commands.filter(function(cmd) {
|
1234
|
+
return !cmd._noHelp;
|
1235
|
+
}).map(function(cmd) {
|
1236
|
+
var args = cmd._args.map(function(arg) {
|
1237
|
+
return humanReadableArgName(arg);
|
1238
|
+
}).join(' ');
|
1239
|
+
|
1240
|
+
return [
|
1241
|
+
cmd._name +
|
1242
|
+
(cmd._alias ? '|' + cmd._alias : '') +
|
1243
|
+
(cmd.options.length ? ' [options]' : '') +
|
1244
|
+
(args ? ' ' + args : ''),
|
1245
|
+
cmd._description
|
1246
|
+
];
|
1247
|
+
});
|
1248
|
+
};
|
1249
|
+
|
1250
|
+
/**
|
1251
|
+
* Return the largest command length.
|
1252
|
+
*
|
1253
|
+
* @return {Number}
|
1254
|
+
* @api private
|
1255
|
+
*/
|
1256
|
+
|
1257
|
+
Command.prototype.largestCommandLength = function() {
|
1258
|
+
var commands = this.prepareCommands();
|
1259
|
+
return commands.reduce(function(max, command) {
|
1260
|
+
return Math.max(max, command[0].length);
|
1261
|
+
}, 0);
|
1262
|
+
};
|
1263
|
+
|
1264
|
+
/**
|
1265
|
+
* Return the largest option length.
|
1266
|
+
*
|
1267
|
+
* @return {Number}
|
1268
|
+
* @api private
|
1269
|
+
*/
|
1270
|
+
|
1271
|
+
Command.prototype.largestOptionLength = function() {
|
1272
|
+
var options = [].slice.call(this.options);
|
1273
|
+
options.push({
|
1274
|
+
flags: this._helpFlags
|
1275
|
+
});
|
1276
|
+
|
1277
|
+
return options.reduce(function(max, option) {
|
1278
|
+
return Math.max(max, option.flags.length);
|
1279
|
+
}, 0);
|
1280
|
+
};
|
1281
|
+
|
1282
|
+
/**
|
1283
|
+
* Return the largest arg length.
|
1284
|
+
*
|
1285
|
+
* @return {Number}
|
1286
|
+
* @api private
|
1287
|
+
*/
|
1288
|
+
|
1289
|
+
Command.prototype.largestArgLength = function() {
|
1290
|
+
return this._args.reduce(function(max, arg) {
|
1291
|
+
return Math.max(max, arg.name.length);
|
1292
|
+
}, 0);
|
1293
|
+
};
|
1294
|
+
|
1295
|
+
/**
|
1296
|
+
* Return the pad width.
|
1297
|
+
*
|
1298
|
+
* @return {Number}
|
1299
|
+
* @api private
|
1300
|
+
*/
|
1301
|
+
|
1302
|
+
Command.prototype.padWidth = function() {
|
1303
|
+
var width = this.largestOptionLength();
|
1304
|
+
if (this._argsDescription && this._args.length) {
|
1305
|
+
if (this.largestArgLength() > width) {
|
1306
|
+
width = this.largestArgLength();
|
1307
|
+
}
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
if (this.commands && this.commands.length) {
|
1311
|
+
if (this.largestCommandLength() > width) {
|
1312
|
+
width = this.largestCommandLength();
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
return width;
|
1317
|
+
};
|
1318
|
+
|
1319
|
+
/**
|
1320
|
+
* Return help for options.
|
1321
|
+
*
|
1322
|
+
* @return {String}
|
1323
|
+
* @api private
|
1324
|
+
*/
|
1325
|
+
|
1326
|
+
Command.prototype.optionHelp = function() {
|
1327
|
+
var width = this.padWidth();
|
1328
|
+
|
1329
|
+
var columns = process.stdout.columns || 80;
|
1330
|
+
var descriptionWidth = columns - width - 4;
|
1331
|
+
|
1332
|
+
// Append the help information
|
1333
|
+
return this.options.map(function(option) {
|
1334
|
+
const fullDesc = option.description +
|
1335
|
+
((!option.negate && option.defaultValue !== undefined) ? ' (default: ' + JSON.stringify(option.defaultValue) + ')' : '');
|
1336
|
+
return pad(option.flags, width) + ' ' + optionalWrap(fullDesc, descriptionWidth, width + 2);
|
1337
|
+
}).concat([pad(this._helpFlags, width) + ' ' + optionalWrap(this._helpDescription, descriptionWidth, width + 2)])
|
1338
|
+
.join('\n');
|
1339
|
+
};
|
1340
|
+
|
1341
|
+
/**
|
1342
|
+
* Return command help documentation.
|
1343
|
+
*
|
1344
|
+
* @return {String}
|
1345
|
+
* @api private
|
1346
|
+
*/
|
1347
|
+
|
1348
|
+
Command.prototype.commandHelp = function() {
|
1349
|
+
if (!this.commands.length) return '';
|
1350
|
+
|
1351
|
+
var commands = this.prepareCommands();
|
1352
|
+
var width = this.padWidth();
|
1353
|
+
|
1354
|
+
var columns = process.stdout.columns || 80;
|
1355
|
+
var descriptionWidth = columns - width - 4;
|
1356
|
+
|
1357
|
+
return [
|
1358
|
+
'Commands:',
|
1359
|
+
commands.map(function(cmd) {
|
1360
|
+
var desc = cmd[1] ? ' ' + cmd[1] : '';
|
1361
|
+
return (desc ? pad(cmd[0], width) : cmd[0]) + optionalWrap(desc, descriptionWidth, width + 2);
|
1362
|
+
}).join('\n').replace(/^/gm, ' '),
|
1363
|
+
''
|
1364
|
+
].join('\n');
|
1365
|
+
};
|
1366
|
+
|
1367
|
+
/**
|
1368
|
+
* Return program help documentation.
|
1369
|
+
*
|
1370
|
+
* @return {String}
|
1371
|
+
* @api private
|
1372
|
+
*/
|
1373
|
+
|
1374
|
+
Command.prototype.helpInformation = function() {
|
1375
|
+
var desc = [];
|
1376
|
+
if (this._description) {
|
1377
|
+
desc = [
|
1378
|
+
this._description,
|
1379
|
+
''
|
1380
|
+
];
|
1381
|
+
|
1382
|
+
var argsDescription = this._argsDescription;
|
1383
|
+
if (argsDescription && this._args.length) {
|
1384
|
+
var width = this.padWidth();
|
1385
|
+
var columns = process.stdout.columns || 80;
|
1386
|
+
var descriptionWidth = columns - width - 5;
|
1387
|
+
desc.push('Arguments:');
|
1388
|
+
desc.push('');
|
1389
|
+
this._args.forEach(function(arg) {
|
1390
|
+
desc.push(' ' + pad(arg.name, width) + ' ' + wrap(argsDescription[arg.name], descriptionWidth, width + 4));
|
1391
|
+
});
|
1392
|
+
desc.push('');
|
1393
|
+
}
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
var cmdName = this._name;
|
1397
|
+
if (this._alias) {
|
1398
|
+
cmdName = cmdName + '|' + this._alias;
|
1399
|
+
}
|
1400
|
+
var parentCmdNames = '';
|
1401
|
+
for (var parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) {
|
1402
|
+
parentCmdNames = parentCmd.name() + ' ' + parentCmdNames;
|
1403
|
+
}
|
1404
|
+
var usage = [
|
1405
|
+
'Usage: ' + parentCmdNames + cmdName + ' ' + this.usage(),
|
1406
|
+
''
|
1407
|
+
];
|
1408
|
+
|
1409
|
+
var cmds = [];
|
1410
|
+
var commandHelp = this.commandHelp();
|
1411
|
+
if (commandHelp) cmds = [commandHelp];
|
1412
|
+
|
1413
|
+
var options = [
|
1414
|
+
'Options:',
|
1415
|
+
'' + this.optionHelp().replace(/^/gm, ' '),
|
1416
|
+
''
|
1417
|
+
];
|
1418
|
+
|
1419
|
+
return usage
|
1420
|
+
.concat(desc)
|
1421
|
+
.concat(options)
|
1422
|
+
.concat(cmds)
|
1423
|
+
.join('\n');
|
1424
|
+
};
|
1425
|
+
|
1426
|
+
/**
|
1427
|
+
* Output help information for this command.
|
1428
|
+
*
|
1429
|
+
* When listener(s) are available for the helpLongFlag
|
1430
|
+
* those callbacks are invoked.
|
1431
|
+
*
|
1432
|
+
* @api public
|
1433
|
+
*/
|
1434
|
+
|
1435
|
+
Command.prototype.outputHelp = function(cb) {
|
1436
|
+
if (!cb) {
|
1437
|
+
cb = function(passthru) {
|
1438
|
+
return passthru;
|
1439
|
+
};
|
1440
|
+
}
|
1441
|
+
const cbOutput = cb(this.helpInformation());
|
1442
|
+
if (typeof cbOutput !== 'string' && !Buffer.isBuffer(cbOutput)) {
|
1443
|
+
throw new Error('outputHelp callback must return a string or a Buffer');
|
1444
|
+
}
|
1445
|
+
process.stdout.write(cbOutput);
|
1446
|
+
this.emit(this._helpLongFlag);
|
1447
|
+
};
|
1448
|
+
|
1449
|
+
/**
|
1450
|
+
* You can pass in flags and a description to override the help
|
1451
|
+
* flags and help description for your command.
|
1452
|
+
*
|
1453
|
+
* @param {String} [flags]
|
1454
|
+
* @param {String} [description]
|
1455
|
+
* @return {Command}
|
1456
|
+
* @api public
|
1457
|
+
*/
|
1458
|
+
|
1459
|
+
Command.prototype.helpOption = function(flags, description) {
|
1460
|
+
this._helpFlags = flags || this._helpFlags;
|
1461
|
+
this._helpDescription = description || this._helpDescription;
|
1462
|
+
|
1463
|
+
var splitFlags = this._helpFlags.split(/[ ,|]+/);
|
1464
|
+
|
1465
|
+
if (splitFlags.length > 1) this._helpShortFlag = splitFlags.shift();
|
1466
|
+
|
1467
|
+
this._helpLongFlag = splitFlags.shift();
|
1468
|
+
|
1469
|
+
return this;
|
1470
|
+
};
|
1471
|
+
|
1472
|
+
/**
|
1473
|
+
* Output help information and exit.
|
1474
|
+
*
|
1475
|
+
* @param {Function} [cb]
|
1476
|
+
* @api public
|
1477
|
+
*/
|
1478
|
+
|
1479
|
+
Command.prototype.help = function(cb) {
|
1480
|
+
this.outputHelp(cb);
|
1481
|
+
// exitCode: preserving original behaviour which was calling process.exit()
|
1482
|
+
// message: do not have all displayed text available so only passing placeholder.
|
1483
|
+
this._exit(process.exitCode || 0, 'commander.help', '(outputHelp)');
|
1484
|
+
};
|
1485
|
+
|
1486
|
+
/**
|
1487
|
+
* Camel-case the given `flag`
|
1488
|
+
*
|
1489
|
+
* @param {String} flag
|
1490
|
+
* @return {String}
|
1491
|
+
* @api private
|
1492
|
+
*/
|
1493
|
+
|
1494
|
+
function camelcase(flag) {
|
1495
|
+
return flag.split('-').reduce(function(str, word) {
|
1496
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
1497
|
+
});
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
/**
|
1501
|
+
* Pad `str` to `width`.
|
1502
|
+
*
|
1503
|
+
* @param {String} str
|
1504
|
+
* @param {Number} width
|
1505
|
+
* @return {String}
|
1506
|
+
* @api private
|
1507
|
+
*/
|
1508
|
+
|
1509
|
+
function pad(str, width) {
|
1510
|
+
var len = Math.max(0, width - str.length);
|
1511
|
+
return str + Array(len + 1).join(' ');
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
/**
|
1515
|
+
* Wraps the given string with line breaks at the specified width while breaking
|
1516
|
+
* words and indenting every but the first line on the left.
|
1517
|
+
*
|
1518
|
+
* @param {String} str
|
1519
|
+
* @param {Number} width
|
1520
|
+
* @param {Number} indent
|
1521
|
+
* @return {String}
|
1522
|
+
* @api private
|
1523
|
+
*/
|
1524
|
+
function wrap(str, width, indent) {
|
1525
|
+
var regex = new RegExp('.{1,' + (width - 1) + '}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)', 'g');
|
1526
|
+
var lines = str.match(regex) || [];
|
1527
|
+
return lines.map(function(line, i) {
|
1528
|
+
if (line.slice(-1) === '\n') {
|
1529
|
+
line = line.slice(0, line.length - 1);
|
1530
|
+
}
|
1531
|
+
return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line.trimRight();
|
1532
|
+
}).join('\n');
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
/**
|
1536
|
+
* Optionally wrap the given str to a max width of width characters per line
|
1537
|
+
* while indenting with indent spaces. Do not wrap if insufficient width or
|
1538
|
+
* string is manually formatted.
|
1539
|
+
*
|
1540
|
+
* @param {String} str
|
1541
|
+
* @param {Number} width
|
1542
|
+
* @param {Number} indent
|
1543
|
+
* @return {String}
|
1544
|
+
* @api private
|
1545
|
+
*/
|
1546
|
+
function optionalWrap(str, width, indent) {
|
1547
|
+
// Detect manually wrapped and indented strings by searching for line breaks
|
1548
|
+
// followed by multiple spaces/tabs.
|
1549
|
+
if (str.match(/[\n]\s+/)) return str;
|
1550
|
+
// Do not wrap to narrow columns (or can end up with a word per line).
|
1551
|
+
const minWidth = 40;
|
1552
|
+
if (width < minWidth) return str;
|
1553
|
+
|
1554
|
+
return wrap(str, width, indent);
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
/**
|
1558
|
+
* Output help information if help flags specified
|
1559
|
+
*
|
1560
|
+
* @param {Command} cmd - command to output help for
|
1561
|
+
* @param {Array} options - array of options to search for -h or --help
|
1562
|
+
* @api private
|
1563
|
+
*/
|
1564
|
+
|
1565
|
+
function outputHelpIfRequested(cmd, options) {
|
1566
|
+
options = options || [];
|
1567
|
+
|
1568
|
+
for (var i = 0; i < options.length; i++) {
|
1569
|
+
if (options[i] === cmd._helpLongFlag || options[i] === cmd._helpShortFlag) {
|
1570
|
+
cmd.outputHelp();
|
1571
|
+
// (Do not have all displayed text available so only passing placeholder.)
|
1572
|
+
cmd._exit(0, 'commander.helpDisplayed', '(outputHelp)');
|
1573
|
+
}
|
1574
|
+
}
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
/**
|
1578
|
+
* Takes an argument and returns its human readable equivalent for help usage.
|
1579
|
+
*
|
1580
|
+
* @param {Object} arg
|
1581
|
+
* @return {String}
|
1582
|
+
* @api private
|
1583
|
+
*/
|
1584
|
+
|
1585
|
+
function humanReadableArgName(arg) {
|
1586
|
+
var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
|
1587
|
+
|
1588
|
+
return arg.required
|
1589
|
+
? '<' + nameOutput + '>'
|
1590
|
+
: '[' + nameOutput + ']';
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
// for versions before node v0.8 when there weren't `fs.existsSync`
|
1594
|
+
function exists(file) {
|
1595
|
+
try {
|
1596
|
+
if (fs.statSync(file).isFile()) {
|
1597
|
+
return true;
|
1598
|
+
}
|
1599
|
+
} catch (e) {
|
1600
|
+
return false;
|
1601
|
+
}
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
/**
|
1605
|
+
* Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command).
|
1606
|
+
*
|
1607
|
+
* @param {string[]} args - array of arguments from node.execArgv
|
1608
|
+
* @returns {string[]}
|
1609
|
+
* @api private
|
1610
|
+
*/
|
1611
|
+
|
1612
|
+
function incrementNodeInspectorPort(args) {
|
1613
|
+
// Testing for these options:
|
1614
|
+
// --inspect[=[host:]port]
|
1615
|
+
// --inspect-brk[=[host:]port]
|
1616
|
+
// --inspect-port=[host:]port
|
1617
|
+
return args.map((arg) => {
|
1618
|
+
var result = arg;
|
1619
|
+
if (arg.indexOf('--inspect') === 0) {
|
1620
|
+
var debugOption;
|
1621
|
+
var debugHost = '127.0.0.1';
|
1622
|
+
var debugPort = '9229';
|
1623
|
+
var match;
|
1624
|
+
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
1625
|
+
// e.g. --inspect
|
1626
|
+
debugOption = match[1];
|
1627
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
1628
|
+
debugOption = match[1];
|
1629
|
+
if (/^\d+$/.test(match[3])) {
|
1630
|
+
// e.g. --inspect=1234
|
1631
|
+
debugPort = match[3];
|
1632
|
+
} else {
|
1633
|
+
// e.g. --inspect=localhost
|
1634
|
+
debugHost = match[3];
|
1635
|
+
}
|
1636
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
1637
|
+
// e.g. --inspect=localhost:1234
|
1638
|
+
debugOption = match[1];
|
1639
|
+
debugHost = match[3];
|
1640
|
+
debugPort = match[4];
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
if (debugOption && debugPort !== '0') {
|
1644
|
+
result = `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
return result;
|
1648
|
+
});
|
1649
|
+
}
|