-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply.ts
More file actions
42 lines (33 loc) · 1.25 KB
/
apply.ts
File metadata and controls
42 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { ProcessName, ctx } from '../events/context.js';
import { Reporter } from '../ui/reporters/reporter.js';
import { sleep } from '../utils/index.js';
import { PlanOrchestrator } from './plan.js';
export interface ApplyArgs {
path?: string;
secure?: boolean;
verbosityLevel?: number;
}
export const ApplyOrchestrator = {
async run(args: ApplyArgs, reporter: Reporter): Promise<void> {
const planResult = await PlanOrchestrator.run(args, reporter);
// Short circuit and exit if every change is NOOP
if (planResult.plan.isEmpty()) {
console.log('No changes necessary. Exiting');
return process.exit(0);
}
const confirm = await reporter.promptConfirmation('Do you want to continue?')
if (!confirm) {
return process.exit(0);
}
const { plan, pluginManager, project } = planResult;
const filteredPlan = plan.filterNoopResources()
ctx.processStarted(ProcessName.APPLY);
await pluginManager.apply(project, filteredPlan);
ctx.processFinished(ProcessName.APPLY);
reporter.displayMessage(`
🎉 Finished applying 🎉
Open a new terminal or source '.zshrc' for the new changes to be reflected`);
// Need to sleep to wait for the message to display before we exit
await sleep(100);
},
};