void 0.22.0 → 0.23.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 +5 -1
- package/dist/{account-cmd-CjyxcGkM.mjs → account-cmd-C84Ee8cO.mjs} +4 -4
- package/dist/{scan-ClYmX3sa.mjs → application-analysis-BVsVqc11.mjs} +135 -18
- package/dist/application-routing-B7QEjqSR.mjs +27 -0
- package/dist/{auth-CZuiVsFh.mjs → auth-CCjt0hcq.mjs} +1 -1
- package/dist/{auth-DLNN0D3Z.mjs → auth-CSkdO2Bb.mjs} +4 -47
- package/dist/{auth-link-BLO4ptzo.mjs → auth-link-CioEg6uY.mjs} +4 -4
- package/dist/{auth-router-ZUg9MF_U.mjs → auth-router-BsR981d4.mjs} +4 -4
- package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
- package/dist/{build-cmd-BxR5FROK.mjs → build-cmd-LzvNJORH.mjs} +17 -5
- package/dist/{cache-D0sWhgKI.mjs → cache-C4MvnrMH.mjs} +2 -2
- package/dist/{cancel-deploy-D4NUqFbi.mjs → cancel-deploy-abUxpP2n.mjs} +2 -2
- package/dist/{cf-build-output-BJ6yGEIS.mjs → cf-build-output-BPqOT964.mjs} +2 -1
- package/dist/cf-build-output-_0HNWysu.mjs +2 -0
- package/dist/cli/cli.mjs +80 -455
- package/dist/cli/{cf-compat.mjs → cloudflare-operation-process.mjs} +442 -421
- package/dist/cli/env-schema-probe.d.mts +2 -1
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-Cu7jWiF1.mjs +2 -0
- package/dist/{client-BTZ3XkrB.mjs → client-RV8NVeB8.mjs} +140 -21
- package/dist/{cloudflare-auth-DQkqoMYa.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -38
- package/dist/{cloudflare-cmd-BKlfGHAy.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +5 -5
- package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
- package/dist/{cloudflare-connect-Ctmrw579.mjs → cloudflare-connect-B8uPZ4nx.mjs} +3 -3
- package/dist/{cloudflare-operations-BT6OWFBk.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
- package/dist/{cloudflare-operations-B9tzgjmf.mjs → cloudflare-operations-fxHb-byx.mjs} +116 -172
- package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
- package/dist/{config-VavjpDnp.d.mts → config-BMHb8RCj.d.mts} +1 -0
- package/dist/config-C_XRIPx2.mjs +89 -0
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-Dg-WkW-C.mjs → connect-Bd4kJd9U.mjs} +5 -5
- package/dist/{create-project-DdoqwFLF.mjs → create-project-Boczwj5r.mjs} +1 -1
- package/dist/{create-project-l9J7pbtm.mjs → create-project-bMf6ffLZ.mjs} +2 -2
- package/dist/{db-gp2sCXyN.mjs → db-8uG64XLl.mjs} +21 -21
- package/dist/{delete-TTedbH6B.mjs → delete-NvbiyeJf.mjs} +2 -2
- package/dist/{deploy-CH-o2CaZ.mjs → deploy-DzAIwqNU.mjs} +908 -582
- package/dist/{deploy-B19L2Bra.mjs → deploy-bjXdFCtn.mjs} +1 -1
- package/dist/{domain-JRF59P_r.mjs → domain-y5Tvydvo.mjs} +3 -3
- package/dist/{email-Bo6G9LOZ.mjs → email-B3umsW75.mjs} +13 -28
- package/dist/{env-BYOrWQnv.mjs → env-BS6qYHDb.mjs} +4 -4
- package/dist/{env-public-BxU_0yTL.d.mts → env-public-BX_r8HR6.d.mts} +1 -1
- package/dist/{env-validation-BB4GkLxn.mjs → env-validation-BPn7vk-V.mjs} +18 -71
- package/dist/{env-validation-BXge7uyK.mjs → env-validation-DbTg7-ar.mjs} +1 -1
- package/dist/{fetch-CXDChK7B.mjs → fetch-BIZJh7vR.mjs} +2 -2
- package/dist/{fetch-stream-AOByI7Ki.mjs → fetch-stream-IvCYKyQL.mjs} +24 -4
- package/dist/{gen-sCtlCOdA.mjs → gen-B580--vC.mjs} +2 -2
- package/dist/gen-BVaUUumi.mjs +2 -0
- package/dist/{github-cmd-0-7PexDq.mjs → github-cmd-v45BdfKX.mjs} +2 -2
- package/dist/{handler-HEcZsaij.d.mts → handler-CZ4nAylQ.d.mts} +1 -1
- package/dist/help-DofyZuY7.mjs +2 -0
- package/dist/{help-GKtwl07I.mjs → help-daGKjXGk.mjs} +229 -747
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +288 -1502
- package/dist/info-B97bTX9N.mjs +113 -0
- package/dist/{init-FZx3Elvz.mjs → init-Bvy7zrBo.mjs} +46 -15
- package/dist/limits-Bq5LG8Id.d.mts +27 -0
- package/dist/limits-Cjuk2VPm.mjs +68 -0
- package/dist/{link-BrQfb_CU.mjs → link-CDqqCjFl.mjs} +3 -3
- package/dist/{list-D44jmIAM.mjs → list-CZj0dzKY.mjs} +3 -3
- package/dist/{live-CKJlvlNp.d.mts → live-Chw1eIMv.d.mts} +1 -1
- package/dist/{local-d1-Bg9OzEEO.mjs → local-d1-2CMnpuW_.mjs} +2 -2
- package/dist/login-DYt_An22.mjs +2 -0
- package/dist/{login-CAsAsQ-_.mjs → login-UZKFM_u7.mjs} +3 -3
- package/dist/{logs-BjKvFnVM.mjs → logs-CUZ6t9t3.mjs} +3 -3
- package/dist/migrate-8_2u55MD.mjs +2 -0
- package/dist/{migrate-BPITvDJN.mjs → migrate-DHul7PRV.mjs} +2 -1
- package/dist/{node-Dt7z256D.mjs → node-BkyRWRx8.mjs} +1 -1
- package/dist/operator-args-CLgKGlwU.mjs +690 -0
- package/dist/{operator-cmd-BK5CCiT9.mjs → operator-cmd-DBA6dl0m.mjs} +68 -22
- package/dist/pages/client.d.mts +34 -2
- package/dist/pages/client.mjs +59 -3
- package/dist/pages/index.d.mts +1 -1
- package/dist/pages/index.mjs +1 -1
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +2 -308
- package/dist/{parse-filename-DioPHiR9.mjs → parse-filename-CUbj-1MP.mjs} +35 -1
- package/dist/plan-D1Q5rf-r.mjs +2 -0
- package/dist/plan-NPpwZ_kc.mjs +58 -0
- package/dist/platform-args-BJdRtlLq.mjs +506 -0
- package/dist/platform-args-D3RXyR6h.mjs +2 -0
- package/dist/{platform-auth-config-BlN8xTdD.mjs → platform-auth-config-B56E9YP1.mjs} +3 -3
- package/dist/{platform-auth-protection-7d5aV2Jg.mjs → platform-auth-protection-BDWO_aER.mjs} +2 -2
- package/dist/{platform-auth-recovery-Dxij8ZbR.mjs → platform-auth-recovery-1gg4CSRe.mjs} +3 -3
- package/dist/{platform-cmd-E0FuL212.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
- package/dist/{platform-cmd-B3hwKrFK.mjs → platform-cmd-DMcQStSc.mjs} +24 -3
- package/dist/{platform-domain-D6Xcy9ZX.mjs → platform-domain-BNkcz0OB.mjs} +2 -2
- package/dist/{platform-lifecycle-k0E0xoxx.mjs → platform-lifecycle-9OyBALhH.mjs} +327 -215
- package/dist/{platform-lifecycle-DMh_qrry.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
- package/dist/{platform-management-Brz_BDiT.mjs → platform-management-CjwLVQwN.mjs} +6 -3
- package/dist/{platform-management-DOtss0BN.mjs → platform-management-CnyTdcWX.mjs} +1 -1
- package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
- package/dist/{platform-recovery-BvtcXON5.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
- package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
- package/dist/{prepare-C-6YZyyg.mjs → prepare-B5Mkic5u.mjs} +1 -1
- package/dist/{prepare-CRhJbVrG.mjs → prepare-DOsL0CC9.mjs} +4 -20
- package/dist/prepare-cgvDMtSb.mjs +2 -0
- package/dist/{project-cmd-BZLCqOqw.mjs → project-cmd-CNzrqvBv.mjs} +16 -16
- package/dist/{project-team-BvgM0WoX.mjs → project-team-DQOWPfQT.mjs} +2 -2
- package/dist/{project-token-l5DqK6Az.mjs → project-token-CTDYU0Cc.mjs} +2 -2
- package/dist/{project-zero-trust-v6Mvpp8y.mjs → project-zero-trust-BNAkW-_0.mjs} +2 -2
- package/dist/{protocol-BBa6cstI.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
- package/dist/protocol-U7bfjHmA.mjs +331 -0
- package/dist/{provision-Fr9pRqce.mjs → provision-C4ORE7G7.mjs} +1 -1
- package/dist/{provision-C4IGqkBf.mjs → provision-CJFgTZY8.mjs} +89 -198
- package/dist/{requests-DN-BbNiM.mjs → requests-MhxYnau8.mjs} +2 -2
- package/dist/resource-name-C7LVpcRm.mjs +11 -0
- package/dist/{rollback-D7rzSaZM.mjs → rollback-CJ6iSDoU.mjs} +3 -3
- package/dist/route-url-CG7U-cRN.mjs +15 -0
- package/dist/{runner-B8wXwWlo.mjs → runner-CXA9Fh8h.mjs} +1 -1
- package/dist/{runner-p-dMs2UN.mjs → runner-Ol0TNjk6.mjs} +2 -2
- package/dist/runtime/ai.d.mts +12 -8
- package/dist/runtime/ai.mjs +84 -17
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.mjs +2 -2
- package/dist/runtime/client-solid.mjs +2 -2
- package/dist/runtime/client-svelte.mjs +2 -2
- package/dist/runtime/client-vue.mjs +2 -2
- package/dist/runtime/client.mjs +2 -2
- package/dist/runtime/durable.d.mts +3 -1
- package/dist/runtime/durable.mjs +4 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-public.d.mts +1 -1
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/kv.mjs +0 -1
- package/dist/runtime/limits.d.mts +2 -0
- package/dist/runtime/limits.mjs +2 -0
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +25 -16
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/migration-handler.mjs +62 -42
- package/dist/runtime/route-url.d.mts +4 -0
- package/dist/runtime/route-url.mjs +2 -0
- package/dist/runtime/routing.d.mts +180 -0
- package/dist/runtime/routing.mjs +1082 -0
- package/dist/runtime/sandbox-container.d.mts +1 -1
- package/dist/runtime/sandbox-container.mjs +1 -1
- package/dist/runtime/sandbox.d.mts +3 -3
- package/dist/runtime/sandbox.mjs +75 -45
- package/dist/runtime/sse.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +4 -2
- package/dist/runtime/ws-server.mjs +27 -2
- package/dist/runtime/ws.d.mts +2 -2
- package/dist/runtime/ws.mjs +8 -6
- package/dist/{sandbox-qpNBT8a3.d.mts → sandbox-XZAqzFlG.d.mts} +11 -8
- package/dist/{sandbox-container-DdNEBfCc.d.mts → sandbox-container-Bo0eiFKz.d.mts} +2 -1
- package/dist/{sandbox-container-4fdqLnyb.mjs → sandbox-container-C6ItmVuN.mjs} +4 -2
- package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
- package/dist/{secret-BOtOl_cb.mjs → secret-Dli5fP0B.mjs} +4 -4
- package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
- package/dist/validate-Dq_L3s0S.mjs +2 -0
- package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
- package/dist/{wrangler-DQF1vKyf.mjs → wrangler-7K-bW_DL.mjs} +8 -239
- package/dist/{ws-BoY7vQML.d.mts → ws-CL1w7GXU.d.mts} +13 -2
- package/package.json +15 -8
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
- package/skills/void/SKILL.md +50 -135
- package/skills/void/docs/guide/ai.md +94 -84
- package/skills/void/docs/guide/app-types.md +3 -32
- package/skills/void/docs/guide/auth.md +12 -116
- package/skills/void/docs/guide/database/d1.md +9 -54
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +5 -26
- package/skills/void/docs/guide/database.md +23 -75
- package/skills/void/docs/guide/deployment.md +27 -113
- package/skills/void/docs/guide/durable-state.md +43 -18
- package/skills/void/docs/guide/edge/headers.md +3 -47
- package/skills/void/docs/guide/edge/prerendering.md +5 -20
- package/skills/void/docs/guide/edge/redirects.md +11 -64
- package/skills/void/docs/guide/edge/revalidation.md +5 -18
- package/skills/void/docs/guide/edge/rewrites.md +56 -284
- package/skills/void/docs/guide/edge/static-assets.md +22 -72
- package/skills/void/docs/guide/email/domains.md +112 -0
- package/skills/void/docs/guide/email/receiving.md +139 -0
- package/skills/void/docs/guide/email/sending.md +231 -0
- package/skills/void/docs/guide/email.md +13 -619
- package/skills/void/docs/guide/env-migration.md +11 -11
- package/skills/void/docs/guide/env-vars.md +9 -29
- package/skills/void/docs/guide/index.md +0 -15
- package/skills/void/docs/guide/jobs.md +3 -18
- package/skills/void/docs/guide/kv.md +5 -11
- package/skills/void/docs/guide/live.md +5 -56
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +78 -125
- package/skills/void/docs/guide/pages-routing/head.md +10 -10
- package/skills/void/docs/guide/pages-routing/islands.md +6 -36
- package/skills/void/docs/guide/pages-routing/layouts.md +6 -128
- package/skills/void/docs/guide/pages-routing/loaders.md +3 -19
- package/skills/void/docs/guide/pages-routing/markdown.md +13 -171
- package/skills/void/docs/guide/pages-routing/overview.md +7 -17
- package/skills/void/docs/guide/pages-routing/view-transitions.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +1 -4
- package/skills/void/docs/guide/platform/administration/email.md +35 -8
- package/skills/void/docs/guide/platform/administration/operations.md +26 -4
- package/skills/void/docs/guide/platform/administration/plans.md +126 -0
- package/skills/void/docs/guide/platform/administration/projects.md +5 -2
- package/skills/void/docs/guide/platform/administration/zero-trust.md +23 -152
- package/skills/void/docs/guide/platform/development/runtime.md +3 -13
- package/skills/void/docs/guide/platform/development/schema-ci.md +0 -58
- package/skills/void/docs/guide/platform/installation/credentials.md +6 -4
- package/skills/void/docs/guide/platform/installation/domains.md +30 -2
- package/skills/void/docs/guide/platform/installation/first-deployment.md +2 -0
- package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
- package/skills/void/docs/guide/platform/installation/prerequisites.md +20 -15
- package/skills/void/docs/guide/platform/installation/setup.md +9 -5
- package/skills/void/docs/guide/platform-administration.md +1 -0
- package/skills/void/docs/guide/queues.md +7 -9
- package/skills/void/docs/guide/quickstart.md +38 -37
- package/skills/void/docs/guide/remote-dev.md +4 -9
- package/skills/void/docs/guide/sandboxes.md +29 -21
- package/skills/void/docs/guide/server-routing.md +9 -72
- package/skills/void/docs/guide/sse.md +4 -18
- package/skills/void/docs/guide/ssg.md +3 -15
- package/skills/void/docs/guide/ssr.md +14 -62
- package/skills/void/docs/guide/storage.md +9 -4
- package/skills/void/docs/guide/type-safety.md +3 -14
- package/skills/void/docs/guide/typed-fetch.md +3 -7
- package/skills/void/docs/guide/websockets.md +68 -40
- package/skills/void/docs/integrations/agents.md +3 -3
- package/skills/void/docs/integrations/cloudflare.md +85 -316
- package/skills/void/docs/integrations/frameworks/analog.md +5 -64
- package/skills/void/docs/integrations/frameworks/astro.md +4 -73
- package/skills/void/docs/integrations/frameworks/nuxt.md +5 -62
- package/skills/void/docs/integrations/frameworks/overview.md +11 -54
- package/skills/void/docs/integrations/frameworks/react-router.md +5 -60
- package/skills/void/docs/integrations/frameworks/sveltekit.md +6 -65
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +4 -62
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -69
- package/skills/void/docs/reference/api/auth.md +156 -0
- package/skills/void/docs/reference/api/client.md +87 -0
- package/skills/void/docs/reference/api/database.md +95 -0
- package/skills/void/docs/reference/api/durable.md +46 -0
- package/skills/void/docs/reference/api/env.md +50 -0
- package/skills/void/docs/reference/api/handlers.md +254 -0
- package/skills/void/docs/reference/api/pages.md +241 -0
- package/skills/void/docs/reference/api/plugin.md +39 -0
- package/skills/void/docs/reference/api/resources.md +109 -0
- package/skills/void/docs/reference/api/rewrites.md +76 -0
- package/skills/void/docs/reference/api/types.md +92 -0
- package/skills/void/docs/reference/api.md +56 -1218
- package/skills/void/docs/reference/cli/auth.md +88 -0
- package/skills/void/docs/reference/cli/database.md +128 -0
- package/skills/void/docs/reference/cli/deploy.md +85 -0
- package/skills/void/docs/reference/cli/domains.md +41 -0
- package/skills/void/docs/reference/cli/email.md +129 -0
- package/skills/void/docs/reference/cli/generate.md +116 -0
- package/skills/void/docs/reference/cli/github.md +189 -0
- package/skills/void/docs/reference/cli/platform-config.md +92 -0
- package/skills/void/docs/reference/cli/platform-email.md +81 -0
- package/skills/void/docs/reference/cli/platform-installation.md +127 -0
- package/skills/void/docs/reference/cli/platform-operations.md +90 -0
- package/skills/void/docs/reference/cli/platform-users.md +89 -0
- package/skills/void/docs/reference/cli/platform-zero-trust.md +45 -0
- package/skills/void/docs/reference/cli/platform.md +70 -0
- package/skills/void/docs/reference/cli/project.md +214 -0
- package/skills/void/docs/reference/cli/secrets.md +76 -0
- package/skills/void/docs/reference/cli/setup.md +70 -0
- package/skills/void/docs/reference/cli.md +32 -1682
- package/skills/void/docs/reference/config.md +12 -18
- package/skills/void/docs/reference/resource-inference.md +3 -58
- package/skills/void/docs/reference/structure.md +14 -41
- package/dist/canonical-json-DuDiiUsQ.mjs +0 -13
- package/dist/client-Czz8o5jP.mjs +0 -2
- package/dist/gen-CNJ62MM7.mjs +0 -2
- package/dist/help-CmZzxUba.mjs +0 -2
- package/dist/login-CGcRKEoi.mjs +0 -2
- package/dist/migrate-CYfbKkXh.mjs +0 -2
- package/dist/plan-BEZ8VJW0.mjs +0 -256
- package/dist/plan-DpuOr14e.mjs +0 -2
- package/dist/prepare-Bm3iq-u4.mjs +0 -2
- package/dist/validate-EKmJWxmy.mjs +0 -2
- /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
//#region src/cli/env-schema-probe.ts
|
|
6
6
|
/**
|
|
7
|
-
* The self-host `void deploy --
|
|
7
|
+
* The self-host `void deploy --platform cloudflare` orchestrator validates the REAL
|
|
8
8
|
* build artifact (`dist/ssr/wrangler.json` `vars`) instead of predicting it. Two
|
|
9
9
|
* pieces still need project code, and BOTH run here — in an ISOLATED SUBPROCESS —
|
|
10
10
|
* because the orchestrator runs in a credential-bearing PARENT (CF Access service
|
|
@@ -169,7 +169,7 @@ function emitResult(result) {
|
|
|
169
169
|
* facts. The import stays isolated because env.ts is arbitrary project code.
|
|
170
170
|
*/
|
|
171
171
|
async function runFactsChild(root) {
|
|
172
|
-
const { deriveSelfHostSchemaFacts, SelfHostSchemaError } = await import("../env-validation-
|
|
172
|
+
const { deriveSelfHostSchemaFacts, SelfHostSchemaError } = await import("../env-validation-DbTg7-ar.mjs");
|
|
173
173
|
try {
|
|
174
174
|
emitResult({
|
|
175
175
|
kind: "ok",
|
|
@@ -194,7 +194,7 @@ async function runFactsChild(root) {
|
|
|
194
194
|
* fault → fail closed as a values-free schema error.
|
|
195
195
|
*/
|
|
196
196
|
async function runValidateEmittedChild(root) {
|
|
197
|
-
const { computeInvalidEmittedKeys, readEmittedWorkerVars, SelfHostSchemaError } = await import("../env-validation-
|
|
197
|
+
const { computeInvalidEmittedKeys, readEmittedWorkerVars, SelfHostSchemaError } = await import("../env-validation-DbTg7-ar.mjs");
|
|
198
198
|
const emitted = readEmittedWorkerVars(root);
|
|
199
199
|
if (!emitted.ok) {
|
|
200
200
|
emitResult({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as join } from "./dist-BVqXeR_h.mjs";
|
|
2
2
|
import { t as cfAccessHeaders } from "./cf-access-DRsQRe6k.mjs";
|
|
3
|
-
import { a as getApiUrl } from "./auth-
|
|
3
|
+
import { a as getApiUrl } from "./auth-CSkdO2Bb.mjs";
|
|
4
4
|
import { s as normalizePlatformApiUrl } from "./platform-registry-QBa4DK32.mjs";
|
|
5
5
|
import { i as isCloudflareAccessChallenge, n as ensurePlatformAccessToken, t as ensureCloudflaredToken } from "./cf-access-P0iZnu0q.mjs";
|
|
6
6
|
import { n as getPackageDir } from "./agents-B_pX_HmQ.mjs";
|
|
@@ -152,10 +152,11 @@ function isPreflightRejection(error) {
|
|
|
152
152
|
* the server's precheck, the only atomic (project-locked) verdict: if
|
|
153
153
|
* an earlier attempt or a concurrent deploy is still in flight, the
|
|
154
154
|
* replay is rejected with 409 and surfaced as a deploy conflict
|
|
155
|
-
* naming the deployment id.
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
155
|
+
* naming the deployment id. Receipt-aware platforms additionally bind
|
|
156
|
+
* the stable invocation key to the accepted artifact, so an accepted
|
|
157
|
+
* request can be recovered without creating another execution. Older
|
|
158
|
+
* platforms retain their concurrency guard. No client-side deployment
|
|
159
|
+
* lookup may authorize replay or identify an unrelated conflicting row.
|
|
159
160
|
*/
|
|
160
161
|
const DEPLOY_POST_MAX_RETRIES = 3;
|
|
161
162
|
const DEPLOY_POST_BACKOFF_MS = [
|
|
@@ -163,6 +164,24 @@ const DEPLOY_POST_BACKOFF_MS = [
|
|
|
163
164
|
5e3,
|
|
164
165
|
1e4
|
|
165
166
|
];
|
|
167
|
+
const DEPLOY_OBSERVATION_TIMEOUT_MS = 3e4;
|
|
168
|
+
const DEPLOY_OBSERVATION_DEADLINE_MS = 18e5;
|
|
169
|
+
const DEPLOY_OBSERVATION_BACKOFF_MS = [
|
|
170
|
+
1e3,
|
|
171
|
+
2e3,
|
|
172
|
+
5e3,
|
|
173
|
+
1e4,
|
|
174
|
+
3e4
|
|
175
|
+
];
|
|
176
|
+
const DEPLOY_EVENT_MAX_BYTES = 1048576;
|
|
177
|
+
var DeploymentProtocolError = class extends Error {};
|
|
178
|
+
function parseDeployEvent(value) {
|
|
179
|
+
if (!value || typeof value !== "object" || !("event" in value) || typeof value.event !== "string") throw new DeploymentProtocolError("Invalid deployment event from platform.");
|
|
180
|
+
const event = value;
|
|
181
|
+
if (event.seq !== void 0 && (!Number.isSafeInteger(event.seq) || event.seq < 1)) throw new DeploymentProtocolError("Invalid deployment event sequence from platform.");
|
|
182
|
+
if (event.event === "start" && typeof event.deploymentId !== "string" || event.event === "done" && (typeof event.deployment !== "string" || typeof event.url !== "string" || !Array.isArray(event.urls) || !event.urls.every((url) => typeof url === "string") || !Number.isSafeInteger(event.assets) || event.assets < 0 || !Number.isSafeInteger(event.workers) || event.workers < 0 || event.published !== void 0 && typeof event.published !== "boolean") || event.event === "error" && (typeof event.message !== "string" || typeof event.step !== "string")) throw new DeploymentProtocolError("Invalid deployment result from platform.");
|
|
183
|
+
return event;
|
|
184
|
+
}
|
|
166
185
|
/**
|
|
167
186
|
* HTTP client for the Void platform API.
|
|
168
187
|
*/
|
|
@@ -237,10 +256,10 @@ var PlatformClient = class {
|
|
|
237
256
|
if (!res.ok) await throwPlatformApiError("Failed to list projects", res);
|
|
238
257
|
return res.json();
|
|
239
258
|
}
|
|
240
|
-
/** A lightweight project list for interactive linking
|
|
259
|
+
/** A lightweight project list for interactive linking. */
|
|
241
260
|
async listProjectChoices() {
|
|
242
261
|
const res = await this.request(`${this.baseUrl}/projects/choices`, { headers: { ...this.authHeaders } });
|
|
243
|
-
if (res.status === 404)
|
|
262
|
+
if (res.status === 404) throw new Error("This platform does not support project lookup. Ask its administrator to upgrade the platform runtime.");
|
|
244
263
|
if (!res.ok) await throwPlatformApiError("Failed to list project choices", res);
|
|
245
264
|
return res.json();
|
|
246
265
|
}
|
|
@@ -251,12 +270,12 @@ var PlatformClient = class {
|
|
|
251
270
|
if (!res.ok) await throwPlatformApiError("Failed to get project", res);
|
|
252
271
|
return res.json();
|
|
253
272
|
}
|
|
254
|
-
/**
|
|
273
|
+
/** Resolve a slug through the current platform contract. */
|
|
255
274
|
async findProjectBySlug(slug) {
|
|
256
275
|
const url = new URL(`${this.baseUrl}/projects/resolve`);
|
|
257
276
|
url.searchParams.set("slug", slug);
|
|
258
277
|
const res = await this.request(url.toString(), { headers: { ...this.authHeaders } });
|
|
259
|
-
if (res.status === 404)
|
|
278
|
+
if (res.status === 404) throw new Error("This platform does not support project lookup. Ask its administrator to upgrade the platform runtime.");
|
|
260
279
|
if (!res.ok) await throwPlatformApiError("Failed to resolve project", res);
|
|
261
280
|
return (await res.json()).project;
|
|
262
281
|
}
|
|
@@ -506,7 +525,8 @@ var PlatformClient = class {
|
|
|
506
525
|
method: "POST",
|
|
507
526
|
headers: {
|
|
508
527
|
"Content-Type": "application/json",
|
|
509
|
-
...this.authHeaders
|
|
528
|
+
...this.authHeaders,
|
|
529
|
+
"x-void-deploy-idempotency-key": crypto.randomUUID()
|
|
510
530
|
},
|
|
511
531
|
body: JSON.stringify(payload)
|
|
512
532
|
});
|
|
@@ -568,6 +588,24 @@ var PlatformClient = class {
|
|
|
568
588
|
}
|
|
569
589
|
throw new PlatformApiError("Deploy failed", res.status, body, isCloudflareAccessChallenge(res) ? void 0 : "deploy");
|
|
570
590
|
}
|
|
591
|
+
const receipt = res.headers.get("x-void-deployment-id");
|
|
592
|
+
if (receipt !== null && !/^[A-Za-z0-9_-]{1,128}$/.test(receipt)) {
|
|
593
|
+
res.body?.cancel().catch(() => {});
|
|
594
|
+
throw new Error("Invalid deployment receipt from platform.");
|
|
595
|
+
}
|
|
596
|
+
let cursor = 0;
|
|
597
|
+
let terminal = false;
|
|
598
|
+
if (!res.body) {
|
|
599
|
+
if (receipt) {
|
|
600
|
+
yield {
|
|
601
|
+
event: "start",
|
|
602
|
+
deploymentId: receipt
|
|
603
|
+
};
|
|
604
|
+
yield* this.followDeploymentEvents(projectId, receipt, cursor);
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
throw new Error("Platform returned no deployment event stream.");
|
|
608
|
+
}
|
|
571
609
|
const reader = res.body.getReader();
|
|
572
610
|
const decoder = new TextDecoder();
|
|
573
611
|
let buffer = "";
|
|
@@ -576,10 +614,49 @@ var PlatformClient = class {
|
|
|
576
614
|
const startedAt = Date.now();
|
|
577
615
|
let eventCount = 0;
|
|
578
616
|
let lastEventName = "<none>";
|
|
617
|
+
let streamFinished = false;
|
|
618
|
+
let readTimer;
|
|
619
|
+
const read = async () => {
|
|
620
|
+
if (!receipt) return reader.read();
|
|
621
|
+
try {
|
|
622
|
+
return await Promise.race([reader.read(), new Promise((_, reject) => {
|
|
623
|
+
readTimer = setTimeout(() => reject(/* @__PURE__ */ new TypeError("Deployment event stream timed out.")), DEPLOY_OBSERVATION_TIMEOUT_MS);
|
|
624
|
+
})]);
|
|
625
|
+
} finally {
|
|
626
|
+
clearTimeout(readTimer);
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
const parseLine = (line) => {
|
|
630
|
+
if (Buffer.byteLength(line) > DEPLOY_EVENT_MAX_BYTES) throw new DeploymentProtocolError("Deployment event exceeds the platform response limit.");
|
|
631
|
+
if (!line.trim()) return null;
|
|
632
|
+
const event = parseDeployEvent(JSON.parse(line));
|
|
633
|
+
if (event.seq !== void 0) {
|
|
634
|
+
if (event.seq <= cursor) return null;
|
|
635
|
+
cursor = event.seq;
|
|
636
|
+
}
|
|
637
|
+
eventCount++;
|
|
638
|
+
lastEventName = event.event;
|
|
639
|
+
cliLog?.info("deploy_event", {
|
|
640
|
+
eventCount,
|
|
641
|
+
event: lastEventName,
|
|
642
|
+
raw: line.slice(0, 200)
|
|
643
|
+
});
|
|
644
|
+
if (receipt && event.event === "start") return null;
|
|
645
|
+
terminal = event.event === "done" || event.event === "error";
|
|
646
|
+
return event;
|
|
647
|
+
};
|
|
579
648
|
try {
|
|
649
|
+
if (receipt) yield {
|
|
650
|
+
event: "start",
|
|
651
|
+
deploymentId: receipt
|
|
652
|
+
};
|
|
580
653
|
while (true) {
|
|
581
|
-
const { done, value } = await
|
|
654
|
+
const { done, value } = await read();
|
|
582
655
|
if (done) {
|
|
656
|
+
streamFinished = true;
|
|
657
|
+
buffer += decoder.decode();
|
|
658
|
+
const event = parseLine(buffer);
|
|
659
|
+
if (event) yield event;
|
|
583
660
|
cliLog?.info("deploy_stream_eof", {
|
|
584
661
|
bytesRead,
|
|
585
662
|
eventCount,
|
|
@@ -597,18 +674,13 @@ var PlatformClient = class {
|
|
|
597
674
|
while ((newlineIdx = buffer.indexOf("\n")) !== -1) {
|
|
598
675
|
const line = buffer.slice(0, newlineIdx);
|
|
599
676
|
buffer = buffer.slice(newlineIdx + 1);
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
eventCount++;
|
|
603
|
-
lastEventName = event.event ?? "<no-event-field>";
|
|
604
|
-
cliLog?.info("deploy_event", {
|
|
605
|
-
eventCount,
|
|
606
|
-
event: lastEventName,
|
|
607
|
-
raw: line.slice(0, 200)
|
|
608
|
-
});
|
|
677
|
+
const event = parseLine(line);
|
|
678
|
+
if (event) {
|
|
609
679
|
yield event;
|
|
680
|
+
if (terminal) return;
|
|
610
681
|
}
|
|
611
682
|
}
|
|
683
|
+
if (Buffer.byteLength(buffer) > DEPLOY_EVENT_MAX_BYTES) throw new DeploymentProtocolError("Deployment event exceeds the platform response limit.");
|
|
612
684
|
}
|
|
613
685
|
} catch (err) {
|
|
614
686
|
cliLog?.error("deploy_stream_error", err, {
|
|
@@ -616,8 +688,55 @@ var PlatformClient = class {
|
|
|
616
688
|
eventCount,
|
|
617
689
|
lastEvent: lastEventName
|
|
618
690
|
});
|
|
619
|
-
throw err;
|
|
691
|
+
if (!receipt || err instanceof DeploymentProtocolError || err instanceof SyntaxError || err instanceof DOMException && err.name === "AbortError") throw err;
|
|
692
|
+
} finally {
|
|
693
|
+
clearTimeout(readTimer);
|
|
694
|
+
if (!streamFinished) reader.cancel().catch(() => {});
|
|
695
|
+
reader.releaseLock();
|
|
696
|
+
}
|
|
697
|
+
if (receipt && !terminal) yield* this.followDeploymentEvents(projectId, receipt, cursor);
|
|
698
|
+
}
|
|
699
|
+
async *followDeploymentEvents(projectId, deploymentId, since) {
|
|
700
|
+
let cursor = since;
|
|
701
|
+
let failures = 0;
|
|
702
|
+
const deadline = Date.now() + DEPLOY_OBSERVATION_DEADLINE_MS;
|
|
703
|
+
while (Date.now() < deadline) {
|
|
704
|
+
const url = `${this.baseUrl}/projects/${encodeURIComponent(projectId)}/deployments/${encodeURIComponent(deploymentId)}/events?since=${cursor}`;
|
|
705
|
+
let page;
|
|
706
|
+
try {
|
|
707
|
+
const response = await this.request(url, {
|
|
708
|
+
headers: { ...this.authHeaders },
|
|
709
|
+
signal: AbortSignal.timeout(DEPLOY_OBSERVATION_TIMEOUT_MS)
|
|
710
|
+
});
|
|
711
|
+
if (!response.ok) await throwPlatformApiError("Failed to observe deployment", response, "read");
|
|
712
|
+
page = await response.json();
|
|
713
|
+
} catch (err) {
|
|
714
|
+
if (!(err instanceof TypeError || err instanceof DOMException && err.name === "TimeoutError" || err instanceof PlatformApiError && (err.status === 429 || err.status >= 500)) || failures >= DEPLOY_OBSERVATION_BACKOFF_MS.length) throw err;
|
|
715
|
+
const delayMs = DEPLOY_OBSERVATION_BACKOFF_MS[failures++];
|
|
716
|
+
this.cliLog?.warn("deploy_observation_retry", {
|
|
717
|
+
deploymentId,
|
|
718
|
+
cursor,
|
|
719
|
+
delayMs
|
|
720
|
+
});
|
|
721
|
+
await sleep(delayMs);
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
failures = 0;
|
|
725
|
+
if (!page || page.deploymentId !== deploymentId || !Array.isArray(page.events) || page.events.length > 1e3 || !Number.isSafeInteger(page.lastSeq) || page.lastSeq < cursor || typeof page.terminal !== "boolean") throw new Error("Invalid deployment observation response from platform.");
|
|
726
|
+
let previousSeq = 0;
|
|
727
|
+
for (const row of page.events) {
|
|
728
|
+
if (!row || !Number.isSafeInteger(row.seq) || row.seq <= previousSeq || row.seq > page.lastSeq) throw new Error("Invalid deployment observation sequence from platform.");
|
|
729
|
+
previousSeq = row.seq;
|
|
730
|
+
const event = parseDeployEvent(row.event);
|
|
731
|
+
if (row.seq <= cursor) continue;
|
|
732
|
+
cursor = row.seq;
|
|
733
|
+
if (event.event !== "start") yield event;
|
|
734
|
+
if (event.event === "done" || event.event === "error") return;
|
|
735
|
+
}
|
|
736
|
+
if (page.terminal) throw new Error("Platform finished deployment without a terminal result.");
|
|
737
|
+
await sleep(1e3);
|
|
620
738
|
}
|
|
739
|
+
throw new Error(`Timed out observing deployment ${deploymentId}. Inspect with \`void project status\`.`);
|
|
621
740
|
}
|
|
622
741
|
async listSecrets(projectId) {
|
|
623
742
|
const res = await this.request(`${this.baseUrl}/projects/${projectId}/secrets`, { headers: { ...this.authHeaders } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as resolveCloudflareOperationArgv, n as decodeCloudflareOperationResult, r as encodeCloudflareOperation } from "./cloudflare-process-B-wekeR6.mjs";
|
|
2
2
|
import { execFile, spawn, spawnSync } from "node:child_process";
|
|
3
3
|
//#region src/cli/cloudflare-auth.ts
|
|
4
4
|
var CloudflareAuthenticationError = class extends Error {
|
|
@@ -22,26 +22,25 @@ async function ensureCloudflareAuthentication(options) {
|
|
|
22
22
|
if (overrides.length > 0) throw new CloudflareAuthenticationError(`Cloudflare browser login cannot replace credentials supplied by ${overrides.join(", ")}. Remove these overrides from this shell and rerun \`void cloudflare login\`.`, "environment-credentials");
|
|
23
23
|
}
|
|
24
24
|
if (options.acceptApiToken && !options.requireAccounts && (process.env.CLOUDFLARE_API_TOKEN?.trim() || process.env.CF_API_TOKEN?.trim())) return { accounts: [] };
|
|
25
|
-
const run = async (
|
|
25
|
+
const run = async (operation, capture) => {
|
|
26
26
|
if (options.beforeRun && !options.beforeRun()) throw new CloudflareAuthenticationError("", "uploader-changed");
|
|
27
|
-
return await options.runWrangler(
|
|
27
|
+
return await options.runWrangler(operation, capture);
|
|
28
|
+
};
|
|
29
|
+
const whoami = {
|
|
30
|
+
type: "auth.whoami",
|
|
31
|
+
...options.configPath ? { configPath: options.configPath } : {}
|
|
28
32
|
};
|
|
29
|
-
const whoamiArgs = [
|
|
30
|
-
"whoami",
|
|
31
|
-
"--json",
|
|
32
|
-
...options.whoamiArgs ?? []
|
|
33
|
-
];
|
|
34
33
|
const readSession = async () => {
|
|
35
|
-
const result = await run(
|
|
34
|
+
const result = await run(whoami, true);
|
|
36
35
|
if (!isCleanExit(result)) return null;
|
|
37
|
-
const session = parseCloudflareAuthSession(result.
|
|
36
|
+
const session = parseCloudflareAuthSession(result.data);
|
|
38
37
|
if (options.requireAccounts) return session && session.accounts.length > 0 ? session : null;
|
|
39
|
-
return session
|
|
38
|
+
return session;
|
|
40
39
|
};
|
|
41
40
|
const existing = options.forceLogin ? null : await readSession();
|
|
42
41
|
if (existing) return existing;
|
|
43
42
|
if (!(options.interactive ?? (process.stdin.isTTY && process.stdout.isTTY))) throw new CloudflareAuthenticationError("Cloudflare authentication is required. Set CLOUDFLARE_API_TOKEN in CI, or run `void cloudflare login` in an interactive terminal.", "not-authenticated");
|
|
44
|
-
if (!isCleanExit(await run(
|
|
43
|
+
if (!isCleanExit(await run({ type: "auth.login" }, false))) throw new CloudflareAuthenticationError("Cloudflare browser sign-in did not complete. Run `void cloudflare login` to try again.", "login");
|
|
45
44
|
const authenticated = await readSession();
|
|
46
45
|
if (!authenticated) throw new CloudflareAuthenticationError("Cloudflare sign-in completed without a usable session. Run `void cloudflare login` to try again.", "not-authenticated");
|
|
47
46
|
return authenticated;
|
|
@@ -53,13 +52,7 @@ function cloudflareCredentialOverrides(source = process.env) {
|
|
|
53
52
|
const email = ["CLOUDFLARE_EMAIL", "CF_EMAIL"].find((key) => Boolean(source[key]));
|
|
54
53
|
return [...tokens, ...key && email ? [key, email] : []];
|
|
55
54
|
}
|
|
56
|
-
function parseCloudflareAuthSession(
|
|
57
|
-
let value;
|
|
58
|
-
try {
|
|
59
|
-
value = JSON.parse(stdout.trim());
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
55
|
+
function parseCloudflareAuthSession(value) {
|
|
63
56
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
64
57
|
const record = value;
|
|
65
58
|
if (record.loggedIn !== true || !Array.isArray(record.accounts)) return null;
|
|
@@ -80,39 +73,49 @@ function parseCloudflareAuthSession(stdout) {
|
|
|
80
73
|
};
|
|
81
74
|
}
|
|
82
75
|
function createBundledCloudflareAuthRunner(root) {
|
|
83
|
-
const [command, ...prefix] =
|
|
84
|
-
return (
|
|
85
|
-
const
|
|
76
|
+
const [command, ...prefix] = resolveCloudflareOperationArgv(root);
|
|
77
|
+
return (operation, capture) => {
|
|
78
|
+
const args = encodeCloudflareOperation(operation);
|
|
79
|
+
const env = cloudflareAuthCommandEnvironment(operation);
|
|
80
|
+
const streaming = cloudflareAuthNeedsTerminal(operation);
|
|
86
81
|
const result = spawnSync(command, [...prefix, ...args], {
|
|
87
82
|
cwd: root,
|
|
88
83
|
encoding: "utf8",
|
|
89
84
|
env,
|
|
90
85
|
maxBuffer: 10485760,
|
|
91
86
|
shell: false,
|
|
92
|
-
stdio:
|
|
87
|
+
stdio: streaming ? "inherit" : [
|
|
93
88
|
"ignore",
|
|
94
89
|
"pipe",
|
|
95
90
|
"pipe"
|
|
96
|
-
]
|
|
91
|
+
],
|
|
97
92
|
timeout: 6e5,
|
|
98
93
|
windowsHide: true
|
|
99
94
|
});
|
|
100
|
-
|
|
95
|
+
const raw = {
|
|
101
96
|
status: result.status,
|
|
102
|
-
stderr:
|
|
103
|
-
stdout:
|
|
97
|
+
stderr: streaming ? "" : result.stderr || "",
|
|
98
|
+
stdout: streaming ? "" : result.stdout || "",
|
|
104
99
|
signal: result.signal,
|
|
105
100
|
error: result.error?.message
|
|
106
101
|
};
|
|
102
|
+
if (streaming) return raw;
|
|
103
|
+
const decoded = decodeCloudflareOperationResult(raw);
|
|
104
|
+
if (!capture) {
|
|
105
|
+
if (decoded.stdout) process.stdout.write(decoded.stdout);
|
|
106
|
+
if (decoded.stderr) process.stderr.write(decoded.stderr);
|
|
107
|
+
}
|
|
108
|
+
return decoded;
|
|
107
109
|
};
|
|
108
110
|
}
|
|
109
111
|
/** Run a captured auth command without blocking terminal input or exposing credentials. */
|
|
110
|
-
function runCloudflareAuthCommand(root,
|
|
111
|
-
const [command, ...prefix] =
|
|
112
|
-
|
|
112
|
+
function runCloudflareAuthCommand(root, operation, signal) {
|
|
113
|
+
const [command, ...prefix] = resolveCloudflareOperationArgv(root);
|
|
114
|
+
const args = encodeCloudflareOperation(operation);
|
|
115
|
+
if (cloudflareAuthNeedsTerminal(operation)) return new Promise((resolve) => {
|
|
113
116
|
const child = spawn(command, [...prefix, ...args], {
|
|
114
117
|
cwd: root,
|
|
115
|
-
env: cloudflareAuthCommandEnvironment(
|
|
118
|
+
env: cloudflareAuthCommandEnvironment(operation),
|
|
116
119
|
shell: false,
|
|
117
120
|
signal,
|
|
118
121
|
stdio: "inherit",
|
|
@@ -140,29 +143,29 @@ function runCloudflareAuthCommand(root, args, signal) {
|
|
|
140
143
|
execFile(command, [...prefix, ...args], {
|
|
141
144
|
cwd: root,
|
|
142
145
|
encoding: "utf8",
|
|
143
|
-
env: cloudflareAuthCommandEnvironment(
|
|
146
|
+
env: cloudflareAuthCommandEnvironment(operation),
|
|
144
147
|
maxBuffer: 10485760,
|
|
145
148
|
shell: false,
|
|
146
149
|
signal,
|
|
147
150
|
timeout: 6e5,
|
|
148
151
|
windowsHide: true
|
|
149
152
|
}, (error, stdout, stderr) => {
|
|
150
|
-
resolve({
|
|
153
|
+
resolve(decodeCloudflareOperationResult({
|
|
151
154
|
status: error ? typeof error.code === "number" ? error.code : null : 0,
|
|
152
155
|
stderr,
|
|
153
156
|
stdout,
|
|
154
157
|
signal: error?.signal,
|
|
155
158
|
error: error?.message
|
|
156
|
-
});
|
|
159
|
+
}));
|
|
157
160
|
}).stdin?.end();
|
|
158
161
|
});
|
|
159
162
|
}
|
|
160
|
-
function cloudflareAuthCommandEnvironment(
|
|
163
|
+
function cloudflareAuthCommandEnvironment(operation, source = process.env) {
|
|
161
164
|
return cloudflareAuthEnvironment(source);
|
|
162
165
|
}
|
|
163
166
|
/** Browser login must display cf's prompts before it completes. */
|
|
164
|
-
function cloudflareAuthNeedsTerminal(
|
|
165
|
-
return
|
|
167
|
+
function cloudflareAuthNeedsTerminal(operation) {
|
|
168
|
+
return operation.type === "auth.login";
|
|
166
169
|
}
|
|
167
170
|
function cloudflareAuthEnvironment(source = process.env) {
|
|
168
171
|
const env = { ...source };
|
|
@@ -182,4 +185,4 @@ function isCleanExit(result) {
|
|
|
182
185
|
return result.status === 0 && result.signal == null && (result.error == null || result.error === "");
|
|
183
186
|
}
|
|
184
187
|
//#endregion
|
|
185
|
-
export {
|
|
188
|
+
export { parseCloudflareAuthSession as a, ensureCloudflareAuthentication as i, cloudflareCredentialOverrides as n, runCloudflareAuthCommand as o, createBundledCloudflareAuthRunner as r, CloudflareAuthenticationError as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as basename } from "./dist-BVqXeR_h.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { y as readRootWranglerConfig } from "./wrangler-7K-bW_DL.mjs";
|
|
3
3
|
import { j as log } from "./dist-CTBk70IR.mjs";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as parseCloudflareAuthSession, i as ensureCloudflareAuthentication, n as cloudflareCredentialOverrides, r as createBundledCloudflareAuthRunner } from "./cloudflare-auth-Qdc7tw8F.mjs";
|
|
5
5
|
//#region src/cli/cloudflare-cmd.ts
|
|
6
6
|
async function runCloudflareCommand(root, args) {
|
|
7
7
|
const runWrangler = createBundledCloudflareAuthRunner(root);
|
|
@@ -14,14 +14,14 @@ async function runCloudflareCommand(root, args) {
|
|
|
14
14
|
console.log("Successfully logged in.");
|
|
15
15
|
return;
|
|
16
16
|
case "status": {
|
|
17
|
-
const result = await runWrangler(
|
|
18
|
-
const session = result.status === 0 && !result.signal && !result.error ? parseCloudflareAuthSession(result.
|
|
17
|
+
const result = await runWrangler({ type: "auth.whoami" }, true);
|
|
18
|
+
const session = result.status === 0 && !result.signal && !result.error ? parseCloudflareAuthSession(result.data) : null;
|
|
19
19
|
if (!session) throw new Error("Not signed in to Cloudflare. Run `void cloudflare login`.");
|
|
20
20
|
log.info(formatSession(root, session));
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
case "logout": {
|
|
24
|
-
if ((await runWrangler(
|
|
24
|
+
if ((await runWrangler({ type: "auth.logout" }, true)).status !== 0) throw new Error("Could not remove the local Cloudflare browser session.");
|
|
25
25
|
const overrides = cloudflareCredentialOverrides();
|
|
26
26
|
if (overrides.length > 0) log.warn(`Removed the local Cloudflare browser session. Environment credentials remain active: ${overrides.join(", ")}.`);
|
|
27
27
|
else log.success("Signed out of Cloudflare.");
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { a as join } from "./dist-BVqXeR_h.mjs";
|
|
2
|
+
import "./project-paths-GgcMozYz.mjs";
|
|
3
|
+
import { m as readConfig } from "./config-Br_JZD6u.mjs";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { parse } from "jsonc-parser";
|
|
7
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
|
+
//#region src/cloudflare-config.ts
|
|
9
|
+
const MATERIALIZED_CLOUDFLARE_FILE = ".void-wrangler.jsonc";
|
|
10
|
+
const VOID_LOCK_FILE = "void.lock.json";
|
|
11
|
+
const PREVIEW_POINTER_FILE = "preview-deploy-config.json";
|
|
12
|
+
function isObject(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
function arrayIdentity(value) {
|
|
16
|
+
if (isObject(value)) {
|
|
17
|
+
for (const key of [
|
|
18
|
+
"binding",
|
|
19
|
+
"name",
|
|
20
|
+
"tag",
|
|
21
|
+
"class_name",
|
|
22
|
+
"pattern",
|
|
23
|
+
"route"
|
|
24
|
+
]) if (typeof value[key] === "string") return `${key}:${value[key]}`;
|
|
25
|
+
}
|
|
26
|
+
return JSON.stringify(value) ?? String(value);
|
|
27
|
+
}
|
|
28
|
+
/** Keep authored values authoritative while retaining fields produced by Void. */
|
|
29
|
+
function mergeConfig(previous, resolved, authored) {
|
|
30
|
+
if (isDeepStrictEqual(previous, authored)) return resolved;
|
|
31
|
+
if (Array.isArray(previous) && Array.isArray(resolved) && Array.isArray(authored)) {
|
|
32
|
+
const previousByIdentity = new Map(previous.map((item) => [arrayIdentity(item), item]));
|
|
33
|
+
const resolvedByIdentity = new Map(resolved.map((item) => [arrayIdentity(item), item]));
|
|
34
|
+
const authoredIdentities = new Set(authored.map(arrayIdentity));
|
|
35
|
+
return [...authored.map((item) => {
|
|
36
|
+
const identity = arrayIdentity(item);
|
|
37
|
+
return previousByIdentity.has(identity) && resolvedByIdentity.has(identity) ? mergeConfig(previousByIdentity.get(identity), resolvedByIdentity.get(identity), item) : item;
|
|
38
|
+
}), ...resolved.filter((item) => {
|
|
39
|
+
const identity = arrayIdentity(item);
|
|
40
|
+
return !previousByIdentity.has(identity) && !authoredIdentities.has(identity);
|
|
41
|
+
})];
|
|
42
|
+
}
|
|
43
|
+
if (isObject(previous) && isObject(resolved) && isObject(authored)) {
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const key of /* @__PURE__ */ new Set([
|
|
46
|
+
...Object.keys(previous),
|
|
47
|
+
...Object.keys(resolved),
|
|
48
|
+
...Object.keys(authored)
|
|
49
|
+
])) {
|
|
50
|
+
if (!(key in authored)) {
|
|
51
|
+
if (!(key in previous) && key in resolved) Object.defineProperty(result, key, {
|
|
52
|
+
value: resolved[key],
|
|
53
|
+
enumerable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const value = mergeConfig(previous[key], resolved[key], authored[key]);
|
|
60
|
+
Object.defineProperty(result, key, {
|
|
61
|
+
value,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
return authored;
|
|
70
|
+
}
|
|
71
|
+
function parseCloudflareText(text, path) {
|
|
72
|
+
const errors = [];
|
|
73
|
+
const value = parse(text.replace(/^\uFEFF/, ""), errors, { allowTrailingComma: true });
|
|
74
|
+
if (errors.length > 0 || !isObject(value)) throw new Error(`config: ${path} must contain a valid JSON/JSONC object.`);
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
function readState(root) {
|
|
78
|
+
const path = join(root, VOID_LOCK_FILE);
|
|
79
|
+
if (!existsSync(path)) return;
|
|
80
|
+
let value;
|
|
81
|
+
try {
|
|
82
|
+
value = JSON.parse(readFileSync(path, "utf8"));
|
|
83
|
+
} catch {
|
|
84
|
+
throw new Error(`config: Invalid ${VOID_LOCK_FILE}. Fix or restore it before continuing.`);
|
|
85
|
+
}
|
|
86
|
+
if (!isObject(value) || value.version !== 1 || !isObject(value.source) || !isObject(value.resolved) || typeof value.text !== "string") throw new Error(`config: Invalid ${VOID_LOCK_FILE}. Fix or restore it before continuing.`);
|
|
87
|
+
const state = value;
|
|
88
|
+
if (!isDeepStrictEqual(parseCloudflareText(state.text, "void.lock.json"), state.resolved)) state.text = `${provenance(state.text)}${JSON.stringify(state.resolved, null, 2)}\n`;
|
|
89
|
+
return state;
|
|
90
|
+
}
|
|
91
|
+
function writeAtomic(path, content) {
|
|
92
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
93
|
+
writeFileSync(temporary, content, { flag: "wx" });
|
|
94
|
+
try {
|
|
95
|
+
renameSync(temporary, path);
|
|
96
|
+
} finally {
|
|
97
|
+
rmSync(temporary, { force: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function writeState(root, state) {
|
|
101
|
+
const path = join(root, VOID_LOCK_FILE);
|
|
102
|
+
const content = `${JSON.stringify(state, null, 2)}\n`;
|
|
103
|
+
if (existsSync(path)) try {
|
|
104
|
+
if (isDeepStrictEqual(JSON.parse(readFileSync(path, "utf8")), state)) return;
|
|
105
|
+
} catch {}
|
|
106
|
+
writeAtomic(path, content);
|
|
107
|
+
}
|
|
108
|
+
/** Keep Vite preview usable without leaving Wrangler's implicit deploy pointer after a build. */
|
|
109
|
+
function stashCloudflareDeployPointer(root) {
|
|
110
|
+
const pointer = join(root, ".wrangler", "deploy", "config.json");
|
|
111
|
+
if (!existsSync(pointer)) return;
|
|
112
|
+
const directory = join(root, ".void");
|
|
113
|
+
mkdirSync(directory, { recursive: true });
|
|
114
|
+
writeAtomic(join(directory, PREVIEW_POINTER_FILE), readFileSync(pointer, "utf8"));
|
|
115
|
+
rmSync(pointer, { force: true });
|
|
116
|
+
}
|
|
117
|
+
function restoreCloudflarePreviewPointer(root) {
|
|
118
|
+
const saved = join(root, ".void", PREVIEW_POINTER_FILE);
|
|
119
|
+
if (!existsSync(saved)) return false;
|
|
120
|
+
const directory = join(root, ".wrangler", "deploy");
|
|
121
|
+
mkdirSync(directory, { recursive: true });
|
|
122
|
+
writeAtomic(join(directory, "config.json"), readFileSync(saved, "utf8"));
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
/** Preserve Void's JSONC provenance comments when authored settings change. */
|
|
126
|
+
function provenance(text) {
|
|
127
|
+
const lines = text.match(/^\s*\/\/ void:(?:managed-queues|published-traffic):v1:[A-Za-z0-9_-]+\s*$/gm);
|
|
128
|
+
return lines ? `${lines.join("\n")}\n` : "";
|
|
129
|
+
}
|
|
130
|
+
/** Resolve the config file passed to Cloudflare tooling. Typed projects use a generated file. */
|
|
131
|
+
function materializeCloudflareConfig(root) {
|
|
132
|
+
if (!existsSync(join(root, "void.config.ts"))) {
|
|
133
|
+
for (const name of ["wrangler.jsonc", "wrangler.json"]) if (existsSync(join(root, name))) return join(root, name);
|
|
134
|
+
return join(root, "wrangler.jsonc");
|
|
135
|
+
}
|
|
136
|
+
if (["wrangler.jsonc", "wrangler.json"].some((name) => existsSync(join(root, name)))) throw new Error("config: Run `void migrate` to move the root Wrangler config into void.config.ts.");
|
|
137
|
+
const authored = readConfig(root).cloudflare ?? {};
|
|
138
|
+
const state = readState(root);
|
|
139
|
+
const resolved = state ? mergeConfig(state.source, state.resolved, authored) : authored;
|
|
140
|
+
const text = state && isDeepStrictEqual(resolved, state.resolved) && isDeepStrictEqual(authored, state.source) ? state.text : `${provenance(state?.text ?? "")}${JSON.stringify(resolved, null, 2)}\n`;
|
|
141
|
+
const path = join(root, MATERIALIZED_CLOUDFLARE_FILE);
|
|
142
|
+
if (!existsSync(path) || readFileSync(path, "utf8") !== text) writeAtomic(path, text);
|
|
143
|
+
if (state) writeState(root, {
|
|
144
|
+
version: 1,
|
|
145
|
+
source: authored,
|
|
146
|
+
resolved,
|
|
147
|
+
text
|
|
148
|
+
});
|
|
149
|
+
return path;
|
|
150
|
+
}
|
|
151
|
+
/** Record Cloudflare settings written by Void so later builds reproduce them. */
|
|
152
|
+
function persistCloudflareConfig(root) {
|
|
153
|
+
if (!existsSync(join(root, "void.config.ts"))) return;
|
|
154
|
+
const path = join(root, MATERIALIZED_CLOUDFLARE_FILE);
|
|
155
|
+
if (!existsSync(path)) throw new Error(`config: Missing generated ${MATERIALIZED_CLOUDFLARE_FILE}.`);
|
|
156
|
+
const text = readFileSync(path, "utf8");
|
|
157
|
+
const resolved = parseCloudflareText(text, path);
|
|
158
|
+
const authored = readConfig(root).cloudflare ?? {};
|
|
159
|
+
if (readState(root) || !isDeepStrictEqual(resolved, authored) || text !== `${JSON.stringify(authored, null, 2)}\n`) writeState(root, {
|
|
160
|
+
version: 1,
|
|
161
|
+
source: authored,
|
|
162
|
+
resolved,
|
|
163
|
+
text
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** Seed the checked-in lock from a root Wrangler file during migration. */
|
|
167
|
+
function seedCloudflareConfig(root, source, text) {
|
|
168
|
+
const existing = readState(root);
|
|
169
|
+
if (existing) {
|
|
170
|
+
if (isDeepStrictEqual(existing.source, source) && isDeepStrictEqual(existing.resolved, source)) return;
|
|
171
|
+
throw new Error(`migrate: ${VOID_LOCK_FILE} already exists with different settings. Resolve it before migrating.`);
|
|
172
|
+
}
|
|
173
|
+
if (!isDeepStrictEqual(parseCloudflareText(text, ".void-wrangler.jsonc"), source)) throw new Error("migrate: The Cloudflare config changed during migration. Retry.");
|
|
174
|
+
writeState(root, {
|
|
175
|
+
version: 1,
|
|
176
|
+
source,
|
|
177
|
+
resolved: source,
|
|
178
|
+
text
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { restoreCloudflarePreviewPointer as a, persistCloudflareConfig as i, VOID_LOCK_FILE as n, seedCloudflareConfig as o, materializeCloudflareConfig as r, stashCloudflareDeployPointer as s, MATERIALIZED_CLOUDFLARE_FILE as t };
|