Skip to content

Commit a8ad62c

Browse files
authored
chore(cli): rename cli-args-gen into user-input-gen (#32821)
This PR does not change CLI functionality because we are not using `CliArguments` yet. This PR includes the following related changes: - `CliArguments` are renamed `UserInput` to reflect what the schema represents -- they are options available to be specified via CLI options or `cdk.json`. - the tool previously known as `cli-arg-gen` is now named `user-input-gen` to reflect this change. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent aff160b commit a8ad62c

33 files changed

+106
-103
lines changed

aws-cdk.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"name": "aws-custom-resource-sdk-adapter",
3232
"rootPath": "packages/@aws-cdk/aws-custom-resource-sdk-adapter"
3333
},
34-
{ "name": "cli-args-gen", "rootPath": "tools/@aws-cdk/cli-args-gen" }
34+
{ "name": "user-input-gen", "rootPath": "tools/@aws-cdk/user-input-gen" }
3535
]
3636
},
3737
"extensions": {

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"packages/@aws-cdk-testing/*",
1111
"packages/@aws-cdk/*/lambda-packages/*",
1212
"tools/@aws-cdk/cdk-build-tools",
13-
"tools/@aws-cdk/cli-args-gen",
13+
"tools/@aws-cdk/user-input-gen",
1414
"tools/@aws-cdk/cdk-release",
1515
"tools/@aws-cdk/node-bundle",
1616
"tools/@aws-cdk/pkglint",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"packages/@aws-cdk-testing/*",
7878
"packages/@aws-cdk/*/lambda-packages/*",
7979
"tools/@aws-cdk/cdk-build-tools",
80-
"tools/@aws-cdk/cli-args-gen",
80+
"tools/@aws-cdk/user-input-gen",
8181
"tools/@aws-cdk/cdk-release",
8282
"tools/@aws-cdk/node-bundle",
8383
"tools/@aws-cdk/pkglint",

packages/aws-cdk/CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
## CLI Commands
22

33
All CDK CLI Commands are defined in `lib/config.ts`. This file is translated
4-
into a valid `yargs` configuration by `bin/cli-args-gen`, which is generated by `@aws-cdk/cli-args-gen`.
4+
into a valid `yargs` configuration by `bin/user-input-gen`, which is generated by `@aws-cdk/user-input-gen`.
55
The `yargs` configuration is generated into the function `parseCommandLineArguments()`,
66
in `lib/parse-command-line-arguments.ts`, and is checked into git for readability and
77
inspectability; do not edit this file by hand, as every subsequent `yarn build` will
88
overwrite any manual edits. If you need to leverage a `yargs` feature not used by
9-
the CLI, you must add support for it to `@aws-cdk/cli-args-gen`.
9+
the CLI, you must add support for it to `@aws-cdk/user-input-gen`.
1010

11-
Note that `bin/cli-args-gen` is executed by `ts-node`, which allows `config.ts` to
11+
Note that `bin/user-input-gen` is executed by `ts-node`, which allows `config.ts` to
1212
reference functions and other identifiers defined in the CLI before the CLI is
1313
built.
1414

1515
### Dynamic Values
1616

1717
Some values, such as the user's platform, cannot be computed at build time.
18-
Some commands depend on these values, and thus `cli-args-gen` must generate the
18+
Some commands depend on these values, and thus `user-input-gen` must generate the
1919
code to compute these values at build time.
2020

2121
The only way to do this today is to reference a parameter with `DynamicValue.fromParameter`.

packages/aws-cdk/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const config = {
1919
"<rootDir>/lib/api/aws-auth/sdk.ts",
2020
// Files generated by cli-args-gen
2121
"<rootDir>/lib/parse-command-line-arguments.ts",
22-
"<rootDir>/lib/cli-arguments.ts",
23-
"<rootDir>/lib/convert-to-cli-args.ts",
22+
"<rootDir>/lib/user-input.ts",
23+
"<rootDir>/lib/convert-to-user-input.ts",
2424
],
2525

2626
// We have many tests here that commonly time out

packages/aws-cdk/lib/config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
2-
import { CliHelpers, type CliConfig } from '@aws-cdk/cli-args-gen';
2+
import { CliHelpers, type CliConfig } from '@aws-cdk/user-input-gen';
33
import { StackActivityProgress } from './api/util/cloudformation/stack-activity-monitor';
44
import { MIGRATE_SUPPORTED_LANGUAGES } from './commands/migrate';
55
import { RequireApproval } from './diff';
@@ -8,8 +8,11 @@ import { availableInitLanguages } from './init';
88
export const YARGS_HELPERS = new CliHelpers('./util/yargs-helpers');
99

1010
/**
11-
* Source of truth for all CDK CLI commands. `cli-args-gen` translates this into the `yargs` definition
12-
* in `lib/parse-command-line-arguments.ts`.
11+
* Source of truth for all CDK CLI commands. `user-input-gen` translates this into:
12+
*
13+
* - the `yargs` definition in `lib/parse-command-line-arguments.ts`.
14+
* - the `UserInput` type in `lib/user-input.ts`.
15+
* - the `convertXxxToUserInput` functions in `lib/convert-to-user-input.ts`.
1316
*/
1417
export async function makeConfig(): Promise<CliConfig> {
1518
return {

packages/aws-cdk/lib/convert-to-cli-args.ts renamed to packages/aws-cdk/lib/convert-to-user-input.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// Do not edit by hand; all changes will be overwritten at build time from the config file.
44
// -------------------------------------------------------------------------------------------
55
/* eslint-disable @stylistic/max-len */
6-
import { CliArguments, GlobalOptions } from './cli-arguments';
76
import { Command } from './settings';
7+
import { UserInput, GlobalOptions } from './user-input';
88

99
// @ts-ignore TS6133
10-
export function convertYargsToCliArgs(args: any): CliArguments {
10+
export function convertYargsToUserInput(args: any): UserInput {
1111
const globalOptions: GlobalOptions = {
1212
app: args.app,
1313
build: args.build,
@@ -250,17 +250,17 @@ export function convertYargsToCliArgs(args: any): CliArguments {
250250
commandOptions = {};
251251
break;
252252
}
253-
const cliArguments: CliArguments = {
253+
const userInput: UserInput = {
254254
_: args._[0],
255255
globalOptions,
256256
[args._[0]]: commandOptions,
257257
};
258258

259-
return cliArguments;
259+
return userInput;
260260
}
261261

262262
// @ts-ignore TS6133
263-
export function convertConfigToCliArgs(config: any): CliArguments {
263+
export function convertConfigToUserInput(config: any): UserInput {
264264
const globalOptions: GlobalOptions = {
265265
app: config.app,
266266
build: config.build,
@@ -428,7 +428,7 @@ export function convertConfigToCliArgs(config: any): CliArguments {
428428
browser: config.docs?.browser,
429429
};
430430
const doctorOptions = {};
431-
const cliArguments: CliArguments = {
431+
const userInput: UserInput = {
432432
globalOptions,
433433
list: listOptions,
434434
synthesize: synthesizeOptions,
@@ -450,5 +450,5 @@ export function convertConfigToCliArgs(config: any): CliArguments {
450450
doctor: doctorOptions,
451451
};
452452

453-
return cliArguments;
453+
return userInput;
454454
}

packages/aws-cdk/lib/cli-arguments.ts renamed to packages/aws-cdk/lib/user-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import { Command } from './settings';
77

88
/**
9-
* The structure of the CLI configuration, generated from packages/aws-cdk/lib/config.ts
9+
* The structure of the user input -- either CLI options or cdk.json -- generated from packages/aws-cdk/lib/config.ts
1010
*
1111
* @struct
1212
*/
13-
export interface CliArguments {
13+
export interface UserInput {
1414
/**
1515
* The CLI command name
1616
*/

packages/aws-cdk/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"scripts": {
99
"build": "cdk-build",
10-
"cli-args-gen": "ts-node --preferTsExts scripts/cli-args-gen.ts",
10+
"user-input-gen": "ts-node --preferTsExts scripts/user-input-gen.ts",
1111
"watch": "cdk-watch",
1212
"lint": "cdk-lint",
1313
"pkglint": "pkglint -f",
@@ -29,7 +29,7 @@
2929
},
3030
"cdk-build": {
3131
"pre": [
32-
"yarn cli-args-gen"
32+
"yarn user-input-gen"
3333
],
3434
"post": [
3535
"cp ../../node_modules/cdk-from-cfn/index_bg.wasm ./lib/",
@@ -70,7 +70,7 @@
7070
"@aws-cdk/cdk-build-tools": "0.0.0",
7171
"@aws-cdk/cli-plugin-contract": "0.0.0",
7272
"@aws-cdk/pkglint": "0.0.0",
73-
"@aws-cdk/cli-args-gen": "0.0.0",
73+
"@aws-cdk/user-input-gen": "0.0.0",
7474
"@octokit/rest": "^18.12.0",
7575
"@types/archiver": "^5.3.4",
7676
"@types/fs-extra": "^9.0.13",

packages/aws-cdk/scripts/cli-args-gen

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)