Skip to content

feat: refactor options can be provided via the config file #714

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,33 @@ locations for a given environment. Resource locations are in the format
resource currently deployed, while the destination must refer to a location
that is not already occupied by any resource.

All command line options that are also available in the configuration file
(`cdk.json`) in the `refactor` section. For example, you can specify the
`--dry-run` option in `cdk.json` as follows:

```json
{
"app": "node bin/main.js",
"refactor": {
"dryRun": true
}
}
```

The same naming pattern applies to all other options, except for
`--additional-stack-name`, which becomes `additionalStackNames`:

```json
{
"app": "node bin/main.js",
"refactor": {
"additionalStackNames": [
"Foo",
"Bar"
]
}
}
```

### `cdk drift`

Expand Down
14 changes: 10 additions & 4 deletions packages/aws-cdk/lib/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,19 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
throw new ToolkitError('Unstable feature use: \'refactor\' is unstable. It must be opted in via \'--unstable\', e.g. \'cdk refactor --unstable=refactor\'');
}

const getOptionValue = (name: string) => args[name] ?? configuration.settings.get(['refactor', name]);

const additionalStackNames = args.additionalStackName != null
? arrayFromYargs(args.additionalStackName ?? [])
: configuration.settings.get(['refactor', 'additionalStackNames']) ?? [];

ioHost.currentAction = 'refactor';
return cli.refactor({
dryRun: args.dryRun,
overrideFile: args.overrideFile,
revert: args.revert,
dryRun: getOptionValue('dryRun'),
overrideFile: getOptionValue('overrideFile'),
revert: getOptionValue('revert'),
stacks: selector,
additionalStackNames: arrayFromYargs(args.additionalStackName ?? []),
additionalStackNames,
});

case 'bootstrap':
Expand Down
Loading