diff --git a/packages/generators/src/index.ts b/packages/generators/src/index.ts index 3e4a7289e30..3ac437b250e 100644 --- a/packages/generators/src/index.ts +++ b/packages/generators/src/index.ts @@ -26,6 +26,7 @@ class GeneratorsCommand { configs: [{ type: "string" }], description: "Type of template", defaultValue: "default", + helpLevel: "minimum", }, { name: "force", @@ -37,6 +38,7 @@ class GeneratorsCommand { }, ], description: "Generate without questions (ideally) using default answers", + helpLevel: "minimum", }, ], async (generationPath: string, options: InitOptions) => { @@ -76,6 +78,7 @@ class GeneratorsCommand { configs: [{ type: "string" }], description: "Type of template", defaultValue: "default", + helpLevel: "minimum", }, ], async (outputPath: string, options: LoaderOptions) => { @@ -115,6 +118,7 @@ class GeneratorsCommand { configs: [{ type: "string" }], description: "Type of template", defaultValue: "default", + helpLevel: "minimum", }, ], async (outputPath: string, options: PluginOptions) => { diff --git a/packages/webpack-cli/src/types.ts b/packages/webpack-cli/src/types.ts index b51d7e0485d..f74ebd1c2fa 100644 --- a/packages/webpack-cli/src/types.ts +++ b/packages/webpack-cli/src/types.ts @@ -144,12 +144,12 @@ interface WebpackCLIBuiltInFlag { describe?: string; negatedDescription?: string; defaultValue?: string; + helpLevel: "minimum" | "verbose"; } interface WebpackCLIBuiltInOption extends WebpackCLIBuiltInFlag { hidden?: boolean; group?: "core"; - helpLevel?: "minimum" | "verbose"; } type WebpackCLIExternalCommandInfo = Pick & { diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 9ccde155c1c..fcb5e2ab6b9 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -388,6 +388,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "To get the output in a specified format ( accept json or markdown )", + helpLevel: "minimum", }, { name: "additional-package", @@ -395,6 +396,7 @@ class WebpackCLI implements IWebpackCLI { configs: [{ type: "string" }], multiple: true, description: "Adds additional packages to the output", + helpLevel: "minimum", }, ]; } @@ -810,6 +812,7 @@ class WebpackCLI implements IWebpackCLI { ], multiple: true, description: "Provide path to a webpack configuration file e.g. ./webpack.config.js.", + helpLevel: "minimum", }, { name: "config-name", @@ -820,6 +823,7 @@ class WebpackCLI implements IWebpackCLI { ], multiple: true, description: "Name of the configuration to use.", + helpLevel: "minimum", }, { name: "merge", @@ -831,6 +835,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Merge two or more configurations using 'webpack-merge'.", + helpLevel: "minimum", }, { name: "disable-interpret", @@ -841,6 +846,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Disable interpret for loading the config file.", + helpLevel: "minimum", }, // Complex configs { @@ -888,6 +894,7 @@ class WebpackCLI implements IWebpackCLI { }, multiple: true, description: "Environment passed to the configuration when it is a function.", + helpLevel: "minimum", }, { name: "node-env", @@ -898,6 +905,7 @@ class WebpackCLI implements IWebpackCLI { ], multiple: false, description: "Sets process.env.NODE_ENV to the specified value.", + helpLevel: "minimum", }, { name: "define-process-env-node-env", @@ -909,6 +917,7 @@ class WebpackCLI implements IWebpackCLI { multiple: false, description: "Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`)", + helpLevel: "minimum", }, // Adding more plugins @@ -922,6 +931,7 @@ class WebpackCLI implements IWebpackCLI { ], multiple: false, description: "It invokes webpack-bundle-analyzer plugin to get bundle information.", + helpLevel: "minimum", }, { name: "progress", @@ -935,6 +945,7 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Print compilation progress during build.", + helpLevel: "minimum", }, // Output options @@ -951,6 +962,7 @@ class WebpackCLI implements IWebpackCLI { ], alias: "j", description: "Prints result as JSON or store it in a file.", + helpLevel: "minimum", }, { name: "fail-on-warnings", @@ -961,11 +973,11 @@ class WebpackCLI implements IWebpackCLI { }, ], description: "Stop webpack-cli process with non-zero exit code on warnings from webpack", + helpLevel: "minimum", }, ]; const minimumHelpFlags = [ - ...builtInFlags.map((flag) => flag.name), "mode", "watch", "watch-options-stdin", @@ -979,37 +991,18 @@ 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 coreArguments = Object.entries(this.webpack.cli.getArguments()).map(([flag, meta]) => { - const inBuiltIn = builtInFlags.find((builtInFlag) => builtInFlag.name === flag); - - if (inBuiltIn) { - return { - ...meta, - // @ts-expect-error this might be overwritten - name: flag, - group: "core", - ...inBuiltIn, - configs: meta.configs || [], - }; - } - - return { ...meta, name: flag, group: "core" }; - }); - - const options: WebpackCLIBuiltInOption[] = ([] as WebpackCLIBuiltInFlag[]) - .concat( - builtInFlags.filter( - (builtInFlag) => - !coreArguments.find((coreArgument) => builtInFlag.name === coreArgument.name), - ), - ) - .concat(coreArguments) - .map((option): WebpackCLIBuiltInOption => { - (option as WebpackCLIBuiltInOption).helpLevel = minimumHelpFlags.includes(option.name) - ? "minimum" - : "verbose"; - return option as WebpackCLIBuiltInOption; - }); + const options = builtInFlags.concat( + Object.entries(this.webpack.cli.getArguments()).map( + ([name, meta]) => { + return { + ...meta, + name, + group: "core", + helpLevel: minimumHelpFlags.includes(name) ? "minimum" : "verbose", + }; + }, + ), + ); this.builtInOptionsCache = options; diff --git a/test/build/json/logging.config.js b/test/build/json/logging.config.js index f25deb4239c..d53a5228db5 100644 --- a/test/build/json/logging.config.js +++ b/test/build/json/logging.config.js @@ -1,4 +1,5 @@ module.exports = { + mode: "development", infrastructureLogging: { level: "log", },