@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.
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/bindings.d.ts +185 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +120 -0
- package/dist/bindings.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 +53 -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 +24 -0
- package/dist/create-webflow-json.d.ts.map +1 -0
- package/dist/create-webflow-json.js +170 -0
- package/dist/create-webflow-json.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/ensure-fixed-cloudflare-adapter.d.ts +36 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js +94 -0
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts +2 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.js +97 -0
- package/dist/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.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 +259 -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 +286 -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 +283 -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/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 +103 -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 +112 -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 +113 -0
- package/dist/frameworks/astro/templates/v7/wrangler.json +9 -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 +93 -0
- package/dist/frameworks/static/index.d.ts.map +1 -0
- package/dist/frameworks/static/index.js +352 -0
- package/dist/frameworks/static/index.js.map +1 -0
- package/dist/frameworks/static/templates/wrangler.json +7 -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 +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +8 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +263 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/ports/command-runner.d.ts +60 -0
- package/dist/ports/command-runner.d.ts.map +1 -0
- package/dist/ports/command-runner.js +116 -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/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 +66 -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 +192 -0
- package/dist/wrangler.d.ts.map +1 -0
- package/dist/wrangler.js +246 -0
- package/dist/wrangler.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,283 @@
|
|
|
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.Astro7Builder = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Astro 7 Framework Builder
|
|
39
|
+
*
|
|
40
|
+
* Builds Astro 7.x projects for Cloudflare Workers deployment.
|
|
41
|
+
*
|
|
42
|
+
* - Node.js 22.12.0+ required
|
|
43
|
+
* - @astrojs/cloudflare@^14.0.0 (uses @cloudflare/vite-plugin)
|
|
44
|
+
* - Vite 8 required
|
|
45
|
+
* - Build output: dist/server/entry.mjs (worker) + dist/client/ (static assets)
|
|
46
|
+
* - Uses workerd natively for dev (no platformProxy)
|
|
47
|
+
* - wrangler.json main: "@astrojs/cloudflare/entrypoints/server"
|
|
48
|
+
*
|
|
49
|
+
* The Cloudflare output shape is unchanged from Astro 6, so the deploy metadata
|
|
50
|
+
* matches astro6.ts. The differences are dependency majors (adapter, React
|
|
51
|
+
* integration) and the underlying Vite 8 / Astro 7 toolchain.
|
|
52
|
+
*/
|
|
53
|
+
const path = __importStar(require("node:path"));
|
|
54
|
+
const fs = __importStar(require("node:fs"));
|
|
55
|
+
const base_1 = require("../base");
|
|
56
|
+
const errors_1 = require("../errors");
|
|
57
|
+
const ensure_fixed_cloudflare_adapter_1 = require("./adapter-patches/ensure-fixed-cloudflare-adapter");
|
|
58
|
+
const utils_1 = require("../../utils");
|
|
59
|
+
/** Base path for Astro 7 templates. */
|
|
60
|
+
const TEMPLATE_BASE = path.join(__dirname, 'templates', 'v7');
|
|
61
|
+
const SHARED_TEMPLATE_BASE = path.join(__dirname, 'templates');
|
|
62
|
+
class Astro7Builder extends base_1.FrameworkBuilder {
|
|
63
|
+
static frameworkName = 'astro';
|
|
64
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
65
|
+
// FRAMEWORK INFO
|
|
66
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
67
|
+
get info() {
|
|
68
|
+
return {
|
|
69
|
+
name: 'astro',
|
|
70
|
+
version: '7.x',
|
|
71
|
+
displayName: 'Astro 7',
|
|
72
|
+
packageName: 'astro',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
getFrameworkVersion() {
|
|
76
|
+
return this.resolveFrameworkVersion('astro');
|
|
77
|
+
}
|
|
78
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
79
|
+
// DETECTION
|
|
80
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
81
|
+
/**
|
|
82
|
+
* Detect if this is an Astro 7 project.
|
|
83
|
+
*
|
|
84
|
+
* Version is always determined from package.json, not webflow.json. The
|
|
85
|
+
* registry checks Astro7Builder before Astro6Builder, so Astro 7+ projects
|
|
86
|
+
* are detected here first.
|
|
87
|
+
*/
|
|
88
|
+
static detect(packageJson, webflowJson) {
|
|
89
|
+
const specifiedFramework = webflowJson?.cloud?.framework;
|
|
90
|
+
// If webflow.json specifies a DIFFERENT framework, don't match.
|
|
91
|
+
if (specifiedFramework && specifiedFramework !== 'astro') {
|
|
92
|
+
return { detected: false };
|
|
93
|
+
}
|
|
94
|
+
const astroVersion = packageJson.dependencies?.astro || packageJson.devDependencies?.astro;
|
|
95
|
+
if (!astroVersion) {
|
|
96
|
+
return { detected: false };
|
|
97
|
+
}
|
|
98
|
+
const majorVersion = (0, utils_1.getMajorVersion)(astroVersion);
|
|
99
|
+
if (majorVersion !== null && majorVersion >= 7) {
|
|
100
|
+
return { detected: true, reason: `Found astro@${astroVersion} (Astro ${majorVersion}.x)` };
|
|
101
|
+
}
|
|
102
|
+
return { detected: false };
|
|
103
|
+
}
|
|
104
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
105
|
+
// VALIDATION
|
|
106
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
107
|
+
async validate() {
|
|
108
|
+
const { log, packageJson } = this.ctx;
|
|
109
|
+
// Astro 7 requires Node 22+.
|
|
110
|
+
const nodeReq = this.getNodeVersionRequirement();
|
|
111
|
+
if (nodeReq) {
|
|
112
|
+
(0, utils_1.validateNodeVersion)(log, nodeReq, this.info.displayName);
|
|
113
|
+
}
|
|
114
|
+
const astroVersion = packageJson.dependencies?.astro || packageJson.devDependencies?.astro;
|
|
115
|
+
if (!astroVersion) {
|
|
116
|
+
throw new errors_1.FrameworkValidationError('Astro is not installed in this project.', {
|
|
117
|
+
remediation: 'Install Astro by running: npm install astro@^7.0.0',
|
|
118
|
+
documentationUrl: 'https://docs.astro.build/en/install/',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Reject "latest" explicitly.
|
|
122
|
+
if (astroVersion === 'latest') {
|
|
123
|
+
throw new errors_1.FrameworkValidationError('Astro version "latest" is not supported by Webflow Cloud.', { remediation: 'Please specify a version, e.g.: npm install astro@^7.0.0' });
|
|
124
|
+
}
|
|
125
|
+
const majorVersion = (0, utils_1.getMajorVersion)(astroVersion);
|
|
126
|
+
if (majorVersion !== null && majorVersion < 7) {
|
|
127
|
+
throw new errors_1.FrameworkValidationError(`Astro ${majorVersion}.x detected but Astro7Builder was selected. This is likely a configuration error.`, {
|
|
128
|
+
remediation: 'Use Astro6Builder for Astro 6.x projects, or upgrade: npm install astro@^7.0.0',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
log.info(`Validated Astro 7 project: astro@${astroVersion}`);
|
|
132
|
+
}
|
|
133
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
134
|
+
// DEPENDENCIES
|
|
135
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
136
|
+
getCloudflareAdapter() {
|
|
137
|
+
return {
|
|
138
|
+
name: '@astrojs/cloudflare',
|
|
139
|
+
version: '^14.0.0',
|
|
140
|
+
peerDependencies: ['@cloudflare/vite-plugin'],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
getRequiredIntegrations() {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
name: '@astrojs/react',
|
|
147
|
+
version: '^6.0.0', // Astro 7 compatible version
|
|
148
|
+
reason: 'Required for Webflow React components',
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
async installDependencies() {
|
|
153
|
+
const { log, cwd, runCommand } = this.ctx;
|
|
154
|
+
// Every 14.x is past the base-path fix (13.3.1), so in practice this only installs the
|
|
155
|
+
// adapter when absent; a sub-14 adapter would be caught here as warn-only (crossing a
|
|
156
|
+
// major), but `@astrojs/cloudflare@13.x` peers on `astro@^6` and can't install against
|
|
157
|
+
// astro@7 anyway. Shared with Astro 6 so the two paths can't silently diverge.
|
|
158
|
+
const adapter = this.getCloudflareAdapter();
|
|
159
|
+
await (0, ensure_fixed_cloudflare_adapter_1.ensureFixedCloudflareAdapter)({
|
|
160
|
+
log,
|
|
161
|
+
runCommand,
|
|
162
|
+
cwd,
|
|
163
|
+
adapterName: adapter.name,
|
|
164
|
+
installVersion: adapter.version,
|
|
165
|
+
fixedFloor: '14.0.0',
|
|
166
|
+
declaredVersion: this.getDependencyVersion(adapter.name),
|
|
167
|
+
});
|
|
168
|
+
// Install peer dependencies.
|
|
169
|
+
if (adapter.peerDependencies) {
|
|
170
|
+
for (const peer of adapter.peerDependencies) {
|
|
171
|
+
if (!this.hasDependency(peer)) {
|
|
172
|
+
log.warn(`Installing ${peer} (peer dependency of ${adapter.name})...`);
|
|
173
|
+
await (0, utils_1.npm)({ log, runCommand, cwd, args: ['install', '--save', peer] });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const integration of this.getRequiredIntegrations()) {
|
|
178
|
+
if (!this.hasDependency(integration.name)) {
|
|
179
|
+
log.warn(`Installing ${integration.name}@${integration.version} (${integration.reason})...`);
|
|
180
|
+
await (0, utils_1.npm)({
|
|
181
|
+
log,
|
|
182
|
+
runCommand,
|
|
183
|
+
cwd,
|
|
184
|
+
args: ['install', '--save', `${integration.name}@${integration.version}`],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
190
|
+
// CONFIGURATION
|
|
191
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
192
|
+
getWebflowLoader() {
|
|
193
|
+
return {
|
|
194
|
+
templatePath: path.join(TEMPLATE_BASE, 'webflow-loader.ts'),
|
|
195
|
+
destinationName: 'webflow-loader.ts',
|
|
196
|
+
configPath: './webflow-loader.ts',
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
getUserConfigPatterns() {
|
|
200
|
+
return ['astro.config.mjs', 'astro.config.cjs', 'astro.config.js', 'astro.config.ts'];
|
|
201
|
+
}
|
|
202
|
+
getWranglerTemplatePath() {
|
|
203
|
+
return path.join(TEMPLATE_BASE, 'wrangler.json');
|
|
204
|
+
}
|
|
205
|
+
getAdditionalConfigFiles() {
|
|
206
|
+
const loader = this.getWebflowLoader();
|
|
207
|
+
return [loader.templatePath, path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts')];
|
|
208
|
+
}
|
|
209
|
+
async prepareConfig() {
|
|
210
|
+
const { log, cwd, userEnv } = this.ctx;
|
|
211
|
+
// Rename user's astro.config.* to clouduser.astro.config.*; if there is no
|
|
212
|
+
// user config, write an empty stub so the generated template's static
|
|
213
|
+
// import always resolves.
|
|
214
|
+
const renamedUserConfig = (0, utils_1.renameUserConfig)(log, cwd, 'astro.config', [
|
|
215
|
+
'mjs',
|
|
216
|
+
'cjs',
|
|
217
|
+
'js',
|
|
218
|
+
'ts',
|
|
219
|
+
]);
|
|
220
|
+
if (renamedUserConfig === null) {
|
|
221
|
+
log.info('no user astro.config.{mjs,cjs,js,ts} found — writing empty clouduser.astro.config.mjs stub');
|
|
222
|
+
fs.writeFileSync(path.join(cwd, 'clouduser.astro.config.mjs'), 'export default {};\n');
|
|
223
|
+
}
|
|
224
|
+
// Copy the merge-logic library (real source, not a template).
|
|
225
|
+
const webflowConfigSrc = path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts');
|
|
226
|
+
if ((0, utils_1.fileExists)(webflowConfigSrc)) {
|
|
227
|
+
log.info('Copying astro.config.webflow.ts...');
|
|
228
|
+
fs.copyFileSync(webflowConfigSrc, path.join(cwd, 'astro.config.webflow.ts'));
|
|
229
|
+
}
|
|
230
|
+
// Render the single astro.config.mjs template.
|
|
231
|
+
const templatePath = path.join(TEMPLATE_BASE, 'astro.config.mjs.template');
|
|
232
|
+
const destPath = path.join(cwd, 'astro.config.mjs');
|
|
233
|
+
log.info('Generating astro.config.mjs from template (Astro 7)...');
|
|
234
|
+
await (0, utils_1.envsubst)(log, templatePath, destPath, {
|
|
235
|
+
...process.env,
|
|
236
|
+
...userEnv,
|
|
237
|
+
});
|
|
238
|
+
// Copy webflow-loader.ts.
|
|
239
|
+
const loader = this.getWebflowLoader();
|
|
240
|
+
if ((0, utils_1.fileExists)(loader.templatePath)) {
|
|
241
|
+
log.info(`Copying ${loader.destinationName}...`);
|
|
242
|
+
fs.copyFileSync(loader.templatePath, path.join(cwd, loader.destinationName));
|
|
243
|
+
}
|
|
244
|
+
// wrangler.json is owned exclusively by `handleWranglerJson`, which runs
|
|
245
|
+
// before this hook and is the only function permitted to write
|
|
246
|
+
// /wrangler.json.
|
|
247
|
+
}
|
|
248
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
249
|
+
// BUILD
|
|
250
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
251
|
+
getBuildCommand() {
|
|
252
|
+
return 'astro build';
|
|
253
|
+
}
|
|
254
|
+
getNodeVersionRequirement() {
|
|
255
|
+
return {
|
|
256
|
+
minimum: '22.12.0',
|
|
257
|
+
severity: 'error', // Astro 7 will definitely fail without Node 22+
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
261
|
+
// OUTPUT
|
|
262
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
263
|
+
static getOutputDeployMetadata() {
|
|
264
|
+
return {
|
|
265
|
+
staticAssetsPath: 'dist/client',
|
|
266
|
+
// No exclude needed — Astro 7 has clean separation.
|
|
267
|
+
workerEntryPath: 'dist/server/entry.mjs',
|
|
268
|
+
wranglerMainOverride: '@astrojs/cloudflare/entrypoints/server',
|
|
269
|
+
deploymentType: 'ssr',
|
|
270
|
+
usesAssetsBinding: true,
|
|
271
|
+
// Astro 7 outputs multiple files (entry.mjs + chunks/*) that need bundling.
|
|
272
|
+
skipNoBundle: true,
|
|
273
|
+
// A fixed @astrojs/cloudflare nests the client tree under dist/client/<mount>/
|
|
274
|
+
// (base = mountPath), so the copy descends into that mount dir via
|
|
275
|
+
// stripCloudflareBaseNesting instead of the blind Astro 5 / Next.js append.
|
|
276
|
+
assetsSourceSkipMountPath: true,
|
|
277
|
+
// After wrangler dry-run, the bundled output is ./entry.mjs
|
|
278
|
+
dryRunEntryPath: './entry.mjs',
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
exports.Astro7Builder = Astro7Builder;
|
|
283
|
+
//# sourceMappingURL=astro7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro7.js","sourceRoot":"","sources":["../../../src/frameworks/astro/astro7.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,gDAAkC;AAClC,4CAA8B;AAE9B,kCAA2C;AAY3C,sCAAqD;AACrD,uGAAiG;AACjG,uCAOqB;AAErB,uCAAuC;AACvC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,W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AC;YACjD,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/E,CAAC;QAED,yEAAyE;QACzE,+DAA+D;QAC/D,kBAAkB;IACpB,CAAC;IAED,8EAA8E;IAC9E,QAAQ;IACR,8EAA8E;IAE9E,eAAe;QACb,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,yBAAyB;QACvB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,OAAO,EAAE,gDAAgD;SACpE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,SAAS;IACT,8EAA8E;IAE9E,MAAM,CAAU,uBAAuB;QACrC,OAAO;YACL,gBAAgB,EAAE,aAAa;YAC/B,oDAAoD;YACpD,eAAe,EAAE,uBAAuB;YACxC,oBAAoB,EAAE,wCAAwC;YAC9D,cAAc,EAAE,KAAK;YACrB,iBAAiB,EAAE,IAAI;YACvB,4EAA4E;YAC5E,YAAY,EAAE,IAAI;YAClB,+EAA+E;YAC/E,mEAAmE;YACnE,4EAA4E;YAC5E,yBAAyB,EAAE,IAAI;YAC/B,4DAA4D;YAC5D,eAAe,EAAE,aAAa;SAC/B,CAAC;IACJ,CAAC;;AAjRH,sCAkRC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro Framework Builders.
|
|
3
|
+
*
|
|
4
|
+
* Exports Astro5/6/7 builders for use by the registry. Version detection is
|
|
5
|
+
* handled by each builder's static detect() method.
|
|
6
|
+
*/
|
|
7
|
+
export { Astro5Builder } from './astro5';
|
|
8
|
+
export { Astro6Builder } from './astro6';
|
|
9
|
+
export { Astro7Builder } from './astro7';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/astro/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Astro7Builder = exports.Astro6Builder = exports.Astro5Builder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Astro Framework Builders.
|
|
6
|
+
*
|
|
7
|
+
* Exports Astro5/6/7 builders for use by the registry. Version detection is
|
|
8
|
+
* handled by each builder's static detect() method.
|
|
9
|
+
*/
|
|
10
|
+
var astro5_1 = require("./astro5");
|
|
11
|
+
Object.defineProperty(exports, "Astro5Builder", { enumerable: true, get: function () { return astro5_1.Astro5Builder; } });
|
|
12
|
+
var astro6_1 = require("./astro6");
|
|
13
|
+
Object.defineProperty(exports, "Astro6Builder", { enumerable: true, get: function () { return astro6_1.Astro6Builder; } });
|
|
14
|
+
var astro7_1 = require("./astro7");
|
|
15
|
+
Object.defineProperty(exports, "Astro7Builder", { enumerable: true, get: function () { return astro7_1.Astro7Builder; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/astro/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AACtB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AACtB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Merge logic for the generated astro.config.mjs (shared between Astro 5 + 6).
|
|
2
|
+
// Copied verbatim into the user's project; types are local to avoid Astro
|
|
3
|
+
// cross-version drift.
|
|
4
|
+
|
|
5
|
+
type AstroIntegration = { name?: string; [key: string]: any };
|
|
6
|
+
type AstroUserConfig = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
export type WebflowOverridesOptions = {
|
|
9
|
+
mountPath: string;
|
|
10
|
+
deployUrl: string;
|
|
11
|
+
/** The result of `cloudflare({ ... })` from `@astrojs/cloudflare`. */
|
|
12
|
+
adapter: any;
|
|
13
|
+
/** The result of `react()` from `@astrojs/react`. Auto-added if the user hasn't already added `@astrojs/react`. */
|
|
14
|
+
reactIntegration: AstroIntegration;
|
|
15
|
+
/** Extra Vite resolve.alias to inject (e.g. react-dom/server -> react-dom/server.edge for React 19+ in prod). Pass `undefined` to skip. */
|
|
16
|
+
reactDomServerAlias: Record<string, string> | undefined;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Wrap the user's Astro config with Webflow Cloud's required overrides.
|
|
21
|
+
* `userExport` is always provided — `{}` when the user ships no astro.config.*.
|
|
22
|
+
*
|
|
23
|
+
* Top-level keys in the override block REPLACE the user's — our adapter / base /
|
|
24
|
+
* output need to win.
|
|
25
|
+
*/
|
|
26
|
+
export function withWebflowOverrides(
|
|
27
|
+
userExport: AstroUserConfig,
|
|
28
|
+
opts: WebflowOverridesOptions,
|
|
29
|
+
): AstroUserConfig {
|
|
30
|
+
const userIntegrations: AstroIntegration[] = userExport.integrations || [];
|
|
31
|
+
const hasReact = userIntegrations.some((i) => i?.name === '@astrojs/react');
|
|
32
|
+
const integrations = hasReact ? userIntegrations : [...userIntegrations, opts.reactIntegration];
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...userExport,
|
|
36
|
+
base: opts.mountPath,
|
|
37
|
+
output: 'server',
|
|
38
|
+
adapter: opts.adapter,
|
|
39
|
+
integrations,
|
|
40
|
+
vite: {
|
|
41
|
+
...userExport.vite,
|
|
42
|
+
resolve: {
|
|
43
|
+
...userExport.vite?.resolve,
|
|
44
|
+
alias: opts.reactDomServerAlias,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
build: {
|
|
48
|
+
assetsPrefix: opts.deployUrl + (opts.mountPath === '/' ? '' : opts.mountPath),
|
|
49
|
+
},
|
|
50
|
+
image: {
|
|
51
|
+
...userExport.image,
|
|
52
|
+
service: {
|
|
53
|
+
entrypoint: './webflow-loader.ts',
|
|
54
|
+
config: {
|
|
55
|
+
deployUrl: opts.deployUrl,
|
|
56
|
+
mountPath: opts.mountPath,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated by the Webflow Cloud builder. Merge logic lives in ./astro.config.webflow.ts.
|
|
2
|
+
import { defineConfig } from 'astro/config';
|
|
3
|
+
import cloudflare from '@astrojs/cloudflare';
|
|
4
|
+
import react from '@astrojs/react';
|
|
5
|
+
import userConfig from './clouduser.astro.config';
|
|
6
|
+
import { withWebflowOverrides } from './astro.config.webflow';
|
|
7
|
+
|
|
8
|
+
export default defineConfig(
|
|
9
|
+
withWebflowOverrides(userConfig, {
|
|
10
|
+
mountPath: '${COSMIC_MOUNT_PATH}',
|
|
11
|
+
deployUrl: '${COSMIC_DEPLOY_URL}',
|
|
12
|
+
adapter: cloudflare({
|
|
13
|
+
imageService: 'custom',
|
|
14
|
+
platformProxy: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
reactIntegration: react(),
|
|
19
|
+
// Use react-dom/server.edge instead of react-dom/server.browser for React 19.
|
|
20
|
+
// Without this, MessageChannel from node:worker_threads needs to be polyfilled.
|
|
21
|
+
reactDomServerAlias: import.meta.env.PROD
|
|
22
|
+
? { 'react-dom/server': 'react-dom/server.edge' }
|
|
23
|
+
: undefined,
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
|
|
2
|
+
|
|
3
|
+
function normalizeSrc(src: string, deployUrl?: string, mountPath?: string) {
|
|
4
|
+
// For local assets, include the mount path but not the deploy url, and remove the leading slash
|
|
5
|
+
if (deployUrl && src.startsWith(deployUrl)) {
|
|
6
|
+
return `${src.slice(deployUrl.length)}`.slice(1);
|
|
7
|
+
} else if (mountPath && src.startsWith(mountPath)) {
|
|
8
|
+
return src.slice(1);
|
|
9
|
+
} else if (src.startsWith('/')) {
|
|
10
|
+
return `${mountPath}${src}`.slice(1);
|
|
11
|
+
}
|
|
12
|
+
return src;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Default implementation copied from Astro's baseService
|
|
16
|
+
function getTargetDimensions(options: ImageTransform) {
|
|
17
|
+
let targetWidth = options.width;
|
|
18
|
+
let targetHeight = options.height;
|
|
19
|
+
|
|
20
|
+
// For ESM imported images, calculate missing dimensions based on aspect ratio
|
|
21
|
+
if (typeof options.src === 'object' && 'width' in options.src && 'height' in options.src) {
|
|
22
|
+
const aspectRatio = options.src.width / options.src.height;
|
|
23
|
+
if (targetHeight && !targetWidth) {
|
|
24
|
+
targetWidth = Math.round(targetHeight * aspectRatio);
|
|
25
|
+
} else if (targetWidth && !targetHeight) {
|
|
26
|
+
targetHeight = Math.round(targetWidth / aspectRatio);
|
|
27
|
+
} else if (!targetWidth && !targetHeight) {
|
|
28
|
+
targetWidth = options.src.width;
|
|
29
|
+
targetHeight = options.src.height;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
targetWidth,
|
|
35
|
+
targetHeight,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cloudflareLoader: ExternalImageService = {
|
|
40
|
+
getURL(options: ImageTransform, imageConfig: AstroConfig['image']) {
|
|
41
|
+
const normalizedSrc = normalizeSrc(
|
|
42
|
+
typeof options.src === 'object' ? options.src.src : options.src,
|
|
43
|
+
imageConfig.service.config.deployUrl,
|
|
44
|
+
imageConfig.service.config.mountPath,
|
|
45
|
+
);
|
|
46
|
+
// Our cloudflare zone doesn't allow optimizing external images for security reasons, so just load the original image
|
|
47
|
+
// For now, also skip optimization for images hosted on regular webflow sites (cdn.website-files.com)
|
|
48
|
+
// because optimizing them would result in two bandwidth charges: one from the website-files zone (for the full image)
|
|
49
|
+
// and one from the cosmic.webflow.services zone (for the resized image)
|
|
50
|
+
if (normalizedSrc.startsWith('http://') || normalizedSrc.startsWith('https://')) {
|
|
51
|
+
return normalizedSrc;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const supportedOptions = ['width', 'height', 'quality', 'format'];
|
|
55
|
+
const params = [];
|
|
56
|
+
for (const option of supportedOptions) {
|
|
57
|
+
if (options[option]) {
|
|
58
|
+
params.push(`${option}=${options[option]}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const workerUrl = imageConfig.service.config.deployUrl;
|
|
63
|
+
// Skip resizing svgs, since it doesn't do anything
|
|
64
|
+
const isSvg =
|
|
65
|
+
typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
|
|
66
|
+
if (isSvg || params.length === 0) {
|
|
67
|
+
return `${workerUrl}/${normalizedSrc}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const paramsString = params.join(',');
|
|
71
|
+
return `${workerUrl}/cdn-cgi/image/${paramsString}/${normalizedSrc}`;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// Default implementation copied from Astro's baseService
|
|
75
|
+
getHTMLAttributes(options: ImageTransform) {
|
|
76
|
+
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
|
77
|
+
const {
|
|
78
|
+
src,
|
|
79
|
+
width,
|
|
80
|
+
height,
|
|
81
|
+
format,
|
|
82
|
+
quality,
|
|
83
|
+
densities,
|
|
84
|
+
widths,
|
|
85
|
+
formats,
|
|
86
|
+
layout,
|
|
87
|
+
priority,
|
|
88
|
+
fit,
|
|
89
|
+
position,
|
|
90
|
+
...attributes
|
|
91
|
+
} = options;
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
...attributes,
|
|
95
|
+
width: targetWidth,
|
|
96
|
+
height: targetHeight,
|
|
97
|
+
loading: attributes.loading ?? 'lazy',
|
|
98
|
+
decoding: attributes.decoding ?? 'async',
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default cloudflareLoader;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Generated by the Webflow Cloud builder. Merge logic lives in ./astro.config.webflow.ts.
|
|
2
|
+
import { defineConfig } from 'astro/config';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import cloudflare from '@astrojs/cloudflare';
|
|
5
|
+
import react from '@astrojs/react';
|
|
6
|
+
import userConfig from './clouduser.astro.config';
|
|
7
|
+
import { withWebflowOverrides } from './astro.config.webflow';
|
|
8
|
+
|
|
9
|
+
// Detect React 19+ so we know whether to alias react-dom/server -> .edge.
|
|
10
|
+
let isReact19 = false;
|
|
11
|
+
try {
|
|
12
|
+
const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
|
|
13
|
+
const reactVersion = pkg.dependencies?.react || pkg.devDependencies?.react || '';
|
|
14
|
+
// Match versions like "19", "^19", "~19", "19.0.0", "^19.0.0", etc.
|
|
15
|
+
isReact19 = /(?:^|[^\d])19(?:\.|$)/.test(reactVersion);
|
|
16
|
+
} catch {
|
|
17
|
+
// Could not read package.json, assume not React 19.
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default defineConfig(
|
|
21
|
+
withWebflowOverrides(userConfig, {
|
|
22
|
+
mountPath: '${COSMIC_MOUNT_PATH}',
|
|
23
|
+
deployUrl: '${COSMIC_DEPLOY_URL}',
|
|
24
|
+
adapter: cloudflare({
|
|
25
|
+
imageService: 'custom',
|
|
26
|
+
// Note: platformProxy removed in Astro 6+ — workerd runs natively via @cloudflare/vite-plugin.
|
|
27
|
+
}),
|
|
28
|
+
reactIntegration: react(),
|
|
29
|
+
// Only React 19+ has react-dom/server.edge. React 18 has only .browser, which doesn't run in edge runtimes.
|
|
30
|
+
reactDomServerAlias:
|
|
31
|
+
import.meta.env.PROD && isReact19
|
|
32
|
+
? { 'react-dom/server': 'react-dom/server.edge' }
|
|
33
|
+
: undefined,
|
|
34
|
+
}),
|
|
35
|
+
);
|