1- // @ts -nocheck
21import * as os from "os" ;
32import * as fs_path from "path" ;
43import * as fs from "fs" ;
54import { fileURLToPath , pathToFileURL } from "url" ;
65
6+ type Tag = { Key : string ; Value : string } ;
7+
78export const PROJECT_CONFIG = "cdk.json" ;
89export const USER_DEFAULTS = "~/.cdk.json" ;
910const CONTEXT_KEY = "context" ;
1011
11- let cdkToolkitPath : string ;
12+ let cdkToolkitPath = "" ;
13+ let cdkToolkitUrl = "" ;
1214
1315try {
14- const cdkToolkitUrl = await import . meta. resolve ! ( "@aws-cdk/toolkit-lib" ) ;
16+ cdkToolkitUrl = await import . meta. resolve ! ( "@aws-cdk/toolkit-lib" ) ;
1517 cdkToolkitPath = fileURLToPath ( cdkToolkitUrl ) ;
1618} catch ( e ) {
1719 // Fallback for test environment where import.meta.resolve is not available
1820 const module = await import ( "module" ) ;
1921 const require = ( module as any ) . createRequire ( import . meta. url ) ;
2022 cdkToolkitPath = require . resolve ( "@aws-cdk/toolkit-lib" ) ;
23+ cdkToolkitUrl = pathToFileURL ( cdkToolkitPath ) . href ;
2124}
2225
2326const { ToolkitError } = await import ( cdkToolkitUrl ) ;
@@ -109,10 +112,10 @@ export class Configuration {
109112 output : "cdk.out" ,
110113 } ) ;
111114
112- private readonly commandLineArguments : Settings ;
113- private readonly commandLineContext : Settings ;
114- private _projectConfig ?: Settings ;
115- private _projectContext ?: Settings ;
115+ private readonly commandLineArguments : typeof Settings ;
116+ private readonly commandLineContext : typeof Settings ;
117+ private _projectConfig ?: typeof Settings ;
118+ private _projectContext ?: typeof Settings ;
116119 private loaded = false ;
117120
118121 constructor ( private readonly props : ConfigurationProps = { } ) {
@@ -198,11 +201,11 @@ export class Configuration {
198201 }
199202}
200203
201- async function loadAndLog ( fileName : string ) : Promise < Settings > {
204+ async function loadAndLog ( fileName : string ) : Promise < typeof Settings > {
202205 return await settingsFromFile ( fileName ) ;
203206}
204207
205- async function settingsFromFile ( fileName : string ) : Promise < Settings > {
208+ async function settingsFromFile ( fileName : string ) : Promise < typeof Settings > {
206209 let settings ;
207210 const expanded = expandHomeDir ( fileName ) ;
208211 if ( fs . existsSync ( expanded ) ) {
@@ -224,7 +227,7 @@ async function settingsFromFile(fileName: string): Promise<Settings> {
224227}
225228
226229function prohibitContextKeys (
227- settings : Settings ,
230+ settings : typeof Settings ,
228231 keys : string [ ] ,
229232 fileName : string
230233) {
@@ -245,7 +248,7 @@ function prohibitContextKeys(
245248}
246249
247250function warnAboutContextKey (
248- settings : Settings ,
251+ settings : typeof Settings ,
249252 prefix : string ,
250253 fileName : string
251254) {
0 commit comments