-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrefresh.ts
More file actions
58 lines (46 loc) · 1.72 KB
/
Copy pathrefresh.ts
File metadata and controls
58 lines (46 loc) · 1.72 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
import { PluginInitOrchestrator } from '../common/initialize-plugins.js';
import { ResourceConfig } from '../entities/resource-config.js';
import { ProcessName, ctx } from '../events/context.js';
import { Reporter } from '../ui/reporters/reporter.js';
import { ImportOrchestrator } from './import.js';
export type RefreshResult = { result: ResourceConfig[], errors: string[] }
export interface RefreshArgs {
typeIds?: string[];
path: string;
secureMode?: boolean;
verbosityLevel?: number;
}
export class RefreshOrchestrator {
static async run(
args: RefreshArgs,
reporter: Reporter
) {
const typeIds = args.typeIds?.filter(Boolean)
ctx.processStarted(ProcessName.REFRESH)
const initializationResult = await PluginInitOrchestrator.run(
{ ...args, allowEmptyProject: true },
reporter,
);
const { project, pluginManager } = initializationResult;
await pluginManager.validate(project);
const importResult = await ImportOrchestrator.import(
pluginManager,
project.resourceConfigs.filter((r) => !typeIds || typeIds.length === 0 || typeIds.includes(r.type))
);
ctx.processFinished(ProcessName.REFRESH);
await reporter.displayImportResult(importResult, false);
// Special handling for remote-file resources. Offer to save them remotely if any changes are detected on import.
await ImportOrchestrator.handleCodifyRemoteFiles(reporter, importResult);
const resourceInfoList = await pluginManager.getMultipleResourceInfo(
project.resourceConfigs.map((r) => r.type),
);
await ImportOrchestrator.updateExistingFiles(
reporter,
project,
importResult,
resourceInfoList,
project.codifyFiles[0],
pluginManager,
);
}
}