@webflow/cloud-app 0.1.0-beta.10
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/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/bindings.d.ts +190 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +126 -0
- package/dist/bindings.js.map +1 -0
- package/dist/compat-date.d.ts +68 -0
- package/dist/compat-date.d.ts.map +1 -0
- package/dist/compat-date.js +169 -0
- package/dist/compat-date.js.map +1 -0
- package/dist/config/package-json.d.ts +57 -0
- package/dist/config/package-json.d.ts.map +1 -0
- package/dist/config/package-json.js +94 -0
- package/dist/config/package-json.js.map +1 -0
- package/dist/config/webflow-json.d.ts +47 -0
- package/dist/config/webflow-json.d.ts.map +1 -0
- package/dist/config/webflow-json.js +72 -0
- package/dist/config/webflow-json.js.map +1 -0
- package/dist/create-webflow-json.d.ts +21 -0
- package/dist/create-webflow-json.d.ts.map +1 -0
- package/dist/create-webflow-json.js +168 -0
- package/dist/create-webflow-json.js.map +1 -0
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +31 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +28 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +148 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts +34 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js +89 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts +39 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js +93 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/astro5.d.ts +28 -0
- package/dist/frameworks/astro/astro5.d.ts.map +1 -0
- package/dist/frameworks/astro/astro5.js +276 -0
- package/dist/frameworks/astro/astro5.js.map +1 -0
- package/dist/frameworks/astro/astro6.d.ts +28 -0
- package/dist/frameworks/astro/astro6.d.ts.map +1 -0
- package/dist/frameworks/astro/astro6.js +305 -0
- package/dist/frameworks/astro/astro6.js.map +1 -0
- package/dist/frameworks/astro/astro7.d.ts +28 -0
- package/dist/frameworks/astro/astro7.d.ts.map +1 -0
- package/dist/frameworks/astro/astro7.js +303 -0
- package/dist/frameworks/astro/astro7.js.map +1 -0
- package/dist/frameworks/astro/index.d.ts +10 -0
- package/dist/frameworks/astro/index.d.ts.map +1 -0
- package/dist/frameworks/astro/index.js +16 -0
- package/dist/frameworks/astro/index.js.map +1 -0
- package/dist/frameworks/astro/session-check.d.ts +24 -0
- package/dist/frameworks/astro/session-check.d.ts.map +1 -0
- package/dist/frameworks/astro/session-check.js +166 -0
- package/dist/frameworks/astro/session-check.js.map +1 -0
- package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
- package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
- package/dist/frameworks/astro/templates/v5/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
- package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
- package/dist/frameworks/astro/templates/v6/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
- package/dist/frameworks/astro/templates/v7/webflow-loader.ts +125 -0
- package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/webflow-image-url.ts +140 -0
- package/dist/frameworks/base.d.ts +134 -0
- package/dist/frameworks/base.d.ts.map +1 -0
- package/dist/frameworks/base.js +175 -0
- package/dist/frameworks/base.js.map +1 -0
- package/dist/frameworks/errors.d.ts +72 -0
- package/dist/frameworks/errors.d.ts.map +1 -0
- package/dist/frameworks/errors.js +120 -0
- package/dist/frameworks/errors.js.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
- package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
- package/dist/frameworks/nextjs/index.d.ts +38 -0
- package/dist/frameworks/nextjs/index.d.ts.map +1 -0
- package/dist/frameworks/nextjs/index.js +268 -0
- package/dist/frameworks/nextjs/index.js.map +1 -0
- package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
- package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
- package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
- package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
- package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
- package/dist/frameworks/registry.d.ts +127 -0
- package/dist/frameworks/registry.d.ts.map +1 -0
- package/dist/frameworks/registry.js +257 -0
- package/dist/frameworks/registry.js.map +1 -0
- package/dist/frameworks/static/index.d.ts +116 -0
- package/dist/frameworks/static/index.d.ts.map +1 -0
- package/dist/frameworks/static/index.js +394 -0
- package/dist/frameworks/static/index.js.map +1 -0
- package/dist/frameworks/static/templates/wrangler.json +8 -0
- package/dist/frameworks/types.d.ts +138 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +3 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/frameworks/vite/index.d.ts +46 -0
- package/dist/frameworks/vite/index.d.ts.map +1 -0
- package/dist/frameworks/vite/index.js +303 -0
- package/dist/frameworks/vite/index.js.map +1 -0
- package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
- package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
- package/dist/frameworks/vite/templates/wrangler.json +10 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +293 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/ports/command-runner.d.ts +59 -0
- package/dist/ports/command-runner.d.ts.map +1 -0
- package/dist/ports/command-runner.js +126 -0
- package/dist/ports/command-runner.js.map +1 -0
- package/dist/ports/filesystem.d.ts +19 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +68 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/index.d.ts +17 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +14 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/logger.d.ts +22 -0
- package/dist/ports/logger.d.ts.map +1 -0
- package/dist/ports/logger.js +18 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/telemetry.d.ts +23 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +12 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/static-base-href.d.ts +31 -0
- package/dist/static-base-href.d.ts.map +1 -0
- package/dist/static-base-href.js +183 -0
- package/dist/static-base-href.js.map +1 -0
- package/dist/toolchain/errors.d.ts +32 -0
- package/dist/toolchain/errors.d.ts.map +1 -0
- package/dist/toolchain/errors.js +31 -0
- package/dist/toolchain/errors.js.map +1 -0
- package/dist/toolchain/resolver.d.ts +25 -0
- package/dist/toolchain/resolver.d.ts.map +1 -0
- package/dist/toolchain/resolver.js +200 -0
- package/dist/toolchain/resolver.js.map +1 -0
- package/dist/toolchain/types.d.ts +52 -0
- package/dist/toolchain/types.d.ts.map +1 -0
- package/dist/toolchain/types.js +10 -0
- package/dist/toolchain/types.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +29 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +126 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/node-version.d.ts +20 -0
- package/dist/utils/node-version.d.ts.map +1 -0
- package/dist/utils/node-version.js +113 -0
- package/dist/utils/node-version.js.map +1 -0
- package/dist/utils/process.d.ts +25 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +40 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/reserved-env.d.ts +26 -0
- package/dist/utils/reserved-env.d.ts.map +1 -0
- package/dist/utils/reserved-env.js +51 -0
- package/dist/utils/reserved-env.js.map +1 -0
- package/dist/utils/template.d.ts +15 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +75 -0
- package/dist/utils/template.js.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/wrangler.d.ts +195 -0
- package/dist/wrangler.d.ts.map +1 -0
- package/dist/wrangler.js +372 -0
- package/dist/wrangler.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,169 @@
|
|
|
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.COMPAT_DATE_RECORD_FILE = exports.COMPAT_DATE_FLOOR = void 0;
|
|
37
|
+
exports.resolveCompatDate = resolveCompatDate;
|
|
38
|
+
exports.applyCompatDateAtBuild = applyCompatDateAtBuild;
|
|
39
|
+
/**
|
|
40
|
+
* Build-phase `compatibility_date` policy.
|
|
41
|
+
*
|
|
42
|
+
* wrangler bundles the worker at build time, and the date decides whether Node's
|
|
43
|
+
* `http`/`https` are inlined unenv polyfills or native imports. A bundle built at
|
|
44
|
+
* an old date still throws at a newer runtime date (so SDKs on Node's http client,
|
|
45
|
+
* like Sentry's server transport, silently drop data), and a bundle built at a new
|
|
46
|
+
* date fails to start at an old one. So the build settles the date once, on the
|
|
47
|
+
* `wrangler.json` it just copied from the framework template, and records it for
|
|
48
|
+
* the deploy, which applies the record and never decides a date itself.
|
|
49
|
+
*
|
|
50
|
+
* The policy is switched on by the host (the server's feature gate, via
|
|
51
|
+
* `compatDatePolicy`); off keeps today's behavior exactly.
|
|
52
|
+
*/
|
|
53
|
+
const fs = __importStar(require("node:fs"));
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
|
+
const bindings_1 = require("./bindings");
|
|
56
|
+
/**
|
|
57
|
+
* Lowest `compatibility_date` the platform runs a worker at once the policy is on.
|
|
58
|
+
* workerd only provides a working `node:http` / `node:https` client from this date.
|
|
59
|
+
*/
|
|
60
|
+
exports.COMPAT_DATE_FLOOR = '2025-08-16';
|
|
61
|
+
/**
|
|
62
|
+
* Where the build records the date it settled on, next to `clouduser.wrangler.json`
|
|
63
|
+
* (which already travels from the build to the deploy). Keep in sync with the
|
|
64
|
+
* deployer.
|
|
65
|
+
*/
|
|
66
|
+
exports.COMPAT_DATE_RECORD_FILE = 'clouduser.compat-date.json';
|
|
67
|
+
function isValidDate(value) {
|
|
68
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const parsed = new Date(`${value}T00:00:00Z`);
|
|
72
|
+
return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Pure resolution of the date a worker is built and deployed with.
|
|
76
|
+
*
|
|
77
|
+
* policy off -> template date, unchanged
|
|
78
|
+
* policy on, user date valid, <= today, >= floor -> user date
|
|
79
|
+
* policy on, otherwise -> default, plus a warning if a
|
|
80
|
+
* user date was given but unusable
|
|
81
|
+
*
|
|
82
|
+
* where default = the template date if it is a valid date at or above the floor,
|
|
83
|
+
* else the floor.
|
|
84
|
+
*/
|
|
85
|
+
function resolveCompatDate(inputs) {
|
|
86
|
+
const { templateDate, userDate, policyEnabled } = inputs;
|
|
87
|
+
const today = (inputs.now ?? new Date()).toISOString().slice(0, 10);
|
|
88
|
+
if (!policyEnabled) {
|
|
89
|
+
return { date: templateDate, source: 'template' };
|
|
90
|
+
}
|
|
91
|
+
const templateUsable = isValidDate(templateDate) && templateDate >= exports.COMPAT_DATE_FLOOR;
|
|
92
|
+
const fallback = templateUsable
|
|
93
|
+
? { date: templateDate, source: 'template' }
|
|
94
|
+
: { date: exports.COMPAT_DATE_FLOOR, source: 'floor' };
|
|
95
|
+
if (userDate === undefined) {
|
|
96
|
+
return fallback;
|
|
97
|
+
}
|
|
98
|
+
let problem;
|
|
99
|
+
if (!isValidDate(userDate)) {
|
|
100
|
+
problem = 'is not a valid YYYY-MM-DD date';
|
|
101
|
+
}
|
|
102
|
+
else if (userDate > today) {
|
|
103
|
+
problem = 'is in the future';
|
|
104
|
+
}
|
|
105
|
+
else if (userDate < exports.COMPAT_DATE_FLOOR) {
|
|
106
|
+
problem = `is below the platform minimum ${exports.COMPAT_DATE_FLOOR}`;
|
|
107
|
+
}
|
|
108
|
+
if (problem) {
|
|
109
|
+
return {
|
|
110
|
+
...fallback,
|
|
111
|
+
warning: `compatibility_date ${userDate} in your wrangler config ${problem}, using ${fallback.date}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return { date: userDate, source: 'user' };
|
|
115
|
+
}
|
|
116
|
+
function recordPath(cwd) {
|
|
117
|
+
return path.join(cwd, exports.COMPAT_DATE_RECORD_FILE);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Settles the date on `<cwd>/wrangler.json` (just copied from the framework
|
|
121
|
+
* template) and records it for the deploy.
|
|
122
|
+
*
|
|
123
|
+
* `userCompatDate` is the date from the user's own wrangler config, if any. The
|
|
124
|
+
* bindings-bridge placeholder is not a user choice and is ignored. With the policy
|
|
125
|
+
* off nothing changes and no record is written; a record already in the checkout is
|
|
126
|
+
* removed either way, because the deploy trusts that file and a repo must not be
|
|
127
|
+
* able to supply it.
|
|
128
|
+
*
|
|
129
|
+
* Never throws: an error keeps the template date and logs a warning, so this cannot
|
|
130
|
+
* fail a build.
|
|
131
|
+
*/
|
|
132
|
+
function applyCompatDateAtBuild(log, cwd, userCompatDate, opts = {}) {
|
|
133
|
+
try {
|
|
134
|
+
fs.rmSync(recordPath(cwd), { force: true });
|
|
135
|
+
const wranglerPath = path.join(cwd, 'wrangler.json');
|
|
136
|
+
const generated = JSON.parse(fs.readFileSync(wranglerPath, 'utf8'));
|
|
137
|
+
const templateDate = generated.compatibility_date;
|
|
138
|
+
const userDate = userCompatDate === bindings_1.BINDINGS_BRIDGE_COMPAT_DATE ? undefined : userCompatDate;
|
|
139
|
+
const policyEnabled = opts.policyEnabled === true;
|
|
140
|
+
const resolution = resolveCompatDate({ templateDate, userDate, policyEnabled, now: opts.now });
|
|
141
|
+
log.info(`compatibility_date: ${resolution.date} (${resolution.source}; policy ${policyEnabled ? 'on' : 'off'}, template ${templateDate}${userDate ? `, user ${userDate}` : ''})`);
|
|
142
|
+
if (resolution.warning) {
|
|
143
|
+
log.warn(resolution.warning);
|
|
144
|
+
}
|
|
145
|
+
if (policyEnabled) {
|
|
146
|
+
if (resolution.date !== templateDate) {
|
|
147
|
+
generated.compatibility_date = resolution.date;
|
|
148
|
+
fs.writeFileSync(wranglerPath, `${JSON.stringify(generated, null, 2)}\n`);
|
|
149
|
+
}
|
|
150
|
+
const record = {
|
|
151
|
+
compatibilityDate: resolution.date,
|
|
152
|
+
source: resolution.source,
|
|
153
|
+
};
|
|
154
|
+
fs.writeFileSync(recordPath(cwd), JSON.stringify(record));
|
|
155
|
+
}
|
|
156
|
+
return resolution;
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
log.warn(`could not apply the compatibility_date policy, keeping the template date: ${err}`);
|
|
160
|
+
try {
|
|
161
|
+
fs.rmSync(recordPath(cwd), { force: true });
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// nothing more to do
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=compat-date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat-date.js","sourceRoot":"","sources":["../src/compat-date.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,8CAgCC;AAmBD,wDA6CC;AAlLD;;;;;;;;;;;;;GAaG;AACH,4CAA8B;AAC9B,gDAAkC;AAGlC,yCAAyD;AAEzD;;;GAGG;AACU,QAAA,iBAAiB,GAAG,YAAY,CAAC;AAE9C;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,4BAA4B,CAAC;AAgCpE,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,KAAK,YAAY,CAAC,CAAC;IAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC;AACxF,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAAC,MAAwB;IACxD,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,GAAG,IA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AG,UAAU,CAAC,IAAI,CAAC;gBAC/C,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YAC5E,CAAC;YACD,MAAM,MAAM,GAAqB;gBAC/B,iBAAiB,EAAE,UAAU,CAAC,IAAI;gBAClC,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC;YACF,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,6EAA6E,GAAG,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC;YACH,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,qBAAqB;QACvB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Package.json schema (minimal fields we need).
|
|
4
|
+
*
|
|
5
|
+
* Only the fields used by the framework builder are validated here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PackageJsonSchema: z.ZodObject<{
|
|
8
|
+
/** Package name */
|
|
9
|
+
name: z.ZodOptional<z.ZodString>;
|
|
10
|
+
/** Package version */
|
|
11
|
+
version: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/** Production dependencies (package name -> version specifier) */
|
|
13
|
+
dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
14
|
+
/** Development dependencies (package name -> version specifier) */
|
|
15
|
+
devDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
16
|
+
/** Runtime declarations. `node` is deliberately retained as unknown so the
|
|
17
|
+
* toolchain resolver can warn and fall back for a malformed customer
|
|
18
|
+
* declaration rather than rejecting the entire package.json. */
|
|
19
|
+
engines: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
node: z.ZodOptional<z.ZodUnknown>;
|
|
21
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
22
|
+
node: z.ZodOptional<z.ZodUnknown>;
|
|
23
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
24
|
+
node: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
version?: string | undefined;
|
|
29
|
+
dependencies?: Record<string, string> | undefined;
|
|
30
|
+
devDependencies?: Record<string, string> | undefined;
|
|
31
|
+
engines?: z.objectOutputType<{
|
|
32
|
+
node: z.ZodOptional<z.ZodUnknown>;
|
|
33
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
version?: string | undefined;
|
|
37
|
+
dependencies?: Record<string, string> | undefined;
|
|
38
|
+
devDependencies?: Record<string, string> | undefined;
|
|
39
|
+
engines?: z.objectInputType<{
|
|
40
|
+
node: z.ZodOptional<z.ZodUnknown>;
|
|
41
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Package.json structure (minimal fields we need).
|
|
45
|
+
*/
|
|
46
|
+
export type PackageJson = z.infer<typeof PackageJsonSchema>;
|
|
47
|
+
/**
|
|
48
|
+
* Load and validate package.json from `cwd`. Returns `undefined` when the file
|
|
49
|
+
* is absent.
|
|
50
|
+
*
|
|
51
|
+
* NOTE: unlike the original cosmic-builder implementation this does NOT cache
|
|
52
|
+
* across calls — a single long-lived host process (the server-side builder, an
|
|
53
|
+
* MCP server) builds many different projects, so a module-level cache would
|
|
54
|
+
* leak one project's package.json into the next build.
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadPackageJson(cwd: string): PackageJson | undefined;
|
|
57
|
+
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../src/config/package-json.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B,mBAAmB;;IAEnB,sBAAsB;;IAEtB,kEAAkE;;IAElE,mEAAmE;;IAEnE;;oEAEgE;;;;;;;;;;;;;;;;;;;;;;;;EAOhE,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAoBpE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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.PackageJsonSchema = void 0;
|
|
37
|
+
exports.loadPackageJson = loadPackageJson;
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const zod_1 = require("zod");
|
|
41
|
+
/**
|
|
42
|
+
* Package.json schema (minimal fields we need).
|
|
43
|
+
*
|
|
44
|
+
* Only the fields used by the framework builder are validated here.
|
|
45
|
+
*/
|
|
46
|
+
exports.PackageJsonSchema = zod_1.z.object({
|
|
47
|
+
/** Package name */
|
|
48
|
+
name: zod_1.z.string().optional(),
|
|
49
|
+
/** Package version */
|
|
50
|
+
version: zod_1.z.string().optional(),
|
|
51
|
+
/** Production dependencies (package name -> version specifier) */
|
|
52
|
+
dependencies: zod_1.z.record(zod_1.z.string()).optional(),
|
|
53
|
+
/** Development dependencies (package name -> version specifier) */
|
|
54
|
+
devDependencies: zod_1.z.record(zod_1.z.string()).optional(),
|
|
55
|
+
/** Runtime declarations. `node` is deliberately retained as unknown so the
|
|
56
|
+
* toolchain resolver can warn and fall back for a malformed customer
|
|
57
|
+
* declaration rather than rejecting the entire package.json. */
|
|
58
|
+
engines: zod_1.z
|
|
59
|
+
.object({
|
|
60
|
+
node: zod_1.z.unknown().optional(),
|
|
61
|
+
})
|
|
62
|
+
.passthrough()
|
|
63
|
+
.optional(),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Load and validate package.json from `cwd`. Returns `undefined` when the file
|
|
67
|
+
* is absent.
|
|
68
|
+
*
|
|
69
|
+
* NOTE: unlike the original cosmic-builder implementation this does NOT cache
|
|
70
|
+
* across calls — a single long-lived host process (the server-side builder, an
|
|
71
|
+
* MCP server) builds many different projects, so a module-level cache would
|
|
72
|
+
* leak one project's package.json into the next build.
|
|
73
|
+
*/
|
|
74
|
+
function loadPackageJson(cwd) {
|
|
75
|
+
const filePath = path.join(cwd, 'package.json');
|
|
76
|
+
if (!fs.statSync(filePath, { throwIfNoEntry: false })) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const raw = fs.readFileSync(filePath).toString('utf8');
|
|
80
|
+
let unparsed;
|
|
81
|
+
try {
|
|
82
|
+
unparsed = JSON.parse(raw);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
throw new Error(`package.json was not valid JSON`, { cause: e });
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
return exports.PackageJsonSchema.parse(unparsed);
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
throw new Error('package.json schema validation failed', { cause: e });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../src/config/package-json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,0CAoBC;AAhED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AAC,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,CAAC;QACH,OAAO,yBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,uCAAuC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Logger } from '../ports';
|
|
2
|
+
import type { WebflowBindings } from '../bindings';
|
|
3
|
+
/**
|
|
4
|
+
* Build-time, permissive view of webflow.json.
|
|
5
|
+
*
|
|
6
|
+
* The user's source webflow.json may not yet contain a complete deploy
|
|
7
|
+
* contract — that's emitted by `createWebflowJson` later in the build. Reads
|
|
8
|
+
* here treat every field as optional and `framework` as an arbitrary `string`
|
|
9
|
+
* (it's user input until the contract validates it at deploy time).
|
|
10
|
+
*
|
|
11
|
+
* Deploy-time reads MUST use `validateForDeploy` from
|
|
12
|
+
* `@webflow/cosmic-deploy-contract`, which is strict and fails fast on contract
|
|
13
|
+
* violations. Do not introduce a second permissive deploy reader here.
|
|
14
|
+
*/
|
|
15
|
+
export type WebflowJson = {
|
|
16
|
+
cloud?: {
|
|
17
|
+
/** User-specified or producer-written framework hint. Validated strictly only at deploy time. */
|
|
18
|
+
framework?: string;
|
|
19
|
+
contract_version?: string;
|
|
20
|
+
framework_version?: string;
|
|
21
|
+
entrypoint_path?: string;
|
|
22
|
+
deployment_type?: string;
|
|
23
|
+
skip_no_bundle?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* User-declared KV / R2 / D1 bindings. The single user-facing place to
|
|
26
|
+
* declare bindings (replacing hand-written wrangler.json). Parsed/validated
|
|
27
|
+
* by `bindings.ts` and synthesized into the wrangler bridge at build time.
|
|
28
|
+
*/
|
|
29
|
+
bindings?: WebflowBindings;
|
|
30
|
+
/**
|
|
31
|
+
* Build-only: URL prefix for static assets. NOT part of the deploy contract.
|
|
32
|
+
*/
|
|
33
|
+
assets_path_prefix?: string;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Load and JSONC-parse webflow.json (or webflow.jsonc) at `cwd`.
|
|
40
|
+
*
|
|
41
|
+
* Returns `undefined` when the file is absent or fails to parse as JSONC.
|
|
42
|
+
* Intentionally permissive — used by build-phase code that reads optional hints
|
|
43
|
+
* (user-specified framework, build-only flags). The deploy phase uses
|
|
44
|
+
* `validateForDeploy` from the contract package instead.
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadWebflowJson(log: Logger, cwd: string, file?: string): WebflowJson | undefined;
|
|
47
|
+
//# sourceMappingURL=webflow-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webflow-json.d.ts","sourceRoot":"","sources":["../../src/config/webflow-json.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE;QACN,iGAAiG;QACjG,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB;;;;WAIG;QACH,QAAQ,CAAC,EAAE,eAAe,CAAC;QAC3B;;WAEG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAiB,GACpB,WAAW,GAAG,SAAS,CAyBzB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.loadWebflowJson = loadWebflowJson;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const jsonc = __importStar(require("jsonc-parser"));
|
|
40
|
+
/**
|
|
41
|
+
* Load and JSONC-parse webflow.json (or webflow.jsonc) at `cwd`.
|
|
42
|
+
*
|
|
43
|
+
* Returns `undefined` when the file is absent or fails to parse as JSONC.
|
|
44
|
+
* Intentionally permissive — used by build-phase code that reads optional hints
|
|
45
|
+
* (user-specified framework, build-only flags). The deploy phase uses
|
|
46
|
+
* `validateForDeploy` from the contract package instead.
|
|
47
|
+
*/
|
|
48
|
+
function loadWebflowJson(log, cwd, file = 'webflow.json') {
|
|
49
|
+
const filePath = path.join(cwd, file);
|
|
50
|
+
if (!fs.statSync(filePath, { throwIfNoEntry: false })) {
|
|
51
|
+
if (file.endsWith('.json')) {
|
|
52
|
+
return loadWebflowJson(log, cwd, file + 'c');
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const raw = fs.readFileSync(filePath).toString('utf8');
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = jsonc.parse(raw);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
log?.error(`loaded but could not parse as JSONC ${filePath} ${JSON.stringify(raw)}: ${e}`);
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
66
|
+
log?.error(`${filePath} is not a JSON object`);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
log.debug(`loaded ${filePath}: ${JSON.stringify(parsed)}`);
|
|
70
|
+
return parsed;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=webflow-json.js.map
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AAC,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,UAAU,QAAQ,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3D,OAAO,MAAqB,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type DeployContractV1 } from '@webflow/cosmic-deploy-contract';
|
|
2
|
+
import type { Logger } from './ports';
|
|
3
|
+
import type { FrameworkBuilder } from './frameworks/base';
|
|
4
|
+
import type { BuilderClass } from './frameworks/registry';
|
|
5
|
+
/**
|
|
6
|
+
* Compute the cloud.* fields createWebflowJson would write for a given framework.
|
|
7
|
+
*
|
|
8
|
+
* The returned object satisfies `DeployContractV1` for the contract fields the
|
|
9
|
+
* deployer reads.
|
|
10
|
+
*/
|
|
11
|
+
export declare function deriveCloudFields(frameworkName: string, builder: FrameworkBuilder | BuilderClass): DeployContractV1;
|
|
12
|
+
/**
|
|
13
|
+
* Create or update webflow.json with the detected framework and build output
|
|
14
|
+
* info.
|
|
15
|
+
*
|
|
16
|
+
* Accepts either a FrameworkBuilder instance (build phase) or a BuilderClass
|
|
17
|
+
* (no BuildContext available). When the existing webflow.json already matches
|
|
18
|
+
* the canonical metadata, no write happens. Otherwise the diff is logged.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createWebflowJson(log: Logger, cwd: string, frameworkName: string, builder: FrameworkBuilder | BuilderClass): void;
|
|
21
|
+
//# sourceMappingURL=create-webflow-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-webflow-json.d.ts","sourceRoot":"","sources":["../src/create-webflow-json.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GAAG,YAAY,GACvC,gBAAgB,CAqClB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GAAG,YAAY,GACvC,IAAI,CA8EN"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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.deriveCloudFields = deriveCloudFields;
|
|
37
|
+
exports.createWebflowJson = createWebflowJson;
|
|
38
|
+
/**
|
|
39
|
+
* webflow.json writer.
|
|
40
|
+
*
|
|
41
|
+
* `createWebflowJson` derives the canonical `cloud.*` deploy-contract fields
|
|
42
|
+
* from the detected framework's build metadata, writes them into the project's
|
|
43
|
+
* webflow.json (preserving any other keys), and runs a producer self-check via
|
|
44
|
+
* `validateForDeploy` so a builder bug fails the build immediately rather than
|
|
45
|
+
* slipping through to deploy time.
|
|
46
|
+
*/
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
|
+
const cosmic_deploy_contract_1 = require("@webflow/cosmic-deploy-contract");
|
|
50
|
+
/**
|
|
51
|
+
* Compute the cloud.* fields createWebflowJson would write for a given framework.
|
|
52
|
+
*
|
|
53
|
+
* The returned object satisfies `DeployContractV1` for the contract fields the
|
|
54
|
+
* deployer reads.
|
|
55
|
+
*/
|
|
56
|
+
function deriveCloudFields(frameworkName, builder) {
|
|
57
|
+
const output = typeof builder === 'function'
|
|
58
|
+
? builder.getOutputDeployMetadata()
|
|
59
|
+
: builder.getOutputDeployMetadata();
|
|
60
|
+
const cloud = {
|
|
61
|
+
contract_version: '1',
|
|
62
|
+
// Narrowed by the contract's Framework enum at the validateForDeploy
|
|
63
|
+
// self-check — if a builder returns an unrecognized name, the write fails fast.
|
|
64
|
+
framework: frameworkName,
|
|
65
|
+
deployment_type: output.deploymentType,
|
|
66
|
+
// Contract requires a boolean; normalize undefined to false.
|
|
67
|
+
skip_no_bundle: output.skipNoBundle === true,
|
|
68
|
+
};
|
|
69
|
+
// Assets-only apps (static, no framework) have no worker, so they carry no
|
|
70
|
+
// entrypoint_path — the contract allows it to be omitted. Every other
|
|
71
|
+
// deployment type has a worker entry: `dryRunEntryPath` points at the file
|
|
72
|
+
// produced by `wrangler deploy --dry-run` (Astro 5: ./index.js, Astro 6:
|
|
73
|
+
// ./entry.mjs, Next.js: ./worker.js), defaulting to ./index.js.
|
|
74
|
+
if (output.deploymentType !== 'static') {
|
|
75
|
+
cloud.entrypoint_path = output.dryRunEntryPath ?? './index.js';
|
|
76
|
+
}
|
|
77
|
+
// framework_version is optional under the contract. It's an instance-only
|
|
78
|
+
// capability (reads the user's package.json via the builder's ctx), so it's
|
|
79
|
+
// only available for the build-phase instance path — not the deploy-phase
|
|
80
|
+
// BuilderClass path. Omitted when unresolvable (e.g. `workspace:*`, `latest`).
|
|
81
|
+
if (typeof builder !== 'function') {
|
|
82
|
+
const frameworkVersion = builder.getFrameworkVersion();
|
|
83
|
+
if (frameworkVersion) {
|
|
84
|
+
cloud.framework_version = frameworkVersion;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return cloud;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create or update webflow.json with the detected framework and build output
|
|
91
|
+
* info.
|
|
92
|
+
*
|
|
93
|
+
* Accepts either a FrameworkBuilder instance (build phase) or a BuilderClass
|
|
94
|
+
* (no BuildContext available). When the existing webflow.json already matches
|
|
95
|
+
* the canonical metadata, no write happens. Otherwise the diff is logged.
|
|
96
|
+
*/
|
|
97
|
+
function createWebflowJson(log, cwd, frameworkName, builder) {
|
|
98
|
+
const webflowJsonPath = path.join(cwd, 'webflow.json');
|
|
99
|
+
// Start with existing webflow.json if present, or create new. If the file is
|
|
100
|
+
// malformed JSON we log and overwrite.
|
|
101
|
+
let webflowJson = { cloud: {} };
|
|
102
|
+
if (fs.existsSync(webflowJsonPath)) {
|
|
103
|
+
try {
|
|
104
|
+
const raw = fs.readFileSync(webflowJsonPath, 'utf8');
|
|
105
|
+
webflowJson = JSON.parse(raw);
|
|
106
|
+
if (!webflowJson.cloud || typeof webflowJson.cloud !== 'object') {
|
|
107
|
+
log.warn('webflow.json is missing "cloud" property, adding it');
|
|
108
|
+
webflowJson.cloud = {};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
log.warn(`Failed to parse existing webflow.json, overwriting: ${e}`);
|
|
113
|
+
webflowJson = { cloud: {} };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const existing = webflowJson.cloud;
|
|
117
|
+
const desired = deriveCloudFields(frameworkName, builder);
|
|
118
|
+
// Compare existing vs desired and log either a diff or a "no change" message.
|
|
119
|
+
const changed = [];
|
|
120
|
+
const trackedKeys = [
|
|
121
|
+
'contract_version',
|
|
122
|
+
'framework',
|
|
123
|
+
'framework_version',
|
|
124
|
+
'deployment_type',
|
|
125
|
+
'entrypoint_path',
|
|
126
|
+
'skip_no_bundle',
|
|
127
|
+
];
|
|
128
|
+
for (const key of trackedKeys) {
|
|
129
|
+
if (existing[key] !== desired[key]) {
|
|
130
|
+
changed.push(`${key}: ${JSON.stringify(existing[key])} -> ${JSON.stringify(desired[key])}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Retired build-only flag; a stale copy from an earlier version must not be re-emitted. Its
|
|
134
|
+
// presence counts as a change so the file is rewritten even when it is the only difference.
|
|
135
|
+
if ('assets_source_skip_mount_path' in existing) {
|
|
136
|
+
changed.push('assets_source_skip_mount_path: removed (retired)');
|
|
137
|
+
}
|
|
138
|
+
if (changed.length === 0) {
|
|
139
|
+
log.info('webflow.json output metadata is correct, skipping write');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
log.info(`webflow.json output metadata changed: ${changed.join(', ')}`);
|
|
143
|
+
// Apply desired values, preserving any other keys (e.g. assets_path_prefix).
|
|
144
|
+
Object.assign(existing, desired);
|
|
145
|
+
delete existing.assets_source_skip_mount_path;
|
|
146
|
+
}
|
|
147
|
+
// Self-check: a producer should never write a file that fails the deploy
|
|
148
|
+
// contract. Throw here so a builder bug surfaces during build, not deploy.
|
|
149
|
+
try {
|
|
150
|
+
(0, cosmic_deploy_contract_1.validateForDeploy)(webflowJson);
|
|
151
|
+
log.info('✅ producer self-check passed (cosmic-deploy-contract v1)');
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
if (e instanceof cosmic_deploy_contract_1.ContractError && e.issues.length > 0) {
|
|
155
|
+
log.error('⛔ producer self-check FAILED (cosmic-deploy-contract v1):');
|
|
156
|
+
for (const issue of e.issues) {
|
|
157
|
+
const issuePath = issue.path.length > 0 ? issue.path.join('.') : '<root>';
|
|
158
|
+
log.error(` ${issuePath}: ${issue.message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
throw e;
|
|
162
|
+
}
|
|
163
|
+
if (changed.length > 0) {
|
|
164
|
+
log.info(`Writing webflow.json with framework: ${frameworkName}`);
|
|
165
|
+
fs.writeFileSync(webflowJsonPath, JSON.stringify(webflowJson, null, 2));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=create-webflow-json.js.map
|