From 338d4c2440fa986dfd88ef8d65e634558c0c1eec Mon Sep 17 00:00:00 2001 From: Rico Hermans Date: Tue, 12 Nov 2024 15:12:02 +0100 Subject: [PATCH] chore: make `@aws-cdk/yargs-gen` a devDependency (#32096) `yargs-gen` used to be a runtime dependency. The only reason seemed to be that there was a factory class for `DynamicResult` types in `yargs-gen`, called `DynamicValue`. In this PR, move the factory to the only location where it is used in the CLI itself, and turn the `import` of `yargs-gen` into an `import type`, which does not imply any runtime dependency. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/config.ts | 25 ++++++++++++++++++++- packages/aws-cdk/package.json | 2 +- tools/@aws-cdk/yargs-gen/lib/yargs-types.ts | 23 ------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/packages/aws-cdk/lib/config.ts b/packages/aws-cdk/lib/config.ts index 5606e65fd22f3..d8f490dac67dc 100644 --- a/packages/aws-cdk/lib/config.ts +++ b/packages/aws-cdk/lib/config.ts @@ -1,4 +1,4 @@ -import { CliConfig, DynamicValue } from '@aws-cdk/yargs-gen'; +import type { CliConfig, DynamicResult } from '@aws-cdk/yargs-gen'; import { StackActivityProgress } from './api/util/cloudformation/stack-activity-monitor'; import { RequireApproval } from './diff'; @@ -417,3 +417,26 @@ export function makeConfig(): CliConfig { }, }; } + +/** + * Informs the code library, `@aws-cdk/yargs-gen`, that + * this value references an entity not defined in this configuration file. + */ +export class DynamicValue { + /** + * Instructs `yargs-gen` to retrieve this value from the parameter with passed name. + */ + public static fromParameter(parameterName: string): DynamicResult { + return { + dynamicType: 'parameter', + dynamicValue: parameterName, + }; + } + + public static fromInline(f: () => any): DynamicResult { + return { + dynamicType: 'function', + dynamicValue: f, + }; + } +} \ No newline at end of file diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index e674d048f16fd..4cad33d3794d2 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -70,6 +70,7 @@ "devDependencies": { "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/pkglint": "0.0.0", + "@aws-cdk/yargs-gen": "0.0.0", "@octokit/rest": "^18.12.0", "@types/archiver": "^5.3.4", "@types/fs-extra": "^9.0.13", @@ -105,7 +106,6 @@ "@aws-cdk/cloudformation-diff": "0.0.0", "@aws-cdk/cx-api": "0.0.0", "@aws-cdk/region-info": "0.0.0", - "@aws-cdk/yargs-gen": "0.0.0", "@aws-sdk/client-appsync": "3.632.0", "@aws-sdk/client-cloudformation": "3.632.0", "@aws-sdk/client-cloudwatch-logs": "3.632.0", diff --git a/tools/@aws-cdk/yargs-gen/lib/yargs-types.ts b/tools/@aws-cdk/yargs-gen/lib/yargs-types.ts index 3ab73594bd557..1178a0601de15 100644 --- a/tools/@aws-cdk/yargs-gen/lib/yargs-types.ts +++ b/tools/@aws-cdk/yargs-gen/lib/yargs-types.ts @@ -55,26 +55,3 @@ export interface DynamicResult { dynamicType: 'parameter' | 'function'; dynamicValue: string | (() => any); } - -/** - * Informs the code library, `@aws-cdk/yargs-gen`, that - * this value references an entity not defined in this configuration file. - */ -export class DynamicValue { - /** - * Instructs `yargs-gen` to retrieve this value from the parameter with passed name. - */ - public static fromParameter(parameterName: string): DynamicResult { - return { - dynamicType: 'parameter', - dynamicValue: parameterName, - }; - } - - public static fromInline(f: () => any): DynamicResult { - return { - dynamicType: 'function', - dynamicValue: f, - }; - } -}