@@ -65,12 +65,6 @@ export interface CommandMeta {
6565 description : string ;
6666}
6767
68- /** Summary line shown at the bottom of a build output block. */
69- export interface BuildSummary {
70- success : boolean ;
71- message : string ;
72- }
73-
7468/** One section emitted by `renderInfoOutput`, e.g. "System" or "Binaries". */
7569export interface InfoSection {
7670 title : string ;
@@ -188,104 +182,7 @@ function _renderHelpOptions(
188182 }
189183}
190184
191- async function _page ( lines : string [ ] , opts : RenderOptions ) : Promise < void > {
192- const { colors, log } = opts ;
193-
194- if (
195- ! process . stdin . isTTY ||
196- typeof ( process . stdin as NodeJS . ReadStream & { setRawMode ?: unknown } ) . setRawMode !== "function"
197- ) {
198- for ( const line of lines ) log ( line ) ;
199- return ;
200- }
201-
202- const termHeight : number = ( process . stdout as NodeJS . WriteStream & { rows ?: number } ) . rows ?? 24 ;
203- const pageSize = termHeight - 2 ;
204- let pos = 0 ;
205-
206- const flush = ( count : number ) => {
207- const end = Math . min ( pos + count , lines . length ) ;
208- for ( let i = pos ; i < end ; i ++ ) log ( lines [ i ] ) ;
209- pos = end ;
210- } ;
211-
212- flush ( pageSize ) ;
213- if ( pos >= lines . length ) return ;
214-
215- process . stdin . setRawMode ( true ) ;
216- process . stdin . resume ( ) ;
217- process . stdin . setEncoding ( "utf8" ) ;
218-
219- const hint =
220- `${ indent ( INDENT ) } ${ colors . cyan ( "─" ) } ` +
221- `${ colors . bold ( "Enter" ) } next line ` +
222- `${ colors . bold ( "Space" ) } next page ` +
223- `${ colors . bold ( "q" ) } quit` ;
224-
225- process . stdout . write ( `\n${ hint } \r` ) ;
226-
227- await new Promise < void > ( ( resolve ) => {
228- const clearHint = ( ) => process . stdout . write ( `\r${ " " . repeat ( process . stdout . columns ?? 80 ) } \r` ) ;
229- const printHint = ( ) => process . stdout . write ( `${ hint } ` ) ;
230- const onKey = ( key : string ) => {
231- if ( key === "\u0003" ) {
232- // eslint-disable-next-line @typescript-eslint/no-use-before-define
233- cleanup ( ) ;
234- process . exit ( 0 ) ;
235- }
236-
237- if ( key === "q" || key === "Q" || key === "\u001B" ) {
238- clearHint ( ) ;
239- // eslint-disable-next-line @typescript-eslint/no-use-before-define
240- cleanup ( ) ;
241- resolve ( ) ;
242- return ;
243- }
244-
245- if ( key === " " || key === "d" ) {
246- clearHint ( ) ;
247- flush ( Math . floor ( pageSize / 2 ) ) ;
248- if ( pos < lines . length ) {
249- process . stdout . write ( "\n" ) ;
250- printHint ( ) ;
251- } else {
252- // eslint-disable-next-line @typescript-eslint/no-use-before-define
253- cleanup ( ) ;
254- resolve ( ) ;
255- }
256- return ;
257- }
258-
259- if ( ( key === "\r" || key === "\n" || key === "\u001B[B" ) && pos < lines . length ) {
260- clearHint ( ) ;
261- process . stdout . write ( `${ lines [ pos ] } \n` ) ;
262- pos ++ ;
263- if ( pos < lines . length ) {
264- printHint ( ) ;
265- } else {
266- // eslint-disable-next-line @typescript-eslint/no-use-before-define
267- cleanup ( ) ;
268- resolve ( ) ;
269- }
270- }
271- } ;
272-
273- const cleanup = ( ) => {
274- process . stdin . removeListener ( "data" , onKey ) ;
275- process . stdin . setRawMode ( false ) ;
276- process . stdin . pause ( ) ;
277- process . stdout . write ( "\n" ) ;
278- } ;
279-
280- process . stdin . on ( "data" , onKey ) ;
281- } ) ;
282- }
283-
284- export async function renderCommandHelp (
285- data : CommandHelpData ,
286- opts : RenderOptions ,
287- paginate = true ,
288- ) : Promise < void > {
185+ export function renderCommandHelp ( data : CommandHelpData , opts : RenderOptions ) : void {
289186 const { colors } = opts ;
290187 const termWidth = Math . min ( opts . columns || MAX_WIDTH , MAX_WIDTH ) ;
291188 const div = divider ( termWidth , colors ) ;
@@ -335,21 +232,7 @@ export async function renderCommandHelp(
335232 ) ;
336233 push ( "" ) ;
337234
338- const termHeight = ( process . stdout as NodeJS . WriteStream & { rows ?: number } ) . rows ?? 24 ;
339- const canPage =
340- paginate &&
341- process . stdout . isTTY &&
342- process . stdin . isTTY &&
343- typeof ( process . stdin as NodeJS . ReadStream & { setRawMode ?: unknown } ) . setRawMode ===
344- "function" ;
345- const shouldPage = canPage && lines . length > termHeight - 2 ;
346-
347- if ( ! shouldPage ) {
348- for ( const line of lines ) opts . log ( line ) ;
349- return ;
350- }
351-
352- await _page ( lines , opts ) ;
235+ for ( const line of lines ) opts . log ( line ) ;
353236}
354237
355238export function renderOptionHelp ( data : OptionHelpData , opts : RenderOptions ) : void {
@@ -493,34 +376,6 @@ export function renderVersionOutput(rawEnvinfo: string, opts: RenderOptions): vo
493376 }
494377}
495378
496- export function renderStatsOutput (
497- statsString : string ,
498- summary : BuildSummary | null ,
499- opts : RenderOptions ,
500- ) : void {
501- const { log } = opts ;
502- const trimmed = statsString . trim ( ) ;
503-
504- if ( trimmed ) {
505- // Output the entire indented stats block as a single log() call so all
506- // lines arrive in one stdout chunk, watch mode tests depend on this.
507- const indented = trimmed
508- . split ( "\n" )
509- . map ( ( line ) => `${ indent ( INDENT ) } ${ line } ` )
510- . join ( "\n" ) ;
511- log ( `\n${ indented } ` ) ;
512- }
513-
514- if ( summary ) {
515- log ( "" ) ;
516- if ( summary . success ) {
517- renderSuccess ( summary . message , opts ) ;
518- } else {
519- renderError ( summary . message , opts ) ;
520- }
521- }
522- }
523-
524379export function renderSection ( title : string , opts : RenderOptions ) : void {
525380 const { colors, log } = opts ;
526381 const termWidth = Math . min ( opts . columns , MAX_WIDTH ) ;
0 commit comments