1- import { ValidateResponseData , PlanRequestData } from 'codify-schemas' ;
1+ import { PlanRequestData , ResourceOperation , ValidateResponseData } from 'codify-schemas' ;
22
33import { PluginValidationError , PluginValidationErrorParams , TypeNotFoundError } from '../common/errors.js' ;
44import { ctx } from '../events/context.js' ;
@@ -7,6 +7,7 @@ import { DependencyMap } from '../plugins/plugin-manager.js';
77import { DependencyGraphResolver } from '../utils/dependency-graph-resolver.js' ;
88import { groupBy } from '../utils/index.js' ;
99import { ConfigBlock , ConfigType } from './config.js' ;
10+ import { type Plan } from './plan.js' ;
1011import { ProjectConfig } from './project-config.js' ;
1112import { ResourceConfig } from './resource-config.js' ;
1213
@@ -125,6 +126,10 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
125126 this . resourceConfigs . unshift ( new ResourceConfig ( {
126127 type : 'xcode-tools'
127128 } ) ) ;
129+
130+ if ( this . evaluationOrder ) {
131+ this . evaluationOrder . unshift ( 'xcode-tools' ) ;
132+ }
128133 }
129134
130135 validateTypeIds ( resourceMap : Map < string , string [ ] > ) {
@@ -135,26 +140,9 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
135140 }
136141 }
137142
138- resolveResourceDependencies ( dependencyMap : DependencyMap ) {
139- const resourceMap = new Map ( this . resourceConfigs . map ( ( r ) => [ r . id , r ] as const ) ) ;
140-
141- for ( const r of this . resourceConfigs ) {
142- // User specified dependencies are hard dependencies. They must be present.
143- r . addDependenciesFromDependsOn ( ( id ) => resourceMap . has ( id ) ) ;
144- r . addDependenciesBasedOnParameters ( ( id ) => resourceMap . has ( id ) ) ;
145-
146- // Plugin dependencies are soft dependencies. They only activate if the dependent resource is present.
147- r . addDependencies ( dependencyMap . get ( r . type )
148- ?. filter ( ( type ) => [ ...resourceMap . values ( ) ] . some ( ( r ) => r . type === type ) )
149- ?. flatMap ( ( type ) => [ ...resourceMap . values ( ) ] . filter ( ( r ) => r . type === type ) . map ( ( r ) => r . id ) ) ?? [ ]
150- ) ;
151-
152- // Add this to ensure that the default config xcode-tools gets applied first
153- // TODO: remove this in the future with required dependencies
154- if ( r . type !== 'xcode-tools' ) {
155- r . addDependencies ( [ 'xcode-tools' ] )
156- }
157- }
143+ resolveDependenciesAndCalculateEvalOrder ( dependencyMap ?: DependencyMap ) {
144+ this . resolveResourceDependencies ( dependencyMap ) ;
145+ this . calculateEvaluationOrder ( ) ;
158146 }
159147
160148 handlePluginResourceValidationResults ( results : ValidateResponseData [ ] ) {
@@ -172,7 +160,29 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
172160 }
173161 }
174162
175- calculateEvaluationOrder ( ) {
163+ removeNoopFromEvaluationOrder ( plan : Plan ) {
164+ this . evaluationOrder = this . evaluationOrder ?. filter ( ( id ) =>
165+ plan . getResourcePlan ( id ) ?. operation !== ResourceOperation . NOOP ,
166+ ) ?? null ;
167+ }
168+
169+ private resolveResourceDependencies ( dependencyMap ?: DependencyMap ) {
170+ const resourceMap = new Map ( this . resourceConfigs . map ( ( r ) => [ r . id , r ] as const ) ) ;
171+
172+ for ( const r of this . resourceConfigs ) {
173+ // User specified dependencies are hard dependencies. They must be present.
174+ r . addDependenciesFromDependsOn ( ( id ) => resourceMap . has ( id ) ) ;
175+ r . addDependenciesBasedOnParameters ( ( id ) => resourceMap . has ( id ) ) ;
176+
177+ // Plugin dependencies are soft dependencies. They only activate if the dependent resource is present.
178+ r . addDependencies ( dependencyMap ?. get ( r . type )
179+ ?. filter ( ( type ) => [ ...resourceMap . values ( ) ] . some ( ( r ) => r . type === type ) )
180+ ?. flatMap ( ( type ) => [ ...resourceMap . values ( ) ] . filter ( ( r ) => r . type === type ) . map ( ( r ) => r . id ) ) ?? [ ]
181+ ) ;
182+ }
183+ }
184+
185+ private calculateEvaluationOrder ( ) {
176186 const resourceOrder = DependencyGraphResolver . calculateDependencyList (
177187 this . resourceConfigs ,
178188 ( r ) => r . id ,
0 commit comments