From 2c1772578b203e9f2b5956ddfd28dd0b03461269 Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Tue, 27 Jan 2026 15:24:18 -0500 Subject: [PATCH] chore: merge CLI into single package --- .cspell.json | 11 +- packages/README.md | 7 +- packages/configtest/CHANGELOG.md | 79 - packages/configtest/README.md | 31 - packages/configtest/package.json | 26 - packages/configtest/src/index.ts | 63 - packages/configtest/tsconfig.json | 13 - packages/info/CHANGELOG.md | 127 -- packages/info/README.md | 54 - packages/info/package.json | 27 - packages/info/src/index.ts | 23 - packages/info/tsconfig.json | 13 - packages/serve/CHANGELOG.md | 198 --- packages/serve/README.md | 32 - packages/serve/package.json | 34 - packages/serve/src/index.ts | 250 --- packages/serve/tsconfig.json | 13 - packages/webpack-cli/package.json | 3 - packages/webpack-cli/src/bootstrap.ts | 7 +- packages/webpack-cli/src/types.ts | 80 +- packages/webpack-cli/src/webpack-cli.ts | 1388 +++++---------- test/api/CLI.test.js | 908 ++++------ .../__snapshots__/CLI.test.js.snap.webpack5 | 31 - test/build/basic/basic.test.js | 4 +- .../unknown.test.js.snap.webpack5 | 22 +- .../help.test.js.snap.devServer5.webpack5 | 1538 ----------------- test/help/help.test.js | 432 ----- test/version/additional-package.test.js | 95 - test/version/basic.test.js | 74 - test/version/output.test.js | 59 - tsconfig.json | 9 - 31 files changed, 852 insertions(+), 4799 deletions(-) delete mode 100644 packages/configtest/CHANGELOG.md delete mode 100644 packages/configtest/README.md delete mode 100644 packages/configtest/package.json delete mode 100644 packages/configtest/src/index.ts delete mode 100644 packages/configtest/tsconfig.json delete mode 100644 packages/info/CHANGELOG.md delete mode 100644 packages/info/README.md delete mode 100644 packages/info/package.json delete mode 100644 packages/info/src/index.ts delete mode 100644 packages/info/tsconfig.json delete mode 100644 packages/serve/CHANGELOG.md delete mode 100644 packages/serve/README.md delete mode 100644 packages/serve/package.json delete mode 100644 packages/serve/src/index.ts delete mode 100644 packages/serve/tsconfig.json delete mode 100644 test/api/__snapshots__/CLI.test.js.snap.webpack5 delete mode 100644 test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 delete mode 100644 test/help/help.test.js delete mode 100644 test/version/additional-package.test.js delete mode 100644 test/version/basic.test.js delete mode 100644 test/version/output.test.js diff --git a/.cspell.json b/.cspell.json index 1aa1b21e8a2..e8d0f6450a0 100644 --- a/.cspell.json +++ b/.cspell.json @@ -107,17 +107,12 @@ "watchpack" ], "dictionaries": ["npm", "software-terms"], + "useGitignore": true, "ignorePaths": [ "**/CHANGELOG.md", - "**/package.json", - "**/dist/**", "**/__snapshots__/**", - "**/*.tsbuildinfo", "**/*.png.tpl", - "**/package-lock.json", - "packages/*/lib/**", - "node_modules", - "coverage", - "*.log" + "**/package.json", + "**/package-lock.json" ] } diff --git a/packages/README.md b/packages/README.md index 58f4f39427e..d51d6cdbf24 100644 --- a/packages/README.md +++ b/packages/README.md @@ -13,11 +13,8 @@ This folder is the collection of those packages. ## Packages -1. [configtest](https://github.com/webpack/webpack-cli/tree/main/packages/configtest) -2. [create-webpack-app](https://github.com/webpack/webpack-cli/tree/main/packages/create-webpack-app) -3. [info](https://github.com/webpack/webpack-cli/tree/main/packages/info) -4. [serve](https://github.com/webpack/webpack-cli/tree/main/packages/serve) -5. [webpack-cli](https://github.com/webpack/webpack-cli/tree/main/packages/webpack-cli) +1. [create-webpack-app](https://github.com/webpack/webpack-cli/tree/main/packages/create-webpack-app) +2. [webpack-cli](https://github.com/webpack/webpack-cli/tree/main/packages/webpack-cli) ## Generic Installation diff --git a/packages/configtest/CHANGELOG.md b/packages/configtest/CHANGELOG.md deleted file mode 100644 index 69f02606722..00000000000 --- a/packages/configtest/CHANGELOG.md +++ /dev/null @@ -1,79 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [3.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@3.0.0...@webpack-cli/configtest@3.0.1) (2024-12-20) - -### Bug Fixes - -- update peer dependencies ([#4356](https://github.com/webpack/webpack-cli/issues/4356)) ([7a7e5d9](https://github.com/webpack/webpack-cli/commit/7a7e5d9f4bd796c7d1089db228b9581e97cc897e)) - -# [3.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.1.1...@webpack-cli/configtest@3.0.0) (2024-12-19) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [2.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.1.0...@webpack-cli/configtest@2.1.1) (2023-06-04) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [2.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.0.1...@webpack-cli/configtest@2.1.0) (2023-05-07) - -### Features - -- shareable webpack configs using `extends` ([#3738](https://github.com/webpack/webpack-cli/issues/3738)) ([d04d0b9](https://github.com/webpack/webpack-cli/commit/d04d0b98b69948966c8de5dacf771ac324ba5658)) - -## [2.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.0.0...@webpack-cli/configtest@2.0.1) (2022-12-05) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [2.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.2.0...@webpack-cli/configtest@2.0.0) (2022-11-17) - -### BREAKING CHANGES - -- the minimum supported webpack version is v5.0.0 (#3342) ([b1af0dc](https://github.com/webpack/webpack-cli/commit/b1af0dc7ebcdf746bc37889e4c1f978c65acc4a5)), closes [#3342](https://github.com/webpack/webpack-cli/issues/3342) -- webpack-cli no longer supports webpack v4, the minimum supported version is webpack v5.0.0 - -# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.1.1...@webpack-cli/configtest@1.2.0) (2022-06-13) - -### Features - -- added types ([8ec1375](https://github.com/webpack/webpack-cli/commit/8ec1375092a6f9676e82fa4231dd88b1016c2302)) - -## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.1.0...@webpack-cli/configtest@1.1.1) (2022-01-24) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.4...@webpack-cli/configtest@1.1.0) (2021-10-06) - -### Features - -- allow to run commands without webpack installation where it is unnecessary ([#2907](https://github.com/webpack/webpack-cli/issues/2907)) ([603041d](https://github.com/webpack/webpack-cli/commit/603041d7e6a9b764bd79d1a8effd22a3e0f019cb)) - -## [1.0.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.3...@webpack-cli/configtest@1.0.4) (2021-06-07) - -### Bug Fixes - -- prettier config ([#2719](https://github.com/webpack/webpack-cli/issues/2719)) ([181295f](https://github.com/webpack/webpack-cli/commit/181295fb1b1973c201c221813562219d85b845ae)) - -## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.2...@webpack-cli/configtest@1.0.3) (2021-05-06) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.1...@webpack-cli/configtest@1.0.2) (2021-03-27) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.0...@webpack-cli/configtest@1.0.1) (2021-02-02) - -### Bug Fixes - -- improve description for 'configtest' command ([#2379](https://github.com/webpack/webpack-cli/issues/2379)) ([311bae3](https://github.com/webpack/webpack-cli/commit/311bae336d83424c800e553b6ef40242d967685c)) - -# 1.0.0 (2021-01-19) - -### Features - -- `configtest` validate default configuration ([#2354](https://github.com/webpack/webpack-cli/issues/2354)) ([487691a](https://github.com/webpack/webpack-cli/commit/487691abc8d817f5b3c1ab87743d7235ff15d956)) -- added the `watch` command ([#2357](https://github.com/webpack/webpack-cli/issues/2357)) ([9693f7d](https://github.com/webpack/webpack-cli/commit/9693f7d9543a8fce610c4ef903ccca0d12d229a1)) -- new `configtest` command ([#2303](https://github.com/webpack/webpack-cli/issues/2303)) ([eb7b189](https://github.com/webpack/webpack-cli/commit/eb7b18937d045261a5b20ca8356e8b4ae4dfcaad)) diff --git a/packages/configtest/README.md b/packages/configtest/README.md deleted file mode 100644 index 947a82d8697..00000000000 --- a/packages/configtest/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# webpack-cli configtest - -[![NPM Downloads][downloads]][downloads-url] - -> **Note** -> -> This package is used by webpack-cli under-the-hood and is not intended for installation - -## Description - -This package validates a webpack configuration. - -## Installation - -```bash -# npm -npm i -D @webpack-cli/configtest - -# yarn -yarn add -D @webpack-cli/configtest - -``` - -## Usage - -```bash -npx webpack configtest [config-path] -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/configtest.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/configtest diff --git a/packages/configtest/package.json b/packages/configtest/package.json deleted file mode 100644 index 7a12e7a558a..00000000000 --- a/packages/configtest/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@webpack-cli/configtest", - "version": "3.0.1", - "description": "Validate a webpack configuration.", - "homepage": "https://github.com/webpack/webpack-cli/tree/main/packages/configtest", - "repository": { - "type": "git", - "url": "https://github.com/webpack/webpack-cli.git" - }, - "license": "MIT", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "files": [ - "lib" - ], - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - }, - "engines": { - "node": ">=18.12.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts deleted file mode 100644 index 67002e7205f..00000000000 --- a/packages/configtest/src/index.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { type IWebpackCLI } from "webpack-cli"; - -const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack"; - -class ConfigTestCommand { - async apply(cli: IWebpackCLI): Promise { - await cli.makeCommand( - { - name: "configtest [config-path]", - alias: "t", - description: "Validate a webpack configuration.", - pkg: "@webpack-cli/configtest", - dependencies: [WEBPACK_PACKAGE], - }, - [], - async (configPath: string | undefined): Promise => { - cli.webpack = await cli.loadWebpack(); - - const config = await cli.loadConfig(configPath ? { config: [configPath] } : {}); - const configPaths = new Set(); - - if (Array.isArray(config.options)) { - for (const options of config.options) { - const loadedConfigPaths = config.path.get(options); - - if (loadedConfigPaths) { - for (const path of loadedConfigPaths) configPaths.add(path); - } - } - } else if (config.path.get(config.options)) { - const loadedConfigPaths = config.path.get(config.options); - - if (loadedConfigPaths) { - for (const path of loadedConfigPaths) configPaths.add(path); - } - } - - if (configPaths.size === 0) { - cli.logger.error("No configuration found."); - process.exit(2); - } - - cli.logger.info(`Validate '${[...configPaths].join(" ,")}'.`); - - try { - cli.webpack.validate(config.options); - } catch (error) { - if (cli.isValidationError(error as Error)) { - cli.logger.error((error as Error).message); - } else { - cli.logger.error(error); - } - - process.exit(2); - } - - cli.logger.success("There are no validation errors in the given webpack configuration."); - }, - ); - } -} - -export default ConfigTestCommand; diff --git a/packages/configtest/tsconfig.json b/packages/configtest/tsconfig.json deleted file mode 100644 index 1c6d02ef88c..00000000000 --- a/packages/configtest/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [ - { - "path": "../webpack-cli" - } - ] -} diff --git a/packages/info/CHANGELOG.md b/packages/info/CHANGELOG.md deleted file mode 100644 index e02c7b40c27..00000000000 --- a/packages/info/CHANGELOG.md +++ /dev/null @@ -1,127 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [3.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@3.0.0...@webpack-cli/info@3.0.1) (2024-12-20) - -### Bug Fixes - -- update peer dependencies ([#4356](https://github.com/webpack/webpack-cli/issues/4356)) ([7a7e5d9](https://github.com/webpack/webpack-cli/commit/7a7e5d9f4bd796c7d1089db228b9581e97cc897e)) - -# [3.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@2.0.2...@webpack-cli/info@3.0.0) (2024-12-19) - -**Note:** Version bump only for package @webpack-cli/info - -## [2.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@2.0.1...@webpack-cli/info@2.0.2) (2023-06-04) - -**Note:** Version bump only for package @webpack-cli/info - -## [2.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@2.0.0...@webpack-cli/info@2.0.1) (2022-12-05) - -**Note:** Version bump only for package @webpack-cli/info - -# [2.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.5.0...@webpack-cli/info@2.0.0) (2022-11-17) - -### Features - -- **info:** show information for webpack-cli packages by default ([#3362](https://github.com/webpack/webpack-cli/issues/3362)) ([a1161a8](https://github.com/webpack/webpack-cli/commit/a1161a83d1c8be942ebd2fc93c20e463db38f632)) - -### BREAKING CHANGES - -- the minimum supported webpack version is v5.0.0 (#3342) ([b1af0dc](https://github.com/webpack/webpack-cli/commit/b1af0dc7ebcdf746bc37889e4c1f978c65acc4a5)), closes [#3342](https://github.com/webpack/webpack-cli/issues/3342) -- webpack-cli no longer supports webpack v4, the minimum supported version is webpack v5.0.0 - -# [1.5.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.4.1...@webpack-cli/info@1.5.0) (2022-06-13) - -### Features - -- added types ([8ec1375](https://github.com/webpack/webpack-cli/commit/8ec1375092a6f9676e82fa4231dd88b1016c2302)) - -## [1.4.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.4.0...@webpack-cli/info@1.4.1) (2022-01-24) - -**Note:** Version bump only for package @webpack-cli/info - -# [1.4.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.3.0...@webpack-cli/info@1.4.0) (2021-10-06) - -### Features - -- **info:** added the `--additional-package` option ([06cd267](https://github.com/webpack/webpack-cli/commit/06cd267663955f64b70685c604105d051ffd6beb)) -- allow to run commands without webpack installation where it is unnecessary ([#2907](https://github.com/webpack/webpack-cli/issues/2907)) ([603041d](https://github.com/webpack/webpack-cli/commit/603041d7e6a9b764bd79d1a8effd22a3e0f019cb)) - -# [1.3.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.4...@webpack-cli/info@1.3.0) (2021-06-07) - -### Bug Fixes - -- prettier config ([#2719](https://github.com/webpack/webpack-cli/issues/2719)) ([181295f](https://github.com/webpack/webpack-cli/commit/181295fb1b1973c201c221813562219d85b845ae)) - -### Features - -- **info:** add alias for --output ([#2709](https://github.com/webpack/webpack-cli/issues/2709)) ([3453053](https://github.com/webpack/webpack-cli/commit/34530530f99750a5efc382293127753f05fc8064)) - -## [1.2.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.3...@webpack-cli/info@1.2.4) (2021-05-06) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.2.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.2...@webpack-cli/info@1.2.3) (2021-03-27) - -### Bug Fixes - -- grammar in description of `--output` ([#2554](https://github.com/webpack/webpack-cli/issues/2554)) ([c6f781d](https://github.com/webpack/webpack-cli/commit/c6f781d741da3b07b25756c053427e5c358ad14f)) - -## [1.2.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.1...@webpack-cli/info@1.2.2) (2021-02-02) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.2.0...@webpack-cli/info@1.2.1) (2020-12-31) - -### Bug Fixes - -- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) - -# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.1.0...@webpack-cli/info@1.2.0) (2020-12-25) - -### Features - -- display monorepos in info output ([#2203](https://github.com/webpack/webpack-cli/issues/2203)) ([d0acf30](https://github.com/webpack/webpack-cli/commit/d0acf3072edd8182c95e37997ac91789da899d66)) - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.2...@webpack-cli/info@1.1.0) (2020-11-04) - -### Bug Fixes - -- **info:** throw error and exit for invalid --output value ([#2020](https://github.com/webpack/webpack-cli/issues/2020)) ([a994d4b](https://github.com/webpack/webpack-cli/commit/a994d4b52a99b3b77d25aac88f741e036a1c44ec)) - -### Features - -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1...@webpack-cli/info@1.0.2) (2020-10-19) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1-rc.1...@webpack-cli/info@1.0.1) (2020-10-10) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1-alpha.4...@webpack-cli/info@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- **info:** throw an error if help or version is passed as an arg ([#1737](https://github.com/webpack/webpack-cli/issues/1737)) ([c8ca878](https://github.com/webpack/webpack-cli/commit/c8ca87858b81e0c23e161d227558d2f0aeac003a)) -- **packages:** make packages have correct main paths to index ([#1366](https://github.com/webpack/webpack-cli/issues/1366)) ([5dd7bd6](https://github.com/webpack/webpack-cli/commit/5dd7bd62046568481996e48328b15a335557f8ae)) - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/info@1.0.1-alpha.3...@webpack-cli/info@1.0.1-alpha.4) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/info@1.0.1-alpha.2...@webpack-cli/info@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1-alpha.1...@webpack-cli/info@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/info - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/info@1.0.1-alpha.0...@webpack-cli/info@1.0.1-alpha.1) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/info diff --git a/packages/info/README.md b/packages/info/README.md deleted file mode 100644 index 44a310e7725..00000000000 --- a/packages/info/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# webpack-cli info - -[![NPM Downloads][downloads]][downloads-url] - -> **Note** -> -> This package is used by webpack-cli under-the-hood and is not intended for installation - -## Description - -This package returns a set of information related to the local environment. - -## Installation - -```bash -# npm -npm i -D @webpack-cli/info - -# yarn -yarn add -D @webpack-cli/info - -``` - -## Usage - -```bash -# npx -npx webpack info [options] - -# global installation -webpack info [options] - -``` - -### Args / Flags - -#### Output format - -| Flag | Description | Type | -| ------------------------------------- | --------------------------------------- | ------ | -| `-o, --output < json or markdown >` | To get the output in a specified format | string | -| `-a, --additional-package ` | Adds additional packages to the output | string | - -_Not supported for config_ - -#### Options - -| Flag | Description | Type | -| ----------- | ------------------------------------------ | ------- | -| `--help` | Show help | boolean | -| `--version` | Show version number of `@webpack-cli/info` | boolean | - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/info.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/info diff --git a/packages/info/package.json b/packages/info/package.json deleted file mode 100644 index 385271f60da..00000000000 --- a/packages/info/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@webpack-cli/info", - "version": "3.0.1", - "description": "Outputs info about system and webpack config", - "homepage": "https://github.com/webpack/webpack-cli/tree/main/packages/info", - "repository": { - "type": "git", - "url": "https://github.com/webpack/webpack-cli.git" - }, - "license": "MIT", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "files": [ - "lib" - ], - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - }, - "engines": { - "node": ">=18.12.0" - }, - "publishConfig": { - "access": "public" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/info/src/index.ts b/packages/info/src/index.ts deleted file mode 100644 index cb9c09509ec..00000000000 --- a/packages/info/src/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { type IWebpackCLI } from "webpack-cli"; - -class InfoCommand { - async apply(cli: IWebpackCLI): Promise { - await cli.makeCommand( - { - name: "info", - alias: "i", - description: "Outputs information about your system.", - usage: "[options]", - pkg: "@webpack-cli/info", - }, - cli.getInfoOptions(), - async (options: { output: string; additionalPackage: string[] }) => { - const info = await cli.getInfoOutput(options); - - cli.logger.raw(info); - }, - ); - } -} - -export default InfoCommand; diff --git a/packages/info/tsconfig.json b/packages/info/tsconfig.json deleted file mode 100644 index 1c6d02ef88c..00000000000 --- a/packages/info/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [ - { - "path": "../webpack-cli" - } - ] -} diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md deleted file mode 100644 index f9ca9461902..00000000000 --- a/packages/serve/CHANGELOG.md +++ /dev/null @@ -1,198 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [3.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@3.0.0...@webpack-cli/serve@3.0.1) (2024-12-20) - -### Bug Fixes - -- update peer dependencies ([#4356](https://github.com/webpack/webpack-cli/issues/4356)) ([7a7e5d9](https://github.com/webpack/webpack-cli/commit/7a7e5d9f4bd796c7d1089db228b9581e97cc897e)) - -# [3.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.5...@webpack-cli/serve@3.0.0) (2024-12-19) - -### Bug Fixes - -- no serve when dev-server is false ([#2947](https://github.com/webpack/webpack-cli/issues/2947)) ([a93e860](https://github.com/webpack/webpack-cli/commit/a93e8603a4c2639916152a013afed04c0e8f3a35)) - -## [2.0.5](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.4...@webpack-cli/serve@2.0.5) (2023-06-04) - -### Bug Fixes - -- improve help for some flags ([f468614](https://github.com/webpack/webpack-cli/commit/f4686141681cfcbc74d57e69a732e176decff225)) - -## [2.0.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.3...@webpack-cli/serve@2.0.4) (2023-05-09) - -### Bug Fixes - -- false positive warning when `--watch` used ([#3783](https://github.com/webpack/webpack-cli/issues/3783)) ([c0436ba](https://github.com/webpack/webpack-cli/commit/c0436baca2da7a8ce9e53bbbe960dd1951fe6404)) - -## [2.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.2...@webpack-cli/serve@2.0.3) (2023-05-07) - -### Performance Improvements - -- simplify logic, reduce extra loops and perf ([#3767](https://github.com/webpack/webpack-cli/issues/3767)) ([6afe1d3](https://github.com/webpack/webpack-cli/commit/6afe1d3be41e191aa7c4865919d092d952e98605)) - -## [2.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.1...@webpack-cli/serve@2.0.2) (2023-04-21) - -**Note:** Version bump only for package @webpack-cli/serve - -## [2.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.0...@webpack-cli/serve@2.0.1) (2022-12-05) - -**Note:** Version bump only for package @webpack-cli/serve - -# [2.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.7.0...@webpack-cli/serve@2.0.0) (2022-11-17) - -### BREAKING CHANGES - -- the minimum supported webpack version is v5.0.0 (#3342) ([b1af0dc](https://github.com/webpack/webpack-cli/commit/b1af0dc7ebcdf746bc37889e4c1f978c65acc4a5)), closes [#3342](https://github.com/webpack/webpack-cli/issues/3342) -- webpack-cli no longer supports webpack v4, the minimum supported version is webpack v5.0.0 -- webpack-cli no longer supports webpack-dev-server v3, the minimum supported version is webpack-dev-server v4.0.0 - -# [1.7.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.6.1...@webpack-cli/serve@1.7.0) (2022-06-13) - -### Features - -- added types ([8ec1375](https://github.com/webpack/webpack-cli/commit/8ec1375092a6f9676e82fa4231dd88b1016c2302)) - -## [1.6.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.6.0...@webpack-cli/serve@1.6.1) (2022-01-24) - -**Note:** Version bump only for package @webpack-cli/serve - -# [1.6.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.5.2...@webpack-cli/serve@1.6.0) (2021-10-06) - -### Bug Fixes - -- allow falsy values for `port` option ([#2962](https://github.com/webpack/webpack-cli/issues/2962)) ([da135dd](https://github.com/webpack/webpack-cli/commit/da135dd717e88b6aa9a0559c1e4e8acb4ee8f3c1)) - -### Features - -- allow to run commands without webpack installation where it is unnecessary ([#2907](https://github.com/webpack/webpack-cli/issues/2907)) ([603041d](https://github.com/webpack/webpack-cli/commit/603041d7e6a9b764bd79d1a8effd22a3e0f019cb)) - -## [1.5.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.5.1...@webpack-cli/serve@1.5.2) (2021-08-15) - -### Bug Fixes - -- ci for dev server next ([#2841](https://github.com/webpack/webpack-cli/issues/2841)) ([54d34b7](https://github.com/webpack/webpack-cli/commit/54d34b723cbeaf8cc13cff45398530be1db911e4)) -- respect dev server CLI options for multi compiler mode ([de48278](https://github.com/webpack/webpack-cli/commit/de482784a4f8cbb9eacbbe1c6b6f3c62ef60567a)) -- using new dev server API for v4 ([#2886](https://github.com/webpack/webpack-cli/issues/2886)) ([f66d01f](https://github.com/webpack/webpack-cli/commit/f66d01f0e382b0b3ffc753ac7549eb252e19e26c)) - -## [1.5.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.5.0...@webpack-cli/serve@1.5.1) (2021-06-07) - -### Bug Fixes - -- broken serve with new CLI API ([#2770](https://github.com/webpack/webpack-cli/issues/2770)) ([2d7ab35](https://github.com/webpack/webpack-cli/commit/2d7ab3549c429193b4ed5fbc6174153c847e0330)) - -# [1.5.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.4.0...@webpack-cli/serve@1.5.0) (2021-06-07) - -### Bug Fixes - -- prettier config ([#2719](https://github.com/webpack/webpack-cli/issues/2719)) ([181295f](https://github.com/webpack/webpack-cli/commit/181295fb1b1973c201c221813562219d85b845ae)) - -### Features - -- new CLI options API for serve ([#2754](https://github.com/webpack/webpack-cli/issues/2754)) ([bb7c9d3](https://github.com/webpack/webpack-cli/commit/bb7c9d3c9b0dca11242e2febcd41805c063e1317)) - -# [1.4.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.3.1...@webpack-cli/serve@1.4.0) (2021-05-06) - -### Bug Fixes - -- avoid unnecessary searching port ([#2648](https://github.com/webpack/webpack-cli/issues/2648)) ([5063ed7](https://github.com/webpack/webpack-cli/commit/5063ed7970cd12fd042308edfccca8dbf249f0fc)) -- **serve:** do not set port client port directly ([#2624](https://github.com/webpack/webpack-cli/issues/2624)) ([ec18b8e](https://github.com/webpack/webpack-cli/commit/ec18b8e478ff1a5f8d85bbddc599001dfd69eba3)) - -### Features - -- add `server` alias for `serve` command ([#2631](https://github.com/webpack/webpack-cli/issues/2631)) ([c9ee947](https://github.com/webpack/webpack-cli/commit/c9ee947618c06447bc1f949e4d401e63f737f38d)) - -## [1.3.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.3.0...@webpack-cli/serve@1.3.1) (2021-03-27) - -**Note:** Version bump only for package @webpack-cli/serve - -# [1.3.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.2...@webpack-cli/serve@1.3.0) (2021-02-02) - -### Bug Fixes - -- avoid deprecation message ([9d6dbda](https://github.com/webpack/webpack-cli/commit/9d6dbda93da167a1aaad03f599105a4fe7849dc3)) -- error message on invalid plugin options ([#2380](https://github.com/webpack/webpack-cli/issues/2380)) ([f9ce1d3](https://github.com/webpack/webpack-cli/commit/f9ce1d30b83bf0e0b4d91498d012c13c208e6e67)) - -### Features - -- entries syntax ([#2369](https://github.com/webpack/webpack-cli/issues/2369)) ([6b31614](https://github.com/webpack/webpack-cli/commit/6b3161479578f572f803f579c7e71073eb797184)) - -## [1.2.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.1...@webpack-cli/serve@1.2.2) (2021-01-19) - -### Bug Fixes - -- pass all `argv` to configurations when `serve` command used ([#2345](https://github.com/webpack/webpack-cli/issues/2345)) ([5070b9b](https://github.com/webpack/webpack-cli/commit/5070b9bcbd5bdac00088d0c21486ad181a4df000)) -- respect `--stats`, `--color` and `--no-color` option for serve c… ([#2312](https://github.com/webpack/webpack-cli/issues/2312)) ([73d3fec](https://github.com/webpack/webpack-cli/commit/73d3feced18b4e3708f958707326a6642a594cf2)) - -## [1.2.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.2.0...@webpack-cli/serve@1.2.1) (2020-12-31) - -### Bug Fixes - -- do not apply HotModuleReplacement plugin twice ([#2269](https://github.com/webpack/webpack-cli/issues/2269)) ([bb16d44](https://github.com/webpack/webpack-cli/commit/bb16d4481414a5f3c0cbeb18af690084b2ae4215)) -- respect the `output.publicPath` option for the `serve`command ([#2271](https://github.com/webpack/webpack-cli/issues/2271)) ([a3092ef](https://github.com/webpack/webpack-cli/commit/a3092ef2b51ece30221f7dd7b30a686626c1fd7a)) -- the `--help` option is working without `webpack-dev-server` ([#2267](https://github.com/webpack/webpack-cli/issues/2267)) ([1dae54d](https://github.com/webpack/webpack-cli/commit/1dae54da94d3220437b9257efe512447023de1d3)) -- the `--progress` option with the `serve` command ([#2265](https://github.com/webpack/webpack-cli/issues/2265)) ([952a188](https://github.com/webpack/webpack-cli/commit/952a1883b1a18c4fb38e8eb7bbbdb2aefc7942f4)) - -# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.1.0...@webpack-cli/serve@1.2.0) (2020-12-25) - -### Bug Fixes - -- respect `--watch-options-stdin` ([2d1e001](https://github.com/webpack/webpack-cli/commit/2d1e001e7f4f560c2b36607bd1b29dfe2aa32066)) -- do not default host in webpack-dev-server v4 ([#2141](https://github.com/webpack/webpack-cli/issues/2141)) ([dbbe4d4](https://github.com/webpack/webpack-cli/commit/dbbe4d4bc93ff9147ba43fae2d2352fa3583558d)) -- do not default port in webpack-dev-server v4 ([#2126](https://github.com/webpack/webpack-cli/issues/2126)) ([cda3047](https://github.com/webpack/webpack-cli/commit/cda30471f51db4631a0f54b852c553de270f7f64)) -- set client port when using default port ([#2147](https://github.com/webpack/webpack-cli/issues/2147)) ([4b97348](https://github.com/webpack/webpack-cli/commit/4b973488a42c4e12d86e0324a4c7051d1380a6fa)) -- catch dev server import during webpack serve ([#2070](https://github.com/webpack/webpack-cli/issues/2070)) ([70bf770](https://github.com/webpack/webpack-cli/commit/70bf7708c21dffe6521f1800b9dec2a62d21cfe2)) -- respect `--color`/`--no-color` options ([#2042](https://github.com/webpack/webpack-cli/issues/2042)) ([09bd812](https://github.com/webpack/webpack-cli/commit/09bd8126e95c9675b1f6862451f629cd4c439adb)) - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1...@webpack-cli/serve@1.1.0) (2020-11-04) - -### Bug Fixes - -- resolve dev server hot options correctly ([#2022](https://github.com/webpack/webpack-cli/issues/2022)) ([7c5a2ba](https://github.com/webpack/webpack-cli/commit/7c5a2bae49625ee4982d7478b7e741968731cea2)) - -### Features - -- add WEBPACK_SERVE environment variable ([#2027](https://github.com/webpack/webpack-cli/issues/2027)) ([ea369a9](https://github.com/webpack/webpack-cli/commit/ea369a98ea5ec366b688caebcb1276d9fbe0c651)) -- export utils from core for other packages ([#2011](https://github.com/webpack/webpack-cli/issues/2011)) ([3004549](https://github.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1-rc.1...@webpack-cli/serve@1.0.1) (2020-10-10) - -**Note:** Version bump only for package @webpack-cli/serve - -## [1.0.1-rc.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.5...@webpack-cli/serve@1.0.1-rc.1) (2020-10-06) - -### Bug Fixes - -- peer dependencies for `webpack serve` ([#1317](https://github.com/webpack/webpack-cli/issues/1317)) ([f8ec203](https://github.com/webpack/webpack-cli/commit/f8ec20382702450134032a65403894573b04be8d)) -- **packages:** make packages have correct main paths to index ([#1366](https://github.com/webpack/webpack-cli/issues/1366)) ([5dd7bd6](https://github.com/webpack/webpack-cli/commit/5dd7bd62046568481996e48328b15a335557f8ae)) -- **serve:** merge CLI and devServer options correctly ([#1649](https://github.com/webpack/webpack-cli/issues/1649)) ([2cdf5ce](https://github.com/webpack/webpack-cli/commit/2cdf5ce159f63ac65b33f4aca4c82fa1e959fef5)) -- **serve:** supplying help or version as an arg should throw error ([#1694](https://github.com/webpack/webpack-cli/issues/1694)) ([6eb7883](https://github.com/webpack/webpack-cli/commit/6eb78833f910135ca798c0c28f8d236ef234a76c)) - -### Features - -- allow multiple targets ([#1799](https://github.com/webpack/webpack-cli/issues/1799)) ([1724ddb](https://github.com/webpack/webpack-cli/commit/1724ddb9067d5c5ba2654d4e5473ee9de5610825)) -- serve integration ([#1712](https://github.com/webpack/webpack-cli/issues/1712)) ([d3e2936](https://github.com/webpack/webpack-cli/commit/d3e29368c40ee47e4f7a07c41281714645e20ea7)) - -## [1.0.1-alpha.5](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.4...@webpack-cli/serve@1.0.1-alpha.5) (2020-03-02) - -**Note:** Version bump only for package @webpack-cli/serve - -## [1.0.1-alpha.4](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.3...@webpack-cli/serve@1.0.1-alpha.4) (2020-02-29) - -**Note:** Version bump only for package @webpack-cli/serve - -## [1.0.1-alpha.3](https://github.com/ematipico/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.2...@webpack-cli/serve@1.0.1-alpha.3) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/serve - -## [1.0.1-alpha.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.1...@webpack-cli/serve@1.0.1-alpha.2) (2020-02-23) - -**Note:** Version bump only for package @webpack-cli/serve - -## [1.0.1-alpha.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@1.0.1-alpha.0...@webpack-cli/serve@1.0.1-alpha.1) (2020-02-23) - -### Bug Fixes - -- **init:** fix webpack config scaffold ([#1231](https://github.com/webpack/webpack-cli/issues/1231)) ([2dc495a](https://github.com/webpack/webpack-cli/commit/2dc495a8d050d28478c6c2533d7839e9ff78d76c)), closes [#1230](https://github.com/webpack/webpack-cli/issues/1230) diff --git a/packages/serve/README.md b/packages/serve/README.md deleted file mode 100644 index 6f1d4807e5f..00000000000 --- a/packages/serve/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# webpack-cli serve - -[![NPM Downloads][downloads]][downloads-url] - -> **Note** -> -> This package is used by webpack-cli under-the-hood and is not intended for installation - -## Description - -This package contains the logic to run [webpack-dev-server](https://github.com/webpack/webpack-dev-server) to serve your webpack app and provide live reloading. - -## Installation - -```bash -npm i -D webpack-cli @webpack-cli/serve -``` - -## Usage - -### CLI (via `webpack-cli`) - -```bash -npx webpack-cli serve -``` - -### Options - -Checkout [`SERVE-OPTIONS-v4.md`](https://github.com/webpack/webpack-cli/blob/main/SERVE-OPTIONS-v4.md) or [`SERVE-OPTIONS-v5.md`](https://github.com/webpack/webpack-cli/blob/main/SERVE-OPTIONS-v5.md) to see list of all available options for `serve` command for respective [`webpack-dev-server`](https://github.com/webpack/webpack-dev-server) version. - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/serve.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/serve diff --git a/packages/serve/package.json b/packages/serve/package.json deleted file mode 100644 index dcb2c407ad4..00000000000 --- a/packages/serve/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@webpack-cli/serve", - "version": "3.0.1", - "description": "", - "keywords": [], - "homepage": "https://github.com/webpack/webpack-cli/tree/main/packages/serve", - "repository": { - "type": "git", - "url": "https://github.com/webpack/webpack-cli.git" - }, - "license": "MIT", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "files": [ - "lib" - ], - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x", - "webpack-dev-server": "^5.0.0" - }, - "peerDependenciesMeta": { - "webpack-dev-server": { - "optional": true - } - }, - "engines": { - "node": ">=18.12.0" - }, - "publishConfig": { - "access": "public" - }, - "gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" -} diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts deleted file mode 100644 index 2639a892d65..00000000000 --- a/packages/serve/src/index.ts +++ /dev/null @@ -1,250 +0,0 @@ -import { type Compiler, type cli } from "webpack"; -import { type IWebpackCLI, type StringsKeys, type WebpackDevServerOptions } from "webpack-cli"; - -const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack"; -const WEBPACK_DEV_SERVER_PACKAGE = process.env.WEBPACK_DEV_SERVER_PACKAGE || "webpack-dev-server"; - -type Problem = NonNullable>[0]; - -class ServeCommand { - async apply(cli: IWebpackCLI): Promise { - const loadDevServerOptions = () => { - const devServer = require(WEBPACK_DEV_SERVER_PACKAGE); - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const options: Record = cli.webpack.cli.getArguments(devServer.schema); - // New options format - // { flag1: {}, flag2: {} } - return Object.keys(options).map((key) => { - options[key].name = key; - - return options[key]; - }); - }; - - await cli.makeCommand( - { - name: "serve [entries...]", - alias: ["server", "s"], - description: "Run the webpack dev server and watch for source file changes while serving.", - usage: "[entries...] [options]", - pkg: "@webpack-cli/serve", - dependencies: [WEBPACK_PACKAGE, WEBPACK_DEV_SERVER_PACKAGE], - }, - async () => { - let devServerFlags = []; - - cli.webpack = await cli.loadWebpack(); - - try { - devServerFlags = loadDevServerOptions(); - } catch (error) { - cli.logger.error( - `You need to install 'webpack-dev-server' for running 'webpack serve'.\n${error}`, - ); - process.exit(2); - } - - const builtInOptions = cli.getBuiltInOptions(); - - return [...builtInOptions, ...devServerFlags]; - }, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - async (entries: string[], options: any) => { - const builtInOptions = cli.getBuiltInOptions(); - let devServerFlags = []; - - try { - devServerFlags = loadDevServerOptions(); - } catch { - // Nothing, to prevent future updates - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const webpackCLIOptions: Record = {}; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const devServerCLIOptions: Record = {}; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const processors: ((opts: Record) => void)[] = []; - - for (const optionName in options) { - const kebabedOption = cli.toKebabCase(optionName); - const isBuiltInOption = builtInOptions.find( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (builtInOption: any) => builtInOption.name === kebabedOption, - ); - - if (isBuiltInOption) { - webpackCLIOptions[optionName] = options[optionName]; - } else { - const needToProcess = devServerFlags.find( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (devServerOption: any) => - devServerOption.name === kebabedOption && devServerOption.processor, - ); - - if (needToProcess) { - processors.push(needToProcess.processor); - } - - devServerCLIOptions[optionName] = options[optionName]; - } - } - - for (const processor of processors) { - processor(devServerCLIOptions); - } - - if (entries.length > 0) { - webpackCLIOptions.entry = [...entries, ...(webpackCLIOptions.entry || [])]; - } - - webpackCLIOptions.argv = { - ...options, - env: { WEBPACK_SERVE: true, ...options.env }, - }; - - webpackCLIOptions.isWatchingLikeCommand = true; - - const compiler = await cli.createCompiler(webpackCLIOptions); - - if (!compiler) { - return; - } - - const servers: (typeof DevServer)[] = []; - - if (cli.needWatchStdin(compiler)) { - process.stdin.on("end", () => { - Promise.all(servers.map((server) => server.stop())).then(() => { - process.exit(0); - }); - }); - process.stdin.resume(); - } - - const DevServer = require(WEBPACK_DEV_SERVER_PACKAGE); - - try { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions - require(`${WEBPACK_DEV_SERVER_PACKAGE}/package.json`).version; - } catch (err) { - cli.logger.error( - `You need to install 'webpack-dev-server' for running 'webpack serve'.\n${err}`, - ); - process.exit(2); - } - - const compilers = cli.isMultipleCompiler(compiler) ? compiler.compilers : [compiler]; - const possibleCompilers = compilers.filter( - (compiler: Compiler) => compiler.options.devServer, - ); - const compilersForDevServer = - possibleCompilers.length > 0 ? possibleCompilers : [compilers[0]]; - const usedPorts: number[] = []; - - for (const compilerForDevServer of compilersForDevServer) { - if (compilerForDevServer.options.devServer === false) { - continue; - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const args = devServerFlags.reduce((accumulator: Record, flag: any) => { - accumulator[flag.name] = flag; - - return accumulator; - }, {}); - const values = Object.keys(devServerCLIOptions).reduce( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (accumulator: Record, name: string) => { - const kebabName = cli.toKebabCase(name); - - if (args[kebabName]) { - accumulator[kebabName] = options[name]; - } - - return accumulator; - }, - {}, - ); - const result = { ...compilerForDevServer.options.devServer }; - const problems = cli.webpack.cli.processArguments(args, result, values); - - if (problems) { - const groupBy = >( - xs: Problem[], - key: K, - ) => - xs.reduce((rv: Record, problem: Problem) => { - const path = problem[key]; - - (rv[path] ||= []).push(problem); - - return rv; - }, {}); - - const problemsByPath = groupBy<"path">(problems, "path"); - - for (const path in problemsByPath) { - const problems = problemsByPath[path]; - - for (const problem of problems) { - cli.logger.error( - `${cli.capitalizeFirstLetter(problem.type.replace("-", " "))}${ - problem.value ? ` '${problem.value}'` : "" - } for the '--${problem.argument}' option${ - problem.index ? ` by index '${problem.index}'` : "" - }`, - ); - - if (problem.expected) { - cli.logger.error(`Expected: '${problem.expected}'`); - } - } - } - - process.exit(2); - } - - const devServerOptions: WebpackDevServerOptions = result as WebpackDevServerOptions; - - if (devServerOptions.port) { - const portNumber = Number(devServerOptions.port); - - if (usedPorts.includes(portNumber)) { - throw new Error( - "Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.", - ); - } - - usedPorts.push(portNumber); - } - - try { - const server = new DevServer(devServerOptions, compiler); - - await server.start(); - - servers.push(server); - } catch (error) { - if (cli.isValidationError(error as Error)) { - cli.logger.error((error as Error).message); - } else { - cli.logger.error(error); - } - - process.exit(2); - } - } - - if (servers.length === 0) { - cli.logger.error("No dev server configurations to run"); - process.exit(2); - } - }, - ); - } -} - -export default ServeCommand; diff --git a/packages/serve/tsconfig.json b/packages/serve/tsconfig.json deleted file mode 100644 index 1c6d02ef88c..00000000000 --- a/packages/serve/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [ - { - "path": "../webpack-cli" - } - ] -} diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index 985648902c9..81b214289da 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -32,9 +32,6 @@ ], "dependencies": { "@discoveryjs/json-ext": "^0.6.1", - "@webpack-cli/configtest": "^3.0.1", - "@webpack-cli/info": "^3.0.1", - "@webpack-cli/serve": "^3.0.1", "colorette": "^2.0.14", "commander": "^12.1.0", "cross-spawn": "^7.0.6", diff --git a/packages/webpack-cli/src/bootstrap.ts b/packages/webpack-cli/src/bootstrap.ts index e9a3ea3d322..5b6d986fe79 100644 --- a/packages/webpack-cli/src/bootstrap.ts +++ b/packages/webpack-cli/src/bootstrap.ts @@ -1,9 +1,8 @@ -import { type IWebpackCLI } from "./types.js"; import WebpackCLI from "./webpack-cli.js"; -const runCLI = async (args: Parameters[0]) => { +const runCLI = async (args?: Parameters[0]) => { // Create a new instance of the CLI object - const cli: IWebpackCLI = new WebpackCLI(); + const cli = new WebpackCLI(); try { await cli.run(args); @@ -17,3 +16,5 @@ export default runCLI; // TODO remove me in the next major release and use `default` export module.exports = runCLI; + +if (process.env.npm_lifecycle_script === "tsx") runCLI(); diff --git a/packages/webpack-cli/src/types.ts b/packages/webpack-cli/src/types.ts index 67acb7de486..4dba7732046 100644 --- a/packages/webpack-cli/src/types.ts +++ b/packages/webpack-cli/src/types.ts @@ -1,5 +1,5 @@ import { type stringifyChunked } from "@discoveryjs/json-ext"; -import { type Command, type CommandOptions, type Option, type ParseOptions } from "commander"; +import { type Command, type CommandOptions, type Option } from "commander"; import { type prepare } from "rechoir"; import { type AssetEmittedInfo, @@ -12,9 +12,7 @@ import { type MultiConfiguration, type MultiStats, type Stats, - type WebpackError, type WebpackOptionsNormalized, - default as webpack, } from "webpack"; import { @@ -31,55 +29,6 @@ declare interface WebpackCallback { (err: null | Error, result?: MultiStats): void; } -// TODO remove me in the next major release, we don't need extra interface -interface IWebpackCLI { - colors: WebpackCLIColors; - logger: WebpackCLILogger; - isColorSupportChanged: boolean | undefined; - webpack: typeof webpack; - builtInOptionsCache: WebpackCLIBuiltInOption[] | undefined; - program: WebpackCLICommand; - isMultipleCompiler(compiler: WebpackCompiler): compiler is MultiCompiler; - isPromise(value: Promise): value is Promise; - isFunction(value: unknown): value is CallableFunction; - getLogger(): WebpackCLILogger; - createColors(useColors?: boolean): WebpackCLIColors; - toKebabCase: StringFormatter; - capitalizeFirstLetter: StringFormatter; - checkPackageExists(packageName: string): boolean; - getAvailablePackageManagers(): PackageManager[]; - getDefaultPackageManager(): PackageManager | undefined; - doInstall(packageName: string, options?: PackageInstallOptions): Promise; - loadJSONFile(path: Path, handleError: boolean): Promise; - tryRequireThenImport(module: ModuleName, handleError: boolean): Promise; - getInfoOptions(): WebpackCLIBuiltInOption[]; - getInfoOutput(options: { output: string; additionalPackage: string[] }): Promise; - makeCommand( - commandOptions: WebpackCLIOptions, - options: WebpackCLICommandOptions, - action: CommandAction, - ): Promise; - makeOption(command: WebpackCLICommand, option: WebpackCLIBuiltInOption): void; - run( - args: Parameters[0], - parseOptions?: ParseOptions, - ): Promise; - getBuiltInOptions(): WebpackCLIBuiltInOption[]; - loadWebpack(handleError?: boolean): Promise; - loadConfig(options: Partial): Promise; - buildConfig( - config: WebpackCLIConfig, - options: WebpackDevServerOptions, - ): Promise; - isValidationError(error: Error): error is WebpackError; - createCompiler( - options: Partial, - callback?: WebpackCallback, - ): Promise; - needWatchStdin(compiler: Compiler | MultiCompiler): boolean; - runWebpack(options: WebpackRunOptions, isWatchCommand: boolean): Promise; -} - interface WebpackCLIColors extends Colors { isColorSupported: boolean; } @@ -118,18 +67,13 @@ type WebpackCLIMainOption = Pick< interface WebpackCLIOptions extends CommandOptions { name: string; - alias: string | string[]; - description?: string; - usage?: string; + alias: string[]; + description: string; dependencies?: string[]; - pkg?: string; - argsDescription?: Record; + options?: Option[]; + action: CommandAction; } -type WebpackCLICommandOptions = - | WebpackCLIBuiltInOption[] - | (() => Promise); - interface WebpackCLIBuiltInFlag { name: string; alias?: string; @@ -145,18 +89,13 @@ interface WebpackCLIBuiltInFlag { describe?: string; negatedDescription?: string; defaultValue?: string; - helpLevel: "minimum" | "verbose"; + hidden: boolean; } interface WebpackCLIBuiltInOption extends WebpackCLIBuiltInFlag { - hidden?: boolean; group?: "core"; } -type WebpackCLIExternalCommandInfo = Pick & { - pkg: string; -}; - /** * Webpack dev server */ @@ -254,8 +193,7 @@ type PotentialPromise = T | Promise; type ModuleName = string; type Path = string; // eslint-disable-next-line @typescript-eslint/no-explicit-any -type LogHandler = (value: any) => void; -type StringFormatter = (value: string) => string; +type LogHandler = (value: any, raw?: boolean) => void; // eslint-disable-next-line @typescript-eslint/no-explicit-any interface Argv extends Record { @@ -313,9 +251,7 @@ export { type CommandAction, type CommanderOption, type DynamicImport, - type EnumValue, type FileSystemCacheOptions, - type IWebpackCLI, type ImportLoaderError, type Instantiable, type JsonExt, @@ -335,9 +271,7 @@ export { type WebpackCLIColors, type WebpackCLICommand, type WebpackCLICommandOption, - type WebpackCLICommandOptions, type WebpackCLIConfig, - type WebpackCLIExternalCommandInfo, type WebpackCLILogger, type WebpackCLIMainOption, type WebpackCLIOptions, diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index ae26dff3317..f6aa9cdac28 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -1,5 +1,5 @@ import { type stringifyChunked } from "@discoveryjs/json-ext"; -import { type Help, type ParseOptions } from "commander"; +import { type ParseOptions } from "commander"; import { type Compiler, type Configuration, @@ -19,11 +19,8 @@ import { type BasicPrimitive, type CLIPluginOptions, type CallableWebpackConfiguration, - type CommandAction, type DynamicImport, - type EnumValue, type FileSystemCacheOptions, - type IWebpackCLI, type ImportLoaderError, type Instantiable, type JsonExt, @@ -44,9 +41,7 @@ import { type WebpackCLIColors, type WebpackCLICommand, type WebpackCLICommandOption, - type WebpackCLICommandOptions, type WebpackCLIConfig, - type WebpackCLIExternalCommandInfo, type WebpackCLILogger, type WebpackCLIMainOption, type WebpackCLIOptions, @@ -83,7 +78,7 @@ interface Information { npmPackages?: string | string[]; } -class WebpackCLI implements IWebpackCLI { +class WebpackCLI { colors: WebpackCLIColors; logger: WebpackCLILogger; @@ -104,13 +99,20 @@ class WebpackCLI implements IWebpackCLI { this.program = program; this.program.name("webpack"); this.program.configureOutput({ - writeErr: (str) => { - this.logger.error(str); - }, + writeErr: (str) => this.logger.error(str, true), outputError: (str, write) => { - write(`Error: ${this.capitalizeFirstLetter(str.replace(/^error:/, "").trim())}`); + write(`Error: ${this.capitalizeFirstLetter(str.replace(/^error:\s*/, ""))}`); }, }); + + // The CLI exits with code '2' instead of code '1' + this.program.exitOverride(({ exitCode }) => { + if (exitCode === 1) { + process.exit(2); + } + }); + + this.program.showHelpAfterError("Run 'webpack --help' to see available commands and options"); } isMultipleConfiguration( @@ -166,12 +168,17 @@ class WebpackCLI implements IWebpackCLI { } getLogger(): WebpackCLILogger { + const log = (method: "error" | "warn" | "info" | "log", val: string, raw?: boolean) => + raw + ? process[method === "error" ? "stderr" : "stdout"].write(`[webpack-cli] ${val}`) + : console[method](`[webpack-cli] ${val}`); + return { - error: (val) => console.error(`[webpack-cli] ${this.colors.red(util.format(val))}`), - warn: (val) => console.warn(`[webpack-cli] ${this.colors.yellow(val)}`), - info: (val) => console.info(`[webpack-cli] ${this.colors.cyan(val)}`), - success: (val) => console.log(`[webpack-cli] ${this.colors.green(val)}`), - log: (val) => console.log(`[webpack-cli] ${val}`), + error: (val, raw) => log("error", this.colors.red(util.format(val)), raw), + warn: (val, raw) => log("warn", this.colors.red(util.format(val)), raw), + info: (val, raw) => log("info", this.colors.red(util.format(val)), raw), + success: (val, raw) => log("log", this.colors.red(util.format(val)), raw), + log: (val, raw) => log("error", this.colors.red(util.format(val)), raw), raw: (val) => console.log(val), }; } @@ -478,7 +485,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "To get the output in a specified format ( accept json or markdown )", - helpLevel: "minimum", + hidden: true, }, { name: "additional-package", @@ -486,7 +493,7 @@ class WebpackCLI implements IWebpackCLI { configs: [{ type: "string" }], multiple: true, description: "Adds additional packages to the output", - helpLevel: "minimum", + hidden: true, }, ]; } @@ -531,7 +538,7 @@ class WebpackCLI implements IWebpackCLI { npmGlobalPackages: ["webpack", "webpack-cli", "webpack-dev-server"], }; - let defaultPackages: string[] = ["webpack", "loader", "@webpack-cli/"]; + let defaultPackages: string[] = ["webpack", "loader"]; if (typeof options.additionalPackage !== "undefined") { defaultPackages = [...defaultPackages, ...options.additionalPackage]; @@ -549,45 +556,27 @@ class WebpackCLI implements IWebpackCLI { return info; } - async makeCommand( - commandOptions: WebpackCLIOptions, - options: WebpackCLICommandOptions, - action: CommandAction, - ): Promise { - const alreadyLoaded = this.program.commands.find( - (command) => - command.name() === commandOptions.name.split(" ")[0] || - command.aliases().includes(commandOptions.alias as string), - ); - - if (alreadyLoaded) { - return; - } - + async makeCommand(commandOptions: WebpackCLIOptions): Promise { const command = this.program.command(commandOptions.name, { hidden: commandOptions.hidden, isDefault: commandOptions.isDefault, }) as WebpackCLICommand; - if (commandOptions.description) { - command.description(commandOptions.description, commandOptions.argsDescription!); - } + command.description(commandOptions.description); + command.aliases(commandOptions.alias); - if (commandOptions.usage) { - command.usage(commandOptions.usage); - } - - if (Array.isArray(commandOptions.alias)) { - command.aliases(commandOptions.alias); - } else { - command.alias(commandOptions.alias); + if (commandOptions.options) { + for (const option of commandOptions.options) { + command.addOption(option); + } } - command.pkg = commandOptions.pkg || "webpack-cli"; - - const { forHelp } = this.program; - - let allDependenciesInstalled = true; + command.configureHelp({ + visibleOptions(cmd) { + const showAll = cmd.args[command.args.indexOf("--help") + 1] === "verbose"; + return cmd.options.filter((opt) => !opt.hidden || showAll); + }, + }); if (commandOptions.dependencies && commandOptions.dependencies.length > 0) { for (const dependency of commandOptions.dependencies) { @@ -595,9 +584,6 @@ class WebpackCLI implements IWebpackCLI { if (isPkgExist) { continue; - } else if (!isPkgExist && forHelp) { - allDependenciesInstalled = false; - continue; } let skipInstallation = false; @@ -628,58 +614,34 @@ class WebpackCLI implements IWebpackCLI { } } - if (options) { - if (typeof options === "function") { - if (forHelp && !allDependenciesInstalled && commandOptions.dependencies) { - command.description( - `${ - commandOptions.description - } To see all available options you need to install ${commandOptions.dependencies - .map((dependency) => `'${dependency}'`) - .join(", ")}.`, - ); - options = []; - } else { - options = await options(); - } - } - - for (const option of options) { - this.makeOption(command, option); - } - } - - command.action(action); + command.action(commandOptions.action); return command; } - makeOption(command: WebpackCLICommand, option: WebpackCLIBuiltInOption) { - let mainOption: WebpackCLIMainOption; - let negativeOption; + makeOption(option: WebpackCLIBuiltInOption): WebpackCLICommandOption[] { + const options: WebpackCLICommandOption[] = []; const flagsWithAlias = ["devtool", "output-path", "target", "watch", "extends"]; if (flagsWithAlias.includes(option.name)) { [option.alias] = option.name; } - if (option.configs) { - let needNegativeOption = false; - let negatedDescription; - const mainOptionType: WebpackCLIMainOption["type"] = new Set(); + const mainOptionType: WebpackCLIMainOption["type"] = new Set(); + let needNegativeOption = false; + let negatedDescription: string | undefined; + // Determine option types and negative option needs + if (option.configs) { for (const config of option.configs) { switch (config.type) { case "reset": - mainOptionType.add(Boolean); - break; case "boolean": - if (!needNegativeOption) { + mainOptionType.add(Boolean); + if (!needNegativeOption && config.type === "boolean") { needNegativeOption = true; negatedDescription = config.negatedDescription; } - - mainOptionType.add(Boolean); break; case "number": mainOptionType.add(Number); @@ -691,188 +653,156 @@ class WebpackCLI implements IWebpackCLI { break; case "enum": { let hasFalseEnum = false; - for (const value of config.values || []) { - switch (typeof value) { - case "string": - mainOptionType.add(String); - break; - case "number": - mainOptionType.add(Number); - break; - case "boolean": - if (!hasFalseEnum && value === false) { - hasFalseEnum = true; - break; - } - + if (typeof value === "string") { + mainOptionType.add(String); + } else if (typeof value === "number") { + mainOptionType.add(Number); + } else if (typeof value === "boolean") { + if (value === false && !hasFalseEnum) { + hasFalseEnum = true; + } else { mainOptionType.add(Boolean); - break; + } } } - - if (!needNegativeOption) { - needNegativeOption = hasFalseEnum; + if (!needNegativeOption && hasFalseEnum) { + needNegativeOption = true; negatedDescription = config.negatedDescription; } + break; } } } - - mainOption = { - flags: option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`, - valueName: option.valueName || "value", - description: option.description || "", - type: mainOptionType, - multiple: option.multiple, - defaultValue: option.defaultValue, - }; - - if (needNegativeOption) { - negativeOption = { - flags: `--no-${option.name}`, - description: - negatedDescription || option.negatedDescription || `Negative '${option.name}' option.`, - }; - } } else { - mainOption = { - flags: option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`, - valueName: option.valueName || "value", - description: option.description || "", - type: option.type - ? new Set(Array.isArray(option.type) ? option.type : [option.type]) - : new Set([Boolean]), - multiple: option.multiple, - defaultValue: option.defaultValue, - }; - - if (option.negative) { - negativeOption = { - flags: `--no-${option.name}`, - description: option.negatedDescription || `Negative '${option.name}' option.`, - }; - } - } - - if (mainOption.type.size > 1 && mainOption.type.has(Boolean)) { - mainOption.flags = `${mainOption.flags} [${mainOption.valueName || "value"}${ - mainOption.multiple ? "..." : "" - }]`; - } else if (mainOption.type.size > 0 && !mainOption.type.has(Boolean)) { - mainOption.flags = `${mainOption.flags} <${mainOption.valueName || "value"}${ - mainOption.multiple ? "..." : "" - }>`; + const types = option.type + ? Array.isArray(option.type) + ? option.type + : [option.type] + : [Boolean]; + for (const type of types) mainOptionType.add(type); + needNegativeOption = option.negative || false; + negatedDescription = option.negatedDescription; } - if (mainOption.type.size === 1) { - if (mainOption.type.has(Number)) { - let skipDefault = true; - - const optionForCommand: WebpackCLICommandOption = new Option( - mainOption.flags, - mainOption.description, - ) - .argParser((value: string, prev = []) => { - if (mainOption.defaultValue && mainOption.multiple && skipDefault) { - prev = []; - skipDefault = false; - } - - return mainOption.multiple ? [...prev, Number(value)] : Number(value); - }) - .default(mainOption.defaultValue); - - optionForCommand.helpLevel = option.helpLevel; + // Build main option flags + const baseFlags = option.alias ? `-${option.alias}, --${option.name}` : `--${option.name}`; + const valueName = option.valueName || "value"; + const multipleIndicator = option.multiple ? "..." : ""; - command.addOption(optionForCommand); - } else if (mainOption.type.has(String)) { - let skipDefault = true; - - const optionForCommand: WebpackCLICommandOption = new Option( - mainOption.flags, - mainOption.description, - ) - .argParser((value: string, prev = []) => { - if (mainOption.defaultValue && mainOption.multiple && skipDefault) { - prev = []; - skipDefault = false; - } - - return mainOption.multiple ? [...prev, value] : value; - }) - .default(mainOption.defaultValue); + let flags = baseFlags; + if (mainOptionType.size > 1 && mainOptionType.has(Boolean)) { + flags = `${baseFlags} [${valueName}${multipleIndicator}]`; + } else if (mainOptionType.size > 0 && !mainOptionType.has(Boolean)) { + flags = `${baseFlags} <${valueName}${multipleIndicator}>`; + } - optionForCommand.helpLevel = option.helpLevel; + const description = option.description || ""; - command.addOption(optionForCommand); - } else if (mainOption.type.has(Boolean)) { - const optionForCommand = new Option(mainOption.flags, mainOption.description).default( - mainOption.defaultValue, - ); + // Create main option + let mainOptionCommand: WebpackCLICommandOption; - optionForCommand.helpLevel = option.helpLevel; + if (mainOptionType.size === 1) { + mainOptionCommand = this.createSingleTypeOption( + flags, + description, + mainOptionType, + option.defaultValue, + option.multiple, + ); + } else if (mainOptionType.size > 1) { + mainOptionCommand = this.createMultiTypeOption( + flags, + description, + mainOptionType, + option.defaultValue, + option.multiple, + ); + } else { + mainOptionCommand = new Option(flags, description).default(option.defaultValue); + } - command.addOption(optionForCommand); - } else { - const optionForCommand = new Option(mainOption.flags, mainOption.description) - .argParser([...mainOption.type][0]) - .default(mainOption.defaultValue); + mainOptionCommand.hidden = option.hidden; + options.push(mainOptionCommand); + + // Create negative option if needed + if (needNegativeOption) { + const negativeFlags = `--no-${option.name}`; + const negativeDesc = + negatedDescription || option.negatedDescription || `Negative '${option.name}' option. `; + const negativeOptionCommand = new Option(negativeFlags, negativeDesc); + negativeOptionCommand.hidden = option.hidden; + options.push(negativeOptionCommand); + } - optionForCommand.helpLevel = option.helpLevel; + return options; + } - command.addOption(optionForCommand); - } - } else if (mainOption.type.size > 1) { - let skipDefault = true; - - const optionForCommand = new Option( - mainOption.flags, - mainOption.description, - mainOption.defaultValue, - ) + private createSingleTypeOption( + flags: string, + description: string, + types: WebpackCLIMainOption["type"], + defaultValue: unknown, + multiple?: boolean, + ): WebpackCLICommandOption { + let skipDefault = true; + + if (types.has(Number)) { + return new Option(flags, description) .argParser((value: string, prev = []) => { - if (mainOption.defaultValue && mainOption.multiple && skipDefault) { + if (defaultValue && multiple && skipDefault) { prev = []; skipDefault = false; } - - if (mainOption.type.has(Number)) { - const numberValue = Number(value); - - if (!Number.isNaN(numberValue)) { - return mainOption.multiple ? [...prev, numberValue] : numberValue; - } - } - - if (mainOption.type.has(String)) { - return mainOption.multiple ? [...prev, value] : value; + return multiple ? [...prev, Number(value)] : Number(value); + }) + .default(defaultValue); + } else if (types.has(String)) { + return new Option(flags, description) + .argParser((value: string, prev = []) => { + if (defaultValue && multiple && skipDefault) { + prev = []; + skipDefault = false; } - - return value; + return multiple ? [...prev, value] : value; }) - .default(mainOption.defaultValue); - - optionForCommand.helpLevel = option.helpLevel; - - command.addOption(optionForCommand); - } else if (mainOption.type.size === 0 && negativeOption) { - const optionForCommand = new Option(mainOption.flags, mainOption.description); - - // Hide stub option - optionForCommand.hideHelp(); - optionForCommand.helpLevel = option.helpLevel; - - command.addOption(optionForCommand); + .default(defaultValue); + } else if (types.has(Boolean)) { + return new Option(flags, description).default(defaultValue); } + return new Option(flags, description).argParser([...types][0]).default(defaultValue); + } + + private createMultiTypeOption( + flags: string, + description: string, + types: WebpackCLIMainOption["type"], + defaultValue: unknown, + multiple?: boolean, + ): WebpackCLICommandOption { + let skipDefault = true; + + return new Option(flags, description) + .argParser((value: string, prev = []) => { + if (defaultValue && multiple && skipDefault) { + prev = []; + skipDefault = false; + } - if (negativeOption) { - const optionForCommand = new Option(negativeOption.flags, negativeOption.description); + if (types.has(Number)) { + const numberValue = Number(value); + if (!Number.isNaN(numberValue)) { + return multiple ? [...prev, numberValue] : numberValue; + } + } - optionForCommand.helpLevel = option.helpLevel; + if (types.has(String)) { + return multiple ? [...prev, value] : value; + } - command.addOption(optionForCommand); - } + return value; + }) + .default(defaultValue); } getBuiltInOptions(): WebpackCLIBuiltInOption[] { @@ -894,7 +824,7 @@ class WebpackCLI implements IWebpackCLI { valueName: "pathToConfigFile", description: 'Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js".', - helpLevel: "minimum", + hidden: true, }, { name: "config-name", @@ -907,7 +837,7 @@ class WebpackCLI implements IWebpackCLI { valueName: "name", description: "Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations.", - helpLevel: "minimum", + hidden: true, }, { name: "merge", @@ -919,7 +849,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Merge two or more configurations using 'webpack-merge'.", - helpLevel: "minimum", + hidden: true, }, { name: "disable-interpret", @@ -930,7 +860,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Disable interpret for loading the config file.", - helpLevel: "minimum", + hidden: true, }, // Complex configs { @@ -975,7 +905,7 @@ class WebpackCLI implements IWebpackCLI { multiple: true, description: 'Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval".', - helpLevel: "minimum", + hidden: true, }, { name: "node-env", @@ -987,7 +917,7 @@ class WebpackCLI implements IWebpackCLI { multiple: false, description: "Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead)", - helpLevel: "minimum", + hidden: true, }, { name: "config-node-env", @@ -999,7 +929,7 @@ class WebpackCLI implements IWebpackCLI { multiple: false, description: "Sets process.env.NODE_ENV to the specified value for access within the configuration.", - helpLevel: "minimum", + hidden: true, }, // Adding more plugins @@ -1013,7 +943,7 @@ class WebpackCLI implements IWebpackCLI { ], multiple: false, description: "It invokes webpack-bundle-analyzer plugin to get bundle information.", - helpLevel: "minimum", + hidden: true, }, { name: "progress", @@ -1027,7 +957,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Print compilation progress during build.", - helpLevel: "minimum", + hidden: true, }, // Output options @@ -1045,7 +975,7 @@ class WebpackCLI implements IWebpackCLI { alias: "j", valueName: "pathToJsonFile", description: "Prints result as JSON or store it in a file.", - helpLevel: "minimum", + hidden: true, }, { name: "fail-on-warnings", @@ -1056,7 +986,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Stop webpack-cli process with non-zero exit code on warnings from webpack.", - helpLevel: "minimum", + hidden: true, }, ]; @@ -1076,18 +1006,19 @@ class WebpackCLI implements IWebpackCLI { // Extract all the flags being exported from core. // A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/main/test/__snapshots__/Cli.basictest.js.snap - const options = [ - ...builtInFlags, - ...Object.entries(this.webpack.cli.getArguments()).map( + let coreOptions: WebpackCLIBuiltInOption[] = []; + if (this.webpack) { + coreOptions = Object.entries(this.webpack.cli.getArguments()).map( ([name, meta]) => ({ ...meta, name, description: meta.description, group: "core", - helpLevel: minimumHelpFlags.includes(name) ? "minimum" : "verbose", + hidden: !minimumHelpFlags.includes(name), }), - ), - ]; + ); + } + const options = [...builtInFlags, ...coreOptions]; this.builtInOptionsCache = options; @@ -1098,692 +1029,260 @@ class WebpackCLI implements IWebpackCLI { return this.tryRequireThenImport(WEBPACK_PACKAGE, handleError); } - async run(args: Parameters[0], parseOptions: ParseOptions) { - // Default `--color` and `--no-color` options + async run(args?: Parameters[0], parseOptions?: ParseOptions) { // eslint-disable-next-line @typescript-eslint/no-this-alias - const cli: IWebpackCLI = this; + const cli = this; + + // Load webpack early for getBuiltInOptions to access cli.getArguments() + this.webpack = await this.loadWebpack(); - // Built-in internal commands - const buildCommandOptions = { + const options = this.getBuiltInOptions().flatMap((opt) => this.makeOption(opt)); + + await this.makeCommand({ name: "build [entries...]", alias: ["bundle", "b"], description: "Run webpack (default command, can be omitted).", - usage: "[entries...] [options]", - dependencies: [WEBPACK_PACKAGE], - }; - const watchCommandOptions = { - name: "watch [entries...]", - alias: "w", - description: "Run webpack and watch for files changes.", - usage: "[entries...] [options]", dependencies: [WEBPACK_PACKAGE], - }; - const versionCommandOptions = { - name: "version", - alias: "v", - usage: "[options]", - description: - "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", - }; - const helpCommandOptions = { - name: "help [command] [option]", - alias: "h", - description: "Display help for commands and options.", - }; - // Built-in external commands - const externalBuiltInCommandsInfo: WebpackCLIExternalCommandInfo[] = [ - { - name: "serve [entries...]", - alias: ["server", "s"], - pkg: "@webpack-cli/serve", - }, - { - name: "info", - alias: "i", - pkg: "@webpack-cli/info", - }, - { - name: "configtest [config-path]", - alias: "t", - pkg: "@webpack-cli/configtest", - }, - ]; + isDefault: true, + options, + async action(this: WebpackCLICommand, entries, options) { + if ( + this.parent!.args.length > 0 && + this.parent!.args[0] === this.args[0] && + !fs.existsSync(this.args[0]) + ) { + // If we are running as default _and_ an entry cannot be found, + // we should suggest alternative commands to the user. + // @ts-expect-error It's a private method + this.parent!.unknownCommand(); + } - const knownCommands = [ - buildCommandOptions, - watchCommandOptions, - versionCommandOptions, - helpCommandOptions, - ...externalBuiltInCommandsInfo, - ]; - const getCommandName = (name: string) => name.split(" ")[0]; - const isKnownCommand = (name: string) => - knownCommands.find( - (command) => - getCommandName(command.name) === name || - (Array.isArray(command.alias) ? command.alias.includes(name) : command.alias === name), - ); - const isCommand = (input: string, commandOptions: WebpackCLIOptions) => { - const longName = getCommandName(commandOptions.name); + if (entries.length > 0) { + options.entry = [...entries, ...(options.entry || [])]; + } - if (input === longName) { - return true; - } + await cli.runWebpack(options, false); + }, + }); - if (commandOptions.alias) { - if (Array.isArray(commandOptions.alias)) { - return commandOptions.alias.includes(input); + await this.makeCommand({ + name: "watch [entries...]", + alias: ["w"], + description: "Run webpack and watch for files changes.", + dependencies: [WEBPACK_PACKAGE], + options, + async action(entries, options) { + if (entries.length > 0) { + options.entry = [...entries, ...(options.entry || [])]; } - return commandOptions.alias === input; - } - - return false; - }; - const findCommandByName = (name: string) => - this.program.commands.find( - (command) => name === command.name() || command.aliases().includes(name), - ); - const isOption = (value: string): boolean => value.startsWith("-"); - const isGlobalOption = (value: string) => - value === "--color" || - value === "--no-color" || - value === "-v" || - value === "--version" || - value === "-h" || - value === "--help"; - - const loadCommandByName = async ( - commandName: WebpackCLIExternalCommandInfo["name"], - allowToInstall = false, - ) => { - const isBuildCommandUsed = isCommand(commandName, buildCommandOptions); - const isWatchCommandUsed = isCommand(commandName, watchCommandOptions); - - if (isBuildCommandUsed || isWatchCommandUsed) { - await this.makeCommand( - isBuildCommandUsed ? buildCommandOptions : watchCommandOptions, - async () => { - this.webpack = await this.loadWebpack(); - - return this.getBuiltInOptions(); - }, - async (entries, options) => { - if (entries.length > 0) { - options.entry = [...entries, ...(options.entry || [])]; - } - await this.runWebpack(options, isWatchCommandUsed); - }, - ); - } else if (isCommand(commandName, helpCommandOptions)) { - this.makeCommand(helpCommandOptions, [], () => { - // Stub for the `help` command - }); - } else if (isCommand(commandName, versionCommandOptions)) { - // Stub for the `version` command - this.makeCommand( - versionCommandOptions, - this.getInfoOptions(), - async (options: { output: string; additionalPackage: string[] }) => { - const info = await cli.getInfoOutput(options); - - cli.logger.raw(info); - }, - ); - } else { - const builtInExternalCommandInfo = externalBuiltInCommandsInfo.find( - (externalBuiltInCommandInfo) => - getCommandName(externalBuiltInCommandInfo.name) === commandName || - (Array.isArray(externalBuiltInCommandInfo.alias) - ? externalBuiltInCommandInfo.alias.includes(commandName) - : externalBuiltInCommandInfo.alias === commandName), - ); + await cli.runWebpack(options, true); + }, + }); - let pkg: string; + await this.makeCommand({ + name: "configtest [config-path]", + alias: ["t"], + description: "Validate a webpack configuration.", + dependencies: [WEBPACK_PACKAGE], + async action(configPath) { + const config = await cli.loadConfig(configPath ? { config: [configPath] } : {}); + const configPaths = new Set(); - if (builtInExternalCommandInfo) { - ({ pkg } = builtInExternalCommandInfo); - } else { - pkg = commandName; - } + if (Array.isArray(config.options)) { + for (const options of config.options) { + const loadedConfigPaths = config.path.get(options); - if (pkg !== "webpack-cli" && !this.checkPackageExists(pkg)) { - if (!allowToInstall) { - return; + if (loadedConfigPaths) { + for (const path of loadedConfigPaths) configPaths.add(path); + } } + } else if (config.path.get(config.options)) { + const loadedConfigPaths = config.path.get(config.options); - pkg = await this.doInstall(pkg, { - preMessage: () => { - this.logger.error( - `For using this command you need to install: '${this.colors.green(pkg)}' package.`, - ); - }, - }); + if (loadedConfigPaths) { + for (const path of loadedConfigPaths) configPaths.add(path); + } } - let loadedCommand; - - try { - loadedCommand = await this.tryRequireThenImport void>>(pkg, false); - } catch { - // Ignore, command is not installed - - return; + if (configPaths.size === 0) { + cli.logger.error("No configuration found."); + process.exit(2); } - let command; + cli.logger.info(`Validate '${[...configPaths].join(" ,")}'.`); try { - // eslint-disable-next-line new-cap - command = new loadedCommand(); - - await command.apply(this); + cli.webpack.validate(config.options); } catch (error) { - this.logger.error(`Unable to load '${pkg}' command`); - this.logger.error(error); - process.exit(2); - } - } - }; - - // Register own exit - this.program.exitOverride(async (error) => { - if (error.exitCode === 0) { - process.exit(0); - } - - if (error.code === "executeSubCommandAsync") { - process.exit(2); - } - - if (error.code === "commander.help") { - process.exit(0); - } - - if (error.code === "commander.unknownOption") { - let name = error.message.match(/'(.+)'/) as string | null; - - if (name) { - name = name[1].slice(2); - - if (name.includes("=")) { - [name] = name.split("="); + if (cli.isValidationError(error as Error)) { + cli.logger.error((error as Error).message); + } else { + cli.logger.error(error); } - const { operands } = this.program.parseOptions(this.program.args); - const operand = - typeof operands[0] !== "undefined" - ? operands[0] - : getCommandName(buildCommandOptions.name); - - if (operand) { - const command = findCommandByName(operand); - - if (!command) { - this.logger.error(`Can't find and load command '${operand}'`); - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } - - const levenshtein = require("fastest-levenshtein"); - - for (const option of (command as WebpackCLICommand).options) { - if (!option.hidden && levenshtein.distance(name, option.long?.slice(2)) < 3) { - this.logger.error(`Did you mean '--${option.name()}'?`); - } - } - } + process.exit(2); } - } - - // Codes: - // - commander.unknownCommand - // - commander.missingArgument - // - commander.missingMandatoryOptionValue - // - commander.optionMissingArgument - - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - }); - - this.program.option("--color", "Enable colors on console."); - this.program.on("option:color", function color(this: WebpackCLICommand) { - const { color } = this.opts(); - - cli.isColorSupportChanged = color; - cli.colors = cli.createColors(color); - }); - this.program.option("--no-color", "Disable colors on console."); - this.program.on("option:no-color", function noColor(this: WebpackCLICommand) { - const { color } = this.opts(); - cli.isColorSupportChanged = color; - cli.colors = cli.createColors(color); + cli.logger.success("There are no validation errors in the given webpack configuration."); + }, }); - this.program.option( - "-v, --version", - "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", - ); - - // webpack-cli has it's own logic for showing suggestions - this.program.showSuggestionAfterError(false); - - const outputHelp = async ( - options: string[], - isVerbose: boolean, - isHelpCommandSyntax: boolean, - program: WebpackCLICommand, - ) => { - const { bold } = this.colors; - const outputIncorrectUsageOfHelp = () => { - this.logger.error("Incorrect use of help"); - this.logger.error( - "Please use: 'webpack help [command] [option]' | 'webpack [command] --help'", - ); - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - }; - - const isGlobalHelp = options.length === 0; - const isCommandHelp = options.length === 1 && !isOption(options[0]); - - if (isGlobalHelp || isCommandHelp) { - program.configureHelp({ - sortSubcommands: true, - // Support multiple aliases - commandUsage: (command: WebpackCLICommand) => { - let parentCmdNames = ""; - - for (let parentCmd = command.parent; parentCmd; parentCmd = parentCmd.parent) { - parentCmdNames = `${parentCmd.name()} ${parentCmdNames}`; - } - - if (isGlobalHelp) { - return `${parentCmdNames}${command.usage()}\n${bold( - "Alternative usage to run commands:", - )} ${parentCmdNames}[command] [options]`; - } - - return `${parentCmdNames}${command.name()}|${command - .aliases() - .join("|")} ${command.usage()}`; - }, - // Support multiple aliases - subcommandTerm: (command: WebpackCLICommand) => { - const humanReadableArgumentName = (argument: WebpackCLICommandOption) => { - const nameOutput = argument.name() + (argument.variadic ? "..." : ""); - - return argument.required ? `<${nameOutput}>` : `[${nameOutput}]`; - }; - const args = command._args - .map((arg: WebpackCLICommandOption) => humanReadableArgumentName(arg)) - .join(" "); - - return `${command.name()}|${command.aliases().join("|")}${args ? ` ${args}` : ""}${ - command.options.length > 0 ? " [options]" : "" - }`; - }, - visibleOptions: function visibleOptions( - command: WebpackCLICommand, - ): WebpackCLICommandOption[] { - return command.options.filter((option: WebpackCLICommandOption) => { - if (option.hidden) { - return false; - } - - // Hide `--watch` option when developer use `webpack watch --help` - if ( - (options[0] === "w" || options[0] === "watch") && - (option.name() === "watch" || option.name() === "no-watch") - ) { - return false; - } - - switch (option.helpLevel) { - case "verbose": - return isVerbose; - case "minimum": - default: - return true; - } - }); - }, - padWidth(command: WebpackCLICommand, helper: Help) { - return Math.max( - helper.longestArgumentTermLength(command, helper), - helper.longestOptionTermLength(command, helper), - // For global options - helper.longestOptionTermLength(program, helper), - helper.longestSubcommandTermLength(isGlobalHelp ? program : command, helper), - ); - }, - formatHelp: (command: WebpackCLICommand, helper: Help) => { - const termWidth = helper.padWidth(command, helper); - const helpWidth = - helper.helpWidth || (process.env.WEBPACK_CLI_HELP_WIDTH as unknown as number) || 80; - const itemIndentWidth = 2; - const itemSeparatorWidth = 2; // between term and description - - const formatItem = (term: string, description: string) => { - if (description) { - const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`; - - return helper.wrap( - fullText, - helpWidth - itemIndentWidth, - termWidth + itemSeparatorWidth, - ); - } - - return term; - }; - - const formatList = (textArray: string[]) => - textArray.join("\n").replaceAll(/^/gm, " ".repeat(itemIndentWidth)); - - // Usage - let output = [`${bold("Usage:")} ${helper.commandUsage(command)}`, ""]; - - // Description - const commandDescription = isGlobalHelp - ? "The build tool for modern web applications." - : helper.commandDescription(command); - - if (commandDescription.length > 0) { - output = [...output, commandDescription, ""]; - } - - // Arguments - const argumentList = helper - .visibleArguments(command) - .map((argument) => formatItem(argument.name(), argument.description)); - - if (argumentList.length > 0) { - output = [...output, bold("Arguments:"), formatList(argumentList), ""]; - } - - // Options - const optionList = helper - .visibleOptions(command) - .map((option) => - formatItem(helper.optionTerm(option), helper.optionDescription(option)), - ); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let devServerArguments: any[] = []; + try { + const devServer = require(WEBPACK_DEV_SERVER_PACKAGE); - if (optionList.length > 0) { - output = [...output, bold("Options:"), formatList(optionList), ""]; - } + devServerArguments = Object.entries(cli.webpack.cli.getArguments(devServer.schema)).map( + ([name, option]) => ({ name, ...option, group: "core", hidden: true }), + ); + } catch { + // webpack-dev-server not available, continue with empty options + } - // Global options - const globalOptionList = program.options.map((option: WebpackCLICommandOption) => - formatItem(helper.optionTerm(option), helper.optionDescription(option)), + await this.makeCommand({ + name: "serve [entries...]", + alias: ["server", "s"], + description: "Run the webpack dev server and watch for source file changes while serving.", + options: [...options, ...devServerArguments.flatMap((opt) => cli.makeOption(opt))], + dependencies: [WEBPACK_PACKAGE, WEBPACK_DEV_SERVER_PACKAGE], + async action(entries, options) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const webpackCLIOptions: Record = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const devServerCLIOptions: Record = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const processors: ((opts: Record) => void)[] = []; + + const builtinOptions = cli.getBuiltInOptions(); + + for (const optionName in options) { + const kebabedOption = cli.toKebabCase(optionName); + const isBuiltInOption = builtinOptions.find((opt) => opt.name === kebabedOption); + + if (isBuiltInOption) { + webpackCLIOptions[optionName] = options[optionName]; + } else { + const needToProcess = devServerArguments.find( + ({ processor, name }) => name === kebabedOption && processor, ); - if (globalOptionList.length > 0) { - output = [...output, bold("Global options:"), formatList(globalOptionList), ""]; - } - - // Commands - const commandList = helper - .visibleCommands(isGlobalHelp ? program : command) - .map((command) => - formatItem(helper.subcommandTerm(command), helper.subcommandDescription(command)), - ); - - if (commandList.length > 0) { - output = [...output, bold("Commands:"), formatList(commandList), ""]; + if (needToProcess) { + processors.push(needToProcess.processor); } - return output.join("\n"); - }, - }); - - if (isGlobalHelp) { - await Promise.all( - knownCommands.map((knownCommand) => - loadCommandByName(getCommandName(knownCommand.name)), - ), - ); - - const buildCommand = findCommandByName(getCommandName(buildCommandOptions.name)); - - if (buildCommand) { - this.logger.raw(buildCommand.helpInformation()); - } - } else { - const [name] = options; - - await loadCommandByName(name); - - const command = findCommandByName(name); - - if (!command) { - const builtInCommandUsed = externalBuiltInCommandsInfo.find( - (command) => command.name.includes(name) || name === command.alias, - ); - if (typeof builtInCommandUsed !== "undefined") { - this.logger.error( - `For using '${name}' command you need to install '${builtInCommandUsed.pkg}' package.`, - ); - } else { - this.logger.error(`Can't find and load command '${name}'`); - this.logger.error("Run 'webpack --help' to see available commands and options."); - } - process.exit(2); + devServerCLIOptions[optionName] = options[optionName]; } + } - this.logger.raw(command.helpInformation()); + for (const processor of processors) { + processor(devServerCLIOptions); } - } else if (isHelpCommandSyntax) { - let isCommandSpecified = false; - let commandName = getCommandName(buildCommandOptions.name); - let optionName = ""; - - if (options.length === 1) { - [optionName] = options; - } else if (options.length === 2) { - isCommandSpecified = true; - [commandName, optionName] = options; - - if (isOption(commandName)) { - outputIncorrectUsageOfHelp(); - } - } else { - outputIncorrectUsageOfHelp(); + + if (entries.length > 0) { + webpackCLIOptions.entry = [...entries, ...(webpackCLIOptions.entry || [])]; } - await loadCommandByName(commandName); + webpackCLIOptions.argv = { + ...options, + env: { WEBPACK_SERVE: true, ...options.env }, + }; - const command = isGlobalOption(optionName) ? program : findCommandByName(commandName); + webpackCLIOptions.isWatchingLikeCommand = true; - if (!command) { - this.logger.error(`Can't find and load command '${commandName}'`); - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } + const compiler = await cli.createCompiler(webpackCLIOptions); + if (!compiler) return; - const option = (command as WebpackCLICommand).options.find( - (option) => option.short === optionName || option.long === optionName, - ); + const servers: (typeof DevServer)[] = []; - if (!option) { - this.logger.error(`Unknown option '${optionName}'`); - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); + if (cli.needWatchStdin(compiler)) { + process.stdin.on("end", () => { + Promise.all(servers.map((server) => server.stop())).then(() => { + process.exit(0); + }); + }); + process.stdin.resume(); } - const nameOutput = - option.flags.replace(/^.+[[<]/, "").replace(/(\.\.\.)?[\]>].*$/, "") + - (option.variadic === true ? "..." : ""); - const value = option.required - ? `<${nameOutput}>` - : option.optional - ? `[${nameOutput}]` - : ""; - - this.logger.raw( - `${bold("Usage")}: webpack${isCommandSpecified ? ` ${commandName}` : ""} ${option.long}${ - value ? ` ${value}` : "" - }`, + const compilers = cli.isMultipleCompiler(compiler) ? compiler.compilers : [compiler]; + const possibleCompilers = compilers.filter( + (compiler: Compiler) => compiler.options.devServer, ); + const devServerCompilers = + possibleCompilers.length > 0 + ? possibleCompilers + : compilers[0].options.devServer === false + ? [] + : [compilers[0]]; - if (option.short) { - this.logger.raw( - `${bold("Short:")} webpack${isCommandSpecified ? ` ${commandName}` : ""} ${ - option.short - }${value ? ` ${value}` : ""}`, - ); - } - - if (option.description) { - this.logger.raw(`${bold("Description:")} ${option.description}`); - } + const usedPorts = new Set(); - if (!option.negate && option.defaultValue) { - this.logger.raw(`${bold("Default value:")} ${JSON.stringify(option.defaultValue)}`); - } + const DevServer = require(WEBPACK_DEV_SERVER_PACKAGE); - const flag = this.getBuiltInOptions().find((flag) => option.long === `--${flag.name}`); + for (const devServerCompiler of devServerCompilers) { + const result = { ...devServerCompiler.options.devServer } as WebpackDevServerOptions; + cli.processArguments(result, options, devServerArguments); - if (flag?.configs) { - const possibleValues = flag.configs.reduce((accumulator, currentValue) => { - if (currentValue.values) { - return [...accumulator, ...currentValue.values]; + if (result.port) { + if (usedPorts.has(result.port)) { + throw new Error( + "Unique ports must be specified for each devServer option in your webpack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.", + ); } - return accumulator; - }, [] as EnumValue[]); - - if (possibleValues.length > 0) { - // Convert the possible values to a union type string - // ['mode', 'development', 'production'] => "'mode' | 'development' | 'production'" - // [false, 'eval'] => "false | 'eval'" - const possibleValuesUnionTypeString = possibleValues - .map((value) => (typeof value === "string" ? `'${value}'` : value)) - .join(" | "); - - this.logger.raw(`${bold("Possible values:")} ${possibleValuesUnionTypeString}`); + usedPorts.add(result.port); } - } - - this.logger.raw(""); - - // TODO implement this after refactor cli arguments - // logger.raw('Documentation: https://webpack.js.org/option/name/'); - } else { - outputIncorrectUsageOfHelp(); - } - - this.logger.raw( - "To see list of all supported commands and options run 'webpack --help=verbose'.\n", - ); - this.logger.raw(`${bold("Webpack documentation:")} https://webpack.js.org/.`); - this.logger.raw(`${bold("CLI documentation:")} https://webpack.js.org/api/cli/.`); - this.logger.raw(`${bold("Made with ♥ by the webpack team")}.`); - process.exit(0); - }; - this.program.helpOption(false); - // Suppress the default help command - this.program.helpCommand(false); - this.program.option("-h, --help [verbose]", "Display help for commands and options."); - - let isInternalActionCalled = false; - - // Default action - this.program.usage("[options]"); - this.program.allowUnknownOption(true); - // Basic command for lazy loading other commands - this.program.action(async (options, program: WebpackCLICommand) => { - if (!isInternalActionCalled) { - isInternalActionCalled = true; - } else { - this.logger.error("No commands found to run"); - process.exit(2); - } + try { + const server = new DevServer(result, compiler); - // Command and options - const { operands, unknown } = this.program.parseOptions(program.args); - const defaultCommandToRun = getCommandName(buildCommandOptions.name); - const hasOperand = typeof operands[0] !== "undefined"; - const operand = hasOperand ? operands[0] : defaultCommandToRun; - const isHelpOption = typeof options.help !== "undefined"; - const isHelpCommandSyntax = isCommand(operand, helpCommandOptions); + await server.start(); - if (isHelpOption || isHelpCommandSyntax) { - let isVerbose = false; + servers.push(server); + } catch (error) { + if (cli.isValidationError(error as Error)) { + cli.logger.error((error as Error).message); + } else { + cli.logger.error(error); + } - if (isHelpOption && typeof options.help === "string") { - if (options.help !== "verbose") { - this.logger.error("Unknown value for '--help' option, please use '--help=verbose'"); process.exit(2); } - - isVerbose = true; } - this.program.forHelp = true; - - const optionsForHelp = [ - ...(isHelpOption && hasOperand ? [operand] : []), - ...operands.slice(1), - ...unknown, - ...(isHelpCommandSyntax && typeof options.color !== "undefined" - ? [options.color ? "--color" : "--no-color"] - : []), - ...(isHelpCommandSyntax && typeof options.version !== "undefined" ? ["--version"] : []), - ]; - - await outputHelp(optionsForHelp, isVerbose, isHelpCommandSyntax, program); - } - - const isVersionOption = typeof options.version !== "undefined"; - - if (isVersionOption) { - const info = await this.getInfoOutput({ output: "", additionalPackage: [] }); - this.logger.raw(info); - process.exit(0); - } - - let commandToRun = operand; - let commandOperands = operands.slice(1); - - if (isKnownCommand(commandToRun)) { - await loadCommandByName(commandToRun, true); - } else { - const isEntrySyntax = fs.existsSync(operand); - - if (isEntrySyntax) { - commandToRun = defaultCommandToRun; - commandOperands = operands; - - await loadCommandByName(commandToRun); - } else { - this.logger.error(`Unknown command or entry '${operand}'`); + if (servers.length === 0) { + cli.logger.error("No dev server configurations to run"); + process.exit(2); + } + }, + }); - const levenshtein = require("fastest-levenshtein"); + await this.makeCommand({ + name: "info", + alias: ["i", "version"], + description: + "Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.", + options: this.getInfoOptions().flatMap((opt) => this.makeOption(opt)), + async action(options) { + const info = await cli.getInfoOutput(options); + cli.logger.raw(info); + }, + }); - const found = knownCommands.find( - (commandOptions) => - levenshtein.distance(operand, getCommandName(commandOptions.name)) < 3, - ); + this.program.option("--color", "Enable colors on console."); + this.program.on("option:color", function color(this: WebpackCLICommand) { + const { color } = this.opts(); - if (found) { - this.logger.error( - `Did you mean '${getCommandName(found.name)}' (alias '${ - Array.isArray(found.alias) ? found.alias.join(", ") : found.alias - }')?`, - ); - } + cli.isColorSupportChanged = color; + cli.colors = cli.createColors(color); + }); - this.logger.error("Run 'webpack --help' to see available commands and options"); - process.exit(2); - } - } + this.program.option("--no-color", "Disable colors on console."); + this.program.on("option:no-color", function noColor(this: WebpackCLICommand) { + const { color } = this.opts(); - await this.program.parseAsync([commandToRun, ...commandOperands, ...unknown], { - from: "user", - }); + cli.isColorSupportChanged = color; + cli.colors = cli.createColors(color); }); await this.program.parseAsync(args, parseOptions); @@ -2136,6 +1635,75 @@ class WebpackCLI implements IWebpackCLI { return config; } + async processArguments( + item: Configuration, + userOptions: Partial, + optionsConfig: WebpackCLIBuiltInOption[] = this.getBuiltInOptions(), + ) { + // Apply options + const args: Record = optionsConfig.reduce( + (accumulator: Record, flag) => { + if (flag.group === "core") { + accumulator[flag.name] = flag as unknown as Argument; + } + return accumulator; + }, + {}, + ); + const values: ProcessedArguments = Object.keys(userOptions).reduce( + (accumulator: ProcessedArguments, name) => { + if (name === "argv") { + return accumulator; + } + + const kebabName = this.toKebabCase(name); + + if (args[kebabName]) { + accumulator[kebabName] = userOptions[name as keyof typeof userOptions as string]; + } + + return accumulator; + }, + {}, + ); + + if (Object.keys(values).length > 0) { + const problems: Problem[] | null = this.webpack.cli.processArguments(args, item, values); + + if (problems) { + const groupBy = >(xs: Problem[], key: K) => + xs.reduce((rv: Record, problem: Problem) => { + const path = problem[key]; + + (rv[path] ||= []).push(problem); + + return rv; + }, {}); + const problemsByPath = groupBy(problems, "path"); + + for (const path in problemsByPath) { + const problems = problemsByPath[path]; + + for (const problem of problems) { + this.logger.error( + `${this.capitalizeFirstLetter(problem.type.replaceAll("-", " "))}${ + problem.value ? ` '${problem.value}'` : "" + } for the '--${problem.argument}' option${ + problem.index ? ` by index '${problem.index}'` : "" + }`, + ); + + if (problem.expected) { + this.logger.error(`Expected: '${problem.expected}'`); + } + } + } + + process.exit(2); + } + } + } + async buildConfig( config: WebpackCLIConfig, options: Partial, @@ -2169,73 +1737,7 @@ class WebpackCLI implements IWebpackCLI { const internalBuildConfig = (item: Configuration) => { const originalWatchValue = item.watch; - // Apply options - const args: Record = this.getBuiltInOptions().reduce( - (accumulator: Record, flag) => { - if (flag.group === "core") { - accumulator[flag.name] = flag as unknown as Argument; - } - return accumulator; - }, - {}, - ); - const values: ProcessedArguments = Object.keys(options).reduce( - (accumulator: ProcessedArguments, name) => { - if (name === "argv") { - return accumulator; - } - - const kebabName = this.toKebabCase(name); - - if (args[kebabName]) { - accumulator[kebabName] = options[name as keyof typeof options as string]; - } - - return accumulator; - }, - {}, - ); - - if (Object.keys(values).length > 0) { - const problems: Problem[] | null = this.webpack.cli.processArguments(args, item, values); - - if (problems) { - const groupBy = >(xs: Problem[], key: K) => - xs.reduce((rv: Record, problem: Problem) => { - const path = problem[key]; - - (rv[path] ||= []).push(problem); - - return rv; - }, {}); - const problemsByPath = groupBy(problems, "path"); - - for (const path in problemsByPath) { - const problems = problemsByPath[path]; - - for (const problem of problems) { - this.logger.error( - `${this.capitalizeFirstLetter(problem.type.replaceAll("-", " "))}${ - problem.value ? ` '${problem.value}'` : "" - } for the '--${problem.argument}' option${ - problem.index ? ` by index '${problem.index}'` : "" - }`, - ); - - if (problem.expected) { - this.logger.error(`Expected: '${problem.expected}'`); - } - } - } - - process.exit(2); - } - } - - // Output warnings - if (!Object.isExtensible(item)) { - return; - } + this.processArguments(item, options); if ( options.isWatchingLikeCommand && diff --git a/test/api/CLI.test.js b/test/api/CLI.test.js index 28de85d0cc2..5d68ec36d87 100644 --- a/test/api/CLI.test.js +++ b/test/api/CLI.test.js @@ -1,6 +1,7 @@ const CLI = require("../../packages/webpack-cli/lib/webpack-cli"); describe("CLI API", () => { + /** @type {CLI.default} */ let cli; beforeEach(() => { @@ -19,8 +20,12 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand({ name: "command" }, [], (options) => { - expect(options).toEqual({}); + const command = await cli.makeCommand({ + name: "command", + options: [], + action: (options) => { + expect(options).toEqual({}); + }, }); command.parseAsync([], { from: "user" }); @@ -31,20 +36,18 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: true }); }, - ); + }); command.parseAsync(["--boolean"], { from: "user" }); }); @@ -54,21 +57,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: true }); }, - ); + }); command.parseAsync(["--boolean"], { from: "user" }); }); @@ -78,22 +79,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: false }); }, - ); + }); command.parseAsync(["--no-boolean"], { from: "user" }); }); @@ -103,11 +102,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "configs-boolean", configs: [ @@ -117,11 +114,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ configsBoolean: false }); }, - ); + }); command.parseAsync(["--no-configs-boolean"], { from: "user" }); }); @@ -131,11 +128,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "configs-number", configs: [ @@ -145,11 +140,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ configsNumber: 42 }); }, - ); + }); command.parseAsync(["--configs-number", "42"], { from: "user" }); }); @@ -159,11 +154,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "configs-string", configs: [ @@ -173,11 +166,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ configsString: "foo" }); }, - ); + }); command.parseAsync(["--configs-string", "foo"], { from: "user" }); }); @@ -187,11 +180,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "configs-path", configs: [ @@ -201,11 +192,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ configsPath: "/root/foo" }); }, - ); + }); command.parseAsync(["--configs-path", "/root/foo"], { from: "user", @@ -217,11 +208,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "configs-regexp", configs: [ @@ -231,11 +220,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ configsRegexp: "\\w+" }); }, - ); + }); command.parseAsync(["--configs-regexp", "\\w+"], { from: "user" }); }); @@ -245,11 +234,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "enum-string", configs: [ @@ -260,11 +247,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ enumString: "foo" }); }, - ); + }); command.parseAsync(["--enum-string", "foo"], { from: "user" }); }); @@ -274,11 +261,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "enum-number", configs: [ @@ -289,11 +274,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ enumNumber: 42 }); }, - ); + }); command.parseAsync(["--enum-number", "42"], { from: "user" }); }); @@ -303,11 +288,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "enum-boolean", configs: [ @@ -318,11 +301,11 @@ describe("CLI API", () => { ], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ enumBoolean: false }); }, - ); + }); command.parseAsync(["--no-enum-boolean"], { from: "user" }); }); @@ -332,22 +315,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: false }); }, - ); + }); command.parseAsync(["--boolean", "--no-boolean"], { from: "user" }); }); @@ -357,22 +338,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: true }); }, - ); + }); command.parseAsync(["--no-boolean", "--boolean"], { from: "user" }); }); @@ -382,22 +361,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "description", defaultValue: false, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: false }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -407,21 +384,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", type: String, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "bar" }); }, - ); + }); command.parseAsync(["--string", "bar"], { from: "user" }); }); @@ -431,22 +406,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", alias: "s", type: String, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "foo" }); }, - ); + }); command.parseAsync(["-s", "foo"], { from: "user" }); }); @@ -456,22 +429,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", type: String, description: "description", defaultValue: "default-value", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "default-value" }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -481,22 +452,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", type: String, description: "description", defaultValue: "default-value", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "foo" }); }, - ); + }); command.parseAsync(["--string", "foo"], { from: "user" }); }); @@ -506,21 +475,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", type: String, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "bar" }); }, - ); + }); command.parseAsync(["--string=bar"], { from: "user" }); }); @@ -530,22 +497,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", multiple: true, type: String, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: ["foo", "bar"] }); }, - ); + }); command.parseAsync(["--string", "foo", "bar"], { from: "user" }); }); @@ -555,11 +520,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", multiple: true, @@ -567,11 +530,11 @@ describe("CLI API", () => { description: "description", defaultValue: "string", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: "string" }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -581,11 +544,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", multiple: true, @@ -593,11 +554,11 @@ describe("CLI API", () => { description: "description", defaultValue: "string", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: ["foo", "bar"] }); }, - ); + }); command.parseAsync(["--string", "foo", "--string", "bar"], { from: "user", @@ -609,22 +570,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "string", multiple: true, type: String, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ string: ["foo", "bar"] }); }, - ); + }); command.parseAsync(["--string", "foo", "--string", "bar"], { from: "user", @@ -636,21 +595,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "number", type: Number, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ number: 12 }); }, - ); + }); command.parseAsync(["--number", "12"], { from: "user" }); }); @@ -660,22 +617,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "number", type: Number, description: "description", defaultValue: 20, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ number: 20 }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -685,22 +640,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "number", multiple: true, type: Number, description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ number: [1, 2] }); }, - ); + }); command.parseAsync(["--number", "1", "--number", "2"], { from: "user", @@ -712,11 +665,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "number", multiple: true, @@ -724,11 +675,11 @@ describe("CLI API", () => { description: "description", defaultValue: 50, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ number: [1, 2] }); }, - ); + }); command.parseAsync(["--number", "1", "--number", "2"], { from: "user", @@ -740,11 +691,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "number", multiple: true, @@ -752,11 +701,11 @@ describe("CLI API", () => { description: "description", defaultValue: 50, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ number: 50 }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -766,21 +715,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "custom", type: () => "function", description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ custom: "function" }); }, - ); + }); command.parseAsync(["--custom", "value"], { from: "user" }); }); @@ -790,22 +737,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "custom", type: () => "function", description: "description", defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ custom: "default" }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -815,22 +760,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "custom", type: (value, previous = []) => [...previous, value], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ custom: ["value", "other"] }); }, - ); + }); command.parseAsync(["--custom", "value", "--custom", "other"], { from: "user", @@ -842,11 +785,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "custom", type: (value, previous = []) => [...previous, value], @@ -854,11 +795,11 @@ describe("CLI API", () => { multiple: true, defaultValue: 50, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ custom: 50 }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -870,11 +811,9 @@ describe("CLI API", () => { let skipDefault = true; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "custom", type: (value, previous = []) => { @@ -889,11 +828,11 @@ describe("CLI API", () => { multiple: true, defaultValue: 50, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ custom: ["foo"] }); }, - ); + }); command.parseAsync(["--custom", "foo"], { from: "user" }); }); @@ -903,21 +842,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: true }); }, - ); + }); command.parseAsync(["--boolean-and-string"], { from: "user" }); }); @@ -927,21 +864,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: "value" }); }, - ); + }); command.parseAsync(["--boolean-and-string", "value"], { from: "user", @@ -953,22 +888,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: true }); }, - ); + }); command.parseAsync(["--boolean-and-string"], { from: "user" }); }); @@ -978,24 +911,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: ["bar", "baz"], }); }, - ); + }); command.parseAsync(["--boolean-and-string", "bar", "--boolean-and-string", "baz"], { from: "user", @@ -1007,22 +938,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: true }); }, - ); + }); command.parseAsync(["--boolean-and-string"], { from: "user" }); }); @@ -1032,22 +961,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: "foo" }); }, - ); + }); command.parseAsync(["--boolean-and-string", "foo"], { from: "user", @@ -1059,22 +986,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-string", type: [Boolean, String], description: "description", negative: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndString: false }); }, - ); + }); command.parseAsync(["--no-boolean-and-string"], { from: "user" }); }); @@ -1084,21 +1009,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number", type: [Boolean, Number], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumber: true }); }, - ); + }); command.parseAsync(["--boolean-and-number"], { from: "user" }); }); @@ -1108,21 +1031,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number", type: [Boolean, Number], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumber: 12 }); }, - ); + }); command.parseAsync(["--boolean-and-number", "12"], { from: "user", @@ -1134,21 +1055,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: [Boolean], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: true }); }, - ); + }); command.parseAsync(["--boolean"], { from: "user" }); }); @@ -1158,23 +1077,21 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: true, }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string"], { from: "user", @@ -1186,21 +1103,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: 12 }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "12"], { from: "user", @@ -1212,23 +1127,21 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: "bar", }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "bar"], { from: "user", @@ -1240,24 +1153,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: "default", }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -1267,24 +1178,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: "foo", }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "foo"], { from: "user", @@ -1296,22 +1205,20 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: 12 }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "12"], { from: "user", @@ -1323,24 +1230,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: true, }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string"], { from: "user", @@ -1352,24 +1257,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: true, }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string"], { from: "user", @@ -1381,24 +1284,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: ["foo"], }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "foo"], { from: "user", @@ -1410,24 +1311,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: [12], }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "12"], { from: "user", @@ -1439,24 +1338,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: ["foo", "bar"], }); }, - ); + }); command.parseAsync( ["--boolean-and-number-and-string", "foo", "--boolean-and-number-and-string", "bar"], @@ -1469,24 +1366,22 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], description: "description", multiple: true, }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: ["foo", 12], }); }, - ); + }); command.parseAsync( ["--boolean-and-number-and-string", "foo", "--boolean-and-number-and-string", "12"], @@ -1499,11 +1394,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], @@ -1511,13 +1404,13 @@ describe("CLI API", () => { multiple: true, defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: "default", }); }, - ); + }); command.parseAsync([], { from: "user" }); }); @@ -1527,11 +1420,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], @@ -1539,13 +1430,13 @@ describe("CLI API", () => { multiple: true, defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: ["foo"], }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "foo"], { from: "user", @@ -1557,11 +1448,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], @@ -1569,13 +1458,13 @@ describe("CLI API", () => { multiple: true, defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: [12], }); }, - ); + }); command.parseAsync(["--boolean-and-number-and-string", "12"], { from: "user", @@ -1587,11 +1476,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean-and-number-and-string", type: [Boolean, Number, String], @@ -1599,13 +1486,13 @@ describe("CLI API", () => { multiple: true, defaultValue: "default", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ booleanAndNumberAndString: ["foo", 12], }); }, - ); + }); command.parseAsync( ["--boolean-and-number-and-string", "foo", "--boolean-and-number-and-string", "12"], @@ -1618,21 +1505,19 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "unknown", type: [Boolean, Symbol], description: "description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ unknown: "foo" }); }, - ); + }); command.parseAsync(["--unknown", "foo"], { from: "user" }); }); @@ -1642,26 +1527,24 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, description: "Description", negatedDescription: "Negated description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: true }); }, - ); + }); command.parseAsync(["--boolean"], { from: "user" }); - expect(command.helpInformation()).toContain("--boolean Description"); + expect(command.helpInformation()).toContain("--boolean Description"); }); it("should make command with Boolean option and negative value and use negatedDescription", async () => { @@ -1669,11 +1552,9 @@ describe("CLI API", () => { cli.program.commands = []; - const command = await cli.makeCommand( - { - name: "command", - }, - [ + const command = await cli.makeCommand({ + name: "command", + options: [ { name: "boolean", type: Boolean, @@ -1681,44 +1562,15 @@ describe("CLI API", () => { negative: true, negatedDescription: "Negated description", }, - ], - (options) => { + ].flatMap(cli.makeOption.bind(cli)), + action: (options) => { expect(options).toEqual({ boolean: false }); }, - ); + }); command.parseAsync(["--no-boolean"], { from: "user" }); expect(command.helpInformation()).toContain("--no-boolean Negated description"); }); }); - - describe("custom help output", () => { - let consoleSpy; - let exitSpy; - - beforeEach(async () => { - consoleSpy = jest.spyOn(globalThis.console, "log"); - exitSpy = jest.spyOn(process, "exit").mockImplementation(() => {}); - - await new Promise((resolve, reject) => { - try { - cli.run(["help", "--mode"], { from: "user" }); - resolve(); - } catch (error) { - reject(error); - } - }); - }); - - afterEach(async () => { - consoleSpy.mockRestore(); - exitSpy.mockRestore(); - }); - - it("should display help information", () => { - expect(exitSpy).toHaveBeenCalledWith(0); - expect(consoleSpy.mock.calls).toMatchSnapshot(); - }); - }); }); diff --git a/test/api/__snapshots__/CLI.test.js.snap.webpack5 b/test/api/__snapshots__/CLI.test.js.snap.webpack5 deleted file mode 100644 index 1416f8f80b0..00000000000 --- a/test/api/__snapshots__/CLI.test.js.snap.webpack5 +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing - -exports[`CLI API custom help output should display help information 1`] = ` -[ - [ - "Usage: webpack --mode ", - ], - [ - "Description: Enable production optimizations or development hints.", - ], - [ - "Possible values: 'development' | 'production' | 'none'", - ], - [ - "", - ], - [ - "To see list of all supported commands and options run 'webpack --help=verbose'. -", - ], - [ - "Webpack documentation: https://webpack.js.org/.", - ], - [ - "CLI documentation: https://webpack.js.org/api/cli/.", - ], - [ - "Made with ♥ by the webpack team.", - ], -] -`; diff --git a/test/build/basic/basic.test.js b/test/build/basic/basic.test.js index 92033d98ba3..669cd055bb4 100644 --- a/test/build/basic/basic.test.js +++ b/test/build/basic/basic.test.js @@ -173,8 +173,8 @@ describe("bundle command", () => { const { exitCode, stderr, stdout } = await run(__dirname, ["buil"]); expect(exitCode).toBe(2); - expect(stderr).toContain("Unknown command or entry 'buil'"); - expect(stderr).toContain("Did you mean 'build' (alias 'bundle, b')?"); + expect(stderr).toContain("Unknown command 'buil'"); + expect(stderr).toContain("(Did you mean build?)"); expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); expect(stdout).toBeFalsy(); }); diff --git a/test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 b/test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 index 7ccf7eb98f1..b80b4fd1360 100644 --- a/test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 +++ b/test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 @@ -37,7 +37,6 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag #2: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--output-fileneme' -[webpack-cli] Did you mean '--output-filename'? [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -45,8 +44,6 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag #3: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--output-library-auxiliary-comment-commnjs' -[webpack-cli] Did you mean '--output-library-auxiliary-comment-commonjs'? -[webpack-cli] Did you mean '--output-library-auxiliary-comment-commonjs2'? [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -54,7 +51,7 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "b" command: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--entyr' -[webpack-cli] Did you mean '--entry'? +(Did you mean --entry?) [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -62,7 +59,7 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "bundle" command: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--entyr' -[webpack-cli] Did you mean '--entry'? +(Did you mean --entry?) [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -70,7 +67,6 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "i" command: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--outpyt' -[webpack-cli] Did you mean '--output'? [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -78,7 +74,6 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag using "info" command: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--outpyt' -[webpack-cli] Did you mean '--output'? [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -86,7 +81,7 @@ exports[`unknown behaviour should log an error if an unknown flag is passed and exports[`unknown behaviour should log an error if an unknown flag is passed and suggests the closest match to an unknown flag: stderr 1`] = ` "[webpack-cli] Error: Unknown option '--entyr' -[webpack-cli] Did you mean '--entry'? +(Did you mean --entry?) [webpack-cli] Run 'webpack --help' to see available commands and options" `; @@ -135,16 +130,17 @@ exports[`unknown behaviour should log an error if an unknown flag is passed: std exports[`unknown behaviour should log an error if an unknown flag is passed: stdout 1`] = `""`; exports[`unknown behaviour should log error and provide suggestion if an unknown command passed: stderr 1`] = ` -"[webpack-cli] Unknown command or entry 'serverr' -[webpack-cli] Did you mean 'serve' (alias 'server, s')? +"[webpack-cli] Error: Unknown command 'serverr' +(Did you mean server?) [webpack-cli] Run 'webpack --help' to see available commands and options" `; exports[`unknown behaviour should log error and provide suggestion if an unknown command passed: stdout 1`] = `""`; exports[`unknown behaviour should log error and respect --color flag: stderr 1`] = ` -"[webpack-cli] Error: Unknown option '--unknown' -[webpack-cli] Run 'webpack --help' to see available commands and options" +"[webpack-cli] Error: Unknown option '--unknown' +[webpack-cli] Run 'webpack --help' to see available commands and options +" `; exports[`unknown behaviour should log error and respect --color flag: stdout 1`] = `""`; @@ -157,7 +153,7 @@ exports[`unknown behaviour should log error for unknown flag and respect --no-co exports[`unknown behaviour should log error for unknown flag and respect --no-color: stdout 1`] = `""`; exports[`unknown behaviour should log error if an unknown command passed: stderr 1`] = ` -"[webpack-cli] Unknown command or entry 'qqq' +"[webpack-cli] Error: Unknown command 'qqq' [webpack-cli] Run 'webpack --help' to see available commands and options" `; diff --git a/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 deleted file mode 100644 index 963ffb8c730..00000000000 --- a/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 +++ /dev/null @@ -1,1538 +0,0 @@ -// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing - -exports[`help should log error for invalid command using command syntax #3: stderr 1`] = ` -"[webpack-cli] Incorrect use of help -[webpack-cli] Please use: 'webpack help [command] [option]' | 'webpack [command] --help' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for invalid command using command syntax #3: stdout 1`] = `""`; - -exports[`help should log error for invalid command using command syntax #4: stderr 1`] = ` -"[webpack-cli] Incorrect use of help -[webpack-cli] Please use: 'webpack help [command] [option]' | 'webpack [command] --help' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for invalid command using command syntax #4: stdout 1`] = `""`; - -exports[`help should log error for invalid command using the "--help" option #2: stderr 1`] = ` -"[webpack-cli] Incorrect use of help -[webpack-cli] Please use: 'webpack help [command] [option]' | 'webpack [command] --help' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for invalid command using the "--help" option #2: stdout 1`] = `""`; - -exports[`help should log error for invalid command using the "--help" option #3: stderr 1`] = ` -"[webpack-cli] Incorrect use of help -[webpack-cli] Please use: 'webpack help [command] [option]' | 'webpack [command] --help' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for invalid command using the "--help" option #3: stdout 1`] = `""`; - -exports[`help should log error for invalid command using the "--help" option: stderr 1`] = `"[webpack-cli] Unknown value for '--help' option, please use '--help=verbose'"`; - -exports[`help should log error for invalid command using the "--help" option: stdout 1`] = `""`; - -exports[`help should log error for invalid flag with the "--help" option #2: stderr 1`] = `"[webpack-cli] Unknown value for '--help' option, please use '--help=verbose'"`; - -exports[`help should log error for invalid flag with the "--help" option #2: stdout 1`] = `""`; - -exports[`help should log error for invalid flag with the "--help" option #3 1`] = `"[webpack-cli] Unknown value for '--help' option, please use '--help=verbose'"`; - -exports[`help should log error for invalid flag with the "--help" option: stderr 1`] = ` -"[webpack-cli] Incorrect use of help -[webpack-cli] Please use: 'webpack help [command] [option]' | 'webpack [command] --help' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for invalid flag with the "--help" option: stdout 1`] = `""`; - -exports[`help should log error for unknown command using command syntax #2: stderr 1`] = ` -"[webpack-cli] Can't find and load command 'verbose' -[webpack-cli] Run 'webpack --help' to see available commands and options." -`; - -exports[`help should log error for unknown command using command syntax #2: stdout 1`] = `""`; - -exports[`help should log error for unknown command using command syntax: stderr 1`] = ` -"[webpack-cli] Can't find and load command 'myCommand' -[webpack-cli] Run 'webpack --help' to see available commands and options." -`; - -exports[`help should log error for unknown command using command syntax: stdout 1`] = `""`; - -exports[`help should log error for unknown option using command syntax #2: stderr 1`] = ` -"[webpack-cli] Unknown option '--made' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for unknown option using command syntax #2: stdout 1`] = `""`; - -exports[`help should log error for unknown option using command syntax #3: stderr 1`] = ` -"[webpack-cli] Unknown option '--made' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for unknown option using command syntax #3: stdout 1`] = `""`; - -exports[`help should log error for unknown option using command syntax #4: stderr 1`] = ` -"[webpack-cli] Can't find and load command 'bui' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`help should log error for unknown option using command syntax #4: stdout 1`] = `""`; - -exports[`help should show help information and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information and respect the "--color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information and respect the "--no-color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information and taking precedence when "--help" and "--version" option using together: stderr 1`] = `""`; - -exports[`help should show help information and taking precedence when "--help" and "--version" option using together: stdout 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'b' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'b' command using command syntax: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'b' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'b' command using the "--help" option: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'build' and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'build' and respect the "--color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'build' and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'build' and respect the "--no-color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'build' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'build' command using command syntax: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'build' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'build' command using the "--help" option: stdout 1`] = ` -"Usage: webpack build|bundle|b [entries...] [options] - -Run webpack (default command, can be omitted). - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'configtest' and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'configtest' and respect the "--color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'configtest' and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'configtest' and respect the "--no-color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'configtest' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'configtest' command using command syntax: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'configtest' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'configtest' command using the "--help" option: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'i' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'i' command using command syntax: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'i' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'i' command using the "--help" option: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'info' and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'info' and respect the "--color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'info' and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'info' and respect the "--no-color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'info' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'info' command using command syntax: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'info' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'info' command using the "--help" option: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 's' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 's' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'serve' and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'serve' and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'serve' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'serve' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'server' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'server' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 't' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 't' command using command syntax: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 't' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 't' command using the "--help" option: stdout 1`] = ` -"Usage: webpack configtest|t [config-path] - -Validate a webpack configuration. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'w' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'w' command using command syntax: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'w' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'w' command using the "--help" option: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'watch' and respect the "--color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'watch' and respect the "--color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'watch' and respect the "--no-color" flag using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'watch' and respect the "--no-color" flag using the "--help" option: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'watch' command using command syntax: stderr 1`] = `""`; - -exports[`help should show help information for 'watch' command using command syntax: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information for 'watch' command using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information for 'watch' command using the "--help" option: stdout 1`] = ` -"Usage: webpack watch|w [entries...] [options] - -Run webpack and watch for files changes. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using command syntax: stderr 1`] = `""`; - -exports[`help should show help information using command syntax: stdout 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "--help" option: stderr 1`] = `""`; - -exports[`help should show help information using the "--help" option: stdout 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --cache-type" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --cache-type" option: stdout 1`] = ` -"Usage: webpack --cache-type -Description: In memory caching. Filesystem caching. -Possible values: 'memory' | 'filesystem' - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --color" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --color" option: stdout 1`] = ` -"Usage: webpack --color -Description: Enable colors on console. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --mode" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --mode" option: stdout 1`] = ` -"Usage: webpack --mode -Description: Enable production optimizations or development hints. -Possible values: 'development' | 'production' | 'none' - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --no-color" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --no-color" option: stdout 1`] = ` -"Usage: webpack --no-color -Description: Disable colors on console. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --no-stats" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --no-stats" option: stdout 1`] = ` -"Usage: webpack --no-stats -Description: Negative 'stats' option. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --output-chunk-format" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --output-chunk-format" option: stdout 1`] = ` -"Usage: webpack --output-chunk-format -Description: The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), 'module' (ESM), but others might be added by plugins). -Possible values: 'array-push' | 'commonjs' | 'module' | false - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --stats" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --stats" option: stdout 1`] = ` -"Usage: webpack --stats [value] -Description: Stats options object or preset name. -Possible values: 'none' | 'summary' | 'errors-only' | 'errors-warnings' | 'minimal' | 'normal' | 'detailed' | 'verbose' - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --target" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --target" option: stdout 1`] = ` -"Usage: webpack --target -Short: webpack -t -Description: Environment to build for. Environment to build for. An array of environments to build for all of them when possible. -Possible values: false - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help --version" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help --version" option: stdout 1`] = ` -"Usage: webpack --version -Short: webpack -v -Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help -v" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help -v" option: stdout 1`] = ` -"Usage: webpack --version -Short: webpack -v -Description: Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help serve --color" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help serve --color" option: stdout 1`] = ` -"Usage: webpack serve --color -Description: Enable colors on console. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help serve --mode" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help serve --mode" option: stdout 1`] = ` -"Usage: webpack serve --mode -Description: Enable production optimizations or development hints. -Possible values: 'development' | 'production' | 'none' - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information using the "help serve --no-color" option: stderr 1`] = `""`; - -exports[`help should show help information using the "help serve --no-color" option: stdout 1`] = ` -"Usage: webpack serve --no-color -Description: Disable colors on console. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show help information with options for sub commands: stderr 1`] = `""`; - -exports[`help should show help information with options for sub commands: stdout 1`] = ` -"Usage: webpack info|i [options] - -Outputs information about your system. - -Options: - -o, --output To get the output in a specified format ( accept json or markdown ) - -a, --additional-package Adds additional packages to the output - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show the same information using the "--help" option and command syntax: stderr from command syntax 1`] = `""`; - -exports[`help should show the same information using the "--help" option and command syntax: stderr from option 1`] = `""`; - -exports[`help should show the same information using the "--help" option and command syntax: stdout from command syntax 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; - -exports[`help should show the same information using the "--help" option and command syntax: stdout from option 1`] = ` -"Usage: webpack [entries...] [options] -Alternative usage to run commands: webpack [command] [options] - -The build tool for modern web applications. - -Options: - -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". - --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --disable-interpret Disable interpret for loading the config file. - --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". - --node-env Sets process.env.NODE_ENV to the specified value for access within the configuration.(Deprecated: Use '--config-node-env' instead) - --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. - --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. - --progress [value] Print compilation progress during build. - -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. - --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. - -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). - --no-devtool Negative 'devtool' option. - --entry A module that is loaded upon startup. Only the last one is exported. - -e, --extends Path to the configuration to be extended (only works when using webpack-cli). - --mode Enable production optimizations or development hints. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path The output directory as **absolute path** (required). - --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. - -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. - -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. - -Global options: - --color Enable colors on console. - --no-color Disable colors on console. - -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - -h, --help [verbose] Display help for commands and options. - -Commands: - build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). - configtest|t [config-path] Validate a webpack configuration. - help|h [command] [option] Display help for commands and options. - info|i [options] Outputs information about your system. - serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. - version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. - watch|w [entries...] [options] Run webpack and watch for files changes. - -To see list of all supported commands and options run 'webpack --help=verbose'. - -Webpack documentation: https://webpack.js.org/. -CLI documentation: https://webpack.js.org/api/cli/. -Made with ♥ by the webpack team." -`; diff --git a/test/help/help.test.js b/test/help/help.test.js deleted file mode 100644 index dc6c9077e7e..00000000000 --- a/test/help/help.test.js +++ /dev/null @@ -1,432 +0,0 @@ -"use strict"; - -const { normalizeStderr, normalizeStdout, run } = require("../utils/test-utils"); - -describe("help", () => { - it('should show help information using the "--help" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should show help information using the "--help" option with the "verbose" value', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "verbose"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should show help information using the "--help" option with the "verbose" value #2', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help=verbose"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should show help information using command syntax", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show the same information using the "--help" option and command syntax', async () => { - const { - exitCode: exitCodeFromOption, - stderr: stderrFromOption, - stdout: stdoutFromOption, - } = await run(__dirname, ["--help"]); - const { - exitCode: exitCodeFromCommandSyntax, - stderr: stderrFromCommandSyntax, - stdout: stdoutFromCommandSyntax, - } = await run(__dirname, ["help"]); - - expect(exitCodeFromOption).toBe(0); - expect(exitCodeFromCommandSyntax).toBe(0); - expect(normalizeStderr(stderrFromOption)).toMatchSnapshot("stderr from option"); - expect(normalizeStderr(stderrFromCommandSyntax)).toMatchSnapshot("stderr from command syntax"); - expect(stdoutFromOption).toBe(stdoutFromCommandSyntax); - expect(normalizeStdout(stdoutFromOption)).toMatchSnapshot("stdout from option"); - expect(normalizeStdout(stdoutFromCommandSyntax)).toMatchSnapshot("stdout from command syntax"); - }); - - it('should show help information and respect the "--color" flag using the "--help" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "--color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).toContain("\u001B[1m"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information and respect the "--no-color" flag using the "--help" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "--no-color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - const commands = [ - { - name: "info", - alias: "i", - }, - { - name: "configtest", - alias: "t", - }, - { - name: "watch", - alias: "w", - }, - { - name: "serve", - alias: ["server", "s"], - }, - { - name: "build", - alias: "b", - }, - ]; - - for (const { name, alias } of commands) { - // TODO fix it - const needSkip = name === "serve"; - - it(`should show help information for '${name}' command using the "--help" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [name, "--help"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - // eslint-disable-next-line jest/no-disabled-tests - it.skip(`should show help information for '${name}' command using the "--help verbose" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [name, "--help", "verbose"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - it(`should show help information for '${name}' command using command syntax`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", name]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - it(`should show help information for '${name}' and respect the "--color" flag using the "--help" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [name, "--help", "--color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).toContain("\u001B[1m"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - it(`should show help information for '${name}' and respect the "--no-color" flag using the "--help" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [name, "--help", "--no-color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).not.toContain("\u001B[1m"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - const aliases = Array.isArray(alias) ? alias : [alias]; - - for (const alias of aliases) { - it(`should show help information for '${alias}' command using the "--help" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [alias, "--help"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - // eslint-disable-next-line jest/no-disabled-tests - it.skip(`should show help information for '${alias}' command using the "--help verbose" option`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [alias, "--help", "verbose"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - - it(`should show help information for '${alias}' command using command syntax`, async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", alias]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (!needSkip) { - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - } - }); - } - } - - it("should show help information with options for sub commands", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["info", "--help"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information and taking precedence when "--help" and "--version" option using together', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "--version"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --mode" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--mode"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --target" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--target"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --stats" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--stats"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --cache-type" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--cache-type"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --output-chunk-format" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--output-chunk-format"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --no-stats" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--no-stats"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help serve --mode" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "serve", "--mode"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --color" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).toContain("\u001B[1m"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --no-color" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--no-color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help serve --color" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "serve", "--color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).toContain("\u001B[1m"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help serve --no-color" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "serve", "--no-color"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help --version" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--version"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should show help information using the "help -v" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "-v"]); - - expect(exitCode).toBe(0); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid command using the "--help" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "myCommand"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid command using the "--help" option #2', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--flag", "--help"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid command using the "--help" option #3', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["serve", "--flag", "--help"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for unknown command using command syntax", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "myCommand"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for unknown command using command syntax #2", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "verbose"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for unknown option using command syntax #2", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--made"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for unknown option using command syntax #3", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "serve", "--made"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for unknown option using command syntax #4", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "bui", "--mode"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for invalid command using command syntax #3", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["help", "--mode", "serve"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it("should log error for invalid command using command syntax #4", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [ - "help", - "serve", - "--mode", - "--mode", - ]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid flag with the "--help" option', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "--my-flag"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid flag with the "--help" option #2', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help", "init", "info"]); - - expect(exitCode).toBe(2); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); - }); - - it('should log error for invalid flag with the "--help" option #3', async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--help="]); - - expect(exitCode).toBe(2); - expect(stderr).toMatchSnapshot(); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/version/additional-package.test.js b/test/version/additional-package.test.js deleted file mode 100644 index 27918b3c516..00000000000 --- a/test/version/additional-package.test.js +++ /dev/null @@ -1,95 +0,0 @@ -"use strict"; - -const { join } = require("node:path"); -const { run } = require("../utils/test-utils"); - -describe("'-a, --additional-package ' usage", () => { - it("should work with only one package", async () => { - const { exitCode, stdout, stderr } = await run(join(__dirname, "../../"), [ - "version", - "--additional-package", - "typescript", - ]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - expect(stdout).toContain("typescript"); - }); - - it("should work with only one package using '-a' alias", async () => { - const { exitCode, stdout, stderr } = await run(join(__dirname, "../../"), [ - "version", - "-a", - "typescript", - ]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - expect(stdout).toContain("typescript"); - }); - - it("should work with multiple packages", async () => { - const { exitCode, stdout, stderr } = await run(join(__dirname, "../../"), [ - "version", - "--additional-package", - "typescript", - "--additional-package", - "eslint", - ]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - expect(stdout).toContain("typescript"); - expect(stdout).toContain("eslint"); - expect(stdout).toContain("eslint-config-prettier"); - expect(stdout).toContain("eslint-plugin-n"); - }); - - it("should work with multiple packages using '-a' alias", async () => { - const { exitCode, stdout, stderr } = await run(join(__dirname, "../../"), [ - "version", - "-a", - "typescript", - "-a", - "eslint", - ]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - expect(stdout).toContain("typescript"); - expect(stdout).toContain("eslint"); - expect(stdout).toContain("eslint-config-prettier"); - expect(stdout).toContain("eslint-plugin-n"); - }); - - it("should throw an error on invalid usage", async () => { - const { exitCode, stdout, stderr } = await run(join(__dirname, "../../"), [ - "version", - "--additional-package", - ]); - - expect(exitCode).toBe(2); - expect(stderr).toContain("Option '-a, --additional-package ' argument missing"); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/version/basic.test.js b/test/version/basic.test.js deleted file mode 100644 index ebd01084e7b..00000000000 --- a/test/version/basic.test.js +++ /dev/null @@ -1,74 +0,0 @@ -const { join } = require("node:path"); -const { run } = require("../utils/test-utils"); - -describe("basic usage", () => { - it("should work", async () => { - const { exitCode, stdout, stderr } = await run(__dirname, ["version"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("should work with v alias", async () => { - const { exitCode, stdout, stderr } = await run(__dirname, ["v"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("should work with --version", async () => { - const { exitCode, stdout, stderr } = await run(__dirname, ["--version"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("should work with -v alias", async () => { - const { exitCode, stdout, stderr } = await run(__dirname, ["-v"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("should work and gets more info in project root", async () => { - const { exitCode, stderr, stdout } = await run(join(__dirname, "../../"), ["version"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Monorepos:"); - expect(stdout).toContain("Packages:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("shows an appropriate warning on supplying unknown args", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["version", "--unknown"]); - - expect(exitCode).toBe(2); - expect(stderr).toContain("Error: Unknown option '--unknown'"); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/version/output.test.js b/test/version/output.test.js deleted file mode 100644 index f22ab598b1d..00000000000 --- a/test/version/output.test.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -const { run } = require("../utils/test-utils"); - -describe("'-o, --output ' usage", () => { - it("gets info text by default", async () => { - const { exitCode, stdout, stderr } = await run(__dirname, ["version"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("System:"); - expect(stdout).toContain("Node"); - expect(stdout).toContain("npm"); - expect(stdout).toContain("Yarn"); - expect(stdout).toContain("pnpm"); - }); - - it("gets info as json", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["version", "--output=json"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('"System":'); - - const parse = () => { - const output = JSON.parse(stdout); - expect(output.System).toBeTruthy(); - expect(output.Binaries).toBeTruthy(); - expect(output.System.OS).toBeTruthy(); - expect(output.System.CPU).toBeTruthy(); - }; - - expect(parse).not.toThrow(); - }); - - it("gets info as markdown", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["version", "--output", "markdown"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("## System:"); - }); - - it("shows a warning if an invalid value is supplied", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["version", "--output", "unknown"]); - - expect(exitCode).toBe(2); - expect(stderr).toContain("'unknown' is not a valid value for output"); - expect(stdout).toBeFalsy(); - }); - - it("recognizes '-o' as an alias for '--output'", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["version", "-o", "markdown"]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toContain("## System:"); - }); -}); diff --git a/tsconfig.json b/tsconfig.json index 6893b2e9aff..a07a3706fc7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,15 +21,6 @@ "declaration": true }, "references": [ - { - "path": "packages/configtest" - }, - { - "path": "packages/info" - }, - { - "path": "packages/serve" - }, { "path": "packages/webpack-cli" },