From ef02b2c7e9bebd66be279a651d72f0f71169c3d9 Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Wed, 15 Jan 2025 15:05:45 +0000 Subject: [PATCH] chore(toolkit): it's alive! --- packages/@aws-cdk/toolkit/.gitignore | 1 + .../api/cloud-assembly/private/from-app.ts | 63 ------------------- .../lib/api/cloud-assembly/stack-assembly.ts | 2 +- .../toolkit/lib/api/io/private/messages.ts | 2 +- .../toolkit/lib/api/io/private/types.ts | 2 +- packages/@aws-cdk/toolkit/lib/toolkit.ts | 2 +- 6 files changed, 5 insertions(+), 67 deletions(-) delete mode 100644 packages/@aws-cdk/toolkit/lib/api/cloud-assembly/private/from-app.ts diff --git a/packages/@aws-cdk/toolkit/.gitignore b/packages/@aws-cdk/toolkit/.gitignore index 4da3f8ac49de4..9552f19942613 100644 --- a/packages/@aws-cdk/toolkit/.gitignore +++ b/packages/@aws-cdk/toolkit/.gitignore @@ -1,6 +1,7 @@ *.js *.js.map *.d.ts +*.d.ts.map *.gz node_modules dist diff --git a/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/private/from-app.ts b/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/private/from-app.ts deleted file mode 100644 index a99e0aa51f4ff..0000000000000 --- a/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/private/from-app.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { ToolkitError } from '../../errors'; -import { ContextAwareCloudAssembly } from '../context-aware-source'; -import { ICloudAssemblySource } from '../types'; - -/** - * Configuration for creating a CLI from an AWS CDK App directory - */ -export interface FromCdkAppProps { -/** - * @default - current working directory - */ - readonly workingDirectory?: string; - - /** - * Emits the synthesized cloud assembly into a directory - * - * @default cdk.out - */ - readonly output?: string; -} - -/** - * Use a directory containing an AWS CDK app as source. - * @param directory the directory of the AWS CDK app. Defaults to the current working directory. - * @param props additional configuration properties - * @returns an instance of `AwsCdkCli` - */ -export function fromCdkApp(app: string, props: FromCdkAppProps = {}): ICloudAssemblySource { - return new ContextAwareCloudAssembly( - { - produce: async () => { - await this.lock?.release(); - - try { - const build = this.props.configuration.settings.get(['build']); - if (build) { - await exec(build, { cwd: props.workingDirectory }); - } - - const commandLine = await guessExecutable(app); - const outdir = props.output ?? 'cdk.out'; - - try { - fs.mkdirpSync(outdir); - } catch (e: any) { - throw new ToolkitError(`Could not create output directory at '${outdir}' (${e.message}).`); - } - - this.lock = await new RWLock(outdir).acquireWrite(); - - const env = await prepareDefaultEnvironment(this.props.sdkProvider, { outdir }); - return await withContext(env, this.props.configuration, async (envWithContext, _context) => { - await exec(commandLine.join(' '), { extraEnv: envWithContext, cwd: props.workingDirectory }); - return createAssembly(outdir); - }); - } finally { - await this.lock?.release(); - } - }, - }, - this.propsForContextAssembly, - ); -} diff --git a/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/stack-assembly.ts b/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/stack-assembly.ts index da664aa5200fd..4f56b02cc0935 100644 --- a/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/stack-assembly.ts +++ b/packages/@aws-cdk/toolkit/lib/api/cloud-assembly/stack-assembly.ts @@ -1,8 +1,8 @@ import * as cxapi from '@aws-cdk/cx-api'; import { CloudAssembly, sanitizePatterns, StackCollection, ExtendedStackSelection as CliExtendedStackSelection } from 'aws-cdk/lib/api/cxapp/cloud-assembly'; import { major } from 'semver'; -import { ICloudAssemblySource } from './types'; import { ExtendedStackSelection, StackSelectionStrategy, StackSelector } from './stack-selector'; +import { ICloudAssemblySource } from './types'; import { ToolkitError } from '../errors'; /** diff --git a/packages/@aws-cdk/toolkit/lib/api/io/private/messages.ts b/packages/@aws-cdk/toolkit/lib/api/io/private/messages.ts index 98e479253a7ce..3a44f3bf71172 100644 --- a/packages/@aws-cdk/toolkit/lib/api/io/private/messages.ts +++ b/packages/@aws-cdk/toolkit/lib/api/io/private/messages.ts @@ -76,7 +76,7 @@ export const error = (message: string, code?: IoMessageCode, payload?: T) => /** * Logs an warning level message. */ -export const warning = (message: string, code?: IoMessageCode, payload?: T) => { +export const warn = (message: string, code?: IoMessageCode, payload?: T) => { return formatMessage({ level: 'warn', code, diff --git a/packages/@aws-cdk/toolkit/lib/api/io/private/types.ts b/packages/@aws-cdk/toolkit/lib/api/io/private/types.ts index 2009b442dbdd7..27f14c55e8d0a 100644 --- a/packages/@aws-cdk/toolkit/lib/api/io/private/types.ts +++ b/packages/@aws-cdk/toolkit/lib/api/io/private/types.ts @@ -8,7 +8,7 @@ export type ActionLessRequest = Omit, 'action'>; /** * Helper type for IoHosts that are action aware */ -export interface ActionlessIoHost extends IIoHost { +export interface ActionAwareIoHost extends IIoHost { notify(msg: ActionLessMessage): Promise; requestResponse(msg: ActionLessRequest): Promise; } diff --git a/packages/@aws-cdk/toolkit/lib/toolkit.ts b/packages/@aws-cdk/toolkit/lib/toolkit.ts index 7d407e200762d..d2ba754de0bfa 100644 --- a/packages/@aws-cdk/toolkit/lib/toolkit.ts +++ b/packages/@aws-cdk/toolkit/lib/toolkit.ts @@ -28,7 +28,7 @@ import { CachedCloudAssemblySource, IdentityCloudAssemblySource, StackAssembly, import { StackSelectionStrategy } from './api/cloud-assembly/stack-selector'; import { ToolkitError } from './api/errors'; import { IIoHost, IoMessageCode, IoMessageLevel } from './api/io'; -import { asSdkLogger, withAction, ActionAwareIoHost, Timer, confirm, data, error, highlight, info, success, warn } from './api/io/private'; +import { asSdkLogger, withAction, Timer, confirm, data, error, highlight, info, success, warn, ActionAwareIoHost } from './api/io/private'; /** * The current action being performed by the CLI. 'none' represents the absence of an action.