-
-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(webpack-cli): verbose and stats verbose flag fixed (rebase) #1461
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12cc455
fix(webpack-cli): verbose and stats verbose flag fixed
aman29271 e5dd3bc
tests(webpack-cli): add test for stats option
aman29271 bbd38c2
Merge branch 'next' of https://github.com/aman29271/webpack-cli into …
aman29271 50fdd2d
Merge branch 'next' of https://github.com/webpack/webpack-cli into next
aman29271 68916a3
tests: add tests for stats
aman29271 aee164c
feat: add help cli more documented
aman29271 e56a4e4
Merge remote-tracking branch 'upstream/next' into next
aman29271 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,12 @@ const ADVANCED_GROUP = 'advanced'; | |
const DISPLAY_GROUP = 'stats'; | ||
const ZERO_CONFIG_GROUP = 'zero-config'; | ||
|
||
function acceptedString(arr) { | ||
return `Accepted Value: ${arr.join(' | ')}`; | ||
} | ||
function descriptionGenerator(example, shortDesc, acceptedValue = []) { | ||
return `\n\n Example: ${example}\n\n ${acceptedValue.length > 0 ? acceptedString(acceptedValue) : ''}\n\n${shortDesc}`; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was fix, not a new feature, do not mix fixes and features, you need to do it in difference PRs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. On it... |
||
module.exports = { | ||
groups: { | ||
HELP_GROUP, | ||
|
@@ -79,7 +85,11 @@ module.exports = { | |
type: String, | ||
defaultOption: true, | ||
group: BASIC_GROUP, | ||
description: 'The entry point of your application.', | ||
shortDesc: 'The entry point of your application.', | ||
description: descriptionGenerator( | ||
'webpack --entry index.js', | ||
'It is the entry point of your application. You can provide multiple entry points also.', | ||
), | ||
link: 'https://webpack.js.org/concepts/#entry', | ||
}, | ||
{ | ||
|
@@ -89,7 +99,11 @@ module.exports = { | |
type: String, | ||
defaultValue: null, | ||
group: CONFIG_GROUP, | ||
description: 'Provide path to a webpack configuration file', | ||
shortDesc: 'Provide path to a webpack configuration file', | ||
description: descriptionGenerator( | ||
'webpack-cli --config ./webpack.config.js', | ||
'It provides path to a webpack configuration file', | ||
), | ||
link: 'https://webpack.js.org/configuration/', | ||
}, | ||
{ | ||
|
@@ -136,15 +150,17 @@ module.exports = { | |
alias: 'o', | ||
group: OUTPUT_GROUP, | ||
type: String, | ||
description: 'Output location of the file generated by webpack', | ||
shortDesc: 'Output location of the file generated by webpack', | ||
description: descriptionGenerator('webpack --output ./a.js', 'Output location to the file generated by webpack'), | ||
link: 'https://webpack.js.org/concepts/#output', | ||
}, | ||
{ | ||
name: 'plugin', | ||
usage: '--plugin', | ||
usage: '--plugin <plugin name> e.g. HtmlWebpackPlugin', | ||
group: ADVANCED_GROUP, | ||
type: String, | ||
description: 'Load a given plugin', | ||
shortDesc: 'Load a given plugin', | ||
description: descriptionGenerator('webpack --plugin ExtractTextWebpackPlugin', 'Load a plugin '), | ||
link: 'https://webpack.js.org/plugins/', | ||
}, | ||
{ | ||
|
@@ -162,7 +178,17 @@ module.exports = { | |
alias: 't', | ||
type: String, | ||
group: ADVANCED_GROUP, | ||
description: 'Sets the build target', | ||
shortDesc: 'Sets the build target', | ||
description: descriptionGenerator('webpack --target node ', 'Instructs webpack to target a specific environment.', [ | ||
'async-node', | ||
'electron-main', | ||
'electron-renderer', | ||
'electron-preload', | ||
'node', | ||
'node-webkit', | ||
'web', | ||
'webworker', | ||
]), | ||
link: 'https://webpack.js.org/configuration/target/#target', | ||
}, | ||
{ | ||
|
@@ -272,14 +298,19 @@ module.exports = { | |
name: 'stats', | ||
usage: '--stats verbose', | ||
type: (value) => { | ||
if (StatsGroup.validOptions().includes(value)) { | ||
if (StatsGroup.validOptions().validArrayString.includes(value)) { | ||
return value; | ||
} | ||
logger.warn('No value recognised for "stats" option'); | ||
return 'normal'; | ||
}, | ||
group: DISPLAY_GROUP, | ||
description: 'It instructs webpack on how to treat the stats', | ||
shortDesc: 'It instructs webpack on how to treat the stats', | ||
description: descriptionGenerator( | ||
'npx webpack-cli --stats verbose', | ||
'These options instructs webpack on how to treat the stats.', | ||
StatsGroup.validOptions().validArrayString, | ||
), | ||
link: 'https://webpack.js.org/configuration/stats/#stats', | ||
}, | ||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need it here? We don't support objects in webpack-cli
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used that for tests. It deals with when a user provide
--stats verbose --verbose
both flags together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put it in tests - you can sue mocking