@@ -3,8 +3,8 @@ import ora, { Ora } from 'ora';
33import ProgressBar from 'cli-progress' ;
44import SummaryManager from './summary-manager' ;
55import { ProcessProgress , ProgressManagerOptions , Failure } from '../interfaces' ;
6- import { configHandler } from '..' ;
76import { ProgressStrategyRegistry } from './progress-strategy' ;
7+ import { isConsoleLogEnabled } from '../logger/console-policy' ;
88
99interface ProgressCallback {
1010 onModuleStart ?: ( moduleName : string ) => void ;
@@ -37,7 +37,7 @@ export default class CLIProgressManager {
3737 private branchName : string ;
3838
3939 constructor ( {
40- showConsoleLogs = false ,
40+ showConsoleLogs = isConsoleLogEnabled ( ) ,
4141 total = 0 ,
4242 moduleName = 'Module' ,
4343 enableNestedProgress = false ,
@@ -70,7 +70,7 @@ export default class CLIProgressManager {
7070 CLIProgressManager . globalSummary = new SummaryManager ( { operationName, context : { branchName } } ) ;
7171
7272 // Only show header if console logs are disabled (progress UI mode)
73- if ( ! configHandler . get ( 'log' ) ?. showConsoleLogs ) {
73+ if ( ! isConsoleLogEnabled ( ) ) {
7474 CLIProgressManager . displayOperationHeader ( branchName , headerTitle ) ;
7575 }
7676
@@ -167,32 +167,44 @@ export default class CLIProgressManager {
167167
168168 /**
169169 * Create a simple progress manager (no nested processes)
170+ *
171+ * @param _showConsoleLogs Deprecated and ignored. Console visibility is a process-wide
172+ * policy (`isConsoleLogEnabled()`), which the constructor reads itself — a caller must
173+ * not be able to override it. The parameter is retained only so the plugins still
174+ * passing it keep compiling, and is removed once those call sites are gone.
170175 */
171- static createSimple ( moduleName : string , total ?: number , showConsoleLogs = false ) : CLIProgressManager {
176+ static createSimple ( moduleName : string , total ?: number , _showConsoleLogs ?: boolean ) : CLIProgressManager {
172177 return new CLIProgressManager ( {
173178 moduleName : moduleName . toUpperCase ( ) ,
174179 total : total || 0 ,
175- showConsoleLogs,
176180 enableNestedProgress : false ,
177181 } ) ;
178182 }
179183
180184 /**
181185 * Create a nested progress manager (with sub-processes)
186+ *
187+ * @param _showConsoleLogs Deprecated and ignored — see `createSimple`.
182188 */
183- static createNested ( moduleName : string , showConsoleLogs = false ) : CLIProgressManager {
189+ static createNested ( moduleName : string , _showConsoleLogs ?: boolean ) : CLIProgressManager {
184190 return new CLIProgressManager ( {
185191 moduleName : moduleName . toUpperCase ( ) ,
186192 total : 0 ,
187- showConsoleLogs,
188193 enableNestedProgress : true ,
189194 } ) ;
190195 }
191196
192197 /**
193- * Show a loading spinner before initializing progress
198+ * Show a loading spinner while an async operation runs.
199+ *
200+ * A spinner is part of the progress UI, so it is skipped entirely when console logs own
201+ * the terminal — callers do not need to branch on the policy themselves.
194202 */
195203 static async withLoadingSpinner < T > ( message : string , asyncOperation : ( ) => Promise < T > ) : Promise < T > {
204+ if ( isConsoleLogEnabled ( ) ) {
205+ return asyncOperation ( ) ;
206+ }
207+
196208 const spinner = ora ( message ) . start ( ) ;
197209 try {
198210 const result = await asyncOperation ( ) ;
@@ -288,6 +300,10 @@ export default class CLIProgressManager {
288300 }
289301
290302 private initializeProgress ( ) : void {
303+ // Console logs and the progress UI are mutually exclusive: exactly one of them owns
304+ // the terminal. When console logging is on, no renderer is created at all — not
305+ // suppressed, not buffered, never constructed. Everything below is therefore reached
306+ // only in progress-UI mode.
291307 if ( this . showConsoleLogs ) {
292308 return ;
293309 }
@@ -305,13 +321,9 @@ export default class CLIProgressManager {
305321 ProgressBar . Presets . shades_classic ,
306322 ) ;
307323
308- if ( ! this . showConsoleLogs ) {
309- console . log ( getChalk ( ) . bold . cyan ( `\n${ this . moduleName } :` ) ) ;
310- }
324+ console . log ( getChalk ( ) . bold . cyan ( `\n${ this . moduleName } :` ) ) ;
311325 } else if ( this . total > 0 ) {
312- if ( ! this . showConsoleLogs ) {
313- console . log ( getChalk ( ) . bold . cyan ( `\n${ this . moduleName } :` ) ) ;
314- }
326+ console . log ( getChalk ( ) . bold . cyan ( `\n${ this . moduleName } :` ) ) ;
315327
316328 this . progressBar = new ProgressBar . SingleBar ( {
317329 format : ' {label} |' + getChalk ( ) . cyan ( '{bar}' ) + '| {percentage}% | {value}/{total} | {status}' ,
0 commit comments