@webflow/cloud-app 0.1.0-beta.8 → 0.1.0
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/README.md +20 -51
- package/dist/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -1
- package/dist/bindings.js +10 -4
- package/dist/bindings.js.map +1 -1
- 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/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/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +3 -3
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +3 -3
- 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/ensure-fixed-cloudflare-adapter.d.ts +2 -2
- package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js +2 -2
- 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/astro6.d.ts.map +1 -1
- package/dist/frameworks/astro/astro6.js +11 -9
- package/dist/frameworks/astro/astro6.js.map +1 -1
- package/dist/frameworks/astro/astro7.d.ts.map +1 -1
- package/dist/frameworks/astro/astro7.js +12 -9
- package/dist/frameworks/astro/astro7.js.map +1 -1
- package/dist/frameworks/astro/session-check.d.ts +27 -0
- package/dist/frameworks/astro/session-check.d.ts.map +1 -0
- package/dist/frameworks/astro/session-check.js +173 -0
- package/dist/frameworks/astro/session-check.js.map +1 -0
- package/dist/frameworks/astro/templates/astro.config.webflow.ts +86 -1
- package/dist/frameworks/astro/templates/v5/webflow-loader.ts +4 -1
- package/dist/frameworks/astro/templates/v6/webflow-loader.ts +4 -1
- package/dist/frameworks/astro/templates/v7/webflow-loader.ts +4 -1
- package/dist/frameworks/static/templates/wrangler.json +2 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +20 -1
- package/dist/pipeline.js.map +1 -1
- 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/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wrangler.d.ts +5 -2
- package/dist/wrangler.d.ts.map +1 -1
- package/dist/wrangler.js +135 -7
- package/dist/wrangler.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -100,62 +100,31 @@ repo). Which copy of `@webflow/cloud-app` they load is decided by **where
|
|
|
100
100
|
`npm install` ran**, not by how the code is bundled and not at runtime — a
|
|
101
101
|
`require("@webflow/cloud-app")` just reads whatever `npm` put in `node_modules`.
|
|
102
102
|
|
|
103
|
-
| Scenario | `node_modules/@webflow/cloud-app` is…
|
|
104
|
-
| ---------------------------------------------------------------------------- |
|
|
105
|
-
| End user runs `npm i -g @webflow/webflow-cli` | the registry copy npm fetched
|
|
106
|
-
| Engineer working in the webflow-cli repo (`npm ci`, build, run local `dist`) | a symlink to `apps/webflow-cloud-app`
|
|
107
|
-
| CI for webflow-cli (unit, regression
|
|
108
|
-
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
by `npm run check:cloud-app-pin
|
|
115
|
-
|
|
116
|
-
the next build.
|
|
103
|
+
| Scenario | `node_modules/@webflow/cloud-app` is… | Source |
|
|
104
|
+
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------- |
|
|
105
|
+
| End user runs `npm i -g @webflow/webflow-cli` | the registry copy npm fetched | npm registry |
|
|
106
|
+
| Engineer working in the webflow-cli repo (`npm ci`, build, run local `dist`) | a symlink to `apps/webflow-cloud-app` | workspace (repo tree) |
|
|
107
|
+
| CI for webflow-cli (unit, regression) | a symlink to `apps/webflow-cloud-app` | workspace (repo tree) |
|
|
108
|
+
| CI for webflow-cli (e2e, temp workspace outside the repo) | a tarball packed from this folder, or the published version the CLI depends on while it lags | workspace (repo tree) or npm registry |
|
|
109
|
+
| cosmic-builder (separate repo) | the registry copy npm fetched | npm registry |
|
|
110
|
+
|
|
111
|
+
- **Inside this monorepo the CLI uses the workspace copy while it depends on
|
|
112
|
+
this package's current version.** `apps/webflow-cli` depends on it through an
|
|
113
|
+
npm alias to an exact version (`npm:@webflow/cloud-app@<version>`, enforced in
|
|
114
|
+
CI by `npm run check:cloud-app-pin`). While that version equals this package's
|
|
115
|
+
version, npm links the workspace copy, so editing the source here takes effect
|
|
116
|
+
on the next build. When this package has moved ahead, the CLI keeps using the
|
|
117
|
+
published version its alias names until the alias is changed on purpose.
|
|
117
118
|
- **The published CLI uses the registry copy.** The engine is kept external in
|
|
118
119
|
the CLI's tsup bundle (it is CJS, not inlined), so the shipped `dist` keeps
|
|
119
120
|
`require("@webflow/cloud-app")` and resolves it at the user's install time.
|
|
120
|
-
The
|
|
121
|
-
|
|
122
|
-
resolve exactly that version from npm.
|
|
121
|
+
The alias names an exact version, so released builds resolve exactly that
|
|
122
|
+
version from npm.
|
|
123
123
|
- **cosmic-builder is a different repo**, so it has no workspace copy and always
|
|
124
|
-
resolves from the registry. That is why publishing to npm
|
|
124
|
+
resolves from the registry. That is why publishing to npm still
|
|
125
125
|
matters even though the CLI links the workspace in development.
|
|
126
126
|
|
|
127
127
|
## Publishing
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
workspace package, but `changeset publish` always publishes with `--tag latest`,
|
|
132
|
-
which would move `latest` onto a beta, so it must already be on npm before a CLI
|
|
133
|
-
release: `publish-packages.sh` refuses to run otherwise, and skips it once it is.
|
|
134
|
-
Don't add changesets for this package — changesets can't increment a prerelease
|
|
135
|
-
(it would turn `0.1.0-beta.7` into `0.1.0`); bump the version by hand. CI fails
|
|
136
|
-
(`npm run check:cloud-app-pin`) if a changeset names it.
|
|
137
|
-
|
|
138
|
-
This is a prerelease line (`0.1.0-beta.x`), so always pass an explicit
|
|
139
|
-
`--tag` — npm would otherwise move the `latest` tag onto a beta. The CLI pins
|
|
140
|
-
this exact version, so move the pin in the same PR (CI runs
|
|
141
|
-
`npm run check:cloud-app-pin`):
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
# from apps/webflow-cloud-app
|
|
145
|
-
npm version prerelease --preid beta --no-git-tag-version # 0.1.0-beta.7 → 0.1.0-beta.8
|
|
146
|
-
# set "@webflow/cloud-app" in apps/webflow-cli/package.json to the same version
|
|
147
|
-
# and run `npm install` from the repo root
|
|
148
|
-
npm publish --tag beta # installs via @webflow/cloud-app@beta
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
To test a build against the consumers (webflow-cli, cosmic-builder) before a
|
|
152
|
-
real release, publish the same version under a throwaway ticket-scoped tag so
|
|
153
|
-
it never touches `latest` or `beta`:
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
npm publish --tag beta7-cloud888 # installs via @webflow/cloud-app@beta7-cloud888
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Consumers then pin that exact version (e.g. `"@webflow/cloud-app": "0.1.0-beta.8"`)
|
|
160
|
-
and CI resolves it from the registry. Remove a throwaway tag when done with
|
|
161
|
-
`npm dist-tag rm @webflow/cloud-app beta7-cloud888`.
|
|
129
|
+
Release instructions for the Cloud team are in
|
|
130
|
+
[RELEASING.md](./RELEASING.md).
|
package/dist/bindings.d.ts
CHANGED
|
@@ -174,6 +174,11 @@ export declare function hasAnyBindings(bindings: WebflowBindings | undefined): b
|
|
|
174
174
|
export declare function validateR2BucketName(name: string): void;
|
|
175
175
|
/** Enforce per-type count limits and R2 naming rules. Mirrors the deployer's checks. */
|
|
176
176
|
export declare function validateBindings(bindings: WebflowBindings): void;
|
|
177
|
+
/**
|
|
178
|
+
* `compatibility_date` written into the binding bridge. A schema placeholder the deployer
|
|
179
|
+
* ignores, not a date the user chose; the compat date policy never treats it as one.
|
|
180
|
+
*/
|
|
181
|
+
export declare const BINDINGS_BRIDGE_COMPAT_DATE = "2025-01-01";
|
|
177
182
|
/**
|
|
178
183
|
* Synthesize the wrangler-shaped binding bridge from webflow.json bindings.
|
|
179
184
|
*
|
package/dist/bindings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAUvC,eAAO,MAAM,eAAe;;;;;;;;;gCAEZ,CAAC;AACjB,eAAO,MAAM,eAAe;;;;;;;;;gCAEZ,CAAC;AACjB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;gCAOZ,CAAC;AAEjB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAMX,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7D,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAGvE;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAG7E;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgBvD;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAmBhE;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,eAAe,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,IAAI,SAAgB,GACnB,YAAY,CAmBd"}
|
package/dist/bindings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BindingsSchema = exports.D1BindingSchema = exports.R2BindingSchema = exports.KvBindingSchema = exports.MAX_BINDINGS_PER_TYPE = void 0;
|
|
3
|
+
exports.BINDINGS_BRIDGE_COMPAT_DATE = exports.BindingsSchema = exports.D1BindingSchema = exports.R2BindingSchema = exports.KvBindingSchema = exports.MAX_BINDINGS_PER_TYPE = void 0;
|
|
4
4
|
exports.parseBindings = parseBindings;
|
|
5
5
|
exports.hasAnyBindings = hasAnyBindings;
|
|
6
6
|
exports.validateR2BucketName = validateR2BucketName;
|
|
@@ -25,8 +25,9 @@ const zod_1 = require("zod");
|
|
|
25
25
|
const errors_1 = require("./frameworks/errors");
|
|
26
26
|
/** Max number of each binding type, matching the deployer's limits. */
|
|
27
27
|
exports.MAX_BINDINGS_PER_TYPE = 5;
|
|
28
|
-
// Cloudflare assigns the real ids at deploy time
|
|
29
|
-
//
|
|
28
|
+
// Cloudflare assigns the real ids at deploy time. The user wrangler schema and
|
|
29
|
+
// `wrangler deploy --dry-run` accept bindings without ids; the placeholders keep
|
|
30
|
+
// the bridge valid against the strict `loadWranglerJson` schema.
|
|
30
31
|
const KV_ID_PLACEHOLDER = '0'.repeat(32);
|
|
31
32
|
const D1_ID_PLACEHOLDER = '00000000-0000-0000-0000-000000000000';
|
|
32
33
|
// `binding` is the JS binding name (e.g. `env.MY_KV`). `id` / `database_id` are
|
|
@@ -90,6 +91,11 @@ function validateBindings(bindings) {
|
|
|
90
91
|
validateR2BucketName(bucket.bucket_name);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* `compatibility_date` written into the binding bridge. A schema placeholder the deployer
|
|
96
|
+
* ignores, not a date the user chose; the compat date policy never treats it as one.
|
|
97
|
+
*/
|
|
98
|
+
exports.BINDINGS_BRIDGE_COMPAT_DATE = '2025-01-01';
|
|
93
99
|
/**
|
|
94
100
|
* Synthesize the wrangler-shaped binding bridge from webflow.json bindings.
|
|
95
101
|
*
|
|
@@ -100,7 +106,7 @@ function validateBindings(bindings) {
|
|
|
100
106
|
function bindingsToWranglerJson(bindings, name = 'webflow-app') {
|
|
101
107
|
return {
|
|
102
108
|
name,
|
|
103
|
-
compatibility_date:
|
|
109
|
+
compatibility_date: exports.BINDINGS_BRIDGE_COMPAT_DATE,
|
|
104
110
|
kv_namespaces: (bindings.kv ?? []).map((k) => ({
|
|
105
111
|
binding: k.binding,
|
|
106
112
|
id: k.id ?? KV_ID_PLACEHOLDER,
|
package/dist/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;AAyDA,sCAGC;AAGD,wCAGC;AAGD,oDAgBC;AAGD,4CAmBC;AAeD,wDAsBC;AAhJD;;;;;;;;;;;;;;GAcG;AACH,6BAAwB;AAExB,gDAA2D;AAG3D,uEAAuE;AAC1D,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAEvC,+EAA+E;AAC/E,iFAAiF;AACjF,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACzC,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AAEjE,gFAAgF;AAChF,wEAAwE;AAC3D,QAAA,eAAe,GAAG,OAAC;KAC7B,MAAM,CAAC,EAAE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;KAC1D,WAAW,EAAE,CAAC;AACJ,QAAA,eAAe,GAAG,OAAC;KAC7B,MAAM,CAAC,EAAE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;KACxD,WAAW,EAAE,CAAC;AACJ,QAAA,eAAe,GAAG,OAAC;KAC7B,MAAM,CAAC;IACN,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;IACzB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC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AAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7C,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,iBAAiB;SAC9B,CAAC,CAAC;QACH,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1C,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC,CAAC;QACH,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5C,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,aAAa,EAAE,CAAC,CAAC,aAAa;YAC9B,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,iBAAiB;YAC/C,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClE,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Logger } from './ports';
|
|
2
|
+
/**
|
|
3
|
+
* Lowest `compatibility_date` the platform runs a worker at once the policy is on.
|
|
4
|
+
* workerd only provides a working `node:http` / `node:https` client from this date.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COMPAT_DATE_FLOOR = "2025-08-16";
|
|
7
|
+
/**
|
|
8
|
+
* Where the build records the date it settled on, next to `clouduser.wrangler.json`
|
|
9
|
+
* (which already travels from the build to the deploy). Keep in sync with the
|
|
10
|
+
* deployer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMPAT_DATE_RECORD_FILE = "clouduser.compat-date.json";
|
|
13
|
+
export type CompatDateSource = 'template' | 'floor' | 'user';
|
|
14
|
+
export interface CompatDateInputs {
|
|
15
|
+
/** `compatibility_date` of the template the build's wrangler.json was copied from. */
|
|
16
|
+
templateDate: string;
|
|
17
|
+
/** `compatibility_date` from the user's own wrangler config, if any. */
|
|
18
|
+
userDate?: string;
|
|
19
|
+
/**
|
|
20
|
+
* When false the template date is used unchanged. When true, the result is always
|
|
21
|
+
* a valid date at or above COMPAT_DATE_FLOOR: the user's date when it qualifies,
|
|
22
|
+
* otherwise the template's date or the floor, whichever is later.
|
|
23
|
+
*/
|
|
24
|
+
policyEnabled: boolean;
|
|
25
|
+
/** Injected for tests. */
|
|
26
|
+
now?: Date;
|
|
27
|
+
}
|
|
28
|
+
export interface CompatDateResolution {
|
|
29
|
+
date: string;
|
|
30
|
+
source: CompatDateSource;
|
|
31
|
+
/** Present when the user's date was unusable. */
|
|
32
|
+
warning?: string;
|
|
33
|
+
}
|
|
34
|
+
/** What the build leaves for the deploy. */
|
|
35
|
+
export interface CompatDateRecord {
|
|
36
|
+
compatibilityDate: string;
|
|
37
|
+
source: CompatDateSource;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pure resolution of the date a worker is built and deployed with.
|
|
41
|
+
*
|
|
42
|
+
* policy off -> template date, unchanged
|
|
43
|
+
* policy on, user date valid, <= today, >= floor -> user date
|
|
44
|
+
* policy on, otherwise -> default, plus a warning if a
|
|
45
|
+
* user date was given but unusable
|
|
46
|
+
*
|
|
47
|
+
* where default = the template date if it is a valid date at or above the floor,
|
|
48
|
+
* else the floor.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveCompatDate(inputs: CompatDateInputs): CompatDateResolution;
|
|
51
|
+
/**
|
|
52
|
+
* Settles the date on `<cwd>/wrangler.json` (just copied from the framework
|
|
53
|
+
* template) and records it for the deploy.
|
|
54
|
+
*
|
|
55
|
+
* `userCompatDate` is the date from the user's own wrangler config, if any. The
|
|
56
|
+
* bindings-bridge placeholder is not a user choice and is ignored. With the policy
|
|
57
|
+
* off nothing changes and no record is written; a record already in the checkout is
|
|
58
|
+
* removed either way, because the deploy trusts that file and a repo must not be
|
|
59
|
+
* able to supply it.
|
|
60
|
+
*
|
|
61
|
+
* Never throws: an error keeps the template date and logs a warning, so this cannot
|
|
62
|
+
* fail a build.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyCompatDateAtBuild(log: Logger, cwd: string, userCompatDate: string | undefined, opts?: {
|
|
65
|
+
policyEnabled?: boolean;
|
|
66
|
+
now?: Date;
|
|
67
|
+
}): CompatDateResolution | undefined;
|
|
68
|
+
//# sourceMappingURL=compat-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat-date.d.ts","sourceRoot":"","sources":["../src/compat-date.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAgChF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GACjD,oBAAoB,GAAG,SAAS,CAwClC"}
|
|
@@ -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,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@@
|
|
|
1
|
+
export type DiagnosticLevel = 'warn' | 'error';
|
|
2
|
+
export declare const DiagnosticCode: {
|
|
3
|
+
readonly ASTRO_SESSION_BINDING_MISSING: "ASTRO_SESSION_BINDING_MISSING";
|
|
4
|
+
readonly WRANGLER_JSON_INVALID: "WRANGLER_JSON_INVALID";
|
|
5
|
+
};
|
|
6
|
+
export type DiagnosticCode = (typeof DiagnosticCode)[keyof typeof DiagnosticCode];
|
|
7
|
+
export interface Diagnostic {
|
|
8
|
+
level: DiagnosticLevel;
|
|
9
|
+
code: DiagnosticCode;
|
|
10
|
+
/** One sentence: what is wrong and what it breaks. No newlines. */
|
|
11
|
+
message: string;
|
|
12
|
+
/** One sentence: the exact change to make. No newlines. */
|
|
13
|
+
fix?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const DIAGNOSTIC_LINE_PATTERN: RegExp;
|
|
16
|
+
export declare function formatDiagnostic({ level, code, message, fix }: Diagnostic): string;
|
|
17
|
+
export declare function parseDiagnostic(line: string): {
|
|
18
|
+
level: DiagnosticLevel;
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
fix?: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAElF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,eAAO,MAAM,uBAAuB,QAC6B,CAAC;AAElE,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,GAAG,MAAM,CAKlF;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAOrF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Machine-readable build diagnostics. The format and code registry match cosmic-builder's BUILD_DIAGNOSTICS.md
|
|
3
|
+
// (keep codes in sync). Agents, the CLI and (later) the dashboard pick these
|
|
4
|
+
// lines out of the build log by the `[cloud:<level>:<CODE>]` prefix, so a code
|
|
5
|
+
// must never change meaning once shipped.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DIAGNOSTIC_LINE_PATTERN = exports.DiagnosticCode = void 0;
|
|
8
|
+
exports.formatDiagnostic = formatDiagnostic;
|
|
9
|
+
exports.parseDiagnostic = parseDiagnostic;
|
|
10
|
+
exports.DiagnosticCode = {
|
|
11
|
+
ASTRO_SESSION_BINDING_MISSING: 'ASTRO_SESSION_BINDING_MISSING',
|
|
12
|
+
WRANGLER_JSON_INVALID: 'WRANGLER_JSON_INVALID',
|
|
13
|
+
};
|
|
14
|
+
// Matches the first line of a diagnostic. Errors may carry detail lines after it.
|
|
15
|
+
// Leading whitespace is allowed because the CLI indents every log line.
|
|
16
|
+
exports.DIAGNOSTIC_LINE_PATTERN = /^\s*\[cloud:(warn|error):([A-Z0-9_]+)\] (.*?)(?: Fix: (.*))?$/;
|
|
17
|
+
function formatDiagnostic({ level, code, message, fix }) {
|
|
18
|
+
if (/[\r\n]/.test(message) || (fix && /[\r\n]/.test(fix))) {
|
|
19
|
+
throw new Error(`diagnostic ${code}: message and fix must be single-line`);
|
|
20
|
+
}
|
|
21
|
+
return `[cloud:${level}:${code}] ${message}` + (fix ? ` Fix: ${fix}` : '');
|
|
22
|
+
}
|
|
23
|
+
function parseDiagnostic(line) {
|
|
24
|
+
const match = exports.DIAGNOSTIC_LINE_PATTERN.exec(line.split(/\r?\n/, 1)[0].replace(/\r+$/, ''));
|
|
25
|
+
if (!match) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const [, level, code, message, fix] = match;
|
|
29
|
+
return { level: level, code, message, ...(fix !== undefined ? { fix } : {}) };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":";AAAA,+GAA+G;AAC/G,6EAA6E;AAC7E,+EAA+E;AAC/E,0CAA0C;;;AAyB1C,4CAKC;AAED,0CASC;AArCY,QAAA,cAAc,GAAG;IAC5B,6BAA6B,EAAE,+BAA+B;IAC9D,qBAAqB,EAAE,uBAAuB;CACtC,CAAC;AAaX,kFAAkF;AAClF,wEAAwE;AAC3D,QAAA,uBAAuB,GAClC,+DAA+D,CAAC;AAElE,SAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAc;IACxE,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,uCAAuC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,UAAU,KAAK,IAAI,IAAI,KAAK,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,SAAgB,eAAe,CAC7B,IAAY;IAEZ,MAAM,KAAK,GAAG,+BAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1F,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5C,OAAO,EAAE,KAAK,EAAE,KAAwB,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACnG,CAAC"}
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* Everything else passes: a missing `assetsPath`, a metadata-only tree, and an asset-less app
|
|
21
21
|
* (an empty `<mount>/` dir still counts as nested).
|
|
22
22
|
*
|
|
23
|
-
* `
|
|
24
|
-
* unreachable. It is reachable through a non-semver adapter spec (git URL,
|
|
25
|
-
*
|
|
23
|
+
* `ensureCompatibleCloudflareAdapter` clamps the adapter into a base-path-fixed range, which is
|
|
24
|
+
* what keeps this nearly unreachable. It is reachable through a non-semver adapter spec (git URL,
|
|
25
|
+
* `file:`, alias) whose range it cannot verify and therefore leaves alone.
|
|
26
26
|
*/
|
|
27
27
|
export declare function assertAdapterNestedUnderMount(cwd: string, assetsPath: string, cleanMountPath: string): void;
|
|
28
28
|
//# sourceMappingURL=assert-adapter-nested-under-mount.d.ts.map
|
|
@@ -92,9 +92,9 @@ function listEntries(dir) {
|
|
|
92
92
|
* Everything else passes: a missing `assetsPath`, a metadata-only tree, and an asset-less app
|
|
93
93
|
* (an empty `<mount>/` dir still counts as nested).
|
|
94
94
|
*
|
|
95
|
-
* `
|
|
96
|
-
* unreachable. It is reachable through a non-semver adapter spec (git URL,
|
|
97
|
-
*
|
|
95
|
+
* `ensureCompatibleCloudflareAdapter` clamps the adapter into a base-path-fixed range, which is
|
|
96
|
+
* what keeps this nearly unreachable. It is reachable through a non-semver adapter spec (git URL,
|
|
97
|
+
* `file:`, alias) whose range it cannot verify and therefore leaves alone.
|
|
98
98
|
*/
|
|
99
99
|
function assertAdapterNestedUnderMount(cwd, assetsPath, cleanMountPath) {
|
|
100
100
|
if (!cleanMountPath) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Logger, CommandRunner } from '../../../ports';
|
|
2
|
+
export interface EnsureCompatibleCloudflareAdapterParams {
|
|
3
|
+
log: Logger;
|
|
4
|
+
runCommand: CommandRunner;
|
|
5
|
+
cwd: string;
|
|
6
|
+
/** e.g. `@astrojs/cloudflare`. */
|
|
7
|
+
adapterName: string;
|
|
8
|
+
/**
|
|
9
|
+
* The adapter range compatible with the project's Astro version, from
|
|
10
|
+
* `resolveCloudflareAdapterRange` (e.g. `>=14.1.7 <14.2.0` or `^13.3.1`).
|
|
11
|
+
*/
|
|
12
|
+
compatibleRange: string;
|
|
13
|
+
/** The user's declared adapter spec (from package.json), or undefined if absent. */
|
|
14
|
+
declaredVersion: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Ensure the project resolves a `@astrojs/cloudflare` within the range that is
|
|
18
|
+
* compatible with its Astro version (see `resolveCloudflareAdapterRange`).
|
|
19
|
+
*
|
|
20
|
+
* - Adapter absent -> install the compatible range.
|
|
21
|
+
* - Declared range NOT a subset of the compatible range -> force-install the
|
|
22
|
+
* compatible range and warn. This catches both a too-low range (a base-path-buggy
|
|
23
|
+
* 13.x, withastro/astro#16276) and a too-high one (an unbounded `^14.0.0` that
|
|
24
|
+
* floats to 14.2.x and breaks Astro 7.0/7.1, whose adapter peerDeps lie).
|
|
25
|
+
* - Declared range already within the compatible range -> leave it alone.
|
|
26
|
+
* - Unparseable spec (`workspace:` / `file:` / `npm:` alias) -> warn and leave it;
|
|
27
|
+
* we cannot reason about the range, and forcing could clobber an intentional link.
|
|
28
|
+
*
|
|
29
|
+
* `npm install --save <pkg>@<range>` rewrites BOTH package.json and the lockfile
|
|
30
|
+
* entry for this package, so a forced install overrides a lockfile-pinned
|
|
31
|
+
* incompatible version.
|
|
32
|
+
*/
|
|
33
|
+
export declare function ensureCompatibleCloudflareAdapter(params: EnsureCompatibleCloudflareAdapterParams): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=ensure-compatible-cloudflare-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-compatible-cloudflare-adapter.d.ts","sourceRoot":"","sources":["../../../../src/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,uCAAuC;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,aAAa,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,iCAAiC,CACrD,MAAM,EAAE,uCAAuC,GAC9C,OAAO,CAAC,IAAI,CAAC,CA0Cf"}
|