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

Ensure all CLI options can always be configured as CLI option and in cdk.json #32474

Open
mrgrain opened this issue Dec 11, 2024 · 0 comments
Open
Assignees
Labels

Comments

@mrgrain
Copy link
Contributor

mrgrain commented Dec 11, 2024

Refactor the code so that we can never fail to have an option that is only supported in cdk.json but not as CLI option or vice versa.

We do NOT have to support all variations of cli options, i.e. rollback: bool in cdk.json is fine to represent --rollback, --no-rollback or --rollback=false

@kaizencc kaizencc self-assigned this Dec 11, 2024
mergify bot pushed a commit that referenced this issue Dec 19, 2024
This PR: 

- generates a new type, `CliArguments` which is an interface created from the cli source-of-truth in `config.ts`.
- renames `yargs-gen` into `cli-args-gen` to better reflect what we are generating now

The purpose of `CliArguments` is to eventually replace our current `Arguments` type, turning it into a strongly-typed object. `Arguments` today looks like this:

```ts
export type Arguments = {
  readonly _: [Command, ...string[]];
  readonly exclusively?: boolean;
  readonly STACKS?: string[];
  readonly lookups?: boolean;
  readonly [name: string]: unknown;
};
```

And because the last line in the definition essentially accepts any kind of property, we end up passing in and using values that are not documented anywhere. The purpose of this PR is to introduce a better type to enforce that the `args` object in `cli.ts` only holds values we expect. We are not currently using the new type anywhere; that will be done in a subsequent PR. 

The success criteria of this PR is that we are generating a new type from the source of truth that will eventually represent the type of the object we receive from CLI inputs.

Part of #32474 


### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@khushail khushail added the p2 label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants