@cdktn/cli-core 0.25.0-pre.9 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/build/lib/cdktf-config.d.ts +1 -0
- package/build/lib/cdktf-config.d.ts.map +1 -1
- package/build/lib/cdktf-config.js +23 -8
- package/build/lib/cdktf-project.d.ts +12 -2
- package/build/lib/cdktf-project.d.ts.map +1 -1
- package/build/lib/cdktf-project.js +72 -61
- package/build/lib/cdktf-stack.d.ts +0 -6
- package/build/lib/cdktf-stack.d.ts.map +1 -1
- package/build/lib/cdktf-stack.js +6 -56
- package/build/lib/convert.js +19 -10
- package/build/lib/dependencies/cdktf-config-manager.d.ts +5 -1
- package/build/lib/dependencies/cdktf-config-manager.d.ts.map +1 -1
- package/build/lib/dependencies/cdktf-config-manager.js +36 -7
- package/build/lib/dependencies/dependency-manager.d.ts +17 -6
- package/build/lib/dependencies/dependency-manager.d.ts.map +1 -1
- package/build/lib/dependencies/dependency-manager.js +79 -49
- package/build/lib/dependencies/package-manager.d.ts.map +1 -1
- package/build/lib/dependencies/package-manager.js +108 -29
- package/build/lib/dependencies/prebuilt-providers.d.ts +3 -0
- package/build/lib/dependencies/prebuilt-providers.d.ts.map +1 -1
- package/build/lib/dependencies/prebuilt-providers.js +88 -28
- package/build/lib/dependencies/registry-api.d.ts +10 -0
- package/build/lib/dependencies/registry-api.d.ts.map +1 -1
- package/build/lib/dependencies/registry-api.js +35 -13
- package/build/lib/dependencies/version-constraints.js +20 -11
- package/build/lib/error-reporting.d.ts +1 -1
- package/build/lib/error-reporting.d.ts.map +1 -1
- package/build/lib/error-reporting.js +111 -41
- package/build/lib/errors.d.ts.map +1 -1
- package/build/lib/execution-logs.js +2 -3
- package/build/lib/get.js +21 -11
- package/build/lib/helpers/stack-helpers.js +8 -9
- package/build/lib/init.d.ts +6 -2
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +82 -21
- package/build/lib/installed-binary-check.d.ts +4 -3
- package/build/lib/installed-binary-check.d.ts.map +1 -1
- package/build/lib/installed-binary-check.js +28 -14
- package/build/lib/local-provider-constraints.js +18 -8
- package/build/lib/local-provider-versions.d.ts.map +1 -1
- package/build/lib/local-provider-versions.js +8 -5
- package/build/lib/models/deploy-machine.d.ts +3 -3
- package/build/lib/models/deploy-machine.d.ts.map +1 -1
- package/build/lib/models/deploy-machine.js +10 -10
- package/build/lib/models/interactive-process.js +2 -3
- package/build/lib/models/schema.js +18 -8
- package/build/lib/models/terraform-cli.d.ts.map +1 -1
- package/build/lib/models/terraform-cli.js +33 -20
- package/build/lib/models/terraform.d.ts.map +1 -1
- package/build/lib/models/terraform.js +4 -3
- package/build/lib/output.d.ts +1 -1
- package/build/lib/output.d.ts.map +1 -1
- package/build/lib/output.js +41 -23
- package/build/lib/provider-add.d.ts.map +1 -1
- package/build/lib/provider-add.js +41 -4
- package/build/lib/server/terraform-logs.js +2 -3
- package/build/lib/synth-stack.d.ts +7 -3
- package/build/lib/synth-stack.d.ts.map +1 -1
- package/build/lib/synth-stack.js +55 -16
- package/build/lib/synth.js +19 -10
- package/build/lib/terraform-json.js +18 -8
- package/build/lib/terraform-provider-lock.d.ts +8 -0
- package/build/lib/terraform-provider-lock.d.ts.map +1 -1
- package/build/lib/terraform-provider-lock.js +47 -1
- package/build/lib/watch.d.ts.map +1 -1
- package/build/lib/watch.js +73 -33
- package/eslint.config.mjs +11 -0
- package/package.json +31 -14
- package/templates/csharp/AGENTS.md +33 -0
- package/templates/csharp/{cdktf.json → cdktf.json{{}}} +2 -0
- package/templates/go/AGENTS.md +33 -0
- package/templates/go/{cdktf.json → cdktf.json{{}}} +2 -0
- package/templates/java/AGENTS.md +33 -0
- package/templates/java/{cdktf.json → cdktf.json{{}}} +2 -0
- package/templates/java/gradlew +0 -0
- package/templates/python/AGENTS.md +33 -0
- package/templates/python/Pipfile +1 -1
- package/templates/python/{cdktf.json → cdktf.json{{}}} +2 -0
- package/templates/python-pip/AGENTS.md +33 -0
- package/templates/python-pip/{cdktf.json → cdktf.json{{}}} +2 -0
- package/templates/typescript/.hooks.sscaff.js +98 -7
- package/templates/typescript/AGENTS.md +33 -0
- package/templates/typescript/{cdktf.json → cdktf.json{{}}} +3 -1
- package/templates/typescript/help +16 -16
- package/templates/typescript/jest.config.js +1 -1
- package/templates/typescript/package.json +2 -2
- package/templates/typescript/tsconfig.json +7 -0
- package/templates/typescript-pnpm/pnpm-workspace.yaml +4 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This is a [CDK Terrain](https://cdktn.io) (CDKTN) project written in Python. CDKTN is the
|
|
4
|
+
community-maintained successor to CDK for Terraform (CDKTF): the library and CLI are both named `cdktn`.
|
|
5
|
+
Packages, imports and some behavior differ from CDKTF, so check the CDKTN docs instead of relying on
|
|
6
|
+
prior CDKTF knowledge.
|
|
7
|
+
|
|
8
|
+
## Docs
|
|
9
|
+
|
|
10
|
+
- Docs MCP server: https://cdktn.io/docs/mcp (streamable HTTP, no auth). `.mcp.json` registers it for
|
|
11
|
+
Claude Code; for other clients add it as a remote MCP server, or run
|
|
12
|
+
`claude mcp add --transport http cdktn https://cdktn.io/docs/mcp`
|
|
13
|
+
- Agent skill: https://cdktn.io/docs/skill.md
|
|
14
|
+
- LLM index: https://cdktn.io/llms.txt
|
|
15
|
+
- Migrating from CDKTF: https://cdktn.io/docs/release/upgrade-guide-v0-22
|
|
16
|
+
|
|
17
|
+
## Layout
|
|
18
|
+
|
|
19
|
+
- `main.py`: the app; define stacks and resources here
|
|
20
|
+
- `cdktf.json`: project config (language, app command, providers, modules)
|
|
21
|
+
- `imports/`: provider and module bindings generated by `cdktn get`; do not edit by hand
|
|
22
|
+
- `cdktf.out/`: Terraform JSON written by `cdktn synth`; do not edit
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
- `cdktn provider add <provider>`: add a provider (uses a prebuilt package when one exists)
|
|
27
|
+
- `cdktn get`: generate bindings for the providers and modules in `cdktf.json`
|
|
28
|
+
- `cdktn synth`: synthesize Terraform JSON into `cdktf.out/`
|
|
29
|
+
- `cdktn diff [stack]`: plan changes for a stack
|
|
30
|
+
- `cdktn deploy [stack]` / `cdktn destroy [stack]`: change real infrastructure; ask before running
|
|
31
|
+
- `pytest main-test.py`: run unit tests
|
|
32
|
+
|
|
33
|
+
The `help` file lists every command for this project.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/open-constructs/cdk-terrain/v{{cdktf_version}}/cdktf.schema.json",
|
|
2
3
|
"language": "python",
|
|
3
4
|
"app": "python3 ./main.py",
|
|
4
5
|
"projectId": "{{projectId}}",
|
|
@@ -7,6 +8,7 @@
|
|
|
7
8
|
"terraform": ">=1.5.7",
|
|
8
9
|
"opentofu": ">=1.6.0"
|
|
9
10
|
},
|
|
11
|
+
"sendUsageTelemetry": "{{sendUsageTelemetry}}",
|
|
10
12
|
"terraformProviders": [],
|
|
11
13
|
"terraformModules": [],
|
|
12
14
|
"codeMakerOutput": "imports",
|
|
@@ -4,7 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const { execSync } = require("child_process");
|
|
7
|
-
const { readFileSync, writeFileSync } = require("fs");
|
|
7
|
+
const { cpSync, readFileSync, writeFileSync } = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
// pnpm-workspace.yaml approves dependency build scripts with `allowBuilds`, which older versions ignore.
|
|
11
|
+
const minimumPnpmVersion = [10, 26];
|
|
12
|
+
|
|
13
|
+
exports.pre = (ctx) => {
|
|
14
|
+
if (ctx.packageManager === "pnpm") {
|
|
15
|
+
requirePnpm();
|
|
16
|
+
} else {
|
|
17
|
+
requirePackageManager("npm");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
8
20
|
|
|
9
21
|
exports.post = (ctx) => {
|
|
10
22
|
const silent = ctx.silent === "true" || ctx.silent === true;
|
|
@@ -28,21 +40,100 @@ exports.post = (ctx) => {
|
|
|
28
40
|
throw new Error(`missing context "npm_cdktf"`);
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
43
|
+
// A variant (a sibling template directory such as typescript-pnpm) contributes the files this template lacks,
|
|
44
|
+
// and they have to be in place before the install below reads them.
|
|
45
|
+
if (ctx.variant) {
|
|
46
|
+
cpSync(path.join(__dirname, "..", ctx.variant), ".", { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// `constructs@10` resolves to the newest 10.x, which satisfies the `^10.6.0`
|
|
50
|
+
// peer range cdktn declares; that peer range is the real constraint, so
|
|
51
|
+
// only the major here has to follow cdktn's.
|
|
52
|
+
installDeps(ctx.pmAdd, [npm_cdktf, `constructs@10`], false, silent);
|
|
53
|
+
// Capped below 7.x: that is the native port, which jsii does not support yet.
|
|
34
54
|
installDeps(
|
|
35
|
-
|
|
55
|
+
ctx.pmAdd,
|
|
56
|
+
[
|
|
57
|
+
"@types/node",
|
|
58
|
+
"typescript@>=5.0.0 <7.0.0",
|
|
59
|
+
"jest",
|
|
60
|
+
"@types/jest",
|
|
61
|
+
"ts-jest",
|
|
62
|
+
"tsx",
|
|
63
|
+
],
|
|
36
64
|
true,
|
|
37
65
|
silent
|
|
38
66
|
);
|
|
39
67
|
|
|
68
|
+
if (ctx.packageManager === "pnpm") {
|
|
69
|
+
pinPackageManager("pnpm", packageManagerVersion("pnpm"));
|
|
70
|
+
}
|
|
71
|
+
|
|
40
72
|
if (!silent) {
|
|
41
73
|
console.log(readFileSync("./help", "utf-8"));
|
|
42
74
|
}
|
|
43
75
|
};
|
|
44
76
|
|
|
45
|
-
function
|
|
77
|
+
function requirePackageManager(packageManager) {
|
|
78
|
+
const probe = process.platform === "win32" ? "where" : "which";
|
|
79
|
+
try {
|
|
80
|
+
execSync(`${probe} ${packageManager}`, { stdio: "ignore" });
|
|
81
|
+
} catch {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Could not find "${packageManager}" on your PATH. Install it (e.g. "corepack enable ${packageManager}") and run cdktn init again.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function requirePnpm() {
|
|
89
|
+
const version = packageManagerVersion("pnpm");
|
|
90
|
+
if (!version) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Could not find "pnpm" on your PATH. Install it (e.g. "corepack enable pnpm") and run cdktn init again.`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const [major, minor] = version.split(".").map(Number);
|
|
96
|
+
const [minMajor, minMinor] = minimumPnpmVersion;
|
|
97
|
+
if (major < minMajor || (major === minMajor && minor < minMinor)) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`pnpm ${version} is too old: this template needs pnpm ${minMajor}.${minMinor} or newer.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Record the package manager that just installed the dependencies, so corepack reproduces it for everyone working
|
|
106
|
+
* on the project. The version is read at scaffold time rather than baked into the template, which would go stale
|
|
107
|
+
* with every release.
|
|
108
|
+
*/
|
|
109
|
+
function pinPackageManager(packageManager, version) {
|
|
110
|
+
if (!version) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const pkg = JSON.parse(readFileSync("./package.json", "utf-8"));
|
|
115
|
+
pkg.packageManager = `${packageManager}@${version}`;
|
|
116
|
+
writeFileSync("./package.json", `${JSON.stringify(pkg, null, 2)}\n`, "utf-8");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function packageManagerVersion(packageManager) {
|
|
120
|
+
let version;
|
|
121
|
+
try {
|
|
122
|
+
version = execSync(`${packageManager} --version`, {
|
|
123
|
+
encoding: "utf-8",
|
|
124
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
125
|
+
}).trim();
|
|
126
|
+
} catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Anything but a plain version (a corepack passthrough message, say) is not safe to rely on.
|
|
131
|
+
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version)
|
|
132
|
+
? version
|
|
133
|
+
: undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function installDeps(pmAdd, deps, isDev, silent) {
|
|
46
137
|
const devDep = isDev ? "-D" : "";
|
|
47
138
|
// make sure we're installing dev dependencies as well
|
|
48
139
|
const env = Object.assign({}, process.env);
|
|
@@ -54,7 +145,7 @@ function installDeps(deps, isDev, silent) {
|
|
|
54
145
|
// character and would silently turn `cdktn@^1.2.3` into `cdktn@1.2.3`.
|
|
55
146
|
const specs = deps.map((dep) => `"${dep}"`).join(" ");
|
|
56
147
|
|
|
57
|
-
execSync(
|
|
148
|
+
execSync(`${pmAdd} ${devDep} ${specs}`, {
|
|
58
149
|
stdio: silent ? "ignore" : "inherit",
|
|
59
150
|
env,
|
|
60
151
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This is a [CDK Terrain](https://cdktn.io) (CDKTN) project written in TypeScript. CDKTN is the
|
|
4
|
+
community-maintained successor to CDK for Terraform (CDKTF): the library and CLI are both named `cdktn`.
|
|
5
|
+
Packages, imports and some behavior differ from CDKTF, so check the CDKTN docs instead of relying on
|
|
6
|
+
prior CDKTF knowledge.
|
|
7
|
+
|
|
8
|
+
## Docs
|
|
9
|
+
|
|
10
|
+
- Docs MCP server: https://cdktn.io/docs/mcp (streamable HTTP, no auth). `.mcp.json` registers it for
|
|
11
|
+
Claude Code; for other clients add it as a remote MCP server, or run
|
|
12
|
+
`claude mcp add --transport http cdktn https://cdktn.io/docs/mcp`
|
|
13
|
+
- Agent skill: https://cdktn.io/docs/skill.md
|
|
14
|
+
- LLM index: https://cdktn.io/llms.txt
|
|
15
|
+
- Migrating from CDKTF: https://cdktn.io/docs/release/upgrade-guide-v0-22
|
|
16
|
+
|
|
17
|
+
## Layout
|
|
18
|
+
|
|
19
|
+
- `main.ts`: the app; define stacks and resources here
|
|
20
|
+
- `cdktf.json`: project config (language, app command, providers, modules)
|
|
21
|
+
- `.gen/`: provider and module bindings generated by `cdktn get`; do not edit by hand
|
|
22
|
+
- `cdktf.out/`: Terraform JSON written by `cdktn synth`; do not edit
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
- `cdktn provider add <provider>`: add a provider (uses a prebuilt package when one exists)
|
|
27
|
+
- `cdktn get`: generate bindings for the providers and modules in `cdktf.json`
|
|
28
|
+
- `cdktn synth`: synthesize Terraform JSON into `cdktf.out/`
|
|
29
|
+
- `cdktn diff [stack]`: plan changes for a stack
|
|
30
|
+
- `cdktn deploy [stack]` / `cdktn destroy [stack]`: change real infrastructure; ask before running
|
|
31
|
+
- `{{ pmRun }} test` (tests live in `__tests__/`): run unit tests
|
|
32
|
+
|
|
33
|
+
The `help` file lists every command for this project.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/open-constructs/cdk-terrain/v{{cdktf_version}}/cdktf.schema.json",
|
|
2
3
|
"language": "typescript",
|
|
3
|
-
"app": "
|
|
4
|
+
"app": "{{ pmExec }} tsx main.ts",
|
|
4
5
|
"projectId": "{{projectId}}",
|
|
5
6
|
"sendCrashReports": "{{sendCrashReports}}",
|
|
6
7
|
"targetVersions": {
|
|
7
8
|
"terraform": ">=1.5.7",
|
|
8
9
|
"opentofu": ">=1.6.0"
|
|
9
10
|
},
|
|
11
|
+
"sendUsageTelemetry": "{{sendUsageTelemetry}}",
|
|
10
12
|
"terraformProviders": [],
|
|
11
13
|
"terraformModules": [],
|
|
12
14
|
"context": {
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
cat help Print this message
|
|
6
6
|
|
|
7
7
|
Compile:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
{{ pmRun }} get Import/update Terraform providers and modules (you should check-in this directory)
|
|
9
|
+
{{ pmRun }} compile Compile typescript code to javascript (or "{{ pmRun }} watch")
|
|
10
|
+
{{ pmRun }} watch Watch for changes and compile typescript in the background
|
|
11
|
+
{{ pmRun }} build Compile typescript
|
|
12
12
|
|
|
13
13
|
Synthesize:
|
|
14
14
|
cdktn synth [stack] Synthesize Terraform resources from stacks to cdktf.out/ (ready for 'terraform apply')
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
cdktn destroy [stack] Destroy the stack
|
|
24
24
|
|
|
25
25
|
Test:
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
{{ pmRun }} test Runs unit tests (edit __tests__/main-test.ts to add your own tests)
|
|
27
|
+
{{ pmRun }} test:watch Watches the tests and reruns them on change
|
|
28
28
|
|
|
29
29
|
Upgrades:
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
{{ pmRun }} upgrade Upgrade cdktn modules to latest version
|
|
31
|
+
{{ pmRun }} upgrade:next Upgrade cdktn modules to latest "@next" version (last commit)
|
|
32
32
|
|
|
33
33
|
Use Providers:
|
|
34
34
|
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
cdktn provider add "aws@~>3.0" null kreuzwerker/docker
|
|
38
38
|
|
|
39
39
|
You can find all prebuilt providers on npm: https://www.npmjs.com/search?q=keywords:cdktn
|
|
40
|
-
You can also install these providers directly through
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
You can also install these providers directly through {{ packageManager }}:
|
|
41
|
+
|
|
42
|
+
{{ pmAdd }} @cdktn/provider-aws
|
|
43
|
+
{{ pmAdd }} @cdktn/provider-google
|
|
44
|
+
{{ pmAdd }} @cdktn/provider-azurerm
|
|
45
|
+
{{ pmAdd }} @cdktn/provider-docker
|
|
46
|
+
{{ pmAdd }} @cdktn/provider-github
|
|
47
|
+
{{ pmAdd }} @cdktn/provider-null
|
|
48
48
|
|
|
49
49
|
You can also build any module or provider locally. Learn more https://cdktn.io/docs/concepts/providers
|
|
50
50
|
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"watch": "tsc -w",
|
|
14
14
|
"test": "jest",
|
|
15
15
|
"test:watch": "jest --watch",
|
|
16
|
-
"upgrade": "
|
|
17
|
-
"upgrade:next": "
|
|
16
|
+
"upgrade": "{{ pmAdd }} cdktn@latest cdktn-cli@latest",
|
|
17
|
+
"upgrade:next": "{{ pmAdd }} cdktn@next cdktn-cli@next"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=22.0"
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"experimentalDecorators": true,
|
|
6
6
|
"inlineSourceMap": true,
|
|
7
7
|
"inlineSources": true,
|
|
8
|
+
// Required for ts-jest on TypeScript 6; `npm run build` still type-checks.
|
|
9
|
+
"isolatedModules": true,
|
|
8
10
|
"lib": [
|
|
9
11
|
"es2018"
|
|
10
12
|
],
|
|
@@ -22,6 +24,11 @@
|
|
|
22
24
|
"strictPropertyInitialization": true,
|
|
23
25
|
"stripInternal": true,
|
|
24
26
|
"target": "ES2018",
|
|
27
|
+
// TypeScript 6 no longer picks up ambient @types automatically.
|
|
28
|
+
"types": [
|
|
29
|
+
"node",
|
|
30
|
+
"jest"
|
|
31
|
+
],
|
|
25
32
|
"incremental": true,
|
|
26
33
|
"skipLibCheck": true
|
|
27
34
|
},
|