@@ -9,6 +9,7 @@ import { DependencyMap, PluginManager } from '../plugins/plugin-manager.js';
99import { PromptType , Reporter } from '../ui/reporters/reporter.js' ;
1010import { FileUtils } from '../utils/file.js' ;
1111import { FileModificationCalculator , ModificationType } from '../utils/file-modification-calculator.js' ;
12+ import { sleep } from '../utils/index.js' ;
1213import { InitializeOrchestrator } from './initialize.js' ;
1314
1415export type RequiredParameters = Map < string , RequiredParameter [ ] > ;
@@ -114,14 +115,6 @@ export class ImportOrchestrator {
114115 }
115116 }
116117
117- private static async parse ( path : string ) : Promise < Project > {
118- ctx . subprocessStarted ( SubProcessName . PARSE ) ;
119- const project = await CodifyParser . parse ( path ) ;
120- ctx . subprocessFinished ( SubProcessName . PARSE ) ;
121-
122- return project
123- }
124-
125118 private static async validate ( typeIds : string [ ] , project : Project , pluginManager : PluginManager , dependencyMap : DependencyMap ) : Promise < void > {
126119 ctx . subprocessStarted ( SubProcessName . VALIDATE )
127120
@@ -158,10 +151,16 @@ ${JSON.stringify(unsupportedTypeIds)}`);
158151 } else if ( promptResult === 'In a new file' ) {
159152 const newFileName = await ImportOrchestrator . generateNewImportFileName ( ) ;
160153 await ImportOrchestrator . saveNewFile ( newFileName , importResult ) ;
154+ } else if ( promptResult === 'No' ) {
161155 }
162156 }
163157
164- private static async updateExistingFile ( reporter : Reporter , filePath : string , importResult : ImportResult , resourceInfoList : ResourceInfo [ ] ) : Promise < void > {
158+ private static async updateExistingFile (
159+ reporter : Reporter ,
160+ filePath : string ,
161+ importResult : ImportResult ,
162+ resourceInfoList : ResourceInfo [ ]
163+ ) : Promise < void > {
165164 const existing = await CodifyParser . parse ( filePath ) ;
166165 ImportOrchestrator . attachResourceInfo ( importResult . result , resourceInfoList ) ;
167166 ImportOrchestrator . attachResourceInfo ( existing . resourceConfigs , resourceInfoList ) ;
@@ -172,13 +171,31 @@ ${JSON.stringify(unsupportedTypeIds)}`);
172171 resource
173172 } ) ) ) ;
174173
174+ // No changes to be made
175+ if ( result . diff === '' ) {
176+ reporter . displayMessage ( '\nNo changes are needed! Exiting...' )
177+
178+ // Wait for the message to display before we exit
179+ await sleep ( 100 ) ;
180+ process . exit ( 0 ) ;
181+ }
182+
175183 reporter . displayFileModification ( result . diff ) ;
176184 const shouldSave = await reporter . promptConfirmation ( `Save to file (${ filePath } )?` ) ;
177185 if ( ! shouldSave ) {
186+ reporter . displayMessage ( '\nSkipping save! Exiting...' ) ;
187+
188+ // Wait for the message to display before we exit
189+ await sleep ( 100 ) ;
178190 process . exit ( 0 ) ;
179191 }
180192
181193 await FileUtils . writeFile ( filePath , result . newFile ) ;
194+
195+ reporter . displayMessage ( '\n🎉 Imported completed and saved to file 🎉' ) ;
196+
197+ // Wait for the message to display before we exit
198+ await sleep ( 100 ) ;
182199 }
183200
184201 private static async saveNewFile ( filePath : string , importResult : ImportResult ) : Promise < void > {
0 commit comments