void 0.20.3 → 0.21.1
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 +2 -2
- package/dist/agents-gni4eqBu.mjs +111 -0
- package/dist/auth-3sGB0zJ1.mjs +22 -0
- package/dist/{auth-DPl6kck4.mjs → auth-B9_D6ygs.mjs} +6 -241
- package/dist/auth-CAw7zHqj.mjs +2 -0
- package/dist/auth-client-BWBT8HLp.mjs +6 -0
- package/dist/auth-client-Bawdj38n.d.mts +7 -0
- package/dist/auth-client-react-7GFffu8R.d.mts +7 -0
- package/dist/auth-client-react-CMLwT2xI.mjs +6 -0
- package/dist/auth-client-solid-DyTFL4cq.d.mts +7 -0
- package/dist/auth-client-solid-UoreJWZG.mjs +6 -0
- package/dist/auth-client-svelte-Cv_WvrRk.mjs +6 -0
- package/dist/auth-client-svelte-zetW0KIH.d.mts +7 -0
- package/dist/auth-client-vue-CFk7Xbv3.mjs +6 -0
- package/dist/auth-client-vue-bChShbQP.d.mts +7 -0
- package/dist/{auth-cmd-CzwquNiP.mjs → auth-cmd-g_ymMkUe.mjs} +5 -5
- package/dist/{auth-link-ElDTgF7j.mjs → auth-link-DFvxIyZi.mjs} +5 -5
- package/dist/{better-auth-shared-DSCeohOK.d.mts → better-auth-shared-BoVwA5Vm.d.mts} +1 -6
- package/dist/{better-auth-shared-CYw1T3k4.mjs → better-auth-shared-syGYYmnY.mjs} +1 -1
- package/dist/{build-cmd-BpJe6boP.mjs → build-cmd-wJAv808h.mjs} +6 -4
- package/dist/{cache-D98YTqeE.mjs → cache-Be0Fu5Ka.mjs} +6 -4
- package/dist/{cancel-deploy-CPbEQLMG.mjs → cancel-deploy-BgmyOwhe.mjs} +5 -3
- package/dist/cf-access-rAZxzMkL.mjs +181 -0
- package/dist/cf-build-output-CTdlo6Rt.mjs +520 -0
- package/dist/cli/cf-compat.d.mts +1 -0
- package/dist/cli/cf-compat.mjs +944 -0
- package/dist/cli/cli.mjs +60 -38
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-DAAivdid.mjs +2 -0
- package/dist/{client-BQBrZoCX.mjs → client-PdAJ-F0t.mjs} +6 -12
- package/dist/{cloudflare-auth-6M5llVPC.mjs → cloudflare-auth-BCmTc1X_.mjs} +13 -44
- package/dist/{cloudflare-cmd-4RPGN3KB.mjs → cloudflare-cmd-D6PrKn7o.mjs} +4 -7
- package/dist/{cloudflare-connect-t1UU5svD.mjs → cloudflare-connect-DloREDlc.mjs} +6 -6
- package/dist/cloudflare-operations-BHNJVDbN.mjs +2 -0
- package/dist/{cloudflare-operations-BzWnlC1_.mjs → cloudflare-operations-CPEdHYhM.mjs} +37 -39
- package/dist/cloudflare-user-output-Q-k0QoNQ.mjs +20 -0
- package/dist/collect-DAUItMDS.mjs +2 -0
- package/dist/collect-DXHNWHcT.mjs +48 -0
- package/dist/config--T87TD8T.mjs +2 -0
- package/dist/{config-NOG_U1aK.mjs → config-BSe70f4T.mjs} +4 -6
- package/dist/config-DDIFxQYx.mjs +2 -0
- package/dist/{config-uNGuFsI2.mjs → config-Dxr6cTXn.mjs} +22 -37
- package/dist/config-DywxBLQC.d.mts +185 -0
- package/dist/config-entry.d.mts +6 -0
- package/dist/config-entry.mjs +7 -0
- package/dist/config-uP7ZDtVZ.mjs +21 -0
- package/dist/config-write-y3CBI_ux.mjs +60 -0
- package/dist/{connect-WCQZ_u3m.mjs → connect-LnvW4HKx.mjs} +8 -6
- package/dist/{create-project-D0oXA090.mjs → create-project-BZBl_gQ0.mjs} +8 -23
- package/dist/create-project-JV9-6ICF.mjs +2 -0
- package/dist/database-provider-Cx525bwX.mjs +6 -0
- package/dist/database-provider.mjs +1 -5
- package/dist/{db-DJ-9qs3S.mjs → db-Mzv88E1C.mjs} +48 -44
- package/dist/{delete-BZ4-WaGm.mjs → delete-Ri6JemSU.mjs} +6 -4
- package/dist/deploy-DAH2-m_-.mjs +2 -0
- package/dist/{deploy-BAhhcg5q.mjs → deploy-DEsMVrCY.mjs} +796 -198
- package/dist/discover-BBzDZe_o.mjs +2 -0
- package/dist/{discover-xvfrgJeo.mjs → discover-C4O6YxVS.mjs} +3 -8
- package/dist/{dist-BrsS7cai.mjs → dist-4WkAWhWx.mjs} +1 -15
- package/dist/{dist-m40_XgNh.mjs → dist-Bn8Kodjp.mjs} +1 -1
- package/dist/dist-C5fND3R0.mjs +2 -0
- package/dist/dist-D7-nEOXi.mjs +2 -0
- package/dist/{output-B0cfNSx5.mjs → dist-Dn6nn2IU.mjs} +3 -926
- package/dist/{domain-BxAyhxXN.mjs → domain-BA37Ye7T.mjs} +7 -5
- package/dist/{route-types-Da-DpyUp.mjs → drizzle-Beb2Am5S.mjs} +1 -280
- package/dist/{email-Bj7Cvdwp.mjs → email-C5NsxrQG.mjs} +14 -12
- package/dist/{email-Ce6SQq-i.mjs → email-C5kaZXzJ.mjs} +2 -2
- package/dist/{entry-DU3oDoQ3.mjs → entry-DdRFGK0y.mjs} +2 -2
- package/dist/{env-DBKmK4vc.mjs → env-DX_v-Q-v.mjs} +1 -1
- package/dist/{env-DP_EErve.mjs → env-U_ohASB0.mjs} +9 -7
- package/dist/env-Yz4HcvHs.mjs +78 -0
- package/dist/env-helpers--wFmQ_5Q.mjs +136 -0
- package/dist/{env-types-BNPhro-M.mjs → env-types-CWDtqHgw.mjs} +6 -2
- package/dist/{env-validation-CF6KvTRf.mjs → env-validation-BsFEXps5.mjs} +19 -28
- package/dist/env-validation-DIDGM7h4.mjs +2 -0
- package/dist/fetch-CXDChK7B.mjs +18 -0
- package/dist/fetch-_SeGZao9.d.mts +57 -0
- package/dist/fetch-stream-AOByI7Ki.mjs +81 -0
- package/dist/fetch-stream-Bjf0hoZb.d.mts +49 -0
- package/dist/gen-B87rlalt.mjs +2 -0
- package/dist/{gen-B_wPnVTK.mjs → gen-pg-Ojg8Y.mjs} +13 -11
- package/dist/{generate-RTK8_kK1.mjs → generate-C0VY6RVf.mjs} +2 -2
- package/dist/{github-cmd-C-z_xRrQ.mjs → github-cmd-DsrkweIl.mjs} +6 -4
- package/dist/{handler-D1hLsObx.d.mts → handler-BXJTXd02.d.mts} +6 -1
- package/dist/handler-DghKr6dU.mjs +150 -0
- package/dist/head-D_QRR5Yd.mjs +112 -0
- package/dist/head-client-DzmJGN4C.mjs +90 -0
- package/dist/{headers-BAHwgHdW.mjs → headers-B_HBMgi0.mjs} +2 -2
- package/dist/help-B403BLBB.mjs +2 -0
- package/dist/{help-CwOX-zmI.mjs → help-sBhFH6pi.mjs} +17 -12
- package/dist/index.d.mts +2 -20
- package/dist/index.mjs +116 -60
- package/dist/{init-BGktCXgA.mjs → init-C--Yyj1b.mjs} +49 -50
- package/dist/{link-D2kbqhWb.mjs → link-BC-mNG9-.mjs} +7 -5
- package/dist/{list-CvkK_G7k.mjs → list-DHU1Wj6c.mjs} +7 -5
- package/dist/live-CB1y5IuC.mjs +411 -0
- package/dist/live-CKiJilLr.d.mts +105 -0
- package/dist/local-d1-DzykTWY8.mjs +104 -0
- package/dist/login-BwiopVdg.mjs +2 -0
- package/dist/{login-WIjNc77c.mjs → login-jKe_0QZL.mjs} +6 -11
- package/dist/{logs-dLUFCapG.mjs → logs-BG11f5PR.mjs} +6 -4
- package/dist/migrate-BV8qHiCb.mjs +285 -0
- package/dist/migrate-BXY3B3m7.mjs +2 -0
- package/dist/migration-handler-DM4clYj5.d.mts +51 -0
- package/dist/{neon-DHwd2zvC.mjs → neon-n74ta1Pr.mjs} +1 -1
- package/dist/{node-Ez5KW5rn.mjs → node-Cupyf7-s.mjs} +6 -6
- package/dist/{operator-auth-B3e08unv.mjs → operator-auth-BkVgJqv-.mjs} +2 -2
- package/dist/{operator-client-LUZnlnYk.mjs → operator-client-A0iex2yi.mjs} +2 -1
- package/dist/{operator-cmd-CKJ7xIRs.mjs → operator-cmd-BwAS2XZt.mjs} +6 -6
- package/dist/output-CCH48AMM.mjs +146 -0
- package/dist/{package-json-CPoWX79C.mjs → package-json-iCbMg5XF.mjs} +1 -1
- package/dist/pages/client.d.mts +5 -2
- package/dist/pages/client.mjs +5 -3
- package/dist/pages/head-client.mjs +1 -89
- package/dist/pages/head.mjs +1 -111
- package/dist/pages/index.d.mts +2 -3
- package/dist/pages/index.mjs +7 -7
- package/dist/pages/islands-plugin.mjs +2 -2
- package/dist/pages/prefetch.d.mts +2 -30
- package/dist/pages/prefetch.mjs +1 -89
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +3 -3
- package/dist/pages/serialize.d.mts +2 -9
- package/dist/pages/serialize.mjs +1 -13
- package/dist/plan-BEZ8VJW0.mjs +256 -0
- package/dist/plan-DpuOr14e.mjs +2 -0
- package/dist/{platform-auth-config-CdVWRRJr.mjs → platform-auth-config-C-hv-_Ok.mjs} +6 -6
- package/dist/{platform-auth-protection-Drl0qhrn.mjs → platform-auth-protection-DjTE5Hj-.mjs} +7 -5
- package/dist/{platform-auth-recovery-CmKEWpDo.mjs → platform-auth-recovery-Cr0r8TEb.mjs} +6 -5
- package/dist/{platform-cmd-5q_k56xS.mjs → platform-cmd-0tEh2ZtA.mjs} +8 -5
- package/dist/platform-cmd-DE6dw45v.mjs +2 -0
- package/dist/{platform-domain-4GiDlcqx.mjs → platform-domain-B_7x6Iqx.mjs} +4 -3
- package/dist/platform-lifecycle-Dhx9Pnub.mjs +2 -0
- package/dist/{platform-lifecycle-R9xAxvtG.mjs → platform-lifecycle-Di0LbhPM.mjs} +208 -37
- package/dist/platform-management-B9LUtMt9.mjs +2 -0
- package/dist/{platform-management-BfWsXHEW.mjs → platform-management-eaiaU3uM.mjs} +8 -5
- package/dist/{platform-recovery-CbK-I1FB.mjs → platform-recovery-BxfA8E5C.mjs} +3 -3
- package/dist/platform-registry-BJbgZLS1.mjs +431 -0
- package/dist/{plugin-inference-BDRfZngg.mjs → plugin-inference-DsvtJLll.mjs} +4 -4
- package/dist/prefetch-Bsc_Pb6c.mjs +90 -0
- package/dist/prefetch-Ce6la4EI.d.mts +31 -0
- package/dist/prepare-D4CkM3_v.mjs +2 -0
- package/dist/{prepare-blNRQvQl.mjs → prepare-_T-Haxrr.mjs} +3 -2
- package/dist/{prepare-CtDJjoOj.mjs → prepare-pcWcxSCh.mjs} +13 -11
- package/dist/prerender-render-Cf_WDE9W.mjs +111 -0
- package/dist/prerender-render.mjs +1 -110
- package/dist/{preset-lAy0B0BQ.mjs → preset-Dowh9tTt.mjs} +16 -118
- package/dist/project-BEBFDFLz.mjs +2 -0
- package/dist/project-CWNIPoXc.mjs +209 -0
- package/dist/{project-cmd-CTdmnzvc.mjs → project-cmd-DrnRJdep.mjs} +18 -16
- package/dist/{project-paths-SK8nMHPp.mjs → project-paths-CKQ-Q5JS.mjs} +47 -14
- package/dist/project-slug-23TpquG4.mjs +8 -0
- package/dist/project-slug-DofjTFd-.mjs +2 -0
- package/dist/{project-team-CGxsQe3_.mjs → project-team-CzRbO_kA.mjs} +6 -4
- package/dist/{project-token-Cirx7uwZ.mjs → project-token-Bwxjf4y6.mjs} +6 -4
- package/dist/{project-tsconfig-Ql2XsSQp.mjs → project-tsconfig-CwfqUnVp.mjs} +2 -2
- package/dist/{protocol-C-pqYJjE.d.mts → protocol-ZH3jP4a7.d.mts} +1 -1
- package/dist/providers-BNKRacMr.d.mts +7 -0
- package/dist/provision-CNgEBkVA.mjs +3 -0
- package/dist/{provision-CSJOjjQk.mjs → provision-Cck2m3jJ.mjs} +11 -25
- package/dist/queues-BWKt1Xo4.d.mts +7 -0
- package/dist/{requests-4Nq59hOr.mjs → requests-DwrqUQZ8.mjs} +5 -3
- package/dist/resolve-project-BTotl8Nn.mjs +2 -0
- package/dist/{resolve-project--Vxawf7z.mjs → resolve-project-Xvis70DG.mjs} +2 -8
- package/dist/response-Tn7rU0MV.mjs +30 -0
- package/dist/{rollback-Dr7u0Ljx.mjs → rollback-B4tFWmkN.mjs} +6 -4
- package/dist/{rolldown-runtime-rQ84J-ij.mjs → rolldown-runtime-DXIUcv95.mjs} +1 -10
- package/dist/route-types-Id82-veQ.mjs +280 -0
- package/dist/{local-d1-D2I6Ox5F.mjs → runner-BGVsGgkb.mjs} +6 -114
- package/dist/runner-CQs_cDSG.mjs +2 -0
- package/dist/runner-mysql-1o47achK.mjs +2 -0
- package/dist/{runner-mysql-7BPUNGmL.mjs → runner-mysql-BhwMk2Bm.mjs} +2 -9
- package/dist/{runner-pg-BkEza-dX.mjs → runner-pg-CJ_JeGF6.mjs} +2 -9
- package/dist/runner-pg-D7z01mQS.mjs +2 -0
- package/dist/runtime/ai.mjs +1 -1
- package/dist/runtime/auth-client-react.d.mts +2 -6
- package/dist/runtime/auth-client-react.mjs +1 -5
- package/dist/runtime/auth-client-solid.d.mts +2 -6
- package/dist/runtime/auth-client-solid.mjs +1 -5
- package/dist/runtime/auth-client-svelte.d.mts +2 -6
- package/dist/runtime/auth-client-svelte.mjs +1 -5
- package/dist/runtime/auth-client-vue.d.mts +2 -6
- package/dist/runtime/auth-client-vue.mjs +1 -5
- package/dist/runtime/auth-client.d.mts +2 -6
- package/dist/runtime/auth-client.mjs +1 -5
- package/dist/runtime/auth.mjs +1 -21
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +3 -3
- package/dist/runtime/client-react.mjs +3 -3
- package/dist/runtime/client-solid.d.mts +3 -3
- package/dist/runtime/client-solid.mjs +3 -3
- package/dist/runtime/client-svelte.d.mts +3 -3
- package/dist/runtime/client-svelte.mjs +3 -3
- package/dist/runtime/client-vue.d.mts +3 -3
- package/dist/runtime/client-vue.mjs +3 -3
- package/dist/runtime/client.d.mts +3 -3
- package/dist/runtime/client.mjs +3 -3
- package/dist/runtime/db.mjs +1 -1
- package/dist/runtime/durable.mjs +1 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-helpers.mjs +1 -135
- package/dist/runtime/env-public-client.mjs +1 -1
- package/dist/runtime/env-public.mjs +2 -2
- package/dist/runtime/env.mjs +1 -77
- package/dist/runtime/fetch-stream.d.mts +2 -49
- package/dist/runtime/fetch-stream.mjs +2 -80
- package/dist/runtime/fetch.d.mts +2 -57
- package/dist/runtime/fetch.mjs +2 -17
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +1 -149
- package/dist/runtime/kv.mjs +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +2 -2
- package/dist/runtime/live.d.mts +2 -104
- package/dist/runtime/live.mjs +1 -410
- package/dist/runtime/migration-handler-mysql.d.mts +1 -1
- package/dist/runtime/migration-handler-pg.d.mts +1 -1
- package/dist/runtime/migration-handler.d.mts +2 -50
- package/dist/runtime/queues.d.mts +2 -6
- package/dist/runtime/queues.mjs +1 -1
- package/dist/runtime/response.mjs +1 -29
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/sse.mjs +1 -171
- package/dist/runtime/storage.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/validator.mjs +1 -71
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws-server.mjs +2 -2
- package/dist/runtime/ws.d.mts +2 -121
- package/dist/{scan-CpK-57ug.mjs → scan-DJbooZm2.mjs} +3 -3
- package/dist/{scan-BMH4rzlv.mjs → scan-DdDvRCU1.mjs} +8 -26
- package/dist/{secret-AcPi-FoA.mjs → secret-UtrRjhEO.mjs} +8 -6
- package/dist/serialize-BPvnNQuA.mjs +14 -0
- package/dist/serialize-CfSwWfF2.d.mts +10 -0
- package/dist/{skills-C0RvGjeE.mjs → skills-B-690E7h.mjs} +3 -2
- package/dist/sse-BaC1jXko.mjs +172 -0
- package/dist/{subcommand-prompt-Bmyn5Rlc.mjs → subcommand-prompt-BuGYkAkC.mjs} +2 -1
- package/dist/sveltekit.d.mts +2 -1
- package/dist/sveltekit.mjs +3 -2
- package/dist/validate-DqJ33oHj.mjs +2 -0
- package/dist/validate-qNhV00PD.mjs +180 -0
- package/dist/validator-BTOu0fB0.mjs +72 -0
- package/dist/{wrangler--imS8n0d.mjs → wrangler-D01qs6VB.mjs} +259 -71
- package/dist/ws-BwcqizuH.d.mts +122 -0
- package/dist/{yarn-pnp-DxSInkzL.mjs → yarn-pnp-CVEc3gE7.mjs} +1 -1
- package/package.json +19 -8
- package/skills/void/SKILL.md +6 -4
- package/skills/void/docs/guide/ai.md +3 -3
- package/skills/void/docs/guide/app-types.md +12 -11
- package/skills/void/docs/guide/auth.md +2 -2
- package/skills/void/docs/guide/database/d1.md +1 -1
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +3 -3
- package/skills/void/docs/guide/deployment.md +8 -15
- package/skills/void/docs/guide/durable-state.md +2 -2
- package/skills/void/docs/guide/edge/headers.md +3 -3
- package/skills/void/docs/guide/edge/prerendering.md +1 -1
- package/skills/void/docs/guide/edge/redirects.md +4 -4
- package/skills/void/docs/guide/edge/revalidation.md +6 -6
- package/skills/void/docs/guide/edge/rewrites.md +28 -27
- package/skills/void/docs/guide/edge/static-assets.md +1 -1
- package/skills/void/docs/guide/email.md +60 -66
- package/skills/void/docs/guide/env-migration.md +1 -1
- package/skills/void/docs/guide/index.md +15 -41
- package/skills/void/docs/guide/pages-routing/head.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +13 -5
- package/skills/void/docs/guide/platform/administration/projects.md +3 -1
- package/skills/void/docs/guide/platform/installation/ci.md +3 -0
- package/skills/void/docs/guide/platform/installation/credentials.md +15 -5
- package/skills/void/docs/guide/platform/installation/prerequisites.md +2 -0
- package/skills/void/docs/guide/platform/installation/setup.md +1 -1
- package/skills/void/docs/guide/quickstart.md +11 -78
- package/skills/void/docs/guide/remote-dev.md +2 -2
- package/skills/void/docs/guide/sandboxes.md +1 -1
- package/skills/void/docs/guide/ssg.md +1 -1
- package/skills/void/docs/guide/websockets.md +1 -1
- package/skills/void/docs/index.md +17 -17
- package/skills/void/docs/integrations/cloudflare.md +91 -96
- package/skills/void/docs/integrations/frameworks/analog.md +14 -9
- package/skills/void/docs/integrations/frameworks/astro.md +14 -10
- package/skills/void/docs/integrations/frameworks/nuxt.md +14 -9
- package/skills/void/docs/integrations/frameworks/overview.md +35 -29
- package/skills/void/docs/integrations/frameworks/react-router.md +1 -1
- package/skills/void/docs/integrations/frameworks/sveltekit.md +33 -30
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +1 -1
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -5
- package/skills/void/docs/reference/api.md +21 -4
- package/skills/void/docs/reference/cli.md +40 -25
- package/skills/void/docs/reference/config.md +58 -35
- package/skills/void/docs/reference/structure.md +2 -2
- package/dist/validate-tBBN_dXH.mjs +0 -505
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { a as join, i as isAbsolute, l as relative, n as dirname, r as extname, t as basename, u as resolve } from "./dist-4WkAWhWx.mjs";
|
|
2
|
+
import { copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { isDeepStrictEqual } from "node:util";
|
|
7
|
+
import { build } from "vite";
|
|
8
|
+
import { getWorkerBundleDir, normalizeDirectoryName, readBuildOutput, writeAssets, writeContainerConfig, writeRootConfig, writeWorkerConfig } from "@cloudflare/build-output-utils";
|
|
9
|
+
import { InputConfigSchema, OutputContainerSchema } from "@cloudflare/config";
|
|
10
|
+
import ignore from "ignore";
|
|
11
|
+
//#region src/cli/cf-config-migrate.ts
|
|
12
|
+
function record(value) {
|
|
13
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
14
|
+
}
|
|
15
|
+
function empty(value) {
|
|
16
|
+
return value === void 0 || value === null || Array.isArray(value) && value.length === 0 || record(value) !== null && Object.keys(value).length === 0;
|
|
17
|
+
}
|
|
18
|
+
/** Remove build-only fields and settings translated into cf's typed config below. */
|
|
19
|
+
function migrationInput(raw) {
|
|
20
|
+
const result = { ...raw };
|
|
21
|
+
if (!empty(result.rules) && !isDeepStrictEqual(result.rules, [{
|
|
22
|
+
type: "ESModule",
|
|
23
|
+
globs: ["**/*.js", "**/*.mjs"]
|
|
24
|
+
}])) throw new Error("cf cannot yet preserve custom Worker module rules in a prebuilt bundle.");
|
|
25
|
+
if (empty(result.logfwdr) || isDeepStrictEqual(result.logfwdr, { bindings: [] })) delete result.logfwdr;
|
|
26
|
+
for (const key of [
|
|
27
|
+
"configPath",
|
|
28
|
+
"userConfigPath",
|
|
29
|
+
"topLevelName",
|
|
30
|
+
"main",
|
|
31
|
+
"jsx_factory",
|
|
32
|
+
"jsx_fragment",
|
|
33
|
+
"rules",
|
|
34
|
+
"python_modules",
|
|
35
|
+
"dev",
|
|
36
|
+
"no_bundle",
|
|
37
|
+
"build",
|
|
38
|
+
"keep_vars",
|
|
39
|
+
"keep_secrets",
|
|
40
|
+
"keep_assets",
|
|
41
|
+
"send_metrics",
|
|
42
|
+
"workflows"
|
|
43
|
+
]) delete result[key];
|
|
44
|
+
for (const [key, value] of Object.entries(result)) if (empty(value)) delete result[key];
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function applyPreservationFlags(raw, worker) {
|
|
48
|
+
const keepBindings = [...raw.keep_vars === true ? ["plain_text", "json"] : [], ...raw.keep_secrets === true ? ["secret_text", "secret_key"] : []];
|
|
49
|
+
if (keepBindings.length === 0 && raw.keep_assets !== true) return;
|
|
50
|
+
const unsafe = record(worker.unsafe) ?? {};
|
|
51
|
+
const metadata = record(unsafe.metadata) ?? {};
|
|
52
|
+
const previous = metadata.keep_bindings;
|
|
53
|
+
if (previous !== void 0 && (!Array.isArray(previous) || !previous.every((value) => typeof value === "string"))) throw new Error("Invalid keep_bindings in the built Cloudflare config.");
|
|
54
|
+
worker.unsafe = {
|
|
55
|
+
...unsafe,
|
|
56
|
+
metadata: {
|
|
57
|
+
...metadata,
|
|
58
|
+
...keepBindings.length > 0 ? { keep_bindings: [.../* @__PURE__ */ new Set([...previous ?? [], ...keepBindings])] } : {},
|
|
59
|
+
...raw.keep_assets === true ? { keep_assets: true } : {}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function applyWorkflows(raw, worker) {
|
|
64
|
+
if (raw.workflows === void 0 || empty(raw.workflows)) return;
|
|
65
|
+
if (!Array.isArray(raw.workflows)) throw new Error("Invalid Workflow bindings in the built Cloudflare config.");
|
|
66
|
+
const env = record(worker.env) ?? {};
|
|
67
|
+
const exports = record(worker.exports) ?? {};
|
|
68
|
+
for (const item of raw.workflows) {
|
|
69
|
+
const workflow = record(item);
|
|
70
|
+
if (!workflow || typeof workflow.binding !== "string" || typeof workflow.name !== "string" || typeof workflow.class_name !== "string" || workflow.script_name !== void 0 && typeof workflow.script_name !== "string") throw new Error("Invalid Workflow binding in the built Cloudflare config.");
|
|
71
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
72
|
+
"binding",
|
|
73
|
+
"name",
|
|
74
|
+
"class_name",
|
|
75
|
+
"script_name",
|
|
76
|
+
"limits",
|
|
77
|
+
"concurrency",
|
|
78
|
+
"schedules",
|
|
79
|
+
"default_retention"
|
|
80
|
+
]);
|
|
81
|
+
for (const key of Object.keys(workflow)) if (!allowed.has(key)) throw new Error(`cf cannot migrate Workflow setting ${key}.`);
|
|
82
|
+
if (Object.hasOwn(env, workflow.binding)) throw new Error(`Duplicate Worker binding ${workflow.binding}.`);
|
|
83
|
+
env[workflow.binding] = {
|
|
84
|
+
type: "workflow",
|
|
85
|
+
name: workflow.name,
|
|
86
|
+
worker: workflow.script_name ?? worker.name,
|
|
87
|
+
exportName: workflow.class_name
|
|
88
|
+
};
|
|
89
|
+
if (workflow.script_name !== void 0 && workflow.script_name !== worker.name) continue;
|
|
90
|
+
const retention = record(workflow.default_retention);
|
|
91
|
+
if (Object.hasOwn(exports, workflow.class_name)) throw new Error(`Duplicate Worker export ${workflow.class_name}.`);
|
|
92
|
+
const schedules = Array.isArray(workflow.schedules) && workflow.schedules.length === 0 ? void 0 : workflow.schedules;
|
|
93
|
+
exports[workflow.class_name] = {
|
|
94
|
+
type: "workflow",
|
|
95
|
+
name: workflow.name,
|
|
96
|
+
...workflow.limits !== void 0 ? { limits: workflow.limits } : {},
|
|
97
|
+
...workflow.concurrency !== void 0 ? { concurrency: workflow.concurrency } : {},
|
|
98
|
+
...schedules !== void 0 ? { schedules } : {},
|
|
99
|
+
...retention ? { defaultRetention: {
|
|
100
|
+
...retention.success_retention !== void 0 ? { successRetention: retention.success_retention } : {},
|
|
101
|
+
...retention.error_retention !== void 0 ? { errorRetention: retention.error_retention } : {}
|
|
102
|
+
} } : {}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
worker.env = env;
|
|
106
|
+
worker.exports = exports;
|
|
107
|
+
}
|
|
108
|
+
function uncredentialedEnvironment() {
|
|
109
|
+
const env = { ...process.env };
|
|
110
|
+
for (const key of Object.keys(env)) if (/^(?:CLOUDFLARE|CF_|WRANGLER|VOID_PLATFORM_|DATABASE_URL|VOID_ACCESS_)/i.test(key)) delete env[key];
|
|
111
|
+
env.CF_DELEGATION = "1";
|
|
112
|
+
return env;
|
|
113
|
+
}
|
|
114
|
+
function migrationFollowUps(output) {
|
|
115
|
+
return [...output.matchAll(/\[required\] ([^:\n]+): ([^\n]+)/g)].map((match) => ({
|
|
116
|
+
path: match[1],
|
|
117
|
+
message: match[2]
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
function assertHandledFollowUps(output) {
|
|
121
|
+
for (const item of migrationFollowUps(output)) if (!(item.path === "assets.directory" && item.message.includes("assets directory") || /^d1_databases\.\d+$/.test(item.path) && /`migrations_(?:dir|table)`/.test(item.message) || /^durable_objects\.bindings\.\d+$/.test(item.path) || item.path === "migrations" || item.path === "containers")) throw new Error(`cf cannot migrate Cloudflare setting ${item.path}: ${item.message}`);
|
|
122
|
+
}
|
|
123
|
+
function durableObjectExports(raw) {
|
|
124
|
+
const migrations = raw.migrations;
|
|
125
|
+
if (migrations === void 0 || Array.isArray(migrations) && migrations.length === 0) return {};
|
|
126
|
+
if (!Array.isArray(migrations) || !migrations.every((entry) => record(entry))) throw new Error("Invalid Durable Object migrations in the built Cloudflare config.");
|
|
127
|
+
const exports = {};
|
|
128
|
+
for (const migration of migrations) {
|
|
129
|
+
const known = /* @__PURE__ */ new Set([
|
|
130
|
+
"tag",
|
|
131
|
+
"new_classes",
|
|
132
|
+
"new_sqlite_classes",
|
|
133
|
+
"renamed_classes",
|
|
134
|
+
"deleted_classes"
|
|
135
|
+
]);
|
|
136
|
+
for (const key of Object.keys(migration)) if (!known.has(key)) throw new Error(`cf cannot migrate Durable Object migration setting ${key}.`);
|
|
137
|
+
for (const [field, storage] of [["new_classes", "legacy-kv"], ["new_sqlite_classes", "sqlite"]]) {
|
|
138
|
+
const classes = migration[field] ?? [];
|
|
139
|
+
if (!Array.isArray(classes) || !classes.every((name) => typeof name === "string")) throw new Error(`Invalid ${field} in the built Cloudflare config.`);
|
|
140
|
+
for (const name of classes) exports[name] = {
|
|
141
|
+
type: "durable-object",
|
|
142
|
+
storage
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const renamed = migration.renamed_classes ?? [];
|
|
146
|
+
if (!Array.isArray(renamed) || !renamed.every((entry) => record(entry))) throw new Error("Invalid renamed_classes in the built Cloudflare config.");
|
|
147
|
+
for (const item of renamed) {
|
|
148
|
+
if (typeof item.from !== "string" || typeof item.to !== "string") throw new Error("Invalid Durable Object class rename in the built Cloudflare config.");
|
|
149
|
+
const old = record(exports[item.from]);
|
|
150
|
+
if (!old || old.storage !== "sqlite" && old.storage !== "legacy-kv") throw new Error(`Cannot determine the storage of renamed Durable Object ${item.from}.`);
|
|
151
|
+
exports[item.from] = {
|
|
152
|
+
type: "durable-object",
|
|
153
|
+
state: "renamed",
|
|
154
|
+
renamedTo: item.to
|
|
155
|
+
};
|
|
156
|
+
exports[item.to] = {
|
|
157
|
+
type: "durable-object",
|
|
158
|
+
storage: old.storage
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const deleted = migration.deleted_classes ?? [];
|
|
162
|
+
if (!Array.isArray(deleted) || !deleted.every((name) => typeof name === "string")) throw new Error("Invalid deleted_classes in the built Cloudflare config.");
|
|
163
|
+
for (const name of deleted) exports[name] = {
|
|
164
|
+
type: "durable-object",
|
|
165
|
+
state: "deleted"
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return exports;
|
|
169
|
+
}
|
|
170
|
+
function containersFromWrangler(raw, exports) {
|
|
171
|
+
const values = raw.containers;
|
|
172
|
+
if (values === void 0) return [];
|
|
173
|
+
if (!Array.isArray(values) || !values.every((value) => record(value))) throw new Error("Invalid Containers in the built Cloudflare config.");
|
|
174
|
+
return values.map((value) => {
|
|
175
|
+
if (typeof value.name !== "string" || typeof value.class_name !== "string" || typeof value.image !== "string") throw new Error("cf requires a name, class_name and image for each Container.");
|
|
176
|
+
const fields = /* @__PURE__ */ new Set([
|
|
177
|
+
"name",
|
|
178
|
+
"class_name",
|
|
179
|
+
"image",
|
|
180
|
+
"max_instances",
|
|
181
|
+
"instance_type"
|
|
182
|
+
]);
|
|
183
|
+
for (const key of Object.keys(value)) if (!fields.has(key)) throw new Error(`cf cannot migrate Container setting ${key}.`);
|
|
184
|
+
const declaration = record(exports[value.class_name]);
|
|
185
|
+
if (!declaration || declaration.storage !== "sqlite") throw new Error(`Container ${value.name} needs a SQLite Durable Object export.`);
|
|
186
|
+
declaration.container = value.name;
|
|
187
|
+
return {
|
|
188
|
+
name: value.name,
|
|
189
|
+
schedulingPolicy: "durable-object",
|
|
190
|
+
images: { default: { reference: value.image } },
|
|
191
|
+
...typeof value.max_instances === "number" ? { maxInstances: value.max_instances } : {},
|
|
192
|
+
...typeof value.instance_type === "string" ? { instanceType: value.instance_type } : {}
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Ask the pinned cf CLI to translate the Vite plugin's generated JSON config.
|
|
198
|
+
* Migration runs on a disposable copy without Cloudflare credentials; its
|
|
199
|
+
* generated module is evaluated in a second uncredentialed Node process.
|
|
200
|
+
*/
|
|
201
|
+
function migrateBuiltWranglerConfig(raw) {
|
|
202
|
+
const cfPackage = fileURLToPath(import.meta.resolve("cf/package.json"));
|
|
203
|
+
const cfBinary = join(dirname(cfPackage), "bin", "cf");
|
|
204
|
+
const directory = mkdtempSync(join(tmpdir(), "void-cf-config-"));
|
|
205
|
+
try {
|
|
206
|
+
mkdirSync(join(directory, "node_modules"));
|
|
207
|
+
symlinkSync(dirname(cfPackage), join(directory, "node_modules", "cf"), "junction");
|
|
208
|
+
writeFileSync(join(directory, "package.json"), JSON.stringify({
|
|
209
|
+
name: "void-private-cf-build",
|
|
210
|
+
private: true,
|
|
211
|
+
type: "module",
|
|
212
|
+
dependencies: {
|
|
213
|
+
cf: "1.0.0",
|
|
214
|
+
"@cloudflare/vite-plugin": "1.0.0"
|
|
215
|
+
}
|
|
216
|
+
}), { mode: 384 });
|
|
217
|
+
const configPath = join(directory, "wrangler.json");
|
|
218
|
+
writeFileSync(configPath, JSON.stringify(migrationInput(raw)), { mode: 384 });
|
|
219
|
+
const env = uncredentialedEnvironment();
|
|
220
|
+
const migrated = spawnSync(process.execPath, [
|
|
221
|
+
cfBinary,
|
|
222
|
+
"migrate",
|
|
223
|
+
configPath,
|
|
224
|
+
"--bundler",
|
|
225
|
+
"vite",
|
|
226
|
+
"--no-install",
|
|
227
|
+
"--force"
|
|
228
|
+
], {
|
|
229
|
+
cwd: directory,
|
|
230
|
+
env,
|
|
231
|
+
encoding: "utf8",
|
|
232
|
+
timeout: 3e4,
|
|
233
|
+
maxBuffer: 4194304
|
|
234
|
+
});
|
|
235
|
+
const generatedPath = join(directory, "cloudflare.config.ts");
|
|
236
|
+
if (!existsSync(generatedPath) || migrated.error) throw new Error("cf could not translate the built Cloudflare configuration.");
|
|
237
|
+
assertHandledFollowUps(migrated.stdout);
|
|
238
|
+
const generated = readFileSync(generatedPath, "utf8");
|
|
239
|
+
const executable = generated.replace(/^throw new Error\("Migration incomplete\.[^\n]*\);\s*$/m, "");
|
|
240
|
+
if (executable === generated && migrated.status !== 0) throw new Error("cf did not provide a usable Cloudflare configuration.");
|
|
241
|
+
const executablePath = join(directory, "cloudflare.config.mjs");
|
|
242
|
+
writeFileSync(executablePath, executable, { mode: 384 });
|
|
243
|
+
const evaluated = spawnSync(process.execPath, [
|
|
244
|
+
"--input-type=module",
|
|
245
|
+
"-e",
|
|
246
|
+
"const mod = await import(process.argv[1]); process.stdout.write(JSON.stringify(mod.default));",
|
|
247
|
+
pathToFileURL(executablePath).href
|
|
248
|
+
], {
|
|
249
|
+
cwd: directory,
|
|
250
|
+
env,
|
|
251
|
+
encoding: "utf8",
|
|
252
|
+
timeout: 1e4,
|
|
253
|
+
maxBuffer: 4194304
|
|
254
|
+
});
|
|
255
|
+
if (evaluated.status !== 0 || evaluated.error) throw new Error("cf generated a configuration that Void could not validate.");
|
|
256
|
+
const result = record(JSON.parse(evaluated.stdout));
|
|
257
|
+
const worker = record(result?.worker);
|
|
258
|
+
if (!result || !worker) throw new Error("cf did not generate a Worker configuration.");
|
|
259
|
+
applyPreservationFlags(raw, worker);
|
|
260
|
+
applyWorkflows(raw, worker);
|
|
261
|
+
const exports = {
|
|
262
|
+
...record(worker.exports),
|
|
263
|
+
...durableObjectExports(raw)
|
|
264
|
+
};
|
|
265
|
+
const containers = containersFromWrangler(raw, exports);
|
|
266
|
+
if (containers.length > 0) {
|
|
267
|
+
const envBindings = record(worker.env);
|
|
268
|
+
const durableBindings = record(raw.durable_objects)?.bindings;
|
|
269
|
+
if (!envBindings || !Array.isArray(durableBindings)) throw new Error("A Container Durable Object binding was not found in the built config.");
|
|
270
|
+
for (const container of containers) {
|
|
271
|
+
const className = raw.containers.find((entry) => entry.name === container.name)?.class_name;
|
|
272
|
+
const binding = durableBindings.find((entry) => record(entry)?.class_name === className);
|
|
273
|
+
if (!record(binding) || typeof binding.name !== "string" || binding.script_name !== void 0 && binding.script_name !== worker.name) throw new Error(`Container ${container.name} must use a local Durable Object binding.`);
|
|
274
|
+
envBindings[binding.name] = {
|
|
275
|
+
type: "unsafe:durable_object_namespace",
|
|
276
|
+
class_name: className
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (Object.keys(exports).length > 0) worker.exports = exports;
|
|
281
|
+
if (containers.length > 0) result.containers = containers;
|
|
282
|
+
return InputConfigSchema.parse(result);
|
|
283
|
+
} finally {
|
|
284
|
+
rmSync(directory, {
|
|
285
|
+
recursive: true,
|
|
286
|
+
force: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/cli/cf-build-output.ts
|
|
292
|
+
function object(value) {
|
|
293
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
294
|
+
}
|
|
295
|
+
const moduleTypes = {
|
|
296
|
+
".js": "esm",
|
|
297
|
+
".mjs": "esm",
|
|
298
|
+
".cjs": "cjs",
|
|
299
|
+
".wasm": "wasm",
|
|
300
|
+
".bin": "data",
|
|
301
|
+
".txt": "text",
|
|
302
|
+
".html": "text",
|
|
303
|
+
".sql": "text",
|
|
304
|
+
".json": "json",
|
|
305
|
+
".map": "sourcemap"
|
|
306
|
+
};
|
|
307
|
+
function copyBundle(source, destination) {
|
|
308
|
+
const modules = {};
|
|
309
|
+
for (const entry of readdirSync(source, {
|
|
310
|
+
recursive: true,
|
|
311
|
+
withFileTypes: true
|
|
312
|
+
})) {
|
|
313
|
+
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
|
314
|
+
const absolute = join(entry.parentPath, entry.name);
|
|
315
|
+
if (entry.isSymbolicLink()) {
|
|
316
|
+
const target = realpathSync(absolute);
|
|
317
|
+
const targetRelative = relative(realpathSync(source), target).replace(/\\/g, "/");
|
|
318
|
+
if (!targetRelative || targetRelative === ".." || targetRelative.startsWith("../") || isAbsolute(targetRelative)) throw new Error("The built Worker contains a symlink outside its output directory.");
|
|
319
|
+
}
|
|
320
|
+
const name = relative(source, absolute);
|
|
321
|
+
if (name === "wrangler.json" || name === ".dev.vars" || name === join(".vite", "manifest.json") || name.endsWith(".css") || name.endsWith(".css.map")) continue;
|
|
322
|
+
const type = moduleTypes[extname(entry.name).toLowerCase()];
|
|
323
|
+
if (!type) return null;
|
|
324
|
+
const destinationPath = join(destination, name);
|
|
325
|
+
mkdirSync(dirname(destinationPath), { recursive: true });
|
|
326
|
+
if (entry.isSymbolicLink()) copyFileSync(realpathSync(absolute), destinationPath);
|
|
327
|
+
else cpSync(absolute, destinationPath);
|
|
328
|
+
modules[name] = { type };
|
|
329
|
+
}
|
|
330
|
+
return modules;
|
|
331
|
+
}
|
|
332
|
+
/** Create a private cf Build Output tree from Void's verified Vite artifact. */
|
|
333
|
+
async function prepareCfBuildOutput(workerDirectory, accountId) {
|
|
334
|
+
const source = resolve(workerDirectory);
|
|
335
|
+
const raw = object(JSON.parse(readFileSync(join(source, "wrangler.json"), "utf8")));
|
|
336
|
+
if (!raw) return null;
|
|
337
|
+
if (typeof raw.account_id === "string" && raw.account_id !== accountId) return null;
|
|
338
|
+
const config = migrateBuiltWranglerConfig(raw);
|
|
339
|
+
if (!config.worker) throw new Error("cf did not produce a Worker configuration.");
|
|
340
|
+
const main = raw.main;
|
|
341
|
+
if (typeof main !== "string" || basename(main) !== main || !existsSync(join(source, main))) return null;
|
|
342
|
+
const assetsDirectory = object(raw.assets)?.directory;
|
|
343
|
+
if (assetsDirectory !== void 0 && typeof assetsDirectory !== "string") return null;
|
|
344
|
+
const directory = mkdtempSync(join(tmpdir(), "void-cf-deploy-"));
|
|
345
|
+
try {
|
|
346
|
+
const bundle = getWorkerBundleDir(directory);
|
|
347
|
+
mkdirSync(bundle, { recursive: true });
|
|
348
|
+
const modules = copyBundle(source, bundle);
|
|
349
|
+
if (!modules) {
|
|
350
|
+
rmSync(directory, {
|
|
351
|
+
recursive: true,
|
|
352
|
+
force: true
|
|
353
|
+
});
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
await writeRootConfig(directory, { accountId }, {
|
|
357
|
+
isPreview: false,
|
|
358
|
+
mode: "production"
|
|
359
|
+
});
|
|
360
|
+
await writeWorkerConfig({
|
|
361
|
+
root: directory,
|
|
362
|
+
config: config.worker,
|
|
363
|
+
manifest: {
|
|
364
|
+
type: "complete",
|
|
365
|
+
mainModule: main,
|
|
366
|
+
modules
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
for (const container of config.containers ?? []) await writeContainerConfig({
|
|
370
|
+
root: directory,
|
|
371
|
+
config: OutputContainerSchema.parse(container),
|
|
372
|
+
directoryName: normalizeDirectoryName(container.name)
|
|
373
|
+
});
|
|
374
|
+
if (typeof assetsDirectory === "string") {
|
|
375
|
+
const assetPath = resolve(source, assetsDirectory);
|
|
376
|
+
if (!existsSync(assetPath)) {
|
|
377
|
+
rmSync(directory, {
|
|
378
|
+
recursive: true,
|
|
379
|
+
force: true
|
|
380
|
+
});
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
await writeAssets({
|
|
384
|
+
root: directory,
|
|
385
|
+
sourceDirectory: assetPath
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
await readBuildOutput(directory);
|
|
389
|
+
return {
|
|
390
|
+
directory,
|
|
391
|
+
...typeof assetsDirectory === "string" ? { assetsDirectory: resolve(source, assetsDirectory) } : {},
|
|
392
|
+
dispose: () => rmSync(directory, {
|
|
393
|
+
recursive: true,
|
|
394
|
+
force: true
|
|
395
|
+
})
|
|
396
|
+
};
|
|
397
|
+
} catch (error) {
|
|
398
|
+
rmSync(directory, {
|
|
399
|
+
recursive: true,
|
|
400
|
+
force: true
|
|
401
|
+
});
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/** Bundle Void's generated thin static Worker before handing it to cf as prebuilt output. */
|
|
406
|
+
async function prepareCfStaticBuildOutput(options) {
|
|
407
|
+
const raw = object(JSON.parse(readFileSync(options.configPath, "utf8")));
|
|
408
|
+
if (!raw || typeof raw.main !== "string" || basename(raw.main) !== raw.main) return null;
|
|
409
|
+
const entry = join(dirname(options.configPath), raw.main);
|
|
410
|
+
if (!existsSync(entry)) return null;
|
|
411
|
+
const scratch = mkdtempSync(join(tmpdir(), "void-cf-static-"));
|
|
412
|
+
try {
|
|
413
|
+
await build({
|
|
414
|
+
configFile: false,
|
|
415
|
+
root: options.projectRoot,
|
|
416
|
+
publicDir: false,
|
|
417
|
+
logLevel: "error",
|
|
418
|
+
build: {
|
|
419
|
+
outDir: scratch,
|
|
420
|
+
emptyOutDir: true,
|
|
421
|
+
lib: {
|
|
422
|
+
entry,
|
|
423
|
+
formats: ["es"],
|
|
424
|
+
fileName: "index"
|
|
425
|
+
},
|
|
426
|
+
target: "es2022"
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
writeFileSync(join(scratch, "wrangler.json"), JSON.stringify({
|
|
430
|
+
...raw,
|
|
431
|
+
main: "index.js",
|
|
432
|
+
assets: {
|
|
433
|
+
...object(raw.assets),
|
|
434
|
+
directory: resolve(options.assetsDirectory)
|
|
435
|
+
}
|
|
436
|
+
}), { mode: 384 });
|
|
437
|
+
return await prepareCfBuildOutput(scratch, options.accountId);
|
|
438
|
+
} finally {
|
|
439
|
+
rmSync(scratch, {
|
|
440
|
+
recursive: true,
|
|
441
|
+
force: true
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/** Bundle an adapter-produced Worker and copy only its public framework assets. */
|
|
446
|
+
async function prepareCfFrameworkBuildOutput(options) {
|
|
447
|
+
const raw = object(JSON.parse(readFileSync(options.configPath, "utf8")));
|
|
448
|
+
const assets = object(raw?.assets);
|
|
449
|
+
if (!raw || typeof raw.main !== "string" || typeof assets?.directory !== "string") return null;
|
|
450
|
+
const configDirectory = dirname(options.configPath);
|
|
451
|
+
const entry = resolve(configDirectory, raw.main);
|
|
452
|
+
const sourceAssets = resolve(configDirectory, assets.directory);
|
|
453
|
+
if (!existsSync(entry) || !existsSync(sourceAssets)) return null;
|
|
454
|
+
const scratch = mkdtempSync(join(tmpdir(), "void-cf-framework-"));
|
|
455
|
+
const publicAssets = mkdtempSync(join(tmpdir(), "void-cf-framework-assets-"));
|
|
456
|
+
try {
|
|
457
|
+
const ignored = ignore();
|
|
458
|
+
const ignorePath = join(sourceAssets, ".assetsignore");
|
|
459
|
+
if (existsSync(ignorePath)) ignored.add(readFileSync(ignorePath, "utf8"));
|
|
460
|
+
const realAssets = realpathSync(sourceAssets);
|
|
461
|
+
for (const file of readdirSync(sourceAssets, {
|
|
462
|
+
recursive: true,
|
|
463
|
+
withFileTypes: true
|
|
464
|
+
})) {
|
|
465
|
+
if (file.isDirectory()) continue;
|
|
466
|
+
const absolute = join(file.parentPath, file.name);
|
|
467
|
+
const name = relative(sourceAssets, absolute).replaceAll("\\", "/");
|
|
468
|
+
if (name === ".assetsignore" || ignored.ignores(name)) continue;
|
|
469
|
+
const destination = join(publicAssets, name);
|
|
470
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
471
|
+
if (file.isSymbolicLink()) {
|
|
472
|
+
const target = realpathSync(absolute);
|
|
473
|
+
const targetRelative = relative(realAssets, target);
|
|
474
|
+
if (targetRelative === ".." || targetRelative.startsWith("../") || isAbsolute(targetRelative)) throw new Error("The framework assets contain a symlink outside the asset directory.");
|
|
475
|
+
copyFileSync(target, destination);
|
|
476
|
+
} else if (file.isFile()) copyFileSync(absolute, destination);
|
|
477
|
+
}
|
|
478
|
+
await build({
|
|
479
|
+
configFile: false,
|
|
480
|
+
root: options.projectRoot,
|
|
481
|
+
publicDir: false,
|
|
482
|
+
logLevel: "error",
|
|
483
|
+
build: {
|
|
484
|
+
outDir: scratch,
|
|
485
|
+
emptyOutDir: true,
|
|
486
|
+
lib: {
|
|
487
|
+
entry,
|
|
488
|
+
formats: ["es"],
|
|
489
|
+
fileName: "index"
|
|
490
|
+
},
|
|
491
|
+
rollupOptions: { external: [/^cloudflare:/, /^node:/] },
|
|
492
|
+
target: "es2022"
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
writeFileSync(join(scratch, "wrangler.json"), JSON.stringify({
|
|
496
|
+
...raw,
|
|
497
|
+
main: "index.js",
|
|
498
|
+
assets: {
|
|
499
|
+
...assets,
|
|
500
|
+
directory: publicAssets
|
|
501
|
+
}
|
|
502
|
+
}), { mode: 384 });
|
|
503
|
+
const prepared = await prepareCfBuildOutput(scratch, options.accountId);
|
|
504
|
+
return prepared ? {
|
|
505
|
+
...prepared,
|
|
506
|
+
assetsDirectory: sourceAssets
|
|
507
|
+
} : null;
|
|
508
|
+
} finally {
|
|
509
|
+
rmSync(scratch, {
|
|
510
|
+
recursive: true,
|
|
511
|
+
force: true
|
|
512
|
+
});
|
|
513
|
+
rmSync(publicAssets, {
|
|
514
|
+
recursive: true,
|
|
515
|
+
force: true
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
export { migrateBuiltWranglerConfig as i, prepareCfFrameworkBuildOutput as n, prepareCfStaticBuildOutput as r, prepareCfBuildOutput as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|