yargs 12.0.1 → 12.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +0 -3
- package/lib/command.js +6 -1
- package/lib/middleware.js +1 -1
- package/lib/usage.js +10 -10
- package/lib/validation.js +1 -1
- package/locales/nb.json +1 -1
- package/locales/nn.json +2 -2
- package/locales/pirate.json +2 -1
- package/package.json +13 -7
- package/yargs.js +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="12.0.5"></a>
|
|
6
|
+
## [12.0.5](https://github.com/yargs/yargs/compare/v12.0.4...v12.0.5) (2018-11-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* allows camel-case, variadic arguments, and strict mode to be combined ([#1247](https://github.com/yargs/yargs/issues/1247)) ([eacc035](https://github.com/yargs/yargs/commit/eacc035))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<a name="12.0.4"></a>
|
|
16
|
+
## [12.0.4](https://github.com/yargs/yargs/compare/v12.0.3...v12.0.4) (2018-11-10)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* don't load config when processing positionals ([5d0dc92](https://github.com/yargs/yargs/commit/5d0dc92))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<a name="12.0.3"></a>
|
|
26
|
+
## [12.0.3](https://github.com/yargs/yargs/compare/v12.0.2...v12.0.3) (2018-10-06)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* $0 contains first arg in bundled electron apps ([#1206](https://github.com/yargs/yargs/issues/1206)) ([567820b](https://github.com/yargs/yargs/commit/567820b))
|
|
32
|
+
* accept single function for middleware ([66fd6f7](https://github.com/yargs/yargs/commit/66fd6f7)), closes [#1214](https://github.com/yargs/yargs/issues/1214) [#1214](https://github.com/yargs/yargs/issues/1214)
|
|
33
|
+
* hide `hidden` options from help output even if they are in a group ([#1221](https://github.com/yargs/yargs/issues/1221)) ([da54028](https://github.com/yargs/yargs/commit/da54028))
|
|
34
|
+
* improve Norwegian Bokmål translations ([#1208](https://github.com/yargs/yargs/issues/1208)) ([a458fa4](https://github.com/yargs/yargs/commit/a458fa4))
|
|
35
|
+
* improve Norwegian Nynorsk translations ([#1207](https://github.com/yargs/yargs/issues/1207)) ([d422eb5](https://github.com/yargs/yargs/commit/d422eb5))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<a name="12.0.2"></a>
|
|
40
|
+
## [12.0.2](https://github.com/yargs/yargs/compare/v12.0.1...v12.0.2) (2018-09-04)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* middleware should work regardless of when method is called ([664b265](https://github.com/yargs/yargs/commit/664b265)), closes [#1178](https://github.com/yargs/yargs/issues/1178)
|
|
46
|
+
* translation not working when using __ with a single parameter ([#1183](https://github.com/yargs/yargs/issues/1183)) ([f449aea](https://github.com/yargs/yargs/commit/f449aea))
|
|
47
|
+
* upgrade os-locale to version that addresses license issue ([#1195](https://github.com/yargs/yargs/issues/1195)) ([efc0970](https://github.com/yargs/yargs/commit/efc0970))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
5
51
|
<a name="12.0.1"></a>
|
|
6
52
|
## [12.0.1](https://github.com/yargs/yargs/compare/v12.0.0...v12.0.1) (2018-06-29)
|
|
7
53
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
[![Build Status][travis-image]][travis-url]
|
|
11
11
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
|
12
12
|
[![NPM version][npm-image]][npm-url]
|
|
13
|
-
[![Windows Tests][windows-image]][windows-url]
|
|
14
13
|
[![js-standard-style][standard-image]][standard-url]
|
|
15
14
|
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
|
|
16
15
|
[![Slack][slack-image]][slack-url]
|
|
@@ -115,8 +114,6 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
|
|
|
115
114
|
[coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
|
|
116
115
|
[npm-url]: https://www.npmjs.com/package/yargs
|
|
117
116
|
[npm-image]: https://img.shields.io/npm/v/yargs.svg
|
|
118
|
-
[windows-url]: https://ci.appveyor.com/project/bcoe/yargs-ljwvf
|
|
119
|
-
[windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs-ljwvf/master.svg?label=Windows%20Tests
|
|
120
117
|
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
|
121
118
|
[standard-url]: http://standardjs.com/
|
|
122
119
|
[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
|
package/lib/command.js
CHANGED
|
@@ -19,7 +19,8 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
|
|
19
19
|
let aliases = []
|
|
20
20
|
handler = handler || (() => {})
|
|
21
21
|
middlewares = middlewares || []
|
|
22
|
-
|
|
22
|
+
globalMiddleware.push(...middlewares)
|
|
23
|
+
middlewares = globalMiddleware
|
|
23
24
|
if (Array.isArray(cmd)) {
|
|
24
25
|
aliases = cmd.slice(1)
|
|
25
26
|
cmd = cmd[0]
|
|
@@ -330,6 +331,7 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
|
|
330
331
|
options.default = Object.assign(parseOptions.default, options.default)
|
|
331
332
|
options.alias = Object.assign(parseOptions.alias, options.alias)
|
|
332
333
|
options.array = options.array.concat(parseOptions.array)
|
|
334
|
+
delete options.config // don't load config when processing positionals.
|
|
333
335
|
|
|
334
336
|
const unparsed = []
|
|
335
337
|
Object.keys(positionalMap).forEach((key) => {
|
|
@@ -356,6 +358,9 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
|
|
356
358
|
|
|
357
359
|
Object.keys(parsed.argv).forEach((key) => {
|
|
358
360
|
if (positionalKeys.indexOf(key) !== -1) {
|
|
361
|
+
// any new aliases need to be placed in positionalMap, which
|
|
362
|
+
// is used for validation.
|
|
363
|
+
if (!positionalMap[key]) positionalMap[key] = parsed.argv[key]
|
|
359
364
|
argv[key] = parsed.argv[key]
|
|
360
365
|
}
|
|
361
366
|
})
|
package/lib/middleware.js
CHANGED
|
@@ -2,7 +2,7 @@ module.exports = function (globalMiddleware, context) {
|
|
|
2
2
|
return function (callback) {
|
|
3
3
|
if (Array.isArray(callback)) {
|
|
4
4
|
Array.prototype.push.apply(globalMiddleware, callback)
|
|
5
|
-
} else if (typeof callback === '
|
|
5
|
+
} else if (typeof callback === 'function') {
|
|
6
6
|
globalMiddleware.push(callback)
|
|
7
7
|
}
|
|
8
8
|
return context
|
package/lib/usage.js
CHANGED
|
@@ -161,13 +161,7 @@ module.exports = function usage (yargs, y18n) {
|
|
|
161
161
|
keys = keys.concat(Object.keys(demandedOptions))
|
|
162
162
|
keys = keys.concat(Object.keys(demandedCommands))
|
|
163
163
|
keys = keys.concat(Object.keys(options.default))
|
|
164
|
-
keys = keys.filter(
|
|
165
|
-
if (options.hiddenOptions.indexOf(key) < 0) {
|
|
166
|
-
return true
|
|
167
|
-
} else if (yargs.parsed.argv[options.showHiddenOpt]) {
|
|
168
|
-
return true
|
|
169
|
-
}
|
|
170
|
-
})
|
|
164
|
+
keys = keys.filter(filterHiddenOptions)
|
|
171
165
|
keys = Object.keys(keys.reduce((acc, key) => {
|
|
172
166
|
if (key !== '_') acc[key] = true
|
|
173
167
|
return acc
|
|
@@ -251,11 +245,9 @@ module.exports = function usage (yargs, y18n) {
|
|
|
251
245
|
Object.keys(groups).forEach((groupName) => {
|
|
252
246
|
if (!groups[groupName].length) return
|
|
253
247
|
|
|
254
|
-
ui.div(__(groupName))
|
|
255
|
-
|
|
256
248
|
// if we've grouped the key 'f', but 'f' aliases 'foobar',
|
|
257
249
|
// normalizedKeys should contain only 'foobar'.
|
|
258
|
-
const normalizedKeys = groups[groupName].map((key) => {
|
|
250
|
+
const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key) => {
|
|
259
251
|
if (~aliasKeys.indexOf(key)) return key
|
|
260
252
|
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
|
|
261
253
|
if (~(options.alias[aliasKey] || []).indexOf(key)) return aliasKey
|
|
@@ -263,6 +255,10 @@ module.exports = function usage (yargs, y18n) {
|
|
|
263
255
|
return key
|
|
264
256
|
})
|
|
265
257
|
|
|
258
|
+
if (normalizedKeys.length < 1) return
|
|
259
|
+
|
|
260
|
+
ui.div(__(groupName))
|
|
261
|
+
|
|
266
262
|
// actually generate the switches string --foo, -f, --bar.
|
|
267
263
|
const switches = normalizedKeys.reduce((acc, key) => {
|
|
268
264
|
acc[key] = [ key ].concat(options.alias[key] || [])
|
|
@@ -420,6 +416,10 @@ module.exports = function usage (yargs, y18n) {
|
|
|
420
416
|
return groupedKeys
|
|
421
417
|
}
|
|
422
418
|
|
|
419
|
+
function filterHiddenOptions (key) {
|
|
420
|
+
return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt]
|
|
421
|
+
}
|
|
422
|
+
|
|
423
423
|
self.showHelp = (level) => {
|
|
424
424
|
const logger = yargs._getLoggerInstance()
|
|
425
425
|
if (!level) level = 'error'
|
package/lib/validation.js
CHANGED
|
@@ -292,7 +292,7 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
292
292
|
// we default keys to 'undefined' that have been configured, we should not
|
|
293
293
|
// apply conflicting check unless they are a value other than 'undefined'.
|
|
294
294
|
if (value && argv[key] !== undefined && argv[value] !== undefined) {
|
|
295
|
-
usage.fail(__(
|
|
295
|
+
usage.fail(__('Arguments %s and %s are mutually exclusive', key, value))
|
|
296
296
|
}
|
|
297
297
|
})
|
|
298
298
|
}
|
package/locales/nb.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"Invalid values:": "Ugyldige verdier:",
|
|
29
29
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gitt: %s, Valg: %s",
|
|
30
|
-
"Argument check failed: %s": "
|
|
30
|
+
"Argument check failed: %s": "Argumentsjekk mislyktes: %s",
|
|
31
31
|
"Implications failed:": "Konsekvensene mislyktes:",
|
|
32
32
|
"Not enough arguments following: %s": "Ikke nok følgende argumenter: %s",
|
|
33
33
|
"Invalid JSON config file: %s": "Ugyldig JSON konfigurasjonsfil: %s",
|
package/locales/nn.json
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"Invalid values:": "Ugyldige verdiar:",
|
|
31
31
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gjeve: %s, Val: %s",
|
|
32
|
-
"Argument check failed: %s": "
|
|
32
|
+
"Argument check failed: %s": "Argumentsjekk mislukkast: %s",
|
|
33
33
|
"Implications failed:": "Konsekvensane mislukkast:",
|
|
34
|
-
"Not enough arguments following: %s": "Ikkje nok
|
|
34
|
+
"Not enough arguments following: %s": "Ikkje nok fylgjande argument: %s",
|
|
35
35
|
"Invalid JSON config file: %s": "Ugyldig JSON konfigurasjonsfil: %s",
|
|
36
36
|
"Path to JSON config file": "Bane til JSON konfigurasjonsfil",
|
|
37
37
|
"Show help": "Vis hjelp",
|
package/locales/pirate.json
CHANGED
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
"other": "Ye be havin' to set the followin' arguments land lubber: %s"
|
|
9
9
|
},
|
|
10
10
|
"Show help": "Parlay this here code of conduct",
|
|
11
|
-
"Show version number": "'Tis the version ye be askin' fer"
|
|
11
|
+
"Show version number": "'Tis the version ye be askin' fer",
|
|
12
|
+
"Arguments %s and %s are mutually exclusive" : "Yon scurvy dogs %s and %s be as bad as rum and a prudish wench"
|
|
12
13
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.5",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Yargs Contributors",
|
|
9
|
+
"url": "https://github.com/yargs/yargs/graphs/contributors"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
6
12
|
"files": [
|
|
7
13
|
"index.js",
|
|
8
14
|
"yargs.js",
|
|
@@ -13,22 +19,22 @@
|
|
|
13
19
|
],
|
|
14
20
|
"dependencies": {
|
|
15
21
|
"cliui": "^4.0.0",
|
|
16
|
-
"decamelize": "^2.0
|
|
22
|
+
"decamelize": "^1.2.0",
|
|
17
23
|
"find-up": "^3.0.0",
|
|
18
24
|
"get-caller-file": "^1.0.1",
|
|
19
|
-
"os-locale": "^
|
|
25
|
+
"os-locale": "^3.0.0",
|
|
20
26
|
"require-directory": "^2.1.1",
|
|
21
27
|
"require-main-filename": "^1.0.1",
|
|
22
28
|
"set-blocking": "^2.0.0",
|
|
23
29
|
"string-width": "^2.0.0",
|
|
24
30
|
"which-module": "^2.0.0",
|
|
25
31
|
"y18n": "^3.2.1 || ^4.0.0",
|
|
26
|
-
"yargs-parser": "^
|
|
32
|
+
"yargs-parser": "^11.1.1"
|
|
27
33
|
},
|
|
28
34
|
"devDependencies": {
|
|
29
35
|
"chai": "^4.1.2",
|
|
30
36
|
"chalk": "^1.1.3",
|
|
31
|
-
"coveralls": "^3.0.
|
|
37
|
+
"coveralls": "^3.0.2",
|
|
32
38
|
"cpr": "^2.0.0",
|
|
33
39
|
"cross-spawn": "^6.0.4",
|
|
34
40
|
"es6-promise": "^4.0.2",
|
|
@@ -49,9 +55,9 @@
|
|
|
49
55
|
},
|
|
50
56
|
"repository": {
|
|
51
57
|
"type": "git",
|
|
52
|
-
"url": "
|
|
58
|
+
"url": "https://github.com/yargs/yargs.git"
|
|
53
59
|
},
|
|
54
|
-
"homepage": "
|
|
60
|
+
"homepage": "https://yargs.js.org/",
|
|
55
61
|
"standard": {
|
|
56
62
|
"ignore": [
|
|
57
63
|
"**/example/**"
|
package/yargs.js
CHANGED
|
@@ -42,12 +42,16 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
42
42
|
return self
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// ignore the node bin, specify this in your
|
|
46
|
+
// bin file with #!/usr/bin/env node
|
|
47
|
+
if (/\b(node|iojs|electron)(\.exe)?$/.test(process.argv[0])) {
|
|
48
|
+
self.$0 = process.argv.slice(1, 2)
|
|
49
|
+
} else {
|
|
50
|
+
self.$0 = process.argv.slice(0, 1)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
self.$0 = self.$0
|
|
47
54
|
.map((x, i) => {
|
|
48
|
-
// ignore the node bin, specify this in your
|
|
49
|
-
// bin file with #!/usr/bin/env node
|
|
50
|
-
if (i === 0 && /\b(node|iojs)(\.exe)?$/.test(x)) return
|
|
51
55
|
const b = rebase(cwd, x)
|
|
52
56
|
return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x
|
|
53
57
|
})
|