@@ -59,18 +59,6 @@ export interface CommandHelpData {
5959 globalOptions : HelpOption [ ] ;
6060}
6161
62- /** Passed to `renderCommandHeader` to describe the running command. */
63- export interface CommandMeta {
64- name : string ;
65- description : string ;
66- }
67-
68- /** One section emitted by `renderInfoOutput`, e.g. "System" or "Binaries". */
69- export interface InfoSection {
70- title : string ;
71- rows : Row [ ] ;
72- }
73-
7462// ─── Layout constants ─────────────────────────────────────────────
7563export const MAX_WIDTH = 80 ;
7664export const INDENT = 2 ;
@@ -139,29 +127,6 @@ export function renderRows(
139127 }
140128}
141129
142- export function renderCommandHeader ( meta : CommandMeta , opts : RenderOptions ) : void {
143- const { colors, log } = opts ;
144- const termWidth = Math . min ( opts . columns || MAX_WIDTH , MAX_WIDTH ) ;
145-
146- log ( "" ) ;
147- log ( `${ indent ( INDENT ) } ${ colors . bold ( colors . cyan ( "⬡" ) ) } ${ colors . bold ( `webpack ${ meta . name } ` ) } ` ) ;
148- log ( divider ( termWidth , colors ) ) ;
149-
150- if ( meta . description ) {
151- const descWidth = termWidth - INDENT * 2 ;
152- for ( const line of wrapValue ( meta . description , descWidth ) ) {
153- log ( `${ indent ( INDENT ) } ${ line } ` ) ;
154- }
155- log ( "" ) ;
156- }
157- }
158-
159- export function renderCommandFooter ( opts : RenderOptions ) : void {
160- const termWidth = Math . min ( opts . columns , MAX_WIDTH ) ;
161- opts . log ( divider ( termWidth , opts . colors ) ) ;
162- opts . log ( "" ) ;
163- }
164-
165130function _renderHelpOptions (
166131 options : HelpOption [ ] ,
167132 colors : Colors ,
@@ -227,9 +192,6 @@ export function renderCommandHelp(data: CommandHelpData, opts: RenderOptions): v
227192 }
228193
229194 push ( div ) ;
230- push (
231- ` ${ colors . cyan ( "ℹ" ) } Run ${ colors . bold ( `'webpack help ${ data . name } --verbose'` ) } to see all available options.` ,
232- ) ;
233195 push ( "" ) ;
234196
235197 for ( const line of lines ) opts . log ( line ) ;
@@ -274,116 +236,6 @@ export function renderAliasHelp(data: AliasHelpData, opts: RenderOptions): void
274236 renderOptionHelp ( data . optionHelp , opts ) ;
275237}
276238
277- export function renderError ( message : string , opts : RenderOptions ) : void {
278- const { colors, log } = opts ;
279- log ( `${ indent ( INDENT ) } ${ colors . red ( "✖" ) } ${ colors . bold ( message ) } ` ) ;
280- }
281-
282- export function renderSuccess ( message : string , opts : RenderOptions ) : void {
283- const { colors, log } = opts ;
284- log ( `${ indent ( INDENT ) } ${ colors . green ( "✔" ) } ${ colors . bold ( message ) } ` ) ;
285- }
286-
287- export function renderWarning ( message : string , opts : RenderOptions ) : void {
288- const { colors, log } = opts ;
289- log ( `${ indent ( INDENT ) } ${ colors . yellow ( "⚠" ) } ${ message } ` ) ;
290- }
291-
292- export function renderInfo ( message : string , opts : RenderOptions ) : void {
293- const { colors, log } = opts ;
294- log ( `${ indent ( INDENT ) } ${ colors . cyan ( "ℹ" ) } ${ message } ` ) ;
295- }
296-
297- export function parseEnvinfoSections ( raw : string ) : InfoSection [ ] {
298- const sections : InfoSection [ ] = [ ] ;
299- let current : InfoSection | null = null ;
300-
301- for ( const line of raw . split ( "\n" ) ) {
302- const sectionMatch = line . match ( / ^ { 2 } ( [ ^ : ] + ) : \s * $ / ) ;
303- if ( sectionMatch ) {
304- if ( current ) sections . push ( current ) ;
305- current = { title : sectionMatch [ 1 ] . trim ( ) , rows : [ ] } ;
306- continue ;
307- }
308-
309- const rowMatch = line . match ( / ^ { 4 } ( [ ^ : ] + ) : \s + ( .+ ) $ / ) ;
310- if ( rowMatch && current ) {
311- current . rows . push ( { label : rowMatch [ 1 ] . trim ( ) , value : rowMatch [ 2 ] . trim ( ) } ) ;
312- continue ;
313- }
314-
315- const emptyRowMatch = line . match ( / ^ { 4 } ( [ ^ : ] + ) : \s * $ / ) ;
316- if ( emptyRowMatch && current ) {
317- current . rows . push ( { label : emptyRowMatch [ 1 ] . trim ( ) , value : "N/A" , color : ( str ) => str } ) ;
318- }
319- }
320-
321- if ( current ) sections . push ( current ) ;
322- return sections . filter ( ( section ) => section . rows . length > 0 ) ;
323- }
324-
325- export function renderInfoOutput ( rawEnvinfo : string , opts : RenderOptions ) : void {
326- const { colors, log } = opts ;
327- const termWidth = Math . min ( opts . columns , MAX_WIDTH ) ;
328- const div = divider ( termWidth , colors ) ;
329- const sections = parseEnvinfoSections ( rawEnvinfo ) ;
330-
331- log ( "" ) ;
332-
333- for ( const section of sections ) {
334- log (
335- `${ indent ( INDENT ) } ${ colors . bold ( colors . cyan ( "⬡" ) ) } ${ colors . bold ( colors . cyan ( section . title ) ) } ` ,
336- ) ;
337- log ( div ) ;
338- renderRows ( section . rows , colors , log , termWidth ) ;
339- log ( div ) ;
340- log ( "" ) ;
341- }
342- }
343-
344- export function renderVersionOutput ( rawEnvinfo : string , opts : RenderOptions ) : void {
345- const { colors, log } = opts ;
346- const termWidth = Math . min ( opts . columns , MAX_WIDTH ) ;
347- const div = divider ( termWidth , colors ) ;
348- const sections = parseEnvinfoSections ( rawEnvinfo ) ;
349-
350- for ( const section of sections ) {
351- log ( "" ) ;
352- log (
353- `${ indent ( INDENT ) } ${ colors . bold ( colors . cyan ( "⬡" ) ) } ${ colors . bold ( colors . cyan ( section . title ) ) } ` ,
354- ) ;
355- log ( div ) ;
356-
357- const labelWidth = Math . max ( ...section . rows . map ( ( row ) => row . label . length ) ) ;
358-
359- for ( const { label, value } of section . rows ) {
360- const arrowIdx = value . indexOf ( "=>" ) ;
361-
362- if ( arrowIdx !== - 1 ) {
363- const requested = value . slice ( 0 , arrowIdx ) . trim ( ) ;
364- const resolved = value . slice ( arrowIdx + 2 ) . trim ( ) ;
365- log (
366- `${ indent ( INDENT ) } ${ colors . bold ( label . padEnd ( labelWidth ) ) } ${ indent ( COL_GAP ) } ` +
367- `${ colors . cyan ( requested . padEnd ( 12 ) ) } ${ colors . cyan ( "→" ) } ${ colors . green ( colors . bold ( resolved ) ) } ` ,
368- ) ;
369- } else {
370- log (
371- `${ indent ( INDENT ) } ${ colors . bold ( label . padEnd ( labelWidth ) ) } ${ indent ( COL_GAP ) } ${ colors . green ( value ) } ` ,
372- ) ;
373- }
374- }
375- log ( div ) ;
376- }
377- }
378-
379- export function renderSection ( title : string , opts : RenderOptions ) : void {
380- const { colors, log } = opts ;
381- const termWidth = Math . min ( opts . columns , MAX_WIDTH ) ;
382- log ( "" ) ;
383- log ( `${ indent ( INDENT ) } ${ colors . bold ( title ) } ` ) ;
384- log ( divider ( termWidth , colors ) ) ;
385- }
386-
387239export function renderFooter ( opts : RenderOptions , footer : FooterOptions = { } ) : void {
388240 const { colors, log } = opts ;
389241
0 commit comments