-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplan.ts
More file actions
59 lines (47 loc) · 1.94 KB
/
plan.ts
File metadata and controls
59 lines (47 loc) · 1.94 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { PluginInitOrchestrator } from '../common/initialize-plugins.js';
import { Plan } from '../entities/plan.js';
import { Project } from '../entities/project.js';
import { ProcessName, SubProcessName, ctx } from '../events/context.js';
import { PluginManager } from '../plugins/plugin-manager.js';
import { Reporter } from '../ui/reporters/reporter.js';
import { createStartupShellScriptsIfNotExists } from '../utils/file.js';
import { ValidateOrchestrator } from './validate.js';
export interface PlanArgs {
path?: string;
secureMode?: boolean;
verbosityLevel?: number;
}
export interface PlanOrchestratorResponse {
plan: Plan,
pluginManager: PluginManager;
project: Project;
}
export class PlanOrchestrator {
static async run(args: PlanArgs, reporter: Reporter): Promise<PlanOrchestratorResponse> {
ctx.processStarted(ProcessName.PLAN)
const initializationResult = await PluginInitOrchestrator.run({
...args,
}, reporter);
const { typeIdsToDependenciesMap, pluginManager, project } = initializationResult;
await createStartupShellScriptsIfNotExists();
await ValidateOrchestrator.run({ existing: initializationResult }, reporter);
project.resolveDependenciesAndCalculateEvalOrder(typeIdsToDependenciesMap);
project.addXCodeToolsConfig(); // We have to add xcode-tools config always since almost every resource depends on it
const plan = await PlanOrchestrator.plan(project, pluginManager);
plan.sortByEvalOrder(project.evaluationOrder);
project.removeNoopFromEvaluationOrder(plan);
ctx.processFinished(ProcessName.PLAN)
reporter.displayPlan(plan);
return {
plan,
pluginManager,
project,
};
}
private static async plan(project: Project, pluginManager: PluginManager): Promise<Plan> {
ctx.subprocessStarted(SubProcessName.GENERATE_PLAN)
const plan = await pluginManager.plan(project);
ctx.subprocessFinished(SubProcessName.GENERATE_PLAN)
return plan;
}
}