@@ -36,6 +36,7 @@ import {
3636 HelpOption ,
3737 MAX_WIDTH ,
3838 RenderOptions ,
39+ frame ,
3940 renderAliasHelp ,
4041 renderCommandHelp ,
4142 renderError ,
@@ -1009,7 +1010,8 @@ class WebpackCLI {
10091010 return {
10101011 colors : this . colors ,
10111012 log : ( line ) => this . logger . raw ( line ) ,
1012- columns : process . stdout . columns ?? MAX_WIDTH , // import MAX_WIDTH from ui-renderer
1013+ // we mirror the way commander handle the width here as calling it directly will cause an infinite loop
1014+ columns : process . stdout . columns ?? MAX_WIDTH , // import MAX_WIDTH from ui-renderer instead of hardcode 80 even if it's consider as the standard
10131015 } ;
10141016 }
10151017
@@ -1823,18 +1825,24 @@ class WebpackCLI {
18231825 } ,
18241826 ] ,
18251827 action : async ( options : { output ?: string } ) => {
1826- const rawInfo = await this . #getInfoOutput( {
1827- information : {
1828- npmPackages : `{${ DEFAULT_WEBPACK_PACKAGES . map ( ( item ) => `*${ item } *` ) . join ( "," ) } }` ,
1829- } ,
1830- } ) ;
1831-
18321828 if ( options . output ) {
18331829 this . logger . raw ( await this . #renderVersion( options ) ) ;
18341830 return ;
18351831 }
18361832
1837- renderVersionOutput ( rawInfo , this . #renderOptions( ) ) ;
1833+ await frame (
1834+ { name : "version" , description : "Installed package versions." } ,
1835+ async ( option ) =>
1836+ renderVersionOutput (
1837+ await this . #getInfoOutput( {
1838+ information : {
1839+ npmPackages : `{${ DEFAULT_WEBPACK_PACKAGES . map ( ( item ) => `*${ item } *` ) . join ( "," ) } }` ,
1840+ } ,
1841+ } ) ,
1842+ option ,
1843+ ) ,
1844+ this . #renderOptions( ) ,
1845+ ) ;
18381846 } ,
18391847 } ,
18401848 info : {
@@ -1872,7 +1880,11 @@ class WebpackCLI {
18721880 return ;
18731881 }
18741882
1875- renderInfoOutput ( info , this . #renderOptions( ) ) ;
1883+ await frame (
1884+ { name : "info" , description : "System and environment information." } ,
1885+ ( option ) => renderInfoOutput ( info , option ) ,
1886+ this . #renderOptions( ) ,
1887+ ) ;
18761888 } ,
18771889 } ,
18781890 configtest : {
@@ -1894,7 +1906,6 @@ class WebpackCLI {
18941906 configPath ? { env, argv, webpack, config : [ configPath ] } : { env, argv, webpack } ,
18951907 ) ;
18961908 const configPaths = new Set < string > ( ) ;
1897- const renderOpts = this . #renderOptions( ) ;
18981909
18991910 if ( Array . isArray ( config . options ) ) {
19001911 for ( const options of config . options ) {
@@ -1912,21 +1923,27 @@ class WebpackCLI {
19121923 }
19131924 }
19141925
1915- if ( configPaths . size === 0 ) {
1916- renderError ( "No configuration found." , renderOpts ) ;
1917- process . exit ( 2 ) ;
1918- }
1919- renderWarning ( `Validating: ${ [ ...configPaths ] . join ( ", " ) } ` , renderOpts ) ;
1920- try {
1921- cmd . context . webpack . validate ( config . options ) ;
1922- } catch ( error ) {
1923- renderError (
1924- this . isValidationError ( error as Error ) ? ( error as Error ) . message : String ( error ) ,
1925- renderOpts ,
1926- ) ;
1927- process . exit ( 2 ) ;
1928- }
1929- renderSuccess ( "No validation errors found." , renderOpts ) ;
1926+ await frame (
1927+ { name : "configtest" , description : "Validating your webpack configuration." } ,
1928+ async ( option ) => {
1929+ if ( configPaths . size === 0 ) {
1930+ renderError ( "No configuration found." , option ) ;
1931+ process . exit ( 2 ) ;
1932+ }
1933+ renderWarning ( `Validating: ${ [ ...configPaths ] . join ( ", " ) } ` , option ) ;
1934+ try {
1935+ cmd . context . webpack . validate ( config . options ) ;
1936+ } catch ( error ) {
1937+ renderError (
1938+ this . isValidationError ( error as Error ) ? ( error as Error ) . message : String ( error ) ,
1939+ option ,
1940+ ) ;
1941+ process . exit ( 2 ) ;
1942+ }
1943+ renderSuccess ( "No validation errors found." , option ) ;
1944+ } ,
1945+ this . #renderOptions( ) ,
1946+ ) ;
19301947 } ,
19311948 } ,
19321949 } ;
0 commit comments