@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,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webflow-json.js","sourceRoot":"","sources":["../../src/config/webflow-json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,0CA6BC;AAvFD,4CAA8B;AAC9B,gDAAkC;AAElC,oDAAsC;AA+CtC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,GAAW,EACX,GAAW,EACX,IAAI,GAAG,cAAc;IAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACtD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,GAAG,EAAE,KAAK,CAAC,uCAAuC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC3F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,GAAG,EAAE,KAAK,CAAC,GAAG,QAAQ,uBAAuB,CAAC,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,24 @@
|
|
|
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, plus optional build-only fields (`assets_source_skip_mount_path`)
|
|
10
|
+
* that the contract tolerates via passthrough.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deriveCloudFields(frameworkName: string, builder: FrameworkBuilder | BuilderClass): DeployContractV1 & {
|
|
13
|
+
assets_source_skip_mount_path?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Create or update webflow.json with the detected framework and build output
|
|
17
|
+
* info.
|
|
18
|
+
*
|
|
19
|
+
* Accepts either a FrameworkBuilder instance (build phase) or a BuilderClass
|
|
20
|
+
* (no BuildContext available). When the existing webflow.json already matches
|
|
21
|
+
* the canonical metadata, no write happens. Otherwise the diff is logged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createWebflowJson(log: Logger, cwd: string, frameworkName: string, builder: FrameworkBuilder | BuilderClass): void;
|
|
24
|
+
//# 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;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GAAG,YAAY,GACvC,gBAAgB,GAAG;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,CA4ChE;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,CAwEN"}
|
|
@@ -0,0 +1,170 @@
|
|
|
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, plus optional build-only fields (`assets_source_skip_mount_path`)
|
|
55
|
+
* that the contract tolerates via passthrough.
|
|
56
|
+
*/
|
|
57
|
+
function deriveCloudFields(frameworkName, builder) {
|
|
58
|
+
const output = typeof builder === 'function'
|
|
59
|
+
? builder.getOutputDeployMetadata()
|
|
60
|
+
: builder.getOutputDeployMetadata();
|
|
61
|
+
const cloud = {
|
|
62
|
+
contract_version: '1',
|
|
63
|
+
// Narrowed by the contract's Framework enum at the validateForDeploy
|
|
64
|
+
// self-check — if a builder returns an unrecognized name, the write fails fast.
|
|
65
|
+
framework: frameworkName,
|
|
66
|
+
deployment_type: output.deploymentType,
|
|
67
|
+
// Contract requires a boolean; normalize undefined to false.
|
|
68
|
+
skip_no_bundle: output.skipNoBundle === true,
|
|
69
|
+
};
|
|
70
|
+
// Assets-only apps (static, no framework) have no worker, so they carry no
|
|
71
|
+
// entrypoint_path — the contract allows it to be omitted. Every other
|
|
72
|
+
// deployment type has a worker entry: `dryRunEntryPath` points at the file
|
|
73
|
+
// produced by `wrangler deploy --dry-run` (Astro 5: ./index.js, Astro 6:
|
|
74
|
+
// ./entry.mjs, Next.js: ./worker.js), defaulting to ./index.js.
|
|
75
|
+
if (output.deploymentType !== 'static') {
|
|
76
|
+
cloud.entrypoint_path = output.dryRunEntryPath ?? './index.js';
|
|
77
|
+
}
|
|
78
|
+
// framework_version is optional under the contract. It's an instance-only
|
|
79
|
+
// capability (reads the user's package.json via the builder's ctx), so it's
|
|
80
|
+
// only available for the build-phase instance path — not the deploy-phase
|
|
81
|
+
// BuilderClass path. Omitted when unresolvable (e.g. `workspace:*`, `latest`).
|
|
82
|
+
// CLD-1785.
|
|
83
|
+
if (typeof builder !== 'function') {
|
|
84
|
+
const frameworkVersion = builder.getFrameworkVersion();
|
|
85
|
+
if (frameworkVersion) {
|
|
86
|
+
cloud.framework_version = frameworkVersion;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Build-only field, outside the deploy contract but written here so build-phase
|
|
90
|
+
// code can read a single source of truth.
|
|
91
|
+
if (output.assetsSourceSkipMountPath) {
|
|
92
|
+
cloud.assets_source_skip_mount_path = true;
|
|
93
|
+
}
|
|
94
|
+
return cloud;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create or update webflow.json with the detected framework and build output
|
|
98
|
+
* info.
|
|
99
|
+
*
|
|
100
|
+
* Accepts either a FrameworkBuilder instance (build phase) or a BuilderClass
|
|
101
|
+
* (no BuildContext available). When the existing webflow.json already matches
|
|
102
|
+
* the canonical metadata, no write happens. Otherwise the diff is logged.
|
|
103
|
+
*/
|
|
104
|
+
function createWebflowJson(log, cwd, frameworkName, builder) {
|
|
105
|
+
const webflowJsonPath = path.join(cwd, 'webflow.json');
|
|
106
|
+
// Start with existing webflow.json if present, or create new. If the file is
|
|
107
|
+
// malformed JSON we log and overwrite.
|
|
108
|
+
let webflowJson = { cloud: {} };
|
|
109
|
+
if (fs.existsSync(webflowJsonPath)) {
|
|
110
|
+
try {
|
|
111
|
+
const raw = fs.readFileSync(webflowJsonPath, 'utf8');
|
|
112
|
+
webflowJson = JSON.parse(raw);
|
|
113
|
+
if (!webflowJson.cloud || typeof webflowJson.cloud !== 'object') {
|
|
114
|
+
log.warn('webflow.json is missing "cloud" property, adding it');
|
|
115
|
+
webflowJson.cloud = {};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
log.warn(`Failed to parse existing webflow.json, overwriting: ${e}`);
|
|
120
|
+
webflowJson = { cloud: {} };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const existing = webflowJson.cloud;
|
|
124
|
+
const desired = deriveCloudFields(frameworkName, builder);
|
|
125
|
+
// Compare existing vs desired and log either a diff or a "no change" message.
|
|
126
|
+
const changed = [];
|
|
127
|
+
const trackedKeys = [
|
|
128
|
+
'contract_version',
|
|
129
|
+
'framework',
|
|
130
|
+
'framework_version',
|
|
131
|
+
'deployment_type',
|
|
132
|
+
'entrypoint_path',
|
|
133
|
+
'skip_no_bundle',
|
|
134
|
+
'assets_source_skip_mount_path',
|
|
135
|
+
];
|
|
136
|
+
for (const key of trackedKeys) {
|
|
137
|
+
if (existing[key] !== desired[key]) {
|
|
138
|
+
changed.push(`${key}: ${JSON.stringify(existing[key])} -> ${JSON.stringify(desired[key])}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (changed.length === 0) {
|
|
142
|
+
log.info('webflow.json output metadata is correct, skipping write');
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
log.info(`webflow.json output metadata changed: ${changed.join(', ')}`);
|
|
146
|
+
// Apply desired values, preserving any other keys (e.g. assets_path_prefix).
|
|
147
|
+
Object.assign(existing, desired);
|
|
148
|
+
}
|
|
149
|
+
// Self-check: a producer should never write a file that fails the deploy
|
|
150
|
+
// contract. Throw here so a builder bug surfaces during build, not deploy.
|
|
151
|
+
try {
|
|
152
|
+
(0, cosmic_deploy_contract_1.validateForDeploy)(webflowJson);
|
|
153
|
+
log.info('✅ producer self-check passed (cosmic-deploy-contract v1)');
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
if (e instanceof cosmic_deploy_contract_1.ContractError && e.issues.length > 0) {
|
|
157
|
+
log.error('⛔ producer self-check FAILED (cosmic-deploy-contract v1):');
|
|
158
|
+
for (const issue of e.issues) {
|
|
159
|
+
const issuePath = issue.path.length > 0 ? issue.path.join('.') : '<root>';
|
|
160
|
+
log.error(` ${issuePath}: ${issue.message}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
throw e;
|
|
164
|
+
}
|
|
165
|
+
if (changed.length > 0) {
|
|
166
|
+
log.info(`Writing webflow.json with framework: ${frameworkName}`);
|
|
167
|
+
fs.writeFileSync(webflowJsonPath, JSON.stringify(webflowJson, null, 2));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=create-webflow-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-webflow-json.js","sourceRoot":"","sources":["../src/create-webflow-json.ts"],"names":[],"mappings":"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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error hierarchy for the build engine. Hosts can branch on these to map build
|
|
3
|
+
* failures onto their own UX (CLI error formatting, deploy status, etc.).
|
|
4
|
+
* Framework-specific errors will be added here as the builders are extracted.
|
|
5
|
+
*/
|
|
6
|
+
export declare class WebflowAppError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/** Thrown by API surface that is declared but not yet implemented. */
|
|
10
|
+
export declare class NotImplementedError extends WebflowAppError {
|
|
11
|
+
constructor(what: string);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,sEAAsE;AACtE,qBAAa,mBAAoB,SAAQ,eAAe;gBAC1C,IAAI,EAAE,MAAM;CAGzB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotImplementedError = exports.WebflowAppError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Error hierarchy for the build engine. Hosts can branch on these to map build
|
|
6
|
+
* failures onto their own UX (CLI error formatting, deploy status, etc.).
|
|
7
|
+
* Framework-specific errors will be added here as the builders are extracted.
|
|
8
|
+
*/
|
|
9
|
+
class WebflowAppError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = new.target.name;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.WebflowAppError = WebflowAppError;
|
|
16
|
+
/** Thrown by API surface that is declared but not yet implemented. */
|
|
17
|
+
class NotImplementedError extends WebflowAppError {
|
|
18
|
+
constructor(what) {
|
|
19
|
+
super(`${what} is not implemented yet`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.NotImplementedError = NotImplementedError;
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,0CAKC;AAED,sEAAsE;AACtE,MAAa,mBAAoB,SAAQ,eAAe;IACtD,YAAY,IAAY;QACtB,KAAK,CAAC,GAAG,IAAI,yBAAyB,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,kDAIC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Logger, CommandRunner } from '../../../ports';
|
|
2
|
+
export interface EnsureFixedCloudflareAdapterParams {
|
|
3
|
+
log: Logger;
|
|
4
|
+
runCommand: CommandRunner;
|
|
5
|
+
cwd: string;
|
|
6
|
+
/** e.g. `@astrojs/cloudflare`. */
|
|
7
|
+
adapterName: string;
|
|
8
|
+
/** The version spec we install/force, e.g. `^13.3.1` (Astro 6) or `^14.0.0` (Astro 7). */
|
|
9
|
+
installVersion: string;
|
|
10
|
+
/** First release with the base-path fix for this Astro line, e.g. `13.3.1` / `14.0.0`. */
|
|
11
|
+
fixedFloor: string;
|
|
12
|
+
/** The user's declared adapter spec (from package.json), or undefined if absent. */
|
|
13
|
+
declaredVersion: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ensure the project resolves a `@astrojs/cloudflare` adapter at or above the release that
|
|
17
|
+
* fixes the base-path bug (withastro/astro#16276, fixed in 13.3.1). Companion to
|
|
18
|
+
* `stripCloudflareBaseNesting`: forcing a fixed adapter is what keeps the strip a rare
|
|
19
|
+
* backstop rather than load-bearing — a buggy 13.0.0–13.3.0 adapter emits the client tree
|
|
20
|
+
* WITHOUT the base prefix, so assets end up at the wrong URL no matter how we copy them.
|
|
21
|
+
*
|
|
22
|
+
* - Adapter absent → install our pinned version.
|
|
23
|
+
* - Declared below the fixed floor, SAME major (e.g. Astro 6's `13.x` → `13.3.1`, a
|
|
24
|
+
* non-breaking bump) → force-install the fixed version and warn.
|
|
25
|
+
* - Declared below the floor but reaching the fix would CROSS a major → warn only; forcing a
|
|
26
|
+
* major upgrade could break the build. (This is the only path Astro 7 can hit — a sub-14
|
|
27
|
+
* adapter — and in practice it can't install anyway: `13.x` peers on `astro@^6`.)
|
|
28
|
+
*
|
|
29
|
+
* Note: we key off the declared range floor (`semver.coerce`), not the resolved version.
|
|
30
|
+
* `npm install --save <pkg>@<range>` rewrites BOTH package.json and the lockfile entry for
|
|
31
|
+
* this package, so a forced bump overrides a lockfile-pinned buggy version. The trade-off: a
|
|
32
|
+
* wide range like `^13.0.0` that already resolves to a fixed `13.5.0` still coerces to
|
|
33
|
+
* `13.0.0`, triggering a harmless, unnecessary reinstall.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureFixedCloudflareAdapter(params: EnsureFixedCloudflareAdapterParams): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=ensure-fixed-cloudflare-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-fixed-cloudflare-adapter.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,kCAAkC;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,aAAa,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
|
@@ -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.ensureFixedCloudflareAdapter = ensureFixedCloudflareAdapter;
|
|
37
|
+
const semver = __importStar(require("semver"));
|
|
38
|
+
const utils_1 = require("../../../utils");
|
|
39
|
+
/**
|
|
40
|
+
* Ensure the project resolves a `@astrojs/cloudflare` adapter at or above the release that
|
|
41
|
+
* fixes the base-path bug (withastro/astro#16276, fixed in 13.3.1). Companion to
|
|
42
|
+
* `stripCloudflareBaseNesting`: forcing a fixed adapter is what keeps the strip a rare
|
|
43
|
+
* backstop rather than load-bearing — a buggy 13.0.0–13.3.0 adapter emits the client tree
|
|
44
|
+
* WITHOUT the base prefix, so assets end up at the wrong URL no matter how we copy them.
|
|
45
|
+
*
|
|
46
|
+
* - Adapter absent → install our pinned version.
|
|
47
|
+
* - Declared below the fixed floor, SAME major (e.g. Astro 6's `13.x` → `13.3.1`, a
|
|
48
|
+
* non-breaking bump) → force-install the fixed version and warn.
|
|
49
|
+
* - Declared below the floor but reaching the fix would CROSS a major → warn only; forcing a
|
|
50
|
+
* major upgrade could break the build. (This is the only path Astro 7 can hit — a sub-14
|
|
51
|
+
* adapter — and in practice it can't install anyway: `13.x` peers on `astro@^6`.)
|
|
52
|
+
*
|
|
53
|
+
* Note: we key off the declared range floor (`semver.coerce`), not the resolved version.
|
|
54
|
+
* `npm install --save <pkg>@<range>` rewrites BOTH package.json and the lockfile entry for
|
|
55
|
+
* this package, so a forced bump overrides a lockfile-pinned buggy version. The trade-off: a
|
|
56
|
+
* wide range like `^13.0.0` that already resolves to a fixed `13.5.0` still coerces to
|
|
57
|
+
* `13.0.0`, triggering a harmless, unnecessary reinstall.
|
|
58
|
+
*/
|
|
59
|
+
async function ensureFixedCloudflareAdapter(params) {
|
|
60
|
+
const { log, runCommand, cwd, adapterName, installVersion, fixedFloor, declaredVersion } = params;
|
|
61
|
+
if (!declaredVersion) {
|
|
62
|
+
log.warn(`Installing ${adapterName}@${installVersion} (required for Cloudflare deployment)...`);
|
|
63
|
+
await (0, utils_1.npm)({
|
|
64
|
+
log,
|
|
65
|
+
runCommand,
|
|
66
|
+
cwd,
|
|
67
|
+
args: ['install', '--save', `${adapterName}@${installVersion}`],
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const resolved = semver.coerce(declaredVersion);
|
|
72
|
+
if (!resolved || !semver.lt(resolved, fixedFloor)) {
|
|
73
|
+
// Already fixed (or an unparseable spec we leave alone).
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const floorMajor = semver.coerce(fixedFloor)?.major;
|
|
77
|
+
if (resolved.major === floorMajor) {
|
|
78
|
+
log.warn(`Detected ${adapterName}@${declaredVersion}, which has a known base-path bug ` +
|
|
79
|
+
`(withastro/astro#16276) that breaks static assets on mounted apps. ` +
|
|
80
|
+
`Upgrading to ${installVersion}.`);
|
|
81
|
+
await (0, utils_1.npm)({
|
|
82
|
+
log,
|
|
83
|
+
runCommand,
|
|
84
|
+
cwd,
|
|
85
|
+
args: ['install', '--save', `${adapterName}@${installVersion}`],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
log.warn(`${adapterName}@${declaredVersion} predates the base-path fix in ${fixedFloor} and ` +
|
|
90
|
+
`upgrading crosses a major version. Please upgrade to ${adapterName}@${installVersion} ` +
|
|
91
|
+
`manually to avoid broken asset serving on mounted apps.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=ensure-fixed-cloudflare-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-fixed-cloudflare-adapter.js","sourceRoot":"","sources":["../../../../src/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,oEA0CC;AAjFD,+CAAiC;AAGjC,0CAAqC;AAgBrC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,4BAA4B,CAChD,MAA0C;IAE1C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAElG,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,cAAc,WAAW,IAAI,cAAc,0CAA0C,CAAC,CAAC;QAChG,MAAM,IAAA,WAAG,EAAC;YACR,GAAG;YACH,UAAU;YACV,GAAG;YACH,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,WAAW,IAAI,cAAc,EAAE,CAAC;SAChE,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;QAClD,yDAAyD;QACzD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IACpD,IAAI,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAClC,GAAG,CAAC,IAAI,CACN,YAAY,WAAW,IAAI,eAAe,oCAAoC;YAC5E,qEAAqE;YACrE,gBAAgB,cAAc,GAAG,CACpC,CAAC;QACF,MAAM,IAAA,WAAG,EAAC;YACR,GAAG;YACH,UAAU;YACV,GAAG;YACH,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,WAAW,IAAI,cAAc,EAAE,CAAC;SAChE,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CACN,GAAG,WAAW,IAAI,eAAe,kCAAkC,UAAU,OAAO;YAClF,wDAAwD,WAAW,IAAI,cAAc,GAAG;YACxF,yDAAyD,CAC5D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-cloudflare-base-nesting.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.ts"],"names":[],"mappings":"AA6CA,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,MAAM,CAkBR"}
|
|
@@ -0,0 +1,97 @@
|
|
|
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.stripCloudflareBaseNesting = stripCloudflareBaseNesting;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the real source subtree to copy static assets from, for Astro 6/7.
|
|
41
|
+
*
|
|
42
|
+
* WHY THIS EXISTS — it reconciles two facts that would otherwise double-nest assets:
|
|
43
|
+
* 1. The generated `astro.config` sets `base = mountPath`, so a CORRECT `@astrojs/cloudflare`
|
|
44
|
+
* (>= 13.3.1 on Astro 6, all 14.x on Astro 7) nests the client tree under
|
|
45
|
+
* `dist/client/<mount>/`.
|
|
46
|
+
* 2. `copyAssets` ALWAYS copies into `assets/<mount>/` — it re-appends the mount to the
|
|
47
|
+
* destination unconditionally.
|
|
48
|
+
* Handing `copyAssets` the whole `dist/client` makes (1)+(2) produce `assets/<mount>/<mount>/…`
|
|
49
|
+
* → `/app/app/_astro` → 404. So we descend into the already-nested `dist/client/<mount>/`
|
|
50
|
+
* first, and the copy re-applies the mount exactly once.
|
|
51
|
+
*
|
|
52
|
+
* Behavior by adapter:
|
|
53
|
+
* - Fixed adapter (the normal case): `<assetsPath>/<mount>/_astro` exists → the whole client
|
|
54
|
+
* tree really is nested there → descend into `<assetsPath>/<mount>`.
|
|
55
|
+
* - Buggy pre-13.3.1 adapter that emitted a FLAT tree (rare — `ensureFixedCloudflareAdapter`
|
|
56
|
+
* forces a fixed version, so this only survives a version we could not safely bump):
|
|
57
|
+
* no nested `_astro` → return `assetsPath` unchanged (copy the flat tree as-is).
|
|
58
|
+
* We key off the nested bundled-assets dir (`_astro`), NOT merely `<assetsPath>/<mount>`
|
|
59
|
+
* existing: on a flat build a same-named page route (e.g. a `src/pages/<mount>/` route) also
|
|
60
|
+
* produces `<assetsPath>/<mount>`, and descending into it would silently drop `_astro` and
|
|
61
|
+
* every other top-level output. Handles any nesting depth, including multi-segment mounts.
|
|
62
|
+
*
|
|
63
|
+
* NOTE: this is REQUIRED on every deploy with a nesting (i.e. fixed) adapter — it is NOT a
|
|
64
|
+
* buggy-adapter workaround. Removing it must be paired with removing the destination-side
|
|
65
|
+
* mount re-append in `copyAssets`; deleting only one reintroduces the double-nest 404.
|
|
66
|
+
*
|
|
67
|
+
* Background: withastro/astro#16276 (base-path bug in `@astrojs/cloudflare` 13.0.0–13.3.0,
|
|
68
|
+
* fixed in 13.3.1; all 14.x are fixed).
|
|
69
|
+
*
|
|
70
|
+
* @param cwd - project/workspace root that `assetsPath` is relative to.
|
|
71
|
+
* @param assetsPath - the framework's static assets path (e.g. `dist/client`), relative to `cwd`.
|
|
72
|
+
* @param cleanMountPath - the mount path with leading/trailing slashes trimmed.
|
|
73
|
+
* @returns the (possibly deeper) assets path, relative to `cwd`.
|
|
74
|
+
*/
|
|
75
|
+
/** True when `abs` is an existing directory (never throws). */
|
|
76
|
+
function isDirectory(abs) {
|
|
77
|
+
const stat = fs.statSync(abs, { throwIfNoEntry: false });
|
|
78
|
+
return stat?.isDirectory() === true;
|
|
79
|
+
}
|
|
80
|
+
function stripCloudflareBaseNesting(cwd, assetsPath, cleanMountPath) {
|
|
81
|
+
if (!cleanMountPath) {
|
|
82
|
+
return assetsPath;
|
|
83
|
+
}
|
|
84
|
+
// With a fixed adapter the whole client tree nests under exactly this known
|
|
85
|
+
// (possibly multi-segment) mount path. Only descend when the nested dir is the
|
|
86
|
+
// real client root — i.e. it contains the bundled-assets dir (`_astro`). A bare
|
|
87
|
+
// `<assetsPath>/<mount>` can also be a same-named page route on a flat build, and
|
|
88
|
+
// descending into that would drop `_astro` and every other top-level output.
|
|
89
|
+
const candidate = `${assetsPath}/${cleanMountPath}`;
|
|
90
|
+
const candidateAbs = path.join(cwd, candidate);
|
|
91
|
+
const nestedBundle = path.join(candidateAbs, '_astro');
|
|
92
|
+
if (isDirectory(candidateAbs) && isDirectory(nestedBundle)) {
|
|
93
|
+
return candidate;
|
|
94
|
+
}
|
|
95
|
+
return assetsPath;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=strip-cloudflare-base-nesting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-cloudflare-base-nesting.js","sourceRoot":"","sources":["../../../../src/frameworks/astro/adapter-patches/strip-cloudflare-base-nesting.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,gEAsBC;AAnED,4CAA8B;AAC9B,gDAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,+DAA+D;AAC/D,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IACzD,OAAO,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;AACtC,CAAC;AAED,SAAgB,0BAA0B,CACxC,GAAW,EACX,UAAkB,EAClB,cAAsB;IAEtB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,4EAA4E;IAC5E,+EAA+E;IAC/E,gFAAgF;IAChF,kFAAkF;IAClF,6EAA6E;IAC7E,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,cAAc,EAAE,CAAC;IACpD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACvD,IAAI,WAAW,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FrameworkBuilder } from '../base';
|
|
2
|
+
import type { BuildOutput, FrameworkInfo, PackageJson, WebflowJson, DetectionResult, AdapterPackage, IntegrationPackage, WebflowLoaderConfig, NodeVersionRequirement } from '../types';
|
|
3
|
+
export declare class Astro5Builder extends FrameworkBuilder {
|
|
4
|
+
static frameworkName: string;
|
|
5
|
+
get info(): FrameworkInfo;
|
|
6
|
+
getFrameworkVersion(): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Detect if this is an Astro 5 (or older) project.
|
|
9
|
+
*
|
|
10
|
+
* Version is always determined from package.json, not webflow.json.
|
|
11
|
+
* Astro6Builder is checked first in the registry, so Astro 6+ projects won't
|
|
12
|
+
* reach this builder.
|
|
13
|
+
*/
|
|
14
|
+
static detect(packageJson: PackageJson, webflowJson?: WebflowJson): DetectionResult;
|
|
15
|
+
validate(): Promise<void>;
|
|
16
|
+
getCloudflareAdapter(): AdapterPackage;
|
|
17
|
+
getRequiredIntegrations(): IntegrationPackage[];
|
|
18
|
+
installDependencies(): Promise<void>;
|
|
19
|
+
getWebflowLoader(): WebflowLoaderConfig;
|
|
20
|
+
getUserConfigPatterns(): string[];
|
|
21
|
+
getWranglerTemplatePath(): string;
|
|
22
|
+
getAdditionalConfigFiles(): string[];
|
|
23
|
+
prepareConfig(): Promise<void>;
|
|
24
|
+
getBuildCommand(): string;
|
|
25
|
+
getNodeVersionRequirement(): NodeVersionRequirement;
|
|
26
|
+
static getOutputDeployMetadata(): BuildOutput;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=astro5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro5.d.ts","sourceRoot":"","sources":["../../../src/frameworks/astro/astro5.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAelB,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAgB,aAAa,SAAW;IAMxC,IAAI,IAAI,IAAI,aAAa,CAOxB;IAEQ,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAQlD;;;;;;OAMG;WACa,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,eAAe;IAgCtF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA6C/B,oBAAoB,IAAI,cAAc;IAOtC,uBAAuB,IAAI,kBAAkB,EAAE;IAUzC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmC1C,gBAAgB,IAAI,mBAAmB;IAQvC,qBAAqB,IAAI,MAAM,EAAE;IAIjC,uBAAuB,IAAI,MAAM;IAIjC,wBAAwB,IAAI,MAAM,EAAE;IAK9B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAoDpC,eAAe,IAAI,MAAM;IAIzB,yBAAyB,IAAI,sBAAsB;WAWnC,uBAAuB,IAAI,WAAW;CAUvD"}
|