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

feat(settings): allow project local settings with cdk.local.json #29822

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as util from './util';
export type SettingsMap = {[key: string]: any};

export const PROJECT_CONFIG = 'cdk.json';
export const PROJECT_LOCAL_CONFIG = 'cdk.local.json';
export const PROJECT_CONTEXT = 'cdk.context.json';
export const USER_DEFAULTS = '~/.cdk.json';

Expand Down Expand Up @@ -111,6 +112,7 @@ export class Configuration {
*/
public async load(): Promise<this> {
const userConfig = await loadAndLog(USER_DEFAULTS);
const localConfig = await loadAndLog(PROJECT_LOCAL_CONFIG);
this._projectConfig = await loadAndLog(PROJECT_CONFIG);
this._projectContext = await loadAndLog(PROJECT_CONTEXT);

Expand All @@ -119,6 +121,9 @@ export class Configuration {
if (userConfig.get(['build'])) {
throw new Error('The `build` key cannot be specified in the user config (~/.cdk.json), specify it in the project config (cdk.json) instead');
}
if (localConfig.get(['build'])) {
throw new Error('The `build` key cannot be specified in the local config (cdk.local.json), specify it in the project config (cdk.json) instead');
}

const contextSources = [
this.commandLineContext,
Expand All @@ -135,6 +140,7 @@ export class Configuration {
this.settings = this.defaultConfig
.merge(userConfig)
.merge(this.projectConfig)
.merge(localConfig)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to override cdk.json but still let CLI take precedence.

.merge(this.commandLineArguments)
.makeReadOnly();

Expand Down
Loading