Skip to content

Commit a215bbe

Browse files
[CODE-60] Apply verification (#24)
* [CODE-60] Add apply verification * [CODE-60] Refactored files * [CODE-60] Remove json diff
1 parent 57df53a commit a215bbe

14 files changed

Lines changed: 43 additions & 26 deletions

File tree

src/common/orchestrator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Project } from '../entities/project.js';
22
import { ctx, SubProcessName } from '../events/context.js';
3-
import { DependencyMap, PluginCollection } from '../plugins/plugin-collection.js';
3+
import { DependencyMap, PluginManager } from '../plugins/plugin-manager.js';
44

55
export const CommonOrchestrator = {
66
async initializePlugins(project?: Project, secureMode = false): Promise<{
77
dependencyMap: DependencyMap
8-
pluginCollection: PluginCollection,
8+
pluginManager: PluginManager,
99
}> {
1010
ctx.subprocessStarted(SubProcessName.INITIALIZE_PLUGINS)
11-
const pluginCollection = new PluginCollection();
12-
const dependencyMap = await pluginCollection.initialize(project, secureMode);
11+
const pluginManager = new PluginManager();
12+
const dependencyMap = await pluginManager.initialize(project, secureMode);
1313
ctx.subprocessFinished(SubProcessName.INITIALIZE_PLUGINS)
1414

15-
return { dependencyMap, pluginCollection };
15+
return { dependencyMap, pluginManager };
1616
},
1717
};
File renamed without changes.

src/entities/project-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ProjectSchema } from 'codify-schemas';
22

33
import { ConfigClass } from '../parser/language-definition.js';
44
import { ajv } from '../utils/ajv.js';
5-
import { RemoveMethods } from '../utils/types.js';
5+
import { RemoveMethods } from '../common/types.js';
66
import { ConfigBlock } from './config.js';
77

88
/** Project JSON supported format

src/entities/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ValidateResponseData } from 'codify-schemas';
22

33
import { ctx } from '../events/context.js';
4-
import { DependencyMap } from '../plugins/plugin-collection.js';
4+
import { DependencyMap } from '../plugins/plugin-manager.js';
55
import { DependencyGraphResolver } from '../utils/dependency-graph-resolver.js';
66
import { ProjectConfig } from './project-config.js';
77
import { ResourceConfig } from './resource-config.js';

src/entities/resource-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ResourceSchema } from 'codify-schemas';
22

33
import { ConfigClass } from '../parser/language-definition.js';
44
import { ajv } from '../utils/ajv.js';
5-
import { RemoveMethods } from '../utils/types.js';
5+
import { RemoveMethods } from '../common/types.js';
66
import { ConfigBlock } from './config.js';
77

88
/** Resource JSON supported format

src/orchestrators/apply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { PlanOrchestratorResponse } from './plan.js';
55

66
export const ApplyOrchestrator = {
77
async run(planResult: PlanOrchestratorResponse): Promise<void> {
8-
const { plan, pluginCollection } = planResult;
8+
const { plan, pluginManager, project } = planResult;
99
const filteredPlan = plan
1010
.filter((p) => p.operation !== ResourceOperation.NOOP)
1111

1212
ctx.processStarted(ProcessName.APPLY);
13-
await pluginCollection.apply(filteredPlan);
13+
await pluginManager.apply(project, filteredPlan);
1414
ctx.processFinished(ProcessName.APPLY);
1515
},
1616
};

src/orchestrators/plan.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { PlanResponseData } from 'codify-schemas';
22

3+
import { CommonOrchestrator } from '../common/orchestrator.js';
34
import { Project } from '../entities/project.js';
45
import { ctx, ProcessName, SubProcessName } from '../events/context.js';
56
import { Parser } from '../parser/index.js';
6-
import { PluginCollection } from '../plugins/plugin-collection.js';
7+
import { PluginManager } from '../plugins/plugin-manager.js';
78
import { createStartupShellScriptsIfNotExists } from '../utils/file.js';
8-
import { CommonOrchestrator } from '../common/orchestrator.js';
99

1010
export interface PlanOrchestratorResponse {
1111
plan: PlanResponseData[],
12-
pluginCollection: PluginCollection;
12+
pluginManager: PluginManager;
1313
project: Project;
1414
}
1515

@@ -24,27 +24,27 @@ export const PlanOrchestrator = {
2424
project.addXCodeToolsConfig();
2525
ctx.subprocessFinished(SubProcessName.PARSE);
2626

27-
const { dependencyMap, pluginCollection } = await CommonOrchestrator.initializePlugins(project, secureMode);
27+
const { dependencyMap, pluginManager } = await CommonOrchestrator.initializePlugins(project, secureMode);
2828
await createStartupShellScriptsIfNotExists();
2929

3030
ctx.subprocessStarted(SubProcessName.VALIDATE)
3131
project.validateWithResourceMap(dependencyMap);
3232
project.resolveResourceDependencies(dependencyMap);
3333

34-
const validationResults = await pluginCollection.validate(project);
34+
const validationResults = await pluginManager.validate(project);
3535
project.handlePluginResourceValidationResults(validationResults);
3636
project.calculateEvaluationOrder();
3737
ctx.subprocessFinished(SubProcessName.VALIDATE)
3838

3939
ctx.subprocessStarted(SubProcessName.GENERATE_PLAN)
40-
const plan = await pluginCollection.getPlan(project);
40+
const plan = await pluginManager.getPlan(project);
4141
ctx.subprocessFinished(SubProcessName.GENERATE_PLAN)
4242

4343
ctx.processFinished(ProcessName.PLAN)
4444

4545
return {
4646
plan,
47-
pluginCollection,
47+
pluginManager,
4848
project,
4949
};
5050
},

src/orchestrators/uninstall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export const UninstallOrchestrator = {
1818
resourceType: type,
1919
} as PlanResponseData))
2020

21-
const { pluginCollection } = await CommonOrchestrator.initializePlugins(undefined, secureMode);
21+
const { pluginManager } = await CommonOrchestrator.initializePlugins(undefined, secureMode);
2222
await createStartupShellScriptsIfNotExists();
2323

2424
ctx.processStarted(ProcessName.UNINSTALL);
25-
await pluginCollection.apply(plan);
25+
// await pluginManager.apply(plan);
2626
ctx.processFinished(ProcessName.UNINSTALL);
2727
},
2828
};

src/parser/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ConfigBlock } from '../entities/config.js';
22
import { Project } from '../entities/project.js';
33
import { ProjectConfig } from '../entities/project-config.js';
44
import { ResourceConfig } from '../entities/resource-config.js';
5-
import { InternalError } from '../utils/errors.js';
5+
import { InternalError } from '../common/errors.js';
66
import { ConfigClass } from './language-definition.js';
77
import { FileParser } from './parser/index.js';
88
import { JsonFileParser } from './parser/json/file-parser.js';

0 commit comments

Comments
 (0)