From 5a9789db237b7696adfdc9826b0dda749fedfa9a Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 13 Apr 2021 16:26:27 +0530 Subject: [PATCH] feat: add `create` and `new` alias for `init` (#2616) --- OPTIONS.md | 15 +- package.json | 2 +- packages/generators/src/index.ts | 2 +- packages/webpack-cli/lib/webpack-cli.js | 6 +- .../__snapshots__/help.test.js.snap.webpack4 | 352 ++++++++--------- .../__snapshots__/help.test.js.snap.webpack5 | 362 +++++++++--------- test/help/help.test.js | 56 +-- .../__snapshots__/init.test.js.snap.webpack4 | 84 ++++ .../__snapshots__/init.test.js.snap.webpack5 | 84 ++++ test/init/init.test.js | 64 ++++ yarn.lock | 8 +- 11 files changed, 641 insertions(+), 394 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index d69cb2e2787..7af5a89d1d0 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -21,6 +21,7 @@ Options: --no-bail Negative 'bail' option. --cache Enable in memory caching. Disable caching. --no-cache Negative 'cache' option. + --cache-max-generations Number of generations unused cache entries stay in memory cache at minimum (1 = may be removed after unused for a single compilation, ..., Infinity: kept forever). --cache-type In memory caching. Filesystem caching. --cache-cache-directory Base directory for the cache (defaults to node_modules/.cache/webpack). --cache-cache-location Locations for the cache (defaults to cacheDirectory / name). @@ -31,6 +32,8 @@ Options: --cache-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable. --cache-managed-paths A path to a managed directory (usually a node_modules directory). --cache-managed-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and can be trusted to not be modified otherwise. + --cache-max-age Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds). + --cache-max-memory-generations Number of generations unused cache entries stay in memory cache at minimum (0 = no memory cache used, 1 = may be removed after unused for a single compilation, ..., Infinity: kept forever). Cache entries will be deserialized from disk when removed from memory cache. --cache-name Name for the cache. Different names will lead to different coexisting caches. --cache-store When to store data to the filesystem. (pack: Store data when compiler is idle in a single file). --cache-version Version of the cache data. Different versions won't allow to reuse the cache and override existing content. Update the version when config changed in a way which doesn't allow to reuse cache. This will invalidate the cache. @@ -85,6 +88,10 @@ Options: --ignore-warnings-message A RegExp to select the warning message. --ignore-warnings-module A RegExp to select the origin module for the warning. --ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings. + --infrastructure-logging-append-only Only appends lines to the output. Avoids updating existing output e. g. for status messages. This option is only used when no custom console is provided. + --no-infrastructure-logging-append-only Negative 'infrastructure-logging-append-only' option. + --infrastructure-logging-colors Enables/Disables colorful output. This option is only used when no custom console is provided. + --no-infrastructure-logging-colors Negative 'infrastructure-logging-colors' option. --infrastructure-logging-debug [value...] Enable/Disable debug logging for all loggers. Enable debug logging for specific loggers. --no-infrastructure-logging-debug Negative 'infrastructure-logging-debug' option. --infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific loggers. @@ -103,12 +110,14 @@ Options: --module-generator-asset-emit Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR. --no-module-generator-asset-emit Negative 'module-generator-asset-emit' option. --module-generator-asset-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. + --module-generator-asset-public-path The 'publicPath' specifies the public URL address of the output files when referenced in a browser. --module-generator-asset-inline-data-url-encoding Asset encoding (defaults to base64). --no-module-generator-asset-inline-data-url-encoding Negative 'module-generator-asset-inline-data-url-encoding' option. --module-generator-asset-inline-data-url-mimetype Asset mimetype (getting from file extension by default). --module-generator-asset-resource-emit Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR. --no-module-generator-asset-resource-emit Negative 'module-generator-asset-resource-emit' option. --module-generator-asset-resource-filename Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk. + --module-generator-asset-resource-public-path The 'publicPath' specifies the public URL address of the output files when referenced in a browser. --module-no-parse A regular expression, when matched the module is not parsed. An absolute path, when the module starts with this path it is not parsed. --module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's matched against the full resolved request. --module-parser-asset-data-url-condition-max-size Maximum size of asset that should be inline as modules. Default: 8kb. @@ -534,7 +543,7 @@ Options: -o, --output-path Output location of the file generated by webpack e.g. ./dist/. --output-pathinfo [value] Include comments with information about the modules. --no-output-pathinfo Negative 'output-pathinfo' option. - --output-public-path The `publicPath` specifies the public URL address of the output files when referenced in a browser. + --output-public-path The 'publicPath' specifies the public URL address of the output files when referenced in a browser. --output-script-type This option enables loading async chunks via a custom script type, such as script type="module". --no-output-script-type Negative 'output-script-type' option. --output-source-map-filename The filename of the SourceMaps for the JavaScript files. They are inside the 'output.path' directory. @@ -774,6 +783,8 @@ Options: --no-stats-group-modules-by-layer Negative 'stats-group-modules-by-layer' option. --stats-group-modules-by-path Group modules by their path. --no-stats-group-modules-by-path Negative 'stats-group-modules-by-path' option. + --stats-group-modules-by-type Group modules by their type. + --no-stats-group-modules-by-type Negative 'stats-group-modules-by-type' option. --stats-hash Add the hash of the compilation. --no-stats-hash Negative 'stats-hash' option. --stats-ids Add ids. @@ -858,7 +869,7 @@ Commands: 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. - init|c [generation-path] [options] Initialize a new webpack project. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. loader|l [output-path] [options] Scaffold a loader. migrate|m [new-config-path] Migrate a configuration to a new version. plugin|p [output-path] [options] Scaffold a plugin. diff --git a/package.json b/package.json index 0d21a118645..34c4f427517 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "ts-jest": "^26.4.3", "ts-node": "^9.1.1", "typescript": "^4.1.3", - "webpack": "^5.25.0", + "webpack": "^5.31.2", "webpack-bundle-analyzer": "^4.3.0", "webpack-dev-server": "^3.11.1", "yeoman-test": "^2.7.0" diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index 4d862c0cebe..5dabe85e05f 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -12,7 +12,7 @@ class GeneratorsCommand { await cli.makeCommand( { name: 'init [generation-path]', - alias: 'c', + alias: ['create', 'new', 'c', 'n'], description: 'Initialize a new webpack project.', usage: '[generation-path] [options]', pkg: '@webpack-cli/generators', diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index d080c9b6595..c31e7ae5d7b 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -24,7 +24,7 @@ class WebpackCLI { async makeCommand(commandOptions, options, action) { const alreadyLoaded = this.program.commands.find( - (command) => command.name() === commandOptions.name || command.aliases().includes(commandOptions.alias), + (command) => command.name() === commandOptions.name.split(' ')[0] || command.aliases().includes(commandOptions.alias), ); if (alreadyLoaded) { @@ -654,7 +654,7 @@ class WebpackCLI { }, { name: 'init', - alias: 'c', + alias: ['create', 'new', 'c', 'n'], pkg: '@webpack-cli/generators', }, { @@ -711,7 +711,7 @@ class WebpackCLI { return false; }; const findCommandByName = (name) => - this.program.commands.find((command) => name === command.name() || command.alias().includes(name)); + this.program.commands.find((command) => name === command.name() || command.aliases().includes(name)); const isOption = (value) => value.startsWith('-'); const isGlobalOption = (value) => value === '--color' || diff --git a/test/help/__snapshots__/help.test.js.snap.webpack4 b/test/help/__snapshots__/help.test.js.snap.webpack4 index 7827dfe8b5d..f91ae795a8c 100644 --- a/test/help/__snapshots__/help.test.js.snap.webpack4 +++ b/test/help/__snapshots__/help.test.js.snap.webpack4 @@ -66,45 +66,45 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - --entry The entry point(s) of your application e.g. ./src/main.js. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - -t, --target Sets the build target e.g. node. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -120,45 +120,45 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - --entry The entry point(s) of your application e.g. ./src/main.js. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - -t, --target Sets the build target e.g. node. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -174,45 +174,45 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - --entry The entry point(s) of your application e.g. ./src/main.js. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - -t, --target Sets the build target e.g. node. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -313,7 +313,7 @@ Made with ♥ by the webpack team." `; exports[`help should show help information for 'init' command using the "--help" option 1`] = ` -"Usage: webpack init|c [generation-path] [options] +"Usage: webpack init|create|new|c|n [generation-path] [options] Initialize a new webpack project. @@ -537,45 +537,45 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - --entry The entry point(s) of your application e.g. ./src/main.js. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - -t, --target Sets the build target e.g. node. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -591,45 +591,45 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - --entry The entry point(s) of your application e.g. ./src/main.js. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - -t, --target Sets the build target e.g. node. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + --entry The entry point(s) of your application e.g. ./src/main.js. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + -t, --target Sets the build target e.g. node. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. diff --git a/test/help/__snapshots__/help.test.js.snap.webpack5 b/test/help/__snapshots__/help.test.js.snap.webpack5 index 0c7e5b2000a..0d9920f5d56 100644 --- a/test/help/__snapshots__/help.test.js.snap.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.webpack5 @@ -66,46 +66,46 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + --no-target Negative 'target' option. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -121,46 +121,46 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + --no-target Negative 'target' option. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -176,46 +176,46 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + --no-target Negative 'target' option. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -317,7 +317,7 @@ Made with ♥ by the webpack team." `; exports[`help should show help information for 'init' command using the "--help" option 1`] = ` -"Usage: webpack init|c [generation-path] [options] +"Usage: webpack init|create|new|c|n [generation-path] [options] Initialize a new webpack project. @@ -543,46 +543,46 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + --no-target Negative 'target' option. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. @@ -598,46 +598,46 @@ Alternative usage to run commands: webpack [command] [options] The build tool for modern web applications. Options: - -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. - --config-name Name of the configuration to use. - -m, --merge Merge two or more configurations using 'webpack-merge'. - --env Environment passed to the configuration when it is a function. - --node-env Sets process.env.NODE_ENV to the specified value. - --progress [value] Print compilation progress during build. - -j, --json [value] Prints result as JSON or store it in a file. - -d, --devtool Determine source maps to use. - --no-devtool Do not generate source maps. - --entry The entry point(s) of your application e.g. ./src/main.js. - --mode Defines the mode to pass to webpack. - --name Name of the configuration. Used when loading multiple configurations. - -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --stats [value] It instructs webpack on how to treat the stats e.g. verbose. - --no-stats Disable stats output. - -t, --target Sets the build target e.g. node. - --no-target Negative 'target' option. - -w, --watch Watch for files changes. - --no-watch Do not watch for file changes. - --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Do not stop watching when stdin stream has ended. + -c, --config Provide path to a webpack configuration file e.g. ./webpack.config.js. + --config-name Name of the configuration to use. + -m, --merge Merge two or more configurations using 'webpack-merge'. + --env Environment passed to the configuration when it is a function. + --node-env Sets process.env.NODE_ENV to the specified value. + --progress [value] Print compilation progress during build. + -j, --json [value] Prints result as JSON or store it in a file. + -d, --devtool Determine source maps to use. + --no-devtool Do not generate source maps. + --entry The entry point(s) of your application e.g. ./src/main.js. + --mode Defines the mode to pass to webpack. + --name Name of the configuration. Used when loading multiple configurations. + -o, --output-path Output location of the file generated by webpack e.g. ./dist/. + --stats [value] It instructs webpack on how to treat the stats e.g. verbose. + --no-stats Disable stats output. + -t, --target Sets the build target e.g. node. + --no-target Negative 'target' option. + -w, --watch Watch for files changes. + --no-watch Do not watch for file changes. + --watch-options-stdin Stop watching when stdin stream has ended. + --no-watch-options-stdin Do not stop watching when stdin stream has ended. 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. + --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. - init|c [generation-path] [options] Initialize a new webpack project. - loader|l [output-path] [options] Scaffold a loader. - migrate|m [new-config-path] Migrate a configuration to a new version. - plugin|p [output-path] [options] Scaffold a plugin. - serve|s [entries...] [options] Run the webpack dev server. - version|v [commands...] 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. + 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. + init|create|new|c|n [generation-path] [options] Initialize a new webpack project. + loader|l [output-path] [options] Scaffold a loader. + migrate|m [new-config-path] Migrate a configuration to a new version. + plugin|p [output-path] [options] Scaffold a plugin. + serve|s [entries...] [options] Run the webpack dev server. + version|v [commands...] 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'. diff --git a/test/help/help.test.js b/test/help/help.test.js index 514a275a666..91e4aeab84d 100644 --- a/test/help/help.test.js +++ b/test/help/help.test.js @@ -73,8 +73,8 @@ describe('help', () => { const commands = [ { name: 'init', - alias: 'c', - usage: 'webpack init|c [generation-path] [options]', + alias: ['create', 'new', 'c', 'n'], + usage: 'webpack init|create|new|c|n [generation-path] [options]', }, { name: 'info', @@ -144,30 +144,6 @@ describe('help', () => { expect(stdout).toContain(usage); }); - 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(stderr).toBeFalsy(); - expect(stdout).toContain(usage); - }); - - it(`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(stderr).toBeFalsy(); - expect(stdout).toContain(usage); - }); - - 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(stderr).toBeFalsy(); - expect(stdout).toContain(usage); - }); - 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'], { env: { FORCE_COLOR: true } }); @@ -187,6 +163,34 @@ describe('help', () => { expect(stdout).toContain(usage); expect(stdout).toContain('Made with ♥ by the webpack team'); }); + + const alises = Array.isArray(alias) ? alias : [alias]; + + alises.forEach((alias) => { + 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(stderr).toBeFalsy(); + expect(stdout).toContain(usage); + }); + + it(`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(stderr).toBeFalsy(); + expect(stdout).toContain(usage); + }); + + 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(stderr).toBeFalsy(); + expect(stdout).toContain(usage); + }); + }); }); it('should show help information with options for sub commands', async () => { diff --git a/test/init/__snapshots__/init.test.js.snap.webpack4 b/test/init/__snapshots__/init.test.js.snap.webpack4 index 6cc10a447af..517d882758f 100644 --- a/test/init/__snapshots__/init.test.js.snap.webpack4 +++ b/test/init/__snapshots__/init.test.js.snap.webpack4 @@ -365,6 +365,90 @@ module.exports = { " `; +exports[`init command should should work with 'c' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'create' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'n' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'new' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + exports[`init command should use less in project when selected 1`] = ` Object { "description": "My webpack project", diff --git a/test/init/__snapshots__/init.test.js.snap.webpack5 b/test/init/__snapshots__/init.test.js.snap.webpack5 index 6cc10a447af..517d882758f 100644 --- a/test/init/__snapshots__/init.test.js.snap.webpack5 +++ b/test/init/__snapshots__/init.test.js.snap.webpack5 @@ -365,6 +365,90 @@ module.exports = { " `; +exports[`init command should should work with 'c' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'create' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'n' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + +exports[`init command should should work with 'new' alias 1`] = ` +Object { + "description": "My webpack project", + "devDependencies": Object { + "html-webpack-plugin": "x.x.x", + "webpack": "x.x.x", + "webpack-cli": "x.x.x", + "webpack-dev-server": "x.x.x", + }, + "name": "my-webpack-project", + "scripts": Object { + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "serve": "webpack serve", + "watch": "webpack --watch", + }, + "version": "1.0.0", +} +`; + exports[`init command should use less in project when selected 1`] = ` Object { "description": "My webpack project", diff --git a/test/init/init.test.js b/test/init/init.test.js index 706f34fe766..d57c24c95bf 100644 --- a/test/init/init.test.js +++ b/test/init/init.test.js @@ -380,4 +380,68 @@ describe('init command', () => { expect(exitCode).toBe(2); expect(stderr).toContain('Failed to create directory'); }); + + it("should should work with 'new' alias", async () => { + const assetsPath = await uniqueDirectoryForTest(rootAssetsPath); + const { stdout, stderr } = await run(assetsPath, ['new', '--force']); + expect(stdout).toContain('Project has been initialised with webpack!'); + expect(stderr).toContain('webpack.config.js'); + + // Test files + const files = ['package.json', 'src', 'src/index.js', 'webpack.config.js']; + files.forEach((file) => { + expect(existsSync(resolve(assetsPath, file))).toBeTruthy(); + }); + + // Check if the generated package.json file content matches the snapshot + expect(readFromPkgJSON(assetsPath)).toMatchSnapshot(); + }); + + it("should should work with 'create' alias", async () => { + const assetsPath = await uniqueDirectoryForTest(rootAssetsPath); + const { stdout, stderr } = await run(assetsPath, ['create', '--force']); + expect(stdout).toContain('Project has been initialised with webpack!'); + expect(stderr).toContain('webpack.config.js'); + + // Test files + const files = ['package.json', 'src', 'src/index.js', 'webpack.config.js']; + files.forEach((file) => { + expect(existsSync(resolve(assetsPath, file))).toBeTruthy(); + }); + + // Check if the generated package.json file content matches the snapshot + expect(readFromPkgJSON(assetsPath)).toMatchSnapshot(); + }); + + it("should should work with 'c' alias", async () => { + const assetsPath = await uniqueDirectoryForTest(rootAssetsPath); + const { stdout, stderr } = await run(assetsPath, ['c', '--force']); + expect(stdout).toContain('Project has been initialised with webpack!'); + expect(stderr).toContain('webpack.config.js'); + + // Test files + const files = ['package.json', 'src', 'src/index.js', 'webpack.config.js']; + files.forEach((file) => { + expect(existsSync(resolve(assetsPath, file))).toBeTruthy(); + }); + + // Check if the generated package.json file content matches the snapshot + expect(readFromPkgJSON(assetsPath)).toMatchSnapshot(); + }); + + it("should should work with 'n' alias", async () => { + const assetsPath = await uniqueDirectoryForTest(rootAssetsPath); + const { stdout, stderr } = await run(assetsPath, ['n', '--force']); + expect(stdout).toContain('Project has been initialised with webpack!'); + expect(stderr).toContain('webpack.config.js'); + + // Test files + const files = ['package.json', 'src', 'src/index.js', 'webpack.config.js']; + files.forEach((file) => { + expect(existsSync(resolve(assetsPath, file))).toBeTruthy(); + }); + + // Check if the generated package.json file content matches the snapshot + expect(readFromPkgJSON(assetsPath)).toMatchSnapshot(); + }); }); diff --git a/yarn.lock b/yarn.lock index 85978b0afc4..a6d48c86c25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10967,10 +10967,10 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.25.0: - version "5.31.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.31.0.tgz#fab61d0be896feca4af87bdad5c18815c0d63455" - integrity sha512-3fUfZT/FUuThWSSyL32Fsh7weUUfYP/Fjc/cGSbla5KiSo0GtI1JMssCRUopJTvmLjrw05R2q7rlLtiKdSzkzQ== +webpack@^5.31.2: + version "5.31.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.31.2.tgz#40d9b9d15b7d76af73d3f1cae895b82613a544d6" + integrity sha512-0bCQe4ybo7T5Z0SC5axnIAH+1WuIdV4FwLYkaAlLtvfBhIx8bPS48WHTfiRZS1VM+pSiYt7e/rgLs3gLrH82lQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.46"