@@ -11,6 +11,7 @@ import {
1111 configHandler ,
1212 getLogPath ,
1313 CLIProgressManager ,
14+ cliux ,
1415} from '@contentstack/cli-utilities' ;
1516
1617import { Context , ImportConfig } from '../../../types' ;
@@ -185,7 +186,7 @@ export default class ImportCommand extends Command {
185186 CLIProgressManager . initializeGlobalSummary (
186187 `IMPORT-${ flags . branch } ` ,
187188 flags . branch ,
188- `IMPORTING "${ flags . branch } " BRANCH CONTENT ` ,
189+ `IMPORTING DATA INTO "${ flags . branch } " BRANCH` ,
189190 ) ;
190191 } else {
191192 CLIProgressManager . initializeGlobalSummary ( `IMPORT` , flags . branch , 'IMPORTING CONTENT' ) ;
@@ -202,17 +203,48 @@ export default class ImportCommand extends Command {
202203 log . success ( successMessage , importConfig . context ) ;
203204 }
204205
205- log . success ( `The log has been stored at '${ getLogPath ( ) } '` , importConfig . context ) ;
206- log . info ( `The backup content has been stored at '${ backupDir } '` , importConfig . context ) ;
207206 CLIProgressManager . printGlobalSummary ( ) ;
207+ this . logSuccessAndBackupMessages ( backupDir , importConfig ) ;
208208 } catch ( error ) {
209209 handleAndLogError ( error ) ;
210- log . info ( `The log has been stored at '${ getLogPath ( ) } '` ) ;
211- if ( importConfig ?. backupDir ) {
212- log . info ( `The backup content has been stored at '${ importConfig ?. backupDir } '` ) ;
213- } else {
214- log . info ( 'No backup directory was created due to early termination' ) ;
215- }
210+ this . logAndPrintErrorDetails ( error , importConfig ) ;
211+ }
212+ }
213+
214+ private logAndPrintErrorDetails ( error : unknown , importConfig : any ) {
215+ cliux . print ( '\n' ) ;
216+ const logPath = getLogPath ( ) ;
217+ const logMsg = `The log has been stored at '${ logPath } '` ;
218+
219+ const backupDir = importConfig ?. backupDir ;
220+ const backupDirMsg = backupDir
221+ ? `The backup content has been stored at '${ backupDir } '`
222+ : 'No backup directory was created due to early termination' ;
223+
224+ log . info ( logMsg ) ;
225+ log . info ( backupDirMsg ) ;
226+
227+ const showConsoleLogs = configHandler . get ( 'log' ) ?. showConsoleLogs ;
228+ if ( ! showConsoleLogs ) {
229+ cliux . print ( `Error: ${ error } ` , { color : 'red' } ) ;
230+ cliux . print ( logMsg , { color : 'blue' } ) ;
231+ cliux . print ( backupDirMsg , { color : 'blue' } ) ;
232+ }
233+ }
234+
235+ private logSuccessAndBackupMessages ( backupDir : string , importConfig : any ) {
236+ cliux . print ( '\n' ) ;
237+ const logPath = getLogPath ( ) ;
238+ const logMsg = `The log has been stored at '${ logPath } '` ;
239+ const backupDirMsg = `The backup content has been stored at '${ backupDir } '` ;
240+
241+ log . success ( logMsg , importConfig . context ) ;
242+ log . info ( backupDirMsg , importConfig . context ) ;
243+
244+ const showConsoleLogs = configHandler . get ( 'log' ) ?. showConsoleLogs ;
245+ if ( ! showConsoleLogs ) {
246+ cliux . print ( logMsg , { color : 'blue' } ) ;
247+ cliux . print ( backupDirMsg , { color : 'blue' } ) ;
216248 }
217249 }
218250
0 commit comments