commit node_modules and generated files
This commit is contained in:
parent
6d7a135fea
commit
34b372292b
3379 changed files with 449603 additions and 2029 deletions
1561
node_modules/webpack-cli/CHANGELOG.md
generated
vendored
Normal file
1561
node_modules/webpack-cli/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
20
node_modules/webpack-cli/LICENSE
generated
vendored
Normal file
20
node_modules/webpack-cli/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Copyright JS Foundation and other contributors
|
||||
|
||||
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.
|
||||
112
node_modules/webpack-cli/README.md
generated
vendored
Normal file
112
node_modules/webpack-cli/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<div align="center">
|
||||
<a href="https://github.com/webpack/webpack-cli">
|
||||
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h1 align="center">webpack CLI</h1>
|
||||
|
||||
<p align="center">
|
||||
The official CLI of webpack
|
||||
</p>
|
||||
<br>
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![Build Status][build-status]][build-status-url]
|
||||
[![Build2 Status][build-status-azure]][build-status-azure-url]
|
||||
[![deps][deps]][deps-url]
|
||||
[![Code Climate][maintainability]][maintainability-url]
|
||||
[![chat on gitter][chat]][chat-url]
|
||||
[![Install Size][size]][size-url]
|
||||
[![Downloads][downloads]][downloads-url]
|
||||
[![lerna][lerna]][lerna-url]
|
||||
[![GitHub contributors][contributors]][contributors-url]
|
||||
|
||||
- [About](#about)
|
||||
- [How to install](#how-to-install)
|
||||
- [Packages](#packages)
|
||||
- [Commands](#commands)
|
||||
- [Utilities](#utilities)
|
||||
- [Getting started](#getting-started)
|
||||
- [webpack CLI Scaffolds](#webpack-cli-scaffolds)
|
||||
- [Contributing and Internal Documentation](#contributing-and-internal-documentation)
|
||||
- [Open Collective](#open-collective)
|
||||
|
||||
## About
|
||||
|
||||
webpack CLI provides a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file, but often developers want to create a more custom webpack configuration based on their use-cases and needs. webpack CLI addresses these needs by providing a set of tools to improve the setup of custom webpack configuration.
|
||||
|
||||
### How to install
|
||||
|
||||
When you have followed the [Getting Started](https://webpack.js.org/guides/getting-started/) guide of webpack then webpack CLI is already installed!
|
||||
|
||||
Otherwise `npm install --save-dev webpack-cli` or `yarn add webpack-cli --dev` will install it.
|
||||
|
||||
## Packages
|
||||
|
||||
We organize webpack CLI as a multi-package repository using [lerna](https://github.com/lerna/lerna). Every command has a dedicated subfolder in the `packages` Folder. Here's a summary of commands provided by the CLI.
|
||||
|
||||
### Commands
|
||||
|
||||
Supporting developers is an important task for webpack CLI. Thus, webpack CLI provides different commands for many common tasks.
|
||||
|
||||
- [`webpack-cli init`](./packages/init/README.md#webpack-cli-init) - Create a new webpack configuration.
|
||||
- [`webpack-cli info`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment.
|
||||
- [`webpack-cli migrate`](./packages/migrate/README.md#webpack-cli-migrate) - Migrate project from one version to another.
|
||||
- [`webpack-cli generate-plugin`](./packages/generate-plugin/README.md#webpack-cli-generate-plugin) - Initiate new plugin project.
|
||||
- [`webpack-cli generate-loader`](./packages/generate-loader/README.md#webpack-cli-generate-loader) - Initiate new loader project.
|
||||
- [`webpack-cli serve`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading.
|
||||
|
||||
### Utilities
|
||||
|
||||
The project also has several utility packages which are used by other commands
|
||||
|
||||
- [`utils`](./packages/utils/README.md) - Several utilities used across webpack-cli.
|
||||
- [`generators`](./packages/generators/README.md) - Contains all webpack-cli related yeoman generators.
|
||||
- [`webpack-scaffold`](./packages/webpack-scaffold/README.md) - Utilities to create a webpack scaffold.
|
||||
|
||||
## Getting started
|
||||
|
||||
When you have followed the [Getting Started](https://webpack.js.org/guides/getting-started/) guide of webpack then webpack CLI is already installed! Otherwise, you would need to install webpack CLI and the packages you want to use. If we want to use the `init` command to create a new `webpack.config.js` configuration file:
|
||||
|
||||
```sh
|
||||
npm i webpack-cli @webpack-cli/init
|
||||
npx webpack-cli init
|
||||
```
|
||||
|
||||
You will be prompted for some questions about what how you want to generate your config file when running the `init` command so webpack CLI can provide the best fitting configuration.
|
||||
|
||||
## webpack CLI Scaffolds
|
||||
|
||||
With v3 of webpack CLI, we introduced scaffolding as an integral part of the CLI. Our goal is to simplify the creation of webpack configurations for different purposes. Additionally, sharing such solutions with the community is beneficial and with webpack, we want to allow this. We provide `webpack-scaffold` as a utility suite for creating these scaffolds. It contains functions that could be of use for creating a scaffold yourself.
|
||||
|
||||
You can read more about [Scaffolding](https://webpack.js.org/guides/scaffolding), learn [How to compose a webpack-scaffold?](https://webpack.js.org/contribute/writing-a-scaffold) or generate one with [webpack-scaffold-starter](https://github.com/rishabh3112/webpack-scaffold-starter).
|
||||
|
||||
## Contributing and Internal Documentation
|
||||
|
||||
The webpack family welcomes any contributor, small or big. We are happy to elaborate, guide you through the source code and find issues you might want to work on! To get started have a look at our [documentation on contributing](./.github/CONTRIBUTING.md).
|
||||
|
||||
## Open Collective
|
||||
|
||||
If you like **webpack**, please consider donating to our [Open Collective](https://opencollective.com/webpack) to help us maintain it.
|
||||
|
||||
[build-status]: https://travis-ci.org/webpack/webpack-cli.svg
|
||||
[build-status-url]: https://travis-ci.org/webpack/webpack-cli
|
||||
[build-status-azure]: https://dev.azure.com/webpack/webpack/_apis/build/status/webpack.webpack-cli
|
||||
[build-status-azure-url]: https://dev.azure.com/webpack/webpack/_build/latest?definitionId=4
|
||||
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
||||
[chat-url]: https://gitter.im/webpack/webpack
|
||||
[contributors]: https://img.shields.io/github/contributors/webpack/webpack-cli.svg
|
||||
[contributors-url]: https://github.com/webpack/webpack-cli/graphs/contributors
|
||||
[deps]: https://img.shields.io/david/webpack/webpack.svg
|
||||
[deps-url]: https://david-dm.org/webpack/webpack-cli
|
||||
[downloads]: https://img.shields.io/npm/dw/webpack-cli.svg
|
||||
[downloads-url]: https://www.npmjs.com/package/webpack-cli
|
||||
[lerna]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
|
||||
[lerna-url]: http://www.lernajs.io/
|
||||
[npm]: https://img.shields.io/npm/v/webpack-cli.svg
|
||||
[npm-url]: https://www.npmjs.com/package/webpack-cli
|
||||
[maintainability]: https://codeclimate.com/github/webpack/webpack-cli/badges/gpa.svg
|
||||
[maintainability-url]: https://codeclimate.com/github/webpack/webpack-cli
|
||||
[size]: https://packagephobia.now.sh/badge?p=webpack-cli
|
||||
[size-url]: https://packagephobia.now.sh/result?p=webpack-cli
|
||||
63
node_modules/webpack-cli/bin/.eslintrc.js
generated
vendored
Normal file
63
node_modules/webpack-cli/bin/.eslintrc.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
plugins: ["node"],
|
||||
extends: ["../.eslintrc.js", "plugin:node/recommended"],
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
jest: true
|
||||
},
|
||||
parserOptions: { ecmaVersion: 2017, sourceType: "module" },
|
||||
rules: {
|
||||
"node/no-unsupported-features": ["error", { version: 6 }],
|
||||
"node/no-deprecated-api": "error",
|
||||
"node/no-missing-import": "error",
|
||||
"node/no-missing-require": [
|
||||
"error",
|
||||
{
|
||||
resolvePaths: ["./packages"],
|
||||
allowModules: [
|
||||
"webpack",
|
||||
"@webpack-cli/generators",
|
||||
"@webpack-cli/init",
|
||||
"@webpack-cli/migrate",
|
||||
"@webpack-cli/utils",
|
||||
"@webpack-cli/generate-loader",
|
||||
"@webpack-cli/generate-plugin",
|
||||
"@webpack-cli/webpack-scaffold"
|
||||
]
|
||||
}
|
||||
],
|
||||
"node/no-unpublished-bin": "error",
|
||||
"node/no-unpublished-require": [
|
||||
"error",
|
||||
{
|
||||
allowModules: [
|
||||
"webpack",
|
||||
"webpack-dev-server",
|
||||
"@webpack-cli/generators",
|
||||
"@webpack-cli/init",
|
||||
"@webpack-cli/migrate",
|
||||
"@webpack-cli/utils",
|
||||
"@webpack-cli/generate-loader",
|
||||
"@webpack-cli/generate-plugin",
|
||||
"@webpack-cli/webpack-scaffold"
|
||||
]
|
||||
}
|
||||
],
|
||||
"node/no-extraneous-require": [
|
||||
"error",
|
||||
{
|
||||
allowModules: [
|
||||
"@webpack-cli/migrate",
|
||||
"@webpack-cli/generators",
|
||||
"@webpack-cli/utils",
|
||||
"@webpack-cli/generate-loader",
|
||||
"@webpack-cli/generate-plugin",
|
||||
"@webpack-cli/webpack-scaffold"
|
||||
]
|
||||
}
|
||||
],
|
||||
"node/process-exit-as-throw": "error"
|
||||
}
|
||||
};
|
||||
366
node_modules/webpack-cli/bin/cli.js
generated
vendored
Executable file
366
node_modules/webpack-cli/bin/cli.js
generated
vendored
Executable file
|
|
@ -0,0 +1,366 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
const { NON_COMPILATION_ARGS } = require("./utils/constants");
|
||||
|
||||
(function() {
|
||||
// wrap in IIFE to be able to use return
|
||||
|
||||
const importLocal = require("import-local");
|
||||
// Prefer the local installation of webpack-cli
|
||||
if (importLocal(__filename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
require("v8-compile-cache");
|
||||
|
||||
const ErrorHelpers = require("./utils/errorHelpers");
|
||||
|
||||
const NON_COMPILATION_CMD = process.argv.find(arg => {
|
||||
if (arg === "serve") {
|
||||
global.process.argv = global.process.argv.filter(a => a !== "serve");
|
||||
process.argv = global.process.argv;
|
||||
}
|
||||
return NON_COMPILATION_ARGS.find(a => a === arg);
|
||||
});
|
||||
|
||||
if (NON_COMPILATION_CMD) {
|
||||
return require("./utils/prompt-command")(NON_COMPILATION_CMD, ...process.argv);
|
||||
}
|
||||
|
||||
const yargs = require("yargs").usage(`webpack-cli ${require("../package.json").version}
|
||||
|
||||
Usage: webpack-cli [options]
|
||||
webpack-cli [options] --entry <entry> --output <output>
|
||||
webpack-cli [options] <entries...> --output <output>
|
||||
webpack-cli <command> [options]
|
||||
|
||||
For more information, see https://webpack.js.org/api/cli/.`);
|
||||
|
||||
require("./config/config-yargs")(yargs);
|
||||
|
||||
// yargs will terminate the process early when the user uses help or version.
|
||||
// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
|
||||
// To prevent this we use the yargs.parse API and exit the process normally
|
||||
yargs.parse(process.argv.slice(2), (err, argv, output) => {
|
||||
Error.stackTraceLimit = 30;
|
||||
|
||||
// arguments validation failed
|
||||
if (err && output) {
|
||||
console.error(output);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// help or version info
|
||||
if (output) {
|
||||
console.log(output);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv.verbose) {
|
||||
argv["display"] = "verbose";
|
||||
}
|
||||
|
||||
let options;
|
||||
try {
|
||||
options = require("./utils/convert-argv")(argv);
|
||||
} catch (err) {
|
||||
if (err.code === "MODULE_NOT_FOUND") {
|
||||
const moduleName = err.message.split("'")[1];
|
||||
let instructions = "";
|
||||
let errorMessage = "";
|
||||
|
||||
if (moduleName === "webpack") {
|
||||
errorMessage = `\n${moduleName} not installed`;
|
||||
instructions = `Install webpack to start bundling: \u001b[32m\n $ npm install --save-dev ${moduleName}\n`;
|
||||
|
||||
if (process.env.npm_execpath !== undefined && process.env.npm_execpath.includes("yarn")) {
|
||||
instructions = `Install webpack to start bundling: \u001b[32m\n $ yarn add ${moduleName} --dev\n`;
|
||||
}
|
||||
Error.stackTraceLimit = 1;
|
||||
console.error(`${errorMessage}\n\n${instructions}`);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (err.name !== "ValidationError") {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const stack = ErrorHelpers.cleanUpWebpackOptions(err.stack, err.message);
|
||||
const message = err.message + "\n" + stack;
|
||||
|
||||
if (argv.color) {
|
||||
console.error(`\u001b[1m\u001b[31m${message}\u001b[39m\u001b[22m`);
|
||||
} else {
|
||||
console.error(message);
|
||||
}
|
||||
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* When --silent flag is present, an object with a no-op write method is
|
||||
* used in place of process.stout
|
||||
*/
|
||||
const stdout = argv.silent ? { write: () => {} } : process.stdout;
|
||||
|
||||
function ifArg(name, fn, init) {
|
||||
if (Array.isArray(argv[name])) {
|
||||
if (init) init();
|
||||
argv[name].forEach(fn);
|
||||
} else if (typeof argv[name] !== "undefined") {
|
||||
if (init) init();
|
||||
fn(argv[name], -1);
|
||||
}
|
||||
}
|
||||
|
||||
function processOptions(options) {
|
||||
// process Promise
|
||||
if (typeof options.then === "function") {
|
||||
options.then(processOptions).catch(function(err) {
|
||||
console.error(err.stack || err);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const firstOptions = [].concat(options)[0];
|
||||
const statsPresetToOptions = require("webpack").Stats.presetToOptions;
|
||||
|
||||
let outputOptions = options.stats;
|
||||
if (typeof outputOptions === "boolean" || typeof outputOptions === "string") {
|
||||
outputOptions = statsPresetToOptions(outputOptions);
|
||||
} else if (!outputOptions) {
|
||||
outputOptions = {};
|
||||
}
|
||||
|
||||
ifArg("display", function(preset) {
|
||||
outputOptions = statsPresetToOptions(preset);
|
||||
});
|
||||
|
||||
outputOptions = Object.create(outputOptions);
|
||||
if (Array.isArray(options) && !outputOptions.children) {
|
||||
outputOptions.children = options.map(o => o.stats);
|
||||
}
|
||||
if (typeof outputOptions.context === "undefined") outputOptions.context = firstOptions.context;
|
||||
|
||||
ifArg("env", function(value) {
|
||||
if (outputOptions.env) {
|
||||
outputOptions._env = value;
|
||||
}
|
||||
});
|
||||
|
||||
ifArg("json", function(bool) {
|
||||
if (bool) {
|
||||
outputOptions.json = bool;
|
||||
outputOptions.modules = bool;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof outputOptions.colors === "undefined") outputOptions.colors = require("supports-color").stdout;
|
||||
|
||||
ifArg("sort-modules-by", function(value) {
|
||||
outputOptions.modulesSort = value;
|
||||
});
|
||||
|
||||
ifArg("sort-chunks-by", function(value) {
|
||||
outputOptions.chunksSort = value;
|
||||
});
|
||||
|
||||
ifArg("sort-assets-by", function(value) {
|
||||
outputOptions.assetsSort = value;
|
||||
});
|
||||
|
||||
ifArg("display-exclude", function(value) {
|
||||
outputOptions.exclude = value;
|
||||
});
|
||||
|
||||
if (!outputOptions.json) {
|
||||
if (typeof outputOptions.cached === "undefined") outputOptions.cached = false;
|
||||
if (typeof outputOptions.cachedAssets === "undefined") outputOptions.cachedAssets = false;
|
||||
|
||||
ifArg("display-chunks", function(bool) {
|
||||
if (bool) {
|
||||
outputOptions.modules = false;
|
||||
outputOptions.chunks = true;
|
||||
outputOptions.chunkModules = true;
|
||||
}
|
||||
});
|
||||
|
||||
ifArg("display-entrypoints", function(bool) {
|
||||
outputOptions.entrypoints = bool;
|
||||
});
|
||||
|
||||
ifArg("display-reasons", function(bool) {
|
||||
if (bool) outputOptions.reasons = true;
|
||||
});
|
||||
|
||||
ifArg("display-depth", function(bool) {
|
||||
if (bool) outputOptions.depth = true;
|
||||
});
|
||||
|
||||
ifArg("display-used-exports", function(bool) {
|
||||
if (bool) outputOptions.usedExports = true;
|
||||
});
|
||||
|
||||
ifArg("display-provided-exports", function(bool) {
|
||||
if (bool) outputOptions.providedExports = true;
|
||||
});
|
||||
|
||||
ifArg("display-optimization-bailout", function(bool) {
|
||||
if (bool) outputOptions.optimizationBailout = bool;
|
||||
});
|
||||
|
||||
ifArg("display-error-details", function(bool) {
|
||||
if (bool) outputOptions.errorDetails = true;
|
||||
});
|
||||
|
||||
ifArg("display-origins", function(bool) {
|
||||
if (bool) outputOptions.chunkOrigins = true;
|
||||
});
|
||||
|
||||
ifArg("display-max-modules", function(value) {
|
||||
outputOptions.maxModules = +value;
|
||||
});
|
||||
|
||||
ifArg("display-cached", function(bool) {
|
||||
if (bool) outputOptions.cached = true;
|
||||
});
|
||||
|
||||
ifArg("display-cached-assets", function(bool) {
|
||||
if (bool) outputOptions.cachedAssets = true;
|
||||
});
|
||||
|
||||
if (!outputOptions.exclude) outputOptions.exclude = ["node_modules", "bower_components", "components"];
|
||||
|
||||
if (argv["display-modules"]) {
|
||||
outputOptions.maxModules = Infinity;
|
||||
outputOptions.exclude = undefined;
|
||||
outputOptions.modules = true;
|
||||
}
|
||||
}
|
||||
|
||||
ifArg("hide-modules", function(bool) {
|
||||
if (bool) {
|
||||
outputOptions.modules = false;
|
||||
outputOptions.chunkModules = false;
|
||||
}
|
||||
});
|
||||
|
||||
ifArg("info-verbosity", function(value) {
|
||||
outputOptions.infoVerbosity = value;
|
||||
});
|
||||
|
||||
ifArg("build-delimiter", function(value) {
|
||||
outputOptions.buildDelimiter = value;
|
||||
});
|
||||
|
||||
const webpack = require("webpack");
|
||||
|
||||
let lastHash = null;
|
||||
let compiler;
|
||||
try {
|
||||
compiler = webpack(options);
|
||||
} catch (err) {
|
||||
if (err.name === "WebpackOptionsValidationError") {
|
||||
if (argv.color) console.error(`\u001b[1m\u001b[31m${err.message}\u001b[39m\u001b[22m`);
|
||||
else console.error(err.message);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (argv.progress) {
|
||||
const ProgressPlugin = require("webpack").ProgressPlugin;
|
||||
new ProgressPlugin({
|
||||
profile: argv.profile
|
||||
}).apply(compiler);
|
||||
}
|
||||
if (outputOptions.infoVerbosity === "verbose") {
|
||||
if (argv.w) {
|
||||
compiler.hooks.watchRun.tap("WebpackInfo", compilation => {
|
||||
const compilationName = compilation.name ? compilation.name : "";
|
||||
console.error("\nCompilation " + compilationName + " starting…\n");
|
||||
});
|
||||
} else {
|
||||
compiler.hooks.beforeRun.tap("WebpackInfo", compilation => {
|
||||
const compilationName = compilation.name ? compilation.name : "";
|
||||
console.error("\nCompilation " + compilationName + " starting…\n");
|
||||
});
|
||||
}
|
||||
compiler.hooks.done.tap("WebpackInfo", compilation => {
|
||||
const compilationName = compilation.name ? compilation.name : "";
|
||||
console.error("\nCompilation " + compilationName + " finished\n");
|
||||
});
|
||||
}
|
||||
|
||||
function compilerCallback(err, stats) {
|
||||
if (!options.watch || err) {
|
||||
// Do not keep cache anymore
|
||||
compiler.purgeInputFileSystem();
|
||||
}
|
||||
if (err) {
|
||||
lastHash = null;
|
||||
console.error(err.stack || err);
|
||||
if (err.details) console.error(err.details);
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
if (outputOptions.json) {
|
||||
stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
|
||||
} else if (stats.hash !== lastHash) {
|
||||
lastHash = stats.hash;
|
||||
if (stats.compilation && stats.compilation.errors.length !== 0) {
|
||||
const errors = stats.compilation.errors;
|
||||
if (errors[0].name === "EntryModuleNotFoundError") {
|
||||
console.error("\n\u001b[1m\u001b[31mInsufficient number of arguments or no entry found.");
|
||||
console.error(
|
||||
"\u001b[1m\u001b[31mAlternatively, run 'webpack(-cli) --help' for usage info.\u001b[39m\u001b[22m\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
const statsString = stats.toString(outputOptions);
|
||||
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
|
||||
if (statsString) stdout.write(`${statsString}\n${delimiter}`);
|
||||
}
|
||||
if (!options.watch && stats.hasErrors()) {
|
||||
process.exitCode = 2;
|
||||
}
|
||||
}
|
||||
if (firstOptions.watch || options.watch) {
|
||||
const watchOptions =
|
||||
firstOptions.watchOptions || options.watchOptions || firstOptions.watch || options.watch || {};
|
||||
if (watchOptions.stdin) {
|
||||
process.stdin.on("end", function(_) {
|
||||
process.exit(); // eslint-disable-line
|
||||
});
|
||||
process.stdin.resume();
|
||||
}
|
||||
compiler.watch(watchOptions, compilerCallback);
|
||||
if (outputOptions.infoVerbosity !== "none") console.error("\nwebpack is watching the files…\n");
|
||||
} else {
|
||||
compiler.run((err, stats) => {
|
||||
if (compiler.close) {
|
||||
compiler.close(err2 => {
|
||||
compilerCallback(err || err2, stats);
|
||||
});
|
||||
} else {
|
||||
compilerCallback(err, stats);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
processOptions(options);
|
||||
});
|
||||
})();
|
||||
504
node_modules/webpack-cli/bin/config/config-yargs.js
generated
vendored
Normal file
504
node_modules/webpack-cli/bin/config/config-yargs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
const optionsSchema = require("../config/optionsSchema.json");
|
||||
|
||||
const { GROUPS } = require("../utils/constants");
|
||||
|
||||
const {
|
||||
CONFIG_GROUP,
|
||||
BASIC_GROUP,
|
||||
MODULE_GROUP,
|
||||
OUTPUT_GROUP,
|
||||
ADVANCED_GROUP,
|
||||
RESOLVE_GROUP,
|
||||
OPTIMIZE_GROUP,
|
||||
DISPLAY_GROUP
|
||||
} = GROUPS;
|
||||
|
||||
const nestedProperties = ["anyOf", "oneOf", "allOf"];
|
||||
|
||||
const resolveSchema = schema => {
|
||||
let current = schema;
|
||||
if (schema && typeof schema === "object" && "$ref" in schema) {
|
||||
const path = schema.$ref.split("/");
|
||||
for (const element of path) {
|
||||
if (element === "#") {
|
||||
current = optionsSchema;
|
||||
} else {
|
||||
current = current[element];
|
||||
}
|
||||
}
|
||||
}
|
||||
return current;
|
||||
};
|
||||
|
||||
const findPropertyInSchema = (schema, property, subProperty) => {
|
||||
if (!schema) return null;
|
||||
if (subProperty) {
|
||||
if (schema[property] && typeof schema[property] === "object" && subProperty in schema[property]) {
|
||||
return resolveSchema(schema[property][subProperty]);
|
||||
}
|
||||
} else {
|
||||
if (property in schema) return resolveSchema(schema[property]);
|
||||
}
|
||||
for (const name of nestedProperties) {
|
||||
if (schema[name]) {
|
||||
for (const item of schema[name]) {
|
||||
const resolvedItem = resolveSchema(item);
|
||||
const result = findPropertyInSchema(resolvedItem, property, subProperty);
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const getSchemaInfo = (path, property, subProperty) => {
|
||||
const pathSegments = path.split(".");
|
||||
let current = optionsSchema;
|
||||
for (const segment of pathSegments) {
|
||||
if (segment === "*") {
|
||||
current = findPropertyInSchema(current, "additionalProperties") || findPropertyInSchema(current, "items");
|
||||
} else {
|
||||
current = findPropertyInSchema(current, "properties", segment);
|
||||
}
|
||||
if (!current) return undefined;
|
||||
}
|
||||
return findPropertyInSchema(current, property, subProperty);
|
||||
};
|
||||
|
||||
module.exports = function(yargs) {
|
||||
yargs
|
||||
.help("help")
|
||||
.alias("help", "h")
|
||||
.version()
|
||||
.alias("version", "v")
|
||||
.options({
|
||||
config: {
|
||||
type: "string",
|
||||
describe: "Path to the config file",
|
||||
group: CONFIG_GROUP,
|
||||
defaultDescription: "webpack.config.js or webpackfile.js",
|
||||
requiresArg: true
|
||||
},
|
||||
"config-register": {
|
||||
type: "array",
|
||||
alias: "r",
|
||||
describe: "Preload one or more modules before loading the webpack configuration",
|
||||
group: CONFIG_GROUP,
|
||||
defaultDescription: "module id or path",
|
||||
requiresArg: true
|
||||
},
|
||||
"config-name": {
|
||||
type: "string",
|
||||
describe: "Name of the config to use",
|
||||
group: CONFIG_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
env: {
|
||||
describe: "Environment passed to the config, when it is a function",
|
||||
group: CONFIG_GROUP
|
||||
},
|
||||
mode: {
|
||||
type: getSchemaInfo("mode", "type"),
|
||||
choices: getSchemaInfo("mode", "enum"),
|
||||
describe: getSchemaInfo("mode", "description"),
|
||||
group: CONFIG_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
context: {
|
||||
type: getSchemaInfo("context", "type"),
|
||||
describe: getSchemaInfo("context", "description"),
|
||||
group: BASIC_GROUP,
|
||||
defaultDescription: "The current directory",
|
||||
requiresArg: true
|
||||
},
|
||||
entry: {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("entry", "description"),
|
||||
group: BASIC_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"no-cache": {
|
||||
type: "boolean",
|
||||
describe: "Disables cached builds",
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
"module-bind": {
|
||||
type: "string",
|
||||
describe: "Bind an extension to a loader",
|
||||
group: MODULE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"module-bind-post": {
|
||||
type: "string",
|
||||
describe: "Bind an extension to a post loader",
|
||||
group: MODULE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"module-bind-pre": {
|
||||
type: "string",
|
||||
describe: "Bind an extension to a pre loader",
|
||||
group: MODULE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
output: {
|
||||
alias: "o",
|
||||
describe: "The output path and file for compilation assets",
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"output-path": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.path", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
defaultDescription: "The current directory",
|
||||
requiresArg: true
|
||||
},
|
||||
"output-filename": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.filename", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
defaultDescription: "[name].js",
|
||||
requiresArg: true
|
||||
},
|
||||
"output-chunk-filename": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.chunkFilename", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
defaultDescription: "filename with [id] instead of [name] or [id] prefixed",
|
||||
requiresArg: true
|
||||
},
|
||||
"output-source-map-filename": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.sourceMapFilename", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"output-public-path": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.publicPath", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"output-jsonp-function": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.jsonpFunction", "description"),
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"output-pathinfo": {
|
||||
type: "boolean",
|
||||
describe: getSchemaInfo("output.pathinfo", "description"),
|
||||
group: OUTPUT_GROUP
|
||||
},
|
||||
"output-library": {
|
||||
type: "array",
|
||||
describe: "Expose the exports of the entry point as library",
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"output-library-target": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("output.libraryTarget", "description"),
|
||||
choices: getSchemaInfo("output.libraryTarget", "enum"),
|
||||
group: OUTPUT_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"records-input-path": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("recordsInputPath", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"records-output-path": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("recordsOutputPath", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"records-path": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("recordsPath", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
define: {
|
||||
type: "string",
|
||||
describe: "Define any free var in the bundle",
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
target: {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("target", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
cache: {
|
||||
type: "boolean",
|
||||
describe: getSchemaInfo("cache", "description"),
|
||||
default: null,
|
||||
group: ADVANCED_GROUP,
|
||||
defaultDescription: "It's enabled by default when watching"
|
||||
},
|
||||
watch: {
|
||||
type: "boolean",
|
||||
alias: "w",
|
||||
describe: getSchemaInfo("watch", "description"),
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
"watch-stdin": {
|
||||
type: "boolean",
|
||||
alias: "stdin",
|
||||
describe: getSchemaInfo("watchOptions.stdin", "description"),
|
||||
group: ADVANCED_GROUP
|
||||
},
|
||||
"watch-aggregate-timeout": {
|
||||
describe: getSchemaInfo("watchOptions.aggregateTimeout", "description"),
|
||||
type: getSchemaInfo("watchOptions.aggregateTimeout", "type"),
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"watch-poll": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("watchOptions.poll", "description"),
|
||||
group: ADVANCED_GROUP
|
||||
},
|
||||
hot: {
|
||||
type: "boolean",
|
||||
describe: "Enables Hot Module Replacement",
|
||||
group: ADVANCED_GROUP
|
||||
},
|
||||
debug: {
|
||||
type: "boolean",
|
||||
describe: "Switch loaders to debug mode",
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
devtool: {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("devtool", "description"),
|
||||
group: BASIC_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"resolve-alias": {
|
||||
type: "string",
|
||||
describe: getSchemaInfo("resolve.alias", "description"),
|
||||
group: RESOLVE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"resolve-extensions": {
|
||||
type: "array",
|
||||
describe: getSchemaInfo("resolve.alias", "description"),
|
||||
group: RESOLVE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"resolve-loader-alias": {
|
||||
type: "string",
|
||||
describe: "Setup a loader alias for resolving",
|
||||
group: RESOLVE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"optimize-max-chunks": {
|
||||
describe: "Try to keep the chunk count below a limit",
|
||||
group: OPTIMIZE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"optimize-min-chunk-size": {
|
||||
describe: getSchemaInfo("optimization.splitChunks.minSize", "description"),
|
||||
group: OPTIMIZE_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"optimize-minimize": {
|
||||
type: "boolean",
|
||||
describe: getSchemaInfo("optimization.minimize", "description"),
|
||||
group: OPTIMIZE_GROUP
|
||||
},
|
||||
prefetch: {
|
||||
type: "string",
|
||||
describe: "Prefetch this request (Example: --prefetch ./file.js)",
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
provide: {
|
||||
type: "string",
|
||||
describe: "Provide these modules as free vars in all modules (Example: --provide jQuery=jquery)",
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
"labeled-modules": {
|
||||
type: "boolean",
|
||||
describe: "Enables labeled modules",
|
||||
group: ADVANCED_GROUP
|
||||
},
|
||||
plugin: {
|
||||
type: "string",
|
||||
describe: "Load this plugin",
|
||||
group: ADVANCED_GROUP,
|
||||
requiresArg: true
|
||||
},
|
||||
bail: {
|
||||
type: getSchemaInfo("bail", "type"),
|
||||
describe: getSchemaInfo("bail", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
default: null
|
||||
},
|
||||
profile: {
|
||||
type: "boolean",
|
||||
describe: getSchemaInfo("profile", "description"),
|
||||
group: ADVANCED_GROUP,
|
||||
default: null
|
||||
},
|
||||
d: {
|
||||
type: "boolean",
|
||||
describe: "shortcut for --debug --devtool eval-cheap-module-source-map --output-pathinfo",
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
p: {
|
||||
type: "boolean",
|
||||
// eslint-disable-next-line quotes
|
||||
describe: 'shortcut for --optimize-minimize --define process.env.NODE_ENV="production"',
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
silent: {
|
||||
type: "boolean",
|
||||
describe: "Prevent output from being displayed in stdout"
|
||||
},
|
||||
json: {
|
||||
type: "boolean",
|
||||
alias: "j",
|
||||
describe: "Prints the result as JSON."
|
||||
},
|
||||
progress: {
|
||||
type: "boolean",
|
||||
describe: "Print compilation progress in percentage",
|
||||
group: BASIC_GROUP
|
||||
},
|
||||
color: {
|
||||
type: "boolean",
|
||||
alias: "colors",
|
||||
default: function supportsColor() {
|
||||
return require("supports-color").stdout;
|
||||
},
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Force colors on the console"
|
||||
},
|
||||
"no-color": {
|
||||
type: "boolean",
|
||||
alias: "no-colors",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Force no colors on the console"
|
||||
},
|
||||
"sort-modules-by": {
|
||||
type: "string",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Sorts the modules list by property in module"
|
||||
},
|
||||
"sort-chunks-by": {
|
||||
type: "string",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Sorts the chunks list by property in chunk"
|
||||
},
|
||||
"sort-assets-by": {
|
||||
type: "string",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Sorts the assets list by property in asset"
|
||||
},
|
||||
"hide-modules": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Hides info about modules"
|
||||
},
|
||||
"display-exclude": {
|
||||
type: "string",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Exclude modules in the output"
|
||||
},
|
||||
"display-modules": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display even excluded modules in the output"
|
||||
},
|
||||
"display-max-modules": {
|
||||
type: "number",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Sets the maximum number of visible modules in output"
|
||||
},
|
||||
"display-chunks": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display chunks in the output"
|
||||
},
|
||||
"display-entrypoints": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display entry points in the output"
|
||||
},
|
||||
"display-origins": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display origins of chunks in the output"
|
||||
},
|
||||
"display-cached": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display also cached modules in the output"
|
||||
},
|
||||
"display-cached-assets": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display also cached assets in the output"
|
||||
},
|
||||
"display-reasons": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display reasons about module inclusion in the output"
|
||||
},
|
||||
"display-depth": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display distance from entry point for each module"
|
||||
},
|
||||
"display-used-exports": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display information about used exports in modules (Tree Shaking)"
|
||||
},
|
||||
"display-provided-exports": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display information about exports provided from modules"
|
||||
},
|
||||
"display-optimization-bailout": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display information about why optimization bailed out for modules"
|
||||
},
|
||||
"display-error-details": {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display details about errors"
|
||||
},
|
||||
display: {
|
||||
type: "string",
|
||||
choices: ["", "verbose", "detailed", "normal", "minimal", "errors-only", "none"],
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Select display preset"
|
||||
},
|
||||
verbose: {
|
||||
type: "boolean",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Show more details"
|
||||
},
|
||||
"info-verbosity": {
|
||||
type: "string",
|
||||
default: "info",
|
||||
choices: ["none", "info", "verbose"],
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Controls the output of lifecycle messaging e.g. Started watching files..."
|
||||
},
|
||||
"build-delimiter": {
|
||||
type: "string",
|
||||
group: DISPLAY_GROUP,
|
||||
describe: "Display custom text after build output"
|
||||
}
|
||||
});
|
||||
};
|
||||
1989
node_modules/webpack-cli/bin/config/optionsSchema.json
generated
vendored
Normal file
1989
node_modules/webpack-cli/bin/config/optionsSchema.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
20
node_modules/webpack-cli/bin/config/webpackConfigurationSchema.json
generated
vendored
Normal file
20
node_modules/webpack-cli/bin/config/webpackConfigurationSchema.json
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"description": "A webpack configuration object."
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "An array of webpack configuration objects.",
|
||||
"items": {
|
||||
"description": "A webpack configuration object.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"instanceof": "Promise",
|
||||
"description": "A promise that resolves with a configuration object, or an array of configuration objects."
|
||||
}
|
||||
]
|
||||
}
|
||||
28
node_modules/webpack-cli/bin/utils/constants.js
generated
vendored
Normal file
28
node_modules/webpack-cli/bin/utils/constants.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const NON_COMPILATION_ARGS = ["init", "migrate", "serve", "generate-loader", "generate-plugin", "info"];
|
||||
|
||||
const CONFIG_GROUP = "Config options:";
|
||||
const BASIC_GROUP = "Basic options:";
|
||||
const MODULE_GROUP = "Module options:";
|
||||
const OUTPUT_GROUP = "Output options:";
|
||||
const ADVANCED_GROUP = "Advanced options:";
|
||||
const RESOLVE_GROUP = "Resolving options:";
|
||||
const OPTIMIZE_GROUP = "Optimizing options:";
|
||||
const DISPLAY_GROUP = "Stats options:";
|
||||
const GROUPS = {
|
||||
CONFIG_GROUP,
|
||||
BASIC_GROUP,
|
||||
MODULE_GROUP,
|
||||
OUTPUT_GROUP,
|
||||
ADVANCED_GROUP,
|
||||
RESOLVE_GROUP,
|
||||
OPTIMIZE_GROUP,
|
||||
DISPLAY_GROUP
|
||||
};
|
||||
|
||||
const WEBPACK_OPTIONS_FLAG = "WEBPACK_OPTIONS";
|
||||
|
||||
module.exports = {
|
||||
NON_COMPILATION_ARGS,
|
||||
GROUPS,
|
||||
WEBPACK_OPTIONS_FLAG
|
||||
};
|
||||
562
node_modules/webpack-cli/bin/utils/convert-argv.js
generated
vendored
Normal file
562
node_modules/webpack-cli/bin/utils/convert-argv.js
generated
vendored
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
fs.existsSync = fs.existsSync || path.existsSync;
|
||||
const interpret = require("interpret");
|
||||
const prepareOptions = require("./prepareOptions");
|
||||
const findup = require("findup-sync");
|
||||
const validateOptions = require("./validate-options");
|
||||
|
||||
module.exports = function(...args) {
|
||||
const argv = args[1] || args[0];
|
||||
const options = [];
|
||||
// Shortcuts
|
||||
if (argv.d) {
|
||||
argv.debug = true;
|
||||
argv["output-pathinfo"] = true;
|
||||
if (!argv.devtool) {
|
||||
argv.devtool = "eval-cheap-module-source-map";
|
||||
}
|
||||
if (!argv.mode) {
|
||||
argv.mode = "development";
|
||||
}
|
||||
}
|
||||
if (argv.p) {
|
||||
argv["optimize-minimize"] = true;
|
||||
// eslint-disable-next-line quotes
|
||||
argv["define"] = [].concat(argv["define"] || []).concat('process.env.NODE_ENV="production"');
|
||||
if (!argv.mode) {
|
||||
argv.mode = "production";
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.output) {
|
||||
let output = argv.output;
|
||||
if (!path.isAbsolute(argv.o)) {
|
||||
output = path.resolve(process.cwd(), output);
|
||||
}
|
||||
argv["output-filename"] = path.basename(output);
|
||||
argv["output-path"] = path.dirname(output);
|
||||
}
|
||||
|
||||
let configFileLoaded = false;
|
||||
let configFiles = [];
|
||||
const extensions = Object.keys(interpret.extensions).sort(function(a, b) {
|
||||
return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length;
|
||||
});
|
||||
|
||||
let i;
|
||||
if (argv.config) {
|
||||
const getConfigExtension = function getConfigExtension(configPath) {
|
||||
for (i = extensions.length - 1; i >= 0; i--) {
|
||||
const tmpExt = extensions[i];
|
||||
if (configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
|
||||
return tmpExt;
|
||||
}
|
||||
}
|
||||
return path.extname(configPath);
|
||||
};
|
||||
|
||||
const mapConfigArg = function mapConfigArg(configArg) {
|
||||
const resolvedPath = path.resolve(configArg);
|
||||
const extension = getConfigExtension(resolvedPath);
|
||||
return {
|
||||
path: resolvedPath,
|
||||
ext: extension
|
||||
};
|
||||
};
|
||||
|
||||
const configArgList = Array.isArray(argv.config) ? argv.config : [argv.config];
|
||||
configFiles = configArgList.map(mapConfigArg);
|
||||
} else {
|
||||
const defaultConfigFileNames = ["webpack.config", "webpackfile"].join("|");
|
||||
const webpackConfigFileRegExp = `(${defaultConfigFileNames})(${extensions.join("|")})`;
|
||||
const pathToWebpackConfig = findup(webpackConfigFileRegExp);
|
||||
|
||||
if (pathToWebpackConfig) {
|
||||
const resolvedPath = path.resolve(pathToWebpackConfig);
|
||||
const actualConfigFileName = path.basename(resolvedPath);
|
||||
const ext = actualConfigFileName.replace(new RegExp(defaultConfigFileNames), "");
|
||||
configFiles.push({
|
||||
path: resolvedPath,
|
||||
ext
|
||||
});
|
||||
}
|
||||
}
|
||||
if (configFiles.length > 0) {
|
||||
const registerCompiler = function registerCompiler(moduleDescriptor) {
|
||||
if (moduleDescriptor) {
|
||||
if (typeof moduleDescriptor === "string") {
|
||||
require(moduleDescriptor);
|
||||
} else if (!Array.isArray(moduleDescriptor)) {
|
||||
moduleDescriptor.register(require(moduleDescriptor.module));
|
||||
} else {
|
||||
for (let i = 0; i < moduleDescriptor.length; i++) {
|
||||
try {
|
||||
registerCompiler(moduleDescriptor[i]);
|
||||
break;
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const requireConfig = function requireConfig(configPath) {
|
||||
let options = (function WEBPACK_OPTIONS() {
|
||||
if (argv.configRegister && argv.configRegister.length) {
|
||||
module.paths.unshift(path.resolve(process.cwd(), "node_modules"), process.cwd());
|
||||
argv.configRegister.forEach(dep => {
|
||||
require(dep);
|
||||
});
|
||||
return require(path.resolve(process.cwd(), configPath));
|
||||
} else {
|
||||
return require(path.resolve(process.cwd(), configPath));
|
||||
}
|
||||
})();
|
||||
options = prepareOptions(options, argv);
|
||||
return options;
|
||||
};
|
||||
|
||||
configFiles.forEach(function(file) {
|
||||
registerCompiler(interpret.extensions[file.ext]);
|
||||
options.push(requireConfig(file.path));
|
||||
});
|
||||
configFileLoaded = true;
|
||||
}
|
||||
|
||||
if (!configFileLoaded) {
|
||||
return processConfiguredOptions();
|
||||
} else if (options.length === 1) {
|
||||
return processConfiguredOptions(options[0]);
|
||||
} else {
|
||||
return processConfiguredOptions(options);
|
||||
}
|
||||
|
||||
function processConfiguredOptions(options) {
|
||||
if (options) {
|
||||
validateOptions(options);
|
||||
} else {
|
||||
options = {};
|
||||
}
|
||||
|
||||
// process Promise
|
||||
if (typeof options.then === "function") {
|
||||
return options.then(processConfiguredOptions);
|
||||
}
|
||||
|
||||
// process ES6 default
|
||||
if (typeof options === "object" && typeof options.default === "object") {
|
||||
return processConfiguredOptions(options.default);
|
||||
}
|
||||
|
||||
// filter multi-config by name
|
||||
if (Array.isArray(options) && argv["config-name"]) {
|
||||
const namedOptions = options.filter(function(opt) {
|
||||
return opt.name === argv["config-name"];
|
||||
});
|
||||
if (namedOptions.length === 0) {
|
||||
console.error("Configuration with name '" + argv["config-name"] + "' was not found.");
|
||||
process.exit(-1); // eslint-disable-line
|
||||
} else if (namedOptions.length === 1) {
|
||||
return processConfiguredOptions(namedOptions[0]);
|
||||
}
|
||||
options = namedOptions;
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
options.forEach(processOptions);
|
||||
} else {
|
||||
processOptions(options);
|
||||
}
|
||||
|
||||
if (argv.context) {
|
||||
options.context = path.resolve(argv.context);
|
||||
}
|
||||
if (!options.context) {
|
||||
options.context = process.cwd();
|
||||
}
|
||||
|
||||
if (argv.watch) {
|
||||
options.watch = true;
|
||||
}
|
||||
|
||||
if (argv["watch-aggregate-timeout"]) {
|
||||
options.watchOptions = options.watchOptions || {};
|
||||
options.watchOptions.aggregateTimeout = +argv["watch-aggregate-timeout"];
|
||||
}
|
||||
|
||||
if (typeof argv["watch-poll"] !== "undefined") {
|
||||
options.watchOptions = options.watchOptions || {};
|
||||
if (argv["watch-poll"] === "true" || argv["watch-poll"] === "") options.watchOptions.poll = true;
|
||||
else if (!isNaN(argv["watch-poll"])) options.watchOptions.poll = +argv["watch-poll"];
|
||||
}
|
||||
|
||||
if (argv["watch-stdin"]) {
|
||||
options.watchOptions = options.watchOptions || {};
|
||||
options.watchOptions.stdin = true;
|
||||
options.watch = true;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function processOptions(options) {
|
||||
function ifArg(name, fn, init, finalize) {
|
||||
const isArray = Array.isArray(argv[name]);
|
||||
const isSet = typeof argv[name] !== "undefined" && argv[name] !== null;
|
||||
if (!isArray && !isSet) return;
|
||||
|
||||
init && init();
|
||||
if (isArray) argv[name].forEach(fn);
|
||||
else if (isSet) fn(argv[name], -1);
|
||||
finalize && finalize();
|
||||
}
|
||||
|
||||
function ifArgPair(name, fn, init, finalize) {
|
||||
ifArg(
|
||||
name,
|
||||
function(content, idx) {
|
||||
const i = content.indexOf("=");
|
||||
if (i < 0) {
|
||||
return fn(null, content, idx);
|
||||
} else {
|
||||
return fn(content.substr(0, i), content.substr(i + 1), idx);
|
||||
}
|
||||
},
|
||||
init,
|
||||
finalize
|
||||
);
|
||||
}
|
||||
|
||||
function ifBooleanArg(name, fn) {
|
||||
ifArg(name, function(bool) {
|
||||
if (bool) {
|
||||
fn();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mapArgToBoolean(name, optionName) {
|
||||
ifArg(name, function(bool) {
|
||||
if (bool === true) options[optionName || name] = true;
|
||||
else if (bool === false) options[optionName || name] = false;
|
||||
});
|
||||
}
|
||||
|
||||
function loadPlugin(name) {
|
||||
const loadUtils = require("loader-utils");
|
||||
let args;
|
||||
try {
|
||||
const p = name && name.indexOf("?");
|
||||
if (p > -1) {
|
||||
args = loadUtils.parseQuery(name.substring(p));
|
||||
name = name.substring(0, p);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Invalid plugin arguments " + name + " (" + e + ").");
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
|
||||
let path;
|
||||
try {
|
||||
const resolve = require("enhanced-resolve");
|
||||
path = resolve.sync(process.cwd(), name);
|
||||
} catch (e) {
|
||||
console.log("Cannot resolve plugin " + name + ".");
|
||||
process.exit(-1); // eslint-disable-line
|
||||
}
|
||||
let Plugin;
|
||||
try {
|
||||
Plugin = require(path);
|
||||
} catch (e) {
|
||||
console.log("Cannot load plugin " + name + ". (" + path + ")");
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
return new Plugin(args);
|
||||
} catch (e) {
|
||||
console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function ensureObject(parent, name, force) {
|
||||
if (force || typeof parent[name] !== "object" || parent[name] === null) {
|
||||
parent[name] = {};
|
||||
}
|
||||
}
|
||||
|
||||
function ensureArray(parent, name) {
|
||||
if (!Array.isArray(parent[name])) {
|
||||
parent[name] = [];
|
||||
}
|
||||
}
|
||||
|
||||
function addPlugin(options, plugin) {
|
||||
ensureArray(options, "plugins");
|
||||
options.plugins.unshift(plugin);
|
||||
}
|
||||
|
||||
ifArg("mode", function(value) {
|
||||
options.mode = value;
|
||||
});
|
||||
|
||||
ifArgPair(
|
||||
"entry",
|
||||
function(name, entry) {
|
||||
if (typeof options.entry[name] !== "undefined" && options.entry[name] !== null) {
|
||||
options.entry[name] = [].concat(options.entry[name]).concat(entry);
|
||||
} else {
|
||||
options.entry[name] = entry;
|
||||
}
|
||||
},
|
||||
function() {
|
||||
ensureObject(options, "entry", true);
|
||||
}
|
||||
);
|
||||
|
||||
function bindRules(arg) {
|
||||
ifArgPair(
|
||||
arg,
|
||||
function(name, binding) {
|
||||
if (name === null) {
|
||||
name = binding;
|
||||
binding += "-loader";
|
||||
}
|
||||
const rule = {
|
||||
test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape
|
||||
loader: binding
|
||||
};
|
||||
if (arg === "module-bind-pre") {
|
||||
rule.enforce = "pre";
|
||||
} else if (arg === "module-bind-post") {
|
||||
rule.enforce = "post";
|
||||
}
|
||||
options.module.rules.push(rule);
|
||||
},
|
||||
function() {
|
||||
ensureObject(options, "module");
|
||||
ensureArray(options.module, "rules");
|
||||
}
|
||||
);
|
||||
}
|
||||
bindRules("module-bind");
|
||||
bindRules("module-bind-pre");
|
||||
bindRules("module-bind-post");
|
||||
|
||||
let defineObject;
|
||||
ifArgPair(
|
||||
"define",
|
||||
function(name, value) {
|
||||
if (name === null) {
|
||||
name = value;
|
||||
value = true;
|
||||
}
|
||||
defineObject[name] = value;
|
||||
},
|
||||
function() {
|
||||
defineObject = {};
|
||||
},
|
||||
function() {
|
||||
const DefinePlugin = require("webpack").DefinePlugin;
|
||||
addPlugin(options, new DefinePlugin(defineObject));
|
||||
}
|
||||
);
|
||||
|
||||
ifArg("output-path", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.path = path.resolve(value);
|
||||
});
|
||||
|
||||
ifArg("output-filename", function(value) {
|
||||
ensureObject(options, "output");
|
||||
|
||||
options.output.filename = value;
|
||||
});
|
||||
|
||||
ifArg("output-chunk-filename", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.chunkFilename = value;
|
||||
});
|
||||
|
||||
ifArg("output-source-map-filename", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.sourceMapFilename = value;
|
||||
});
|
||||
|
||||
ifArg("output-public-path", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.publicPath = value;
|
||||
});
|
||||
|
||||
ifArg("output-jsonp-function", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.jsonpFunction = value;
|
||||
});
|
||||
|
||||
ifBooleanArg("output-pathinfo", function() {
|
||||
ensureObject(options, "output");
|
||||
options.output.pathinfo = true;
|
||||
});
|
||||
|
||||
ifArg("output-library", function(value) {
|
||||
ensureObject(options, "output");
|
||||
ensureArray(options.output, "library");
|
||||
options.output.library.push(value);
|
||||
});
|
||||
|
||||
ifArg("output-library-target", function(value) {
|
||||
ensureObject(options, "output");
|
||||
options.output.libraryTarget = value;
|
||||
});
|
||||
|
||||
ifArg("records-input-path", function(value) {
|
||||
options.recordsInputPath = path.resolve(value);
|
||||
});
|
||||
|
||||
ifArg("records-output-path", function(value) {
|
||||
options.recordsOutputPath = path.resolve(value);
|
||||
});
|
||||
|
||||
ifArg("records-path", function(value) {
|
||||
options.recordsPath = path.resolve(value);
|
||||
});
|
||||
|
||||
ifArg("target", function(value) {
|
||||
options.target = value;
|
||||
});
|
||||
|
||||
mapArgToBoolean("cache");
|
||||
|
||||
ifBooleanArg("hot", function() {
|
||||
const HotModuleReplacementPlugin = require("webpack").HotModuleReplacementPlugin;
|
||||
addPlugin(options, new HotModuleReplacementPlugin());
|
||||
});
|
||||
|
||||
ifBooleanArg("no-cache", function() {
|
||||
options.cache = false;
|
||||
});
|
||||
|
||||
ifBooleanArg("debug", function() {
|
||||
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
|
||||
addPlugin(
|
||||
options,
|
||||
new LoaderOptionsPlugin({
|
||||
debug: true
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
ifArg("devtool", function(value) {
|
||||
options.devtool = value;
|
||||
});
|
||||
|
||||
function processResolveAlias(arg, key) {
|
||||
ifArgPair(arg, function(name, value) {
|
||||
if (!name) {
|
||||
throw new Error("--" + arg + " <string>=<string>");
|
||||
}
|
||||
ensureObject(options, key);
|
||||
ensureObject(options[key], "alias");
|
||||
options[key].alias[name] = value;
|
||||
});
|
||||
}
|
||||
processResolveAlias("resolve-alias", "resolve");
|
||||
processResolveAlias("resolve-loader-alias", "resolveLoader");
|
||||
|
||||
ifArg("resolve-extensions", function(value) {
|
||||
ensureObject(options, "resolve");
|
||||
if (Array.isArray(value)) {
|
||||
options.resolve.extensions = value;
|
||||
} else {
|
||||
options.resolve.extensions = value.split(/,\s*/);
|
||||
}
|
||||
});
|
||||
|
||||
ifArg("optimize-max-chunks", function(value) {
|
||||
const LimitChunkCountPlugin = require("webpack").optimize.LimitChunkCountPlugin;
|
||||
addPlugin(
|
||||
options,
|
||||
new LimitChunkCountPlugin({
|
||||
maxChunks: parseInt(value, 10)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
ifArg("optimize-min-chunk-size", function(value) {
|
||||
const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin;
|
||||
addPlugin(
|
||||
options,
|
||||
new MinChunkSizePlugin({
|
||||
minChunkSize: parseInt(value, 10)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
ifBooleanArg("optimize-minimize", function() {
|
||||
const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin;
|
||||
addPlugin(
|
||||
options,
|
||||
new LoaderOptionsPlugin({
|
||||
minimize: true
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
ifArg("prefetch", function(request) {
|
||||
const PrefetchPlugin = require("webpack").PrefetchPlugin;
|
||||
addPlugin(options, new PrefetchPlugin(request));
|
||||
});
|
||||
|
||||
ifArg("provide", function(value) {
|
||||
const idx = value.indexOf("=");
|
||||
let name;
|
||||
if (idx >= 0) {
|
||||
name = value.substr(0, idx);
|
||||
value = value.substr(idx + 1);
|
||||
} else {
|
||||
name = value;
|
||||
}
|
||||
const ProvidePlugin = require("webpack").ProvidePlugin;
|
||||
addPlugin(options, new ProvidePlugin(name, value));
|
||||
});
|
||||
|
||||
ifArg("plugin", function(value) {
|
||||
addPlugin(options, loadPlugin(value));
|
||||
});
|
||||
|
||||
mapArgToBoolean("bail");
|
||||
|
||||
mapArgToBoolean("profile");
|
||||
|
||||
if (argv._.length > 0) {
|
||||
ensureObject(options, "entry", true);
|
||||
|
||||
const addTo = function addTo(name, entry) {
|
||||
if (options.entry[name]) {
|
||||
if (!Array.isArray(options.entry[name])) {
|
||||
options.entry[name] = [options.entry[name]];
|
||||
}
|
||||
options.entry[name].push(entry);
|
||||
} else {
|
||||
options.entry[name] = entry;
|
||||
}
|
||||
};
|
||||
argv._.forEach(function(content) {
|
||||
const i = content.indexOf("=");
|
||||
const j = content.indexOf("?");
|
||||
if (i < 0 || (j >= 0 && j < i)) {
|
||||
const resolved = path.resolve(content);
|
||||
if (fs.existsSync(resolved)) {
|
||||
addTo("main", `${resolved}${fs.statSync(resolved).isDirectory() ? path.sep : ""}`);
|
||||
} else {
|
||||
addTo("main", content);
|
||||
}
|
||||
} else {
|
||||
addTo(content.substr(0, i), content.substr(i + 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
33
node_modules/webpack-cli/bin/utils/errorHelpers.js
generated
vendored
Normal file
33
node_modules/webpack-cli/bin/utils/errorHelpers.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const { WEBPACK_OPTIONS_FLAG } = require("./constants");
|
||||
|
||||
exports.cutOffByFlag = (stack, flag) => {
|
||||
stack = stack.split("\n");
|
||||
for (let i = 0; i < stack.length; i++) if (stack[i].indexOf(flag) >= 0) stack.length = i;
|
||||
return stack.join("\n");
|
||||
};
|
||||
|
||||
exports.cutOffWebpackOptions = stack => exports.cutOffByFlag(stack, WEBPACK_OPTIONS_FLAG);
|
||||
|
||||
exports.cutOffMultilineMessage = (stack, message) => {
|
||||
stack = stack.split("\n");
|
||||
message = message.split("\n");
|
||||
|
||||
return stack
|
||||
.reduce(
|
||||
(acc, line, idx) => (line === message[idx] || line === `Error: ${message[idx]}` ? acc : acc.concat(line)),
|
||||
[]
|
||||
)
|
||||
.join("\n");
|
||||
};
|
||||
|
||||
exports.cleanUpWebpackOptions = (stack, message) => {
|
||||
stack = exports.cutOffWebpackOptions(stack);
|
||||
stack = exports.cutOffMultilineMessage(stack, message);
|
||||
return stack;
|
||||
};
|
||||
24
node_modules/webpack-cli/bin/utils/prepareOptions.js
generated
vendored
Normal file
24
node_modules/webpack-cli/bin/utils/prepareOptions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function prepareOptions(options, argv) {
|
||||
argv = argv || {};
|
||||
options = handleExport(options);
|
||||
|
||||
return Array.isArray(options)
|
||||
? options.map(_options => handleFunction(_options, argv))
|
||||
: handleFunction(options, argv);
|
||||
};
|
||||
|
||||
function handleExport(options) {
|
||||
const isES6DefaultExported =
|
||||
typeof options === "object" && options !== null && typeof options.default !== "undefined";
|
||||
|
||||
return isES6DefaultExported ? options.default : options;
|
||||
}
|
||||
|
||||
function handleFunction(options, argv) {
|
||||
if (typeof options === "function") {
|
||||
options = options(argv.env, argv);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
142
node_modules/webpack-cli/bin/utils/prompt-command.js
generated
vendored
Normal file
142
node_modules/webpack-cli/bin/utils/prompt-command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
// based on https://github.com/webpack/webpack/blob/master/bin/webpack.js
|
||||
|
||||
/**
|
||||
* @param {string} command process to run
|
||||
* @param {string[]} args commandline arguments
|
||||
* @returns {Promise<void>} promise
|
||||
*/
|
||||
const runCommand = (command, args) => {
|
||||
const cp = require("child_process");
|
||||
return new Promise((resolve, reject) => {
|
||||
const executedCommand = cp.spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
shell: true
|
||||
});
|
||||
|
||||
executedCommand.on("error", error => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
executedCommand.on("exit", code => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const npmGlobalRoot = () => {
|
||||
const cp = require("child_process");
|
||||
return new Promise((resolve, reject) => {
|
||||
const command = cp.spawn("npm", ["root", "-g"]);
|
||||
command.on("error", error => reject(error));
|
||||
command.stdout.on("data", data => resolve(data.toString()));
|
||||
command.stderr.on("data", data => reject(data));
|
||||
});
|
||||
};
|
||||
|
||||
const runWhenInstalled = (packages, pathForCmd, ...args) => {
|
||||
const currentPackage = require(pathForCmd);
|
||||
const func = currentPackage.default;
|
||||
if (typeof func !== "function") {
|
||||
throw new Error(`@webpack-cli/${packages} failed to export a default function`);
|
||||
}
|
||||
return func(...args);
|
||||
};
|
||||
|
||||
module.exports = function promptForInstallation(packages, ...args) {
|
||||
const nameOfPackage = "@webpack-cli/" + packages;
|
||||
let packageIsInstalled = false;
|
||||
let pathForCmd;
|
||||
try {
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
|
||||
if (!fs.existsSync(pathForCmd)) {
|
||||
const globalModules = require("global-modules");
|
||||
pathForCmd = globalModules + "/@webpack-cli/" + packages;
|
||||
require.resolve(pathForCmd);
|
||||
} else {
|
||||
require.resolve(pathForCmd);
|
||||
}
|
||||
packageIsInstalled = true;
|
||||
} catch (err) {
|
||||
packageIsInstalled = false;
|
||||
}
|
||||
if (!packageIsInstalled) {
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const readLine = require("readline");
|
||||
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
|
||||
|
||||
const packageManager = isYarn ? "yarn" : "npm";
|
||||
const options = ["install", "-D", nameOfPackage];
|
||||
|
||||
if (isYarn) {
|
||||
options[0] = "add";
|
||||
}
|
||||
|
||||
if (packages === "init") {
|
||||
if (isYarn) {
|
||||
options.splice(1, 1); // remove '-D'
|
||||
options.splice(0, 0, "global");
|
||||
} else {
|
||||
options[1] = "-g";
|
||||
}
|
||||
}
|
||||
|
||||
const commandToBeRun = `${packageManager} ${options.join(" ")}`;
|
||||
|
||||
const question = `Would you like to install ${packages}? (That will run ${commandToBeRun}) (yes/NO) : `;
|
||||
|
||||
console.error(`The command moved into a separate package: ${nameOfPackage}`);
|
||||
const questionInterface = readLine.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
questionInterface.question(question, answer => {
|
||||
questionInterface.close();
|
||||
switch (answer.toLowerCase()) {
|
||||
case "y":
|
||||
case "yes":
|
||||
case "1": {
|
||||
runCommand(packageManager, options)
|
||||
.then(_ => {
|
||||
if (packages === "init") {
|
||||
npmGlobalRoot()
|
||||
.then(root => {
|
||||
const pathtoInit = path.resolve(root.trim(), "@webpack-cli", "init");
|
||||
return pathtoInit;
|
||||
})
|
||||
.then(pathForInit => {
|
||||
return require(pathForInit).default(...args);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
pathForCmd = path.resolve(process.cwd(), "node_modules", "@webpack-cli", packages);
|
||||
return runWhenInstalled(packages, pathForCmd, ...args);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.error(`${nameOfPackage} needs to be installed in order to run the command.`);
|
||||
process.exitCode = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return runWhenInstalled(packages, pathForCmd, ...args);
|
||||
}
|
||||
};
|
||||
21
node_modules/webpack-cli/bin/utils/validate-options.js
generated
vendored
Normal file
21
node_modules/webpack-cli/bin/utils/validate-options.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const webpackConfigurationSchema = require("../config/webpackConfigurationSchema.json");
|
||||
const validateSchema = require("webpack").validateSchema;
|
||||
|
||||
module.exports = function validateOptions(options) {
|
||||
let error;
|
||||
try {
|
||||
const errors = validateSchema(webpackConfigurationSchema, options);
|
||||
if (errors && errors.length > 0) {
|
||||
const { WebpackOptionsValidationError } = require("webpack");
|
||||
error = new WebpackOptionsValidationError(errors);
|
||||
}
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
console.error(error.message);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
process.exit(-1);
|
||||
}
|
||||
};
|
||||
1
node_modules/webpack-cli/node_modules/.bin/import-local-fixture
generated
vendored
Symbolic link
1
node_modules/webpack-cli/node_modules/.bin/import-local-fixture
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../import-local/fixtures/cli.js
|
||||
65
node_modules/webpack-cli/node_modules/cliui/CHANGELOG.md
generated
vendored
Normal file
65
node_modules/webpack-cli/node_modules/cliui/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# Change Log
|
||||
|
||||
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.
|
||||
|
||||
# [5.0.0](https://github.com/yargs/cliui/compare/v4.1.0...v5.0.0) (2019-04-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update wrap-ansi to fix compatibility with latest versions of chalk. ([#60](https://github.com/yargs/cliui/issues/60)) ([7bf79ae](https://github.com/yargs/cliui/commit/7bf79ae))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Drop support for node < 6.
|
||||
|
||||
|
||||
|
||||
<a name="4.1.0"></a>
|
||||
# [4.1.0](https://github.com/yargs/cliui/compare/v4.0.0...v4.1.0) (2018-04-23)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add resetOutput method ([#57](https://github.com/yargs/cliui/issues/57)) ([7246902](https://github.com/yargs/cliui/commit/7246902))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
# [4.0.0](https://github.com/yargs/cliui/compare/v3.2.0...v4.0.0) (2017-12-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* downgrades strip-ansi to version 3.0.1 ([#54](https://github.com/yargs/cliui/issues/54)) ([5764c46](https://github.com/yargs/cliui/commit/5764c46))
|
||||
* set env variable FORCE_COLOR. ([#56](https://github.com/yargs/cliui/issues/56)) ([7350e36](https://github.com/yargs/cliui/commit/7350e36))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* drop support for node < 4 ([#53](https://github.com/yargs/cliui/issues/53)) ([b105376](https://github.com/yargs/cliui/commit/b105376))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add fallback for window width ([#45](https://github.com/yargs/cliui/issues/45)) ([d064922](https://github.com/yargs/cliui/commit/d064922))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* officially drop support for Node < 4
|
||||
|
||||
|
||||
|
||||
<a name="3.2.0"></a>
|
||||
# [3.2.0](https://github.com/yargs/cliui/compare/v3.1.2...v3.2.0) (2016-04-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reduces tarball size ([acc6c33](https://github.com/yargs/cliui/commit/acc6c33))
|
||||
|
||||
### Features
|
||||
|
||||
* adds standard-version for release management ([ff84e32](https://github.com/yargs/cliui/commit/ff84e32))
|
||||
14
node_modules/webpack-cli/node_modules/cliui/LICENSE.txt
generated
vendored
Normal file
14
node_modules/webpack-cli/node_modules/cliui/LICENSE.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Copyright (c) 2015, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice
|
||||
appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
115
node_modules/webpack-cli/node_modules/cliui/README.md
generated
vendored
Normal file
115
node_modules/webpack-cli/node_modules/cliui/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
# cliui
|
||||
|
||||
[](https://travis-ci.org/yargs/cliui)
|
||||
[](https://coveralls.io/r/yargs/cliui?branch=)
|
||||
[](https://www.npmjs.com/package/cliui)
|
||||
[](https://github.com/conventional-changelog/standard-version)
|
||||
|
||||
easily create complex multi-column command-line-interfaces.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var ui = require('cliui')()
|
||||
|
||||
ui.div('Usage: $0 [command] [options]')
|
||||
|
||||
ui.div({
|
||||
text: 'Options:',
|
||||
padding: [2, 0, 2, 0]
|
||||
})
|
||||
|
||||
ui.div(
|
||||
{
|
||||
text: "-f, --file",
|
||||
width: 20,
|
||||
padding: [0, 4, 0, 4]
|
||||
},
|
||||
{
|
||||
text: "the file to load." +
|
||||
chalk.green("(if this description is long it wraps).")
|
||||
,
|
||||
width: 20
|
||||
},
|
||||
{
|
||||
text: chalk.red("[required]"),
|
||||
align: 'right'
|
||||
}
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
<img width="500" src="screenshot.png">
|
||||
|
||||
## Layout DSL
|
||||
|
||||
cliui exposes a simple layout DSL:
|
||||
|
||||
If you create a single `ui.div`, passing a string rather than an
|
||||
object:
|
||||
|
||||
* `\n`: characters will be interpreted as new rows.
|
||||
* `\t`: characters will be interpreted as new columns.
|
||||
* `\s`: characters will be interpreted as padding.
|
||||
|
||||
**as an example...**
|
||||
|
||||
```js
|
||||
var ui = require('./')({
|
||||
width: 60
|
||||
})
|
||||
|
||||
ui.div(
|
||||
'Usage: node ./bin/foo.js\n' +
|
||||
' <regex>\t provide a regex\n' +
|
||||
' <glob>\t provide a glob\t [required]'
|
||||
)
|
||||
|
||||
console.log(ui.toString())
|
||||
```
|
||||
|
||||
**will output:**
|
||||
|
||||
```shell
|
||||
Usage: node ./bin/foo.js
|
||||
<regex> provide a regex
|
||||
<glob> provide a glob [required]
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
```js
|
||||
cliui = require('cliui')
|
||||
```
|
||||
|
||||
### cliui({width: integer})
|
||||
|
||||
Specify the maximum width of the UI being generated.
|
||||
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
|
||||
|
||||
### cliui({wrap: boolean})
|
||||
|
||||
Enable or disable the wrapping of text in a column.
|
||||
|
||||
### cliui.div(column, column, column)
|
||||
|
||||
Create a row with any number of columns, a column
|
||||
can either be a string, or an object with the following
|
||||
options:
|
||||
|
||||
* **text:** some text to place in the column.
|
||||
* **width:** the width of a column.
|
||||
* **align:** alignment, `right` or `center`.
|
||||
* **padding:** `[top, right, bottom, left]`.
|
||||
* **border:** should a border be placed around the div?
|
||||
|
||||
### cliui.span(column, column, column)
|
||||
|
||||
Similar to `div`, except the next row will be appended without
|
||||
a new line being created.
|
||||
|
||||
### cliui.resetOutput()
|
||||
|
||||
Resets the UI elements of the current cliui instance, maintaining the values
|
||||
set for `width` and `wrap`.
|
||||
324
node_modules/webpack-cli/node_modules/cliui/index.js
generated
vendored
Normal file
324
node_modules/webpack-cli/node_modules/cliui/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
var stringWidth = require('string-width')
|
||||
var stripAnsi = require('strip-ansi')
|
||||
var wrap = require('wrap-ansi')
|
||||
var align = {
|
||||
right: alignRight,
|
||||
center: alignCenter
|
||||
}
|
||||
var top = 0
|
||||
var right = 1
|
||||
var bottom = 2
|
||||
var left = 3
|
||||
|
||||
function UI (opts) {
|
||||
this.width = opts.width
|
||||
this.wrap = opts.wrap
|
||||
this.rows = []
|
||||
}
|
||||
|
||||
UI.prototype.span = function () {
|
||||
var cols = this.div.apply(this, arguments)
|
||||
cols.span = true
|
||||
}
|
||||
|
||||
UI.prototype.resetOutput = function () {
|
||||
this.rows = []
|
||||
}
|
||||
|
||||
UI.prototype.div = function () {
|
||||
if (arguments.length === 0) this.div('')
|
||||
if (this.wrap && this._shouldApplyLayoutDSL.apply(this, arguments)) {
|
||||
return this._applyLayoutDSL(arguments[0])
|
||||
}
|
||||
|
||||
var cols = []
|
||||
|
||||
for (var i = 0, arg; (arg = arguments[i]) !== undefined; i++) {
|
||||
if (typeof arg === 'string') cols.push(this._colFromString(arg))
|
||||
else cols.push(arg)
|
||||
}
|
||||
|
||||
this.rows.push(cols)
|
||||
return cols
|
||||
}
|
||||
|
||||
UI.prototype._shouldApplyLayoutDSL = function () {
|
||||
return arguments.length === 1 && typeof arguments[0] === 'string' &&
|
||||
/[\t\n]/.test(arguments[0])
|
||||
}
|
||||
|
||||
UI.prototype._applyLayoutDSL = function (str) {
|
||||
var _this = this
|
||||
var rows = str.split('\n')
|
||||
var leftColumnWidth = 0
|
||||
|
||||
// simple heuristic for layout, make sure the
|
||||
// second column lines up along the left-hand.
|
||||
// don't allow the first column to take up more
|
||||
// than 50% of the screen.
|
||||
rows.forEach(function (row) {
|
||||
var columns = row.split('\t')
|
||||
if (columns.length > 1 && stringWidth(columns[0]) > leftColumnWidth) {
|
||||
leftColumnWidth = Math.min(
|
||||
Math.floor(_this.width * 0.5),
|
||||
stringWidth(columns[0])
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
// generate a table:
|
||||
// replacing ' ' with padding calculations.
|
||||
// using the algorithmically generated width.
|
||||
rows.forEach(function (row) {
|
||||
var columns = row.split('\t')
|
||||
_this.div.apply(_this, columns.map(function (r, i) {
|
||||
return {
|
||||
text: r.trim(),
|
||||
padding: _this._measurePadding(r),
|
||||
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
return this.rows[this.rows.length - 1]
|
||||
}
|
||||
|
||||
UI.prototype._colFromString = function (str) {
|
||||
return {
|
||||
text: str,
|
||||
padding: this._measurePadding(str)
|
||||
}
|
||||
}
|
||||
|
||||
UI.prototype._measurePadding = function (str) {
|
||||
// measure padding without ansi escape codes
|
||||
var noAnsi = stripAnsi(str)
|
||||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length]
|
||||
}
|
||||
|
||||
UI.prototype.toString = function () {
|
||||
var _this = this
|
||||
var lines = []
|
||||
|
||||
_this.rows.forEach(function (row, i) {
|
||||
_this.rowToString(row, lines)
|
||||
})
|
||||
|
||||
// don't display any lines with the
|
||||
// hidden flag set.
|
||||
lines = lines.filter(function (line) {
|
||||
return !line.hidden
|
||||
})
|
||||
|
||||
return lines.map(function (line) {
|
||||
return line.text
|
||||
}).join('\n')
|
||||
}
|
||||
|
||||
UI.prototype.rowToString = function (row, lines) {
|
||||
var _this = this
|
||||
var padding
|
||||
var rrows = this._rasterize(row)
|
||||
var str = ''
|
||||
var ts
|
||||
var width
|
||||
var wrapWidth
|
||||
|
||||
rrows.forEach(function (rrow, r) {
|
||||
str = ''
|
||||
rrow.forEach(function (col, c) {
|
||||
ts = '' // temporary string used during alignment/padding.
|
||||
width = row[c].width // the width with padding.
|
||||
wrapWidth = _this._negatePadding(row[c]) // the width without padding.
|
||||
|
||||
ts += col
|
||||
|
||||
for (var i = 0; i < wrapWidth - stringWidth(col); i++) {
|
||||
ts += ' '
|
||||
}
|
||||
|
||||
// align the string within its column.
|
||||
if (row[c].align && row[c].align !== 'left' && _this.wrap) {
|
||||
ts = align[row[c].align](ts, wrapWidth)
|
||||
if (stringWidth(ts) < wrapWidth) ts += new Array(width - stringWidth(ts)).join(' ')
|
||||
}
|
||||
|
||||
// apply border and padding to string.
|
||||
padding = row[c].padding || [0, 0, 0, 0]
|
||||
if (padding[left]) str += new Array(padding[left] + 1).join(' ')
|
||||
str += addBorder(row[c], ts, '| ')
|
||||
str += ts
|
||||
str += addBorder(row[c], ts, ' |')
|
||||
if (padding[right]) str += new Array(padding[right] + 1).join(' ')
|
||||
|
||||
// if prior row is span, try to render the
|
||||
// current row on the prior line.
|
||||
if (r === 0 && lines.length > 0) {
|
||||
str = _this._renderInline(str, lines[lines.length - 1])
|
||||
}
|
||||
})
|
||||
|
||||
// remove trailing whitespace.
|
||||
lines.push({
|
||||
text: str.replace(/ +$/, ''),
|
||||
span: row.span
|
||||
})
|
||||
})
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
function addBorder (col, ts, style) {
|
||||
if (col.border) {
|
||||
if (/[.']-+[.']/.test(ts)) return ''
|
||||
else if (ts.trim().length) return style
|
||||
else return ' '
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
// if the full 'source' can render in
|
||||
// the target line, do so.
|
||||
UI.prototype._renderInline = function (source, previousLine) {
|
||||
var leadingWhitespace = source.match(/^ */)[0].length
|
||||
var target = previousLine.text
|
||||
var targetTextWidth = stringWidth(target.trimRight())
|
||||
|
||||
if (!previousLine.span) return source
|
||||
|
||||
// if we're not applying wrapping logic,
|
||||
// just always append to the span.
|
||||
if (!this.wrap) {
|
||||
previousLine.hidden = true
|
||||
return target + source
|
||||
}
|
||||
|
||||
if (leadingWhitespace < targetTextWidth) return source
|
||||
|
||||
previousLine.hidden = true
|
||||
|
||||
return target.trimRight() + new Array(leadingWhitespace - targetTextWidth + 1).join(' ') + source.trimLeft()
|
||||
}
|
||||
|
||||
UI.prototype._rasterize = function (row) {
|
||||
var _this = this
|
||||
var i
|
||||
var rrow
|
||||
var rrows = []
|
||||
var widths = this._columnWidths(row)
|
||||
var wrapped
|
||||
|
||||
// word wrap all columns, and create
|
||||
// a data-structure that is easy to rasterize.
|
||||
row.forEach(function (col, c) {
|
||||
// leave room for left and right padding.
|
||||
col.width = widths[c]
|
||||
if (_this.wrap) wrapped = wrap(col.text, _this._negatePadding(col), { hard: true }).split('\n')
|
||||
else wrapped = col.text.split('\n')
|
||||
|
||||
if (col.border) {
|
||||
wrapped.unshift('.' + new Array(_this._negatePadding(col) + 3).join('-') + '.')
|
||||
wrapped.push("'" + new Array(_this._negatePadding(col) + 3).join('-') + "'")
|
||||
}
|
||||
|
||||
// add top and bottom padding.
|
||||
if (col.padding) {
|
||||
for (i = 0; i < (col.padding[top] || 0); i++) wrapped.unshift('')
|
||||
for (i = 0; i < (col.padding[bottom] || 0); i++) wrapped.push('')
|
||||
}
|
||||
|
||||
wrapped.forEach(function (str, r) {
|
||||
if (!rrows[r]) rrows.push([])
|
||||
|
||||
rrow = rrows[r]
|
||||
|
||||
for (var i = 0; i < c; i++) {
|
||||
if (rrow[i] === undefined) rrow.push('')
|
||||
}
|
||||
rrow.push(str)
|
||||
})
|
||||
})
|
||||
|
||||
return rrows
|
||||
}
|
||||
|
||||
UI.prototype._negatePadding = function (col) {
|
||||
var wrapWidth = col.width
|
||||
if (col.padding) wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0)
|
||||
if (col.border) wrapWidth -= 4
|
||||
return wrapWidth
|
||||
}
|
||||
|
||||
UI.prototype._columnWidths = function (row) {
|
||||
var _this = this
|
||||
var widths = []
|
||||
var unset = row.length
|
||||
var unsetWidth
|
||||
var remainingWidth = this.width
|
||||
|
||||
// column widths can be set in config.
|
||||
row.forEach(function (col, i) {
|
||||
if (col.width) {
|
||||
unset--
|
||||
widths[i] = col.width
|
||||
remainingWidth -= col.width
|
||||
} else {
|
||||
widths[i] = undefined
|
||||
}
|
||||
})
|
||||
|
||||
// any unset widths should be calculated.
|
||||
if (unset) unsetWidth = Math.floor(remainingWidth / unset)
|
||||
widths.forEach(function (w, i) {
|
||||
if (!_this.wrap) widths[i] = row[i].width || stringWidth(row[i].text)
|
||||
else if (w === undefined) widths[i] = Math.max(unsetWidth, _minWidth(row[i]))
|
||||
})
|
||||
|
||||
return widths
|
||||
}
|
||||
|
||||
// calculates the minimum width of
|
||||
// a column, based on padding preferences.
|
||||
function _minWidth (col) {
|
||||
var padding = col.padding || []
|
||||
var minWidth = 1 + (padding[left] || 0) + (padding[right] || 0)
|
||||
if (col.border) minWidth += 4
|
||||
return minWidth
|
||||
}
|
||||
|
||||
function getWindowWidth () {
|
||||
if (typeof process === 'object' && process.stdout && process.stdout.columns) return process.stdout.columns
|
||||
}
|
||||
|
||||
function alignRight (str, width) {
|
||||
str = str.trim()
|
||||
var padding = ''
|
||||
var strWidth = stringWidth(str)
|
||||
|
||||
if (strWidth < width) {
|
||||
padding = new Array(width - strWidth + 1).join(' ')
|
||||
}
|
||||
|
||||
return padding + str
|
||||
}
|
||||
|
||||
function alignCenter (str, width) {
|
||||
str = str.trim()
|
||||
var padding = ''
|
||||
var strWidth = stringWidth(str.trim())
|
||||
|
||||
if (strWidth < width) {
|
||||
padding = new Array(parseInt((width - strWidth) / 2, 10) + 1).join(' ')
|
||||
}
|
||||
|
||||
return padding + str
|
||||
}
|
||||
|
||||
module.exports = function (opts) {
|
||||
opts = opts || {}
|
||||
|
||||
return new UI({
|
||||
width: (opts || {}).width || getWindowWidth() || 80,
|
||||
wrap: typeof opts.wrap === 'boolean' ? opts.wrap : true
|
||||
})
|
||||
}
|
||||
67
node_modules/webpack-cli/node_modules/cliui/package.json
generated
vendored
Normal file
67
node_modules/webpack-cli/node_modules/cliui/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"name": "cliui",
|
||||
"version": "5.0.0",
|
||||
"description": "easily create complex multi-column command-line-interfaces",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"pretest": "standard",
|
||||
"test": "nyc mocha",
|
||||
"coverage": "nyc --reporter=text-lcov mocha | coveralls",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/yargs/cliui.git"
|
||||
},
|
||||
"config": {
|
||||
"blanket": {
|
||||
"pattern": [
|
||||
"index.js"
|
||||
],
|
||||
"data-cover-never": [
|
||||
"node_modules",
|
||||
"test"
|
||||
],
|
||||
"output-reporter": "spec"
|
||||
}
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"**/example/**"
|
||||
],
|
||||
"globals": [
|
||||
"it"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
"command-line",
|
||||
"layout",
|
||||
"design",
|
||||
"console",
|
||||
"wrap",
|
||||
"table"
|
||||
],
|
||||
"author": "Ben Coe <ben@npmjs.com>",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^3.1.0",
|
||||
"strip-ansi": "^5.2.0",
|
||||
"wrap-ansi": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"coveralls": "^3.0.3",
|
||||
"mocha": "^6.0.2",
|
||||
"nyc": "^13.3.0",
|
||||
"standard": "^12.0.1",
|
||||
"standard-version": "^5.0.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"engine": {
|
||||
"node": ">=6"
|
||||
}
|
||||
}
|
||||
20
node_modules/webpack-cli/node_modules/emoji-regex/LICENSE-MIT.txt
generated
vendored
Normal file
20
node_modules/webpack-cli/node_modules/emoji-regex/LICENSE-MIT.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
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.
|
||||
73
node_modules/webpack-cli/node_modules/emoji-regex/README.md
generated
vendored
Normal file
73
node_modules/webpack-cli/node_modules/emoji-regex/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# emoji-regex [](https://travis-ci.org/mathiasbynens/emoji-regex)
|
||||
|
||||
_emoji-regex_ offers a regular expression to match all emoji symbols (including textual representations of emoji) as per the Unicode Standard.
|
||||
|
||||
This repository contains a script that generates this regular expression based on [the data from Unicode Technical Report #51](https://github.com/mathiasbynens/unicode-tr51). Because of this, the regular expression can easily be updated whenever new emoji are added to the Unicode standard.
|
||||
|
||||
## Installation
|
||||
|
||||
Via [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
npm install emoji-regex
|
||||
```
|
||||
|
||||
In [Node.js](https://nodejs.org/):
|
||||
|
||||
```js
|
||||
const emojiRegex = require('emoji-regex');
|
||||
// Note: because the regular expression has the global flag set, this module
|
||||
// exports a function that returns the regex rather than exporting the regular
|
||||
// expression itself, to make it impossible to (accidentally) mutate the
|
||||
// original regular expression.
|
||||
|
||||
const text = `
|
||||
\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation)
|
||||
\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji
|
||||
\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base)
|
||||
\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier
|
||||
`;
|
||||
|
||||
const regex = emojiRegex();
|
||||
let match;
|
||||
while (match = regex.exec(text)) {
|
||||
const emoji = match[0];
|
||||
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
|
||||
}
|
||||
```
|
||||
|
||||
Console output:
|
||||
|
||||
```
|
||||
Matched sequence ⌚ — code points: 1
|
||||
Matched sequence ⌚ — code points: 1
|
||||
Matched sequence ↔️ — code points: 2
|
||||
Matched sequence ↔️ — code points: 2
|
||||
Matched sequence 👩 — code points: 1
|
||||
Matched sequence 👩 — code points: 1
|
||||
Matched sequence 👩🏿 — code points: 2
|
||||
Matched sequence 👩🏿 — code points: 2
|
||||
```
|
||||
|
||||
To match emoji in their textual representation as well (i.e. emoji that are not `Emoji_Presentation` symbols and that aren’t forced to render as emoji by a variation selector), `require` the other regex:
|
||||
|
||||
```js
|
||||
const emojiRegex = require('emoji-regex/text.js');
|
||||
```
|
||||
|
||||
Additionally, in environments which support ES2015 Unicode escapes, you may `require` ES2015-style versions of the regexes:
|
||||
|
||||
```js
|
||||
const emojiRegex = require('emoji-regex/es2015/index.js');
|
||||
const emojiRegexText = require('emoji-regex/es2015/text.js');
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||
|---|
|
||||
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||
|
||||
## License
|
||||
|
||||
_emoji-regex_ is available under the [MIT](https://mths.be/mit) license.
|
||||
6
node_modules/webpack-cli/node_modules/emoji-regex/es2015/index.js
generated
vendored
Normal file
6
node_modules/webpack-cli/node_modules/emoji-regex/es2015/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/webpack-cli/node_modules/emoji-regex/es2015/text.js
generated
vendored
Normal file
6
node_modules/webpack-cli/node_modules/emoji-regex/es2015/text.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/webpack-cli/node_modules/emoji-regex/index.d.ts
generated
vendored
Normal file
5
node_modules/webpack-cli/node_modules/emoji-regex/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
declare module 'emoji-regex' {
|
||||
function emojiRegex(): RegExp;
|
||||
|
||||
export default emojiRegex;
|
||||
}
|
||||
6
node_modules/webpack-cli/node_modules/emoji-regex/index.js
generated
vendored
Normal file
6
node_modules/webpack-cli/node_modules/emoji-regex/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
node_modules/webpack-cli/node_modules/emoji-regex/package.json
generated
vendored
Normal file
51
node_modules/webpack-cli/node_modules/emoji-regex/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "emoji-regex",
|
||||
"version": "7.0.3",
|
||||
"description": "A regular expression to match all Emoji-only symbols as per the Unicode Standard.",
|
||||
"homepage": "https://mths.be/emoji-regex",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"regex",
|
||||
"regexp",
|
||||
"regular expressions",
|
||||
"code points",
|
||||
"symbols",
|
||||
"characters",
|
||||
"emoji"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathiasbynens/emoji-regex.git"
|
||||
},
|
||||
"bugs": "https://github.com/mathiasbynens/emoji-regex/issues",
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"text.js",
|
||||
"es2015/index.js",
|
||||
"es2015/text.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rm -rf -- es2015; babel src -d .; NODE_ENV=es2015 babel src -d ./es2015; node script/inject-sequences.js",
|
||||
"test": "mocha",
|
||||
"test:watch": "npm run test -- --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0",
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/plugin-proposal-unicode-property-regex": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"regexgen": "^1.3.0",
|
||||
"unicode-11.0.0": "^0.7.7",
|
||||
"unicode-tr51": "^9.0.1"
|
||||
}
|
||||
}
|
||||
6
node_modules/webpack-cli/node_modules/emoji-regex/text.js
generated
vendored
Normal file
6
node_modules/webpack-cli/node_modules/emoji-regex/text.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
46
node_modules/webpack-cli/node_modules/find-up/index.js
generated
vendored
Normal file
46
node_modules/webpack-cli/node_modules/find-up/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const locatePath = require('locate-path');
|
||||
|
||||
module.exports = (filename, opts = {}) => {
|
||||
const startDir = path.resolve(opts.cwd || '');
|
||||
const {root} = path.parse(startDir);
|
||||
|
||||
const filenames = [].concat(filename);
|
||||
|
||||
return new Promise(resolve => {
|
||||
(function find(dir) {
|
||||
locatePath(filenames, {cwd: dir}).then(file => {
|
||||
if (file) {
|
||||
resolve(path.join(dir, file));
|
||||
} else if (dir === root) {
|
||||
resolve(null);
|
||||
} else {
|
||||
find(path.dirname(dir));
|
||||
}
|
||||
});
|
||||
})(startDir);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = (filename, opts = {}) => {
|
||||
let dir = path.resolve(opts.cwd || '');
|
||||
const {root} = path.parse(dir);
|
||||
|
||||
const filenames = [].concat(filename);
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const file = locatePath.sync(filenames, {cwd: dir});
|
||||
|
||||
if (file) {
|
||||
return path.join(dir, file);
|
||||
}
|
||||
|
||||
if (dir === root) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dir = path.dirname(dir);
|
||||
}
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/find-up/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/find-up/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
50
node_modules/webpack-cli/node_modules/find-up/package.json
generated
vendored
Normal file
50
node_modules/webpack-cli/node_modules/find-up/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "find-up",
|
||||
"version": "3.0.0",
|
||||
"description": "Find a file or directory by walking up parent directories",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/find-up",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"package",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"dir",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"locate-path": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"tempy": "^0.2.1",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
87
node_modules/webpack-cli/node_modules/find-up/readme.md
generated
vendored
Normal file
87
node_modules/webpack-cli/node_modules/find-up/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# find-up [](https://travis-ci.org/sindresorhus/find-up) [](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
|
||||
|
||||
> Find a file or directory by walking up parent directories
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install find-up
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/
|
||||
└── Users
|
||||
└── sindresorhus
|
||||
├── unicorn.png
|
||||
└── foo
|
||||
└── bar
|
||||
├── baz
|
||||
└── example.js
|
||||
```
|
||||
|
||||
`example.js`
|
||||
|
||||
```js
|
||||
const findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### findUp(filename, [options])
|
||||
|
||||
Returns a `Promise` for either the filepath or `null` if it couldn't be found.
|
||||
|
||||
### findUp([filenameA, filenameB], [options])
|
||||
|
||||
Returns a `Promise` for either the first filepath found (by respecting the order) or `null` if none could be found.
|
||||
|
||||
### findUp.sync(filename, [options])
|
||||
|
||||
Returns a filepath or `null`.
|
||||
|
||||
### findUp.sync([filenameA, filenameB], [options])
|
||||
|
||||
Returns the first filepath found (by respecting the order) or `null`.
|
||||
|
||||
#### filename
|
||||
|
||||
Type: `string`
|
||||
|
||||
Filename of the file to find.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
|
||||
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module like `require.resolve()` but from a given path
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
7
node_modules/webpack-cli/node_modules/import-local/fixtures/cli.js
generated
vendored
Executable file
7
node_modules/webpack-cli/node_modules/import-local/fixtures/cli.js
generated
vendored
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
const importLocal = require('..');
|
||||
|
||||
if (importLocal(__filename)) {
|
||||
console.log('local');
|
||||
}
|
||||
17
node_modules/webpack-cli/node_modules/import-local/index.js
generated
vendored
Normal file
17
node_modules/webpack-cli/node_modules/import-local/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const resolveCwd = require('resolve-cwd');
|
||||
const pkgDir = require('pkg-dir');
|
||||
|
||||
module.exports = filename => {
|
||||
const globalDir = pkgDir.sync(path.dirname(filename));
|
||||
const relativePath = path.relative(globalDir, filename);
|
||||
const pkg = require(path.join(globalDir, 'package.json'));
|
||||
const localFile = resolveCwd.silent(path.join(pkg.name, relativePath));
|
||||
|
||||
// Use `path.relative()` to detect local package installation,
|
||||
// because __filename's case is inconsistent on Windows
|
||||
// Can use `===` when targeting Node.js 8
|
||||
// See https://github.com/nodejs/node/issues/6624
|
||||
return localFile && path.relative(localFile, filename) !== '' ? require(localFile) : null;
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/import-local/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/import-local/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
51
node_modules/webpack-cli/node_modules/import-local/package.json
generated
vendored
Normal file
51
node_modules/webpack-cli/node_modules/import-local/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "import-local",
|
||||
"version": "2.0.0",
|
||||
"description": "Let a globally installed package use a locally installed version of itself if available",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/import-local",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bin": {
|
||||
"import-local-fixture": "fixtures/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"fixtures/cli.js"
|
||||
],
|
||||
"keywords": [
|
||||
"import",
|
||||
"local",
|
||||
"require",
|
||||
"resolve",
|
||||
"global",
|
||||
"version",
|
||||
"prefer",
|
||||
"cli"
|
||||
],
|
||||
"dependencies": {
|
||||
"pkg-dir": "^3.0.0",
|
||||
"resolve-cwd": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"cpy": "^7.0.1",
|
||||
"del": "^3.0.0",
|
||||
"execa": "^0.11.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"fixtures"
|
||||
]
|
||||
}
|
||||
}
|
||||
30
node_modules/webpack-cli/node_modules/import-local/readme.md
generated
vendored
Normal file
30
node_modules/webpack-cli/node_modules/import-local/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# import-local [](https://travis-ci.org/sindresorhus/import-local)
|
||||
|
||||
> Let a globally installed package use a locally installed version of itself if available
|
||||
|
||||
Useful for CLI tools that want to defer to the user's locally installed version when available, but still work if it's not installed locally. For example, [AVA](http://ava.li) and [XO](https://github.com/xojs/xo) uses this method.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install import-local
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const importLocal = require('import-local');
|
||||
|
||||
if (importLocal(__filename)) {
|
||||
console.log('Using local version of this package');
|
||||
} else {
|
||||
// Code for both global and local version here…
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
46
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
46
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
/* eslint-disable yoda */
|
||||
module.exports = x => {
|
||||
if (Number.isNaN(x)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// code points are derived from:
|
||||
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
|
||||
if (
|
||||
x >= 0x1100 && (
|
||||
x <= 0x115f || // Hangul Jamo
|
||||
x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
|
||||
x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
|
||||
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
||||
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
|
||||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
||||
(0x3250 <= x && x <= 0x4dbf) ||
|
||||
// CJK Unified Ideographs .. Yi Radicals
|
||||
(0x4e00 <= x && x <= 0xa4c6) ||
|
||||
// Hangul Jamo Extended-A
|
||||
(0xa960 <= x && x <= 0xa97c) ||
|
||||
// Hangul Syllables
|
||||
(0xac00 <= x && x <= 0xd7a3) ||
|
||||
// CJK Compatibility Ideographs
|
||||
(0xf900 <= x && x <= 0xfaff) ||
|
||||
// Vertical Forms
|
||||
(0xfe10 <= x && x <= 0xfe19) ||
|
||||
// CJK Compatibility Forms .. Small Form Variants
|
||||
(0xfe30 <= x && x <= 0xfe6b) ||
|
||||
// Halfwidth and Fullwidth Forms
|
||||
(0xff01 <= x && x <= 0xff60) ||
|
||||
(0xffe0 <= x && x <= 0xffe6) ||
|
||||
// Kana Supplement
|
||||
(0x1b000 <= x && x <= 0x1b001) ||
|
||||
// Enclosed Ideographic Supplement
|
||||
(0x1f200 <= x && x <= 0x1f251) ||
|
||||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
||||
(0x20000 <= x && x <= 0x3fffd)
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
21
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/license
generated
vendored
Normal file
21
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
45
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
45
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "is-fullwidth-code-point",
|
||||
"version": "2.0.0",
|
||||
"description": "Check if the character represented by a given Unicode code point is fullwidth",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/is-fullwidth-code-point",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"full",
|
||||
"width",
|
||||
"unicode",
|
||||
"character",
|
||||
"char",
|
||||
"string",
|
||||
"str",
|
||||
"codepoint",
|
||||
"code",
|
||||
"point",
|
||||
"is",
|
||||
"detect",
|
||||
"check"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
||||
39
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/readme.md
generated
vendored
Normal file
39
node_modules/webpack-cli/node_modules/is-fullwidth-code-point/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# is-fullwidth-code-point [](https://travis-ci.org/sindresorhus/is-fullwidth-code-point)
|
||||
|
||||
> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save is-fullwidth-code-point
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
|
||||
isFullwidthCodePoint('谢'.codePointAt());
|
||||
//=> true
|
||||
|
||||
isFullwidthCodePoint('a'.codePointAt());
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### isFullwidthCodePoint(input)
|
||||
|
||||
#### input
|
||||
|
||||
Type: `number`
|
||||
|
||||
[Code point](https://en.wikipedia.org/wiki/Code_point) of a character.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
24
node_modules/webpack-cli/node_modules/locate-path/index.js
generated
vendored
Normal file
24
node_modules/webpack-cli/node_modules/locate-path/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const pathExists = require('path-exists');
|
||||
const pLocate = require('p-locate');
|
||||
|
||||
module.exports = (iterable, options) => {
|
||||
options = Object.assign({
|
||||
cwd: process.cwd()
|
||||
}, options);
|
||||
|
||||
return pLocate(iterable, el => pathExists(path.resolve(options.cwd, el)), options);
|
||||
};
|
||||
|
||||
module.exports.sync = (iterable, options) => {
|
||||
options = Object.assign({
|
||||
cwd: process.cwd()
|
||||
}, options);
|
||||
|
||||
for (const el of iterable) {
|
||||
if (pathExists.sync(path.resolve(options.cwd, el))) {
|
||||
return el;
|
||||
}
|
||||
}
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/locate-path/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/locate-path/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
44
node_modules/webpack-cli/node_modules/locate-path/package.json
generated
vendored
Normal file
44
node_modules/webpack-cli/node_modules/locate-path/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "locate-path",
|
||||
"version": "3.0.0",
|
||||
"description": "Get the first path that exists on disk of multiple paths",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/locate-path",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"locate",
|
||||
"path",
|
||||
"paths",
|
||||
"file",
|
||||
"files",
|
||||
"exists",
|
||||
"find",
|
||||
"finder",
|
||||
"search",
|
||||
"searcher",
|
||||
"array",
|
||||
"iterable",
|
||||
"iterator"
|
||||
],
|
||||
"dependencies": {
|
||||
"p-locate": "^3.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
99
node_modules/webpack-cli/node_modules/locate-path/readme.md
generated
vendored
Normal file
99
node_modules/webpack-cli/node_modules/locate-path/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
# locate-path [](https://travis-ci.org/sindresorhus/locate-path)
|
||||
|
||||
> Get the first path that exists on disk of multiple paths
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install locate-path
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Here we find the first file that exists on disk, in array order.
|
||||
|
||||
```js
|
||||
const locatePath = require('locate-path');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
console(await locatePath(files));
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### locatePath(input, [options])
|
||||
|
||||
Returns a `Promise` for the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
Paths to check.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### concurrency
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`<br>
|
||||
Minimum: `1`
|
||||
|
||||
Number of concurrently pending promises.
|
||||
|
||||
##### preserveOrder
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Preserve `input` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Current working directory.
|
||||
|
||||
### locatePath.sync(input, [options])
|
||||
|
||||
Returns the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
Paths to check.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Same as above.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
34
node_modules/webpack-cli/node_modules/p-locate/index.js
generated
vendored
Normal file
34
node_modules/webpack-cli/node_modules/p-locate/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
const pLimit = require('p-limit');
|
||||
|
||||
class EndError extends Error {
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
// The input can also be a promise, so we `Promise.resolve()` it
|
||||
const testElement = (el, tester) => Promise.resolve(el).then(tester);
|
||||
|
||||
// The input can also be a promise, so we `Promise.all()` them both
|
||||
const finder = el => Promise.all(el).then(val => val[1] === true && Promise.reject(new EndError(val[0])));
|
||||
|
||||
module.exports = (iterable, tester, opts) => {
|
||||
opts = Object.assign({
|
||||
concurrency: Infinity,
|
||||
preserveOrder: true
|
||||
}, opts);
|
||||
|
||||
const limit = pLimit(opts.concurrency);
|
||||
|
||||
// Start all the promises concurrently with optional limit
|
||||
const items = [...iterable].map(el => [el, limit(testElement, el, tester)]);
|
||||
|
||||
// Check the promises either serially or concurrently
|
||||
const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity);
|
||||
|
||||
return Promise.all(items.map(el => checkLimit(finder, el)))
|
||||
.then(() => {})
|
||||
.catch(err => err instanceof EndError ? err.value : Promise.reject(err));
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/p-locate/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/p-locate/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
51
node_modules/webpack-cli/node_modules/p-locate/package.json
generated
vendored
Normal file
51
node_modules/webpack-cli/node_modules/p-locate/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "p-locate",
|
||||
"version": "3.0.0",
|
||||
"description": "Get the first fulfilled promise that satisfies the provided testing function",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/p-locate",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"locate",
|
||||
"find",
|
||||
"finder",
|
||||
"search",
|
||||
"searcher",
|
||||
"test",
|
||||
"array",
|
||||
"collection",
|
||||
"iterable",
|
||||
"iterator",
|
||||
"race",
|
||||
"fulfilled",
|
||||
"fastest",
|
||||
"async",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
],
|
||||
"dependencies": {
|
||||
"p-limit": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"delay": "^3.0.0",
|
||||
"in-range": "^1.0.0",
|
||||
"time-span": "^2.0.0",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
88
node_modules/webpack-cli/node_modules/p-locate/readme.md
generated
vendored
Normal file
88
node_modules/webpack-cli/node_modules/p-locate/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
# p-locate [](https://travis-ci.org/sindresorhus/p-locate)
|
||||
|
||||
> Get the first fulfilled promise that satisfies the provided testing function
|
||||
|
||||
Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install p-locate
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Here we find the first file that exists on disk, in array order.
|
||||
|
||||
```js
|
||||
const pathExists = require('path-exists');
|
||||
const pLocate = require('p-locate');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
const foundPath = await pLocate(files, file => pathExists(file));
|
||||
|
||||
console.log(foundPath);
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
|
||||
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pLocate(input, tester, [options])
|
||||
|
||||
Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<Promise|any>`
|
||||
|
||||
#### tester(element)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Expected to return a `Promise<boolean>` or boolean.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### concurrency
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`<br>
|
||||
Minimum: `1`
|
||||
|
||||
Number of concurrently pending promises returned by `tester`.
|
||||
|
||||
##### preserveOrder
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Preserve `input` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
|
||||
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
|
||||
- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled
|
||||
- [More…](https://github.com/sindresorhus/promise-fun)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
17
node_modules/webpack-cli/node_modules/path-exists/index.js
generated
vendored
Normal file
17
node_modules/webpack-cli/node_modules/path-exists/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = fp => new Promise(resolve => {
|
||||
fs.access(fp, err => {
|
||||
resolve(!err);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports.sync = fp => {
|
||||
try {
|
||||
fs.accessSync(fp);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
21
node_modules/webpack-cli/node_modules/path-exists/license
generated
vendored
Normal file
21
node_modules/webpack-cli/node_modules/path-exists/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
40
node_modules/webpack-cli/node_modules/path-exists/package.json
generated
vendored
Normal file
40
node_modules/webpack-cli/node_modules/path-exists/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "path-exists",
|
||||
"version": "3.0.0",
|
||||
"description": "Check if a path exists",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/path-exists",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"path",
|
||||
"exists",
|
||||
"exist",
|
||||
"file",
|
||||
"filepath",
|
||||
"fs",
|
||||
"filesystem",
|
||||
"file-system",
|
||||
"access",
|
||||
"stat"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
||||
50
node_modules/webpack-cli/node_modules/path-exists/readme.md
generated
vendored
Normal file
50
node_modules/webpack-cli/node_modules/path-exists/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# path-exists [](https://travis-ci.org/sindresorhus/path-exists)
|
||||
|
||||
> Check if a path exists
|
||||
|
||||
Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
|
||||
|
||||
Never use this before handling a file though:
|
||||
|
||||
> In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-exists
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const pathExists = require('path-exists');
|
||||
|
||||
pathExists('foo.js').then(exists => {
|
||||
console.log(exists);
|
||||
//=> true
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pathExists(path)
|
||||
|
||||
Returns a promise for a boolean of whether the path exists.
|
||||
|
||||
### pathExists.sync(path)
|
||||
|
||||
Returns a boolean of whether the path exists.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
10
node_modules/webpack-cli/node_modules/pkg-dir/index.js
generated
vendored
Normal file
10
node_modules/webpack-cli/node_modules/pkg-dir/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
|
||||
module.exports = cwd => findUp('package.json', {cwd}).then(fp => fp ? path.dirname(fp) : null);
|
||||
|
||||
module.exports.sync = cwd => {
|
||||
const fp = findUp.sync('package.json', {cwd});
|
||||
return fp ? path.dirname(fp) : null;
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/pkg-dir/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/pkg-dir/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
53
node_modules/webpack-cli/node_modules/pkg-dir/package.json
generated
vendored
Normal file
53
node_modules/webpack-cli/node_modules/pkg-dir/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "pkg-dir",
|
||||
"version": "3.0.0",
|
||||
"description": "Find the root directory of a Node.js project or npm package",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/pkg-dir",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"package",
|
||||
"json",
|
||||
"root",
|
||||
"npm",
|
||||
"entry",
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"dir",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"find-up": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
66
node_modules/webpack-cli/node_modules/pkg-dir/readme.md
generated
vendored
Normal file
66
node_modules/webpack-cli/node_modules/pkg-dir/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# pkg-dir [](https://travis-ci.org/sindresorhus/pkg-dir)
|
||||
|
||||
> Find the root directory of a Node.js project or npm package
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install pkg-dir
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/
|
||||
└── Users
|
||||
└── sindresorhus
|
||||
└── foo
|
||||
├── package.json
|
||||
└── bar
|
||||
├── baz
|
||||
└── example.js
|
||||
```
|
||||
|
||||
```js
|
||||
// example.js
|
||||
const pkgDir = require('pkg-dir');
|
||||
|
||||
(async () => {
|
||||
const rootDir = await pkgDir(__dirname);
|
||||
|
||||
console.log(rootDir);
|
||||
//=> '/Users/sindresorhus/foo'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pkgDir([cwd])
|
||||
|
||||
Returns a `Promise` for either the project root path or `null` if it couldn't be found.
|
||||
|
||||
### pkgDir.sync([cwd])
|
||||
|
||||
Returns the project root path or `null`.
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
5
node_modules/webpack-cli/node_modules/resolve-cwd/index.js
generated
vendored
Normal file
5
node_modules/webpack-cli/node_modules/resolve-cwd/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
const resolveFrom = require('resolve-from');
|
||||
|
||||
module.exports = moduleId => resolveFrom(process.cwd(), moduleId);
|
||||
module.exports.silent = moduleId => resolveFrom.silent(process.cwd(), moduleId);
|
||||
21
node_modules/webpack-cli/node_modules/resolve-cwd/license
generated
vendored
Normal file
21
node_modules/webpack-cli/node_modules/resolve-cwd/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
41
node_modules/webpack-cli/node_modules/resolve-cwd/package.json
generated
vendored
Normal file
41
node_modules/webpack-cli/node_modules/resolve-cwd/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "resolve-cwd",
|
||||
"version": "2.0.0",
|
||||
"description": "Resolve the path of a module like `require.resolve()` but from the current working directory",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/resolve-cwd",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"require",
|
||||
"resolve",
|
||||
"path",
|
||||
"module",
|
||||
"from",
|
||||
"like",
|
||||
"cwd",
|
||||
"current",
|
||||
"working",
|
||||
"directory",
|
||||
"import"
|
||||
],
|
||||
"dependencies": {
|
||||
"resolve-from": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
57
node_modules/webpack-cli/node_modules/resolve-cwd/readme.md
generated
vendored
Normal file
57
node_modules/webpack-cli/node_modules/resolve-cwd/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# resolve-cwd [](https://travis-ci.org/sindresorhus/resolve-cwd)
|
||||
|
||||
> Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save resolve-cwd
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const resolveCwd = require('resolve-cwd');
|
||||
|
||||
console.log(__dirname);
|
||||
//=> '/Users/sindresorhus/rainbow'
|
||||
|
||||
console.log(process.cwd());
|
||||
//=> '/Users/sindresorhus/unicorn'
|
||||
|
||||
resolveCwd('./foo');
|
||||
//=> '/Users/sindresorhus/unicorn/foo.js'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### resolveCwd(moduleId)
|
||||
|
||||
Like `require()`, throws when the module can't be found.
|
||||
|
||||
### resolveCwd.silent(moduleId)
|
||||
|
||||
Returns `null` instead of throwing when the module can't be found.
|
||||
|
||||
#### moduleId
|
||||
|
||||
Type: `string`
|
||||
|
||||
What you would use in `require()`.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path
|
||||
- [req-from](https://github.com/sindresorhus/req-from) - Require a module from a given path
|
||||
- [req-cwd](https://github.com/sindresorhus/req-cwd) - Require a module from the current working directory
|
||||
- [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point
|
||||
- [lazy-req](https://github.com/sindresorhus/lazy-req) - Require modules lazily
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
35
node_modules/webpack-cli/node_modules/resolve-from/index.js
generated
vendored
Normal file
35
node_modules/webpack-cli/node_modules/resolve-from/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const Module = require('module');
|
||||
|
||||
const resolveFrom = (fromDir, moduleId, silent) => {
|
||||
if (typeof fromDir !== 'string') {
|
||||
throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDir}\``);
|
||||
}
|
||||
|
||||
if (typeof moduleId !== 'string') {
|
||||
throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
|
||||
}
|
||||
|
||||
fromDir = path.resolve(fromDir);
|
||||
const fromFile = path.join(fromDir, 'noop.js');
|
||||
|
||||
const resolveFileName = () => Module._resolveFilename(moduleId, {
|
||||
id: fromFile,
|
||||
filename: fromFile,
|
||||
paths: Module._nodeModulePaths(fromDir)
|
||||
});
|
||||
|
||||
if (silent) {
|
||||
try {
|
||||
return resolveFileName();
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return resolveFileName();
|
||||
};
|
||||
|
||||
module.exports = (fromDir, moduleId) => resolveFrom(fromDir, moduleId);
|
||||
module.exports.silent = (fromDir, moduleId) => resolveFrom(fromDir, moduleId, true);
|
||||
21
node_modules/webpack-cli/node_modules/resolve-from/license
generated
vendored
Normal file
21
node_modules/webpack-cli/node_modules/resolve-from/license
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
35
node_modules/webpack-cli/node_modules/resolve-from/package.json
generated
vendored
Normal file
35
node_modules/webpack-cli/node_modules/resolve-from/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "resolve-from",
|
||||
"version": "3.0.0",
|
||||
"description": "Resolve the path of a module like `require.resolve()` but from a given path",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/resolve-from",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"require",
|
||||
"resolve",
|
||||
"path",
|
||||
"module",
|
||||
"from",
|
||||
"like",
|
||||
"import",
|
||||
"path"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
71
node_modules/webpack-cli/node_modules/resolve-from/readme.md
generated
vendored
Normal file
71
node_modules/webpack-cli/node_modules/resolve-from/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# resolve-from [](https://travis-ci.org/sindresorhus/resolve-from)
|
||||
|
||||
> Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from a given path
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save resolve-from
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const resolveFrom = require('resolve-from');
|
||||
|
||||
// There is a file at `./foo/bar.js`
|
||||
|
||||
resolveFrom('foo', './bar');
|
||||
//=> '/Users/sindresorhus/dev/test/foo/bar.js'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### resolveFrom(fromDir, moduleId)
|
||||
|
||||
Like `require()`, throws when the module can't be found.
|
||||
|
||||
### resolveFrom.silent(fromDir, moduleId)
|
||||
|
||||
Returns `null` instead of throwing when the module can't be found.
|
||||
|
||||
#### fromDir
|
||||
|
||||
Type: `string`
|
||||
|
||||
Directory to resolve from.
|
||||
|
||||
#### moduleId
|
||||
|
||||
Type: `string`
|
||||
|
||||
What you would use in `require()`.
|
||||
|
||||
|
||||
## Tip
|
||||
|
||||
Create a partial using a bound function if you want to resolve from the same `fromDir` multiple times:
|
||||
|
||||
```js
|
||||
const resolveFromFoo = resolveFrom.bind(null, 'foo');
|
||||
|
||||
resolveFromFoo('./bar');
|
||||
resolveFromFoo('./baz');
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [resolve-cwd](https://github.com/sindresorhus/resolve-cwd) - Resolve the path of a module from the current working directory
|
||||
- [req-from](https://github.com/sindresorhus/req-from) - Require a module from a given path
|
||||
- [req-cwd](https://github.com/sindresorhus/req-cwd) - Require a module from the current working directory
|
||||
- [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point
|
||||
- [lazy-req](https://github.com/sindresorhus/lazy-req) - Require modules lazily
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
39
node_modules/webpack-cli/node_modules/string-width/index.js
generated
vendored
Normal file
39
node_modules/webpack-cli/node_modules/string-width/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
||||
const emojiRegex = require('emoji-regex')();
|
||||
|
||||
module.exports = input => {
|
||||
input = input.replace(emojiRegex, ' ');
|
||||
|
||||
if (typeof input !== 'string' || input.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
input = stripAnsi(input);
|
||||
|
||||
let width = 0;
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const code = input.codePointAt(i);
|
||||
|
||||
// Ignore control characters
|
||||
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore combining characters
|
||||
if (code >= 0x300 && code <= 0x36F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Surrogates
|
||||
if (code > 0xFFFF) {
|
||||
i++;
|
||||
}
|
||||
|
||||
width += isFullwidthCodePoint(code) ? 2 : 1;
|
||||
}
|
||||
|
||||
return width;
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/string-width/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/string-width/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
56
node_modules/webpack-cli/node_modules/string-width/package.json
generated
vendored
Normal file
56
node_modules/webpack-cli/node_modules/string-width/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"name": "string-width",
|
||||
"version": "3.1.0",
|
||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/string-width",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"string",
|
||||
"str",
|
||||
"character",
|
||||
"char",
|
||||
"unicode",
|
||||
"width",
|
||||
"visual",
|
||||
"column",
|
||||
"columns",
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"full",
|
||||
"ansi",
|
||||
"escape",
|
||||
"codes",
|
||||
"cli",
|
||||
"command-line",
|
||||
"terminal",
|
||||
"console",
|
||||
"cjk",
|
||||
"chinese",
|
||||
"japanese",
|
||||
"korean",
|
||||
"fixed-width"
|
||||
],
|
||||
"dependencies": {
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.0.1",
|
||||
"xo": "^0.23.0"
|
||||
}
|
||||
}
|
||||
45
node_modules/webpack-cli/node_modules/string-width/readme.md
generated
vendored
Normal file
45
node_modules/webpack-cli/node_modules/string-width/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# string-width [](https://travis-ci.org/sindresorhus/string-width)
|
||||
|
||||
> Get the visual width of a string - the number of columns required to display it
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
Useful to be able to measure the actual width of command-line output.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install string-width
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stringWidth = require('string-width');
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001b[1m古\u001b[22m');
|
||||
//=> 2
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
|
||||
stringWidth('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||
// => 5
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
15
node_modules/webpack-cli/node_modules/strip-ansi/index.d.ts
generated
vendored
Normal file
15
node_modules/webpack-cli/node_modules/strip-ansi/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
|
||||
|
||||
@example
|
||||
```
|
||||
import stripAnsi from 'strip-ansi';
|
||||
|
||||
stripAnsi('\u001B[4mUnicorn\u001B[0m');
|
||||
//=> 'Unicorn'
|
||||
|
||||
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||
//=> 'Click'
|
||||
```
|
||||
*/
|
||||
export default function stripAnsi(string: string): string;
|
||||
7
node_modules/webpack-cli/node_modules/strip-ansi/index.js
generated
vendored
Normal file
7
node_modules/webpack-cli/node_modules/strip-ansi/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
const ansiRegex = require('ansi-regex');
|
||||
|
||||
const stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
|
||||
|
||||
module.exports = stripAnsi;
|
||||
module.exports.default = stripAnsi;
|
||||
9
node_modules/webpack-cli/node_modules/strip-ansi/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/strip-ansi/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
54
node_modules/webpack-cli/node_modules/strip-ansi/package.json
generated
vendored
Normal file
54
node_modules/webpack-cli/node_modules/strip-ansi/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"name": "strip-ansi",
|
||||
"version": "5.2.0",
|
||||
"description": "Strip ANSI escape codes from a string",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/strip-ansi",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd-check"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"strip",
|
||||
"trim",
|
||||
"remove",
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-regex": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.3.1",
|
||||
"tsd-check": "^0.5.0",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
61
node_modules/webpack-cli/node_modules/strip-ansi/readme.md
generated
vendored
Normal file
61
node_modules/webpack-cli/node_modules/strip-ansi/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# strip-ansi [](https://travis-ci.org/chalk/strip-ansi)
|
||||
|
||||
> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for 'strip-ansi' with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install strip-ansi
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stripAnsi = require('strip-ansi');
|
||||
|
||||
stripAnsi('\u001B[4mUnicorn\u001B[0m');
|
||||
//=> 'Unicorn'
|
||||
|
||||
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||
//=> 'Click'
|
||||
```
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
5
node_modules/webpack-cli/node_modules/supports-color/browser.js
generated
vendored
Normal file
5
node_modules/webpack-cli/node_modules/supports-color/browser.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
module.exports = {
|
||||
stdout: false,
|
||||
stderr: false
|
||||
};
|
||||
138
node_modules/webpack-cli/node_modules/supports-color/index.js
generated
vendored
Normal file
138
node_modules/webpack-cli/node_modules/supports-color/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
'use strict';
|
||||
const os = require('os');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let forceColor;
|
||||
if (hasFlag('no-color') ||
|
||||
hasFlag('no-colors') ||
|
||||
hasFlag('color=false') ||
|
||||
hasFlag('color=never')) {
|
||||
forceColor = 0;
|
||||
} else if (hasFlag('color') ||
|
||||
hasFlag('colors') ||
|
||||
hasFlag('color=true') ||
|
||||
hasFlag('color=always')) {
|
||||
forceColor = 1;
|
||||
}
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === true || env.FORCE_COLOR === 'true') {
|
||||
forceColor = 1;
|
||||
} else if (env.FORCE_COLOR === false || env.FORCE_COLOR === 'false') {
|
||||
forceColor = 0;
|
||||
} else {
|
||||
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(stream) {
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') ||
|
||||
hasFlag('color=full') ||
|
||||
hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (stream && !stream.isTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
||||
// libuv that enables 256 color output on Windows. Anything earlier and it
|
||||
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
||||
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
|
||||
// release that supports 256 colors. Windows 10 build 14931 is the first release
|
||||
// that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(process.versions.node.split('.')[0]) >= 8 &&
|
||||
Number(osRelease[0]) >= 10 &&
|
||||
Number(osRelease[2]) >= 10586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
const level = supportsColor(stream);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: getSupportLevel(process.stdout),
|
||||
stderr: getSupportLevel(process.stderr)
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/supports-color/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/supports-color/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
53
node_modules/webpack-cli/node_modules/supports-color/package.json
generated
vendored
Normal file
53
node_modules/webpack-cli/node_modules/supports-color/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "supports-color",
|
||||
"version": "6.1.0",
|
||||
"description": "Detect whether a terminal supports color",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/supports-color",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"browser.js"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"ansi",
|
||||
"styles",
|
||||
"tty",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"support",
|
||||
"supports",
|
||||
"capability",
|
||||
"detect",
|
||||
"truecolor",
|
||||
"16m"
|
||||
],
|
||||
"dependencies": {
|
||||
"has-flag": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.25.0",
|
||||
"import-fresh": "^2.0.0",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"browser": "browser.js"
|
||||
}
|
||||
85
node_modules/webpack-cli/node_modules/supports-color/readme.md
generated
vendored
Normal file
85
node_modules/webpack-cli/node_modules/supports-color/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# supports-color [](https://travis-ci.org/chalk/supports-color)
|
||||
|
||||
> Detect whether a terminal supports color
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install supports-color
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor.stdout) {
|
||||
console.log('Terminal stdout supports color');
|
||||
}
|
||||
|
||||
if (supportsColor.stdout.has256) {
|
||||
console.log('Terminal stdout supports 256 colors');
|
||||
}
|
||||
|
||||
if (supportsColor.stderr.has16m) {
|
||||
console.log('Terminal stderr supports 16 million colors (truecolor)');
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
|
||||
|
||||
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
|
||||
|
||||
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
|
||||
- `.level = 2` and `.has256 = true`: 256 color support
|
||||
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
|
||||
|
||||
|
||||
## Info
|
||||
|
||||
It obeys the `--color` and `--no-color` CLI flags.
|
||||
|
||||
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
188
node_modules/webpack-cli/node_modules/wrap-ansi/index.js
generated
vendored
Executable file
188
node_modules/webpack-cli/node_modules/wrap-ansi/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,188 @@
|
|||
'use strict';
|
||||
const stringWidth = require('string-width');
|
||||
const stripAnsi = require('strip-ansi');
|
||||
const ansiStyles = require('ansi-styles');
|
||||
|
||||
const ESCAPES = new Set([
|
||||
'\u001B',
|
||||
'\u009B'
|
||||
]);
|
||||
|
||||
const END_CODE = 39;
|
||||
|
||||
const wrapAnsi = code => `${ESCAPES.values().next().value}[${code}m`;
|
||||
|
||||
// Calculate the length of words split on ' ', ignoring
|
||||
// the extra characters added by ansi escape codes
|
||||
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
||||
|
||||
// Wrap a long word across multiple rows
|
||||
// Ansi escape codes do not count towards length
|
||||
const wrapWord = (rows, word, columns) => {
|
||||
const characters = [...word];
|
||||
|
||||
let insideEscape = false;
|
||||
let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
|
||||
|
||||
for (const [index, character] of characters.entries()) {
|
||||
const characterLength = stringWidth(character);
|
||||
|
||||
if (visible + characterLength <= columns) {
|
||||
rows[rows.length - 1] += character;
|
||||
} else {
|
||||
rows.push(character);
|
||||
visible = 0;
|
||||
}
|
||||
|
||||
if (ESCAPES.has(character)) {
|
||||
insideEscape = true;
|
||||
} else if (insideEscape && character === 'm') {
|
||||
insideEscape = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (insideEscape) {
|
||||
continue;
|
||||
}
|
||||
|
||||
visible += characterLength;
|
||||
|
||||
if (visible === columns && index < characters.length - 1) {
|
||||
rows.push('');
|
||||
visible = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// It's possible that the last row we copy over is only
|
||||
// ansi escape characters, handle this edge-case
|
||||
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
||||
rows[rows.length - 2] += rows.pop();
|
||||
}
|
||||
};
|
||||
|
||||
// Trims spaces from a string ignoring invisible sequences
|
||||
const stringVisibleTrimSpacesRight = str => {
|
||||
const words = str.split(' ');
|
||||
let last = words.length;
|
||||
|
||||
while (last > 0) {
|
||||
if (stringWidth(words[last - 1]) > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
last--;
|
||||
}
|
||||
|
||||
if (last === words.length) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
||||
};
|
||||
|
||||
// The wrap-ansi module can be invoked
|
||||
// in either 'hard' or 'soft' wrap mode
|
||||
//
|
||||
// 'hard' will never allow a string to take up more
|
||||
// than columns characters
|
||||
//
|
||||
// 'soft' allows long words to expand past the column length
|
||||
const exec = (string, columns, options = {}) => {
|
||||
if (options.trim !== false && string.trim() === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
let pre = '';
|
||||
let ret = '';
|
||||
let escapeCode;
|
||||
|
||||
const lengths = wordLengths(string);
|
||||
let rows = [''];
|
||||
|
||||
for (const [index, word] of string.split(' ').entries()) {
|
||||
if (options.trim !== false) {
|
||||
rows[rows.length - 1] = rows[rows.length - 1].trimLeft();
|
||||
}
|
||||
|
||||
let rowLength = stringWidth(rows[rows.length - 1]);
|
||||
|
||||
if (index !== 0) {
|
||||
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
||||
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
||||
rows.push('');
|
||||
rowLength = 0;
|
||||
}
|
||||
|
||||
if (rowLength > 0 || options.trim === false) {
|
||||
rows[rows.length - 1] += ' ';
|
||||
rowLength++;
|
||||
}
|
||||
}
|
||||
|
||||
// In 'hard' wrap mode, the length of a line is
|
||||
// never allowed to extend past 'columns'
|
||||
if (options.hard && lengths[index] > columns) {
|
||||
const remainingColumns = (columns - rowLength);
|
||||
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
||||
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
||||
if (breaksStartingNextLine < breaksStartingThisLine) {
|
||||
rows.push('');
|
||||
}
|
||||
|
||||
wrapWord(rows, word, columns);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
||||
if (options.wordWrap === false && rowLength < columns) {
|
||||
wrapWord(rows, word, columns);
|
||||
continue;
|
||||
}
|
||||
|
||||
rows.push('');
|
||||
}
|
||||
|
||||
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
||||
wrapWord(rows, word, columns);
|
||||
continue;
|
||||
}
|
||||
|
||||
rows[rows.length - 1] += word;
|
||||
}
|
||||
|
||||
if (options.trim !== false) {
|
||||
rows = rows.map(stringVisibleTrimSpacesRight);
|
||||
}
|
||||
|
||||
pre = rows.join('\n');
|
||||
|
||||
for (const [index, character] of [...pre].entries()) {
|
||||
ret += character;
|
||||
|
||||
if (ESCAPES.has(character)) {
|
||||
const code = parseFloat(/\d[^m]*/.exec(pre.slice(index, index + 4)));
|
||||
escapeCode = code === END_CODE ? null : code;
|
||||
}
|
||||
|
||||
const code = ansiStyles.codes.get(Number(escapeCode));
|
||||
|
||||
if (escapeCode && code) {
|
||||
if (pre[index + 1] === '\n') {
|
||||
ret += wrapAnsi(code);
|
||||
} else if (character === '\n') {
|
||||
ret += wrapAnsi(escapeCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
// For each newline, invoke the method separately
|
||||
module.exports = (string, columns, options) => {
|
||||
return String(string)
|
||||
.normalize()
|
||||
.split('\n')
|
||||
.map(line => exec(line, columns, options))
|
||||
.join('\n');
|
||||
};
|
||||
9
node_modules/webpack-cli/node_modules/wrap-ansi/license
generated
vendored
Normal file
9
node_modules/webpack-cli/node_modules/wrap-ansi/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
61
node_modules/webpack-cli/node_modules/wrap-ansi/package.json
generated
vendored
Normal file
61
node_modules/webpack-cli/node_modules/wrap-ansi/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"name": "wrap-ansi",
|
||||
"version": "5.1.0",
|
||||
"description": "Wordwrap a string with ANSI escape codes",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/wrap-ansi",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"wrap",
|
||||
"break",
|
||||
"wordwrap",
|
||||
"wordbreak",
|
||||
"linewrap",
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-styles": "^3.2.0",
|
||||
"string-width": "^3.0.0",
|
||||
"strip-ansi": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.2.1",
|
||||
"chalk": "^2.4.2",
|
||||
"coveralls": "^3.0.3",
|
||||
"has-ansi": "^3.0.0",
|
||||
"nyc": "^13.3.0",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
108
node_modules/webpack-cli/node_modules/wrap-ansi/readme.md
generated
vendored
Normal file
108
node_modules/webpack-cli/node_modules/wrap-ansi/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
# wrap-ansi [](https://travis-ci.org/chalk/wrap-ansi) [](https://coveralls.io/github/chalk/wrap-ansi?branch=master)
|
||||
|
||||
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install wrap-ansi
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
const wrapAnsi = require('wrap-ansi');
|
||||
|
||||
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
||||
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
||||
|
||||
console.log(wrapAnsi(input, 20));
|
||||
```
|
||||
|
||||
<img width="331" src="screenshot.png">
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-wrap_ansi?utm_source=npm-wrap-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### wrapAnsi(input, columns, [options])
|
||||
|
||||
Wrap words to the specified column width.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string`
|
||||
|
||||
String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
|
||||
|
||||
#### columns
|
||||
|
||||
Type: `number`
|
||||
|
||||
Number of columns to wrap the text to.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### hard
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
||||
|
||||
##### wordWrap
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
||||
|
||||
##### trim
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
|
||||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
- [Benjamin Coe](https://github.com/bcoe)
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
467
node_modules/webpack-cli/node_modules/yargs-parser/CHANGELOG.md
generated
vendored
Normal file
467
node_modules/webpack-cli/node_modules/yargs-parser/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,467 @@
|
|||
# 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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ensure empty string is added into argv._ ([#140](https://github.com/yargs/yargs-parser/issues/140)) ([79cda98](https://github.com/yargs/yargs-parser/commit/79cda98))
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* make requiresArg work in conjunction with arrays ([#136](https://github.com/yargs/yargs-parser/issues/136)) ([f4a3063](https://github.com/yargs/yargs-parser/commit/f4a3063))
|
||||
|
||||
|
||||
|
||||
<a name="11.1.0"></a>
|
||||
# [11.1.0](https://github.com/yargs/yargs-parser/compare/v11.0.0...v11.1.0) (2018-11-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* handling of one char alias ([#139](https://github.com/yargs/yargs-parser/issues/139)) ([ee56e31](https://github.com/yargs/yargs-parser/commit/ee56e31))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add halt-at-non-option configuration option ([#130](https://github.com/yargs/yargs-parser/issues/130)) ([a849fce](https://github.com/yargs/yargs-parser/commit/a849fce))
|
||||
|
||||
|
||||
|
||||
<a name="11.0.0"></a>
|
||||
# [11.0.0](https://github.com/yargs/yargs-parser/compare/v10.1.0...v11.0.0) (2018-10-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* flatten-duplicate-arrays:false for more than 2 arrays ([#128](https://github.com/yargs/yargs-parser/issues/128)) ([2bc395f](https://github.com/yargs/yargs-parser/commit/2bc395f))
|
||||
* hyphenated flags combined with dot notation broke parsing ([#131](https://github.com/yargs/yargs-parser/issues/131)) ([dc788da](https://github.com/yargs/yargs-parser/commit/dc788da))
|
||||
* make requiresArg work in conjunction with arrays ([#136](https://github.com/yargs/yargs-parser/issues/136)) ([77ae1d4](https://github.com/yargs/yargs-parser/commit/77ae1d4))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* update dependencies ([6dc42a1](https://github.com/yargs/yargs-parser/commit/6dc42a1))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* also add camelCase array options ([#125](https://github.com/yargs/yargs-parser/issues/125)) ([08c0117](https://github.com/yargs/yargs-parser/commit/08c0117))
|
||||
* array.type can now be provided, supporting coercion ([#132](https://github.com/yargs/yargs-parser/issues/132)) ([4b8cfce](https://github.com/yargs/yargs-parser/commit/4b8cfce))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* drops Node 4 support
|
||||
* the argv object is now populated differently (correctly) when hyphens and dot notation are used in conjunction.
|
||||
|
||||
|
||||
|
||||
<a name="10.1.0"></a>
|
||||
# [10.1.0](https://github.com/yargs/yargs-parser/compare/v10.0.0...v10.1.0) (2018-06-29)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add `set-placeholder-key` configuration ([#123](https://github.com/yargs/yargs-parser/issues/123)) ([19386ee](https://github.com/yargs/yargs-parser/commit/19386ee))
|
||||
|
||||
|
||||
|
||||
<a name="10.0.0"></a>
|
||||
# [10.0.0](https://github.com/yargs/yargs-parser/compare/v9.0.2...v10.0.0) (2018-04-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not set boolean flags if not defined in `argv` ([#119](https://github.com/yargs/yargs-parser/issues/119)) ([f6e6599](https://github.com/yargs/yargs-parser/commit/f6e6599))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* `boolean` flags defined without a `default` value will now behave like other option type and won't be set in the parsed results when the user doesn't set the corresponding CLI arg.
|
||||
|
||||
Previous behavior:
|
||||
```js
|
||||
var parse = require('yargs-parser');
|
||||
|
||||
parse('--flag', {boolean: ['flag']});
|
||||
// => { _: [], flag: true }
|
||||
|
||||
parse('--no-flag', {boolean: ['flag']});
|
||||
// => { _: [], flag: false }
|
||||
|
||||
parse('', {boolean: ['flag']});
|
||||
// => { _: [], flag: false }
|
||||
```
|
||||
|
||||
New behavior:
|
||||
```js
|
||||
var parse = require('yargs-parser');
|
||||
|
||||
parse('--flag', {boolean: ['flag']});
|
||||
// => { _: [], flag: true }
|
||||
|
||||
parse('--no-flag', {boolean: ['flag']});
|
||||
// => { _: [], flag: false }
|
||||
|
||||
parse('', {boolean: ['flag']});
|
||||
// => { _: [] } => flag not set similarly to other option type
|
||||
```
|
||||
|
||||
|
||||
|
||||
<a name="9.0.2"></a>
|
||||
## [9.0.2](https://github.com/yargs/yargs-parser/compare/v9.0.1...v9.0.2) (2018-01-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* nargs was still aggressively consuming too many arguments ([9b28aad](https://github.com/yargs/yargs-parser/commit/9b28aad))
|
||||
|
||||
|
||||
|
||||
<a name="9.0.1"></a>
|
||||
## [9.0.1](https://github.com/yargs/yargs-parser/compare/v9.0.0...v9.0.1) (2018-01-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* nargs was consuming too many arguments ([4fef206](https://github.com/yargs/yargs-parser/commit/4fef206))
|
||||
|
||||
|
||||
|
||||
<a name="9.0.0"></a>
|
||||
# [9.0.0](https://github.com/yargs/yargs-parser/compare/v8.1.0...v9.0.0) (2018-01-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* narg arguments no longer consume flag arguments ([#114](https://github.com/yargs/yargs-parser/issues/114)) ([60bb9b3](https://github.com/yargs/yargs-parser/commit/60bb9b3))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* arguments of form --foo, -abc, will no longer be consumed by nargs
|
||||
|
||||
|
||||
|
||||
<a name="8.1.0"></a>
|
||||
# [8.1.0](https://github.com/yargs/yargs-parser/compare/v8.0.0...v8.1.0) (2017-12-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow null config values ([#108](https://github.com/yargs/yargs-parser/issues/108)) ([d8b14f9](https://github.com/yargs/yargs-parser/commit/d8b14f9))
|
||||
* ensure consistent parsing of dot-notation arguments ([#102](https://github.com/yargs/yargs-parser/issues/102)) ([c9bd79c](https://github.com/yargs/yargs-parser/commit/c9bd79c))
|
||||
* implement [@antoniom](https://github.com/antoniom)'s fix for camel-case expansion ([3087e1d](https://github.com/yargs/yargs-parser/commit/3087e1d))
|
||||
* only run coercion functions once, despite aliases. ([#76](https://github.com/yargs/yargs-parser/issues/76)) ([#103](https://github.com/yargs/yargs-parser/issues/103)) ([507aaef](https://github.com/yargs/yargs-parser/commit/507aaef))
|
||||
* scientific notation circumvented bounds check ([#110](https://github.com/yargs/yargs-parser/issues/110)) ([3571f57](https://github.com/yargs/yargs-parser/commit/3571f57))
|
||||
* tokenizer should ignore spaces at the beginning of the argString ([#106](https://github.com/yargs/yargs-parser/issues/106)) ([f34ead9](https://github.com/yargs/yargs-parser/commit/f34ead9))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* make combining arrays a configurable option ([#111](https://github.com/yargs/yargs-parser/issues/111)) ([c8bf536](https://github.com/yargs/yargs-parser/commit/c8bf536))
|
||||
* merge array from arguments with array from config ([#83](https://github.com/yargs/yargs-parser/issues/83)) ([806ddd6](https://github.com/yargs/yargs-parser/commit/806ddd6))
|
||||
|
||||
|
||||
|
||||
<a name="8.0.0"></a>
|
||||
# [8.0.0](https://github.com/yargs/yargs-parser/compare/v7.0.0...v8.0.0) (2017-10-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Ignore multiple spaces between arguments. ([#100](https://github.com/yargs/yargs-parser/issues/100)) ([d137227](https://github.com/yargs/yargs-parser/commit/d137227))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow configuration of prefix for boolean negation ([#94](https://github.com/yargs/yargs-parser/issues/94)) ([00bde7d](https://github.com/yargs/yargs-parser/commit/00bde7d))
|
||||
* reworking how numbers are parsed ([#104](https://github.com/yargs/yargs-parser/issues/104)) ([fba00eb](https://github.com/yargs/yargs-parser/commit/fba00eb))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* strings that fail `Number.isSafeInteger()` are no longer coerced into numbers.
|
||||
|
||||
|
||||
|
||||
<a name="7.0.0"></a>
|
||||
# [7.0.0](https://github.com/yargs/yargs-parser/compare/v6.0.1...v7.0.0) (2017-05-02)
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* revert populate-- logic ([#91](https://github.com/yargs/yargs-parser/issues/91)) ([6003e6d](https://github.com/yargs/yargs-parser/commit/6003e6d))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* populate-- now defaults to false.
|
||||
|
||||
|
||||
|
||||
<a name="6.0.1"></a>
|
||||
## [6.0.1](https://github.com/yargs/yargs-parser/compare/v6.0.0...v6.0.1) (2017-05-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* default '--' to undefined when not provided; this is closer to the array API ([#90](https://github.com/yargs/yargs-parser/issues/90)) ([4e739cc](https://github.com/yargs/yargs-parser/commit/4e739cc))
|
||||
|
||||
|
||||
|
||||
<a name="6.0.0"></a>
|
||||
# [6.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v6.0.0) (2017-05-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f))
|
||||
* parsing hints should apply for dot notation keys ([#86](https://github.com/yargs/yargs-parser/issues/86)) ([3e47d62](https://github.com/yargs/yargs-parser/commit/3e47d62))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* upgrade to newest version of camelcase ([#87](https://github.com/yargs/yargs-parser/issues/87)) ([f1903aa](https://github.com/yargs/yargs-parser/commit/f1903aa))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add -- option which allows arguments after the -- flag to be returned separated from positional arguments ([#84](https://github.com/yargs/yargs-parser/issues/84)) ([2572ca8](https://github.com/yargs/yargs-parser/commit/2572ca8))
|
||||
* when parsing stops, we now populate "--" by default ([#88](https://github.com/yargs/yargs-parser/issues/88)) ([cd666db](https://github.com/yargs/yargs-parser/commit/cd666db))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* rather than placing arguments in "_", when parsing is stopped via "--"; we now populate an array called "--" by default.
|
||||
* camelcase now requires Node 4+.
|
||||
* environment variables will now override config files (args, env, config-file, config-object)
|
||||
|
||||
|
||||
|
||||
<a name="5.0.0"></a>
|
||||
# [5.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0) (2017-02-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* environment variables will now override config files (args, env, config-file, config-object)
|
||||
|
||||
|
||||
|
||||
<a name="4.2.1"></a>
|
||||
## [4.2.1](https://github.com/yargs/yargs-parser/compare/v4.2.0...v4.2.1) (2017-01-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* flatten/duplicate regression ([#75](https://github.com/yargs/yargs-parser/issues/75)) ([68d68a0](https://github.com/yargs/yargs-parser/commit/68d68a0))
|
||||
|
||||
|
||||
|
||||
<a name="4.2.0"></a>
|
||||
# [4.2.0](https://github.com/yargs/yargs-parser/compare/v4.1.0...v4.2.0) (2016-12-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* inner objects in configs had their keys appended to top-level key when dot-notation was disabled ([#72](https://github.com/yargs/yargs-parser/issues/72)) ([0b1b5f9](https://github.com/yargs/yargs-parser/commit/0b1b5f9))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow multiple arrays to be provided, rather than always combining ([#71](https://github.com/yargs/yargs-parser/issues/71)) ([0f0fb2d](https://github.com/yargs/yargs-parser/commit/0f0fb2d))
|
||||
|
||||
|
||||
|
||||
<a name="4.1.0"></a>
|
||||
# [4.1.0](https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0) (2016-11-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* apply coercions to default options ([#65](https://github.com/yargs/yargs-parser/issues/65)) ([c79052b](https://github.com/yargs/yargs-parser/commit/c79052b))
|
||||
* handle dot notation boolean options ([#63](https://github.com/yargs/yargs-parser/issues/63)) ([02c3545](https://github.com/yargs/yargs-parser/commit/02c3545))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.2"></a>
|
||||
## [4.0.2](https://github.com/yargs/yargs-parser/compare/v4.0.1...v4.0.2) (2016-09-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* whoops, let's make the assign not change the Object key order ([29d069a](https://github.com/yargs/yargs-parser/commit/29d069a))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.1"></a>
|
||||
## [4.0.1](https://github.com/yargs/yargs-parser/compare/v4.0.0...v4.0.1) (2016-09-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* lodash.assign was deprecated ([#59](https://github.com/yargs/yargs-parser/issues/59)) ([5e7eb11](https://github.com/yargs/yargs-parser/commit/5e7eb11))
|
||||
|
||||
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
# [4.0.0](https://github.com/yargs/yargs-parser/compare/v3.2.0...v4.0.0) (2016-09-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* coerce should be applied to the final objects and arrays created ([#57](https://github.com/yargs/yargs-parser/issues/57)) ([4ca69da](https://github.com/yargs/yargs-parser/commit/4ca69da))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* coerce is no longer applied to individual arguments in an implicit array.
|
||||
|
||||
|
||||
|
||||
<a name="3.2.0"></a>
|
||||
# [3.2.0](https://github.com/yargs/yargs-parser/compare/v3.1.0...v3.2.0) (2016-08-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* coerce full array instead of each element ([#51](https://github.com/yargs/yargs-parser/issues/51)) ([cc4dc56](https://github.com/yargs/yargs-parser/commit/cc4dc56))
|
||||
|
||||
|
||||
|
||||
<a name="3.1.0"></a>
|
||||
# [3.1.0](https://github.com/yargs/yargs-parser/compare/v3.0.0...v3.1.0) (2016-08-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* address pkgConf parsing bug outlined in [#37](https://github.com/yargs/yargs-parser/issues/37) ([#45](https://github.com/yargs/yargs-parser/issues/45)) ([be76ee6](https://github.com/yargs/yargs-parser/commit/be76ee6))
|
||||
* better parsing of negative values ([#44](https://github.com/yargs/yargs-parser/issues/44)) ([2e43692](https://github.com/yargs/yargs-parser/commit/2e43692))
|
||||
* check aliases when guessing defaults for arguments fixes [#41](https://github.com/yargs/yargs-parser/issues/41) ([#43](https://github.com/yargs/yargs-parser/issues/43)) ([f3e4616](https://github.com/yargs/yargs-parser/commit/f3e4616))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added coerce option, for providing specialized argument parsing ([#42](https://github.com/yargs/yargs-parser/issues/42)) ([7b49cd2](https://github.com/yargs/yargs-parser/commit/7b49cd2))
|
||||
|
||||
|
||||
|
||||
<a name="3.0.0"></a>
|
||||
# [3.0.0](https://github.com/yargs/yargs-parser/compare/v2.4.1...v3.0.0) (2016-08-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* parsing issue with numeric character in group of options ([#19](https://github.com/yargs/yargs-parser/issues/19)) ([f743236](https://github.com/yargs/yargs-parser/commit/f743236))
|
||||
* upgraded lodash.assign ([5d7fdf4](https://github.com/yargs/yargs-parser/commit/5d7fdf4))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* subtle change to how values are parsed in a group of single-character arguments.
|
||||
* _first released in 3.1.0, better handling of negative values should be considered a breaking change._
|
||||
|
||||
|
||||
|
||||
<a name="2.4.1"></a>
|
||||
## [2.4.1](https://github.com/yargs/yargs-parser/compare/v2.4.0...v2.4.1) (2016-07-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **count:** do not increment a default value ([#39](https://github.com/yargs/yargs-parser/issues/39)) ([b04a189](https://github.com/yargs/yargs-parser/commit/b04a189))
|
||||
|
||||
|
||||
|
||||
<a name="2.4.0"></a>
|
||||
# [2.4.0](https://github.com/yargs/yargs-parser/compare/v2.3.0...v2.4.0) (2016-04-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **environment:** Support nested options in environment variables ([#26](https://github.com/yargs/yargs-parser/issues/26)) thanks [@elas7](https://github.com/elas7) \o/ ([020778b](https://github.com/yargs/yargs-parser/commit/020778b))
|
||||
|
||||
|
||||
|
||||
<a name="2.3.0"></a>
|
||||
# [2.3.0](https://github.com/yargs/yargs-parser/compare/v2.2.0...v2.3.0) (2016-04-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **boolean:** fix for boolean options with non boolean defaults (#20) ([2dbe86b](https://github.com/yargs/yargs-parser/commit/2dbe86b)), closes [(#20](https://github.com/(/issues/20)
|
||||
* **package:** remove tests from tarball ([0353c0d](https://github.com/yargs/yargs-parser/commit/0353c0d))
|
||||
* **parsing:** handle calling short option with an empty string as the next value. ([a867165](https://github.com/yargs/yargs-parser/commit/a867165))
|
||||
* boolean flag when next value contains the strings 'true' or 'false'. ([69941a6](https://github.com/yargs/yargs-parser/commit/69941a6))
|
||||
* update dependencies; add standard-version bin for next release (#24) ([822d9d5](https://github.com/yargs/yargs-parser/commit/822d9d5))
|
||||
|
||||
### Features
|
||||
|
||||
* **configuration:** Allow to pass configuration objects to yargs-parser ([0780900](https://github.com/yargs/yargs-parser/commit/0780900))
|
||||
* **normalize:** allow normalize to work with arrays ([e0eaa1a](https://github.com/yargs/yargs-parser/commit/e0eaa1a))
|
||||
14
node_modules/webpack-cli/node_modules/yargs-parser/LICENSE.txt
generated
vendored
Normal file
14
node_modules/webpack-cli/node_modules/yargs-parser/LICENSE.txt
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Copyright (c) 2016, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice
|
||||
appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
396
node_modules/webpack-cli/node_modules/yargs-parser/README.md
generated
vendored
Normal file
396
node_modules/webpack-cli/node_modules/yargs-parser/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,396 @@
|
|||
# yargs-parser
|
||||
|
||||
[](https://travis-ci.org/yargs/yargs-parser)
|
||||
[](https://coveralls.io/r/yargs/yargs-parser?branch=master)
|
||||
[](https://www.npmjs.com/package/yargs-parser)
|
||||
[](https://github.com/conventional-changelog/standard-version)
|
||||
|
||||
|
||||
The mighty option parser used by [yargs](https://github.com/yargs/yargs).
|
||||
|
||||
visit the [yargs website](http://yargs.js.org/) for more examples, and thorough usage instructions.
|
||||
|
||||
<img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/master/yargs-logo.png">
|
||||
|
||||
## Example
|
||||
|
||||
```sh
|
||||
npm i yargs-parser --save
|
||||
```
|
||||
|
||||
```js
|
||||
var argv = require('yargs-parser')(process.argv.slice(2))
|
||||
console.log(argv)
|
||||
```
|
||||
|
||||
```sh
|
||||
node example.js --foo=33 --bar hello
|
||||
{ _: [], foo: 33, bar: 'hello' }
|
||||
```
|
||||
|
||||
_or parse a string!_
|
||||
|
||||
```js
|
||||
var argv = require('./')('--foo=99 --bar=33')
|
||||
console.log(argv)
|
||||
```
|
||||
|
||||
```sh
|
||||
{ _: [], foo: 99, bar: 33 }
|
||||
```
|
||||
|
||||
Convert an array of mixed types before passing to `yargs-parser`:
|
||||
|
||||
```js
|
||||
var parse = require('yargs-parser')
|
||||
parse(['-f', 11, '--zoom', 55].join(' ')) // <-- array to string
|
||||
parse(['-f', 11, '--zoom', 55].map(String)) // <-- array of strings
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### require('yargs-parser')(args, opts={})
|
||||
|
||||
Parses command line arguments returning a simple mapping of keys and values.
|
||||
|
||||
**expects:**
|
||||
|
||||
* `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']}`.<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.coerce`: provide a custom synchronous function that returns a coerced value from the argument provided
|
||||
(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.number`: keys should be treated as numbers.
|
||||
* `opts.string`: keys should be treated as strings (even if they resemble a number `-x 33`).
|
||||
|
||||
**returns:**
|
||||
|
||||
* `obj`: an object representing the parsed value of `args`
|
||||
* `key/value`: key value pairs for each argument and their aliases.
|
||||
* `_`: an array representing the positional arguments.
|
||||
* [optional] `--`: an array with arguments after the end-of-options flag `--`.
|
||||
|
||||
### require('yargs-parser').detailed(args, opts={})
|
||||
|
||||
Parses a command line string, returning detailed information required by the
|
||||
yargs engine.
|
||||
|
||||
**expects:**
|
||||
|
||||
* `args`: a string or array of strings representing options to parse.
|
||||
* `opts`: provide a set of hints indicating how `args`, inputs are identical to `require('yargs-parser')(args, opts={})`.
|
||||
|
||||
**returns:**
|
||||
|
||||
* `argv`: an object representing the parsed value of `args`
|
||||
* `key/value`: key value pairs for each argument and their aliases.
|
||||
* `_`: an array representing the positional arguments.
|
||||
* `error`: populated with an error object if an exception occurred during parsing.
|
||||
* `aliases`: the inferred list of aliases built by combining lists in `opts.alias`.
|
||||
* `newAliases`: any new aliases added via camel-case expansion.
|
||||
* `configuration`: the configuration loaded from the `yargs` stanza in package.json.
|
||||
|
||||
<a name="configuration"></a>
|
||||
|
||||
### Configuration
|
||||
|
||||
The yargs-parser applies several automated transformations on the keys provided
|
||||
in `args`. These features can be turned on and off using the `configuration` field
|
||||
of `opts`.
|
||||
|
||||
```js
|
||||
var parsed = parser(['--no-dice'], {
|
||||
configuration: {
|
||||
'boolean-negation': false
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### short option groups
|
||||
|
||||
* default: `true`.
|
||||
* key: `short-option-groups`.
|
||||
|
||||
Should a group of short-options be treated as boolean flags?
|
||||
|
||||
```sh
|
||||
node example.js -abc
|
||||
{ _: [], a: true, b: true, c: true }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js -abc
|
||||
{ _: [], abc: true }
|
||||
```
|
||||
|
||||
### camel-case expansion
|
||||
|
||||
* default: `true`.
|
||||
* key: `camel-case-expansion`.
|
||||
|
||||
Should hyphenated arguments be expanded into camel-case aliases?
|
||||
|
||||
```sh
|
||||
node example.js --foo-bar
|
||||
{ _: [], 'foo-bar': true, fooBar: true }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js --foo-bar
|
||||
{ _: [], 'foo-bar': true }
|
||||
```
|
||||
|
||||
### dot-notation
|
||||
|
||||
* default: `true`
|
||||
* key: `dot-notation`
|
||||
|
||||
Should keys that contain `.` be treated as objects?
|
||||
|
||||
```sh
|
||||
node example.js --foo.bar
|
||||
{ _: [], foo: { bar: true } }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js --foo.bar
|
||||
{ _: [], "foo.bar": true }
|
||||
```
|
||||
|
||||
### parse numbers
|
||||
|
||||
* default: `true`
|
||||
* key: `parse-numbers`
|
||||
|
||||
Should keys that look like numbers be treated as such?
|
||||
|
||||
```sh
|
||||
node example.js --foo=99.3
|
||||
{ _: [], foo: 99.3 }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js --foo=99.3
|
||||
{ _: [], foo: "99.3" }
|
||||
```
|
||||
|
||||
### boolean negation
|
||||
|
||||
* default: `true`
|
||||
* key: `boolean-negation`
|
||||
|
||||
Should variables prefixed with `--no` be treated as negations?
|
||||
|
||||
```sh
|
||||
node example.js --no-foo
|
||||
{ _: [], foo: false }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js --no-foo
|
||||
{ _: [], "no-foo": true }
|
||||
```
|
||||
|
||||
### combine arrays
|
||||
|
||||
* default: `false`
|
||||
* key: `combine-arrays`
|
||||
|
||||
Should arrays be combined when provided by both command line arguments and
|
||||
a configuration file.
|
||||
|
||||
### duplicate arguments array
|
||||
|
||||
* default: `true`
|
||||
* key: `duplicate-arguments-array`
|
||||
|
||||
Should arguments be coerced into an array when duplicated:
|
||||
|
||||
```sh
|
||||
node example.js -x 1 -x 2
|
||||
{ _: [], x: [1, 2] }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js -x 1 -x 2
|
||||
{ _: [], x: 2 }
|
||||
```
|
||||
|
||||
### flatten duplicate arrays
|
||||
|
||||
* default: `true`
|
||||
* key: `flatten-duplicate-arrays`
|
||||
|
||||
Should array arguments be coerced into a single array when duplicated:
|
||||
|
||||
```sh
|
||||
node example.js -x 1 2 -x 3 4
|
||||
{ _: [], x: [1, 2, 3, 4] }
|
||||
```
|
||||
|
||||
_if disabled:_
|
||||
|
||||
```sh
|
||||
node example.js -x 1 2 -x 3 4
|
||||
{ _: [], x: [[1, 2], [3, 4]] }
|
||||
```
|
||||
|
||||
### negation prefix
|
||||
|
||||
* default: `no-`
|
||||
* key: `negation-prefix`
|
||||
|
||||
The prefix to use for negated boolean variables.
|
||||
|
||||
```sh
|
||||
node example.js --no-foo
|
||||
{ _: [], foo: false }
|
||||
```
|
||||
|
||||
_if set to `quux`:_
|
||||
|
||||
```sh
|
||||
node example.js --quuxfoo
|
||||
{ _: [], foo: false }
|
||||
```
|
||||
|
||||
### populate --
|
||||
|
||||
* default: `false`.
|
||||
* key: `populate--`
|
||||
|
||||
Should unparsed flags be stored in `--` or `_`.
|
||||
|
||||
_If disabled:_
|
||||
|
||||
```sh
|
||||
node example.js a -b -- x y
|
||||
{ _: [ 'a', 'x', 'y' ], b: true }
|
||||
```
|
||||
|
||||
_If enabled:_
|
||||
|
||||
```sh
|
||||
node example.js a -b -- x y
|
||||
{ _: [ 'a' ], '--': [ 'x', 'y' ], b: true }
|
||||
```
|
||||
|
||||
### set placeholder key
|
||||
|
||||
* default: `false`.
|
||||
* key: `set-placeholder-key`.
|
||||
|
||||
Should a placeholder be added for keys not set via the corresponding CLI argument?
|
||||
|
||||
_If disabled:_
|
||||
|
||||
```sh
|
||||
node example.js -a 1 -c 2
|
||||
{ _: [], a: 1, c: 2 }
|
||||
```
|
||||
|
||||
_If enabled:_
|
||||
|
||||
```sh
|
||||
node example.js -a 1 -c 2
|
||||
{ _: [], a: 1, b: undefined, c: 2 }
|
||||
```
|
||||
|
||||
### halt at non-option
|
||||
|
||||
* default: `false`.
|
||||
* key: `halt-at-non-option`.
|
||||
|
||||
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
|
||||
{ _: [ 'b' ], a: 'run', x: 'y' }
|
||||
```
|
||||
|
||||
_If enabled:_
|
||||
|
||||
```sh
|
||||
node example.js -a run b -x y
|
||||
{ _: [ '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
|
||||
|
||||
The yargs project evolves from optimist and minimist. It owes its
|
||||
existence to a lot of James Halliday's hard work. Thanks [substack](https://github.com/substack) **beep** **boop** \o/
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
916
node_modules/webpack-cli/node_modules/yargs-parser/index.js
generated
vendored
Normal file
916
node_modules/webpack-cli/node_modules/yargs-parser/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,916 @@
|
|||
var camelCase = require('camelcase')
|
||||
var decamelize = require('decamelize')
|
||||
var path = require('path')
|
||||
var tokenizeArgString = require('./lib/tokenize-arg-string')
|
||||
var util = require('util')
|
||||
|
||||
function parse (args, opts) {
|
||||
if (!opts) 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 = Object.assign({
|
||||
'short-option-groups': true,
|
||||
'camel-case-expansion': true,
|
||||
'dot-notation': true,
|
||||
'parse-numbers': true,
|
||||
'boolean-negation': true,
|
||||
'negation-prefix': 'no-',
|
||||
'duplicate-arguments-array': true,
|
||||
'flatten-duplicate-arrays': true,
|
||||
'populate--': false,
|
||||
'combine-arrays': false,
|
||||
'set-placeholder-key': false,
|
||||
'halt-at-non-option': false,
|
||||
'strip-aliased': false,
|
||||
'strip-dashed': false
|
||||
}, opts.configuration)
|
||||
var defaults = opts.default || {}
|
||||
var configObjects = opts.configObjects || []
|
||||
var envPrefix = opts.envPrefix
|
||||
var notFlagsOption = configuration['populate--']
|
||||
var notFlagsArgv = notFlagsOption ? '--' : '_'
|
||||
var newAliases = {}
|
||||
// allow a i18n handler to be passed in, default to a fake one (util.format).
|
||||
var __ = opts.__ || util.format
|
||||
var error = null
|
||||
var flags = {
|
||||
aliases: {},
|
||||
arrays: {},
|
||||
bools: {},
|
||||
strings: {},
|
||||
numbers: {},
|
||||
counts: {},
|
||||
normalize: {},
|
||||
configs: {},
|
||||
defaulted: {},
|
||||
nargs: {},
|
||||
coercions: {},
|
||||
keys: []
|
||||
}
|
||||
var negative = /^-[0-9]+(\.[0-9]+)?/
|
||||
var negatedBoolean = new RegExp('^--' + configuration['negation-prefix'] + '(.+)')
|
||||
|
||||
;[].concat(opts.array).filter(Boolean).forEach(function (opt) {
|
||||
var key = opt.key || opt
|
||||
|
||||
// assign to flags[bools|strings|numbers]
|
||||
const assignment = Object.keys(opt).map(function (key) {
|
||||
return ({
|
||||
boolean: 'bools',
|
||||
string: 'strings',
|
||||
number: 'numbers'
|
||||
})[key]
|
||||
}).filter(Boolean).pop()
|
||||
|
||||
// assign key to be coerced
|
||||
if (assignment) {
|
||||
flags[assignment][key] = true
|
||||
}
|
||||
|
||||
flags.arrays[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
;[].concat(opts.boolean).filter(Boolean).forEach(function (key) {
|
||||
flags.bools[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
;[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
||||
flags.strings[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
;[].concat(opts.number).filter(Boolean).forEach(function (key) {
|
||||
flags.numbers[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
;[].concat(opts.count).filter(Boolean).forEach(function (key) {
|
||||
flags.counts[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
;[].concat(opts.normalize).filter(Boolean).forEach(function (key) {
|
||||
flags.normalize[key] = true
|
||||
flags.keys.push(key)
|
||||
})
|
||||
|
||||
Object.keys(opts.narg || {}).forEach(function (k) {
|
||||
flags.nargs[k] = opts.narg[k]
|
||||
flags.keys.push(k)
|
||||
})
|
||||
|
||||
Object.keys(opts.coerce || {}).forEach(function (k) {
|
||||
flags.coercions[k] = opts.coerce[k]
|
||||
flags.keys.push(k)
|
||||
})
|
||||
|
||||
if (Array.isArray(opts.config) || typeof opts.config === 'string') {
|
||||
;[].concat(opts.config).filter(Boolean).forEach(function (key) {
|
||||
flags.configs[key] = true
|
||||
})
|
||||
} else {
|
||||
Object.keys(opts.config || {}).forEach(function (k) {
|
||||
flags.configs[k] = opts.config[k]
|
||||
})
|
||||
}
|
||||
|
||||
// create a lookup table that takes into account all
|
||||
// combinations of aliases: {f: ['foo'], foo: ['f']}
|
||||
extendAliases(opts.key, aliases, opts.default, flags.arrays)
|
||||
|
||||
// apply default values to all aliases.
|
||||
Object.keys(defaults).forEach(function (key) {
|
||||
(flags.aliases[key] || []).forEach(function (alias) {
|
||||
defaults[alias] = defaults[key]
|
||||
})
|
||||
})
|
||||
|
||||
var argv = { _: [] }
|
||||
|
||||
Object.keys(flags.bools).forEach(function (key) {
|
||||
if (Object.prototype.hasOwnProperty.call(defaults, key)) {
|
||||
setArg(key, defaults[key])
|
||||
setDefaulted(key)
|
||||
}
|
||||
})
|
||||
|
||||
var notFlags = []
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i]
|
||||
var broken
|
||||
var key
|
||||
var letters
|
||||
var m
|
||||
var next
|
||||
var value
|
||||
|
||||
// -- separated by =
|
||||
if (arg.match(/^--.+=/) || (
|
||||
!configuration['short-option-groups'] && arg.match(/^-.+=/)
|
||||
)) {
|
||||
// Using [\s\S] instead of . because js doesn't support the
|
||||
// 'dotall' regex modifier. See:
|
||||
// http://stackoverflow.com/a/1068308/13216
|
||||
m = arg.match(/^--?([^=]+)=([\s\S]*)$/)
|
||||
|
||||
// nargs format = '--f=monkey washing cat'
|
||||
if (checkAllAliases(m[1], flags.nargs)) {
|
||||
args.splice(i + 1, 0, m[2])
|
||||
i = eatNargs(i, m[1], args)
|
||||
// arrays format = '--f=a b c'
|
||||
} else if (checkAllAliases(m[1], flags.arrays) && args.length > i + 1) {
|
||||
args.splice(i + 1, 0, m[2])
|
||||
i = eatArray(i, m[1], args)
|
||||
} else {
|
||||
setArg(m[1], m[2])
|
||||
}
|
||||
} else if (arg.match(negatedBoolean) && configuration['boolean-negation']) {
|
||||
key = arg.match(negatedBoolean)[1]
|
||||
setArg(key, false)
|
||||
|
||||
// -- seperated by space.
|
||||
} else if (arg.match(/^--.+/) || (
|
||||
!configuration['short-option-groups'] && arg.match(/^-[^-]+/)
|
||||
)) {
|
||||
key = arg.match(/^--?(.+)/)[1]
|
||||
|
||||
// nargs format = '--foo a b c'
|
||||
if (checkAllAliases(key, flags.nargs)) {
|
||||
i = eatNargs(i, key, args)
|
||||
// array format = '--foo a b c'
|
||||
} else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
|
||||
i = eatArray(i, key, args)
|
||||
} else {
|
||||
next = flags.nargs[key] === 0 ? undefined : args[i + 1]
|
||||
|
||||
if (next !== undefined && (!next.match(/^-/) ||
|
||||
next.match(negative)) &&
|
||||
!checkAllAliases(key, flags.bools) &&
|
||||
!checkAllAliases(key, flags.counts)) {
|
||||
setArg(key, next)
|
||||
i++
|
||||
} else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key, next)
|
||||
i++
|
||||
} else {
|
||||
setArg(key, defaultValue(key))
|
||||
}
|
||||
}
|
||||
|
||||
// dot-notation flag seperated by '='.
|
||||
} else if (arg.match(/^-.\..+=/)) {
|
||||
m = arg.match(/^-([^=]+)=([\s\S]*)$/)
|
||||
setArg(m[1], m[2])
|
||||
|
||||
// dot-notation flag seperated by space.
|
||||
} else if (arg.match(/^-.\..+/)) {
|
||||
next = args[i + 1]
|
||||
key = arg.match(/^-(.\..+)/)[1]
|
||||
|
||||
if (next !== undefined && !next.match(/^-/) &&
|
||||
!checkAllAliases(key, flags.bools) &&
|
||||
!checkAllAliases(key, flags.counts)) {
|
||||
setArg(key, next)
|
||||
i++
|
||||
} else {
|
||||
setArg(key, defaultValue(key))
|
||||
}
|
||||
} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
|
||||
letters = arg.slice(1, -1).split('')
|
||||
broken = false
|
||||
|
||||
for (var j = 0; j < letters.length; j++) {
|
||||
next = arg.slice(j + 2)
|
||||
|
||||
if (letters[j + 1] && letters[j + 1] === '=') {
|
||||
value = arg.slice(j + 3)
|
||||
key = letters[j]
|
||||
|
||||
// nargs format = '-f=monkey washing cat'
|
||||
if (checkAllAliases(key, flags.nargs)) {
|
||||
args.splice(i + 1, 0, value)
|
||||
i = eatNargs(i, key, args)
|
||||
// array format = '-f=a b c'
|
||||
} else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
|
||||
args.splice(i + 1, 0, value)
|
||||
i = eatArray(i, key, args)
|
||||
} else {
|
||||
setArg(key, value)
|
||||
}
|
||||
|
||||
broken = true
|
||||
break
|
||||
}
|
||||
|
||||
if (next === '-') {
|
||||
setArg(letters[j], next)
|
||||
continue
|
||||
}
|
||||
|
||||
// current letter is an alphabetic character and next value is a number
|
||||
if (/[A-Za-z]/.test(letters[j]) &&
|
||||
/^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
||||
setArg(letters[j], next)
|
||||
broken = true
|
||||
break
|
||||
}
|
||||
|
||||
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
||||
setArg(letters[j], next)
|
||||
broken = true
|
||||
break
|
||||
} else {
|
||||
setArg(letters[j], defaultValue(letters[j]))
|
||||
}
|
||||
}
|
||||
|
||||
key = arg.slice(-1)[0]
|
||||
|
||||
if (!broken && key !== '-') {
|
||||
// nargs format = '-f a b c'
|
||||
if (checkAllAliases(key, flags.nargs)) {
|
||||
i = eatNargs(i, key, args)
|
||||
// array format = '-f a b c'
|
||||
} else if (checkAllAliases(key, flags.arrays) && args.length > i + 1) {
|
||||
i = eatArray(i, key, args)
|
||||
} else {
|
||||
next = args[i + 1]
|
||||
|
||||
if (next !== undefined && (!/^(-|--)[^-]/.test(next) ||
|
||||
next.match(negative)) &&
|
||||
!checkAllAliases(key, flags.bools) &&
|
||||
!checkAllAliases(key, flags.counts)) {
|
||||
setArg(key, next)
|
||||
i++
|
||||
} else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key, next)
|
||||
i++
|
||||
} else {
|
||||
setArg(key, defaultValue(key))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (arg === '--') {
|
||||
notFlags = args.slice(i + 1)
|
||||
break
|
||||
} else if (configuration['halt-at-non-option']) {
|
||||
notFlags = args.slice(i)
|
||||
break
|
||||
} else {
|
||||
argv._.push(maybeCoerceNumber('_', arg))
|
||||
}
|
||||
}
|
||||
|
||||
// order of precedence:
|
||||
// 1. command line arg
|
||||
// 2. value from env var
|
||||
// 3. value from config file
|
||||
// 4. value from config objects
|
||||
// 5. configured default value
|
||||
applyEnvVars(argv, true) // special case: check env vars that point to config file
|
||||
applyEnvVars(argv, false)
|
||||
setConfig(argv)
|
||||
setConfigObjects()
|
||||
applyDefaultsAndAliases(argv, flags.aliases, defaults)
|
||||
applyCoercions(argv)
|
||||
if (configuration['set-placeholder-key']) setPlaceholderKeys(argv)
|
||||
|
||||
// for any counts either not in args or without an explicit default, set to 0
|
||||
Object.keys(flags.counts).forEach(function (key) {
|
||||
if (!hasKey(argv, key.split('.'))) setArg(key, 0)
|
||||
})
|
||||
|
||||
// '--' defaults to undefined.
|
||||
if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = []
|
||||
notFlags.forEach(function (key) {
|
||||
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) {
|
||||
var ii
|
||||
const toEat = checkAllAliases(key, flags.nargs)
|
||||
|
||||
// nargs will not consume flag arguments, e.g., -abc, --foo,
|
||||
// and terminates when one is observed.
|
||||
var available = 0
|
||||
for (ii = i + 1; ii < args.length; ii++) {
|
||||
if (!args[ii].match(/^-[^0-9]/)) available++
|
||||
else break
|
||||
}
|
||||
|
||||
if (available < toEat) error = Error(__('Not enough arguments following: %s', key))
|
||||
|
||||
const consumed = Math.min(available, toEat)
|
||||
for (ii = i + 1; ii < (consumed + i + 1); ii++) {
|
||||
setArg(key, args[ii])
|
||||
}
|
||||
|
||||
return (i + consumed)
|
||||
}
|
||||
|
||||
// if an option is an array, eat all non-hyphenated arguments
|
||||
// following it... YUM!
|
||||
// e.g., --foo apple banana cat becomes ["apple", "banana", "cat"]
|
||||
function eatArray (i, key, args) {
|
||||
var start = i + 1
|
||||
var argsToSet = []
|
||||
var multipleArrayFlag = i > 0
|
||||
for (var ii = i + 1; ii < args.length; ii++) {
|
||||
if (/^-/.test(args[ii]) && !negative.test(args[ii])) {
|
||||
if (ii === start) {
|
||||
setArg(key, defaultForType('array'))
|
||||
}
|
||||
multipleArrayFlag = true
|
||||
break
|
||||
}
|
||||
i = ii
|
||||
argsToSet.push(args[ii])
|
||||
}
|
||||
if (multipleArrayFlag) {
|
||||
setArg(key, argsToSet.map(function (arg) {
|
||||
return processValue(key, arg)
|
||||
}))
|
||||
} else {
|
||||
argsToSet.forEach(function (arg) {
|
||||
setArg(key, arg)
|
||||
})
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
function setArg (key, val) {
|
||||
unsetDefaulted(key)
|
||||
|
||||
if (/-/.test(key) && configuration['camel-case-expansion']) {
|
||||
var alias = key.split('.').map(function (prop) {
|
||||
return camelCase(prop)
|
||||
}).join('.')
|
||||
addNewAlias(key, alias)
|
||||
}
|
||||
|
||||
var value = processValue(key, val)
|
||||
|
||||
var splitKey = key.split('.')
|
||||
setKey(argv, splitKey, value)
|
||||
|
||||
// handle populating aliases of the full key
|
||||
if (flags.aliases[key] && flags.aliases[key].forEach) {
|
||||
flags.aliases[key].forEach(function (x) {
|
||||
x = x.split('.')
|
||||
setKey(argv, x, value)
|
||||
})
|
||||
}
|
||||
|
||||
// handle populating aliases of the first element of the dot-notation key
|
||||
if (splitKey.length > 1 && configuration['dot-notation']) {
|
||||
;(flags.aliases[splitKey[0]] || []).forEach(function (x) {
|
||||
x = x.split('.')
|
||||
|
||||
// expand alias with nested objects in key
|
||||
var a = [].concat(splitKey)
|
||||
a.shift() // nuke the old key.
|
||||
x = x.concat(a)
|
||||
|
||||
setKey(argv, x, value)
|
||||
})
|
||||
}
|
||||
|
||||
// Set normalize getter and setter when key is in 'normalize' but isn't an array
|
||||
if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
|
||||
var keys = [key].concat(flags.aliases[key] || [])
|
||||
keys.forEach(function (key) {
|
||||
argv.__defineSetter__(key, function (v) {
|
||||
val = path.normalize(v)
|
||||
})
|
||||
|
||||
argv.__defineGetter__(key, function () {
|
||||
return typeof val === 'string' ? path.normalize(val) : val
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function addNewAlias (key, alias) {
|
||||
if (!(flags.aliases[key] && flags.aliases[key].length)) {
|
||||
flags.aliases[key] = [alias]
|
||||
newAliases[alias] = true
|
||||
}
|
||||
if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
|
||||
addNewAlias(alias, key)
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
|
||||
var value = maybeCoerceNumber(key, val)
|
||||
|
||||
// increment a count given as arg (either no value or value parsed as boolean)
|
||||
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
|
||||
value = increment
|
||||
}
|
||||
|
||||
// Set normalized value when key is in 'normalize' and in 'arrays'
|
||||
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
|
||||
if (Array.isArray(val)) value = val.map(path.normalize)
|
||||
else value = path.normalize(val)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
function maybeCoerceNumber (key, value) {
|
||||
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.coercions)) {
|
||||
const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (
|
||||
Number.isSafeInteger(Math.floor(value))
|
||||
)
|
||||
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) value = Number(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// set args from config.json file, this should be
|
||||
// applied last so that defaults can be applied.
|
||||
function setConfig (argv) {
|
||||
var configLookup = {}
|
||||
|
||||
// expand defaults/aliases, in-case any happen to reference
|
||||
// the config.json file.
|
||||
applyDefaultsAndAliases(configLookup, flags.aliases, defaults)
|
||||
|
||||
Object.keys(flags.configs).forEach(function (configKey) {
|
||||
var configPath = argv[configKey] || configLookup[configKey]
|
||||
if (configPath) {
|
||||
try {
|
||||
var config = null
|
||||
var resolvedConfigPath = path.resolve(process.cwd(), configPath)
|
||||
|
||||
if (typeof flags.configs[configKey] === 'function') {
|
||||
try {
|
||||
config = flags.configs[configKey](resolvedConfigPath)
|
||||
} catch (e) {
|
||||
config = e
|
||||
}
|
||||
if (config instanceof Error) {
|
||||
error = config
|
||||
return
|
||||
}
|
||||
} else {
|
||||
config = require(resolvedConfigPath)
|
||||
}
|
||||
|
||||
setConfigObject(config)
|
||||
} catch (ex) {
|
||||
if (argv[configKey]) error = Error(__('Invalid JSON config file: %s', configPath))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// set args from config object.
|
||||
// it recursively checks nested objects.
|
||||
function setConfigObject (config, prev) {
|
||||
Object.keys(config).forEach(function (key) {
|
||||
var value = config[key]
|
||||
var fullKey = prev ? prev + '.' + key : key
|
||||
|
||||
// if the value is an inner object and we have dot-notation
|
||||
// enabled, treat inner objects in config the same as
|
||||
// heavily nested dot notations (foo.bar.apple).
|
||||
if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
|
||||
// if the value is an object but not an array, check nested object
|
||||
setConfigObject(value, fullKey)
|
||||
} else {
|
||||
// setting arguments via CLI takes precedence over
|
||||
// values within the config file.
|
||||
if (!hasKey(argv, fullKey.split('.')) || (flags.defaulted[fullKey]) || (flags.arrays[fullKey] && configuration['combine-arrays'])) {
|
||||
setArg(fullKey, value)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// set all config objects passed in opts
|
||||
function setConfigObjects () {
|
||||
if (typeof configObjects === 'undefined') return
|
||||
configObjects.forEach(function (configObject) {
|
||||
setConfigObject(configObject)
|
||||
})
|
||||
}
|
||||
|
||||
function applyEnvVars (argv, configOnly) {
|
||||
if (typeof envPrefix === 'undefined') return
|
||||
|
||||
var prefix = typeof envPrefix === 'string' ? envPrefix : ''
|
||||
Object.keys(process.env).forEach(function (envVar) {
|
||||
if (prefix === '' || envVar.lastIndexOf(prefix, 0) === 0) {
|
||||
// get array of nested keys and convert them to camel case
|
||||
var keys = envVar.split('__').map(function (key, i) {
|
||||
if (i === 0) {
|
||||
key = key.substring(prefix.length)
|
||||
}
|
||||
return camelCase(key)
|
||||
})
|
||||
|
||||
if (((configOnly && flags.configs[keys.join('.')]) || !configOnly) && (!hasKey(argv, keys) || flags.defaulted[keys.join('.')])) {
|
||||
setArg(keys.join('.'), process.env[envVar])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function applyCoercions (argv) {
|
||||
var coerce
|
||||
var applied = {}
|
||||
Object.keys(argv).forEach(function (key) {
|
||||
if (!applied.hasOwnProperty(key)) { // If we haven't already coerced this option via one of its aliases
|
||||
coerce = checkAllAliases(key, flags.coercions)
|
||||
if (typeof coerce === 'function') {
|
||||
try {
|
||||
var value = coerce(argv[key])
|
||||
;([].concat(flags.aliases[key] || [], key)).forEach(ali => {
|
||||
applied[ali] = argv[ali] = value
|
||||
})
|
||||
} catch (err) {
|
||||
error = err
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function setPlaceholderKeys (argv) {
|
||||
flags.keys.forEach((key) => {
|
||||
// don't set placeholder keys for dot notation options 'foo.bar'.
|
||||
if (~key.indexOf('.')) return
|
||||
if (typeof argv[key] === 'undefined') argv[key] = undefined
|
||||
})
|
||||
return argv
|
||||
}
|
||||
|
||||
function applyDefaultsAndAliases (obj, aliases, defaults) {
|
||||
Object.keys(defaults).forEach(function (key) {
|
||||
if (!hasKey(obj, key.split('.'))) {
|
||||
setKey(obj, key.split('.'), defaults[key])
|
||||
|
||||
;(aliases[key] || []).forEach(function (x) {
|
||||
if (hasKey(obj, x.split('.'))) return
|
||||
setKey(obj, x.split('.'), defaults[key])
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function hasKey (obj, keys) {
|
||||
var o = obj
|
||||
|
||||
if (!configuration['dot-notation']) keys = [keys.join('.')]
|
||||
|
||||
keys.slice(0, -1).forEach(function (key) {
|
||||
o = (o[key] || {})
|
||||
})
|
||||
|
||||
var key = keys[keys.length - 1]
|
||||
|
||||
if (typeof o !== 'object') return false
|
||||
else return key in o
|
||||
}
|
||||
|
||||
function setKey (obj, keys, value) {
|
||||
var o = obj
|
||||
|
||||
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] = {}
|
||||
}
|
||||
|
||||
if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
|
||||
// ensure that o[key] is an array, and that the last item is an empty object.
|
||||
if (Array.isArray(o[key])) {
|
||||
o[key].push({})
|
||||
} else {
|
||||
o[key] = [o[key], {}]
|
||||
}
|
||||
|
||||
// we want to update the empty object at the end of the o[key] array, so set o to that object
|
||||
o = o[key][o[key].length - 1]
|
||||
} else {
|
||||
o = o[key]
|
||||
}
|
||||
})
|
||||
|
||||
// TODO(bcoe): in the next major version of yargs, switch to
|
||||
// Object.create(null) for dot notation:
|
||||
const key = sanitizeKey(keys[keys.length - 1])
|
||||
|
||||
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])
|
||||
} else if (Array.isArray(o[key])) {
|
||||
if (duplicate && isTypeArray && isValueArray) {
|
||||
o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value])
|
||||
} else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
|
||||
o[key] = value
|
||||
} else {
|
||||
o[key] = o[key].concat([value])
|
||||
}
|
||||
} else if (o[key] === undefined && isTypeArray) {
|
||||
o[key] = isValueArray ? value : [value]
|
||||
} else if (duplicate && !(o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(keys.join('.'), flags.bools) || checkAllAliases(key, flags.counts))) {
|
||||
o[key] = [ o[key], value ]
|
||||
} else {
|
||||
o[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
// extend the aliases list with inferred aliases.
|
||||
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
|
||||
// exist in both 'opts.default' and 'opts.key'.
|
||||
if (flags.aliases[key]) return
|
||||
|
||||
flags.aliases[key] = [].concat(aliases[key] || [])
|
||||
// For "--option-name", also set argv.optionName
|
||||
flags.aliases[key].concat(key).forEach(function (x) {
|
||||
if (/-/.test(x) && configuration['camel-case-expansion']) {
|
||||
var c = camelCase(x)
|
||||
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
||||
flags.aliases[key].push(c)
|
||||
newAliases[c] = true
|
||||
}
|
||||
}
|
||||
})
|
||||
// For "--optionName", also set argv['option-name']
|
||||
flags.aliases[key].concat(key).forEach(function (x) {
|
||||
if (x.length > 1 && /[A-Z]/.test(x) && configuration['camel-case-expansion']) {
|
||||
var c = decamelize(x, '-')
|
||||
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
||||
flags.aliases[key].push(c)
|
||||
newAliases[c] = true
|
||||
}
|
||||
}
|
||||
})
|
||||
flags.aliases[key].forEach(function (x) {
|
||||
flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
|
||||
return x !== y
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// check if a flag is set for any of a key's aliases.
|
||||
function checkAllAliases (key, flag) {
|
||||
var isSet = false
|
||||
var toCheck = [].concat(flags.aliases[key] || [], key)
|
||||
|
||||
toCheck.forEach(function (key) {
|
||||
if (flag[key]) isSet = flag[key]
|
||||
})
|
||||
|
||||
return isSet
|
||||
}
|
||||
|
||||
function setDefaulted (key) {
|
||||
[].concat(flags.aliases[key] || [], key).forEach(function (k) {
|
||||
flags.defaulted[k] = true
|
||||
})
|
||||
}
|
||||
|
||||
function unsetDefaulted (key) {
|
||||
[].concat(flags.aliases[key] || [], key).forEach(function (k) {
|
||||
delete flags.defaulted[k]
|
||||
})
|
||||
}
|
||||
|
||||
// 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) {
|
||||
var def = {
|
||||
boolean: true,
|
||||
string: '',
|
||||
number: undefined,
|
||||
array: []
|
||||
}
|
||||
|
||||
return def[type]
|
||||
}
|
||||
|
||||
// given a flag, enforce a default type.
|
||||
function guessType (key) {
|
||||
var type = 'boolean'
|
||||
|
||||
if (checkAllAliases(key, flags.strings)) type = 'string'
|
||||
else if (checkAllAliases(key, flags.numbers)) type = 'number'
|
||||
else if (checkAllAliases(key, flags.arrays)) type = 'array'
|
||||
|
||||
return type
|
||||
}
|
||||
|
||||
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
|
||||
// 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) {
|
||||
return num === undefined
|
||||
}
|
||||
|
||||
return {
|
||||
argv: argv,
|
||||
error: error,
|
||||
aliases: flags.aliases,
|
||||
newAliases: newAliases,
|
||||
configuration: configuration
|
||||
}
|
||||
}
|
||||
|
||||
// if any aliases reference each other, we should
|
||||
// merge them together.
|
||||
function combineAliases (aliases) {
|
||||
var aliasArrays = []
|
||||
var change = true
|
||||
var combined = {}
|
||||
|
||||
// turn alias lookup hash {key: ['alias1', 'alias2']} into
|
||||
// a simple array ['key', 'alias1', 'alias2']
|
||||
Object.keys(aliases).forEach(function (key) {
|
||||
aliasArrays.push(
|
||||
[].concat(aliases[key], key)
|
||||
)
|
||||
})
|
||||
|
||||
// combine arrays until zero changes are
|
||||
// made in an iteration.
|
||||
while (change) {
|
||||
change = false
|
||||
for (var i = 0; i < aliasArrays.length; i++) {
|
||||
for (var ii = i + 1; ii < aliasArrays.length; ii++) {
|
||||
var intersect = aliasArrays[i].filter(function (v) {
|
||||
return aliasArrays[ii].indexOf(v) !== -1
|
||||
})
|
||||
|
||||
if (intersect.length) {
|
||||
aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii])
|
||||
aliasArrays.splice(ii, 1)
|
||||
change = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// map arrays back to the hash-lookup (de-dupe while
|
||||
// we're at it).
|
||||
aliasArrays.forEach(function (aliasArray) {
|
||||
aliasArray = aliasArray.filter(function (v, i, self) {
|
||||
return self.indexOf(v) === i
|
||||
})
|
||||
combined[aliasArray.pop()] = aliasArray
|
||||
})
|
||||
|
||||
return combined
|
||||
}
|
||||
|
||||
// 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
|
||||
function increment (orig) {
|
||||
return orig !== undefined ? orig + 1 : 1
|
||||
}
|
||||
|
||||
function Parser (args, opts) {
|
||||
var result = parse(args.slice(), opts)
|
||||
|
||||
return result.argv
|
||||
}
|
||||
|
||||
// parse arguments and return detailed
|
||||
// meta information, aliases, etc.
|
||||
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
|
||||
40
node_modules/webpack-cli/node_modules/yargs-parser/lib/tokenize-arg-string.js
generated
vendored
Normal file
40
node_modules/webpack-cli/node_modules/yargs-parser/lib/tokenize-arg-string.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// take an un-split argv string and tokenize it.
|
||||
module.exports = function (argString) {
|
||||
if (Array.isArray(argString)) {
|
||||
return argString.map(e => typeof e !== 'string' ? e + '' : e)
|
||||
}
|
||||
|
||||
argString = argString.trim()
|
||||
|
||||
var i = 0
|
||||
var prevC = null
|
||||
var c = null
|
||||
var opening = null
|
||||
var args = []
|
||||
|
||||
for (var ii = 0; ii < argString.length; ii++) {
|
||||
prevC = c
|
||||
c = argString.charAt(ii)
|
||||
|
||||
// split on spaces unless we're in quotes.
|
||||
if (c === ' ' && !opening) {
|
||||
if (!(prevC === ' ')) {
|
||||
i++
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// don't split the string if we're in matching
|
||||
// opening or closing single and double quotes.
|
||||
if (c === opening) {
|
||||
opening = null
|
||||
} else if ((c === "'" || c === '"') && !opening) {
|
||||
opening = c
|
||||
}
|
||||
|
||||
if (!args[i]) args[i] = ''
|
||||
args[i] += c
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
47
node_modules/webpack-cli/node_modules/yargs-parser/package.json
generated
vendored
Normal file
47
node_modules/webpack-cli/node_modules/yargs-parser/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "yargs-parser",
|
||||
"version": "13.1.2",
|
||||
"description": "the mighty option parser used by yargs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "nyc mocha test/*.js",
|
||||
"posttest": "standard",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"repository": {
|
||||
"url": "git@github.com:yargs/yargs-parser.git"
|
||||
},
|
||||
"keywords": [
|
||||
"argument",
|
||||
"parser",
|
||||
"yargs",
|
||||
"command",
|
||||
"cli",
|
||||
"parsing",
|
||||
"option",
|
||||
"args",
|
||||
"argument"
|
||||
],
|
||||
"author": "Ben Coe <ben@npmjs.com>",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "^14.1.0",
|
||||
"standard": "^12.0.1",
|
||||
"standard-version": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"camelcase": "^5.0.0",
|
||||
"decamelize": "^1.2.0"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"index.js"
|
||||
],
|
||||
"engine": {
|
||||
"node": ">=6"
|
||||
}
|
||||
}
|
||||
1335
node_modules/webpack-cli/node_modules/yargs/CHANGELOG.md
generated
vendored
Normal file
1335
node_modules/webpack-cli/node_modules/yargs/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
22
node_modules/webpack-cli/node_modules/yargs/LICENSE
generated
vendored
Normal file
22
node_modules/webpack-cli/node_modules/yargs/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Copyright 2010 James Halliday (mail@substack.net)
|
||||
Modified work Copyright 2014 Contributors (ben@npmjs.com)
|
||||
|
||||
This project is free software released under the MIT/X11 license:
|
||||
|
||||
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.
|
||||
122
node_modules/webpack-cli/node_modules/yargs/README.md
generated
vendored
Normal file
122
node_modules/webpack-cli/node_modules/yargs/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<p align="center">
|
||||
<img width="250" src="/yargs-logo.png">
|
||||
</p>
|
||||
<h1 align="center"> Yargs </h1>
|
||||
<p align="center">
|
||||
<b >Yargs be a node.js library fer hearties tryin' ter parse optstrings</b>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![js-standard-style][standard-image]][standard-url]
|
||||
[![Conventional Commits][conventional-commits-image]][conventional-commits-url]
|
||||
[![Slack][slack-image]][slack-url]
|
||||
|
||||
## Description :
|
||||
Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.
|
||||
|
||||
It gives you:
|
||||
|
||||
* commands and (grouped) options (`my-program.js serve --port=5000`).
|
||||
* a dynamically generated help menu based on your arguments.
|
||||
|
||||
> <img width="400" src="/screen.png">
|
||||
|
||||
* bash-completion shortcuts for commands and options.
|
||||
* and [tons more](/docs/api.md).
|
||||
|
||||
## Installation
|
||||
|
||||
Stable version:
|
||||
```bash
|
||||
npm i yargs
|
||||
```
|
||||
|
||||
Bleeding edge version with the most recent features:
|
||||
```bash
|
||||
npm i yargs@next
|
||||
```
|
||||
|
||||
## Usage :
|
||||
|
||||
### Simple Example
|
||||
|
||||
````javascript
|
||||
#!/usr/bin/env node
|
||||
const argv = require('yargs').argv
|
||||
|
||||
if (argv.ships > 3 && argv.distance < 53.5) {
|
||||
console.log('Plunder more riffiwobbles!')
|
||||
} else {
|
||||
console.log('Retreat from the xupptumblers!')
|
||||
}
|
||||
````
|
||||
|
||||
```bash
|
||||
$ ./plunder.js --ships=4 --distance=22
|
||||
Plunder more riffiwobbles!
|
||||
|
||||
$ ./plunder.js --ships 12 --distance 98.7
|
||||
Retreat from the xupptumblers!
|
||||
```
|
||||
|
||||
### Complex Example
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
require('yargs') // eslint-disable-line
|
||||
.command('serve [port]', 'start the server', (yargs) => {
|
||||
yargs
|
||||
.positional('port', {
|
||||
describe: 'port to bind on',
|
||||
default: 5000
|
||||
})
|
||||
}, (argv) => {
|
||||
if (argv.verbose) console.info(`start server on :${argv.port}`)
|
||||
serve(argv.port)
|
||||
})
|
||||
.option('verbose', {
|
||||
alias: 'v',
|
||||
default: false
|
||||
})
|
||||
.argv
|
||||
```
|
||||
|
||||
Run the example above with `--help` to see the help for the application.
|
||||
|
||||
## Community :
|
||||
|
||||
Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com).
|
||||
|
||||
## Documentation :
|
||||
|
||||
### Table of Contents
|
||||
|
||||
* [Yargs' API](/docs/api.md)
|
||||
* [Examples](/docs/examples.md)
|
||||
* [Parsing Tricks](/docs/tricks.md)
|
||||
* [Stop the Parser](/docs/tricks.md#stop)
|
||||
* [Negating Boolean Arguments](/docs/tricks.md#negate)
|
||||
* [Numbers](/docs/tricks.md#numbers)
|
||||
* [Arrays](/docs/tricks.md#arrays)
|
||||
* [Objects](/docs/tricks.md#objects)
|
||||
* [Advanced Topics](/docs/advanced.md)
|
||||
* [Composing Your App Using Commands](/docs/advanced.md#commands)
|
||||
* [Building Configurable CLI Apps](/docs/advanced.md#configuration)
|
||||
* [Customizing Yargs' Parser](/docs/advanced.md#customizing)
|
||||
* [Contributing](/contributing.md)
|
||||
|
||||
[travis-url]: https://travis-ci.org/yargs/yargs
|
||||
[travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
|
||||
[coveralls-url]: https://coveralls.io/github/yargs/yargs
|
||||
[coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
|
||||
[npm-url]: https://www.npmjs.com/package/yargs
|
||||
[npm-image]: https://img.shields.io/npm/v/yargs.svg
|
||||
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
||||
[standard-url]: http://standardjs.com/
|
||||
[conventional-commits-image]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
|
||||
[conventional-commits-url]: https://conventionalcommits.org/
|
||||
[slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
|
||||
[slack-url]: http://devtoolscommunity.herokuapp.com
|
||||
32
node_modules/webpack-cli/node_modules/yargs/index.js
generated
vendored
Normal file
32
node_modules/webpack-cli/node_modules/yargs/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use strict'
|
||||
// classic singleton yargs API, to use yargs
|
||||
// without running as a singleton do:
|
||||
// require('yargs/yargs')(process.argv.slice(2))
|
||||
const yargs = require('./yargs')
|
||||
|
||||
Argv(process.argv.slice(2))
|
||||
|
||||
module.exports = Argv
|
||||
|
||||
function Argv (processArgs, cwd) {
|
||||
const argv = yargs(processArgs, cwd, require)
|
||||
singletonify(argv)
|
||||
return argv
|
||||
}
|
||||
|
||||
/* Hack an instance of Argv with process.argv into Argv
|
||||
so people can do
|
||||
require('yargs')(['--beeble=1','-z','zizzle']).argv
|
||||
to parse a list of args and
|
||||
require('yargs').argv
|
||||
to get a parsed version of process.argv.
|
||||
*/
|
||||
function singletonify (inst) {
|
||||
Object.keys(inst).forEach((key) => {
|
||||
if (key === 'argv') {
|
||||
Argv.__defineGetter__(key, inst.__lookupGetter__(key))
|
||||
} else {
|
||||
Argv[key] = typeof inst[key] === 'function' ? inst[key].bind(inst) : inst[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
53
node_modules/webpack-cli/node_modules/yargs/lib/apply-extends.js
generated
vendored
Normal file
53
node_modules/webpack-cli/node_modules/yargs/lib/apply-extends.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
'use strict'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const YError = require('./yerror')
|
||||
|
||||
let previouslyVisitedConfigs = []
|
||||
|
||||
function checkForCircularExtends (cfgPath) {
|
||||
if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
|
||||
throw new YError(`Circular extended configurations: '${cfgPath}'.`)
|
||||
}
|
||||
}
|
||||
|
||||
function getPathToDefaultConfig (cwd, pathToExtend) {
|
||||
return path.resolve(cwd, pathToExtend)
|
||||
}
|
||||
|
||||
function applyExtends (config, cwd) {
|
||||
let defaultConfig = {}
|
||||
|
||||
if (config.hasOwnProperty('extends')) {
|
||||
if (typeof config.extends !== 'string') return defaultConfig
|
||||
const isPath = /\.json|\..*rc$/.test(config.extends)
|
||||
let pathToDefault = null
|
||||
if (!isPath) {
|
||||
try {
|
||||
pathToDefault = require.resolve(config.extends)
|
||||
} catch (err) {
|
||||
// most likely this simply isn't a module.
|
||||
}
|
||||
} else {
|
||||
pathToDefault = getPathToDefaultConfig(cwd, config.extends)
|
||||
}
|
||||
// maybe the module uses key for some other reason,
|
||||
// err on side of caution.
|
||||
if (!pathToDefault && !isPath) return config
|
||||
|
||||
checkForCircularExtends(pathToDefault)
|
||||
|
||||
previouslyVisitedConfigs.push(pathToDefault)
|
||||
|
||||
defaultConfig = isPath ? JSON.parse(fs.readFileSync(pathToDefault, 'utf8')) : require(config.extends)
|
||||
delete config.extends
|
||||
defaultConfig = applyExtends(defaultConfig, path.dirname(pathToDefault))
|
||||
}
|
||||
|
||||
previouslyVisitedConfigs = []
|
||||
|
||||
return Object.assign({}, defaultConfig, config)
|
||||
}
|
||||
|
||||
module.exports = applyExtends
|
||||
68
node_modules/webpack-cli/node_modules/yargs/lib/argsert.js
generated
vendored
Normal file
68
node_modules/webpack-cli/node_modules/yargs/lib/argsert.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict'
|
||||
|
||||
// hoisted due to circular dependency on command.
|
||||
module.exports = argsert
|
||||
const command = require('./command')()
|
||||
const YError = require('./yerror')
|
||||
|
||||
const positionName = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']
|
||||
function argsert (expected, callerArguments, length) {
|
||||
// TODO: should this eventually raise an exception.
|
||||
try {
|
||||
// preface the argument description with "cmd", so
|
||||
// that we can run it through yargs' command parser.
|
||||
let position = 0
|
||||
let parsed = { demanded: [], optional: [] }
|
||||
if (typeof expected === 'object') {
|
||||
length = callerArguments
|
||||
callerArguments = expected
|
||||
} else {
|
||||
parsed = command.parseCommand(`cmd ${expected}`)
|
||||
}
|
||||
const args = [].slice.call(callerArguments)
|
||||
|
||||
while (args.length && args[args.length - 1] === undefined) args.pop()
|
||||
length = length || args.length
|
||||
|
||||
if (length < parsed.demanded.length) {
|
||||
throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`)
|
||||
}
|
||||
|
||||
const totalCommands = parsed.demanded.length + parsed.optional.length
|
||||
if (length > totalCommands) {
|
||||
throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`)
|
||||
}
|
||||
|
||||
parsed.demanded.forEach((demanded) => {
|
||||
const arg = args.shift()
|
||||
const observedType = guessType(arg)
|
||||
const matchingTypes = demanded.cmd.filter(type => type === observedType || type === '*')
|
||||
if (matchingTypes.length === 0) argumentTypeError(observedType, demanded.cmd, position, false)
|
||||
position += 1
|
||||
})
|
||||
|
||||
parsed.optional.forEach((optional) => {
|
||||
if (args.length === 0) return
|
||||
const arg = args.shift()
|
||||
const observedType = guessType(arg)
|
||||
const matchingTypes = optional.cmd.filter(type => type === observedType || type === '*')
|
||||
if (matchingTypes.length === 0) argumentTypeError(observedType, optional.cmd, position, true)
|
||||
position += 1
|
||||
})
|
||||
} catch (err) {
|
||||
console.warn(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function guessType (arg) {
|
||||
if (Array.isArray(arg)) {
|
||||
return 'array'
|
||||
} else if (arg === null) {
|
||||
return 'null'
|
||||
}
|
||||
return typeof arg
|
||||
}
|
||||
|
||||
function argumentTypeError (observedType, allowedTypes, position, optional) {
|
||||
throw new YError(`Invalid ${positionName[position] || 'manyith'} argument. Expected ${allowedTypes.join(' or ')} but received ${observedType}.`)
|
||||
}
|
||||
437
node_modules/webpack-cli/node_modules/yargs/lib/command.js
generated
vendored
Normal file
437
node_modules/webpack-cli/node_modules/yargs/lib/command.js
generated
vendored
Normal file
|
|
@ -0,0 +1,437 @@
|
|||
'use strict'
|
||||
|
||||
const inspect = require('util').inspect
|
||||
const isPromise = require('./is-promise')
|
||||
const { applyMiddleware, commandMiddlewareFactory } = require('./middleware')
|
||||
const path = require('path')
|
||||
const Parser = require('yargs-parser')
|
||||
|
||||
const DEFAULT_MARKER = /(^\*)|(^\$0)/
|
||||
|
||||
// handles parsing positional arguments,
|
||||
// and populating argv with said positional
|
||||
// arguments.
|
||||
module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
||||
const self = {}
|
||||
let handlers = {}
|
||||
let aliasMap = {}
|
||||
let defaultCommand
|
||||
globalMiddleware = globalMiddleware || []
|
||||
|
||||
self.addHandler = function addHandler (cmd, description, builder, handler, commandMiddleware) {
|
||||
let aliases = []
|
||||
const middlewares = commandMiddlewareFactory(commandMiddleware)
|
||||
handler = handler || (() => {})
|
||||
|
||||
if (Array.isArray(cmd)) {
|
||||
aliases = cmd.slice(1)
|
||||
cmd = cmd[0]
|
||||
} else if (typeof cmd === 'object') {
|
||||
let command = (Array.isArray(cmd.command) || typeof cmd.command === 'string') ? cmd.command : moduleName(cmd)
|
||||
if (cmd.aliases) command = [].concat(command).concat(cmd.aliases)
|
||||
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares)
|
||||
return
|
||||
}
|
||||
|
||||
// allow a module to be provided instead of separate builder and handler
|
||||
if (typeof builder === 'object' && builder.builder && typeof builder.handler === 'function') {
|
||||
self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares)
|
||||
return
|
||||
}
|
||||
|
||||
// parse positionals out of cmd string
|
||||
const parsedCommand = self.parseCommand(cmd)
|
||||
|
||||
// remove positional args from aliases only
|
||||
aliases = aliases.map(alias => self.parseCommand(alias).cmd)
|
||||
|
||||
// check for default and filter out '*''
|
||||
let isDefault = false
|
||||
const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
|
||||
if (DEFAULT_MARKER.test(c)) {
|
||||
isDefault = true
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
// standardize on $0 for default command.
|
||||
if (parsedAliases.length === 0 && isDefault) parsedAliases.push('$0')
|
||||
|
||||
// shift cmd and aliases after filtering out '*'
|
||||
if (isDefault) {
|
||||
parsedCommand.cmd = parsedAliases[0]
|
||||
aliases = parsedAliases.slice(1)
|
||||
cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd)
|
||||
}
|
||||
|
||||
// populate aliasMap
|
||||
aliases.forEach((alias) => {
|
||||
aliasMap[alias] = parsedCommand.cmd
|
||||
})
|
||||
|
||||
if (description !== false) {
|
||||
usage.command(cmd, description, isDefault, aliases)
|
||||
}
|
||||
|
||||
handlers[parsedCommand.cmd] = {
|
||||
original: cmd,
|
||||
description: description,
|
||||
handler,
|
||||
builder: builder || {},
|
||||
middlewares: middlewares || [],
|
||||
demanded: parsedCommand.demanded,
|
||||
optional: parsedCommand.optional
|
||||
}
|
||||
|
||||
if (isDefault) defaultCommand = handlers[parsedCommand.cmd]
|
||||
}
|
||||
|
||||
self.addDirectory = function addDirectory (dir, context, req, callerFile, opts) {
|
||||
opts = opts || {}
|
||||
// disable recursion to support nested directories of subcommands
|
||||
if (typeof opts.recurse !== 'boolean') opts.recurse = false
|
||||
// exclude 'json', 'coffee' from require-directory defaults
|
||||
if (!Array.isArray(opts.extensions)) opts.extensions = ['js']
|
||||
// allow consumer to define their own visitor function
|
||||
const parentVisit = typeof opts.visit === 'function' ? opts.visit : o => o
|
||||
// call addHandler via visitor function
|
||||
opts.visit = function visit (obj, joined, filename) {
|
||||
const visited = parentVisit(obj, joined, filename)
|
||||
// allow consumer to skip modules with their own visitor
|
||||
if (visited) {
|
||||
// check for cyclic reference
|
||||
// each command file path should only be seen once per execution
|
||||
if (~context.files.indexOf(joined)) return visited
|
||||
// keep track of visited files in context.files
|
||||
context.files.push(joined)
|
||||
self.addHandler(visited)
|
||||
}
|
||||
return visited
|
||||
}
|
||||
require('require-directory')({ require: req, filename: callerFile }, dir, opts)
|
||||
}
|
||||
|
||||
// lookup module object from require()d command and derive name
|
||||
// if module was not require()d and no name given, throw error
|
||||
function moduleName (obj) {
|
||||
const mod = require('which-module')(obj)
|
||||
if (!mod) throw new Error(`No command name given for module: ${inspect(obj)}`)
|
||||
return commandFromFilename(mod.filename)
|
||||
}
|
||||
|
||||
// derive command name from filename
|
||||
function commandFromFilename (filename) {
|
||||
return path.basename(filename, path.extname(filename))
|
||||
}
|
||||
|
||||
function extractDesc (obj) {
|
||||
for (let keys = ['describe', 'description', 'desc'], i = 0, l = keys.length, test; i < l; i++) {
|
||||
test = obj[keys[i]]
|
||||
if (typeof test === 'string' || typeof test === 'boolean') return test
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
self.parseCommand = function parseCommand (cmd) {
|
||||
const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' ')
|
||||
const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/)
|
||||
const bregex = /\.*[\][<>]/g
|
||||
const parsedCommand = {
|
||||
cmd: (splitCommand.shift()).replace(bregex, ''),
|
||||
demanded: [],
|
||||
optional: []
|
||||
}
|
||||
splitCommand.forEach((cmd, i) => {
|
||||
let variadic = false
|
||||
cmd = cmd.replace(/\s/g, '')
|
||||
if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true
|
||||
if (/^\[/.test(cmd)) {
|
||||
parsedCommand.optional.push({
|
||||
cmd: cmd.replace(bregex, '').split('|'),
|
||||
variadic
|
||||
})
|
||||
} else {
|
||||
parsedCommand.demanded.push({
|
||||
cmd: cmd.replace(bregex, '').split('|'),
|
||||
variadic
|
||||
})
|
||||
}
|
||||
})
|
||||
return parsedCommand
|
||||
}
|
||||
|
||||
self.getCommands = () => Object.keys(handlers).concat(Object.keys(aliasMap))
|
||||
|
||||
self.getCommandHandlers = () => handlers
|
||||
|
||||
self.hasDefaultCommand = () => !!defaultCommand
|
||||
|
||||
self.runCommand = function runCommand (command, yargs, parsed, commandIndex) {
|
||||
let aliases = parsed.aliases
|
||||
const commandHandler = handlers[command] || handlers[aliasMap[command]] || defaultCommand
|
||||
const currentContext = yargs.getContext()
|
||||
let numFiles = currentContext.files.length
|
||||
const parentCommands = currentContext.commands.slice()
|
||||
|
||||
// what does yargs look like after the buidler is run?
|
||||
let innerArgv = parsed.argv
|
||||
let innerYargs = null
|
||||
let positionalMap = {}
|
||||
if (command) {
|
||||
currentContext.commands.push(command)
|
||||
currentContext.fullCommands.push(commandHandler.original)
|
||||
}
|
||||
if (typeof commandHandler.builder === 'function') {
|
||||
// a function can be provided, which builds
|
||||
// up a yargs chain and possibly returns it.
|
||||
innerYargs = commandHandler.builder(yargs.reset(parsed.aliases))
|
||||
// if the builder function did not yet parse argv with reset yargs
|
||||
// and did not explicitly set a usage() string, then apply the
|
||||
// original command string as usage() for consistent behavior with
|
||||
// options object below.
|
||||
if (yargs.parsed === false) {
|
||||
if (shouldUpdateUsage(yargs)) {
|
||||
yargs.getUsageInstance().usage(
|
||||
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
|
||||
commandHandler.description
|
||||
)
|
||||
}
|
||||
innerArgv = innerYargs ? innerYargs._parseArgs(null, null, true, commandIndex) : yargs._parseArgs(null, null, true, commandIndex)
|
||||
} else {
|
||||
innerArgv = yargs.parsed.argv
|
||||
}
|
||||
|
||||
if (innerYargs && yargs.parsed === false) aliases = innerYargs.parsed.aliases
|
||||
else aliases = yargs.parsed.aliases
|
||||
} else if (typeof commandHandler.builder === 'object') {
|
||||
// as a short hand, an object can instead be provided, specifying
|
||||
// the options that a command takes.
|
||||
innerYargs = yargs.reset(parsed.aliases)
|
||||
if (shouldUpdateUsage(innerYargs)) {
|
||||
innerYargs.getUsageInstance().usage(
|
||||
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
|
||||
commandHandler.description
|
||||
)
|
||||
}
|
||||
Object.keys(commandHandler.builder).forEach((key) => {
|
||||
innerYargs.option(key, commandHandler.builder[key])
|
||||
})
|
||||
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex)
|
||||
aliases = innerYargs.parsed.aliases
|
||||
}
|
||||
|
||||
if (!yargs._hasOutput()) {
|
||||
positionalMap = populatePositionals(commandHandler, innerArgv, currentContext, yargs)
|
||||
}
|
||||
|
||||
const middlewares = globalMiddleware.slice(0).concat(commandHandler.middlewares || [])
|
||||
applyMiddleware(innerArgv, yargs, middlewares, true)
|
||||
|
||||
// we apply validation post-hoc, so that custom
|
||||
// checks get passed populated positional arguments.
|
||||
if (!yargs._hasOutput()) yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error)
|
||||
|
||||
if (commandHandler.handler && !yargs._hasOutput()) {
|
||||
yargs._setHasOutput()
|
||||
|
||||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false)
|
||||
|
||||
const handlerResult = isPromise(innerArgv)
|
||||
? innerArgv.then(argv => commandHandler.handler(argv))
|
||||
: commandHandler.handler(innerArgv)
|
||||
|
||||
if (isPromise(handlerResult)) {
|
||||
handlerResult.catch(error =>
|
||||
yargs.getUsageInstance().fail(null, error)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (command) {
|
||||
currentContext.commands.pop()
|
||||
currentContext.fullCommands.pop()
|
||||
}
|
||||
numFiles = currentContext.files.length - numFiles
|
||||
if (numFiles > 0) currentContext.files.splice(numFiles * -1, numFiles)
|
||||
|
||||
return innerArgv
|
||||
}
|
||||
|
||||
function shouldUpdateUsage (yargs) {
|
||||
return !yargs.getUsageInstance().getUsageDisabled() &&
|
||||
yargs.getUsageInstance().getUsage().length === 0
|
||||
}
|
||||
|
||||
function usageFromParentCommandsCommandHandler (parentCommands, commandHandler) {
|
||||
const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, '').trim() : commandHandler.original
|
||||
const pc = parentCommands.filter((c) => { return !DEFAULT_MARKER.test(c) })
|
||||
pc.push(c)
|
||||
return `$0 ${pc.join(' ')}`
|
||||
}
|
||||
|
||||
self.runDefaultBuilderOn = function (yargs) {
|
||||
if (shouldUpdateUsage(yargs)) {
|
||||
// build the root-level command string from the default string.
|
||||
const commandString = DEFAULT_MARKER.test(defaultCommand.original)
|
||||
? defaultCommand.original : defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ')
|
||||
yargs.getUsageInstance().usage(
|
||||
commandString,
|
||||
defaultCommand.description
|
||||
)
|
||||
}
|
||||
const builder = defaultCommand.builder
|
||||
if (typeof builder === 'function') {
|
||||
builder(yargs)
|
||||
} else {
|
||||
Object.keys(builder).forEach((key) => {
|
||||
yargs.option(key, builder[key])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// transcribe all positional arguments "command <foo> <bar> [apple]"
|
||||
// onto argv.
|
||||
function populatePositionals (commandHandler, argv, context, yargs) {
|
||||
argv._ = argv._.slice(context.commands.length) // nuke the current commands
|
||||
const demanded = commandHandler.demanded.slice(0)
|
||||
const optional = commandHandler.optional.slice(0)
|
||||
const positionalMap = {}
|
||||
|
||||
validation.positionalCount(demanded.length, argv._.length)
|
||||
|
||||
while (demanded.length) {
|
||||
const demand = demanded.shift()
|
||||
populatePositional(demand, argv, positionalMap)
|
||||
}
|
||||
|
||||
while (optional.length) {
|
||||
const maybe = optional.shift()
|
||||
populatePositional(maybe, argv, positionalMap)
|
||||
}
|
||||
|
||||
argv._ = context.commands.concat(argv._)
|
||||
|
||||
postProcessPositionals(argv, positionalMap, self.cmdToParseOptions(commandHandler.original))
|
||||
|
||||
return positionalMap
|
||||
}
|
||||
|
||||
function populatePositional (positional, argv, positionalMap, parseOptions) {
|
||||
const cmd = positional.cmd[0]
|
||||
if (positional.variadic) {
|
||||
positionalMap[cmd] = argv._.splice(0).map(String)
|
||||
} else {
|
||||
if (argv._.length) positionalMap[cmd] = [String(argv._.shift())]
|
||||
}
|
||||
}
|
||||
|
||||
// we run yargs-parser against the positional arguments
|
||||
// applying the same parsing logic used for flags.
|
||||
function postProcessPositionals (argv, positionalMap, parseOptions) {
|
||||
// combine the parsing hints we've inferred from the command
|
||||
// string with explicitly configured parsing hints.
|
||||
const options = Object.assign({}, yargs.getOptions())
|
||||
options.default = Object.assign(parseOptions.default, options.default)
|
||||
options.alias = Object.assign(parseOptions.alias, options.alias)
|
||||
options.array = options.array.concat(parseOptions.array)
|
||||
delete options.config // don't load config when processing positionals.
|
||||
|
||||
const unparsed = []
|
||||
Object.keys(positionalMap).forEach((key) => {
|
||||
positionalMap[key].map((value) => {
|
||||
unparsed.push(`--${key}`)
|
||||
unparsed.push(value)
|
||||
})
|
||||
})
|
||||
|
||||
// short-circuit parse.
|
||||
if (!unparsed.length) return
|
||||
|
||||
const parsed = Parser.detailed(unparsed, options)
|
||||
|
||||
if (parsed.error) {
|
||||
yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
|
||||
} else {
|
||||
// only copy over positional keys (don't overwrite
|
||||
// flag arguments that were already parsed).
|
||||
const positionalKeys = Object.keys(positionalMap)
|
||||
Object.keys(positionalMap).forEach((key) => {
|
||||
[].push.apply(positionalKeys, parsed.aliases[key])
|
||||
})
|
||||
|
||||
Object.keys(parsed.argv).forEach((key) => {
|
||||
if (positionalKeys.indexOf(key) !== -1) {
|
||||
// any new aliases need to be placed in positionalMap, which
|
||||
// is used for validation.
|
||||
if (!positionalMap[key]) positionalMap[key] = parsed.argv[key]
|
||||
argv[key] = parsed.argv[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
self.cmdToParseOptions = function (cmdString) {
|
||||
const parseOptions = {
|
||||
array: [],
|
||||
default: {},
|
||||
alias: {},
|
||||
demand: {}
|
||||
}
|
||||
|
||||
const parsed = self.parseCommand(cmdString)
|
||||
parsed.demanded.forEach((d) => {
|
||||
const cmds = d.cmd.slice(0)
|
||||
const cmd = cmds.shift()
|
||||
if (d.variadic) {
|
||||
parseOptions.array.push(cmd)
|
||||
parseOptions.default[cmd] = []
|
||||
}
|
||||
cmds.forEach((c) => {
|
||||
parseOptions.alias[cmd] = c
|
||||
})
|
||||
parseOptions.demand[cmd] = true
|
||||
})
|
||||
|
||||
parsed.optional.forEach((o) => {
|
||||
const cmds = o.cmd.slice(0)
|
||||
const cmd = cmds.shift()
|
||||
if (o.variadic) {
|
||||
parseOptions.array.push(cmd)
|
||||
parseOptions.default[cmd] = []
|
||||
}
|
||||
cmds.forEach((c) => {
|
||||
parseOptions.alias[cmd] = c
|
||||
})
|
||||
})
|
||||
|
||||
return parseOptions
|
||||
}
|
||||
|
||||
self.reset = () => {
|
||||
handlers = {}
|
||||
aliasMap = {}
|
||||
defaultCommand = undefined
|
||||
return self
|
||||
}
|
||||
|
||||
// used by yargs.parse() to freeze
|
||||
// the state of commands such that
|
||||
// we can apply .parse() multiple times
|
||||
// with the same yargs instance.
|
||||
let frozen
|
||||
self.freeze = () => {
|
||||
frozen = {}
|
||||
frozen.handlers = handlers
|
||||
frozen.aliasMap = aliasMap
|
||||
frozen.defaultCommand = defaultCommand
|
||||
}
|
||||
self.unfreeze = () => {
|
||||
handlers = frozen.handlers
|
||||
aliasMap = frozen.aliasMap
|
||||
defaultCommand = frozen.defaultCommand
|
||||
frozen = undefined
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
49
node_modules/webpack-cli/node_modules/yargs/lib/completion-templates.js
generated
vendored
Normal file
49
node_modules/webpack-cli/node_modules/yargs/lib/completion-templates.js
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
exports.completionShTemplate =
|
||||
`###-begin-{{app_name}}-completions-###
|
||||
#
|
||||
# yargs command completion script
|
||||
#
|
||||
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
||||
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
||||
#
|
||||
_yargs_completions()
|
||||
{
|
||||
local cur_word args type_list
|
||||
|
||||
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
||||
args=("\${COMP_WORDS[@]}")
|
||||
|
||||
# ask yargs to generate completions.
|
||||
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
||||
|
||||
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
||||
|
||||
# if no match was found, fall back to filename completion
|
||||
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
||||
COMPREPLY=()
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -o default -F _yargs_completions {{app_name}}
|
||||
###-end-{{app_name}}-completions-###
|
||||
`
|
||||
|
||||
exports.completionZshTemplate = `###-begin-{{app_name}}-completions-###
|
||||
#
|
||||
# yargs command completion script
|
||||
#
|
||||
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
||||
# or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
|
||||
#
|
||||
_{{app_name}}_yargs_completions()
|
||||
{
|
||||
local reply
|
||||
local si=$IFS
|
||||
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
||||
IFS=$si
|
||||
_describe 'values' reply
|
||||
}
|
||||
compdef _{{app_name}}_yargs_completions {{app_name}}
|
||||
###-end-{{app_name}}-completions-###
|
||||
`
|
||||
115
node_modules/webpack-cli/node_modules/yargs/lib/completion.js
generated
vendored
Normal file
115
node_modules/webpack-cli/node_modules/yargs/lib/completion.js
generated
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
// add bash completions to your
|
||||
// yargs-powered applications.
|
||||
module.exports = function completion (yargs, usage, command) {
|
||||
const self = {
|
||||
completionKey: 'get-yargs-completions'
|
||||
}
|
||||
|
||||
const zshShell = process.env.SHELL && process.env.SHELL.indexOf('zsh') !== -1
|
||||
// get a list of completion commands.
|
||||
// 'args' is the array of strings from the line to be completed
|
||||
self.getCompletion = function getCompletion (args, done) {
|
||||
const completions = []
|
||||
const current = args.length ? args[args.length - 1] : ''
|
||||
const argv = yargs.parse(args, true)
|
||||
const aliases = yargs.parsed.aliases
|
||||
const parentCommands = yargs.getContext().commands
|
||||
|
||||
// a custom completion function can be provided
|
||||
// to completion().
|
||||
if (completionFunction) {
|
||||
if (completionFunction.length < 3) {
|
||||
const result = completionFunction(current, argv)
|
||||
|
||||
// promise based completion function.
|
||||
if (typeof result.then === 'function') {
|
||||
return result.then((list) => {
|
||||
process.nextTick(() => { done(list) })
|
||||
}).catch((err) => {
|
||||
process.nextTick(() => { throw err })
|
||||
})
|
||||
}
|
||||
|
||||
// synchronous completion function.
|
||||
return done(result)
|
||||
} else {
|
||||
// asynchronous completion function
|
||||
return completionFunction(current, argv, (completions) => {
|
||||
done(completions)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handlers = command.getCommandHandlers()
|
||||
for (let i = 0, ii = args.length; i < ii; ++i) {
|
||||
if (handlers[args[i]] && handlers[args[i]].builder) {
|
||||
const builder = handlers[args[i]].builder
|
||||
if (typeof builder === 'function') {
|
||||
const y = yargs.reset()
|
||||
builder(y)
|
||||
return y.argv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current) {
|
||||
usage.getCommands().forEach((usageCommand) => {
|
||||
const commandName = command.parseCommand(usageCommand[0]).cmd
|
||||
if (args.indexOf(commandName) === -1) {
|
||||
if (!zshShell) {
|
||||
completions.push(commandName)
|
||||
} else {
|
||||
const desc = usageCommand[1] || ''
|
||||
completions.push(commandName.replace(/:/g, '\\:') + ':' + desc)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (current.match(/^-/) || (current === '' && completions.length === 0)) {
|
||||
const descs = usage.getDescriptions()
|
||||
Object.keys(yargs.getOptions().key).forEach((key) => {
|
||||
// If the key and its aliases aren't in 'args', add the key to 'completions'
|
||||
const keyAndAliases = [key].concat(aliases[key] || [])
|
||||
const notInArgs = keyAndAliases.every(val => args.indexOf(`--${val}`) === -1)
|
||||
if (notInArgs) {
|
||||
if (!zshShell) {
|
||||
completions.push(`--${key}`)
|
||||
} else {
|
||||
const desc = descs[key] || ''
|
||||
completions.push(`--${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
done(completions)
|
||||
}
|
||||
|
||||
// generate the completion script to add to your .bashrc.
|
||||
self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
|
||||
const templates = require('./completion-templates')
|
||||
let script = zshShell ? templates.completionZshTemplate : templates.completionShTemplate
|
||||
const name = path.basename($0)
|
||||
|
||||
// add ./to applications not yet installed as bin.
|
||||
if ($0.match(/\.js$/)) $0 = `./${$0}`
|
||||
|
||||
script = script.replace(/{{app_name}}/g, name)
|
||||
script = script.replace(/{{completion_command}}/g, cmd)
|
||||
return script.replace(/{{app_path}}/g, $0)
|
||||
}
|
||||
|
||||
// register a function to perform your own custom
|
||||
// completions., this function can be either
|
||||
// synchrnous or asynchronous.
|
||||
let completionFunction = null
|
||||
self.registerFunction = (fn) => {
|
||||
completionFunction = fn
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
32
node_modules/webpack-cli/node_modules/yargs/lib/decamelize.js
generated
vendored
Normal file
32
node_modules/webpack-cli/node_modules/yargs/lib/decamelize.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
module.exports = (text, separator) => {
|
||||
separator = typeof separator === 'undefined' ? '_' : separator
|
||||
|
||||
return text
|
||||
.replace(/([a-z\d])([A-Z])/g, `$1${separator}$2`)
|
||||
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, `$1${separator}$2`)
|
||||
.toLowerCase()
|
||||
}
|
||||
3
node_modules/webpack-cli/node_modules/yargs/lib/is-promise.js
generated
vendored
Normal file
3
node_modules/webpack-cli/node_modules/yargs/lib/is-promise.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function isPromise (maybePromise) {
|
||||
return maybePromise instanceof Promise
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue