Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): generate yargs configuration from TS #31850

Merged
merged 29 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
637d5a9
init
comcalvi Oct 14, 2024
3097ee5
prototype
comcalvi Oct 14, 2024
e3b3d61
args fix + the yargs inline function for the options is still wrong
comcalvi Oct 14, 2024
19e92a3
middleware + more options
comcalvi Oct 15, 2024
8e0421b
docstring
comcalvi Oct 15, 2024
8ca3812
all commands + options, missing epilogue + preamble still
comcalvi Oct 16, 2024
7c04ce0
working w/parameters
comcalvi Oct 21, 2024
13c60eb
comment
comcalvi Oct 21, 2024
4740b49
console
comcalvi Oct 22, 2024
37c55ee
move to the CLI...using ts-node is probably too large a deviation fro…
comcalvi Oct 22, 2024
5353bb7
comments
comcalvi Oct 22, 2024
814e36f
var-naming
comcalvi Oct 22, 2024
545128c
un-ignore
comcalvi Oct 23, 2024
869765b
\n
comcalvi Oct 23, 2024
f88ce55
docs
comcalvi Oct 23, 2024
feb8766
conflicts
comcalvi Oct 24, 2024
f5a6eec
dynamic expressions-ish + global options
comcalvi Oct 24, 2024
dad0479
bootstrap
comcalvi Oct 24, 2024
0c08bf3
docstrings
comcalvi Oct 24, 2024
0000df6
merge
comcalvi Oct 25, 2024
16f1c0d
ooh man
comcalvi Oct 25, 2024
345360f
Merge branch 'main' of github.com:aws/aws-cdk into comcalvi/cli-yargs…
comcalvi Oct 26, 2024
b0cb288
scripts dir
comcalvi Nov 1, 2024
72759ca
fixed the middleware
comcalvi Nov 1, 2024
d677a02
Merge branch 'main' into comcalvi/cli-yargs-code-gen
mrgrain Nov 4, 2024
616e1fd
Merge branch 'main' into comcalvi/cli-yargs-code-gen
mrgrain Nov 5, 2024
bf013e7
fix formatting
mrgrain Nov 5, 2024
ddd7eae
Merge branch 'main' into comcalvi/cli-yargs-code-gen
mrgrain Nov 5, 2024
f7a09b0
latest updates
mrgrain Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"packages/@aws-cdk-testing/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/@aws-cdk/cdk-build-tools",
"tools/@aws-cdk/yargs-gen",
"tools/@aws-cdk/cdk-release",
"tools/@aws-cdk/node-bundle",
"tools/@aws-cdk/pkglint",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"packages/@aws-cdk-testing/*",
"packages/@aws-cdk/*/lambda-packages/*",
"tools/@aws-cdk/cdk-build-tools",
"tools/@aws-cdk/yargs-gen",
"tools/@aws-cdk/cdk-release",
"tools/@aws-cdk/node-bundle",
"tools/@aws-cdk/pkglint",
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ The @aws-cdk/cli-lib-alpha package includes the following third-party software/l

----------------

** @jsii/check-node@1.103.1 - https://www.npmjs.com/package/@jsii/check-node/v/1.103.1 | Apache-2.0
** @jsii/check-node@1.104.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.104.0 | Apache-2.0
jsii
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand Down Expand Up @@ -3562,7 +3562,7 @@ THE SOFTWARE.

----------------

** tslib@2.7.0 - https://www.npmjs.com/package/tslib/v/2.7.0 | 0BSD
** tslib@2.8.0 - https://www.npmjs.com/package/tslib/v/2.8.0 | 0BSD
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
Expand Down
23 changes: 23 additions & 0 deletions packages/aws-cdk/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## CLI Commands

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

Note that `bin/yargs-gen` is executed by `ts-node`, which allows `config.ts` to
reference functions and other identifiers defined in the CLI before the CLI is
built.

### Dynamic Values

Some values, such as the user's platform, cannot be computed at build time.
Some commands depend on these values, and thus `yargs-gen` must generate the
code to compute these values at build time.

The only way to do this today is to reference a parameter with `DynamicValue.fromParameter`.
The caller of `parseCommandLineArguments()` must pass the parameter.

## Integration Tests

Unit tests are automatically run as part of the regular build. Integration tests
Expand Down
342 changes: 14 additions & 328 deletions packages/aws-cdk/lib/cli.ts

Large diffs are not rendered by default.

419 changes: 419 additions & 0 deletions packages/aws-cdk/lib/config.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/aws-cdk/lib/notices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface NoticesProps {
*
* @default false
*/
readonly includeAcknowlegded?: boolean;
readonly includeAcknowledged?: boolean;

}

Expand Down Expand Up @@ -223,7 +223,7 @@ export class Notices {
private constructor(props: NoticesProps) {
this.configuration = props.configuration;
this.acknowledgedIssueNumbers = new Set(this.configuration.context.get('acknowledged-issue-numbers') ?? []);
this.includeAcknowlegded = props.includeAcknowlegded ?? false;
this.includeAcknowlegded = props.includeAcknowledged ?? false;
}

/**
Expand Down
Loading
Loading