devflare 1.0.0-next.19 → 1.0.0-next.20
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/LLM.md +6807 -888
- package/README.md +375 -957
- package/dist/account-05zgta47.js +475 -0
- package/dist/account-b2ag1esh.js +475 -0
- package/dist/account-bxtcz61a.js +475 -0
- package/dist/account-gyfqg964.js +475 -0
- package/dist/account-q6pvs9d9.js +475 -0
- package/dist/account-rp4zbvw1.js +475 -0
- package/dist/bridge/client.d.ts +5 -0
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/gateway-runtime.d.ts +1 -1
- package/dist/bridge/gateway-runtime.d.ts.map +1 -1
- package/dist/bridge/miniflare.d.ts +67 -0
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/bridge/proxy.d.ts +2 -1
- package/dist/bridge/proxy.d.ts.map +1 -1
- package/dist/bridge/server.d.ts.map +1 -1
- package/dist/browser.d.ts +2520 -40
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +3 -3
- package/dist/build-2s5paw5p.js +54 -0
- package/dist/build-4c350cp7.js +54 -0
- package/dist/build-e7wym63t.js +54 -0
- package/dist/build-ge6qp3t4.js +54 -0
- package/dist/build-ta8c6t11.js +54 -0
- package/dist/build-wvjj8f28.js +54 -0
- package/dist/build-ypg6f2kw.js +54 -0
- package/dist/build-yts8wwgf.js +54 -0
- package/dist/build-yzkdqexs.js +54 -0
- package/dist/cli/build-manifest.d.ts +12 -0
- package/dist/cli/build-manifest.d.ts.map +1 -1
- package/dist/cli/commands/deploy/metadata.d.ts +18 -0
- package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
- package/dist/cli/commands/deploy/prepare.d.ts +23 -0
- package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
- package/dist/cli/commands/deploy/runtime.d.ts +4 -0
- package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
- package/dist/cli/commands/deploy/verification.d.ts +36 -0
- package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
- package/dist/cli/commands/deploy.d.ts +2 -2
- package/dist/cli/commands/deploy.d.ts.map +1 -1
- package/dist/cli/commands/secrets.d.ts +4 -0
- package/dist/cli/commands/secrets.d.ts.map +1 -0
- package/dist/cli/commands/type-generation/generator.d.ts +67 -1
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
- package/dist/cli/help-pages/pages/core.d.ts +1 -1
- package/dist/cli/help-pages/pages/core.d.ts.map +1 -1
- package/dist/cli/help-pages/shared.d.ts +1 -1
- package/dist/cli/help-pages/shared.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/package-metadata.d.ts.map +1 -1
- package/dist/cli/preview-bindings.d.ts.map +1 -1
- package/dist/cloudflare/index.js +2 -2
- package/dist/cloudflare/preview-registry-store.d.ts +1 -1
- package/dist/cloudflare/preview-registry-store.d.ts.map +1 -1
- package/dist/cloudflare/types.d.ts +1 -1
- package/dist/cloudflare/types.d.ts.map +1 -1
- package/dist/config/binding-resolution-helpers.d.ts +5 -0
- package/dist/config/binding-resolution-helpers.d.ts.map +1 -1
- package/dist/config/compiler/bindings.d.ts +14 -0
- package/dist/config/compiler/bindings.d.ts.map +1 -0
- package/dist/config/compiler/core-helpers.d.ts +6 -0
- package/dist/config/compiler/core-helpers.d.ts.map +1 -0
- package/dist/config/compiler/do-workers.d.ts +34 -0
- package/dist/config/compiler/do-workers.d.ts.map +1 -0
- package/dist/config/compiler/paths.d.ts +18 -0
- package/dist/config/compiler/paths.d.ts.map +1 -0
- package/dist/config/compiler/types.d.ts +267 -0
- package/dist/config/compiler/types.d.ts.map +1 -0
- package/dist/config/compiler.d.ts +11 -175
- package/dist/config/compiler.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/local-dev-vars.d.ts +15 -0
- package/dist/config/local-dev-vars.d.ts.map +1 -0
- package/dist/config/preview-resources.d.ts.map +1 -1
- package/dist/config/preview.d.ts.map +1 -1
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resource-resolution.d.ts.map +1 -1
- package/dist/config/schema-bindings.d.ts +559 -19
- package/dist/config/schema-bindings.d.ts.map +1 -1
- package/dist/config/schema-env.d.ts +1306 -34
- package/dist/config/schema-env.d.ts.map +1 -1
- package/dist/config/schema-normalization.d.ts +97 -1
- package/dist/config/schema-normalization.d.ts.map +1 -1
- package/dist/config/schema-runtime.d.ts +245 -7
- package/dist/config/schema-runtime.d.ts.map +1 -1
- package/dist/config/schema.d.ts +2976 -57
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config-6m0n7d84.js +59 -0
- package/dist/config-7cf004ag.js +59 -0
- package/dist/config-b98dp58n.js +59 -0
- package/dist/config-cf3djhqy.js +59 -0
- package/dist/config-entry.js +1 -1
- package/dist/config-wa7hm0w9.js +59 -0
- package/dist/deploy-1jfagtn9.js +1055 -0
- package/dist/deploy-2afw0jfg.js +1055 -0
- package/dist/deploy-2fzj68kq.js +1055 -0
- package/dist/deploy-57nzn9wj.js +1045 -0
- package/dist/deploy-asyryrvm.js +1055 -0
- package/dist/deploy-hc927rw6.js +1045 -0
- package/dist/deploy-pnnf8tgy.js +1045 -0
- package/dist/deploy-q33bw715.js +1055 -0
- package/dist/deploy-tmdgecs3.js +1055 -0
- package/dist/deploy-v0y8kczr.js +1055 -0
- package/dist/deploy-xhj6zbcx.js +1055 -0
- package/dist/dev-1mvcts8w.js +2515 -0
- package/dist/dev-2a283xts.js +2515 -0
- package/dist/dev-62nhytf8.js +2505 -0
- package/dist/dev-75acm2xj.js +2478 -0
- package/dist/dev-802rg9dp.js +2515 -0
- package/dist/dev-d1bb2t0f.js +2515 -0
- package/dist/dev-dwry8494.js +2489 -0
- package/dist/dev-g6112y4w.js +2515 -0
- package/dist/dev-h2kneh95.js +2496 -0
- package/dist/dev-kybq3mwr.js +2489 -0
- package/dist/dev-n8qndkyg.js +2512 -0
- package/dist/dev-p32fkbwf.js +2489 -0
- package/dist/dev-qm9d4mfh.js +2478 -0
- package/dist/dev-rcthnse5.js +2473 -0
- package/dist/dev-server/dev-server-state.d.ts +1 -0
- package/dist/dev-server/dev-server-state.d.ts.map +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +44 -1
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -1
- package/dist/dev-server/miniflare-dev-config.d.ts +1 -0
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -1
- package/dist/dev-server/miniflare-log.d.ts +8 -0
- package/dist/dev-server/miniflare-log.d.ts.map +1 -1
- package/dist/dev-server/miniflare-worker-config.d.ts +31 -1
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -1
- package/dist/dev-server/server.d.ts.map +1 -1
- package/dist/dev-server/vite-process.d.ts +1 -0
- package/dist/dev-server/vite-process.d.ts.map +1 -1
- package/dist/dev-tgwja5mz.js +2496 -0
- package/dist/doctor-2shhdak6.js +245 -0
- package/dist/doctor-5g73w40j.js +245 -0
- package/dist/doctor-gamefzcs.js +245 -0
- package/dist/doctor-rn53ctfs.js +245 -0
- package/dist/index-01kehw41.js +348 -0
- package/dist/index-06bg0z9y.js +185 -0
- package/dist/index-0d7tw5r4.js +136 -0
- package/dist/index-0m6e4mxz.js +133 -0
- package/dist/index-0vah20er.js +1410 -0
- package/dist/index-0wa0ebm1.js +68 -0
- package/dist/index-1714y3cz.js +1410 -0
- package/dist/index-1qs5gcm7.js +895 -0
- package/dist/index-29k04v43.js +574 -0
- package/dist/index-2jywf4pz.js +1372 -0
- package/dist/index-2qhk9nbx.js +1372 -0
- package/dist/index-2vq6bveq.js +574 -0
- package/dist/index-36h8gkhb.js +1088 -0
- package/dist/index-38fq7pww.js +560 -0
- package/dist/index-3bxqn033.js +1410 -0
- package/dist/index-3jme4hgw.js +1234 -0
- package/dist/index-3p7s9mk9.js +360 -0
- package/dist/index-47w35sft.js +244 -0
- package/dist/index-4by4c7rm.js +52 -0
- package/dist/index-4phjwd6h.js +412 -0
- package/dist/index-4z5jrw0j.js +594 -0
- package/dist/index-51mzqy0d.js +895 -0
- package/dist/index-53pqqpq9.js +74 -0
- package/dist/index-5enq8ntr.js +1766 -0
- package/dist/index-5fnq9r9m.js +1410 -0
- package/dist/index-5w9f2b17.js +695 -0
- package/dist/index-627srx16.js +45 -0
- package/dist/index-6bqgf5x8.js +227 -0
- package/dist/index-6xknvbyk.js +1088 -0
- package/dist/index-7ef3ktz5.js +1372 -0
- package/dist/index-7hpjfdzh.js +185 -0
- package/dist/index-8052df4m.js +627 -0
- package/dist/index-82epjzrr.js +1410 -0
- package/dist/index-82z7rvz6.js +1238 -0
- package/dist/index-8atc1yb9.js +68 -0
- package/dist/index-8tj0awnv.js +476 -0
- package/dist/index-8x745h59.js +1069 -0
- package/dist/index-9bawzcny.js +574 -0
- package/dist/index-9bjjqdfc.js +236 -0
- package/dist/index-9d7x3vfr.js +236 -0
- package/dist/index-9nf8zs4p.js +1069 -0
- package/dist/index-acwbmagz.js +412 -0
- package/dist/index-aqjdaem7.js +74 -0
- package/dist/index-b6448fd0.js +133 -0
- package/dist/index-b9j55r7q.js +240 -0
- package/dist/index-bdatd1za.js +1372 -0
- package/dist/index-c3nxftnp.js +699 -0
- package/dist/index-c643s0gv.js +488 -0
- package/dist/index-d2md1j3d.js +185 -0
- package/dist/index-dbr6bfz6.js +528 -0
- package/dist/index-dd1g0g7e.js +360 -0
- package/dist/index-dktb9az5.js +1372 -0
- package/dist/index-dm9q84c7.js +360 -0
- package/dist/index-f51mkh13.js +1088 -0
- package/dist/index-f86n1fpd.js +55 -0
- package/dist/index-fnk0tkw7.js +412 -0
- package/dist/index-g5aq66bj.js +1534 -0
- package/dist/index-gj5qh491.js +54 -0
- package/dist/index-gq39t0rx.js +895 -0
- package/dist/index-h5dqna7q.js +1410 -0
- package/dist/index-hjs9j2g9.js +895 -0
- package/dist/index-hn5nbxbt.js +147 -0
- package/dist/index-hpjh0qjx.js +1723 -0
- package/dist/index-hs6ekcfs.js +412 -0
- package/dist/index-jdzrvnfj.js +52 -0
- package/dist/index-jg720mq7.js +476 -0
- package/dist/index-jrzddxvt.js +2167 -0
- package/dist/index-kgstnk6g.js +239 -0
- package/dist/index-khnw972v.js +117 -0
- package/dist/index-kwqff3ba.js +1410 -0
- package/dist/index-m2v0fj08.js +74 -0
- package/dist/index-mjve6tqn.js +447 -0
- package/dist/index-mkxzgn0q.js +1372 -0
- package/dist/index-mzmq3v0d.js +1088 -0
- package/dist/index-ng9n3znd.js +1372 -0
- package/dist/index-nhbkm2ba.js +467 -0
- package/dist/index-nrfhk0k5.js +1088 -0
- package/dist/index-p0zppqxm.js +467 -0
- package/dist/index-pkxf6h87.js +895 -0
- package/dist/index-pqp4312v.js +52 -0
- package/dist/index-pw9jn6kz.js +574 -0
- package/dist/index-q31ne0xa.js +412 -0
- package/dist/index-qf2dkqxh.js +249 -0
- package/dist/index-qmtdf7k5.js +639 -0
- package/dist/index-qwgr4q7s.js +37 -0
- package/dist/index-rab2dfh3.js +494 -0
- package/dist/index-rz7rx80s.js +1410 -0
- package/dist/index-s37h3jgk.js +572 -0
- package/dist/index-sb705m7d.js +52 -0
- package/dist/index-syscwrjp.js +1576 -0
- package/dist/index-t14zr0ys.js +1063 -0
- package/dist/index-tjc99447.js +68 -0
- package/dist/index-v35460hf.js +574 -0
- package/dist/index-v7q00d1e.js +1410 -0
- package/dist/index-vkkmx4xe.js +1372 -0
- package/dist/index-vrps1gky.js +2202 -0
- package/dist/index-w4c9vmvg.js +1517 -0
- package/dist/index-wqd8n2qk.js +574 -0
- package/dist/index-x12e6fzy.js +476 -0
- package/dist/index-xagpz645.js +2199 -0
- package/dist/index-xbth1r6e.js +572 -0
- package/dist/index-xm9fqhcb.js +447 -0
- package/dist/index-y59hnmd0.js +132 -0
- package/dist/index-y7mkb00x.js +133 -0
- package/dist/index-z40mjts9.js +212 -0
- package/dist/index-z5k5bjc7.js +1218 -0
- package/dist/index-z73sytma.js +895 -0
- package/dist/index-zjv6apef.js +1410 -0
- package/dist/index.js +8 -8
- package/dist/init-cwpergap.js +180 -0
- package/dist/login-83bjfhvz.js +77 -0
- package/dist/login-ddw888xb.js +77 -0
- package/dist/login-e7pytkdc.js +77 -0
- package/dist/login-fe0brfcr.js +77 -0
- package/dist/login-h7sm5trm.js +77 -0
- package/dist/login-vd0m3xr4.js +77 -0
- package/dist/previews-2wfvsjfy.js +1337 -0
- package/dist/previews-31feb8r3.js +1337 -0
- package/dist/previews-3w4pxqby.js +1337 -0
- package/dist/previews-93ttrf5f.js +1337 -0
- package/dist/previews-bdrefjzx.js +1337 -0
- package/dist/previews-cfcn56b4.js +1337 -0
- package/dist/previews-mssq1hrm.js +1337 -0
- package/dist/previews-tcaz1gt8.js +1337 -0
- package/dist/productions-4h80j2c7.js +505 -0
- package/dist/productions-86jaqt7m.js +505 -0
- package/dist/productions-bn2q31my.js +505 -0
- package/dist/productions-dv8g7f6g.js +505 -0
- package/dist/productions-e2m9s4tr.js +505 -0
- package/dist/productions-fgshs1m7.js +505 -0
- package/dist/productions-hphmt68n.js +505 -0
- package/dist/productions-vhq7yx86.js +505 -0
- package/dist/runtime/index.js +8 -8
- package/dist/secrets/local-secrets.d.ts +46 -0
- package/dist/secrets/local-secrets.d.ts.map +1 -0
- package/dist/secrets-8wcj47nh.js +91 -0
- package/dist/secrets-b2ww34ta.js +91 -0
- package/dist/secrets-b7g4z621.js +91 -0
- package/dist/shims/local-media-bindings.d.ts +19 -0
- package/dist/shims/local-media-bindings.d.ts.map +1 -0
- package/dist/shims/local-worker-loader.d.ts +3 -0
- package/dist/shims/local-worker-loader.d.ts.map +1 -0
- package/dist/sveltekit/index.js +163 -26
- package/dist/sveltekit/local-bindings.d.ts +4 -0
- package/dist/sveltekit/local-bindings.d.ts.map +1 -0
- package/dist/sveltekit/platform.d.ts +8 -0
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/dist/test/ai-search.d.ts +39 -0
- package/dist/test/ai-search.d.ts.map +1 -0
- package/dist/test/binding-hints.d.ts.map +1 -1
- package/dist/test/cf.d.ts +3 -3
- package/dist/test/containers.d.ts +87 -0
- package/dist/test/containers.d.ts.map +1 -0
- package/dist/test/index.d.ts +4 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +2833 -543
- package/dist/test/local-worker-loader.d.ts +3 -0
- package/dist/test/local-worker-loader.d.ts.map +1 -0
- package/dist/test/offline-bindings.d.ts +65 -0
- package/dist/test/offline-bindings.d.ts.map +1 -0
- package/dist/test/queue.d.ts.map +1 -1
- package/dist/test/remote-ai.d.ts.map +1 -1
- package/dist/test/should-skip.d.ts +14 -0
- package/dist/test/should-skip.d.ts.map +1 -1
- package/dist/test/simple-context-bindings.d.ts.map +1 -1
- package/dist/test/simple-context-durable-objects.d.ts.map +1 -1
- package/dist/test/simple-context-gateway-script.d.ts +1 -1
- package/dist/test/simple-context-gateway-script.d.ts.map +1 -1
- package/dist/test/simple-context-lifecycle.d.ts.map +1 -1
- package/dist/test/simple-context-mfconfig.d.ts +4 -1
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -1
- package/dist/test/simple-context-multi-worker.d.ts.map +1 -1
- package/dist/test/simple-context-startup.d.ts.map +1 -1
- package/dist/test/tail.d.ts.map +1 -1
- package/dist/test/utilities/artifacts.d.ts +11 -0
- package/dist/test/utilities/artifacts.d.ts.map +1 -0
- package/dist/test/utilities/context.d.ts +39 -0
- package/dist/test/utilities/context.d.ts.map +1 -0
- package/dist/test/utilities/d1.d.ts +21 -0
- package/dist/test/utilities/d1.d.ts.map +1 -0
- package/dist/test/utilities/env.d.ts +40 -0
- package/dist/test/utilities/env.d.ts.map +1 -0
- package/dist/test/utilities/kv.d.ts +11 -0
- package/dist/test/utilities/kv.d.ts.map +1 -0
- package/dist/test/utilities/media.d.ts +16 -0
- package/dist/test/utilities/media.d.ts.map +1 -0
- package/dist/test/utilities/platform.d.ts +38 -0
- package/dist/test/utilities/platform.d.ts.map +1 -0
- package/dist/test/utilities/queue.d.ts +5 -0
- package/dist/test/utilities/queue.d.ts.map +1 -0
- package/dist/test/utilities/r2.d.ts +12 -0
- package/dist/test/utilities/r2.d.ts.map +1 -0
- package/dist/test/utilities/workflows.d.ts +26 -0
- package/dist/test/utilities/workflows.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +10 -106
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/types-2ejrbba1.js +695 -0
- package/dist/types-7jkbm95a.js +695 -0
- package/dist/types-a2fk9yns.js +695 -0
- package/dist/types-dyb3c6zw.js +695 -0
- package/dist/types-e2n9f3pd.js +695 -0
- package/dist/types-j4s6qcrc.js +695 -0
- package/dist/utils/send-email.d.ts.map +1 -1
- package/dist/utils/send-email.js +1 -1
- package/dist/vite/index.js +6 -6
- package/dist/vite/plugin-context.d.ts.map +1 -1
- package/dist/worker-663em30d.js +513 -0
- package/dist/worker-argxc7fb.js +513 -0
- package/dist/worker-entry/composed-worker.d.ts.map +1 -1
- package/dist/worker-entry/surface-paths.d.ts +2 -0
- package/dist/worker-entry/surface-paths.d.ts.map +1 -1
- package/dist/worker-fcdsnj14.js +513 -0
- package/dist/worker-fk42rzse.js +513 -0
- package/dist/worker-jkemk8d2.js +513 -0
- package/dist/worker-m4ze8djx.js +513 -0
- package/dist/worker-wnan5dca.js +513 -0
- package/dist/worker-yw3atfb1.js +513 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
- package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
- package/package.json +13 -12
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import {
|
|
2
|
+
browserBindingSchema,
|
|
3
|
+
getSingleBrowserBindingName,
|
|
4
|
+
normalizeArtifactsBinding,
|
|
5
|
+
normalizeCompatibilityFlags,
|
|
6
|
+
normalizeD1Binding,
|
|
7
|
+
normalizeDOBinding,
|
|
8
|
+
normalizeDispatchNamespaceBinding,
|
|
9
|
+
normalizeHyperdriveBinding,
|
|
10
|
+
normalizeImagesBinding,
|
|
11
|
+
normalizeKVBinding,
|
|
12
|
+
normalizeMediaBinding,
|
|
13
|
+
normalizeMtlsCertificateBinding,
|
|
14
|
+
normalizePipelineBinding,
|
|
15
|
+
normalizeWorkflowBinding,
|
|
16
|
+
resolveConfigForEnvironment
|
|
17
|
+
} from "./index-g5aq66bj.js";
|
|
18
|
+
import {
|
|
19
|
+
__require
|
|
20
|
+
} from "./index-37x76zdn.js";
|
|
21
|
+
|
|
22
|
+
// src/config/compiler/paths.ts
|
|
23
|
+
import { basename, isAbsolute, relative, resolve } from "pathe";
|
|
24
|
+
function stringifyConfig(config) {
|
|
25
|
+
const header = `// Generated by devflare — Do not edit directly
|
|
26
|
+
// Edit devflare.config.ts instead
|
|
27
|
+
|
|
28
|
+
`;
|
|
29
|
+
return header + JSON.stringify(config, null, "\t");
|
|
30
|
+
}
|
|
31
|
+
function rebasePathForConfigDir(projectRoot, configDir, pathValue) {
|
|
32
|
+
const absolutePath = isAbsolute(pathValue) ? pathValue : resolve(projectRoot, pathValue);
|
|
33
|
+
return relative(configDir, absolutePath).replace(/\\/g, "/");
|
|
34
|
+
}
|
|
35
|
+
function isLocalContainerPath(pathValue) {
|
|
36
|
+
return pathValue === "Dockerfile" || pathValue.startsWith(".") || pathValue.startsWith("/") || pathValue.startsWith("\\") || isAbsolute(pathValue) || pathValue.endsWith("/Dockerfile") || pathValue.endsWith("\\Dockerfile");
|
|
37
|
+
}
|
|
38
|
+
function pathIsInsideDirectory(directoryPath, candidatePath) {
|
|
39
|
+
const normalizedDirectoryPath = directoryPath.replace(/\\/g, "/");
|
|
40
|
+
const normalizedCandidatePath = candidatePath.replace(/\\/g, "/");
|
|
41
|
+
return normalizedCandidatePath === normalizedDirectoryPath || normalizedCandidatePath.startsWith(`${normalizedDirectoryPath}/`);
|
|
42
|
+
}
|
|
43
|
+
function isolateViteBuildOutputPaths(projectRoot, config) {
|
|
44
|
+
const assetsDirectory = config.assets?.directory;
|
|
45
|
+
if (!assetsDirectory) {
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
const isolatedAssetsDirectoryPath = resolve(projectRoot, ".devflare", "vite-build-output", basename(assetsDirectory));
|
|
49
|
+
const isolatedAssetsDirectory = relative(projectRoot, isolatedAssetsDirectoryPath).replace(/\\/g, "/");
|
|
50
|
+
const isolatedConfig = {
|
|
51
|
+
...config,
|
|
52
|
+
assets: config.assets ? {
|
|
53
|
+
...config.assets,
|
|
54
|
+
directory: isolatedAssetsDirectory
|
|
55
|
+
} : config.assets
|
|
56
|
+
};
|
|
57
|
+
if (!config.main) {
|
|
58
|
+
return isolatedConfig;
|
|
59
|
+
}
|
|
60
|
+
const originalAssetsDirectoryPath = resolve(projectRoot, assetsDirectory);
|
|
61
|
+
const originalMainEntryPath = resolve(projectRoot, config.main);
|
|
62
|
+
if (!pathIsInsideDirectory(originalAssetsDirectoryPath, originalMainEntryPath)) {
|
|
63
|
+
return isolatedConfig;
|
|
64
|
+
}
|
|
65
|
+
const relativeMainEntryPath = relative(originalAssetsDirectoryPath, originalMainEntryPath);
|
|
66
|
+
const isolatedMainEntryPath = resolve(isolatedAssetsDirectoryPath, relativeMainEntryPath);
|
|
67
|
+
return {
|
|
68
|
+
...isolatedConfig,
|
|
69
|
+
main: relative(projectRoot, isolatedMainEntryPath).replace(/\\/g, "/")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function rebaseWranglerConfigPaths(projectRoot, configDir, config) {
|
|
73
|
+
return {
|
|
74
|
+
...config,
|
|
75
|
+
...config.main ? { main: rebasePathForConfigDir(projectRoot, configDir, config.main) } : {},
|
|
76
|
+
...config.assets?.directory ? {
|
|
77
|
+
assets: {
|
|
78
|
+
...config.assets,
|
|
79
|
+
directory: rebasePathForConfigDir(projectRoot, configDir, config.assets.directory)
|
|
80
|
+
}
|
|
81
|
+
} : {},
|
|
82
|
+
...config.containers ? {
|
|
83
|
+
containers: config.containers.map((container) => ({
|
|
84
|
+
...container,
|
|
85
|
+
image: isLocalContainerPath(container.image) ? rebasePathForConfigDir(projectRoot, configDir, container.image) : container.image,
|
|
86
|
+
...container.image_build_context && {
|
|
87
|
+
image_build_context: rebasePathForConfigDir(projectRoot, configDir, container.image_build_context)
|
|
88
|
+
}
|
|
89
|
+
}))
|
|
90
|
+
} : {}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function writeWranglerConfig(cwd, config, filename = "wrangler.jsonc") {
|
|
94
|
+
const { resolve: resolve2 } = await import("pathe");
|
|
95
|
+
const fs = await import("node:fs/promises");
|
|
96
|
+
try {
|
|
97
|
+
await fs.mkdir(cwd, { recursive: true });
|
|
98
|
+
} catch {}
|
|
99
|
+
const content = stringifyConfig(config);
|
|
100
|
+
const wranglerPath = resolve2(cwd, filename);
|
|
101
|
+
await fs.writeFile(wranglerPath, content, "utf-8");
|
|
102
|
+
return wranglerPath;
|
|
103
|
+
}
|
|
104
|
+
async function readWranglerConfig(filePath) {
|
|
105
|
+
const fs = await import("node:fs/promises");
|
|
106
|
+
const { parse } = await import("jsonc-parser");
|
|
107
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
108
|
+
const parsedConfig = parse(content);
|
|
109
|
+
if (!parsedConfig || typeof parsedConfig !== "object") {
|
|
110
|
+
throw new Error(`Could not parse Wrangler config at ${filePath}.`);
|
|
111
|
+
}
|
|
112
|
+
return parsedConfig;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/config/compiler/bindings.ts
|
|
116
|
+
function getWranglerD1DatabaseBinding(bindingName, bindingConfig, options = {}) {
|
|
117
|
+
const normalized = normalizeD1Binding(bindingConfig);
|
|
118
|
+
if (normalized.databaseId) {
|
|
119
|
+
return {
|
|
120
|
+
binding: bindingName,
|
|
121
|
+
database_id: normalized.databaseId
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (options.preserveNamedBindings && normalized.name) {
|
|
125
|
+
return {
|
|
126
|
+
binding: bindingName,
|
|
127
|
+
database_name: normalized.name
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
throw new Error(`D1 binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
131
|
+
}
|
|
132
|
+
function getWranglerKVNamespaceBinding(bindingName, bindingConfig, options = {}) {
|
|
133
|
+
const normalized = normalizeKVBinding(bindingConfig);
|
|
134
|
+
if (normalized.namespaceId) {
|
|
135
|
+
return {
|
|
136
|
+
binding: bindingName,
|
|
137
|
+
id: normalized.namespaceId
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (options.preserveNamedBindings && normalized.name) {
|
|
141
|
+
return {
|
|
142
|
+
binding: bindingName,
|
|
143
|
+
name: normalized.name
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`KV binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
147
|
+
}
|
|
148
|
+
function getWranglerHyperdriveBinding(bindingName, bindingConfig, options = {}) {
|
|
149
|
+
const normalized = normalizeHyperdriveBinding(bindingConfig);
|
|
150
|
+
if (normalized.configurationId) {
|
|
151
|
+
return {
|
|
152
|
+
binding: bindingName,
|
|
153
|
+
id: normalized.configurationId,
|
|
154
|
+
...normalized.localConnectionString && {
|
|
155
|
+
localConnectionString: normalized.localConnectionString
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (options.preserveNamedBindings && normalized.name) {
|
|
160
|
+
return {
|
|
161
|
+
binding: bindingName,
|
|
162
|
+
name: normalized.name,
|
|
163
|
+
...normalized.localConnectionString && {
|
|
164
|
+
localConnectionString: normalized.localConnectionString
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
throw new Error(`Hyperdrive binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
169
|
+
}
|
|
170
|
+
function getWranglerBrowserBinding(browserBindings) {
|
|
171
|
+
if (!browserBindings) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const parsed = browserBindingSchema.parse(browserBindings);
|
|
175
|
+
const bindingName = getSingleBrowserBindingName(parsed);
|
|
176
|
+
if (!bindingName) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const bindingConfig = parsed[bindingName];
|
|
180
|
+
return {
|
|
181
|
+
binding: bindingName,
|
|
182
|
+
...typeof bindingConfig === "object" && bindingConfig.remote !== undefined && {
|
|
183
|
+
remote: bindingConfig.remote
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function compileBindings(bindings, result, options = {}) {
|
|
188
|
+
if (bindings.kv) {
|
|
189
|
+
result.kv_namespaces = Object.entries(bindings.kv).map(([binding, namespace]) => {
|
|
190
|
+
return getWranglerKVNamespaceBinding(binding, namespace, options);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (bindings.d1) {
|
|
194
|
+
result.d1_databases = Object.entries(bindings.d1).map(([binding, database_id]) => {
|
|
195
|
+
return getWranglerD1DatabaseBinding(binding, database_id, options);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (bindings.r2) {
|
|
199
|
+
result.r2_buckets = Object.entries(bindings.r2).map(([binding, bucket_name]) => ({
|
|
200
|
+
binding,
|
|
201
|
+
bucket_name
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
if (bindings.durableObjects) {
|
|
205
|
+
result.durable_objects = {
|
|
206
|
+
bindings: Object.entries(bindings.durableObjects).map(([name, config]) => {
|
|
207
|
+
const normalized = normalizeDOBinding(config);
|
|
208
|
+
const binding = {
|
|
209
|
+
name,
|
|
210
|
+
class_name: normalized.className
|
|
211
|
+
};
|
|
212
|
+
if (normalized.kind === "cross-worker" && normalized.scriptName) {
|
|
213
|
+
binding.script_name = normalized.scriptName;
|
|
214
|
+
}
|
|
215
|
+
return binding;
|
|
216
|
+
})
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
if (bindings.queues) {
|
|
220
|
+
result.queues = {};
|
|
221
|
+
if (bindings.queues.producers) {
|
|
222
|
+
result.queues.producers = Object.entries(bindings.queues.producers).map(([binding, queue]) => ({ binding, queue }));
|
|
223
|
+
}
|
|
224
|
+
if (bindings.queues.consumers) {
|
|
225
|
+
result.queues.consumers = bindings.queues.consumers.map((consumer) => ({
|
|
226
|
+
queue: consumer.queue,
|
|
227
|
+
...consumer.maxBatchSize && { max_batch_size: consumer.maxBatchSize },
|
|
228
|
+
...consumer.maxBatchTimeout && { max_batch_timeout: consumer.maxBatchTimeout },
|
|
229
|
+
...consumer.maxRetries && { max_retries: consumer.maxRetries },
|
|
230
|
+
...consumer.deadLetterQueue && { dead_letter_queue: consumer.deadLetterQueue },
|
|
231
|
+
...consumer.maxConcurrency && { max_concurrency: consumer.maxConcurrency },
|
|
232
|
+
...consumer.retryDelay && { retry_delay: consumer.retryDelay }
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (bindings.rateLimits) {
|
|
237
|
+
result.ratelimits = Object.entries(bindings.rateLimits).map(([name, config]) => ({
|
|
238
|
+
name,
|
|
239
|
+
namespace_id: config.namespaceId,
|
|
240
|
+
simple: {
|
|
241
|
+
limit: config.simple.limit,
|
|
242
|
+
period: config.simple.period
|
|
243
|
+
}
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
if (bindings.versionMetadata) {
|
|
247
|
+
result.version_metadata = {
|
|
248
|
+
binding: bindings.versionMetadata.binding
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
if (bindings.workerLoaders) {
|
|
252
|
+
result.worker_loaders = Object.keys(bindings.workerLoaders).map((binding) => ({ binding }));
|
|
253
|
+
}
|
|
254
|
+
if (bindings.mtlsCertificates) {
|
|
255
|
+
result.mtls_certificates = Object.entries(bindings.mtlsCertificates).map(([binding, config]) => {
|
|
256
|
+
const normalized = normalizeMtlsCertificateBinding(config);
|
|
257
|
+
return {
|
|
258
|
+
binding,
|
|
259
|
+
certificate_id: normalized.certificateId,
|
|
260
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (bindings.dispatchNamespaces) {
|
|
265
|
+
result.dispatch_namespaces = Object.entries(bindings.dispatchNamespaces).map(([binding, config]) => {
|
|
266
|
+
const normalized = normalizeDispatchNamespaceBinding(config);
|
|
267
|
+
return {
|
|
268
|
+
binding,
|
|
269
|
+
namespace: normalized.namespace,
|
|
270
|
+
...normalized.outbound && { outbound: normalized.outbound },
|
|
271
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (bindings.workflows) {
|
|
276
|
+
result.workflows = Object.entries(bindings.workflows).map(([binding, config]) => {
|
|
277
|
+
const normalized = normalizeWorkflowBinding(config);
|
|
278
|
+
return {
|
|
279
|
+
binding,
|
|
280
|
+
name: normalized.name,
|
|
281
|
+
class_name: normalized.className,
|
|
282
|
+
...normalized.scriptName && { script_name: normalized.scriptName },
|
|
283
|
+
...normalized.remote !== undefined && { remote: normalized.remote },
|
|
284
|
+
...normalized.limits && { limits: normalized.limits }
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (bindings.pipelines) {
|
|
289
|
+
result.pipelines = Object.entries(bindings.pipelines).map(([binding, config]) => {
|
|
290
|
+
const normalized = normalizePipelineBinding(config);
|
|
291
|
+
return {
|
|
292
|
+
binding,
|
|
293
|
+
pipeline: normalized.pipeline,
|
|
294
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (bindings.images) {
|
|
299
|
+
const [entry] = Object.entries(bindings.images);
|
|
300
|
+
if (entry) {
|
|
301
|
+
const [binding, config] = entry;
|
|
302
|
+
const normalized = normalizeImagesBinding(binding, config);
|
|
303
|
+
result.images = {
|
|
304
|
+
binding: normalized.binding,
|
|
305
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (bindings.media) {
|
|
310
|
+
const [entry] = Object.entries(bindings.media);
|
|
311
|
+
if (entry) {
|
|
312
|
+
const [binding, config] = entry;
|
|
313
|
+
const normalized = normalizeMediaBinding(binding, config);
|
|
314
|
+
result.media = {
|
|
315
|
+
binding: normalized.binding,
|
|
316
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (bindings.artifacts) {
|
|
321
|
+
result.artifacts = Object.entries(bindings.artifacts).map(([binding, config]) => {
|
|
322
|
+
const normalized = normalizeArtifactsBinding(config);
|
|
323
|
+
return {
|
|
324
|
+
binding,
|
|
325
|
+
namespace: normalized.namespace,
|
|
326
|
+
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
if (bindings.secretsStore) {
|
|
331
|
+
result.secrets_store_secrets = Object.entries(bindings.secretsStore).map(([binding, config]) => ({
|
|
332
|
+
binding,
|
|
333
|
+
store_id: config.storeId,
|
|
334
|
+
secret_name: config.secretName
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
if (bindings.services) {
|
|
338
|
+
result.services = Object.entries(bindings.services).map(([binding, config]) => ({
|
|
339
|
+
binding,
|
|
340
|
+
service: config.service,
|
|
341
|
+
...config.entrypoint && { entrypoint: config.entrypoint },
|
|
342
|
+
...config.environment && { environment: config.environment }
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
if (bindings.ai?.binding) {
|
|
346
|
+
result.ai = {
|
|
347
|
+
binding: bindings.ai.binding,
|
|
348
|
+
...bindings.ai.remote !== undefined && { remote: bindings.ai.remote },
|
|
349
|
+
...bindings.ai.staging !== undefined && { staging: bindings.ai.staging }
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
if (bindings.aiSearchNamespaces) {
|
|
353
|
+
result.ai_search_namespaces = Object.entries(bindings.aiSearchNamespaces).map(([binding, config]) => ({
|
|
354
|
+
binding,
|
|
355
|
+
namespace: config.namespace,
|
|
356
|
+
...config.remote !== undefined && { remote: config.remote }
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
if (bindings.aiSearch) {
|
|
360
|
+
result.ai_search = Object.entries(bindings.aiSearch).map(([binding, config]) => ({
|
|
361
|
+
binding,
|
|
362
|
+
instance_name: config.instanceName,
|
|
363
|
+
...config.remote !== undefined && { remote: config.remote }
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
if (bindings.vectorize) {
|
|
367
|
+
result.vectorize = Object.entries(bindings.vectorize).map(([binding, config]) => ({
|
|
368
|
+
binding,
|
|
369
|
+
index_name: config.indexName,
|
|
370
|
+
...config.remote !== undefined && { remote: config.remote }
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
if (bindings.hyperdrive) {
|
|
374
|
+
result.hyperdrive = Object.entries(bindings.hyperdrive).map(([binding, config]) => {
|
|
375
|
+
return getWranglerHyperdriveBinding(binding, config, options);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
const browserBinding = getWranglerBrowserBinding(bindings.browser);
|
|
379
|
+
if (browserBinding) {
|
|
380
|
+
result.browser = browserBinding;
|
|
381
|
+
}
|
|
382
|
+
if (bindings.analyticsEngine) {
|
|
383
|
+
result.analytics_engine_datasets = Object.entries(bindings.analyticsEngine).map(([binding, config]) => ({
|
|
384
|
+
binding,
|
|
385
|
+
dataset: config.dataset
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
if (bindings.sendEmail) {
|
|
389
|
+
result.send_email = Object.entries(bindings.sendEmail).map(([name, config]) => ({
|
|
390
|
+
name,
|
|
391
|
+
...config.destinationAddress && {
|
|
392
|
+
destination_address: config.destinationAddress
|
|
393
|
+
},
|
|
394
|
+
...config.allowedDestinationAddresses && {
|
|
395
|
+
allowed_destination_addresses: config.allowedDestinationAddresses
|
|
396
|
+
},
|
|
397
|
+
...config.allowedSenderAddresses && {
|
|
398
|
+
allowed_sender_addresses: config.allowedSenderAddresses
|
|
399
|
+
}
|
|
400
|
+
}));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// src/config/compiler/core-helpers.ts
|
|
405
|
+
function compileWranglerMigrations(migrations) {
|
|
406
|
+
return migrations.map((migration) => ({
|
|
407
|
+
tag: migration.tag,
|
|
408
|
+
...migration.new_classes && { new_classes: migration.new_classes },
|
|
409
|
+
...migration.renamed_classes && {
|
|
410
|
+
renamed_classes: migration.renamed_classes.map((renamedClass) => ({
|
|
411
|
+
from: renamedClass.from,
|
|
412
|
+
to: renamedClass.to
|
|
413
|
+
}))
|
|
414
|
+
},
|
|
415
|
+
...migration.deleted_classes && { deleted_classes: migration.deleted_classes },
|
|
416
|
+
...migration.new_sqlite_classes && { new_sqlite_classes: migration.new_sqlite_classes }
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
function compileModuleOptions(config, result) {
|
|
420
|
+
if (config.rules && config.rules.length > 0) {
|
|
421
|
+
result.rules = config.rules;
|
|
422
|
+
}
|
|
423
|
+
if (config.findAdditionalModules !== undefined) {
|
|
424
|
+
result.find_additional_modules = config.findAdditionalModules;
|
|
425
|
+
}
|
|
426
|
+
if (config.baseDir) {
|
|
427
|
+
result.base_dir = config.baseDir;
|
|
428
|
+
}
|
|
429
|
+
if (config.preserveFileNames !== undefined) {
|
|
430
|
+
result.preserve_file_names = config.preserveFileNames;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function compileContainers(config, result) {
|
|
434
|
+
if (!config.containers || config.containers.length === 0) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
result.containers = config.containers.map((container) => ({
|
|
438
|
+
class_name: container.className,
|
|
439
|
+
image: container.image,
|
|
440
|
+
...container.maxInstances !== undefined && { max_instances: container.maxInstances },
|
|
441
|
+
...container.instanceType && { instance_type: container.instanceType },
|
|
442
|
+
...container.name && { name: container.name },
|
|
443
|
+
...container.imageBuildContext && { image_build_context: container.imageBuildContext },
|
|
444
|
+
...container.imageVars && { image_vars: container.imageVars },
|
|
445
|
+
...container.rolloutActiveGracePeriod !== undefined && {
|
|
446
|
+
rollout_active_grace_period: container.rolloutActiveGracePeriod
|
|
447
|
+
},
|
|
448
|
+
...container.rolloutStepPercentage !== undefined && {
|
|
449
|
+
rollout_step_percentage: container.rolloutStepPercentage
|
|
450
|
+
}
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// src/config/local-dev-vars.ts
|
|
455
|
+
import { isAbsolute as isAbsolute2, resolve as resolve2 } from "pathe";
|
|
456
|
+
function resolveConfigPath(cwd, configPath) {
|
|
457
|
+
if (!configPath) {
|
|
458
|
+
return resolve2(cwd, "devflare.config.ts");
|
|
459
|
+
}
|
|
460
|
+
return isAbsolute2(configPath) ? configPath : resolve2(cwd, configPath);
|
|
461
|
+
}
|
|
462
|
+
function stringifyBindingValue(value) {
|
|
463
|
+
if (typeof value === "string") {
|
|
464
|
+
return value;
|
|
465
|
+
}
|
|
466
|
+
return JSON.stringify(value);
|
|
467
|
+
}
|
|
468
|
+
function toWranglerSecretsConfig(secrets) {
|
|
469
|
+
if (!secrets) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const required = Object.entries(secrets).filter(([, config]) => config.required !== false).map(([name]) => name).sort();
|
|
473
|
+
return required.length > 0 ? { required } : undefined;
|
|
474
|
+
}
|
|
475
|
+
async function loadLocalDevVars(options) {
|
|
476
|
+
const wrangler = await import("wrangler");
|
|
477
|
+
const configPath = resolveConfigPath(options.cwd, options.configPath);
|
|
478
|
+
const activeEnvironment = options.environment ?? process.env.CLOUDFLARE_ENV;
|
|
479
|
+
const bindings = wrangler.unstable_getVarsForDev(configPath, undefined, options.vars ?? {}, activeEnvironment, options.silent ?? true, toWranglerSecretsConfig(options.secrets));
|
|
480
|
+
return Object.fromEntries(Object.entries(bindings).map(([name, binding]) => [name, stringifyBindingValue(binding.value)]));
|
|
481
|
+
}
|
|
482
|
+
async function applyLocalDevVarsToConfig(config, options) {
|
|
483
|
+
const vars = await loadLocalDevVars({
|
|
484
|
+
...options,
|
|
485
|
+
vars: config.vars,
|
|
486
|
+
secrets: config.secrets
|
|
487
|
+
});
|
|
488
|
+
if (Object.keys(vars).length === 0) {
|
|
489
|
+
return config;
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
...config,
|
|
493
|
+
vars
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/config/compiler/do-workers.ts
|
|
498
|
+
import { resolve as resolve3 } from "pathe";
|
|
499
|
+
|
|
500
|
+
// src/config/compiler.ts
|
|
501
|
+
function compileConfig(config, environment) {
|
|
502
|
+
return compileConfigInternal(config, environment);
|
|
503
|
+
}
|
|
504
|
+
function compileBuildConfig(config, environment, options = {}) {
|
|
505
|
+
return compileConfigInternal(config, environment, {
|
|
506
|
+
preserveNamedBindings: true,
|
|
507
|
+
alreadyResolved: options.alreadyResolved
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function compileConfigInternal(config, environment, options = {}) {
|
|
511
|
+
const resolvedConfig = options.alreadyResolved ? config : resolveConfigForEnvironment(config, environment);
|
|
512
|
+
const mergedConfig = {
|
|
513
|
+
...resolvedConfig,
|
|
514
|
+
compatibilityFlags: normalizeCompatibilityFlags(resolvedConfig.compatibilityFlags)
|
|
515
|
+
};
|
|
516
|
+
const result = {
|
|
517
|
+
name: mergedConfig.name,
|
|
518
|
+
compatibility_date: mergedConfig.compatibilityDate,
|
|
519
|
+
preview_urls: true,
|
|
520
|
+
workers_dev: true
|
|
521
|
+
};
|
|
522
|
+
if (mergedConfig.accountId) {
|
|
523
|
+
result.account_id = mergedConfig.accountId;
|
|
524
|
+
}
|
|
525
|
+
const mainEntry = mergedConfig.files?.fetch;
|
|
526
|
+
if (typeof mainEntry === "string") {
|
|
527
|
+
result.main = mainEntry;
|
|
528
|
+
}
|
|
529
|
+
compileModuleOptions(mergedConfig, result);
|
|
530
|
+
if (mergedConfig.compatibilityFlags && mergedConfig.compatibilityFlags.length > 0) {
|
|
531
|
+
result.compatibility_flags = mergedConfig.compatibilityFlags;
|
|
532
|
+
}
|
|
533
|
+
if (mergedConfig.bindings) {
|
|
534
|
+
compileBindings(mergedConfig.bindings, result, options);
|
|
535
|
+
}
|
|
536
|
+
if (mergedConfig.triggers?.crons && mergedConfig.triggers.crons.length > 0) {
|
|
537
|
+
result.triggers = { crons: mergedConfig.triggers.crons };
|
|
538
|
+
}
|
|
539
|
+
if (mergedConfig.tailConsumers && mergedConfig.tailConsumers.length > 0) {
|
|
540
|
+
result.tail_consumers = mergedConfig.tailConsumers.map((consumer) => typeof consumer === "string" ? { service: consumer } : {
|
|
541
|
+
service: consumer.service,
|
|
542
|
+
...consumer.environment && { environment: consumer.environment }
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
if (mergedConfig.vars && Object.keys(mergedConfig.vars).length > 0) {
|
|
546
|
+
result.vars = mergedConfig.vars;
|
|
547
|
+
}
|
|
548
|
+
const secrets = toWranglerSecretsConfig(mergedConfig.secrets);
|
|
549
|
+
if (secrets) {
|
|
550
|
+
result.secrets = secrets;
|
|
551
|
+
}
|
|
552
|
+
if (mergedConfig.routes && mergedConfig.routes.length > 0) {
|
|
553
|
+
result.routes = mergedConfig.routes.map((route) => ({
|
|
554
|
+
pattern: route.pattern,
|
|
555
|
+
...route.zone_name && { zone_name: route.zone_name },
|
|
556
|
+
...route.zone_id && { zone_id: route.zone_id },
|
|
557
|
+
...route.custom_domain !== undefined && { custom_domain: route.custom_domain }
|
|
558
|
+
}));
|
|
559
|
+
}
|
|
560
|
+
if (mergedConfig.assets?.directory) {
|
|
561
|
+
result.assets = {
|
|
562
|
+
directory: mergedConfig.assets.directory,
|
|
563
|
+
...mergedConfig.assets.binding && { binding: mergedConfig.assets.binding },
|
|
564
|
+
...mergedConfig.assets.html_handling && {
|
|
565
|
+
html_handling: mergedConfig.assets.html_handling
|
|
566
|
+
},
|
|
567
|
+
...mergedConfig.assets.not_found_handling && {
|
|
568
|
+
not_found_handling: mergedConfig.assets.not_found_handling
|
|
569
|
+
},
|
|
570
|
+
...mergedConfig.assets.run_worker_first !== undefined && {
|
|
571
|
+
run_worker_first: mergedConfig.assets.run_worker_first
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
if (mergedConfig.placement) {
|
|
576
|
+
result.placement = mergedConfig.placement;
|
|
577
|
+
}
|
|
578
|
+
if (mergedConfig.observability) {
|
|
579
|
+
result.observability = mergedConfig.observability;
|
|
580
|
+
}
|
|
581
|
+
if (mergedConfig.limits) {
|
|
582
|
+
result.limits = mergedConfig.limits;
|
|
583
|
+
}
|
|
584
|
+
compileContainers(mergedConfig, result);
|
|
585
|
+
if (mergedConfig.migrations && mergedConfig.migrations.length > 0) {
|
|
586
|
+
result.migrations = compileWranglerMigrations(mergedConfig.migrations);
|
|
587
|
+
}
|
|
588
|
+
if (mergedConfig.wrangler?.passthrough) {
|
|
589
|
+
Object.assign(result, mergedConfig.wrangler.passthrough);
|
|
590
|
+
}
|
|
591
|
+
return result;
|
|
592
|
+
}
|
|
593
|
+
function compileToProgrammaticConfig(config, environment, options = {}) {
|
|
594
|
+
return options.preserveNamedBindings ? compileBuildConfig(config, environment) : compileConfig(config, environment);
|
|
595
|
+
}
|
|
596
|
+
// src/config/service-bindings-validation.ts
|
|
597
|
+
class ServiceBindingValidationError extends Error {
|
|
598
|
+
code = "SERVICE_BINDING_VALIDATION_ERROR";
|
|
599
|
+
missing;
|
|
600
|
+
constructor(missing, accountId) {
|
|
601
|
+
super(`Service binding(s) reference worker(s) that do not exist in Cloudflare account ${accountId}: ` + missing.join(", ") + `. Check the 'services' map in devflare.config.ts for typos or deploy the target worker(s) first.`);
|
|
602
|
+
this.name = "ServiceBindingValidationError";
|
|
603
|
+
this.missing = missing;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
function collectReferencedServiceNames(config) {
|
|
607
|
+
const services = config.bindings?.services;
|
|
608
|
+
if (!services) {
|
|
609
|
+
return [];
|
|
610
|
+
}
|
|
611
|
+
const names = new Set;
|
|
612
|
+
for (const binding of Object.values(services)) {
|
|
613
|
+
if (binding && typeof binding === "object" && typeof binding.service === "string") {
|
|
614
|
+
const name = binding.service.trim();
|
|
615
|
+
if (name.length > 0) {
|
|
616
|
+
names.add(name);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return [...names];
|
|
621
|
+
}
|
|
622
|
+
async function validateServiceBindings(config, accountId, options) {
|
|
623
|
+
const referenced = collectReferencedServiceNames(config);
|
|
624
|
+
if (referenced.length === 0) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const selfName = options.selfWorkerName?.trim();
|
|
628
|
+
const toValidate = selfName ? referenced.filter((name) => name !== selfName) : referenced;
|
|
629
|
+
if (toValidate.length === 0) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
const workers = await options.listWorkers(accountId);
|
|
633
|
+
const workerNames = new Set(workers.map((worker) => worker.name));
|
|
634
|
+
const missing = toValidate.filter((name) => !workerNames.has(name));
|
|
635
|
+
if (missing.length > 0) {
|
|
636
|
+
throw new ServiceBindingValidationError(missing, accountId);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
export { applyLocalDevVarsToConfig, stringifyConfig, isolateViteBuildOutputPaths, rebaseWranglerConfigPaths, writeWranglerConfig, readWranglerConfig, compileConfig, compileBuildConfig, compileToProgrammaticConfig, ServiceBindingValidationError, validateServiceBindings };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/utils/glob.ts
|
|
2
|
+
import { globby, globbySync } from "globby";
|
|
3
|
+
var DEFAULT_DO_PATTERN = "**/do.*.{ts,js}";
|
|
4
|
+
var DEFAULT_ENTRYPOINT_PATTERN = "**/ep.*.{ts,js}";
|
|
5
|
+
var DEFAULT_WORKFLOW_PATTERN = "**/wf.*.{ts,js}";
|
|
6
|
+
async function findFiles(pattern, options) {
|
|
7
|
+
const { cwd, absolute = true, gitignore = true } = options;
|
|
8
|
+
return globby(pattern, {
|
|
9
|
+
cwd,
|
|
10
|
+
absolute,
|
|
11
|
+
gitignore,
|
|
12
|
+
ignore: [
|
|
13
|
+
"**/node_modules/**",
|
|
14
|
+
"**/.devflare/**",
|
|
15
|
+
"**/dist/**",
|
|
16
|
+
"**/build/**",
|
|
17
|
+
"**/.git/**"
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function findFilesSync(pattern, options) {
|
|
22
|
+
const { cwd, absolute = true, gitignore = true } = options;
|
|
23
|
+
return globbySync(pattern, {
|
|
24
|
+
cwd,
|
|
25
|
+
absolute,
|
|
26
|
+
gitignore,
|
|
27
|
+
ignore: [
|
|
28
|
+
"**/node_modules/**",
|
|
29
|
+
"**/.devflare/**",
|
|
30
|
+
"**/dist/**",
|
|
31
|
+
"**/build/**",
|
|
32
|
+
"**/.git/**"
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { DEFAULT_DO_PATTERN, DEFAULT_ENTRYPOINT_PATTERN, DEFAULT_WORKFLOW_PATTERN, findFiles, findFilesSync };
|