11import { OS , PlanRequestData , ResourceOperation , ValidateResponseData } from 'codify-schemas' ;
2- import * as os from 'os'
2+ import * as os from 'node: os'
33import { validate } from 'uuid'
44
55import {
@@ -14,30 +14,29 @@ import { SourceMapCache } from '../parser/source-maps.js';
1414import { ResourceDefinitionMap } from '../plugins/plugin-manager.js' ;
1515import { DependencyGraphResolver } from '../utils/dependency-graph-resolver.js' ;
1616import { groupBy } from '../utils/index.js' ;
17+ import { ShellUtils } from '../utils/shell.js' ;
1718import { ConfigBlock , ConfigType } from './config.js' ;
1819import { type Plan } from './plan.js' ;
1920import { ProjectConfig } from './project-config.js' ;
2021import { ResourceConfig } from './resource-config.js' ;
21- import { ShellUtils } from '../utils/shell.js' ;
2222
2323export class Project {
2424 projectConfig : ProjectConfig | null ;
2525 resourceConfigs : ResourceConfig [ ] ;
2626 stateConfigs : ResourceConfig [ ] | null = null ;
2727 evaluationOrder : null | string [ ] = null ;
2828
29- codifyFiles : string [ ] ;
30-
29+ path ?: string ;
3130 sourceMaps ?: SourceMapCache ;
3231 planRequestsCache ?: Map < string , PlanRequestData >
3332
3433 isDestroyProject = false ;
3534
3635 static empty ( ) : Project {
37- return Project . create ( [ ] , [ ] ) ;
36+ return Project . create ( [ ] ) ;
3837 }
3938
40- static create ( configs : ConfigBlock [ ] , codifyFiles : string [ ] , sourceMaps ?: SourceMapCache ) : Project {
39+ static create ( configs : ConfigBlock [ ] , path ? : string , sourceMaps ?: SourceMapCache ) : Project {
4140 const projectConfigs = configs . filter ( ( u ) => u . configClass === ConfigType . PROJECT ) ;
4241 if ( projectConfigs . length > 1 ) {
4342 throw new Error ( `Only one project config can be specified. Found ${ projectConfigs . length } . \n\n
@@ -47,16 +46,16 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
4746 return new Project (
4847 ( projectConfigs [ 0 ] as ProjectConfig ) ?? null ,
4948 configs . filter ( ( u ) => u . configClass !== ConfigType . PROJECT ) as ResourceConfig [ ] ,
50- codifyFiles ,
49+ path ,
5150 sourceMaps ,
5251 ) ;
5352 }
5453
55- constructor ( projectConfig : ProjectConfig | null , resourceConfigs : ResourceConfig [ ] , codifyFiles : string [ ] , sourceMaps ?: SourceMapCache ) {
54+ constructor ( projectConfig : ProjectConfig | null , resourceConfigs : ResourceConfig [ ] , path ? : string , sourceMaps ?: SourceMapCache ) {
5655 this . projectConfig = projectConfig ;
5756 this . resourceConfigs = resourceConfigs ;
5857 this . sourceMaps = sourceMaps ;
59- this . codifyFiles = codifyFiles ;
58+ this . path = path ;
6059
6160 this . addUniqueNamesForDuplicateResources ( )
6261 }
@@ -66,7 +65,7 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
6665 }
6766
6867 exists ( ) : boolean {
69- return this . codifyFiles . length > 0 ;
68+ return Boolean ( this . path ) ;
7069 }
7170
7271 isStateful ( ) : boolean {
@@ -75,7 +74,7 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
7574
7675 // TODO: Update to a more robust method in the future
7776 isCloud ( ) : boolean {
78- return validate ( this . codifyFiles [ 0 ] )
77+ return Boolean ( this . path && validate ( this . path ) ) ;
7978 }
8079
8180 filterInPlace ( ids : string [ ] ) : Project {
@@ -130,7 +129,7 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
130129 const uninstallProject = new Project (
131130 this . projectConfig ,
132131 this . resourceConfigs ,
133- this . codifyFiles ,
132+ this . path ,
134133 this . sourceMaps ,
135134 )
136135
0 commit comments