1
0
mirror of https://github.com/actions/labeler synced 2026-05-06 03:37:48 +02:00
This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -1,7 +1,62 @@
# Change Log
# Changelog
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.
### [13.1.1](https://www.github.com/yargs/yargs-parser/compare/v13.1.0...v13.1.1) (2019-06-10)
### Bug Fixes
* convert values to strings when tokenizing ([#167](https://www.github.com/yargs/yargs-parser/issues/167)) ([57b7883](https://www.github.com/yargs/yargs-parser/commit/57b7883))
* nargs should allow duplicates when duplicate-arguments-array=false ([#164](https://www.github.com/yargs/yargs-parser/issues/164)) ([47ccb0b](https://www.github.com/yargs/yargs-parser/commit/47ccb0b))
* should populate "_" when given config with "short-option-groups" false ([#179](https://www.github.com/yargs/yargs-parser/issues/179)) ([6055974](https://www.github.com/yargs/yargs-parser/commit/6055974))
## [13.1.0](https://github.com/yargs/yargs-parser/compare/v13.0.0...v13.1.0) (2019-05-05)
### Features
* add `strip-aliased` and `strip-dashed` configuration options. ([#172](https://github.com/yargs/yargs-parser/issues/172)) ([a3936aa](https://github.com/yargs/yargs-parser/commit/a3936aa))
* support boolean which do not consume next argument. ([#171](https://github.com/yargs/yargs-parser/issues/171)) ([0ae7fcb](https://github.com/yargs/yargs-parser/commit/0ae7fcb))
<a name="13.0.0"></a>
# [13.0.0](https://github.com/yargs/yargs-parser/compare/v12.0.0...v13.0.0) (2019-02-02)
### Features
* don't coerce number from string with leading '0' or '+' ([#158](https://github.com/yargs/yargs-parser/issues/158)) ([18d0fd5](https://github.com/yargs/yargs-parser/commit/18d0fd5))
### BREAKING CHANGES
* options with leading '+' or '0' now parse as strings
<a name="12.0.0"></a>
# [12.0.0](https://github.com/yargs/yargs-parser/compare/v11.1.1...v12.0.0) (2019-01-29)
### Bug Fixes
* better handling of quoted strings ([#153](https://github.com/yargs/yargs-parser/issues/153)) ([2fb71b2](https://github.com/yargs/yargs-parser/commit/2fb71b2))
### Features
* default value is now used if no right-hand value provided for numbers/strings ([#156](https://github.com/yargs/yargs-parser/issues/156)) ([5a7c46a](https://github.com/yargs/yargs-parser/commit/5a7c46a))
### BREAKING CHANGES
* a flag with no right-hand value no longer populates defaulted options with `undefined`.
* quotes at beginning and endings of strings are not removed during parsing.
<a name="11.1.1"></a>
## [11.1.1](https://github.com/yargs/yargs-parser/compare/v11.1.0...v11.1.1) (2018-11-19)

67
node_modules/yargs-parser/README.md generated vendored
View File

@@ -58,22 +58,24 @@ Parses command line arguments returning a simple mapping of keys and values.
* `args`: a string or array of strings representing the options to parse.
* `opts`: provide a set of hints indicating how `args` should be parsed:
* `opts.alias`: an object representing the set of aliases for a key: `{alias: {foo: ['f']}}`.
* `opts.array`: indicate that keys should be parsed as an array: `{array: ['foo', 'bar']}`.
Indicate that keys should be parsed as an array and coerced to booleans / numbers:
`{array: [{ key: 'foo', boolean: true }, {key: 'bar', number: true}]}`.
* `opts.array`: indicate that keys should be parsed as an array: `{array: ['foo', 'bar']}`.<br>
Indicate that keys should be parsed as an array and coerced to booleans / numbers:<br>
`{array: [{ key: 'foo', boolean: true }, {key: 'bar', number: true}]}`.
* `opts.boolean`: arguments should be parsed as booleans: `{boolean: ['x', 'y']}`.
* `opts.config`: indicate a key that represents a path to a configuration file (this file will be loaded and parsed).
* `opts.coerce`: provide a custom synchronous function that returns a coerced value from the argument provided
(or throws an error), e.g. `{coerce: {foo: function (arg) {return modifiedArg}}}`.
(or throws an error). For arrays the function is called only once for the entire array:<br>
`{coerce: {foo: function (arg) {return modifiedArg}}}`.
* `opts.config`: indicate a key that represents a path to a configuration file (this file will be loaded and parsed).
* `opts.configObjects`: configuration objects to parse, their properties will be set as arguments:<br>
`{configObjects: [{'x': 5, 'y': 33}, {'z': 44}]}`.
* `opts.configuration`: provide configuration options to the yargs-parser (see: [configuration](#configuration)).
* `opts.count`: indicate a key that should be used as a counter, e.g., `-vvv` = `{v: 3}`.
* `opts.default`: provide default values for keys: `{default: {x: 33, y: 'hello world!'}}`.
* `opts.envPrefix`: environment variables (`process.env`) with the prefix provided should be parsed.
* `opts.narg`: specify that a key requires `n` arguments: `{narg: {x: 2}}`.
* `opts.normalize`: `path.normalize()` will be applied to values set to this key.
* `opts.string`: keys should be treated as strings (even if they resemble a number `-x 33`).
* `opts.configuration`: provide configuration options to the yargs-parser (see: [configuration](#configuration)).
* `opts.number`: keys should be treated as numbers.
* `opts['--']`: arguments after the end-of-options flag `--` will be set to the `argv.['--']` array instead of being set to the `argv._` array.
* `opts.string`: keys should be treated as strings (even if they resemble a number `-x 33`).
**returns:**
@@ -325,20 +327,63 @@ node example.js -a 1 -c 2
* default: `false`.
* key: `halt-at-non-option`.
Should parsing stop at the first text argument? This is similar to how e.g. `ssh` parses its command line.
Should parsing stop at the first positional argument? This is similar to how e.g. `ssh` parses its command line.
_If disabled:_
```sh
node example.js -a run b -x y
{ _: [ 'run', 'b', 'y' ], a: true, x: true }
{ _: [ 'b' ], a: 'run', x: 'y' }
```
_If enabled:_
```sh
node example.js -a run b -x y
{ _: [ 'run', 'b', '-x', 'y' ], a: true }
{ _: [ 'b', '-x', 'y' ], a: 'run' }
```
### strip aliased
* default: `false`
* key: `strip-aliased`
Should aliases be removed before returning results?
_If disabled:_
```sh
node example.js --test-field 1
{ _: [], 'test-field': 1, testField: 1, 'test-alias': 1, testAlias: 1 }
```
_If enabled:_
```sh
node example.js --test-field 1
{ _: [], 'test-field': 1, testField: 1 }
```
### strip dashed
* default: `false`
* key: `strip-dashed`
Should dashed keys be removed before returning results? This option has no effect if
`camel-case-exansion` is disabled.
_If disabled:_
```sh
node example.js --test-field 1
{ _: [], 'test-field': 1, testField: 1 }
```
_If enabled:_
```sh
node example.js --test-field 1
{ _: [], testField: 1 }
```
## Special Thanks

118
node_modules/yargs-parser/index.js generated vendored
View File

@@ -9,9 +9,10 @@ function parse (args, opts) {
// allow a string argument to be passed in rather
// than an argv array.
args = tokenizeArgString(args)
// aliases might have transitive relationships, normalize this.
var aliases = combineAliases(opts.alias || {})
var configuration = assign({
var configuration = Object.assign({
'short-option-groups': true,
'camel-case-expansion': true,
'dot-notation': true,
@@ -23,7 +24,9 @@ function parse (args, opts) {
'populate--': false,
'combine-arrays': false,
'set-placeholder-key': false,
'halt-at-non-option': false
'halt-at-non-option': false,
'strip-aliased': false,
'strip-dashed': false
}, opts.configuration)
var defaults = opts.default || {}
var configObjects = opts.configObjects || []
@@ -32,9 +35,7 @@ function parse (args, opts) {
var notFlagsArgv = notFlagsOption ? '--' : '_'
var newAliases = {}
// allow a i18n handler to be passed in, default to a fake one (util.format).
var __ = opts.__ || function (str) {
return util.format.apply(util, Array.prototype.slice.call(arguments))
}
var __ = opts.__ || util.format
var error = null
var flags = {
aliases: {},
@@ -176,7 +177,7 @@ function parse (args, opts) {
// -- seperated by space.
} else if (arg.match(/^--.+/) || (
!configuration['short-option-groups'] && arg.match(/^-.+/)
!configuration['short-option-groups'] && arg.match(/^-[^-]+/)
)) {
key = arg.match(/^--?(.+)/)[1]
@@ -187,7 +188,7 @@ function parse (args, opts) {
} else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
i = eatArray(i, key, args)
} else {
next = args[i + 1]
next = flags.nargs[key] === 0 ? undefined : args[i + 1]
if (next !== undefined && (!next.match(/^-/) ||
next.match(negative)) &&
@@ -199,7 +200,7 @@ function parse (args, opts) {
setArg(key, next)
i++
} else {
setArg(key, defaultForType(guessType(key, flags)))
setArg(key, defaultValue(key))
}
}
@@ -219,7 +220,7 @@ function parse (args, opts) {
setArg(key, next)
i++
} else {
setArg(key, defaultForType(guessType(key, flags)))
setArg(key, defaultValue(key))
}
} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
letters = arg.slice(1, -1).split('')
@@ -266,7 +267,7 @@ function parse (args, opts) {
broken = true
break
} else {
setArg(letters[j], defaultForType(guessType(letters[j], flags)))
setArg(letters[j], defaultValue(letters[j]))
}
}
@@ -292,7 +293,7 @@ function parse (args, opts) {
setArg(key, next)
i++
} else {
setArg(key, defaultForType(guessType(key, flags)))
setArg(key, defaultValue(key))
}
}
}
@@ -332,6 +333,23 @@ function parse (args, opts) {
argv[notFlagsArgv].push(key)
})
if (configuration['camel-case-expansion'] && configuration['strip-dashed']) {
Object.keys(argv).filter(key => key !== '--' && key.includes('-')).forEach(key => {
delete argv[key]
})
}
if (configuration['strip-aliased']) {
// XXX Switch to [].concat(...Object.values(aliases)) once node.js 6 is dropped
;[].concat(...Object.keys(aliases).map(k => aliases[k])).forEach(alias => {
if (configuration['camel-case-expansion']) {
delete argv[alias.split('.').map(prop => camelCase(prop)).join('.')]
}
delete argv[alias]
})
}
// how many arguments should we consume, based
// on the nargs option?
function eatNargs (i, key, args) {
@@ -403,7 +421,7 @@ function parse (args, opts) {
setKey(argv, splitKey, value)
// handle populating aliases of the full key
if (flags.aliases[key]) {
if (flags.aliases[key] && flags.aliases[key].forEach) {
flags.aliases[key].forEach(function (x) {
x = x.split('.')
setKey(argv, x, value)
@@ -450,6 +468,14 @@ function parse (args, opts) {
}
function processValue (key, val) {
// strings may be quoted, clean this up as we assign values.
if (typeof val === 'string' &&
(val[0] === "'" || val[0] === '"') &&
val[val.length - 1] === val[0]
) {
val = val.substring(1, val.length - 1)
}
// handle parsing boolean arguments --foo=true --bar false.
if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
if (typeof val === 'string') val = val === 'true'
@@ -633,6 +659,10 @@ function parse (args, opts) {
if (!configuration['dot-notation']) keys = [keys.join('.')]
keys.slice(0, -1).forEach(function (key, index) {
// TODO(bcoe): in the next major version of yargs, switch to
// Object.create(null) for dot notation:
key = sanitizeKey(key)
if (typeof o === 'object' && o[key] === undefined) {
o[key] = {}
}
@@ -652,11 +682,21 @@ function parse (args, opts) {
}
})
var key = keys[keys.length - 1]
// TODO(bcoe): in the next major version of yargs, switch to
// Object.create(null) for dot notation:
const key = sanitizeKey(keys[keys.length - 1])
var isTypeArray = checkAllAliases(keys.join('.'), flags.arrays)
var isValueArray = Array.isArray(value)
var duplicate = configuration['duplicate-arguments-array']
const isTypeArray = checkAllAliases(keys.join('.'), flags.arrays)
const isValueArray = Array.isArray(value)
let duplicate = configuration['duplicate-arguments-array']
// nargs has higher priority than duplicate
if (!duplicate && checkAllAliases(key, flags.nargs)) {
duplicate = true
if ((!isUndefined(o[key]) && flags.nargs[key] === 1) || (Array.isArray(o[key]) && o[key].length === flags.nargs[key])) {
o[key] = undefined
}
}
if (value === increment) {
o[key] = increment(o[key])
@@ -678,8 +718,8 @@ function parse (args, opts) {
}
// extend the aliases list with inferred aliases.
function extendAliases () {
Array.prototype.slice.call(arguments).forEach(function (obj) {
function extendAliases (...args) {
args.forEach(function (obj) {
Object.keys(obj || {}).forEach(function (key) {
// short-circuit if we've already added a key
// to the aliases array, for example it might
@@ -740,6 +780,18 @@ function parse (args, opts) {
})
}
// make a best effor to pick a default value
// for an option based on name and type.
function defaultValue (key) {
if (!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts) &&
`${key}` in defaults) {
return defaults[key]
} else {
return defaultForType(guessType(key))
}
}
// return a default value, given the type of a flag.,
// e.g., key of type 'string' will default to '', rather than 'true'.
function defaultForType (type) {
@@ -754,7 +806,7 @@ function parse (args, opts) {
}
// given a flag, enforce a default type.
function guessType (key, flags) {
function guessType (key) {
var type = 'boolean'
if (checkAllAliases(key, flags.strings)) type = 'string'
@@ -765,9 +817,14 @@ function parse (args, opts) {
}
function isNumber (x) {
if (x === null || x === undefined) return false
// if loaded from config, may already be a number.
if (typeof x === 'number') return true
// hexadecimal.
if (/^0x[0-9a-f]+$/i.test(x)) return true
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x)
// don't treat 0123 as a number; as it drops the leading '0'.
if (x.length > 1 && x[0] === '0') return false
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x)
}
function isUndefined (num) {
@@ -830,20 +887,6 @@ function combineAliases (aliases) {
return combined
}
function assign (defaults, configuration) {
var o = {}
configuration = configuration || {}
Object.keys(defaults).forEach(function (k) {
o[k] = defaults[k]
})
Object.keys(configuration).forEach(function (k) {
o[k] = configuration[k]
})
return o
}
// this function should only be called when a count is given as an arg
// it is NOT called to set a default value
// thus we can start the count at 1 instead of 0
@@ -863,4 +906,11 @@ Parser.detailed = function (args, opts) {
return parse(args.slice(), opts)
}
// TODO(bcoe): in the next major version of yargs, switch to
// Object.create(null) for dot notation:
function sanitizeKey (key) {
if (key === '__proto__') return '___proto___'
return key
}
module.exports = Parser

View File

@@ -1,6 +1,8 @@
// take an un-split argv string and tokenize it.
module.exports = function (argString) {
if (Array.isArray(argString)) return argString
if (Array.isArray(argString)) {
return argString.map(e => typeof e !== 'string' ? e + '' : e)
}
argString = argString.trim()
@@ -25,12 +27,9 @@ module.exports = function (argString) {
// don't split the string if we're in matching
// opening or closing single and double quotes.
if (c === opening) {
if (!args[i]) args[i] = ''
opening = null
continue
} else if ((c === "'" || c === '"') && !opening) {
opening = c
continue
}
if (!args[i]) args[i] = ''

View File

@@ -1,33 +1,27 @@
{
"_args": [
[
"yargs-parser@11.1.1",
"/Users/pjquirk/Source/GitHub/actions/labeler"
]
],
"_development": true,
"_from": "yargs-parser@11.1.1",
"_id": "yargs-parser@11.1.1",
"_from": "yargs-parser@^13.1.2",
"_id": "yargs-parser@13.1.2",
"_inBundle": false,
"_integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==",
"_integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
"_location": "/yargs-parser",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "yargs-parser@11.1.1",
"raw": "yargs-parser@^13.1.2",
"name": "yargs-parser",
"escapedName": "yargs-parser",
"rawSpec": "11.1.1",
"rawSpec": "^13.1.2",
"saveSpec": null,
"fetchSpec": "11.1.1"
"fetchSpec": "^13.1.2"
},
"_requiredBy": [
"/yargs"
],
"_resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz",
"_spec": "11.1.1",
"_where": "/Users/pjquirk/Source/GitHub/actions/labeler",
"_resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
"_shasum": "130f09702ebaeef2650d54ce6e3e5706f7a4fb38",
"_spec": "yargs-parser@^13.1.2",
"_where": "/Users/dakale/dev/GitHub/actions/labeler/node_modules/yargs",
"author": {
"name": "Ben Coe",
"email": "ben@npmjs.com"
@@ -35,18 +29,20 @@
"bugs": {
"url": "https://github.com/yargs/yargs-parser/issues"
},
"bundleDependencies": false,
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"deprecated": false,
"description": "the mighty option parser used by yargs",
"devDependencies": {
"chai": "^4.2.0",
"coveralls": "^3.0.2",
"mocha": "^5.2.0",
"nyc": "^13.0.1",
"nyc": "^14.1.0",
"standard": "^12.0.1",
"standard-version": "^4.4.0"
"standard-version": "^6.0.0"
},
"engine": {
"node": ">=6"
@@ -79,5 +75,5 @@
"release": "standard-version",
"test": "nyc mocha test/*.js"
},
"version": "11.1.1"
"version": "13.1.2"
}