Skip to content

Commit

Permalink
chore: make @aws-cdk/yargs-gen a devDependency (#32096)
Browse files Browse the repository at this point in the history
`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*
  • Loading branch information
rix0rrr authored Nov 12, 2024
1 parent 5bc0662 commit 338d4c2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
25 changes: 24 additions & 1 deletion packages/aws-cdk/lib/config.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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,
};
}
}
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions tools/@aws-cdk/yargs-gen/lib/yargs-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}

0 comments on commit 338d4c2

Please sign in to comment.