|
1 | 1 | import { |
| 2 | + ApplyNoteRequestData, |
2 | 3 | ImportResponseData, ResourceDefinition, |
3 | 4 | ResourceJson, |
4 | 5 | ValidateResponseData, |
5 | 6 | } from '@codifycli/schemas'; |
6 | 7 |
|
7 | 8 | import { InternalError, PluginError } from '../common/errors.js'; |
8 | 9 | import { config } from '../config.js'; |
| 10 | +import { ApplyNote } from '../entities/apply-note.js'; |
9 | 11 | import { ApplyResult, createApplyResult } from '../entities/apply-result.js'; |
10 | 12 | import { Plan, ResourcePlan } from '../entities/plan.js'; |
11 | 13 | import { Project } from '../entities/project.js'; |
12 | 14 | import { ResourceConfig } from '../entities/resource-config.js'; |
13 | 15 | import { ResourceInfo } from '../entities/resource-info.js'; |
14 | | -import { SubProcessName, SubprocessFinishStatus, ctx } from '../events/context.js'; |
| 16 | +import { Event, SubProcessName, SubprocessFinishStatus, ctx } from '../events/context.js'; |
15 | 17 | import { groupBy } from '../utils/index.js'; |
16 | 18 | import { registerKillListeners } from '../utils/register-kill-listeners.js'; |
17 | 19 | import { Plugin } from './plugin.js'; |
@@ -142,6 +144,12 @@ export class PluginManager { |
142 | 144 | const collectedErrors: PluginError[] = []; |
143 | 145 | const skippedIds = new Set<string>(); |
144 | 146 | const succeededPlans: ResourcePlan[] = []; |
| 147 | + const collectedNotes: ApplyNote[] = []; |
| 148 | + |
| 149 | + const noteListener = (_pluginName: string, data: ApplyNoteRequestData) => { |
| 150 | + collectedNotes.push({ message: data.message, resourceType: data.resourceType }); |
| 151 | + }; |
| 152 | + ctx.on(Event.APPLY_NOTE_REQUEST, noteListener); |
145 | 153 |
|
146 | 154 | for (const id of project.evaluationOrder ?? []) { |
147 | 155 | if (skippedIds.has(id)) { |
@@ -179,7 +187,8 @@ export class PluginManager { |
179 | 187 | } |
180 | 188 | } |
181 | 189 |
|
182 | | - return createApplyResult(succeededPlans, collectedErrors, skippedIds); |
| 190 | + ctx.emitter.removeListener(Event.APPLY_NOTE_REQUEST, noteListener); |
| 191 | + return createApplyResult(succeededPlans, collectedErrors, skippedIds, collectedNotes); |
183 | 192 | } |
184 | 193 |
|
185 | 194 | async setVerbosityLevel(verbosityLevel: number): Promise<void> { |
|
0 commit comments