Skip to content

Commit

Permalink
fix: show all CLI specific flags in the minimum help output (#3354)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored and alexander-akait committed Nov 15, 2022
1 parent 60b3020 commit 35843e8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 20 deletions.
33 changes: 13 additions & 20 deletions packages/webpack-cli/src/webpack-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,26 +698,6 @@ class WebpackCLI implements IWebpackCLI {
return this.builtInOptionsCache;
}

const minimumHelpFlags = [
"config",
"config-name",
"merge",
"disable-interpret",
"env",
"mode",
"watch",
"watch-options-stdin",
"stats",
"devtool",
"entry",
"target",
"progress",
"json",
"name",
"output-path",
"node-env",
];

const builtInFlags: WebpackCLIBuiltInFlag[] = [
// For configs
{
Expand Down Expand Up @@ -873,6 +853,19 @@ class WebpackCLI implements IWebpackCLI {
},
];

const minimumHelpFlags = [
...builtInFlags.map((flag) => flag.name),
"mode",
"watch",
"watch-options-stdin",
"stats",
"devtool",
"entry",
"target",
"name",
"output-path",
];

// 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/master/test/__snapshots__/Cli.test.js.snap
const coreArguments = Object.entries(this.webpack.cli.getArguments()).map(([flag, meta]) => {
Expand Down
46 changes: 46 additions & 0 deletions test/help/__snapshots__/help.test.js.snap.devServer4.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -157,8 +159,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -214,8 +218,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -270,8 +276,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -314,8 +322,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -361,8 +371,12 @@ Options:
--env <value...> Environment passed to the configuration when it is
a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get
bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false |
eval |
[inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
Expand Down Expand Up @@ -418,8 +432,12 @@ Options:
--env <value...> Environment passed to the configuration when it is
a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get
bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false |
eval |
[inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
Expand Down Expand Up @@ -472,8 +490,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -516,8 +536,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1494,8 +1516,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1536,8 +1560,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1581,8 +1607,12 @@ Options:
--env <value...> Environment passed to the configuration when it is
a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get
bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false |
eval |
[inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
Expand Down Expand Up @@ -1636,8 +1666,12 @@ Options:
--env <value...> Environment passed to the configuration when it is
a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get
bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false |
eval |
[inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
Expand Down Expand Up @@ -1688,8 +1722,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1730,8 +1766,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1773,8 +1811,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -1830,8 +1870,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -2077,8 +2119,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down Expand Up @@ -2132,8 +2176,10 @@ Options:
--disable-interpret Disable interpret a config file.
--env <value...> Environment passed to the configuration when it is a function.
--node-env <value> Sets process.env.NODE_ENV to the specified value.
--analyze It invokes webpack-bundle-analyzer plugin to get bundle information.
--progress [value] Print compilation progress during build.
-j, --json [value] 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 <value> A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map).
--no-devtool Negative 'devtool' option.
--entry <value...> A module that is loaded upon startup. Only the last one is exported.
Expand Down

0 comments on commit 35843e8

Please sign in to comment.