44 ValidateResponseData ,
55} from '@codifycli/schemas' ;
66
7- import { InternalError } from '../common/errors.js' ;
7+ import { ApplyPartialFailureError , InternalError , PluginError } from '../common/errors.js' ;
88import { config } from '../config.js' ;
99import { Plan , ResourcePlan } from '../entities/plan.js' ;
1010import { Project } from '../entities/project.js' ;
@@ -138,7 +138,16 @@ export class PluginManager {
138138 }
139139
140140 async apply ( project : Project , plan : Plan ) : Promise < void > {
141+ const collectedErrors : PluginError [ ] = [ ] ;
142+ const skippedIds = new Set < string > ( ) ;
143+
141144 for ( const id of project . evaluationOrder ?? [ ] ) {
145+ if ( skippedIds . has ( id ) ) {
146+ ctx . subprocessStarted ( SubProcessName . APPLYING_RESOURCE , id ) ;
147+ ctx . subprocessFinished ( SubProcessName . APPLYING_RESOURCE , id ) ;
148+ continue ;
149+ }
150+
142151 ctx . subprocessStarted ( SubProcessName . APPLYING_RESOURCE , id ) ;
143152
144153 const resourcePlan = plan . getResourcePlan ( id ) ;
@@ -152,10 +161,24 @@ export class PluginManager {
152161 throw new InternalError ( `Unable to determine plugin for apply: ${ resourceType } ` ) ;
153162 }
154163
155- await this . plugins . get ( pluginName ) ! . apply ( resourcePlan ) ;
164+ try {
165+ await this . plugins . get ( pluginName ) ! . apply ( resourcePlan ) ;
166+ } catch ( err ) {
167+ if ( err instanceof PluginError ) {
168+ collectedErrors . push ( err ) ;
169+ const dependents = plan . computeTransitiveDependents ( id ) ;
170+ for ( const depId of dependents ) skippedIds . add ( depId ) ;
171+ } else {
172+ throw err ;
173+ }
174+ }
156175
157176 ctx . subprocessFinished ( SubProcessName . APPLYING_RESOURCE , resourcePlan . id ) ;
158177 }
178+
179+ if ( collectedErrors . length > 0 ) {
180+ throw new ApplyPartialFailureError ( collectedErrors ) ;
181+ }
159182 }
160183
161184 async setVerbosityLevel ( verbosityLevel : number ) : Promise < void > {
0 commit comments