Merge pull request #1142 from tj/develop
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Release 4.1
authored by Tomoaki Abe · committed by GitHub · parents b25cc3a, 1c66935 · Browse files · 21 files·+1082 added−406 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
21 files+1082 added−406 removed
- tests:+160 added−37 removed
- other:+922 added−369 removed
Provenance
- Commit
8e1cdf5- Tree
7840d30- Author
Tomoaki Abe <abe@enzou.tokyo>- Committer
GitHub <noreply@github.com>- Parent 1
b25cc3a- Parent 2
1c66935
21 files changed+1082 added−406 removed
added:changelogs/CHANGELOG-0.md+88 added
1+# Changelog for 0.x2+3+## 0.6.1 / 2012-06-014+5+* Added: append (yes or no) on confirmation6+* Added: allow node.js v0.7.x7+8+## 0.6.0 / 2012-04-109+10+* Added `.prompt(obj, callback)` support. Closes #4911+* Added default support to .choose(). Closes #4112+* Fixed the choice example13+14+## 0.5.1 / 2011-12-2015+16+* Fixed `password()` for recent nodes. Closes #3617+18+## 0.5.0 / 2011-12-0419+20+* Added sub-command option support [itay]21+22+## 0.4.3 / 2011-12-0423+24+* Fixed custom help ordering. Closes #3225+26+## 0.4.2 / 2011-11-2427+28+* Added travis support29+* Fixed: line-buffered input automatically trimmed. Closes #3130+31+## 0.4.1 / 2011-11-1832+33+* Removed listening for "close" on --help34+35+## 0.4.0 / 2011-11-1536+37+* Added support for `--`. Closes #2438+39+## 0.3.3 / 2011-11-1440+41+* Fixed: wait for close event when writing help info [Jerry Hamlet]42+43+## 0.3.2 / 2011-11-0144+45+* Fixed long flag definitions with values [felixge]46+47+## 0.3.1 / 2011-10-3148+49+* Changed `--version` short flag to `-V` from `-v`50+* Changed `.version()` so it's configurable [felixge]51+52+## 0.3.0 / 2011-10-3153+54+* Added support for long flags only. Closes #1855+56+## 0.2.1 / 2011-10-2457+58+* "node": ">= 0.4.x < 0.7.0". Closes #2059+60+## 0.2.0 / 2011-09-2661+62+* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]63+64+## 0.1.0 / 2011-08-2465+66+* Added support for custom `--help` output67+68+## 0.0.5 / 2011-08-1869+70+* Changed: when the user enters nothing prompt for password again71+* Fixed issue with passwords beginning with numbers [NuckChorris]72+73+## 0.0.4 / 2011-08-1574+75+* Fixed `Commander#args`76+77+## 0.0.3 / 2011-08-1578+79+* Added default option value support80+81+## 0.0.2 / 2011-08-1582+83+* Added mask support to `Command#password(str[, mask], fn)`84+* Added `Command#password(str, fn)`85+86+## 0.0.1 / 2010-01-0387+88+* Initial releaseadded:changelogs/CHANGELOG-1.md+56 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# Changelog for 1.x
## 1.3.2 / 2013-07-18
* add support for sub-commands to co-exist with the original command
## 1.3.1 / 2013-07-18
* add quick .runningCommand hack so you can opt-out of other logic when running a sub command
## 1.3.0 / 2013-07-09
* add EACCES error handling* fix sub-command --help
## 1.2.0 / 2013-06-13
* allow "-" hyphen as an option argument* support for RegExp coercion
## 1.1.1 / 2012-11-20
* add more sub-command padding* fix .usage() when args are present. Closes #106
## 1.1.0 / 2012-11-16
* add git-style executable subcommand support. Closes #94
## 1.0.5 / 2012-10-09
* fix `--name` clobbering. Closes #92* fix examples/help. Closes #89
## 1.0.4 / 2012-09-03
* add `outputHelp()` method.
## 1.0.3 / 2012-08-30
* remove invalid .version() defaulting
## 1.0.2 / 2012-08-24
* add `--foo=bar` support [arv]* fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
## 1.0.1 / 2012-08-03
* fix issue #56* fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
## 1.0.0 / 2012-07-05
* add support for optional option descriptions* add defaulting of `.version()` to package.json's versionadded:examples/storeOptionsAsProperties-action.js+40 added
12345678910111213141516171819202122232425262728293031323334353637383940#!/usr/bin/env node
// To avoid possible name clashes, you can change the default behaviour// of storing the options values as properties on the command object.// In addition, you can pass just the options to the action handler// instead of a commmand object. This allows simpler code, and is more consistent// with the previous behaviour so less code changes from old code.//// Example output://// $ node storeOptionsAsProperties-action.js show// undefined// undefined//// $ node storeOptionsAsProperties-action.js --name foo show --action jump// jump// foo
const commander = require('../');const program = new commander.Command();
program .storeOptionsAsProperties(false) // <--- change behaviour .passCommandToAction(false); // <--- change behaviour
program .name('my-program-name') .option('-n,--name <name>');
program .command('show') .option('-a,--action <action>') .action((options) => { // <--- passed options, not Command console.log(options.action); // <--- matches old code });
program.parse(process.argv);
const programOptions = program.opts(); // <--- use opts to access option valuesconsole.log(programOptions.name);added:examples/storeOptionsAsProperties-opts.js+38 added
1234567891011121314151617181920212223242526272829303132333435363738#!/usr/bin/env node
// To avoid possible name clashes, you can change the default behaviour// of storing the options values as properties on the command object.// You access the option values using the .opts() function.//// Example output://// $ node storeOptionsAsProperties-opts.js show// undefined// undefined//// $ node storeOptionsAsProperties-opts.js --name foo show --action jump// jump// foo
const commander = require('../');const program = new commander.Command();
program .storeOptionsAsProperties(false); // <--- change behaviour
program .name('my-program-name') .option('-n,--name <name>');
program .command('show') .option('-a,--action <action>') .action((cmd) => { const options = cmd.opts(); // <--- use opts to access option values console.log(options.action); });
program.parse(process.argv);
const programOptions = program.opts(); // <--- use opts to access option valuesconsole.log(programOptions.name);added:examples/storeOptionsAsProperties-problem.js+35 added
1234567891011121314151617181920212223242526272829303132333435#!/usr/bin/env node
// The original and default behaviour is that the option values are stored// as properties on the program (Command). The action handler is passed a// command object (Command) with the options values also stored as properties.// This is very convenient to code, but the downside is possible clashes with// existing properties of Command.//// Example output, note the issues in the first call://// $ node storeOptionsAsProperties-problem.js show// [Function]// [Function]//// $ node storeOptionsAsProperties-problem.js --name foo show --action jump// jump// foo
const commander = require('../');const program = new commander.Command();
program .name('my-program-name') .option('-n,--name <name>'); // Oops, clash with .name()
program .command('show') .option('-a,--action <action>') // Oops, clash with .action() .action((cmd) => { console.log(cmd.action); });
program.parse(process.argv);
console.log(program.name);modified:tests/command.action.test.js+16 added
86 unmodified lines8788899091929394959697989910010110210310410510686 unmodified lines program.parse(['node', 'test', 'a']);
expect(actionMock).toHaveBeenCalledWith('a', program);});
test('when action is async then can await parseAsync', async() => { let asyncFinished = false; async function delay() { await new Promise(resolve => setTimeout(resolve, 100)); asyncFinished = true; }; const program = new commander.Command(); program .action(delay);
const later = program.parseAsync(['node', 'test']); expect(asyncFinished).toBe(false); await later; expect(asyncFinished).toBe(true);});modified:tests/command.executableSubcommand.lookup.test.js+4 added-2 removed
87 unmodified lines88 });89 });90 91 test('when subcommand suffix is .ts then lookup succeeds', (done) => {92- jest.setTimeout(20000); // Extend timeout for GitHub Actions92+ // We support looking for ts files for ts-node in particular, but don't need to test ts-node itself.93+ // The program and the subcommand `pm-install.ts` are both plain JavaScript code.94 const binLinkTs = path.join(__dirname, 'fixtures-ts', 'pm.ts');94- childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) {95+ // childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) {96+ childProcess.execFile('node', [binLinkTs, 'install'], function(_error, stdout, stderr) {97 expect(stdout).toBe('install\n');98 done();99 });100 });7 unmodified linesadded:tests/commander.configureCommand.test.js+87 added
1+const commander = require('../');2+3+// Mostly testing direct on program, limited check that (sub)command working same.4+5+// Default behaviours6+7+test('when default then options stored on command', () => {8+ const program = new commander.Command();9+ program10+ .option('--foo <value>', 'description');11+ program.parse(['node', 'test', '--foo', 'bar']);12+ expect(program.foo).toBe('bar');13+});14+15+test('when default then command passed to action', () => {16+ const program = new commander.Command();17+ const callback = jest.fn();18+ program19+ .arguments('<value>')20+ .action(callback);21+ program.parse(['node', 'test', 'value']);22+ expect(callback).toHaveBeenCalledWith('value', program);23+});24+25+// storeOptionsAsProperties26+27+test('when storeOptionsAsProperties() then options stored on command', () => {28+ const program = new commander.Command();29+ program30+ .storeOptionsAsProperties()31+ .option('--foo <value>', 'description');32+ program.parse(['node', 'test', '--foo', 'bar']);33+ expect(program.foo).toBe('bar');34+});35+36+test('when storeOptionsAsProperties(true) then options stored on command', () => {37+ const program = new commander.Command();38+ program39+ .storeOptionsAsProperties(true)40+ .option('--foo <value>', 'description');41+ program.parse(['node', 'test', '--foo', 'bar']);42+ expect(program.foo).toBe('bar');43+});44+45+test('when storeOptionsAsProperties(false) then options not stored on command', () => {46+ const program = new commander.Command();47+ program48+ .storeOptionsAsProperties(false)49+ .option('--foo <value>', 'description');50+ program.parse(['node', 'test', '--foo', 'bar']);51+ expect(program.foo).toBeUndefined();52+});53+54+// passCommandToAction55+56+test('when passCommandToAction() then command passed to action', () => {57+ const program = new commander.Command();58+ const callback = jest.fn();59+ program60+ .passCommandToAction()61+ .arguments('<value>')62+ .action(callback);63+ program.parse(['node', 'test', 'value']);64+ expect(callback).toHaveBeenCalledWith('value', program);65+});66+67+test('when passCommandToAction(true) then command passed to action', () => {68+ const program = new commander.Command();69+ const callback = jest.fn();70+ program71+ .passCommandToAction(true)72+ .arguments('<value>')73+ .action(callback);74+ program.parse(['node', 'test', 'value']);75+ expect(callback).toHaveBeenCalledWith('value', program);76+});77+78+test('when passCommandToAction(false) then options passed to action', () => {79+ const program = new commander.Command();80+ const callback = jest.fn();81+ program82+ .passCommandToAction(false)83+ .arguments('<value>')84+ .action(callback);85+ program.parse(['node', 'test', 'value']);86+ expect(callback).toHaveBeenCalledWith('value', program.opts());87+});modified:tests/helpwrap.test.js+4 added-4 removed
11 unmodified lines12 const expectedOutput =13 `Usage: [options]14 15 Options:16- -x -extra-long-option-switch kjsahdkajshkahd kajhsd akhds kashd kajhs dkha 17- dkh aksd ka dkha kdh kasd ka kahs dkh sdkh 16+ -x -extra-long-option-switch kjsahdkajshkahd kajhsd akhds kashd kajhs dkha17+ dkh aksd ka dkha kdh kasd ka kahs dkh sdkh18 askdh aksd kashdk ahsd kahs dkha skdh19 -h, --help output usage information20 `;21 11 unmodified lines33 const expectedOutput =34 `Usage: [options]35 36 Options:37- -x -extra-long-option <value> kjsahdkajshkahd kajhsd akhds (default: "aaa 37+ -x -extra-long-option <value> kjsahdkajshkahd kajhsd akhds (default: "aaa38 bbb ccc ddd eee fff ggg")39 -h, --help output usage information40 `;41 16 unmodified lines58 -x -extra-long-option-switch x59 -h, --help output usage information60 61 Commands:62- alpha Lorem mollit quis dolor ex do eu quis ad insa 62+ alpha Lorem mollit quis dolor ex do eu quis ad insa63 a commodo esse.64 `;65 66 expect(program.helpInformation()).toBe(expectedOutput);56 unmodified linesmodified:tests/options.opts.test.js+49 added-31 removed
10 unmodified lines11 program.parse(['node', 'test']);12 expect(program.opts()).toEqual({ version });13 });14 15-test('when boolean flag not specified then not in opts', () => {15+test('when .version used with storeOptionsAsProperties(false) then version not in opts', () => {16+ // New behaviour, stop storing version as an option value.17 const program = new commander.Command();18+ const version = '0.0.1';19 program18- .option('--pepper', 'add pepper');20+ .storeOptionsAsProperties(false)21+ .version(version);22 program.parse(['node', 'test']);23 expect(program.opts()).toEqual({ });24 });25 26+describe.each([true, false])('storeOptionsAsProperties is %s', (storeOptionsAsProperties) => {27+ test('when boolean flag not specified then not in opts', () => {23-test('when boolean flag specified then value true', () => {24- const program = new commander.Command();25- program26- .option('--pepper', 'add pepper');27- program.parse(['node', 'test', '--pepper']);28- expect(program.opts()).toEqual({ pepper: true });29-});28+ const program = new commander.Command();29+ program.storeOptionsAsProperties(storeOptionsAsProperties);30+ program31+ .option('--pepper', 'add pepper');32+ program.parse(['node', 'test']);33+ expect(program.opts()).toEqual({ });34+ });35 31-test('when option with required value not specified then not in opts', () => {32- const program = new commander.Command();33- program34- .option('--pepper <flavour>', 'add pepper');35- program.parse(['node', 'test']);36- expect(program.opts()).toEqual({ });37-});36+ test('when boolean flag specified then value true', () => {37+ const program = new commander.Command();38+ program.storeOptionsAsProperties(storeOptionsAsProperties);39+ program40+ .option('--pepper', 'add pepper');41+ program.parse(['node', 'test', '--pepper']);42+ expect(program.opts()).toEqual({ pepper: true });43+ });44 39-test('when option with required value specified then value as specified', () => {40- const pepperValue = 'red';41- const program = new commander.Command();42- program43- .option('--pepper <flavour>', 'add pepper');44- program.parse(['node', 'test', '--pepper', pepperValue]);45- expect(program.opts()).toEqual({ pepper: pepperValue });46-});45+ test('when option with required value not specified then not in opts', () => {46+ const program = new commander.Command();47+ program.storeOptionsAsProperties(storeOptionsAsProperties);48+ program49+ .option('--pepper <flavour>', 'add pepper');50+ program.parse(['node', 'test']);51+ expect(program.opts()).toEqual({ });52+ });53 48-test('when option with default value not specified then default value in opts', () => {49- const pepperDefault = 'red';50- const program = new commander.Command();51- program52- .option('--pepper <flavour>', 'add pepper', pepperDefault);53- program.parse(['node', 'test']);54- expect(program.opts()).toEqual({ pepper: pepperDefault });54+ test('when option with required value specified then value as specified', () => {55+ const pepperValue = 'red';56+ const program = new commander.Command();57+ program.storeOptionsAsProperties(storeOptionsAsProperties);58+ program59+ .option('--pepper <flavour>', 'add pepper');60+ program.parse(['node', 'test', '--pepper', pepperValue]);61+ expect(program.opts()).toEqual({ pepper: pepperValue });62+ });63+64+ test('when option with default value not specified then default value in opts', () => {65+ const pepperDefault = 'red';66+ const program = new commander.Command();67+ program.storeOptionsAsProperties(storeOptionsAsProperties);68+ program69+ .option('--pepper <flavour>', 'add pepper', pepperDefault);70+ program.parse(['node', 'test']);71+ expect(program.opts()).toEqual({ pepper: pepperDefault });72+ });73 });modified:typings/commander-tests.ts+9 added
8 unmodified lines9 const errorInstance = new program.CommanderError(1, 'code', 'message');10 11 const name = program.name();12 13+program.storeOptionsAsProperties(true);14+program.passCommandToAction(true);15+16 program17 .name('set name')18 .version('0.0.1')19 .option('-p, --peppers', 'Add peppers')112 unmodified lines132 });133 134 program.parse(process.argv);135 136+program.parseAsync(process.argv).then(() => {137+ console.log('parseAsync success');138+}).catch(err => {139+ console.log('parseAsync failed');140+});141+142 console.log('stuff');modified:typings/index.d.ts+55 added-46 removed
1-// Type definitions for commander 2.112-// Project: https://github.com/visionmedia/commander.js3-// Definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>4-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped1+// Type definitions for commander2+// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>3 4 ///<reference types="node" />5 6 declare namespace commander {29 unmodified lines36 * This method auto-registers the "-V, --version" flag37 * which will print the version number when passed.38 * 39 * You can optionally supply the flags and description to override the defaults.42- *40 */41 version(str: string, flags?: string, description?: string): Command;42 43 /**39 unmodified lines83 84 /**85 * Define argument syntax for the top-level command.86 *90- * @param {string} desc91- * @returns {Command} for chaining87+ * @returns Command for chaining88 */89 arguments(desc: string): Command;90 91 /**92 * Parse expected `args`.93 *94 * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.95 *100- * @param {string[]} args101- * @returns {Command} for chaining96+ * @returns Command for chaining97 */98 parseExpectedArgs(args: string[]): Command;99 100 /**11 unmodified lines112 * .action(function() {113 * // output help here114 * });115 *121- * @param {(...args: any[]) => void} fn122- * @returns {Command} for chaining116+ * @returns Command for chaining117 */118 action(fn: (...args: any[]) => void): Command;119 120 /**35 unmodified lines156 *157 * // optional argument158 * program.option('-c, --cheese [type]', 'add cheese [marble]');159 *166- * @param {string} flags167- * @param {string} [description]168- * @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default169- * @param {*} [defaultValue]170- * @returns {Command} for chaining160+ * @returns Command for chaining161 */162 option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;163 option(flags: string, description?: string, defaultValue?: any): Command;164 5 unmodified lines170 */171 requiredOption(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;172 requiredOption(flags: string, description?: string, defaultValue?: any): Command;173 174+175 /**176+ * Whether to store option values as properties on command object,177+ * or store separately (specify false). In both cases the option values can be accessed using .opts().178+ *179+ * @return Command for chaining180+ */181+ storeOptionsAsProperties(value?: boolean): Command;182+183+ /**184+ * Whether to pass command to action handler,185+ * or just the options (specify false).186+ * 187+ * @return Command for chaining188+ */189+ passCommandToAction(value?: boolean): Command;190+191+ /**192 * Allow unknown options on the command line.193 *187- * @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options.188- * @returns {Command} for chaining194+ * @param [arg] if `true` or omitted, no error will be thrown for unknown options.195+ * @returns Command for chaining196 */197 allowUnknownOption(arg?: boolean): Command;198 199 /**193- * Parse `argv`, settings options and invoking commands when defined.200+ * Parse `argv`, setting options and invoking commands when defined.201 *195- * @param {string[]} argv196- * @returns {Command} for chaining202+ * @returns Command for chaining203 */204 parse(argv: string[]): Command;205 206 /**201- * Parse options from `argv` returning `argv` void of these options.207+ * Parse `argv`, setting options and invoking commands when defined.208+ * 209+ * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.210 *203- * @param {string[]} argv204- * @returns {ParseOptionsResult}211+ * @returns Promise212 */213+ parseAsync(argv: string[]): Promise<any>;214+215+ /**216+ * Parse options from `argv` returning `argv` void of these options.217+ */218 parseOptions(argv: string[]): commander.ParseOptionsResult;219 220 /**221 * Return an object containing options as key-value pairs210- *211- * @returns {{[key: string]: any}}222 */223 opts(): { [key: string]: any };224 225 /**216- * Set the description to `str`.217- *218- * @param {string} str219- * @param {{[argName: string]: string}} argsDescription220- * @return {(Command | string)}226+ * Set the description.227+ * 228+ * @returns Command for chaining229 */230 description(str: string, argsDescription?: {[argName: string]: string}): Command;231+ /**232+ * Get the description.233+ */234 description(): string;235 236 /**237 * Set an alias for the command.227- *228- * @param {string} alias229- * @return {(Command | string)}238+ * 239+ * @returns Command for chaining240 */241 alias(alias: string): Command;242+ /**243+ * Get alias for the command.244+ */245 alias(): string;246 247 /**235- * Set or get the command usage.236- *237- * @param {string} str238- * @return {(Command | string)}248+ * Set the command usage.249+ * 250+ * @returns Command for chaining251 */252 usage(str: string): Command;253+ /**254+ * Get the command usage.255+ */256 usage(): string;257 258 /**259 * Set the name of the command.245- *246- * @param {string} str247- * @return {Command}260+ * 261+ * @returns Command for chaining262 */263 name(str: string): Command;250-264 /**265 * Get the name of the command.253- *254- * @return {string}266 */267 name(): string;268 269 /**270 * Output help information for this command.271 *272 * When listener(s) are available for the helpLongFlag273 * those callbacks are invoked.263- * 264- * @param {(str: string) => string} [cb]274 */275 outputHelp(cb?: (str: string) => string): void;276 277 /**34 unmodified linesadded:.eslintignore+2 added
1+# We have not configured eslint for TypeScript so avoid bogus error messages in the test file and typings file.2+**/*.tsmodified:.eslintrc.json+2 added-1 removed
2 unmodified lines3 "plugins": ["jest"],4 "rules": {5 "one-var": "off",6 "semi": ["error", "always"],7- "space-before-function-paren": ["error", "never"]7+ "space-before-function-paren": ["error", "never"],8+ "no-else-return": ["error", { "allowElseIf": false }]9 }10 }modified:CHANGELOG.md+30 added-141 removed
5 unmodified lines6 and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). (Format adopted after v3.0.0.)7 8 <!-- markdownlint-disable MD024 -->9 10+## [4.1.0] (2020-01-06)11+12+### Added13+14+- two routines to change how option values are handled, and eliminate name clashes with command properties ([#933] [#1102])15+ - see storeOptionsAsProperties and passCommandToAction in README16+- `.parseAsync` to use instead of `.parse` if supply async action handlers ([#806] [#1118])17+18+### Fixed19+20+- Remove trailing blanks from wrapped help text ([#1096])21+22+### Changed23+24+- update dependencies25+- extend security coverage for Commander 2.x to 2020-02-0326+- improvements to README27+- improvements to TypeScript definition documentation28+- move old versions out of main CHANGELOG29+- removed explicit use of `ts-node` in tests30+31 ## [4.0.1] (2019-11-12)32 33 ### Fixed34 14-* display help when requested, even if there are missing required options [(#1091)]35+* display help when requested, even if there are missing required options ([#1091])36 37 ## [4.0.0] (2019-11-02)38 39 ### Added335 unmodified lines375 ## 2.0.0 / 2013-07-18376 377 * remove input methods (.prompt, .confirm, etc)378 358-## 1.3.2 / 2013-07-18379+## Older versions380 360-* add support for sub-commands to co-exist with the original command381+* [1.x](./changelogs/CHANGELOG-1.md)382+* [0.x](./changelogs/CHANGELOG-0.md)383 362-## 1.3.1 / 2013-07-18363-364-* add quick .runningCommand hack so you can opt-out of other logic when running a sub command365-366-## 1.3.0 / 2013-07-09367-368-* add EACCES error handling369-* fix sub-command --help370-371-## 1.2.0 / 2013-06-13372-373-* allow "-" hyphen as an option argument374-* support for RegExp coercion375-376-## 1.1.1 / 2012-11-20377-378-* add more sub-command padding379-* fix .usage() when args are present. Closes #106380-381-## 1.1.0 / 2012-11-16382-383-* add git-style executable subcommand support. Closes #94384-385-## 1.0.5 / 2012-10-09386-387-* fix `--name` clobbering. Closes #92388-* fix examples/help. Closes #89389-390-## 1.0.4 / 2012-09-03391-392-* add `outputHelp()` method.393-394-## 1.0.3 / 2012-08-30395-396-* remove invalid .version() defaulting397-398-## 1.0.2 / 2012-08-24399-400-* add `--foo=bar` support [arv]401-* fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]402-403-## 1.0.1 / 2012-08-03404-405-* fix issue #56406-* fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())407-408-## 1.0.0 / 2012-07-05409-410-* add support for optional option descriptions411-* add defaulting of `.version()` to package.json's version412-413-## 0.6.1 / 2012-06-01414-415-* Added: append (yes or no) on confirmation416-* Added: allow node.js v0.7.x417-418-## 0.6.0 / 2012-04-10419-420-* Added `.prompt(obj, callback)` support. Closes #49421-* Added default support to .choose(). Closes #41422-* Fixed the choice example423-424-## 0.5.1 / 2011-12-20425-426-* Fixed `password()` for recent nodes. Closes #36427-428-## 0.5.0 / 2011-12-04429-430-* Added sub-command option support [itay]431-432-## 0.4.3 / 2011-12-04433-434-* Fixed custom help ordering. Closes #32435-436-## 0.4.2 / 2011-11-24437-438-* Added travis support439-* Fixed: line-buffered input automatically trimmed. Closes #31440-441-## 0.4.1 / 2011-11-18442-443-* Removed listening for "close" on --help444-445-## 0.4.0 / 2011-11-15446-447-* Added support for `--`. Closes #24448-449-## 0.3.3 / 2011-11-14450-451-* Fixed: wait for close event when writing help info [Jerry Hamlet]452-453-## 0.3.2 / 2011-11-01454-455-* Fixed long flag definitions with values [felixge]456-457-## 0.3.1 / 2011-10-31458-459-* Changed `--version` short flag to `-V` from `-v`460-* Changed `.version()` so it's configurable [felixge]461-462-## 0.3.0 / 2011-10-31463-464-* Added support for long flags only. Closes #18465-466-## 0.2.1 / 2011-10-24467-468-* "node": ">= 0.4.x < 0.7.0". Closes #20469-470-## 0.2.0 / 2011-09-26471-472-* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]473-474-## 0.1.0 / 2011-08-24475-476-* Added support for custom `--help` output477-478-## 0.0.5 / 2011-08-18479-480-* Changed: when the user enters nothing prompt for password again481-* Fixed issue with passwords beginning with numbers [NuckChorris]482-483-## 0.0.4 / 2011-08-15484-485-* Fixed `Commander#args`486-487-## 0.0.3 / 2011-08-15488-489-* Added default option value support490-491-## 0.0.2 / 2011-08-15492-493-* Added mask support to `Command#password(str[, mask], fn)`494-* Added `Command#password(str, fn)`495-496-## 0.0.1 / 2010-01-03497-498-* Initial release499-384 [#599]: https://github.com/tj/commander.js/issues/599385 [#611]: https://github.com/tj/commander.js/issues/611386 [#697]: https://github.com/tj/commander.js/issues/697387 [#795]: https://github.com/tj/commander.js/issues/795388+[#806]: https://github.com/tj/commander.js/issues/806389 [#915]: https://github.com/tj/commander.js/issues/915390 [#938]: https://github.com/tj/commander.js/issues/938391 [#963]: https://github.com/tj/commander.js/issues/963392 [#974]: https://github.com/tj/commander.js/issues/974393 [#980]: https://github.com/tj/commander.js/issues/980394 [#987]: https://github.com/tj/commander.js/issues/987395 [#990]: https://github.com/tj/commander.js/issues/990396 [#991]: https://github.com/tj/commander.js/issues/991397+[#993]: https://github.com/tj/commander.js/issues/993398 [#999]: https://github.com/tj/commander.js/issues/999399 [#1010]: https://github.com/tj/commander.js/pull/1010400 [#1018]: https://github.com/tj/commander.js/pull/1018401 [#1026]: https://github.com/tj/commander.js/pull/10269 unmodified lines411 [#1053]: https://github.com/tj/commander.js/pull/1053412 [#1071]: https://github.com/tj/commander.js/pull/1071413 [#1081]: https://github.com/tj/commander.js/pull/1081414 [#1091]: https://github.com/tj/commander.js/pull/1091415+[#1096]: https://github.com/tj/commander.js/pull/1096416+[#1102]: https://github.com/tj/commander.js/pull/1102417+[#1118]: https://github.com/tj/commander.js/pull/1118418 419 [Unreleased]: https://github.com/tj/commander.js/compare/master...develop420 [4.0.1]: https://github.com/tj/commander.js/compare/v4.0.0..v4.0.1421 [4.0.0]: https://github.com/tj/commander.js/compare/v3.0.2..v4.0.06 unmodified linesmodified:index.js+136 added-37 removed
113 unmodified lines114 115 /**116 * Initialize a new `Command`.117 *118- * @param {String} name118+ * @param {String} [name]119 * @api public120 */121 122 function Command(name) {2 unmodified lines125 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 default131+ this._passCommandToAction = true; // backwards compatible by default132+ this._actionResults = [];133 134 this._helpFlags = '-h, --help';135 this._helpDescription = 'output usage information';136 this._helpShortFlag = '-h';17 unmodified lines154 *155 * // Command implemented using separate executable file (description is second parameter to `.command`)156 * program157 * .command('start <service>', 'start named service')154- * .command('stop [service]', 'stop named serice, or all if no name supplied');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)23 unmodified lines186 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 file194 this.commands.push(cmd);195 cmd.parseExpectedArgs(args);132 unmodified lines328 329 var parsed = self.parseOptions(unknown);330 331 // Output help if necessary326- outputHelpIfNecessary(self, parsed.unknown);332+ outputHelpIfRequested(self, parsed.unknown);333 self._checkForMissingMandatoryOptions();334 335 // If there are still any unknown options, then we simply336 // die, unless someone asked for help, in which case we give it19 unmodified lines356 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) {354- actionArgs[expectedArgsCount] = self;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 360- fn.apply(self, actionArgs);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);39 unmodified lines420 // preassign default value for --no-*, [optional], <required>, or plain flag if boolean value421 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 defined423 if (option.negate) {408- var opts = self.opts();409- defaultValue = Object.prototype.hasOwnProperty.call(opts, name) ? opts[name] : true;424+ const positiveLongFlag = option.long.replace(/^--no-/, '--');425+ defaultValue = self.optionFor(positiveLongFlag) ? self._getOptionValue(name) : true;426 }427 // preassign only if we have a default428 if (defaultValue !== undefined) {413- self[name] = defaultValue;429+ self._setOptionValue(name, defaultValue);430 option.defaultValue = defaultValue;431 }432 }433 4 unmodified lines438 // and conditionally invoke the callback439 this.on('option:' + oname, function(val) {440 // coercion441 if (val !== null && fn) {426- val = fn(val, self[name] === undefined ? defaultValue : self[name]);442+ val = fn(val, self._getOptionValue(name) === undefined ? defaultValue : self._getOptionValue(name));443 }444 445 // unassigned or boolean value430- if (typeof self[name] === 'boolean' || typeof self[name] === 'undefined') {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) {433- self[name] = option.negate449+ self._setOptionValue(name, option.negate450 ? false435- : defaultValue || true;451+ : defaultValue || true);452 } else {437- self[name] = val;453+ self._setOptionValue(name, val);454 }455 } else if (val !== null) {456 // reassign441- self[name] = option.negate ? false : val;457+ self._setOptionValue(name, option.negate ? false : val);458 }459 });460 461 return this;85 unmodified lines547 return this;548 };549 550 /**535- * Parse `argv`, settings options and invoking commands when defined.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} value555+ * @return {Command} Command for chaining556+ * @api public557+ */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} value573+ * @return {Command} Command for chaining574+ * @api public575+ */576+577+Command.prototype.passCommandToAction = function(value) {578+ this._passCommandToAction = (value === undefined) || value;579+ return this;580+};581+582+/**583+ * Store option value584 *585+ * @param {String} key586+ * @param {Object} value587+ * @api private588+ */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 value600+ *601+ * @param {String} key602+ * @return {Object} value603+ * @api private604+ */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} argv617 * @return {Command} for chaining618 * @api public619 */75 unmodified lines695 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} argv704+ * @return {Promise}705+ * @api public706+ */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} argv716 * @param {Array} args717 * @param {Array} unknown625- * @param {String} specifySubcommand718+ * @param {String} executableFile719 * @api private720 */721 722 Command.prototype.executeSubCommand = function(argv, args, unknown, executableFile) {170 unmodified lines893 } else {894 this.emit('command:*', args, unknown);895 }896 } else {804- outputHelpIfNecessary(this, unknown);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) {33 unmodified lines935 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) => {846- if (anOption.mandatory && (cmd[anOption.attributeName()] === undefined)) {939+ if (anOption.mandatory && (cmd._getOptionValue(anOption.attributeName()) === undefined)) {940 cmd.missingMandatoryOptionValue(anOption);941 }942 });943 }3 unmodified lines947 * Parse options from `argv` returning `argv`948 * void of these options.949 *950 * @param {Array} argv858- * @return {Array}951+ * @return {{args: Array, unknown: Array}}952 * @api public953 */954 955 Command.prototype.parseOptions = function(argv) {72 unmodified lines1028 * @return {Object}1029 * @api public1030 */1031 Command.prototype.opts = function() {1032+ if (this._storeOptionsAsProperties) {1033+ // Preserve original behaviour so backwards compatible when still using properties939- var result = {},940- len = this.options.length;1034+ var result = {},1035+ len = this.options.length;1036 942- for (var i = 0; i < len; i++) {943- var key = this.options[i].attributeName();944- result[key] = key === this._versionOptionName ? this._version : this[key];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 }946- return result;1043+1044+ return this._optionValues;1045 };1046 1047 /**1048 * Argument `name` is missing.10 unmodified lines1059 1060 /**1061 * `Option` is missing an argument, but received `flag` or nothing.1062 *965- * @param {String} option966- * @param {String} flag1063+ * @param {Option} option1064+ * @param {String} [flag]1065 * @api private1066 */1067 1068 Command.prototype.optionMissingArgument = function(option, flag) {9 unmodified lines1078 1079 /**1080 * `Option` does not have a value, and is a mandatory option.1081 *984- * @param {String} option1082+ * @param {Option} option1083 * @api private1084 */1085 1086 Command.prototype.missingMandatoryOptionValue = function(option) {51 unmodified lines1138 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');1046- this._exit(0, 'commander.version', str);1145+ self._exit(0, 'commander.version', str);1146 });1147 return this;1148 };1149 1150 /**1151 * Set the description to `str`.1152 *1153 * @param {String} str1055- * @param {Object} argsDescription1154+ * @param {Object} [argsDescription]1155 * @return {String|Command}1156 * @api public1157 */1158 28 unmodified lines1187 1188 /**1189 * Set / get the command usage `str`.1190 *1092- * @param {String} str1191+ * @param {String} [str]1192 * @return {String|Command}1193 * @api public1194 */1195 14 unmodified lines1210 1211 /**1212 * Get or set the name of the command1213 *1115- * @param {String} str1214+ * @param {String} [str]1215 * @return {String|Command}1216 * @api public1217 */1218 308 unmodified lines1527 return lines.map(function(line, i) {1528 if (line.slice(-1) === '\n') {1529 line = line.slice(0, line.length - 1);1530 }1432- return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line;1531+ return ((i > 0 && indent) ? Array(indent + 1).join(' ') : '') + line.trimRight();1532 }).join('\n');1533 }1534 1535 /**18 unmodified lines1554 return wrap(str, width, indent);1555 }1556 1557 /**1459- * Output help information if necessary1558+ * Output help information if help flags specified1559 *1461- * @param {Command} command to output help for1462- * @param {Array} array of options to search for -h or --help1560+ * @param {Command} cmd - command to output help for1561+ * @param {Array} options - array of options to search for -h or --help1562 * @api private1563 */1564 1466-function outputHelpIfNecessary(cmd, options) {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) {80 unmodified linesmodified:package-lock.json+302 added-125 removed
1 {2 "name": "commander",3- "version": "4.0.1",3+ "version": "4.1.0",4 "lockfileVersion": 1,5 "requires": true,6 "dependencies": {7 "@babel/code-frame": {424 unmodified lines432 "@types/istanbul-lib-report": "*"433 }434 },435 "@types/jest": {436- "version": "24.0.18",437- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.18.tgz",438- "integrity": "sha512-jcDDXdjTcrQzdN06+TSVsPPqxvsZA/5QkYfIZlq1JMw7FdP5AZylbOc+6B/cuDurctRe+MziUMtQ3xQdrbjqyQ==",436+ "version": "24.0.23",437+ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.23.tgz",438+ "integrity": "sha512-L7MBvwfNpe7yVPTXLn32df/EK+AMBFAFvZrRuArGs7npEWnlziUXK+5GMIUTI4NIuwok3XibsjXCs5HxviYXjg==",439 "dev": true,440 "requires": {441- "@types/jest-diff": "*"441+ "jest-diff": "^24.3.0"442 }443 },444- "@types/jest-diff": {445- "version": "20.0.1",446- "resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz",447- "integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==",448- "dev": true449- },444 "@types/json-schema": {445 "version": "7.0.3",446 "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz",447 "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==",448 "dev": true449 },450 "@types/node": {457- "version": "12.7.8",458- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.8.tgz",459- "integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A==",451+ "version": "12.12.11",452+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz",453+ "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==",454 "dev": true455 },456 "@types/stack-utils": {457 "version": "1.0.1",87 unmodified lines545 }546 }547 },548 "acorn-jsx": {555- "version": "5.0.2",556- "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz",557- "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==",549+ "version": "5.1.0",550+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.1.0.tgz",551+ "integrity": "sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw==",552 "dev": true553 },554 "acorn-walk": {555 "version": "6.2.0",43 unmodified lines599 "micromatch": "^3.1.4",600 "normalize-path": "^2.1.1"601 }602 },609- "arg": {610- "version": "4.1.1",611- "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz",612- "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==",613- "dev": true614- },603 "argparse": {604 "version": "1.0.10",605 "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",606 "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",382 unmodified lines989 }990 }991 },992 "cli-cursor": {1005- "version": "2.1.0",1006- "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",1007- "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",993+ "version": "3.1.0",994+ "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",995+ "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==",996 "dev": true,997 "requires": {1010- "restore-cursor": "^2.0.0"998+ "restore-cursor": "^3.1.0"999 }1000 },1001 "cli-width": {1002 "version": "2.2.0",65 unmodified lines1068 "delayed-stream": "~1.0.0"1069 }1070 },1071 "commander": {1084- "version": "2.20.0",1085- "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",1086- "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",1072+ "version": "2.20.3",1073+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",1074+ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",1075 "dev": true,1076 "optional": true1077 },1078 "component-emitter": {220 unmodified lines1299 "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz",1300 "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=",1301 "dev": true1302 },1315- "diff": {1316- "version": "4.0.1",1317- "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz",1318- "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==",1319- "dev": true1320- },1303 "diff-sequences": {1304 "version": "24.9.0",1305 "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz",1306 "integrity": "sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==",107 unmodified lines1414 }1415 }1416 },1417 "eslint": {1436- "version": "6.4.0",1437- "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.4.0.tgz",1438- "integrity": "sha512-WTVEzK3lSFoXUovDHEbkJqCVPEPwbhCq4trDktNI6ygs7aO41d4cDT0JFAT5MivzZeVLWlg7vHL+bgrQv/t3vA==",1418+ "version": "6.7.0",1419+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.0.tgz",1420+ "integrity": "sha512-dQpj+PaHKHfXHQ2Imcw5d853PTvkUGbHk/MR68KQUl98EgKDCdh4vLRH1ZxhqeQjQFJeg8fgN0UwmNhN3l8dDQ==",1421 "dev": true,1422 "requires": {1423 "@babel/code-frame": "^7.0.0",1424 "ajv": "^6.10.0",1 unmodified line1426 "cross-spawn": "^6.0.5",1427 "debug": "^4.0.1",1428 "doctrine": "^3.0.0",1429 "eslint-scope": "^5.0.0",1448- "eslint-utils": "^1.4.2",1430+ "eslint-utils": "^1.4.3",1431 "eslint-visitor-keys": "^1.1.0",1450- "espree": "^6.1.1",1432+ "espree": "^6.1.2",1433 "esquery": "^1.0.1",1434 "esutils": "^2.0.2",1435 "file-entry-cache": "^5.0.1",1436 "functional-red-black-tree": "^1.0.1",1437 "glob-parent": "^5.0.0",1456- "globals": "^11.7.0",1438+ "globals": "^12.1.0",1439 "ignore": "^4.0.6",1440 "import-fresh": "^3.0.0",1441 "imurmurhash": "^0.1.4",1460- "inquirer": "^6.4.1",1442+ "inquirer": "^7.0.0",1443 "is-glob": "^4.0.0",1444 "js-yaml": "^3.13.1",1445 "json-stable-stringify-without-jsonify": "^1.0.1",1446 "levn": "^0.3.0",1447 "lodash": "^4.17.14",1448 "minimatch": "^3.0.4",1449 "mkdirp": "^0.5.1",1450 "natural-compare": "^1.4.0",1469- "optionator": "^0.8.2",1451+ "optionator": "^0.8.3",1452 "progress": "^2.0.0",1453 "regexpp": "^2.0.1",1454 "semver": "^6.1.2",1455 "strip-ansi": "^5.2.0",1456 "strip-json-comments": "^3.0.1",1457 "table": "^5.2.3",1458 "text-table": "^0.2.0",1459 "v8-compile-cache": "^2.0.3"1460+ },1461+ "dependencies": {1462+ "eslint-utils": {1463+ "version": "1.4.3",1464+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz",1465+ "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==",1466+ "dev": true,1467+ "requires": {1468+ "eslint-visitor-keys": "^1.1.0"1469+ }1470+ },1471+ "globals": {1472+ "version": "12.3.0",1473+ "resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz",1474+ "integrity": "sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw==",1475+ "dev": true,1476+ "requires": {1477+ "type-fest": "^0.8.1"1478+ }1479+ },1480+ "optionator": {1481+ "version": "0.8.3",1482+ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",1483+ "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",1484+ "dev": true,1485+ "requires": {1486+ "deep-is": "~0.1.3",1487+ "fast-levenshtein": "~2.0.6",1488+ "levn": "~0.3.0",1489+ "prelude-ls": "~1.1.2",1490+ "type-check": "~0.3.2",1491+ "word-wrap": "~1.2.3"1492+ }1493+ },1494+ "type-fest": {1495+ "version": "0.8.1",1496+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",1497+ "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",1498+ "dev": true1499+ }1500 }1501 },1502 "eslint-config-standard": {1503 "version": "14.1.0",277 unmodified lines1781 }1782 }1783 },1784 "eslint-plugin-jest": {1763- "version": "22.17.0",1764- "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.17.0.tgz",1765- "integrity": "sha512-WT4DP4RoGBhIQjv+5D0FM20fAdAUstfYAf/mkufLNTojsfgzc5/IYW22cIg/Q4QBavAZsROQlqppiWDpFZDS8Q==",1785+ "version": "22.21.0",1786+ "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-22.21.0.tgz",1787+ "integrity": "sha512-OaqnSS7uBgcGiqXUiEnjoqxPNKvR4JWG5mSRkzVoR6+vDwlqqp11beeql1hYs0HTbdhiwrxWLxbX0Vx7roG3Ew==",1788 "dev": true,1789 "requires": {1790 "@typescript-eslint/experimental-utils": "^1.13.0"1791 }85 unmodified lines1877 "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==",1878 "dev": true1879 },1880 "espree": {1859- "version": "6.1.1",1860- "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.1.tgz",1861- "integrity": "sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ==",1881+ "version": "6.1.2",1882+ "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz",1883+ "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==",1884 "dev": true,1885 "requires": {1864- "acorn": "^7.0.0",1865- "acorn-jsx": "^5.0.2",1886+ "acorn": "^7.1.0",1887+ "acorn-jsx": "^5.1.0",1888 "eslint-visitor-keys": "^1.1.0"1889 }1890 },1891 "esprima": {259 unmodified lines2151 "bser": "^2.0.0"2152 }2153 },2154 "figures": {2133- "version": "2.0.0",2134- "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",2135- "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",2155+ "version": "3.1.0",2156+ "resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz",2157+ "integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",2158 "dev": true,2159 "requires": {2160 "escape-string-regexp": "^1.0.5"2161 }737 unmodified lines2899 "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",2900 "dev": true2901 },2902 "handlebars": {2881- "version": "4.3.3",2882- "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.3.tgz",2883- "integrity": "sha512-VupOxR91xcGojfINrzMqrvlyYbBs39sXIrWa7YdaQWeBudOlvKEGvCczMfJPgnuwHE/zyH1M6J+IUP6cgDVyxg==",2903+ "version": "4.5.3",2904+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz",2905+ "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==",2906 "dev": true,2907 "requires": {2908 "neo-async": "^2.6.0",2909 "optimist": "^0.6.1",111 unmodified lines3021 "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",3022 "dev": true3023 },3024 "import-fresh": {3003- "version": "3.1.0",3004- "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz",3005- "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==",3025+ "version": "3.2.1",3026+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",3027+ "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",3028 "dev": true,3029 "requires": {3030 "parent-module": "^1.0.0",3031 "resolve-from": "^4.0.0"31 unmodified lines3063 "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",3064 "dev": true3065 },3066 "inquirer": {3045- "version": "6.5.2",3046- "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",3047- "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",3067+ "version": "7.0.0",3068+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz",3069+ "integrity": "sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ==",3070 "dev": true,3071 "requires": {3050- "ansi-escapes": "^3.2.0",3072+ "ansi-escapes": "^4.2.1",3073 "chalk": "^2.4.2",3052- "cli-cursor": "^2.1.0",3074+ "cli-cursor": "^3.1.0",3075 "cli-width": "^2.0.0",3076 "external-editor": "^3.0.3",3055- "figures": "^2.0.0",3056- "lodash": "^4.17.12",3057- "mute-stream": "0.0.7",3077+ "figures": "^3.0.0",3078+ "lodash": "^4.17.15",3079+ "mute-stream": "0.0.8",3080 "run-async": "^2.2.0",3081 "rxjs": "^6.4.0",3060- "string-width": "^2.1.0",3082+ "string-width": "^4.1.0",3083 "strip-ansi": "^5.1.0",3084 "through": "^2.3.6"3085+ },3086+ "dependencies": {3087+ "ansi-escapes": {3088+ "version": "4.3.0",3089+ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz",3090+ "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==",3091+ "dev": true,3092+ "requires": {3093+ "type-fest": "^0.8.1"3094+ }3095+ },3096+ "type-fest": {3097+ "version": "0.8.1",3098+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",3099+ "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",3100+ "dev": true3101+ }3102 }3103 },3104 "invariant": {3105 "version": "2.2.4",958 unmodified lines4064 "dev": true4065 }4066 }4067 },4029- "make-error": {4030- "version": "1.3.5",4031- "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",4032- "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",4033- "dev": true4034- },4068 "makeerror": {4069 "version": "1.0.11",4070 "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.11.tgz",4071 "integrity": "sha1-4BpckQnyr3lmDk6LlYd5AYT1qWw=",59 unmodified lines4131 "mime-db": "1.40.0"4132 }4133 },4134 "mimic-fn": {4102- "version": "1.2.0",4103- "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",4104- "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",4135+ "version": "2.1.0",4136+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",4137+ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",4138 "dev": true4139 },4140 "minimatch": {4141 "version": "3.0.4",46 unmodified lines4188 "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",4189 "dev": true4190 },4191 "mute-stream": {4159- "version": "0.0.7",4160- "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",4161- "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",4192+ "version": "0.0.8",4193+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",4194+ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",4195 "dev": true4196 },4197 "nan": {4198 "version": "2.14.0",256 unmodified lines4455 "wrappy": "1"4456 }4457 },4458 "onetime": {4426- "version": "2.0.1",4427- "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",4428- "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",4459+ "version": "5.1.0",4460+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz",4461+ "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==",4462 "dev": true,4463 "requires": {4431- "mimic-fn": "^1.0.0"4464+ "mimic-fn": "^2.1.0"4465 }4466 },4467 "optimist": {4468 "version": "0.6.1",493 unmodified lines4962 "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",4963 "dev": true4964 },4965 "restore-cursor": {4933- "version": "2.0.0",4934- "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",4935- "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",4966+ "version": "3.1.0",4967+ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",4968+ "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==",4969 "dev": true,4970 "requires": {4938- "onetime": "^2.0.0",4971+ "onetime": "^5.1.0",4972 "signal-exit": "^3.0.2"4973 }4974 },4975 "ret": {425 unmodified lines5401 "eslint-plugin-promise": "~4.2.1",5402 "eslint-plugin-react": "~7.14.2",5403 "eslint-plugin-standard": "~4.0.0",5404 "standard-engine": "^12.0.0"5405+ },5406+ "dependencies": {5407+ "cli-cursor": {5408+ "version": "2.1.0",5409+ "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",5410+ "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",5411+ "dev": true,5412+ "requires": {5413+ "restore-cursor": "^2.0.0"5414+ }5415+ },5416+ "eslint": {5417+ "version": "6.4.0",5418+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.4.0.tgz",5419+ "integrity": "sha512-WTVEzK3lSFoXUovDHEbkJqCVPEPwbhCq4trDktNI6ygs7aO41d4cDT0JFAT5MivzZeVLWlg7vHL+bgrQv/t3vA==",5420+ "dev": true,5421+ "requires": {5422+ "@babel/code-frame": "^7.0.0",5423+ "ajv": "^6.10.0",5424+ "chalk": "^2.1.0",5425+ "cross-spawn": "^6.0.5",5426+ "debug": "^4.0.1",5427+ "doctrine": "^3.0.0",5428+ "eslint-scope": "^5.0.0",5429+ "eslint-utils": "^1.4.2",5430+ "eslint-visitor-keys": "^1.1.0",5431+ "espree": "^6.1.1",5432+ "esquery": "^1.0.1",5433+ "esutils": "^2.0.2",5434+ "file-entry-cache": "^5.0.1",5435+ "functional-red-black-tree": "^1.0.1",5436+ "glob-parent": "^5.0.0",5437+ "globals": "^11.7.0",5438+ "ignore": "^4.0.6",5439+ "import-fresh": "^3.0.0",5440+ "imurmurhash": "^0.1.4",5441+ "inquirer": "^6.4.1",5442+ "is-glob": "^4.0.0",5443+ "js-yaml": "^3.13.1",5444+ "json-stable-stringify-without-jsonify": "^1.0.1",5445+ "levn": "^0.3.0",5446+ "lodash": "^4.17.14",5447+ "minimatch": "^3.0.4",5448+ "mkdirp": "^0.5.1",5449+ "natural-compare": "^1.4.0",5450+ "optionator": "^0.8.2",5451+ "progress": "^2.0.0",5452+ "regexpp": "^2.0.1",5453+ "semver": "^6.1.2",5454+ "strip-ansi": "^5.2.0",5455+ "strip-json-comments": "^3.0.1",5456+ "table": "^5.2.3",5457+ "text-table": "^0.2.0",5458+ "v8-compile-cache": "^2.0.3"5459+ }5460+ },5461+ "figures": {5462+ "version": "2.0.0",5463+ "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",5464+ "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",5465+ "dev": true,5466+ "requires": {5467+ "escape-string-regexp": "^1.0.5"5468+ }5469+ },5470+ "inquirer": {5471+ "version": "6.5.2",5472+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",5473+ "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",5474+ "dev": true,5475+ "requires": {5476+ "ansi-escapes": "^3.2.0",5477+ "chalk": "^2.4.2",5478+ "cli-cursor": "^2.1.0",5479+ "cli-width": "^2.0.0",5480+ "external-editor": "^3.0.3",5481+ "figures": "^2.0.0",5482+ "lodash": "^4.17.12",5483+ "mute-stream": "0.0.7",5484+ "run-async": "^2.2.0",5485+ "rxjs": "^6.4.0",5486+ "string-width": "^2.1.0",5487+ "strip-ansi": "^5.1.0",5488+ "through": "^2.3.6"5489+ }5490+ },5491+ "mimic-fn": {5492+ "version": "1.2.0",5493+ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",5494+ "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",5495+ "dev": true5496+ },5497+ "mute-stream": {5498+ "version": "0.0.7",5499+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",5500+ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",5501+ "dev": true5502+ },5503+ "onetime": {5504+ "version": "2.0.1",5505+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",5506+ "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",5507+ "dev": true,5508+ "requires": {5509+ "mimic-fn": "^1.0.0"5510+ }5511+ },5512+ "restore-cursor": {5513+ "version": "2.0.0",5514+ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",5515+ "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",5516+ "dev": true,5517+ "requires": {5518+ "onetime": "^2.0.0",5519+ "signal-exit": "^3.0.2"5520+ }5521+ },5522+ "string-width": {5523+ "version": "2.1.1",5524+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",5525+ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",5526+ "dev": true,5527+ "requires": {5528+ "is-fullwidth-code-point": "^2.0.0",5529+ "strip-ansi": "^4.0.0"5530+ },5531+ "dependencies": {5532+ "strip-ansi": {5533+ "version": "4.0.0",5534+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",5535+ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",5536+ "dev": true,5537+ "requires": {5538+ "ansi-regex": "^3.0.0"5539+ }5540+ }5541+ }5542+ }5543 }5544 },5545 "standard-engine": {5546 "version": "12.0.0",63 unmodified lines5610 }5611 }5612 },5613 "string-width": {5443- "version": "2.1.1",5444- "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",5445- "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",5614+ "version": "4.2.0",5615+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",5616+ "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",5617 "dev": true,5618 "requires": {5619+ "emoji-regex": "^8.0.0",5448- "is-fullwidth-code-point": "^2.0.0",5449- "strip-ansi": "^4.0.0"5620+ "is-fullwidth-code-point": "^3.0.0",5621+ "strip-ansi": "^6.0.0"5622 },5623 "dependencies": {5624+ "ansi-regex": {5625+ "version": "5.0.0",5626+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",5627+ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",5628+ "dev": true5629+ },5630+ "emoji-regex": {5631+ "version": "8.0.0",5632+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",5633+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",5634+ "dev": true5635+ },5636+ "is-fullwidth-code-point": {5637+ "version": "3.0.0",5638+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",5639+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",5640+ "dev": true5641+ },5642 "strip-ansi": {5453- "version": "4.0.0",5454- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",5455- "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",5643+ "version": "6.0.0",5644+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",5645+ "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",5646 "dev": true,5647 "requires": {5458- "ansi-regex": "^3.0.0"5648+ "ansi-regex": "^5.0.0"5649 }5650 }5651 }5652 },203 unmodified lines5856 "requires": {5857 "punycode": "^2.1.0"5858 }5859 },5670- "ts-node": {5671- "version": "8.4.1",5672- "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.4.1.tgz",5673- "integrity": "sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==",5674- "dev": true,5675- "requires": {5676- "arg": "^4.1.0",5677- "diff": "^4.0.1",5678- "make-error": "^1.1.1",5679- "source-map-support": "^0.5.6",5680- "yn": "^3.0.0"5681- }5682- },5860 "tslib": {5861 "version": "1.10.0",5862 "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",5863 "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",29 unmodified lines5893 "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==",5894 "dev": true5895 },5896 "typescript": {5720- "version": "3.6.3",5721- "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",5722- "integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",5897+ "version": "3.7.2",5898+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz",5899+ "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==",5900 "dev": true5901 },5902 "uglify-js": {5726- "version": "3.6.0",5727- "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",5728- "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",5903+ "version": "3.6.9",5904+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.9.tgz",5905+ "integrity": "sha512-pcnnhaoG6RtrvHJ1dFncAe8Od6Nuy30oaJ82ts6//sGSXOP5UjBMEthiProjXmMNHOfd93sqlkztifFMcb+4yw==",5906 "dev": true,5907 "optional": true,5908 "requires": {5732- "commander": "~2.20.0",5909+ "commander": "~2.20.3",5910 "source-map": "~0.6.1"5911 }5912 },5913 "union-value": {182 unmodified lines6096 "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",6097 "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",6098 "dev": true6099 },6100+ "word-wrap": {6101+ "version": "1.2.3",6102+ "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",6103+ "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",6104+ "dev": true6105+ },6106 "wordwrap": {6107 "version": "1.0.0",6108 "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",6109 "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",115 unmodified lines6225 "requires": {6226 "camelcase": "^5.0.0",6227 "decamelize": "^1.2.0"6228 }6046- },6047- "yn": {6048- "version": "3.1.1",6049- "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",6050- "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",6051- "dev": true6229 }6230 }6231 }modified:package.json+6 added-7 removed
1 {2 "name": "commander",3- "version": "4.0.1",3+ "version": "4.1.0",4 "description": "the complete solution for node.js command-line programs",5 "keywords": [6 "commander",7 "command",17 unmodified lines25 "typings/index.d.ts"26 ],27 "dependencies": {},28 "devDependencies": {29- "@types/jest": "^24.0.18",30- "@types/node": "^12.7.5",31- "eslint": "^6.4.0",32- "eslint-plugin-jest": "^22.17.0",29+ "@types/jest": "^24.0.23",30+ "@types/node": "^12.12.11",31+ "eslint": "^6.7.0",32+ "eslint-plugin-jest": "^22.21.0",33 "jest": "^24.8.0",34 "standard": "^14.3.1",35- "ts-node": "^8.4.1",36- "typescript": "^3.6.3"35+ "typescript": "^3.7.2"36 },37 "typings": "typings/index.d.ts",38 "engines": {39 "node": ">= 6"2 unmodified linesmodified:Readme_zh-CN.md+58 added-4 removed
29 unmodified lines30 - [.helpOption(flags, description)](#helpoptionflags-description)31 - [.help(cb)](#helpcb)32 - [自定义事件监听](#%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6%e7%9b%91%e5%90%ac)33 - [零碎知识](#%e9%9b%b6%e7%a2%8e%e7%9f%a5%e8%af%86)34+ - [避免选项命名冲突](#避免选项命名冲突)35 - [TypeScript](#typescript)35- - [Node 选项例如 `--harmony`](#node-%e9%80%89%e9%a1%b9%e4%be%8b%e5%a6%82---harmony)36+ - [Node 选项例如 --harmony](#node-%e9%80%89%e9%a1%b9%e4%be%8b%e5%a6%82---harmony)37 - [Node 调试](#node-%e8%b0%83%e8%af%95)38 - [重载退出(exit)处理](#%e9%87%8d%e8%bd%bd%e9%80%80%e5%87%baexit%e5%a4%84%e7%90%86)39 - [例子](#%e4%be%8b%e5%ad%90)40 - [许可证](#%e8%ae%b8%e5%8f%af%e8%af%81)41 - [支持](#%e6%94%af%e6%8c%81)42+ - [企业使用Commander](#企业使用Commander)43 44 ## 安装45 46 ```bash22 unmodified lines69 `.option()` 方法用来定义带选项的 commander,同时也用于这些选项的文档。每个选项可以有一个短标识(单个字符)和一个长名字,它们之间用逗号或空格分开。70 71 选项会被放到 Commander 对象的属性上,多词选项如"--template-engine"会被转为驼峰法`program.templateEngine`。多个短标识可以组合为一个参数,如`-a -b -c`等价于`-abc`。72 73+ 另请参看可选的新功能 [避免命名冲突](#避免选项命名冲突).74+75 ### 常用选项类型,boolean和值76 77 最常用的两个选项类型是boolean(选项后面不跟值)和选项跟一个值(使用尖括号声明)。除非在命令行中指定,否则两者都是`undefined`。78 292 unmodified lines371 372 program.parse(process.argv)373 ```374 375+你可以自行实现一个`async`操作处理程序,同时调用`.parseAsync`代替`.parse`。376+377+```js378+async function run() { /* 在这里编写代码 */ }379+380+async function main() {381+ program382+ .command('run')383+ .action(run);384+ await program.parseAsync(process.argv);385+}386+```387+388+389 当一个命令在命令行上被使用时,它的选项必须是合法的。使用任何未知的选项会报错。然而如果一个基于操作的命令没有定义任何操作,那么这些选项是不合法的。390 391 定义配置选项可以随着调用 `.command()` 传递。392 为 `opts.noHelp` 指定 `true` 则该命令不会出现生成的帮助输出里。164 unmodified lines557 ```558 559 ## 零碎知识560 561+### 避免选项命名冲突562+563+Commander原本和默认的行为是将选项值作为program的属性存储的,并且给操作处理程序(action handler)传递了一个将选项值作为属性存储的command对象。564+这样确实使得编程很方便,但是会带来有可能会和Command对象的属性相冲突的缺点。565+566+这里有两种方法来改变着这样的行为,而且我们有可能在将来改变默认的行为567+568+- `storeOptionsAsProperties`: 是否将选项值作为command对象的属性来存储,亦或者分开地存储(指定 false)并使用`.opts()`来获得。569+- `passCommandToAction`: 是否把command对象传递给操作处理程序,亦或者仅仅传递这些选项(指定 false)570+571+```js572+// 文件: ./examples/storeOptionsAsProperties.action.js573+program574+ .storeOptionsAsProperties(false)575+ .passCommandToAction(false);576+577+program578+ .name('my-program-name')579+ .option('-n,--name <name>');580+581+program582+ .command('show')583+ .option('-a,--action <action>')584+ .action((options) => {585+ console.log(options.action);586+ });587+588+program.parse(process.argv);589+590+const programOptions = program.opts();591+console.log(programOptions.name);592+```593+594 ### TypeScript595 596 包里包含 TypeScript 定义文件,但是需要你自己安装 node types。如:597 88 unmodified lines686 [MIT](https://github.com/tj/commander.js/blob/master/LICENSE)687 688 ## 支持689 639-Commander 现在在Node 8以及更高的版本上得到支持。(尽管Commander仍有可能在更低的Node版本上工作,但是Node 8以下版本不再保证相关的测试)690+Commander 4.x版本现在在Node 8以及更高的版本上得到支持,尽管仍有可能在Node 6版本上工作,但是不再保证相关的测试。691+(对于Node版本低于6的情况,建议使用Commander 3.x 或 2.x版本。)692 693 主要的社区支持的免费论坛就在Github上的项目[Issues](https://github.com/tj/commander.js/issues)694 643-[专业支持的commander现在已经可用!](https://tidelift.com/subscription/pkg/npm-commander?utm_source=npm-commander&utm_medium=referral&utm_campaign=readme)695+### 企业使用Commander696 645-Tidelift为软件开发团队提供了购买和维护其软件的单一来源,并由最了解软件的专家提供专业级保证,同时与现有工具无缝集成。697+作为Tidelift订阅的一部分现在可用698+699+Commander和数以千计的其他包的维护者在与Tidelift合作,提供对于企业用来构筑应用的开源依赖的商业支持与维护。通过向相关依赖包的维护者支付一定费用,从而帮助企业节省时间,降低风险,改进代码运行情况。[了解更多](https://tidelift.com/subscription/pkg/npm-commander?utm_source=npm-commander&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)modified:Readme.md+57 added-3 removed
9 unmodified lines10 Read this in other languages: English | [简体中文](./Readme_zh-CN.md)11 12 - [Commander.js](#commanderjs)13 - [Installation](#installation)14- - [Declaring _program_ variable](#declaring-program-variable)14+ - [Declaring program variable](#declaring-program-variable)15 - [Options](#options)16 - [Common option types, boolean and value](#common-option-types-boolean-and-value)17 - [Default option value](#default-option-value)18 - [Other option types, negatable boolean and flag|value](#other-option-types-negatable-boolean-and-flagvalue)11 unmodified lines30 - [.helpOption(flags, description)](#helpoptionflags-description)31 - [.help(cb)](#helpcb)32 - [Custom event listeners](#custom-event-listeners)33 - [Bits and pieces](#bits-and-pieces)34+ - [Avoiding option name clashes](#avoiding-option-name-clashes)35 - [TypeScript](#typescript)35- - [Node options such as `--harmony`](#node-options-such-as---harmony)36+ - [Node options such as --harmony](#node-options-such-as---harmony)37 - [Node debugging](#node-debugging)38 - [Override exit handling](#override-exit-handling)39 - [Examples](#examples)40 - [License](#license)29 unmodified lines70 Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space.71 72 The options can be accessed as properties on the Command object. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. Multiple short flags may be combined as a single arg, for example `-abc` is equivalent to `-a -b -c`.73 74+See also optional new behaviour to [avoid name clashes](#avoiding-option-name-clashes).75+76 ### Common option types, boolean and value77 78 The two most used option types are a boolean flag, and an option which takes a value (declared using angle brackets). Both are `undefined` unless specified on command line.79 296 unmodified lines376 377 program.parse(process.argv)378 ```379 380+You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`.381+382+```js383+async function run() { /* code goes here */ }384+385+async function main() {386+ program387+ .command('run')388+ .action(run);389+ await program.parseAsync(process.argv);390+}391+```392+393 A command's options on the command line are validated when the command is used. Any unknown options will be reported as an error. However, if an action-based command does not define an action, then the options are not validated.394 395 Configuration options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the command from the generated help output.396 168 unmodified lines565 ```566 567 ## Bits and pieces568 569+### Avoiding option name clashes570+571+The original and default behaviour is that the option values are stored572+as properties on the program, and the action handler is passed a573+command object with the options values stored as properties.574+This is very convenient to code, but the downside is possible clashes with575+existing properties of Command.576+577+There are two new routines to change the behaviour, and the default behaviour may change in the future:578+579+- `storeOptionsAsProperties`: whether to store option values as properties on command object, or store separately (specify false) and access using `.opts()`580+- `passCommandToAction`: whether to pass command to action handler,581+or just the options (specify false)582+583+```js584+// file: ./examples/storeOptionsAsProperties.action.js585+program586+ .storeOptionsAsProperties(false)587+ .passCommandToAction(false);588+589+program590+ .name('my-program-name')591+ .option('-n,--name <name>');592+593+program594+ .command('show')595+ .option('-a,--action <action>')596+ .action((options) => {597+ console.log(options.action);598+ });599+600+program.parse(process.argv);601+602+const programOptions = program.opts();603+console.log(programOptions.name);604+```605+606 ### TypeScript607 608 The Commander package includes its TypeScript Definition file, but also requires the node types which you need to install yourself. e.g.609 90 unmodified lines700 [MIT](https://github.com/tj/commander.js/blob/master/LICENSE)701 702 ## Support703 651-Commander is supported on Node 8 and above. (Commander is likely to still work on older versions of Node, but is not tested below Node 8.)704+Commander 4.x is supported on Node 8 and above, and is likely to work with Node 6 but not tested.705+(For versions of Node below Node 6, use Commander 3.x or 2.x.)706 707 The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.708 709 ### Commander for enterprise4 unmodified linesmodified:SECURITY.md+8 added-5 removed
1 # Security Policy2 3 ## Supported Versions4 5-| Version | Supported |6-| ------- | ------------------ |7-| 4.x | :white_check_mark: |8-| 3.x | :white_check_mark: |9-| < 3 | :x: |5+Old versions receive security updates for six months.6 7+| Version | Supported |8+| ------- | ------------------------------------------ |9+| 4.x | :white_check_mark: |10+| 3.x | :white_check_mark: support ends 2020-05-01 |11+| 2.x | :white_check_mark: support ends 2020-02-03 |12+| < 2 | :x: |13+14 ## Reporting a Vulnerability15 16 To report a security vulnerability, please use the17 [Tidelift security contact](https://tidelift.com/security).1 unmodified line