Skip to content

Commit 5a9789d

Browse files
authored
feat: add create and new alias for init (#2616)
1 parent 7c2f5e7 commit 5a9789d

File tree

11 files changed

+641
-394
lines changed

11 files changed

+641
-394
lines changed

OPTIONS.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Options:
2121
--no-bail Negative 'bail' option.
2222
--cache Enable in memory caching. Disable caching.
2323
--no-cache Negative 'cache' option.
24+
--cache-max-generations <value> 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).
2425
--cache-type <value> In memory caching. Filesystem caching.
2526
--cache-cache-directory <value> Base directory for the cache (defaults to node_modules/.cache/webpack).
2627
--cache-cache-location <value> Locations for the cache (defaults to cacheDirectory / name).
@@ -31,6 +32,8 @@ Options:
3132
--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.
3233
--cache-managed-paths <value...> A path to a managed directory (usually a node_modules directory).
3334
--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.
35+
--cache-max-age <value> Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds).
36+
--cache-max-memory-generations <value> 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.
3437
--cache-name <value> Name for the cache. Different names will lead to different coexisting caches.
3538
--cache-store <value> When to store data to the filesystem. (pack: Store data when compiler is idle in a single file).
3639
--cache-version <value> 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:
8588
--ignore-warnings-message <value...> A RegExp to select the warning message.
8689
--ignore-warnings-module <value...> A RegExp to select the origin module for the warning.
8790
--ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings.
91+
--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.
92+
--no-infrastructure-logging-append-only Negative 'infrastructure-logging-append-only' option.
93+
--infrastructure-logging-colors Enables/Disables colorful output. This option is only used when no custom console is provided.
94+
--no-infrastructure-logging-colors Negative 'infrastructure-logging-colors' option.
8895
--infrastructure-logging-debug [value...] Enable/Disable debug logging for all loggers. Enable debug logging for specific loggers.
8996
--no-infrastructure-logging-debug Negative 'infrastructure-logging-debug' option.
9097
--infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific loggers.
@@ -103,12 +110,14 @@ Options:
103110
--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.
104111
--no-module-generator-asset-emit Negative 'module-generator-asset-emit' option.
105112
--module-generator-asset-filename <value> 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.
113+
--module-generator-asset-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
106114
--module-generator-asset-inline-data-url-encoding <value> Asset encoding (defaults to base64).
107115
--no-module-generator-asset-inline-data-url-encoding Negative 'module-generator-asset-inline-data-url-encoding' option.
108116
--module-generator-asset-inline-data-url-mimetype <value> Asset mimetype (getting from file extension by default).
109117
--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.
110118
--no-module-generator-asset-resource-emit Negative 'module-generator-asset-resource-emit' option.
111119
--module-generator-asset-resource-filename <value> 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.
120+
--module-generator-asset-resource-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
112121
--module-no-parse <value...> A regular expression, when matched the module is not parsed. An absolute path, when the module starts with this path it is not parsed.
113122
--module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's matched against the full resolved request.
114123
--module-parser-asset-data-url-condition-max-size <value> Maximum size of asset that should be inline as modules. Default: 8kb.
@@ -534,7 +543,7 @@ Options:
534543
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
535544
--output-pathinfo [value] Include comments with information about the modules.
536545
--no-output-pathinfo Negative 'output-pathinfo' option.
537-
--output-public-path <value> The `publicPath` specifies the public URL address of the output files when referenced in a browser.
546+
--output-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
538547
--output-script-type <value> This option enables loading async chunks via a custom script type, such as script type="module".
539548
--no-output-script-type Negative 'output-script-type' option.
540549
--output-source-map-filename <value> The filename of the SourceMaps for the JavaScript files. They are inside the 'output.path' directory.
@@ -774,6 +783,8 @@ Options:
774783
--no-stats-group-modules-by-layer Negative 'stats-group-modules-by-layer' option.
775784
--stats-group-modules-by-path Group modules by their path.
776785
--no-stats-group-modules-by-path Negative 'stats-group-modules-by-path' option.
786+
--stats-group-modules-by-type Group modules by their type.
787+
--no-stats-group-modules-by-type Negative 'stats-group-modules-by-type' option.
777788
--stats-hash Add the hash of the compilation.
778789
--no-stats-hash Negative 'stats-hash' option.
779790
--stats-ids Add ids.
@@ -858,7 +869,7 @@ Commands:
858869
configtest|t [config-path] Validate a webpack configuration.
859870
help|h [command] [option] Display help for commands and options.
860871
info|i [options] Outputs information about your system.
861-
init|c [generation-path] [options] Initialize a new webpack project.
872+
init|create|new|c|n [generation-path] [options] Initialize a new webpack project.
862873
loader|l [output-path] [options] Scaffold a loader.
863874
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
864875
plugin|p [output-path] [options] Scaffold a plugin.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"ts-jest": "^26.4.3",
8383
"ts-node": "^9.1.1",
8484
"typescript": "^4.1.3",
85-
"webpack": "^5.25.0",
85+
"webpack": "^5.31.2",
8686
"webpack-bundle-analyzer": "^4.3.0",
8787
"webpack-dev-server": "^3.11.1",
8888
"yeoman-test": "^2.7.0"

packages/generators/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GeneratorsCommand {
1212
await cli.makeCommand(
1313
{
1414
name: 'init [generation-path]',
15-
alias: 'c',
15+
alias: ['create', 'new', 'c', 'n'],
1616
description: 'Initialize a new webpack project.',
1717
usage: '[generation-path] [options]',
1818
pkg: '@webpack-cli/generators',

packages/webpack-cli/lib/webpack-cli.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class WebpackCLI {
2424

2525
async makeCommand(commandOptions, options, action) {
2626
const alreadyLoaded = this.program.commands.find(
27-
(command) => command.name() === commandOptions.name || command.aliases().includes(commandOptions.alias),
27+
(command) => command.name() === commandOptions.name.split(' ')[0] || command.aliases().includes(commandOptions.alias),
2828
);
2929

3030
if (alreadyLoaded) {
@@ -654,7 +654,7 @@ class WebpackCLI {
654654
},
655655
{
656656
name: 'init',
657-
alias: 'c',
657+
alias: ['create', 'new', 'c', 'n'],
658658
pkg: '@webpack-cli/generators',
659659
},
660660
{
@@ -711,7 +711,7 @@ class WebpackCLI {
711711
return false;
712712
};
713713
const findCommandByName = (name) =>
714-
this.program.commands.find((command) => name === command.name() || command.alias().includes(name));
714+
this.program.commands.find((command) => name === command.name() || command.aliases().includes(name));
715715
const isOption = (value) => value.startsWith('-');
716716
const isGlobalOption = (value) =>
717717
value === '--color' ||

0 commit comments

Comments
 (0)