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.
Files changed (72) hide show
  1. package/.jsii +437 -220
  2. package/README.md +2 -2
  3. package/lib/annotations.js +1 -1
  4. package/lib/app.js +1 -1
  5. package/lib/aspect.js +1 -1
  6. package/lib/backends/azurerm-backend.js +2 -2
  7. package/lib/backends/cloud-backend.js +4 -4
  8. package/lib/backends/consul-backend.js +2 -2
  9. package/lib/backends/cos-backend.js +2 -2
  10. package/lib/backends/gcs-backend.js +2 -2
  11. package/lib/backends/http-backend.js +2 -2
  12. package/lib/backends/local-backend.js +2 -2
  13. package/lib/backends/oss-backend.js +2 -2
  14. package/lib/backends/pg-backend.js +2 -2
  15. package/lib/backends/remote-backend.js +4 -4
  16. package/lib/backends/s3-backend.d.ts +11 -1
  17. package/lib/backends/s3-backend.js +11 -4
  18. package/lib/backends/swift-backend.js +2 -2
  19. package/lib/complex-computed-list.js +23 -23
  20. package/lib/features.d.ts +9 -0
  21. package/lib/features.js +11 -2
  22. package/lib/functions/function-availability.generated.d.ts +16 -0
  23. package/lib/functions/function-availability.generated.js +21 -0
  24. package/lib/functions/helpers.js +3 -1
  25. package/lib/functions/terraform-functions.generated.d.ts +40 -2
  26. package/lib/functions/terraform-functions.generated.js +57 -5
  27. package/lib/functions/usage-registry.d.ts +6 -0
  28. package/lib/functions/usage-registry.js +34 -0
  29. package/lib/importable-resource.js +1 -1
  30. package/lib/manifest.js +1 -1
  31. package/lib/resource.js +1 -1
  32. package/lib/synthesize/synthesizer.js +5 -1
  33. package/lib/terraform-asset.js +1 -1
  34. package/lib/terraform-backend.js +1 -1
  35. package/lib/terraform-count.js +1 -1
  36. package/lib/terraform-data-resource.js +1 -1
  37. package/lib/terraform-data-source.js +1 -1
  38. package/lib/terraform-element.js +1 -1
  39. package/lib/terraform-functions.js +1 -1
  40. package/lib/terraform-hcl-module.js +1 -1
  41. package/lib/terraform-iterator.js +5 -5
  42. package/lib/terraform-local.js +1 -1
  43. package/lib/terraform-module.js +1 -1
  44. package/lib/terraform-operators.js +1 -1
  45. package/lib/terraform-output.js +1 -1
  46. package/lib/terraform-provider.js +1 -1
  47. package/lib/terraform-provisioner.js +1 -1
  48. package/lib/terraform-remote-state.js +1 -1
  49. package/lib/terraform-resource-targets.js +1 -1
  50. package/lib/terraform-resource.js +1 -1
  51. package/lib/terraform-stack.js +6 -2
  52. package/lib/terraform-variable.js +2 -2
  53. package/lib/testing/index.js +3 -3
  54. package/lib/testing/matchers.js +1 -1
  55. package/lib/tokens/lazy.js +2 -2
  56. package/lib/tokens/resolvable.js +2 -2
  57. package/lib/tokens/string-fragments.js +1 -1
  58. package/lib/tokens/token.js +2 -2
  59. package/lib/tsconfig.tsbuildinfo +1 -1
  60. package/lib/upgrade-id-aspect.js +1 -1
  61. package/lib/validations/index.d.ts +3 -0
  62. package/lib/validations/index.js +4 -1
  63. package/lib/validations/target-versions.d.ts +71 -0
  64. package/lib/validations/target-versions.js +132 -0
  65. package/lib/validations/validate-binary-version.d.ts +10 -0
  66. package/lib/validations/validate-binary-version.js +11 -1
  67. package/lib/validations/validate-function-version-support.d.ts +21 -0
  68. package/lib/validations/validate-function-version-support.js +53 -0
  69. package/lib/validations/validate-terraform-feature-version.d.ts +34 -0
  70. package/lib/validations/validate-terraform-feature-version.js +34 -0
  71. package/package.json +8 -8
  72. package/scripts/pack.mjs +168 -0
@@ -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.");