[CLI] Where can I find an example of ~/.cdk.json file configuration
:question: General Issue
The Question
Hello,
I'm trying to use newly issued fix for progress bar vs events on a more global level. I've tried creating ~/.cdk.json but I can't seem to get it right. I haven't seen any examples in docs showing how to properly configure ~/.cdk.json globally.
Can you please provide an example how to do this?
Thanks!
Environment
- CDK CLI Version: 1.63.0
- Node.js Version: v14.11.0
- OS: OSX Mojave
- Language (Version): TypeScript (3.8.3)
You should have a cdk.json file in your directory, it is created by the cdk init when creating a cdk application. In any case you can execute cdk init in an empty folder to get the file.
Hello, @NetaNir. I'm not referring to a new project here. I was referring to a global environment (~/.cdk.json) as stated in the documentation (5th bullet).
https://docs.aws.amazon.com/cdk/latest/guide/context.html

I'd really like to declare variables on a global level so that all of my projects are using --progress=events setting introduced in https://github.com/aws/aws-cdk/pull/9623.
@NetaNir Here are the contents of my ~/.cdk.json file, but they're being ignored when I run cdk init app in a new project. What am I doing wrong?
{
"context": {
"language": "typescript",
"progress": "events"
}
}
Edit: I see that ~/.cdk.json is being loaded as a default in https://github.com/aws/aws-cdk/blob/master/packages/aws-cdk/lib/settings.ts#L12. However, it seems to me that if local cdk.json exists, then global config (in ~/.cdk.json) gets overridden by the local one (in cdk.json). Shouldn't just local be merged into global instead?
@robertd Thanks for debugging this. I think that this is the expected behavior, the local cdk.json take precedence over the global one. Merging logic will most likely be more confusing. We definitely need to document the order in which the context values are populated to out docs. @Jerry-AWS
Merge logic may be confusing, but without it, ~/.cdk.json is pretty well useless. As a developer who works on a number of different small projects in CDK, I would expect ~/.cdk.json to contain global configuration values - such as setting progress to bar vs. events, or a default language, and the local cdk.json to contain local configuration and overrides. Otherwise, as I said above, what's the point of ~/.cdk.json?
@kpeters-cbsi @robertd Your comments on expected behavior of merging context from ~/.cdk.json are relating to #10823 (... where I have added a PR)
@bitbauer Sweet. Thank you. 🙏
Closed by #12394
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.