@@ -388,13 +388,15 @@ class WebpackCLI implements IWebpackCLI {
388
388
} ,
389
389
] ,
390
390
description : "To get the output in a specified format ( accept json or markdown )" ,
391
+ helpLevel : "minimum" ,
391
392
} ,
392
393
{
393
394
name : "additional-package" ,
394
395
alias : "a" ,
395
396
configs : [ { type : "string" } ] ,
396
397
multiple : true ,
397
398
description : "Adds additional packages to the output" ,
399
+ helpLevel : "minimum" ,
398
400
} ,
399
401
] ;
400
402
}
@@ -810,6 +812,7 @@ class WebpackCLI implements IWebpackCLI {
810
812
] ,
811
813
multiple : true ,
812
814
description : "Provide path to a webpack configuration file e.g. ./webpack.config.js." ,
815
+ helpLevel : "minimum" ,
813
816
} ,
814
817
{
815
818
name : "config-name" ,
@@ -820,6 +823,7 @@ class WebpackCLI implements IWebpackCLI {
820
823
] ,
821
824
multiple : true ,
822
825
description : "Name of the configuration to use." ,
826
+ helpLevel : "minimum" ,
823
827
} ,
824
828
{
825
829
name : "merge" ,
@@ -831,6 +835,7 @@ class WebpackCLI implements IWebpackCLI {
831
835
} ,
832
836
] ,
833
837
description : "Merge two or more configurations using 'webpack-merge'." ,
838
+ helpLevel : "minimum" ,
834
839
} ,
835
840
{
836
841
name : "disable-interpret" ,
@@ -841,6 +846,7 @@ class WebpackCLI implements IWebpackCLI {
841
846
} ,
842
847
] ,
843
848
description : "Disable interpret for loading the config file." ,
849
+ helpLevel : "minimum" ,
844
850
} ,
845
851
// Complex configs
846
852
{
@@ -888,6 +894,7 @@ class WebpackCLI implements IWebpackCLI {
888
894
} ,
889
895
multiple : true ,
890
896
description : "Environment passed to the configuration when it is a function." ,
897
+ helpLevel : "minimum" ,
891
898
} ,
892
899
{
893
900
name : "node-env" ,
@@ -898,6 +905,7 @@ class WebpackCLI implements IWebpackCLI {
898
905
] ,
899
906
multiple : false ,
900
907
description : "Sets process.env.NODE_ENV to the specified value." ,
908
+ helpLevel : "minimum" ,
901
909
} ,
902
910
{
903
911
name : "define-process-env-node-env" ,
@@ -909,6 +917,7 @@ class WebpackCLI implements IWebpackCLI {
909
917
multiple : false ,
910
918
description :
911
919
"Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`)" ,
920
+ helpLevel : "minimum" ,
912
921
} ,
913
922
914
923
// Adding more plugins
@@ -922,6 +931,7 @@ class WebpackCLI implements IWebpackCLI {
922
931
] ,
923
932
multiple : false ,
924
933
description : "It invokes webpack-bundle-analyzer plugin to get bundle information." ,
934
+ helpLevel : "minimum" ,
925
935
} ,
926
936
{
927
937
name : "progress" ,
@@ -935,6 +945,7 @@ class WebpackCLI implements IWebpackCLI {
935
945
} ,
936
946
] ,
937
947
description : "Print compilation progress during build." ,
948
+ helpLevel : "minimum" ,
938
949
} ,
939
950
940
951
// Output options
@@ -951,6 +962,7 @@ class WebpackCLI implements IWebpackCLI {
951
962
] ,
952
963
alias : "j" ,
953
964
description : "Prints result as JSON or store it in a file." ,
965
+ helpLevel : "minimum" ,
954
966
} ,
955
967
{
956
968
name : "fail-on-warnings" ,
@@ -961,11 +973,11 @@ class WebpackCLI implements IWebpackCLI {
961
973
} ,
962
974
] ,
963
975
description : "Stop webpack-cli process with non-zero exit code on warnings from webpack" ,
976
+ helpLevel : "minimum" ,
964
977
} ,
965
978
] ;
966
979
967
980
const minimumHelpFlags = [
968
- ...builtInFlags . map ( ( flag ) => flag . name ) ,
969
981
"mode" ,
970
982
"watch" ,
971
983
"watch-options-stdin" ,
@@ -979,37 +991,18 @@ class WebpackCLI implements IWebpackCLI {
979
991
980
992
// Extract all the flags being exported from core.
981
993
// 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
982
- const coreArguments = Object . entries ( this . webpack . cli . getArguments ( ) ) . map ( ( [ flag , meta ] ) => {
983
- const inBuiltIn = builtInFlags . find ( ( builtInFlag ) => builtInFlag . name === flag ) ;
984
-
985
- if ( inBuiltIn ) {
986
- return {
987
- ...meta ,
988
- // @ts -expect-error this might be overwritten
989
- name : flag ,
990
- group : "core" ,
991
- ...inBuiltIn ,
992
- configs : meta . configs || [ ] ,
993
- } ;
994
- }
995
-
996
- return { ...meta , name : flag , group : "core" } ;
997
- } ) ;
998
-
999
- const options : WebpackCLIBuiltInOption [ ] = ( [ ] as WebpackCLIBuiltInFlag [ ] )
1000
- . concat (
1001
- builtInFlags . filter (
1002
- ( builtInFlag ) =>
1003
- ! coreArguments . find ( ( coreArgument ) => builtInFlag . name === coreArgument . name ) ,
1004
- ) ,
1005
- )
1006
- . concat ( coreArguments )
1007
- . map ( ( option ) : WebpackCLIBuiltInOption => {
1008
- ( option as WebpackCLIBuiltInOption ) . helpLevel = minimumHelpFlags . includes ( option . name )
1009
- ? "minimum"
1010
- : "verbose" ;
1011
- return option as WebpackCLIBuiltInOption ;
1012
- } ) ;
994
+ const options = builtInFlags . concat (
995
+ Object . entries ( this . webpack . cli . getArguments ( ) ) . map < WebpackCLIBuiltInOption > (
996
+ ( [ name , meta ] ) => {
997
+ return {
998
+ ...meta ,
999
+ name,
1000
+ group : "core" ,
1001
+ helpLevel : minimumHelpFlags . includes ( name ) ? "minimum" : "verbose" ,
1002
+ } ;
1003
+ } ,
1004
+ ) ,
1005
+ ) ;
1013
1006
1014
1007
this . builtInOptionsCache = options ;
1015
1008
0 commit comments