cdktn 0.23.3 → 0.23.4
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/.jsii +437 -220
- package/README.md +2 -2
- package/lib/annotations.js +1 -1
- package/lib/app.js +1 -1
- package/lib/aspect.js +1 -1
- package/lib/backends/azurerm-backend.js +2 -2
- package/lib/backends/cloud-backend.js +4 -4
- package/lib/backends/consul-backend.js +2 -2
- package/lib/backends/cos-backend.js +2 -2
- package/lib/backends/gcs-backend.js +2 -2
- package/lib/backends/http-backend.js +2 -2
- package/lib/backends/local-backend.js +2 -2
- package/lib/backends/oss-backend.js +2 -2
- package/lib/backends/pg-backend.js +2 -2
- package/lib/backends/remote-backend.js +4 -4
- package/lib/backends/s3-backend.d.ts +11 -1
- package/lib/backends/s3-backend.js +11 -4
- package/lib/backends/swift-backend.js +2 -2
- package/lib/complex-computed-list.js +23 -23
- package/lib/features.d.ts +9 -0
- package/lib/features.js +11 -2
- package/lib/functions/function-availability.generated.d.ts +16 -0
- package/lib/functions/function-availability.generated.js +21 -0
- package/lib/functions/helpers.js +3 -1
- package/lib/functions/terraform-functions.generated.d.ts +40 -2
- package/lib/functions/terraform-functions.generated.js +57 -5
- package/lib/functions/usage-registry.d.ts +6 -0
- package/lib/functions/usage-registry.js +34 -0
- package/lib/importable-resource.js +1 -1
- package/lib/manifest.js +1 -1
- package/lib/resource.js +1 -1
- package/lib/synthesize/synthesizer.js +5 -1
- package/lib/terraform-asset.js +1 -1
- package/lib/terraform-backend.js +1 -1
- package/lib/terraform-count.js +1 -1
- package/lib/terraform-data-resource.js +1 -1
- package/lib/terraform-data-source.js +1 -1
- package/lib/terraform-element.js +1 -1
- package/lib/terraform-functions.js +1 -1
- package/lib/terraform-hcl-module.js +1 -1
- package/lib/terraform-iterator.js +5 -5
- package/lib/terraform-local.js +1 -1
- package/lib/terraform-module.js +1 -1
- package/lib/terraform-operators.js +1 -1
- package/lib/terraform-output.js +1 -1
- package/lib/terraform-provider.js +1 -1
- package/lib/terraform-provisioner.js +1 -1
- package/lib/terraform-remote-state.js +1 -1
- package/lib/terraform-resource-targets.js +1 -1
- package/lib/terraform-resource.js +1 -1
- package/lib/terraform-stack.js +6 -2
- package/lib/terraform-variable.js +2 -2
- package/lib/testing/index.js +3 -3
- package/lib/testing/matchers.js +1 -1
- package/lib/tokens/lazy.js +2 -2
- package/lib/tokens/resolvable.js +2 -2
- package/lib/tokens/string-fragments.js +1 -1
- package/lib/tokens/token.js +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/upgrade-id-aspect.js +1 -1
- package/lib/validations/index.d.ts +3 -0
- package/lib/validations/index.js +4 -1
- package/lib/validations/target-versions.d.ts +71 -0
- package/lib/validations/target-versions.js +132 -0
- package/lib/validations/validate-binary-version.d.ts +10 -0
- package/lib/validations/validate-binary-version.js +11 -1
- package/lib/validations/validate-function-version-support.d.ts +21 -0
- package/lib/validations/validate-function-version-support.js +53 -0
- package/lib/validations/validate-terraform-feature-version.d.ts +34 -0
- package/lib/validations/validate-terraform-feature-version.js +34 -0
- package/package.json +8 -8
- package/scripts/pack.mjs +168 -0
package/scripts/pack.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Build the cdktn language packages via jsii-pacmak.
|
|
7
|
+
//
|
|
8
|
+
// Why this script exists:
|
|
9
|
+
// cdktn ships its runtime deps (json-stable-stringify, semver, yazl) inside the published tarball so JSII pacmak can
|
|
10
|
+
// embed them in the Python/Java/Go/.NET targets — the embedded JS needs them at runtime in user environments where
|
|
11
|
+
// there is no `npm install`.
|
|
12
|
+
//
|
|
13
|
+
// Under pnpm's default isolated layout, those deps inside packages/cdktn/node_modules are symlinks back into
|
|
14
|
+
// ../../node_modules/.pnpm/<dep>/. When `npm pack` (called by jsii-pacmak) walks the symlinks, it produces tarball
|
|
15
|
+
// entries with `..`-escape paths that most tar extractors discard, leaving the bundled deps' transitives missing in
|
|
16
|
+
// the published tarballs.
|
|
17
|
+
//
|
|
18
|
+
// This script sidesteps the issue by copying cdktn's source into a staging directory and running `npm install
|
|
19
|
+
// --omit=dev` there. npm produces a regular nested node_modules layout (no symlinks), which jsii-pacmak + `npm pack`
|
|
20
|
+
// can bundle correctly. Outputs are copied back to packages/cdktn/dist/.
|
|
21
|
+
|
|
22
|
+
import { execFileSync } from "node:child_process";
|
|
23
|
+
import { rmSync, mkdirSync, cpSync, existsSync } from "node:fs";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { dirname, join, resolve } from "node:path";
|
|
26
|
+
import { pacmak } from "jsii-pacmak";
|
|
27
|
+
|
|
28
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
const packageDir = resolve(__dirname, "..");
|
|
30
|
+
const stagingDir = join(packageDir, ".pack-staging");
|
|
31
|
+
const distOutDir = join(packageDir, "dist");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Run a command synchronously, inheriting stdio and logging the invocation.
|
|
35
|
+
* Throws on non-zero exit.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} cmd
|
|
38
|
+
* @param {string[]} args
|
|
39
|
+
* @param {import("node:child_process").SpawnSyncOptionsWithBufferEncoding} [opts]
|
|
40
|
+
*/
|
|
41
|
+
function run(cmd, args, opts = {}) {
|
|
42
|
+
console.log(`> ${cmd} ${args.join(" ")}`);
|
|
43
|
+
execFileSync(cmd, args, {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
cwd: packageDir,
|
|
46
|
+
...opts,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Use `npm pack --dry-run --json` to discover the file list npm would publish and return it as relative paths from
|
|
52
|
+
* `packageDir`. Drops any `..`-escape paths that come from npm following pnpm's node_modules symlinks — those are
|
|
53
|
+
* the broken entries the staging copy will replace with a clean `npm install`.
|
|
54
|
+
*
|
|
55
|
+
* @returns {string[]} relative paths from packageDir
|
|
56
|
+
*/
|
|
57
|
+
function resolveSourceFiles() {
|
|
58
|
+
console.log("Resolving cdktn's file list via `npm pack --dry-run`...");
|
|
59
|
+
const packJson = execFileSync("npm", ["pack", "--dry-run", "--json"], {
|
|
60
|
+
cwd: packageDir,
|
|
61
|
+
}).toString();
|
|
62
|
+
const packInfo = JSON.parse(packJson);
|
|
63
|
+
const files = packInfo[0].files
|
|
64
|
+
.map((f) => f.path)
|
|
65
|
+
.filter((p) => !p.includes(".."));
|
|
66
|
+
console.log(` ${files.length} source files to copy.`);
|
|
67
|
+
return files;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Recreate the staging directory empty.
|
|
72
|
+
*/
|
|
73
|
+
function prepareStagingDir() {
|
|
74
|
+
console.log(`Preparing staging dir at ${stagingDir}...`);
|
|
75
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
76
|
+
mkdirSync(stagingDir, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Copy the resolved source files into the staging directory, preserving relative paths.
|
|
81
|
+
*
|
|
82
|
+
* @param {string[]} sourceFiles relative paths from packageDir
|
|
83
|
+
*/
|
|
84
|
+
function copySourceFiles(sourceFiles) {
|
|
85
|
+
for (const relPath of sourceFiles) {
|
|
86
|
+
const src = join(packageDir, relPath);
|
|
87
|
+
const dst = join(stagingDir, relPath);
|
|
88
|
+
if (!existsSync(src)) continue;
|
|
89
|
+
mkdirSync(dirname(dst), { recursive: true });
|
|
90
|
+
cpSync(src, dst);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Install runtime dependencies into the staging directory using npm. Produces a flat/nested node_modules layout (no
|
|
96
|
+
* pnpm symlinks) suitable for npm pack.
|
|
97
|
+
*
|
|
98
|
+
* Flags:
|
|
99
|
+
* --omit=dev: skip devDependencies (jest, jsii, typescript, ...).
|
|
100
|
+
* --omit=optional: skip optional deps.
|
|
101
|
+
* --no-package-lock: don't pollute staging with a fresh lockfile.
|
|
102
|
+
* --prefer-offline: use the local npm cache before the network.
|
|
103
|
+
* --ignore-scripts: don't run install scripts of bundled deps; bundling needs the tree on disk only.
|
|
104
|
+
*/
|
|
105
|
+
function installRuntimeDeps() {
|
|
106
|
+
console.log("Installing runtime deps into staging via npm...");
|
|
107
|
+
run(
|
|
108
|
+
"npm",
|
|
109
|
+
[
|
|
110
|
+
"install",
|
|
111
|
+
"--omit=dev",
|
|
112
|
+
"--omit=optional",
|
|
113
|
+
"--no-package-lock",
|
|
114
|
+
"--prefer-offline",
|
|
115
|
+
"--ignore-scripts",
|
|
116
|
+
],
|
|
117
|
+
{ cwd: stagingDir },
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Run jsii-pacmak against the staging directory via its programmatic API. Avoids spawning a Node subprocess and lets
|
|
123
|
+
* static analysers see the jsii-pacmak dependency.
|
|
124
|
+
*
|
|
125
|
+
* @param {string[]} targets jsii-pacmak target names; empty = all.
|
|
126
|
+
*/
|
|
127
|
+
async function runJsiiPacmak(targets) {
|
|
128
|
+
console.log("Running jsii-pacmak from staging...");
|
|
129
|
+
await pacmak({
|
|
130
|
+
inputDirectories: [stagingDir],
|
|
131
|
+
...(targets.length > 0 ? { targets } : {}),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Run go-copyright-header.sh against the staging output. Operates on dist/go/ so needs to run from where dist/ landed
|
|
137
|
+
* (the staging dir).
|
|
138
|
+
*/
|
|
139
|
+
function runGoCopyrightHeader() {
|
|
140
|
+
const script = join(stagingDir, "go-copyright-header.sh");
|
|
141
|
+
if (!existsSync(script)) return;
|
|
142
|
+
console.log("Running go-copyright-header.sh from staging...");
|
|
143
|
+
run("bash", ["./go-copyright-header.sh"], { cwd: stagingDir });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Move the produced dist/ from staging back to the package's dist/. Replaces any prior content.
|
|
148
|
+
*/
|
|
149
|
+
function moveDistOut() {
|
|
150
|
+
const stagingDist = join(stagingDir, "dist");
|
|
151
|
+
if (!existsSync(stagingDist)) {
|
|
152
|
+
console.error(`No dist/ produced in staging at ${stagingDist}`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
console.log(`Moving staging dist/ to ${distOutDir}...`);
|
|
156
|
+
rmSync(distOutDir, { recursive: true, force: true });
|
|
157
|
+
cpSync(stagingDist, distOutDir, { recursive: true });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const targets = process.argv.slice(2);
|
|
161
|
+
const sourceFiles = resolveSourceFiles();
|
|
162
|
+
prepareStagingDir();
|
|
163
|
+
copySourceFiles(sourceFiles);
|
|
164
|
+
installRuntimeDeps();
|
|
165
|
+
await runJsiiPacmak(targets);
|
|
166
|
+
runGoCopyrightHeader();
|
|
167
|
+
moveDistOut();
|
|
168
|
+
console.log("Done.");
|