Update to NPM version
This commit is contained in:
43
ProjectSourceCode/node_modules/yargs-unparser/CHANGELOG.md
generated
vendored
Normal file
43
ProjectSourceCode/node_modules/yargs-unparser/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# 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.
|
||||
|
||||
## 1.6.0 (2019-07-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **security:** update deps addressing recent audit vulnerabilities ([#40](https://github.com/yargs/yargs-unparser/issues/40)) ([2e74f1b](https://github.com/yargs/yargs-unparser/commit/2e74f1b))
|
||||
* address bug with camelCased flattened keys ([#32](https://github.com/yargs/yargs-unparser/issues/32)) ([981533a](https://github.com/yargs/yargs-unparser/commit/981533a))
|
||||
* **deps:** updated the lodash version to fix vulnerability ([#39](https://github.com/yargs/yargs-unparser/issues/39)) ([7375966](https://github.com/yargs/yargs-unparser/commit/7375966))
|
||||
* **package:** update yargs to version 10.0.3 ([f1eb4cb](https://github.com/yargs/yargs-unparser/commit/f1eb4cb))
|
||||
* **package:** update yargs to version 11.0.0 ([6aa7c91](https://github.com/yargs/yargs-unparser/commit/6aa7c91))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add interoperation with minimist ([ba477f5](https://github.com/yargs/yargs-unparser/commit/ba477f5))
|
||||
|
||||
<a name="1.5.0"></a>
|
||||
# 1.5.0 (2018-11-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **package:** update yargs to version 10.0.3 ([f1eb4cb](https://github.com/yargs/yargs-unparser/commit/f1eb4cb))
|
||||
* **package:** update yargs to version 11.0.0 ([6aa7c91](https://github.com/yargs/yargs-unparser/commit/6aa7c91))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add interoperation with minimist ([ba477f5](https://github.com/yargs/yargs-unparser/commit/ba477f5))
|
||||
|
||||
|
||||
|
||||
<a name="1.4.0"></a>
|
||||
# [1.4.0](https://github.com/moxystudio/yargs-unparser/compare/v1.3.0...v1.4.0) (2017-12-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add interoperation with minimist ([ba477f5](https://github.com/moxystudio/yargs-unparser/commit/ba477f5))
|
||||
21
ProjectSourceCode/node_modules/yargs-unparser/LICENSE
generated
vendored
Normal file
21
ProjectSourceCode/node_modules/yargs-unparser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Made With MOXY Lda <hello@moxy.studio>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
91
ProjectSourceCode/node_modules/yargs-unparser/README.md
generated
vendored
Normal file
91
ProjectSourceCode/node_modules/yargs-unparser/README.md
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# yargs-unparser
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
|
||||
|
||||
[npm-url]:https://npmjs.org/package/yargs-unparser
|
||||
[npm-image]:http://img.shields.io/npm/v/yargs-unparser.svg
|
||||
[downloads-image]:http://img.shields.io/npm/dm/yargs-unparser.svg
|
||||
[travis-url]:https://travis-ci.org/yargs/yargs-unparser
|
||||
[travis-image]:http://img.shields.io/travis/yargs/yargs-unparser/master.svg
|
||||
[codecov-url]:https://codecov.io/gh/yargs/yargs-unparser
|
||||
[codecov-image]:https://img.shields.io/codecov/c/github/yargs/yargs-unparser/master.svg
|
||||
[david-dm-url]:https://david-dm.org/yargs/yargs-unparser
|
||||
[david-dm-image]:https://img.shields.io/david/yargs/yargs-unparser.svg
|
||||
[david-dm-dev-url]:https://david-dm.org/yargs/yargs-unparser?type=dev
|
||||
[david-dm-dev-image]:https://img.shields.io/david/dev/yargs/yargs-unparser.svg
|
||||
[greenkeeper-image]:https://badges.greenkeeper.io/yargs/yargs-unparser.svg
|
||||
[greenkeeper-url]:https://greenkeeper.io
|
||||
|
||||
Converts back a `yargs` argv object to its original array form.
|
||||
|
||||
Probably the unparser word doesn't even exist, but it sounds nice and goes well with [yargs-parser](https://github.com/yargs/yargs-parser).
|
||||
|
||||
The code originally lived in [MOXY](https://github.com/moxystudio)'s GitHub but was later moved here for discoverability.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
`$ npm install yargs-unparser`
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const parse = require('yargs-parser');
|
||||
const unparse = require('yargs-unparser');
|
||||
|
||||
const argv = parse(['--no-boolean', '--number', '4', '--string', 'foo'], {
|
||||
boolean: ['boolean'],
|
||||
number: ['number'],
|
||||
string: ['string'],
|
||||
});
|
||||
// { boolean: false, number: 4, string: 'foo', _: [] }
|
||||
|
||||
const unparsedArgv = unparse(argv);
|
||||
// ['--no-boolean', '--number', '4', '--string', 'foo'];
|
||||
```
|
||||
|
||||
The second argument of `unparse` accepts an options object:
|
||||
|
||||
- `alias`: The [aliases](https://github.com/yargs/yargs-parser#requireyargs-parserargs-opts) so that duplicate options aren't generated
|
||||
- `default`: The [default](https://github.com/yargs/yargs-parser#requireyargs-parserargs-opts) values so that the options with default values are omitted
|
||||
- `command`: The [command](https://github.com/yargs/yargs/blob/master/docs/advanced.md#commands) first argument so that command names and positional arguments are handled correctly
|
||||
|
||||
### Example with `command` options
|
||||
|
||||
```js
|
||||
const yargs = require('yargs');
|
||||
const unparse = require('yargs-unparser');
|
||||
|
||||
const argv = yargs
|
||||
.command('my-command <positional>', 'My awesome command', (yargs) =>
|
||||
yargs
|
||||
.option('boolean', { type: 'boolean' })
|
||||
.option('number', { type: 'number' })
|
||||
.option('string', { type: 'string' })
|
||||
)
|
||||
.parse(['my-command', 'hello', '--no-boolean', '--number', '4', '--string', 'foo']);
|
||||
// { positional: 'hello', boolean: false, number: 4, string: 'foo', _: ['my-command'] }
|
||||
|
||||
const unparsedArgv = unparse(argv, {
|
||||
command: 'my-command <positional>',
|
||||
});
|
||||
// ['my-command', 'hello', '--no-boolean', '--number', '4', '--string', 'foo'];
|
||||
```
|
||||
|
||||
### Caveats
|
||||
|
||||
The returned array can be parsed again by `yargs-parser` using the default configuration. If you used custom configuration that you want `yargs-unparser` to be aware, please fill an [issue](https://github.com/yargs/yargs-unparser/issues).
|
||||
|
||||
If you `coerce` in weird ways, things might not work correctly.
|
||||
|
||||
|
||||
## Tests
|
||||
|
||||
`$ npm test`
|
||||
`$ npm test -- --watch` during development
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](http://opensource.org/licenses/MIT)
|
||||
127
ProjectSourceCode/node_modules/yargs-unparser/index.js
generated
vendored
Normal file
127
ProjectSourceCode/node_modules/yargs-unparser/index.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
'use strict';
|
||||
|
||||
const yargs = require('yargs/yargs');
|
||||
const flatten = require('flat');
|
||||
const { castArray, some, isPlainObject, camelCase, kebabCase, omitBy } = require('lodash');
|
||||
|
||||
function isAlias(key, alias) {
|
||||
return some(alias, (aliases) => castArray(aliases).indexOf(key) !== -1);
|
||||
}
|
||||
|
||||
function hasDefaultValue(key, value, defaults) {
|
||||
return value === defaults[key];
|
||||
}
|
||||
|
||||
function isCamelCased(key, argv) {
|
||||
return /[A-Z]/.test(key) && camelCase(key) === key && // Is it camel case?
|
||||
argv[kebabCase(key)] != null; // Is the standard version defined?
|
||||
}
|
||||
|
||||
function keyToFlag(key) {
|
||||
return key.length === 1 ? `-${key}` : `--${key}`;
|
||||
}
|
||||
|
||||
function unparseOption(key, value, unparsed) {
|
||||
if (typeof value === 'string') {
|
||||
unparsed.push(keyToFlag(key), value);
|
||||
} else if (value === true) {
|
||||
unparsed.push(keyToFlag(key));
|
||||
} else if (value === false) {
|
||||
unparsed.push(`--no-${key}`);
|
||||
} else if (Array.isArray(value)) {
|
||||
value.forEach((item) => unparseOption(key, item, unparsed));
|
||||
} else if (isPlainObject(value)) {
|
||||
const flattened = flatten(value, { safe: true });
|
||||
|
||||
for (const flattenedKey in flattened) {
|
||||
if (!isCamelCased(flattenedKey, flattened)) {
|
||||
unparseOption(`${key}.${flattenedKey}`, flattened[flattenedKey], unparsed);
|
||||
}
|
||||
}
|
||||
// Fallback case (numbers and other types)
|
||||
} else if (value != null) {
|
||||
unparsed.push(keyToFlag(key), `${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
function unparsePositional(argv, options, unparsed) {
|
||||
const knownPositional = [];
|
||||
|
||||
// Unparse command if set, collecting all known positional arguments
|
||||
// e.g.: build <first> <second> <rest...>
|
||||
if (options.command) {
|
||||
const { 0: cmd, index } = options.command.match(/[^<[]*/);
|
||||
const { demanded, optional } = yargs()
|
||||
.getCommandInstance()
|
||||
.parseCommand(`foo ${options.command.substr(index + cmd.length)}`);
|
||||
|
||||
// Push command (can be a deep command)
|
||||
unparsed.push(...cmd.trim().split(/\s+/));
|
||||
|
||||
// Push positional arguments
|
||||
[...demanded, ...optional].forEach(({ cmd: cmds, variadic }) => {
|
||||
knownPositional.push(...cmds);
|
||||
|
||||
const cmd = cmds[0];
|
||||
const args = (variadic ? argv[cmd] || [] : [argv[cmd]])
|
||||
.filter((arg) => arg != null)
|
||||
.map((arg) => `${arg}`);
|
||||
|
||||
unparsed.push(...args);
|
||||
});
|
||||
}
|
||||
|
||||
// Unparse unkown positional arguments
|
||||
argv._ && unparsed.push(...argv._.slice(knownPositional.length));
|
||||
|
||||
return knownPositional;
|
||||
}
|
||||
|
||||
function unparseOptions(argv, options, knownPositional, unparsed) {
|
||||
const optionsArgv = omitBy(argv, (value, key) =>
|
||||
// Remove positional arguments
|
||||
knownPositional.includes(key) ||
|
||||
// Remove special _, -- and $0
|
||||
['_', '--', '$0'].includes(key) ||
|
||||
// Remove aliases
|
||||
isAlias(key, options.alias) ||
|
||||
// Remove default values
|
||||
hasDefaultValue(key, value, options.default) ||
|
||||
// Remove camel-cased
|
||||
isCamelCased(key, argv));
|
||||
|
||||
for (const key in optionsArgv) {
|
||||
unparseOption(key, optionsArgv[key], unparsed);
|
||||
}
|
||||
}
|
||||
|
||||
function unparseEndOfOptions(argv, options, unparsed) {
|
||||
// Unparse ending (--) arguments if set
|
||||
argv['--'] && unparsed.push('--', ...argv['--']);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
function unparser(argv, options) {
|
||||
options = Object.assign({
|
||||
alias: {},
|
||||
default: {},
|
||||
command: null,
|
||||
}, options);
|
||||
|
||||
const unparsed = [];
|
||||
|
||||
// Unparse known & unknown positional arguments (foo <first> <second> [rest...])
|
||||
// All known positional will be returned so that they are not added as flags
|
||||
const knownPositional = unparsePositional(argv, options, unparsed);
|
||||
|
||||
// Unparse option arguments (--foo hello --bar hi)
|
||||
unparseOptions(argv, options, knownPositional, unparsed);
|
||||
|
||||
// Unparse "end-of-options" arguments (stuff after " -- ")
|
||||
unparseEndOfOptions(argv, options, unparsed);
|
||||
|
||||
return unparsed;
|
||||
}
|
||||
|
||||
module.exports = unparser;
|
||||
65
ProjectSourceCode/node_modules/yargs-unparser/package.json
generated
vendored
Normal file
65
ProjectSourceCode/node_modules/yargs-unparser/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "yargs-unparser",
|
||||
"description": "Converts back a yargs argv object to its original array form",
|
||||
"version": "1.6.0",
|
||||
"keywords": [
|
||||
"yargs",
|
||||
"unparse",
|
||||
"expand",
|
||||
"inverse",
|
||||
"argv"
|
||||
],
|
||||
"author": "André Cruz <andre@moxy.studio>",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"homepage": "https://github.com/yargs/yargs-unparser",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:yargs/yargs-unparser.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"files": [],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "jest --env node --coverage",
|
||||
"prerelease": "npm t && npm run lint",
|
||||
"release": "standard-version",
|
||||
"precommit": "lint-staged",
|
||||
"commitmsg": "commitlint -e $GIT_PARAMS"
|
||||
},
|
||||
"standard-version": {
|
||||
"scripts": {
|
||||
"posttag": "git push --follow-tags origin master"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^8.1.0",
|
||||
"@commitlint/config-conventional": "^8.1.0",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-config-moxy": "^7.1.0",
|
||||
"husky": "^3.0.1",
|
||||
"jest": "^24.8.0",
|
||||
"lint-staged": "^9.2.1",
|
||||
"minimist": "^1.2.0",
|
||||
"standard-version": "^7.0.0",
|
||||
"yargs-parser": "^13.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"flat": "^4.1.0",
|
||||
"lodash": "^4.17.15",
|
||||
"yargs": "^13.3.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user