@webflow/cloud-app 0.1.0-beta.7

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 (174) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -0
  3. package/dist/bindings.d.ts +185 -0
  4. package/dist/bindings.d.ts.map +1 -0
  5. package/dist/bindings.js +120 -0
  6. package/dist/bindings.js.map +1 -0
  7. package/dist/config/package-json.d.ts +57 -0
  8. package/dist/config/package-json.d.ts.map +1 -0
  9. package/dist/config/package-json.js +94 -0
  10. package/dist/config/package-json.js.map +1 -0
  11. package/dist/config/webflow-json.d.ts +53 -0
  12. package/dist/config/webflow-json.d.ts.map +1 -0
  13. package/dist/config/webflow-json.js +72 -0
  14. package/dist/config/webflow-json.js.map +1 -0
  15. package/dist/create-webflow-json.d.ts +24 -0
  16. package/dist/create-webflow-json.d.ts.map +1 -0
  17. package/dist/create-webflow-json.js +170 -0
  18. package/dist/create-webflow-json.js.map +1 -0
  19. package/dist/errors.d.ts +13 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +23 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts +36 -0
  24. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts.map +1 -0
  25. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js +94 -0
  26. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js.map +1 -0
  27. package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts +2 -0
  28. package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts.map +1 -0
  29. package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.js +97 -0
  30. package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.js.map +1 -0
  31. package/dist/frameworks/astro/astro5.d.ts +28 -0
  32. package/dist/frameworks/astro/astro5.d.ts.map +1 -0
  33. package/dist/frameworks/astro/astro5.js +259 -0
  34. package/dist/frameworks/astro/astro5.js.map +1 -0
  35. package/dist/frameworks/astro/astro6.d.ts +28 -0
  36. package/dist/frameworks/astro/astro6.d.ts.map +1 -0
  37. package/dist/frameworks/astro/astro6.js +286 -0
  38. package/dist/frameworks/astro/astro6.js.map +1 -0
  39. package/dist/frameworks/astro/astro7.d.ts +28 -0
  40. package/dist/frameworks/astro/astro7.d.ts.map +1 -0
  41. package/dist/frameworks/astro/astro7.js +283 -0
  42. package/dist/frameworks/astro/astro7.js.map +1 -0
  43. package/dist/frameworks/astro/index.d.ts +10 -0
  44. package/dist/frameworks/astro/index.d.ts.map +1 -0
  45. package/dist/frameworks/astro/index.js +16 -0
  46. package/dist/frameworks/astro/index.js.map +1 -0
  47. package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
  48. package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
  49. package/dist/frameworks/astro/templates/v5/webflow-loader.ts +103 -0
  50. package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
  51. package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
  52. package/dist/frameworks/astro/templates/v6/webflow-loader.ts +112 -0
  53. package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
  54. package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
  55. package/dist/frameworks/astro/templates/v7/webflow-loader.ts +113 -0
  56. package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
  57. package/dist/frameworks/base.d.ts +134 -0
  58. package/dist/frameworks/base.d.ts.map +1 -0
  59. package/dist/frameworks/base.js +175 -0
  60. package/dist/frameworks/base.js.map +1 -0
  61. package/dist/frameworks/errors.d.ts +72 -0
  62. package/dist/frameworks/errors.d.ts.map +1 -0
  63. package/dist/frameworks/errors.js +120 -0
  64. package/dist/frameworks/errors.js.map +1 -0
  65. package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
  66. package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
  67. package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
  68. package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
  69. package/dist/frameworks/nextjs/index.d.ts +38 -0
  70. package/dist/frameworks/nextjs/index.d.ts.map +1 -0
  71. package/dist/frameworks/nextjs/index.js +268 -0
  72. package/dist/frameworks/nextjs/index.js.map +1 -0
  73. package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
  74. package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
  75. package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
  76. package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
  77. package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
  78. package/dist/frameworks/registry.d.ts +127 -0
  79. package/dist/frameworks/registry.d.ts.map +1 -0
  80. package/dist/frameworks/registry.js +257 -0
  81. package/dist/frameworks/registry.js.map +1 -0
  82. package/dist/frameworks/static/index.d.ts +93 -0
  83. package/dist/frameworks/static/index.d.ts.map +1 -0
  84. package/dist/frameworks/static/index.js +352 -0
  85. package/dist/frameworks/static/index.js.map +1 -0
  86. package/dist/frameworks/static/templates/wrangler.json +7 -0
  87. package/dist/frameworks/types.d.ts +138 -0
  88. package/dist/frameworks/types.d.ts.map +1 -0
  89. package/dist/frameworks/types.js +3 -0
  90. package/dist/frameworks/types.js.map +1 -0
  91. package/dist/frameworks/vite/index.d.ts +46 -0
  92. package/dist/frameworks/vite/index.d.ts.map +1 -0
  93. package/dist/frameworks/vite/index.js +303 -0
  94. package/dist/frameworks/vite/index.js.map +1 -0
  95. package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
  96. package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
  97. package/dist/frameworks/vite/templates/wrangler.json +10 -0
  98. package/dist/index.d.ts +44 -0
  99. package/dist/index.d.ts.map +1 -0
  100. package/dist/index.js +118 -0
  101. package/dist/index.js.map +1 -0
  102. package/dist/pipeline.d.ts +8 -0
  103. package/dist/pipeline.d.ts.map +1 -0
  104. package/dist/pipeline.js +263 -0
  105. package/dist/pipeline.js.map +1 -0
  106. package/dist/ports/command-runner.d.ts +60 -0
  107. package/dist/ports/command-runner.d.ts.map +1 -0
  108. package/dist/ports/command-runner.js +116 -0
  109. package/dist/ports/command-runner.js.map +1 -0
  110. package/dist/ports/filesystem.d.ts +19 -0
  111. package/dist/ports/filesystem.d.ts.map +1 -0
  112. package/dist/ports/filesystem.js +68 -0
  113. package/dist/ports/filesystem.js.map +1 -0
  114. package/dist/ports/index.d.ts +17 -0
  115. package/dist/ports/index.d.ts.map +1 -0
  116. package/dist/ports/index.js +14 -0
  117. package/dist/ports/index.js.map +1 -0
  118. package/dist/ports/logger.d.ts +22 -0
  119. package/dist/ports/logger.d.ts.map +1 -0
  120. package/dist/ports/logger.js +18 -0
  121. package/dist/ports/logger.js.map +1 -0
  122. package/dist/ports/telemetry.d.ts +23 -0
  123. package/dist/ports/telemetry.d.ts.map +1 -0
  124. package/dist/ports/telemetry.js +12 -0
  125. package/dist/ports/telemetry.js.map +1 -0
  126. package/dist/toolchain/errors.d.ts +32 -0
  127. package/dist/toolchain/errors.d.ts.map +1 -0
  128. package/dist/toolchain/errors.js +31 -0
  129. package/dist/toolchain/errors.js.map +1 -0
  130. package/dist/toolchain/resolver.d.ts +25 -0
  131. package/dist/toolchain/resolver.d.ts.map +1 -0
  132. package/dist/toolchain/resolver.js +200 -0
  133. package/dist/toolchain/resolver.js.map +1 -0
  134. package/dist/toolchain/types.d.ts +52 -0
  135. package/dist/toolchain/types.d.ts.map +1 -0
  136. package/dist/toolchain/types.js +10 -0
  137. package/dist/toolchain/types.js.map +1 -0
  138. package/dist/types.d.ts +66 -0
  139. package/dist/types.d.ts.map +1 -0
  140. package/dist/types.js +3 -0
  141. package/dist/types.js.map +1 -0
  142. package/dist/utils/fs.d.ts +29 -0
  143. package/dist/utils/fs.d.ts.map +1 -0
  144. package/dist/utils/fs.js +126 -0
  145. package/dist/utils/fs.js.map +1 -0
  146. package/dist/utils/index.d.ts +11 -0
  147. package/dist/utils/index.d.ts.map +1 -0
  148. package/dist/utils/index.js +27 -0
  149. package/dist/utils/index.js.map +1 -0
  150. package/dist/utils/node-version.d.ts +20 -0
  151. package/dist/utils/node-version.d.ts.map +1 -0
  152. package/dist/utils/node-version.js +113 -0
  153. package/dist/utils/node-version.js.map +1 -0
  154. package/dist/utils/process.d.ts +25 -0
  155. package/dist/utils/process.d.ts.map +1 -0
  156. package/dist/utils/process.js +40 -0
  157. package/dist/utils/process.js.map +1 -0
  158. package/dist/utils/reserved-env.d.ts +26 -0
  159. package/dist/utils/reserved-env.d.ts.map +1 -0
  160. package/dist/utils/reserved-env.js +51 -0
  161. package/dist/utils/reserved-env.js.map +1 -0
  162. package/dist/utils/template.d.ts +15 -0
  163. package/dist/utils/template.d.ts.map +1 -0
  164. package/dist/utils/template.js +75 -0
  165. package/dist/utils/template.js.map +1 -0
  166. package/dist/utils/version.d.ts +9 -0
  167. package/dist/utils/version.d.ts.map +1 -0
  168. package/dist/utils/version.js +52 -0
  169. package/dist/utils/version.js.map +1 -0
  170. package/dist/wrangler.d.ts +192 -0
  171. package/dist/wrangler.d.ts.map +1 -0
  172. package/dist/wrangler.js +246 -0
  173. package/dist/wrangler.js.map +1 -0
  174. package/package.json +47 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.recursiveCopy = recursiveCopy;
