yargs 10.1.1 → 11.1.1
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 +49 -0
- package/lib/apply-extends.js +3 -3
- package/lib/validation.js +0 -32
- package/package.json +4 -4
- package/yargs.js +19 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,55 @@
|
|
|
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="11.1.1"></a>
|
|
6
|
+
# [11.1.1](https://github.com/yargs/yargs/compare/v11.1.0...v11.1.1) (2019-10-06)
|
|
7
|
+
|
|
8
|
+
* backport security fix for os-locale.
|
|
9
|
+
|
|
10
|
+
<a name="11.1.0"></a>
|
|
11
|
+
# [11.1.0](https://github.com/yargs/yargs/compare/v11.0.0...v11.1.0) (2018-03-04)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* choose correct config directory when require.main does not exist ([#1056](https://github.com/yargs/yargs/issues/1056)) ([a04678c](https://github.com/yargs/yargs/commit/a04678c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* allow hidden options to be displayed with --show-hidden ([#1061](https://github.com/yargs/yargs/issues/1061)) ([ea862ae](https://github.com/yargs/yargs/commit/ea862ae))
|
|
22
|
+
* extend *.rc files in addition to json ([#1080](https://github.com/yargs/yargs/issues/1080)) ([11691a6](https://github.com/yargs/yargs/commit/11691a6))
|
|
23
|
+
|
|
24
|
+
<a name="11.0.0"></a>
|
|
25
|
+
# [11.0.0](https://github.com/yargs/yargs/compare/v10.1.2...v11.0.0) (2018-01-22)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* Set implicit nargs=1 when type=number requiresArg=true ([#1050](https://github.com/yargs/yargs/issues/1050)) ([2b56812](https://github.com/yargs/yargs/commit/2b56812))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* requiresArg is now simply an alias for nargs(1) ([#1054](https://github.com/yargs/yargs/issues/1054)) ([a3ddacc](https://github.com/yargs/yargs/commit/a3ddacc))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### BREAKING CHANGES
|
|
39
|
+
|
|
40
|
+
* requiresArg now has significantly different error output, matching nargs.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<a name="10.1.2"></a>
|
|
45
|
+
## [10.1.2](https://github.com/yargs/yargs/compare/v10.1.1...v10.1.2) (2018-01-17)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* requiresArg should only be enforced if argument exists ([#1043](https://github.com/yargs/yargs/issues/1043)) ([fbf41ae](https://github.com/yargs/yargs/commit/fbf41ae))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
5
54
|
<a name="10.1.1"></a>
|
|
6
55
|
## [10.1.1](https://github.com/yargs/yargs/compare/v10.1.0...v10.1.1) (2018-01-09)
|
|
7
56
|
|
package/lib/apply-extends.js
CHANGED
|
@@ -6,9 +6,9 @@ const YError = require('./yerror')
|
|
|
6
6
|
|
|
7
7
|
let previouslyVisitedConfigs = []
|
|
8
8
|
|
|
9
|
-
function checkForCircularExtends (
|
|
10
|
-
if (previouslyVisitedConfigs.indexOf(
|
|
11
|
-
throw new YError(`Circular extended configurations: '${
|
|
9
|
+
function checkForCircularExtends (cfgPath) {
|
|
10
|
+
if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
|
|
11
|
+
throw new YError(`Circular extended configurations: '${cfgPath}'.`)
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
package/lib/validation.js
CHANGED
|
@@ -54,38 +54,6 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// make sure that any args that require an
|
|
58
|
-
// value (--foo=bar), have a value.
|
|
59
|
-
self.missingArgumentValue = function missingArgumentValue (argv) {
|
|
60
|
-
const defaultValues = [true, false, '', undefined]
|
|
61
|
-
const options = yargs.getOptions()
|
|
62
|
-
|
|
63
|
-
if (options.requiresArg.length > 0) {
|
|
64
|
-
const missingRequiredArgs = []
|
|
65
|
-
|
|
66
|
-
options.requiresArg.forEach((key) => {
|
|
67
|
-
const value = argv[key]
|
|
68
|
-
|
|
69
|
-
// if a value is explicitly requested,
|
|
70
|
-
// flag argument as missing if it does not
|
|
71
|
-
// look like foo=bar was entered.
|
|
72
|
-
if (~defaultValues.indexOf(value) ||
|
|
73
|
-
(Array.isArray(value) && !value.length)) {
|
|
74
|
-
missingRequiredArgs.push(key)
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
if (missingRequiredArgs.length > 0) {
|
|
79
|
-
usage.fail(__n(
|
|
80
|
-
'Missing argument value: %s',
|
|
81
|
-
'Missing argument values: %s',
|
|
82
|
-
missingRequiredArgs.length,
|
|
83
|
-
missingRequiredArgs.join(', ')
|
|
84
|
-
))
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
57
|
// make sure all the required arguments are present.
|
|
90
58
|
self.requiredArguments = function requiredArguments (argv) {
|
|
91
59
|
const demandedOptions = yargs.getDemandedOptions()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.1.1",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,21 +16,21 @@
|
|
|
16
16
|
"decamelize": "^1.1.1",
|
|
17
17
|
"find-up": "^2.1.0",
|
|
18
18
|
"get-caller-file": "^1.0.1",
|
|
19
|
-
"os-locale": "^
|
|
19
|
+
"os-locale": "^3.1.0",
|
|
20
20
|
"require-directory": "^2.1.1",
|
|
21
21
|
"require-main-filename": "^1.0.1",
|
|
22
22
|
"set-blocking": "^2.0.0",
|
|
23
23
|
"string-width": "^2.0.0",
|
|
24
24
|
"which-module": "^2.0.0",
|
|
25
25
|
"y18n": "^3.2.1",
|
|
26
|
-
"yargs-parser": "^
|
|
26
|
+
"yargs-parser": "^9.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"chai": "^4.1.2",
|
|
30
30
|
"chalk": "^1.1.3",
|
|
31
31
|
"coveralls": "^2.11.11",
|
|
32
32
|
"cpr": "^2.0.0",
|
|
33
|
-
"cross-spawn": "^
|
|
33
|
+
"cross-spawn": "^6.0.4",
|
|
34
34
|
"es6-promise": "^4.0.2",
|
|
35
35
|
"hashish": "0.0.4",
|
|
36
36
|
"mocha": "^3.0.1",
|
package/yargs.js
CHANGED
|
@@ -92,7 +92,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
92
92
|
groups = {}
|
|
93
93
|
|
|
94
94
|
const arrayOptions = [
|
|
95
|
-
'array', 'boolean', 'string', '
|
|
95
|
+
'array', 'boolean', 'string', 'skipValidation',
|
|
96
96
|
'count', 'normalize', 'number'
|
|
97
97
|
]
|
|
98
98
|
|
|
@@ -204,7 +204,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
204
204
|
|
|
205
205
|
self.requiresArg = function (keys) {
|
|
206
206
|
argsert('<array|string>', [keys], arguments.length)
|
|
207
|
-
|
|
207
|
+
populateParserHintObject(self.nargs, false, 'narg', keys, 1)
|
|
208
208
|
return self
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -476,17 +476,17 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
476
476
|
return self
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
-
self.pkgConf = function pkgConf (key,
|
|
480
|
-
argsert('<string> [string]', [key,
|
|
479
|
+
self.pkgConf = function pkgConf (key, rootPath) {
|
|
480
|
+
argsert('<string> [string]', [key, rootPath], arguments.length)
|
|
481
481
|
let conf = null
|
|
482
482
|
// prefer cwd to require-main-filename in this method
|
|
483
483
|
// since we're looking for e.g. "nyc" config in nyc consumer
|
|
484
484
|
// rather than "yargs" config in nyc (where nyc is the main filename)
|
|
485
|
-
const obj = pkgUp(
|
|
485
|
+
const obj = pkgUp(rootPath || cwd)
|
|
486
486
|
|
|
487
487
|
// If an object exists in the key, add it to options.configObjects
|
|
488
488
|
if (obj[key] && typeof obj[key] === 'object') {
|
|
489
|
-
conf = applyExtends(obj[key],
|
|
489
|
+
conf = applyExtends(obj[key], rootPath || cwd)
|
|
490
490
|
options.configObjects = (options.configObjects || []).concat(conf)
|
|
491
491
|
}
|
|
492
492
|
|
|
@@ -494,16 +494,24 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
494
494
|
}
|
|
495
495
|
|
|
496
496
|
const pkgs = {}
|
|
497
|
-
function pkgUp (
|
|
498
|
-
const npath =
|
|
497
|
+
function pkgUp (rootPath) {
|
|
498
|
+
const npath = rootPath || '*'
|
|
499
499
|
if (pkgs[npath]) return pkgs[npath]
|
|
500
500
|
const findUp = require('find-up')
|
|
501
501
|
|
|
502
502
|
let obj = {}
|
|
503
503
|
try {
|
|
504
|
+
let startDir = rootPath || require('require-main-filename')(parentRequire || require)
|
|
505
|
+
|
|
506
|
+
// When called in an environment that lacks require.main.filename, such as a jest test runner,
|
|
507
|
+
// startDir is already process.cwd(), and should not be shortened.
|
|
508
|
+
// Whether or not it is _actually_ a directory (e.g., extensionless bin) is irrelevant, find-up handles it.
|
|
509
|
+
if (!rootPath && path.extname(startDir)) {
|
|
510
|
+
startDir = path.dirname(startDir)
|
|
511
|
+
}
|
|
512
|
+
|
|
504
513
|
const pkgJsonPath = findUp.sync('package.json', {
|
|
505
|
-
cwd:
|
|
506
|
-
normalize: false
|
|
514
|
+
cwd: startDir
|
|
507
515
|
})
|
|
508
516
|
obj = JSON.parse(fs.readFileSync(pkgJsonPath))
|
|
509
517
|
} catch (noop) {}
|
|
@@ -964,6 +972,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
964
972
|
|
|
965
973
|
options.__ = y18n.__
|
|
966
974
|
options.configuration = pkgUp()['yargs'] || {}
|
|
975
|
+
|
|
967
976
|
const parsed = Parser.detailed(args, options)
|
|
968
977
|
let argv = parsed.argv
|
|
969
978
|
if (parseContext) argv = Object.assign({}, argv, parseContext)
|
|
@@ -1106,7 +1115,6 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
1106
1115
|
self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors) {
|
|
1107
1116
|
if (parseErrors) throw new YError(parseErrors.message)
|
|
1108
1117
|
validation.nonOptionCount(argv)
|
|
1109
|
-
validation.missingArgumentValue(argv)
|
|
1110
1118
|
validation.requiredArguments(argv)
|
|
1111
1119
|
if (strict) validation.unknownArguments(argv, aliases, positionalMap)
|
|
1112
1120
|
validation.customChecks(argv, aliases)
|