@@ -45,86 +45,16 @@ export class DependencyGraphResolver {
4545 }
4646
4747 node . dependencies . forEach ( ( parentNode ) => {
48- if ( -- parentNode . indegree ) {
48+ if ( -- parentNode . indegree === 0 ) {
4949 queue . push ( parentNode ) ;
5050 }
5151 } ) ;
5252 result . push ( node ) ;
5353 }
5454
55- // const { resourceConfigs } = project;
56- // const resourceMap = new Map<string, ResourceConfig>(
57- // resourceConfigs.map((r) => [r.id, r] as const)
58- // );
59- //
60- // const resourceReferenceRegex = /\${([\w.]+)}/g
61- //
62- // // TODO: Support named resources in the future
63- //
64- // for (const config of resourceConfigs) {
65- // const referenceParameters = findParametersWithReferences(new Map(Object.entries(config.parameters)))
66- //
67- // for (const [name, match] of referenceParameters) {
68- // const parts = match.split('.');
69- // if (parts.length < 2) {
70- // throw new Error(`Only resource parameter references are allowed. ${match}`);
71- // }
72- //
73- // const referencedId = findId(parts);
74- // if (!referencedId) {
75- // throw new Error(`Unable to find resource being referenced. ${match}`);
76- // }
77- //
78- // const referencedResource = resourceMap.get(referencedId)
79- // if (!referencedResource) {
80- // throw new Error(`Unable to find resource being referenced. ${match}`);
81- // }
82- //
83- // const referencedParameterName = findParameterName(parts, referencedId);
84- // const referencedParameter = referencedResource.parameters.get(referencedParameterName);
85- // if (!referencedParameter) {
86- // throw new Error(`Un-able to find parameter being referenced. ${match}`);
87- // }
88- //
89- // // TODO: Add recursive check for parameters of type parameter
90- //
91- // config.dependencies.push(referencedResource);
92- //
93- // // Substitute with actual value
94- // config.parameters.set(name,
95- // String(config.parameters.get(name)).replace(`\${${match}}`, String(referencedParameter))
96- // );
97- // }
98-
9955 return result . map ( ( n ) => n . val ) ;
10056 }
10157
102- // function findParametersWithReferences(parameters: Record<string, unknown>) {
103- // return [...parameters.entries()]
104- // .map(([name, value]) => [name, String(value), String(value).matchAll(resourceReferenceRegex)] as const)
105- // .filter(([, _, match]) => match)
106- // .flatMap(([name, _, matches]) =>
107- // [...matches].map(match => [name, match[1]] as const)
108- // );
109- // }
110- //
111- // function findId(parts: string[]): null | string {
112- // if (applyableGraph.has(parts[0])) {
113- // return parts[0];
114- // }
115- //
116- // if (applyableGraph.has(parts[0] + '.' + parts[1])) {
117- // return parts[0] + '.' + parts[1];
118- // }
119- //
120- // return null;
121- // }
122- //
123- // function findParameterName(parts: string[], id: string): string {
124- // return id.split('.').length === 1 ? parts[1] : parts[2];
125- // }
126- // };
127-
12858 private static populateNodeDependencies < T > ( nodeMap : Map < string , Node < T > > , getDependencyIds : ( t : T ) => string [ ] ) {
12959 [ ...nodeMap . values ( ) ] . forEach ( ( n ) => {
13060 const dependencies = getDependencyIds ( n . val )
0 commit comments