37
+ exports.fileExists = fileExists;
38
+ exports.matchesExcludePattern = matchesExcludePattern;
39
+ exports.renameUserConfig = renameUserConfig;
40
+ /**
41
+ * Synchronous filesystem helpers used for in-workspace file manipulation
42
+ * (copying build artifacts, renaming user configs aside). These operate on the
43
+ * ephemeral workspace; workspace-level isolate/collect goes through the
44
+ * FileSystem port instead.
45
+ */
46
+ const fs = __importStar(require("node:fs"));
47
+ const path = __importStar(require("node:path"));
48
+ /**
49
+ * Recursively copy directory contents.
50
+ *
51
+ * @returns Number of files copied.
52
+ */
53
+ function recursiveCopy(log, src, dest, options) {
54
+ const excludePatterns = options?.exclude
55
+ ? Array.isArray(options.exclude)
56
+ ? options.exclude
57
+ : [options.exclude]
58
+ : [];
59
+ const baseName = path.basename(src);
60
+ if (excludePatterns.some((p) => baseName === p)) {
61
+ log.debug(`Skipping excluded: ${src}`);
62
+ return 0;
63
+ }
64
+ const stat = fs.statSync(src, { throwIfNoEntry: false });
65
+ if (!stat) {
66
+ log.debug(`Source does not exist: ${src}`);
67
+ return 0;
68
+ }
69
+ if (stat.isDirectory()) {
70
+ log.debug(`Copying directory: ${src} -> ${dest}`);
71
+ const contents = fs.readdirSync(src);
72
+ let count = 0;
73
+ for (const entry of contents) {
74
+ count += recursiveCopy(log, path.join(src, entry), path.join(dest, entry), options);
75
+ }
76
+ return count;
77
+ }
78
+ const destDir = path.dirname(dest);
79
+ if (!fs.existsSync(destDir)) {
80
+ fs.mkdirSync(destDir, { recursive: true });
81
+ }
82
+ log.debug(`Copying file: ${src} -> ${dest}`);
83
+ fs.copyFileSync(src, dest);
84
+ return 1;
85
+ }
86
+ /** Check if a file exists. */
87
+ function fileExists(filePath) {
88
+ return fs.existsSync(filePath);
89
+ }
90
+ /** Escape a string for safe embedding in a RegExp. */
91
+ function escapeRegExp(s) {
92
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
93
+ }
94
+ /**
95
+ * Match a basename against a simple glob pattern where `*` matches any run of
96
+ * non-`/` characters. A pattern without `*` is an exact-name match. Used by the
97
+ * static builder's asset-exclusion policy.
98
+ */
99
+ function matchesExcludePattern(name, pattern) {
100
+ if (!pattern.includes('*')) {
101
+ return name === pattern;
102
+ }
103
+ const escaped = pattern.split('*').map(escapeRegExp).join('[^/]*');
104
+ return new RegExp(`^${escaped}$`).test(name);
105
+ }
106
+ /**
107
+ * Rename a user config file to a `clouduser.*` prefix.
108
+ *
109
+ * Searches for a config file with the given base name and extensions, renaming
110
+ * the first found to `clouduser.{baseName}.{ext}`.
111
+ *
112
+ * @returns Path to the renamed file, or null if no config found.
113
+ */
114
+ function renameUserConfig(log, cwd, baseName, extensions) {
115
+ for (const ext of extensions) {
116
+ const from = path.join(cwd, `${baseName}.${ext}`);
117
+ if (fs.existsSync(from)) {
118
+ const to = path.join(cwd, `clouduser.${baseName}.${ext}`);
119
+ log.info(`Renaming user config: ${baseName}.${ext} -> clouduser.${baseName}.${ext}`);
120
+ fs.renameSync(from, to);
121
+ return to;
122
+ }
123
+ }
124
+ return null;
125
+ }
126
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3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AAM,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,GAAW,EACX,GAAW,EACX,QAAgB,EAChB,UAAoB;IAEpB,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;QAClD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;YAC1D,GAAG,CAAC,IAAI,CAAC,yBAAyB,QAAQ,IAAI,GAAG,iBAAiB,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;YACrF,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Utility barrel. Builders import helpers from here (`../../utils`), matching
3
+ * the cosmic-builder layout so the cloned builder tests can mock this module.
4
+ */
5
+ export * from './version';
6
+ export * from './node-version';
7
+ export * from './reserved-env';
8
+ export * from './fs';
9
+ export * from './template';
10
+ export * from './process';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Utility barrel. Builders import helpers from here (`../../utils`), matching
19
+ * the cosmic-builder layout so the cloned builder tests can mock this module.
20
+ */
21
+ __exportStar(require("./version"), exports);
22
+ __exportStar(require("./node-version"), exports);
23
+ __exportStar(require("./reserved-env"), exports);
24
+ __exportStar(require("./fs"), exports);
25
+ __exportStar(require("./template"), exports);
26
+ __exportStar(require("./process"), exports);
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,4CAA0B;AAC1B,iDAA+B;AAC/B,iDAA+B;AAC/B,uCAAqB;AACrB,6CAA2B;AAC3B,4CAA0B"}
@@ -0,0 +1,20 @@
1
+ import type { Logger } from '../ports';
2
+ import type { NodeVersionRequirement } from '../frameworks/types';
3
+ /** Get the current Node.js version string (without the 'v' prefix). */
4
+ export declare function getCurrentNodeVersion(): string;
5
+ /** Get the major version from a version string using semver.coerce. */
6
+ export declare function getNodeMajorVersion(version: string): number | null;
7
+ /** Compare two version strings. -1 if a<b, 0 if a==b, 1 if a>b, null if incomparable. */
8
+ export declare function compareNodeVersions(a: string, b: string): number | null;
9
+ /** Check whether `current` meets the `minimum` requirement (current >= minimum). */
10
+ export declare function meetsVersionRequirement(current: string, minimum: string): boolean;
11
+ /**
12
+ * Validate that the current Node.js version meets the requirement.
13
+ *
14
+ * - 'warn': logs a warning but allows the build to continue
15
+ * - 'error': throws FrameworkValidationError, stopping the build
16
+ */
17
+ export declare function validateNodeVersion(log: Logger, requirement: NodeVersionRequirement, frameworkName: string): void;
18
+ /** Get a human-readable description of the Node.js version requirement. */
19
+ export declare function describeRequirement(requirement: NodeVersionRequirement): string;
20
+ //# sourceMappingURL=node-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-version.d.ts","sourceRoot":"","sources":["../../src/utils/node-version.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,uEAAuE;AACvE,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvE;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CASjF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,MAAM,GACpB,IAAI,CAwBN;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,sBAAsB,GAAG,MAAM,CAG/E"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getCurrentNodeVersion = getCurrentNodeVersion;
37
+ exports.getNodeMajorVersion = getNodeMajorVersion;
38
+ exports.compareNodeVersions = compareNodeVersions;
39
+ exports.meetsVersionRequirement = meetsVersionRequirement;
40
+ exports.validateNodeVersion = validateNodeVersion;
41
+ exports.describeRequirement = describeRequirement;
42
+ /**
43
+ * Node.js version validation.
44
+ *
45
+ * Checks that the current Node.js version meets framework requirements, using
46
+ * semver for all parsing and comparison.
47
+ *
48
+ * - 'warn' severity: logs a warning but continues
49
+ * - 'error' severity: throws FrameworkValidationError
50
+ */
51
+ const semver = __importStar(require("semver"));
52
+ const errors_1 = require("../frameworks/errors");
53
+ /** Get the current Node.js version string (without the 'v' prefix). */
54
+ function getCurrentNodeVersion() {
55
+ return process.version.slice(1);
56
+ }
57
+ /** Get the major version from a version string using semver.coerce. */
58
+ function getNodeMajorVersion(version) {
59
+ const coerced = semver.coerce(version);
60
+ return coerced ? coerced.major : null;
61
+ }
62
+ /** Compare two version strings. -1 if a<b, 0 if a==b, 1 if a>b, null if incomparable. */
63
+ function compareNodeVersions(a, b) {
64
+ const coercedA = semver.coerce(a);
65
+ const coercedB = semver.coerce(b);
66
+ if (!coercedA || !coercedB)
67
+ return null;
68
+ return semver.compare(coercedA, coercedB);
69
+ }
70
+ /** Check whether `current` meets the `minimum` requirement (current >= minimum). */
71
+ function meetsVersionRequirement(current, minimum) {
72
+ const coercedCurrent = semver.coerce(current);
73
+ const coercedMinimum = semver.coerce(minimum);
74
+ if (!coercedCurrent || !coercedMinimum) {
75
+ return false;
76
+ }
77
+ return semver.gte(coercedCurrent, coercedMinimum);
78
+ }
79
+ /**
80
+ * Validate that the current Node.js version meets the requirement.
81
+ *
82
+ * - 'warn': logs a warning but allows the build to continue
83
+ * - 'error': throws FrameworkValidationError, stopping the build
84
+ */
85
+ function validateNodeVersion(log, requirement, frameworkName) {
86
+ const current = getCurrentNodeVersion();
87
+ const minimum = requirement.minimum;
88
+ if (!meetsVersionRequirement(current, minimum)) {
89
+ const majorVersion = getNodeMajorVersion(minimum);
90
+ const message = `${frameworkName} requires Node.js ${minimum} or higher. ` + `Current version: ${current}`;
91
+ if (requirement.severity === 'error') {
92
+ throw new errors_1.FrameworkValidationError(message, {
93
+ remediation: `Please upgrade Node.js to ${minimum} or higher. ` +
94
+ `You can use nvm, fnm, or similar tools to manage Node.js versions.\n\n` +
95
+ ` nvm install ${majorVersion}\n` +
96
+ ` nvm use ${majorVersion}`,
97
+ documentationUrl: 'https://nodejs.org/en/download/',
98
+ });
99
+ }
100
+ else {
101
+ log.warn(`${message}. Build may fail or behave unexpectedly.`);
102
+ }
103
+ }
104
+ else {
105
+ log.debug(`Node.js version ${current} meets requirement ${minimum}`);
106
+ }
107
+ }
108
+ /** Get a human-readable description of the Node.js version requirement. */
109
+ function describeRequirement(requirement) {
110
+ const severity = requirement.severity === 'error' ? 'required' : 'recommended';
111
+ return `Node.js ${requirement.minimum}+ (${severity})`;
112
+ }
113
+ //# sourceMappingURL=node-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-version.js","sourceRoot":"","sources":["../../src/utils/node-version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,sDAEC;AAGD,kDAGC;AAGD,kDAKC;AAGD,0DASC;AAQD,kDA4BC;AAGD,kDAGC;AAtFD;;;;;;;;GAQG;AACH,+CAAiC;AAGjC,iDAAgE;AAGhE,uEAAuE;AACvE,SAAgB,qBAAqB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,uEAAuE;AACvE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC;AAED,yFAAyF;AACzF,SAAgB,mBAAmB,CAAC,CAAS,EAAE,CAAS;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED,oFAAoF;AACpF,SAAgB,uBAAuB,CAAC,OAAe,EAAE,OAAe;IACtE,MAAM,cAAc,GAA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AAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;IAC/E,OAAO,WAAW,WAAW,CAAC,OAAO,MAAM,QAAQ,GAAG,CAAC;AACzD,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * npm execution.
3
+ *
4
+ * The original cosmic-builder spawned npm directly. Here it runs through the
5
+ * injected CommandRunner port so the host controls execution (and can sandbox
6
+ * it). Kept as a free function — rather than a base-class method — so it can be
7
+ * mocked at the module boundary the same way the cosmic-builder tests do.
8
+ */
9
+ import type { Logger, CommandRunner } from '../ports';
10
+ /** Standard npm arguments to reduce noise. */
11
+ export declare const NPM_ARGS: string[];
12
+ export interface NpmOptions {
13
+ log: Logger;
14
+ runCommand: CommandRunner;
15
+ cwd: string;
16
+ args: string[];
17
+ env?: Record<string, string>;
18
+ }
19
+ /**
20
+ * Execute an npm command with standardized arguments and telemetry disabled.
21
+ *
22
+ * Rejects (via the runner's CommandError) on a non-zero exit.
23
+ */
24
+ export declare function npm(options: NpmOptions): Promise<void>;
25
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEtD,8CAA8C;AAC9C,eAAO,MAAM,QAAQ,UAAuE,CAAC;AAE7F,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,aAAa,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B5D"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NPM_ARGS = void 0;
4
+ exports.npm = npm;
5
+ /** Standard npm arguments to reduce noise. */
6
+ exports.NPM_ARGS = ['--no-update-notifier', '--no-progress', '--no-audit', '--no-fund'];
7
+ /**
8
+ * Execute an npm command with standardized arguments and telemetry disabled.
9
+ *
10
+ * Rejects (via the runner's CommandError) on a non-zero exit.
11
+ */
12
+ async function npm(options) {
13
+ const { log, runCommand, cwd, args } = options;
14
+ // Inherit the host environment as the base so registry auth, proxies, custom
15
+ // CAs (NODE_EXTRA_CA_CERTS), and npm config resolution keep working — this
16
+ // matches how the legacy cosmic-builder / CLI ran npm (inherited env). A host
17
+ // that needs a hermetic or secret-isolated build env should inject its own
18
+ // CommandRunner rather than relying on this default.
19
+ const env = {};
20
+ for (const [key, value] of Object.entries(process.env)) {
21
+ if (value !== undefined)
22
+ env[key] = value;
23
+ }
24
+ // Caller-supplied vars (e.g. the user's build env) override inherited ones.
25
+ Object.assign(env, options.env ?? {});
26
+ // Disable telemetry regardless of what was inherited or passed.
27
+ env.WRANGLER_SEND_METRICS = 'false';
28
+ env.NEXT_TELEMETRY_DISABLED = '1';
29
+ log.debug(`npm ${[...exports.NPM_ARGS, ...args].join(' ')} (in ${cwd})`);
30
+ await runCommand.run('npm', [...exports.NPM_ARGS, ...args], {
31
+ cwd,
32
+ env,
33
+ onOutput: (chunk) => {
34
+ const trimmed = chunk.replace(/\s+$/, '');
35
+ if (trimmed)
36
+ log.info(trimmed);
37
+ },
38
+ });
39
+ }
40
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";;;AA0BA,kBA8BC;AA9CD,8CAA8C;AACjC,QAAA,QAAQ,GAAG,CAAC,sBAAsB,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAU7F;;;;GA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line injects these names and the deployer maps them to
5
+ * Cloudflare Worker bindings. If a user-defined env var collides with one of
6
+ * them, the deploy step fails when Cloudflare rejects the duplicate binding
7
+ * (e.g. `Binding name 'COSMIC_MOUNT_PATH' already in use`), which previously
8
+ * surfaced only as a silent hang.
9
+ *
10
+ * This is a safety net: the dashboard (UI) and API reject reserved names before
11
+ * they are ever stored. This filter only catches names that slip through. Keep
12
+ * it in sync with the monorepo source of truth at
13
+ * `packages/systems/cosmic/constants/reservedEnvVarNames.ts` and with the
14
+ * system env declarations in cosmic-builder's `images/env.ts`.
15
+ */
16
+ /** Reserved name prefixes — any key starting with one of these is reserved. */
17
+ export declare const RESERVED_ENV_VAR_PREFIXES: readonly ["COSMIC_", "CLOUDFLARE_", "WRANGLER_"];
18
+ /** Reserved exact names not already covered by a reserved prefix. */
19
+ export declare const RESERVED_ENV_VAR_NAMES: readonly ["APP_NAME", "APP_PATH", "COMMIT_HASH", "DEPLOYMENT_ID", "COMPLETION_URL", "STARTED_URL", "OUTPUT_URL", "REPO_URL", "TARBALL_URL", "UPLOAD_CREDENTIALS", "HOSTNAME", "NODE_ENV", "NODE_VERSION"];
20
+ /**
21
+ * Returns true if `key` is reserved for Webflow Cloud internal use and must not
22
+ * be applied as a user-defined environment variable. Matching is
23
+ * case-insensitive and ignores surrounding whitespace.
24
+ */
25
+ export declare function isReservedEnvVarName(key: string): boolean;
26
+ //# sourceMappingURL=reserved-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserved-env.d.ts","sourceRoot":"","sources":["../../src/utils/reserved-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,kDAAmD,CAAC;AAE1F,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,2MAczB,CAAC;AAIX;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMzD"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Environment variable names that Webflow Cloud reserves for internal use.
4
+ *
5
+ * The build/deploy pipeline injects these names and the deployer maps them to
6
+ * Cloudflare Worker bindings. If a user-defined env var collides with one of
7
+ * them, the deploy step fails when Cloudflare rejects the duplicate binding
8
+ * (e.g. `Binding name 'COSMIC_MOUNT_PATH' already in use`), which previously
9
+ * surfaced only as a silent hang.
10
+ *
11
+ * This is a safety net: the dashboard (UI) and API reject reserved names before
12
+ * they are ever stored. This filter only catches names that slip through. Keep
13
+ * it in sync with the monorepo source of truth at
14
+ * `packages/systems/cosmic/constants/reservedEnvVarNames.ts` and with the
15
+ * system env declarations in cosmic-builder's `images/env.ts`.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.RESERVED_ENV_VAR_NAMES = exports.RESERVED_ENV_VAR_PREFIXES = void 0;
19
+ exports.isReservedEnvVarName = isReservedEnvVarName;
20
+ /** Reserved name prefixes — any key starting with one of these is reserved. */
21
+ exports.RESERVED_ENV_VAR_PREFIXES = ['COSMIC_', 'CLOUDFLARE_', 'WRANGLER_'];
22
+ /** Reserved exact names not already covered by a reserved prefix. */
23
+ exports.RESERVED_ENV_VAR_NAMES = [
24
+ 'APP_NAME',
25
+ 'APP_PATH',
26
+ 'COMMIT_HASH',
27
+ 'DEPLOYMENT_ID',
28
+ 'COMPLETION_URL',
29
+ 'STARTED_URL',
30
+ 'OUTPUT_URL',
31
+ 'REPO_URL',
32
+ 'TARBALL_URL',
33
+ 'UPLOAD_CREDENTIALS',
34
+ 'HOSTNAME',
35
+ 'NODE_ENV',
36
+ 'NODE_VERSION',
37
+ ];
38
+ const RESERVED_NAME_SET = new Set(exports.RESERVED_ENV_VAR_NAMES);
39
+ /**
40
+ * Returns true if `key` is reserved for Webflow Cloud internal use and must not
41
+ * be applied as a user-defined environment variable. Matching is
42
+ * case-insensitive and ignores surrounding whitespace.
43
+ */
44
+ function isReservedEnvVarName(key) {
45
+ const normalized = key.trim().toUpperCase();
46
+ if (RESERVED_NAME_SET.has(normalized)) {
47
+ return true;
48
+ }
49
+ return exports.RESERVED_ENV_VAR_PREFIXES.some((prefix) => normalized.startsWith(prefix));
50
+ }
51
+ //# sourceMappingURL=reserved-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserved-env.js","sourceRoot":"","sources":["../../src/utils/reserved-env.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA6BH,oDAMC;AAjCD,+EAA+E;AAClE,QAAA,yBAAyB,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAU,CAAC;AAE1F,qEAAqE;AACxD,QAAA,sBAAsB,GAAG;IACpC,UAAU;IACV,UAAU;IACV,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,UAAU;IACV,aAAa;IACb,oBAAoB;IACpB,UAAU;IACV,UAAU;IACV,cAAc;CACN,CAAC;AAEX,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,8BAAsB,CAAC,CAAC;AAE/E;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,iCAAyB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Substitute `${VAR}` and `$VAR` references in `input` with values from `vars`.
3
+ * Unset variables become the empty string. Single pass — substituted values are
4
+ * not re-scanned — matching `envsubst`.
5
+ */
6
+ export declare function substituteEnv(input: string, vars: Record<string, string | undefined>): string;
7
+ /**
8
+ * Render a template file to `outputPath`, substituting environment variables.
9
+ *
10
+ * @throws Error if the template file does not exist.
11
+ */
12
+ export declare function envsubst(log: {
13
+ debug(message: string): void;
14
+ }, templatePath: string, outputPath: string, env?: Record<string, string | undefined>): Promise<void>;
15
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAQ7F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE;IAAE,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACrC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAUf"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.substituteEnv = substituteEnv;
37
+ exports.envsubst = envsubst;
38
+ /**
39
+ * Template rendering.
40
+ *
41
+ * The original cosmic-builder shelled out to the system `envsubst` binary
42
+ * (gettext). That's fine inside the ECS build container but not in a public,
43
+ * agent-importable package that also runs on contributors' machines and inside
44
+ * the CLI — `envsubst` is frequently absent there. This is a pure-JS
45
+ * reimplementation of the substitution semantics the templates rely on
46
+ * (`${VAR}` / `$VAR`, unset variables become the empty string, single pass with
47
+ * no recursion), so rendering is identical without the system dependency.
48
+ */
49
+ const fs = __importStar(require("node:fs"));
50
+ /**
51
+ * Substitute `${VAR}` and `$VAR` references in `input` with values from `vars`.
52
+ * Unset variables become the empty string. Single pass — substituted values are
53
+ * not re-scanned — matching `envsubst`.
54
+ */
55
+ function substituteEnv(input, vars) {
56
+ return input.replace(/\$(?:\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g, (_match, braced, bare) => {
57
+ const name = braced ?? bare ?? '';
58
+ return vars[name] ?? '';
59
+ });
60
+ }
61
+ /**
62
+ * Render a template file to `outputPath`, substituting environment variables.
63
+ *
64
+ * @throws Error if the template file does not exist.
65
+ */
66
+ async function envsubst(log, templatePath, outputPath, env) {
67
+ if (!fs.existsSync(templatePath)) {
68
+ throw new Error(`Template not found: ${templatePath}`);
69
+ }
70
+ const source = fs.readFileSync(templatePath, 'utf8');
71
+ const result = substituteEnv(source, env ?? process.env);
72
+ log.debug(`envsubst: ${templatePath} -> ${outputPath}`);
73
+ fs.writeFileSync(outputPath, result);
74
+ }
75
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,sCAQC;AAOD,4BAeC;AAhDD;;;;;;;;;;GAUG;AACH,4CAA8B;AAE9B;;;;GAIG;AACH,SAAgB,aAAa,CAAC,KAAa,EAAE,IAAwC;IACnF,OAAO,KAAK,CAAC,OAAO,CAClB,8DAA8D,EAC9D,CAAC,MAAM,EAAE,MAA0B,EAAE,IAAwB,EAAE,EAAE;QAC/D,MAAM,IAAI,GAAG,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAC5B,GAAqC,EACrC,YAAoB,EACpB,UAAkB,EAClB,GAAwC;IAExC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,uBAAuB,YAAY,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzD,GAAG,CAAC,KAAK,CAAC,aAAa,YAAY,OAAO,UAAU,EAAE,CAAC,CAAC;IACxD,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Extracts the major version from a package.json version specifier.
3
+ *
4
+ * Handles `^1.2.3`, `~1.2.3`, `1.2.3`, `npm:pkg@^1.2.3`, `>=1.2.3`,
5
+ * `>=1.2.3 <2.0.0`. Returns null for unparseable specifiers (`latest`,
6
+ * `file:../local`, `workspace:*`, `link:../other`, empty string).
7
+ */
8
+ export declare function getMajorVersion(versionSpec: string): number | null;
9
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/utils/version.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMlE"}