void 1.10.0 → 1.12.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/dist/{account-cmd-CZhbDfp4.mjs → account-cmd-D_0qJ9fx.mjs} +6 -6
- package/dist/{agents-DRo8gzni.mjs → agents-64FnLwxP.mjs} +6 -5
- package/dist/{application-analysis-Do1WaGAY.mjs → application-analysis-Cx2S63z5.mjs} +48 -22
- package/dist/{application-routing-DrOFahHO.mjs → application-routing-BAXpnawu.mjs} +1 -1
- package/dist/{assets-DZBd7yqh.mjs → assets-Br6_BeFJ.mjs} +34 -27
- package/dist/{ast-Cv0JwXqb.mjs → ast-BkPQu7A0.mjs} +5 -1
- package/dist/{auth-BN0NU9dz.mjs → auth-Boz0lrb3.mjs} +1 -1
- package/dist/{auth-CCk9Seol.mjs → auth-DlLDymuc.mjs} +24 -12
- package/dist/{auth-link-DFQTA1jN.mjs → auth-link-C97r9p2N.mjs} +6 -6
- package/dist/{auth-router-BOiaDmcQ.mjs → auth-router-BmzEgzYx.mjs} +5 -5
- package/dist/{better-auth-shared-BqsMzU14.d.mts → better-auth-shared-BS3pDQbT.d.mts} +11 -6
- package/dist/{better-auth-shared-DRHo5FoG.mjs → better-auth-shared-BcqDt-37.mjs} +7 -2
- package/dist/{build-cmd-BCiXgjn9.mjs → build-cmd-BaFsyZrz.mjs} +13 -12
- package/dist/{cache-CUulshOu.mjs → cache-xO711ATQ.mjs} +6 -6
- package/dist/{cancel-deploy-BHGZo6KC.mjs → cancel-deploy-Di11ynsr.mjs} +5 -5
- package/dist/{cf-access-pejlJmuy.mjs → cf-access-DmkKPcAI.mjs} +0 -8
- package/dist/{cf-access-Dnyw8KFY.mjs → cf-access-FaIm95jA.mjs} +8 -4
- package/dist/{cf-build-output-bBx1gDll.mjs → cf-build-output-Ca201_n1.mjs} +27 -25
- package/dist/cf-build-output-Dy7N0hQN.mjs +1 -0
- package/dist/{cf-command-values-Ccl-zRhl.mjs → cf-command-values-5BPBRc9Z.mjs} +1 -1
- package/dist/cf-config-migrate-D271BTiw.mjs +1664 -0
- package/dist/{cf-worker-settings-CARs4Wy9.mjs → cf-worker-settings-BBdlhm9U.mjs} +1 -1
- package/dist/cli/cli.mjs +1 -1
- package/dist/cli/cloudflare-operation-process.mjs +223 -16
- package/dist/cli/env-schema-probe.d.mts +3 -1
- package/dist/cli/env-schema-probe.mjs +7 -8
- package/dist/{cli-main-hM7rhIbB.mjs → cli-main-DlW6lB8s.mjs} +153 -91
- package/dist/{client-BEYbgqZw.mjs → client-DkYzDEC0.mjs} +1 -1
- package/dist/{client-aIv5UQf3.mjs → client-ImIe7Mjq.mjs} +192 -17
- package/dist/{cloudflare-auth-pNvmT6kL.mjs → cloudflare-auth-eWfhdZCk.mjs} +1 -1
- package/dist/{cloudflare-cmd-DLcgInCa.mjs → cloudflare-cmd-SsFlJe2B.mjs} +7 -8
- package/dist/{cloudflare-config-BfEfIEuY.mjs → cloudflare-config-D9UFH_A5.mjs} +2 -2
- package/dist/{cloudflare-connect-CMcKtA02.mjs → cloudflare-connect-BgpHcSg3.mjs} +3 -3
- package/dist/{cloudflare-operations-DLhn_Bom.mjs → cloudflare-operations-BF0PSErW.mjs} +40 -24
- package/dist/cloudflare-operations-dpRD-2Px.mjs +1 -0
- package/dist/cloudflare-process-60r4Z2Zf.mjs +671 -0
- package/dist/cloudflare-user-output-CCR99eQY.mjs +19 -0
- package/dist/collect-B6nlSnsb.mjs +1 -0
- package/dist/{collect-C6Blu9yw.mjs → collect-rNLybAnF.mjs} +3 -3
- package/dist/{config-Do7gJI3T.mjs → config-BFX5ZB1J.mjs} +5 -4
- package/dist/{config-CbKmMpHK.mjs → config-BSoW3QCB.mjs} +5 -5
- package/dist/{config-DuiDZbq7.d.mts → config-DA6ZbLXO.d.mts} +3 -1
- package/dist/{config-CtkCfPpv.mjs → config-DtjrUtPo.mjs} +1 -1
- package/dist/{config-qgt863GH.mjs → config-Dv5jri1-.mjs} +10 -6
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-DM3yCNPG.mjs → connect-DDRQGfFE.mjs} +9 -9
- package/dist/{create-project-BkVGXGNt.mjs → create-project-CY7sP8sI.mjs} +7 -6
- package/dist/{create-project-C-hNdYvD.mjs → create-project-Dro3K-az.mjs} +1 -1
- package/dist/{db-DQAi7Ckr.mjs → db-DmlaWVBu.mjs} +166 -121
- package/dist/db-seed-loader-Bcz_SutQ.mjs +253 -0
- package/dist/{db-types-BpPYAx0B.mjs → db-types-B4Cf9dzR.mjs} +8 -2
- package/dist/{delete-BtVnPGO2.mjs → delete-Uuq9ch6o.mjs} +6 -6
- package/dist/{deploy-Cs93Af-d.mjs → deploy-B9E7_rHC.mjs} +235 -558
- package/dist/deploy-BB3rsZbP.mjs +2 -0
- package/dist/{deploy-managed-static-CZIx3cc1.mjs → deploy-managed-static-IKZyuc1W.mjs} +123 -198
- package/dist/deploy-security-notice-C3LalelR.mjs +192 -0
- package/dist/{deploy-transport-DT-ALuDj.mjs → deploy-transport-BKP_oV9q.mjs} +4 -4
- package/dist/deploy.mjs +10 -9
- package/dist/{dev-inbox-BiamQEAa.mjs → dev-inbox-ClVjKEHy.mjs} +1 -1
- package/dist/direct-r2-upload-DFXLWfXV.mjs +204 -0
- package/dist/discover-D2KGP3cR.mjs +1 -0
- package/dist/{discover-Vd18lHsj.mjs → discover-IcspacCg.mjs} +1 -1
- package/dist/{dispatch-DPEuEblR.mjs → dispatch-DIhDA3NI.mjs} +38 -17
- package/dist/{dist-Cp4b1_T9.mjs → dist-C47zy_kJ.mjs} +1 -1
- package/dist/{dist-STQXl8ck.mjs → dist-Cr_xGE_K.mjs} +73 -38
- package/dist/{domain-cOhYYiHU.mjs → domain-B_xY1yZ5.mjs} +8 -10
- package/dist/{dotenv-CEI8hapP.mjs → dotenv-BG6RQavH.mjs} +2 -2
- package/dist/{drizzle-DBSpPpU1.mjs → drizzle-BJDMPrj7.mjs} +35 -30
- package/dist/{drizzle-D4V_06-B.mjs → drizzle-CQ5jWuDL.mjs} +1 -1
- package/dist/{email-CnnDqvXV.mjs → email-BIC15L7a.mjs} +47 -32
- package/dist/{email-cloudflare-CCIoQueP.mjs → email-cloudflare-C447nOqq.mjs} +195 -109
- package/dist/{email-pattern-BYr-EFq5.mjs → email-pattern-bRna9MOJ.mjs} +2 -2
- package/dist/{entry-DMgR7XOf.mjs → entry-Bwb9ev8K.mjs} +13 -10
- package/dist/{env-5bphL5mV.mjs → env-DJPZYHT5.mjs} +8 -8
- package/dist/{env-UqS-21xi.mjs → env-EjHqc7m9.mjs} +1 -1
- package/dist/{env-types-WEZw5D-r.mjs → env-types-D2hBodXP.mjs} +2 -19
- package/dist/{env-validation-DfJ9Fzfa.mjs → env-validation-D-v5_CWL.mjs} +13 -13
- package/dist/{env-validation-ly_Q9Kgd.mjs → env-validation-j9pjCDfA.mjs} +1 -1
- package/dist/{error-pages-QNeBXiRR.mjs → error-pages-GORL6F_e.mjs} +1 -1
- package/dist/{fetch-CbI6lNnk.d.mts → fetch-CczQyIed.d.mts} +1 -1
- package/dist/{fetch-DdK9eGin.mjs → fetch-CiEsvjpP.mjs} +1 -1
- package/dist/{fetch-stream-DQAavFdm.mjs → fetch-stream-BIG5lHW6.mjs} +3 -4
- package/dist/{fetch-stream-DoED9atq.d.mts → fetch-stream-DRX8-83b.d.mts} +2 -2
- package/dist/gen-CQDiPi8m.mjs +1 -0
- package/dist/{gen-CjcH6DJS.mjs → gen-DiTZlDx8.mjs} +21 -18
- package/dist/{generate-BOp1g1H_.mjs → generate-C3ZAqCy-.mjs} +1 -1
- package/dist/{generate-CWb8aOsm.mjs → generate-Dq2Bgw75.mjs} +6 -6
- package/dist/{git-metadata-Cukp5kV5.mjs → git-metadata-BEokJ6US.mjs} +1 -1
- package/dist/{github-cmd-CVDLb51-.mjs → github-cmd-DPmby8x-.mjs} +14 -9
- package/dist/{handler-w_FAiIRu.mjs → handler-DCrDLzw2.mjs} +3 -3
- package/dist/has-own-key-D9QEnAkF.mjs +5 -0
- package/dist/{head-0o0QoREY.mjs → head-BwQ5kgqt.mjs} +5 -4
- package/dist/{head-CVO92KEx.d.mts → head-fUp8n_QJ.d.mts} +9 -4
- package/dist/{headers-Cyr87J6Z.mjs → headers-DqBsjDxg.mjs} +7 -7
- package/dist/{help-B1cH8518.mjs → help-9wfMyXHb.mjs} +146 -69
- package/dist/help-Dy3w4rPq.mjs +1 -0
- package/dist/{inbound-BHt4dIlL.d.mts → inbound-CwgZSqFI.d.mts} +9 -3
- package/dist/{inbound--OF7zkwX.mjs → inbound-feMn1Rxx.mjs} +7 -7
- package/dist/{index-CmqHYj2R.d.mts → index-8cAgNdb6.d.mts} +1 -1
- package/dist/{index-BTmhCDbw.d.mts → index-BQ5qYiAw.d.mts} +2 -2
- package/dist/{index-BESZTC1z.d.mts → index-BYcWajVp.d.mts} +2 -1
- package/dist/{index-BXdP39qx.d.mts → index-Dn2mkPr2.d.mts} +24 -23
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +351 -444
- package/dist/{info-BE3snw2_.mjs → info-BWEWaOBo.mjs} +4 -4
- package/dist/{init-BrS5MAiJ.mjs → init-BuTPVLPO.mjs} +737 -546
- package/dist/{isr-config-Czzb4mIq.mjs → isr-config-DiTnL9Tb.mjs} +5 -5
- package/dist/{link-BbzyrCBD.mjs → link-BiesPyT4.mjs} +7 -7
- package/dist/{list-DmppHjVc.mjs → list-CkonftPQ.mjs} +11 -7
- package/dist/{live-DvtxTUhW.mjs → live-dvGThbwy.mjs} +14 -17
- package/dist/{load-user-env-BltIJLtl.mjs → load-user-env-B8qC0Q2Y.mjs} +1 -1
- package/dist/{local-d1-DLxsKmkw.mjs → local-d1-CYOYkVwO.mjs} +3 -3
- package/dist/{login-Cihxnu7m.mjs → login-BSOSah1j.mjs} +8 -6
- package/dist/login-DWCZeCX9.mjs +1 -0
- package/dist/{logs-BCgLeLNd.mjs → logs-HOBUnroa.mjs} +9 -9
- package/dist/{migrate-DOK67gE-.mjs → migrate-BNZL1hee.mjs} +9 -10
- package/dist/migrate-C9aoWLvY.mjs +1 -0
- package/dist/{migrations-ByS7r3HV.mjs → migrations-CUHhX65Y.mjs} +15 -12
- package/dist/{mime-BGoZ8ZLL.mjs → mime-Btw9R3CC.mjs} +26 -12
- package/dist/{mysql-sql-SlpS6OMg.mjs → mysql-sql-CB52k8tQ.mjs} +45 -22
- package/dist/nitro.d.mts +3 -0
- package/dist/nitro.mjs +14 -5
- package/dist/{node-qXD3FbIU.mjs → node-DVJWfV6s.mjs} +6 -6
- package/dist/node-buffer-D7kgjaDs.mjs +4 -0
- package/dist/{operator-ai-logging-CNuX5uKg.mjs → operator-ai-logging-ZDqqhnIq.mjs} +11 -10
- package/dist/operator-args-DCkWbgT-.mjs +1499 -0
- package/dist/{operator-auth-CD3pap65.mjs → operator-auth-BjoPLgja.mjs} +2 -2
- package/dist/{operator-client-XvXTkea6.mjs → operator-client-DzebIntv.mjs} +3 -3
- package/dist/{operator-cmd-D0vSUVle.mjs → operator-cmd-AZoeI9Pl.mjs} +28 -12
- package/dist/operator-cmd-DEnHFmJF.mjs +1 -0
- package/dist/operator-security-Bo26FP01.mjs +263 -0
- package/dist/{output-DNVILSz2.mjs → output-BZLnu0z8.mjs} +39 -4
- package/dist/output-D7K9TWIA.mjs +1 -0
- package/dist/{package-json-DvS6IFRv.mjs → package-json-4xUI3xLz.mjs} +1 -1
- package/dist/pages/client.d.mts +53 -30
- package/dist/pages/client.mjs +93 -31
- package/dist/pages/head.d.mts +1 -1
- package/dist/pages/head.mjs +1 -1
- package/dist/pages/index.d.mts +2 -2
- package/dist/pages/index.mjs +7 -7
- package/dist/pages/islands-plugin.d.mts +26 -8
- package/dist/pages/islands-plugin.mjs +61 -22
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +1 -1
- package/dist/pages/serialize.mjs +1 -1
- package/dist/{pgpass-CEtnBOZO.mjs → pgpass-BLPoYN9_.mjs} +3 -2
- package/dist/platform-args-DNbNZ_RR.mjs +1 -0
- package/dist/{platform-args-DQSMW4EP.mjs → platform-args-lwCyQ6Xy.mjs} +37 -9
- package/dist/{platform-auth-config-V2ifSLQ-.mjs → platform-auth-config-DLRMPw1G.mjs} +26 -23
- package/dist/{platform-auth-protection-BybVCUzi.mjs → platform-auth-protection-HSmLmD3d.mjs} +10 -10
- package/dist/{platform-auth-recovery-kH1-h8Ch.mjs → platform-auth-recovery-BXPhTlKa.mjs} +11 -9
- package/dist/{platform-cmd-B1jtqXnu.mjs → platform-cmd-CqRjxFEU.mjs} +1 -1
- package/dist/{platform-cmd-BHWdh1Hx.mjs → platform-cmd-DJ-fOYhL.mjs} +11 -11
- package/dist/{platform-discovery-B0eZjZ3B.mjs → platform-discovery-CLxtixHJ.mjs} +1 -1
- package/dist/{platform-domain-DB_KpVhg.mjs → platform-domain-CRsRJOws.mjs} +14 -10
- package/dist/{platform-lifecycle-BoOTmH6H.mjs → platform-lifecycle-bx_kpqo7.mjs} +1 -1
- package/dist/{platform-lifecycle-C6fUuj4y.mjs → platform-lifecycle-fau3VKv6.mjs} +773 -206
- package/dist/platform-management-BRGhD-oF.mjs +1 -0
- package/dist/{platform-management-B8-pOxoJ.mjs → platform-management-CnKBdDx5.mjs} +227 -58
- package/dist/{platform-plans-config-iczSDkQK.mjs → platform-plans-config-2C3_5EDs.mjs} +112 -35
- package/dist/{platform-recovery-ZAXin6WK.mjs → platform-recovery-poxgOOAY.mjs} +5 -5
- package/dist/{platform-registry-DZ_2Xuqd.mjs → platform-registry-DHH6fivm.mjs} +6 -5
- package/dist/{platform-setup-CpcHLI-0.mjs → platform-setup-DYylapHD.mjs} +26 -12
- package/dist/{plugin-inference-BGamcCqB.mjs → plugin-inference-7O11_E4H.mjs} +26 -26
- package/dist/{prepare-BrAkXTTB.mjs → prepare-BbvlKreR.mjs} +12 -12
- package/dist/prepare-BmG2E6TI.mjs +1 -0
- package/dist/{prepare-Cjt6EM0d.mjs → prepare-DWjn1Lzd.mjs} +3 -3
- package/dist/{project-cmd-wtCuc8Ln.mjs → project-cmd-DyUEFi2b.mjs} +30 -24
- package/dist/{project-CLwxcEdq.mjs → project-dh9431bN.mjs} +2 -2
- package/dist/{project-paths-CUhCPMpK.mjs → project-paths-2ENfCCih.mjs} +4 -3
- package/dist/project-security--tYGFPGo.mjs +1340 -0
- package/dist/project-security-DZEQgnsS.mjs +1 -0
- package/dist/{project-team-CZFvPIJ-.mjs → project-team-BszTHgzC.mjs} +8 -8
- package/dist/{project-token-C3TxkWeC.mjs → project-token-DBDy4NdV.mjs} +6 -6
- package/dist/{project-tsconfig-MyRJgufB.mjs → project-tsconfig-BOA4ym99.mjs} +25 -5
- package/dist/{project-DVsTAWFh.mjs → project-uXKua1it.mjs} +1 -1
- package/dist/project-zero-trust-D9sUouij.mjs +210 -0
- package/dist/{protocol-W5EQcIzN.mjs → protocol-CE3wP-H1.mjs} +5 -5
- package/dist/{protocol-BlAiF-hc.d.mts → protocol-ERy-n3jf.d.mts} +7 -4
- package/dist/{provision-CknEbPuw.mjs → provision-Bh44omGA.mjs} +39 -29
- package/dist/provision-DFv7SJDn.mjs +1 -0
- package/dist/{public-B80SwOFp.d.mts → public-DB9C2Cy_.d.mts} +5 -2
- package/dist/{raw-7pQirZpQ.mjs → raw-5rak34QN.mjs} +2 -1
- package/dist/{redirect-Dqb4fEc5.mjs → redirect-DD825Stf.mjs} +1 -1
- package/dist/{requests-FaA9M3RX.mjs → requests-CBokjiOi.mjs} +6 -6
- package/dist/{resolve-project-Da3OgCU1.mjs → resolve-project-8WZ3iVmr.mjs} +3 -3
- package/dist/resolve-project-YsTH-U9I.mjs +1 -0
- package/dist/{rollback-DM6pZ23Y.mjs → rollback-CEeHNFUn.mjs} +16 -7
- package/dist/route-types-CSed9-Dp.mjs +435 -0
- package/dist/{route-url-BBdkU7rb.mjs → route-url-B41eQ8QI.mjs} +1 -1
- package/dist/{route-url-Di1kB8D_.d.mts → route-url-Bd6IX-JZ.d.mts} +2 -1
- package/dist/routes-stub.d.mts +1 -1
- package/dist/routes-stub.mjs +1 -1
- package/dist/{runner-CTk21HrO.mjs → runner-Bf94YVJK.mjs} +1 -1
- package/dist/{runner-CMZb7jNU.mjs → runner-CeguHWJx.mjs} +3 -2
- package/dist/{runner-mysql-CJ-HyqxV.mjs → runner-mysql-3XDKrn-g.mjs} +13 -9
- package/dist/{runner-mysql-C_PrAUTm.mjs → runner-mysql-r688x6Y9.mjs} +1 -1
- package/dist/{runner-pg-mYc75KfH.mjs → runner-pg-Buzw17hl.mjs} +1 -1
- package/dist/{runner-pg-2pjltt0t.mjs → runner-pg-DMJquR3d.mjs} +1 -1
- package/dist/runtime/ai/index.d.mts +1 -0
- package/dist/runtime/ai/index.mjs +26 -11
- package/dist/runtime/auth/better-auth-d1.d.mts +1 -1
- package/dist/runtime/auth/better-auth-d1.mjs +2 -2
- package/dist/runtime/auth/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/auth/better-auth-mysql.mjs +2 -2
- package/dist/runtime/auth/better-auth-postgres.d.mts +1 -1
- package/dist/runtime/auth/better-auth-postgres.mjs +3 -3
- package/dist/runtime/client/fetch-server.d.mts +1 -1
- package/dist/runtime/client/fetch-server.mjs +2 -2
- package/dist/runtime/client/fetch-stream.d.mts +2 -2
- package/dist/runtime/client/fetch-stream.mjs +1 -1
- package/dist/runtime/client/fetch.d.mts +1 -1
- package/dist/runtime/client/fetch.mjs +1 -1
- package/dist/runtime/client/index.d.mts +2 -2
- package/dist/runtime/client/index.mjs +2 -2
- package/dist/runtime/client/react.d.mts +2 -2
- package/dist/runtime/client/react.mjs +2 -2
- package/dist/runtime/client/solid.d.mts +2 -2
- package/dist/runtime/client/solid.mjs +2 -2
- package/dist/runtime/client/svelte.d.mts +2 -2
- package/dist/runtime/client/svelte.mjs +2 -2
- package/dist/runtime/client/vue.d.mts +2 -2
- package/dist/runtime/client/vue.mjs +2 -2
- package/dist/runtime/db/index.d.mts +8 -2
- package/dist/runtime/db/index.mjs +21 -8
- package/dist/runtime/db/migrations/mysql-handler.mjs +1 -1
- package/dist/runtime/db/migrations/postgres-handler.mjs +1 -1
- package/dist/runtime/db/session.d.mts +2 -0
- package/dist/runtime/db/session.mjs +1 -0
- package/dist/runtime/durable/index.mjs +7 -5
- package/dist/runtime/email/index.d.mts +1 -1
- package/dist/runtime/email/index.mjs +14 -11
- package/dist/runtime/email/testing.d.mts +1 -1
- package/dist/runtime/email/testing.mjs +4 -4
- package/dist/runtime/env/public-client.d.mts +4 -1
- package/dist/runtime/env/public.d.mts +1 -1
- package/dist/runtime/env/public.mjs +2 -2
- package/dist/runtime/env/runtime.mjs +1 -1
- package/dist/runtime/handler/index.d.mts +1 -1
- package/dist/runtime/handler/index.mjs +1 -1
- package/dist/runtime/handler/validator.d.mts +1 -1
- package/dist/runtime/handler/validator.mjs +1 -1
- package/dist/runtime/isr/index.mjs +1 -1
- package/dist/runtime/kv/index.mjs +1 -1
- package/dist/runtime/live/client.d.mts +2 -2
- package/dist/runtime/live/client.mjs +7 -7
- package/dist/runtime/live/index.d.mts +1 -1
- package/dist/runtime/live/index.mjs +1 -1
- package/dist/runtime/live/server.mjs +3 -3
- package/dist/runtime/queues/index.mjs +2 -2
- package/dist/runtime/remote/index.d.mts +5 -1
- package/dist/runtime/remote/index.mjs +10 -9
- package/dist/runtime/routing/index.d.mts +11 -12
- package/dist/runtime/routing/index.mjs +69 -65
- package/dist/runtime/routing/route-url.d.mts +1 -1
- package/dist/runtime/routing/route-url.mjs +1 -1
- package/dist/runtime/sandbox/index.d.mts +1 -1
- package/dist/runtime/sandbox/index.mjs +2 -2
- package/dist/runtime/sse/client.d.mts +1 -1
- package/dist/runtime/sse/index.mjs +1 -1
- package/dist/runtime/storage/index.mjs +1 -1
- package/dist/runtime/ws/index.d.mts +1 -1
- package/dist/runtime/ws/index.mjs +3 -2
- package/dist/runtime/ws/room.d.mts +1 -1
- package/dist/runtime/ws/room.mjs +2 -2
- package/dist/runtime/ws/server.d.mts +2 -2
- package/dist/runtime/ws/server.mjs +1 -1
- package/dist/{runtime-zDDinDI5.mjs → runtime-C_VPIJBF.mjs} +1 -1
- package/dist/{scan-tDExXbA1.mjs → scan-Ct_SEzH4.mjs} +36 -29
- package/dist/{secret-DDNLIQOT.mjs → secret-Deqo3n_N.mjs} +11 -10
- package/dist/security-api-types-CU7zQtr_.mjs +9 -0
- package/dist/security-sarif-ClyYwtAW.mjs +123 -0
- package/dist/{serialize-Pf-CIQK_.mjs → serialize-BmB4BfKu.mjs} +1 -1
- package/dist/{server-CfUbeOjx.mjs → server-T-4mn8zy.mjs} +5 -4
- package/dist/session-BT8XDkvL.mjs +45 -0
- package/dist/session-ouZYD7zb.d.mts +18 -0
- package/dist/{skills-CoBB9_Ao.mjs → skills-C-csz78e.mjs} +10 -17
- package/dist/{sse-BXnTfcf3.mjs → sse-D3ab0YQT.mjs} +16 -13
- package/dist/{static-exports-DFkzL-NX.mjs → static-exports-s7P86Ngp.mjs} +3 -3
- package/dist/{subcommand-prompt-0yIARXf2.mjs → subcommand-prompt-B4LOLosl.mjs} +31 -21
- package/dist/sveltekit.mjs +1 -1
- package/dist/{terminal-log-text-DNsWJREL.mjs → terminal-log-text-CfS2JKM6.mjs} +1 -1
- package/dist/{url-DaehRGKR.mjs → url-DBQluotE.mjs} +4 -1
- package/dist/validate-CZYUIfR-.mjs +1 -0
- package/dist/{validate-Ddzl-IwT.mjs → validate-CtBWCzez.mjs} +7 -4
- package/dist/{validator-Duafcnh7.mjs → validator-Dfh9kCDm.mjs} +5 -5
- package/dist/{version-metadata-DEmItNdS.mjs → version-metadata-DqgLa6gc.mjs} +1 -1
- package/dist/{wrangler-D1zq1rXr.mjs → wrangler-DVe5KV5G.mjs} +49 -46
- package/dist/wrangler-Dq269bjx.mjs +1 -0
- package/dist/{wrapper-C2gMY432.mjs → wrapper-CcMYpOS8.mjs} +45 -171
- package/docs/guide/ai.md +13 -0
- package/docs/guide/app-types.md +1 -1
- package/docs/guide/auth.md +2 -16
- package/docs/guide/database/d1.md +283 -3
- package/docs/guide/database.md +2 -0
- package/docs/guide/email/domains.md +8 -6
- package/docs/guide/email/sending.md +18 -1
- package/docs/guide/pages-routing/actions-and-forms.md +4 -4
- package/docs/guide/pages-routing/head.md +20 -2
- package/docs/guide/platform/administration/plans.md +13 -0
- package/docs/guide/platform/administration/security-audits.md +213 -0
- package/docs/guide/platform/administration/zero-trust.md +6 -0
- package/docs/guide/platform/development/local.md +3 -5
- package/docs/guide/platform/installation/ci.md +1 -1
- package/docs/guide/platform/installation/credentials.md +23 -20
- package/docs/guide/platform/installation/maintenance.md +8 -2
- package/docs/guide/platform/installation/prerequisites.md +1 -1
- package/docs/guide/platform/installation/uninstall.md +2 -0
- package/docs/guide/platform-administration.md +1 -0
- package/docs/guide/self-hosted-platform.md +14 -13
- package/docs/guide/type-safety.md +1 -1
- package/docs/integrations/cloudflare.md +5 -3
- package/docs/reference/api/database.md +42 -2
- package/docs/reference/api/handlers.md +3 -3
- package/docs/reference/api/types.md +11 -1
- package/docs/reference/api.md +1 -1
- package/docs/reference/cli/database.md +6 -3
- package/docs/reference/cli/deploy.md +17 -13
- package/docs/reference/cli/domains.md +1 -1
- package/docs/reference/cli/email.md +3 -3
- package/docs/reference/cli/platform-config.md +5 -3
- package/docs/reference/cli/platform-installation.md +29 -28
- package/docs/reference/cli/platform-security.md +98 -0
- package/docs/reference/cli/platform-zero-trust.md +2 -0
- package/docs/reference/cli/platform.md +1 -0
- package/docs/reference/cli/project.md +57 -0
- package/docs/reference/cli.md +3 -1
- package/docs/reference/config.md +7 -6
- package/package.json +31 -27
- package/schema.json +7 -1
- package/skills/void/SKILL.md +8 -0
- package/dist/cf-build-output-D3_x71H6.mjs +0 -1
- package/dist/cf-config-migrate-CHtnM3_C.mjs +0 -348
- package/dist/cloudflare-operations-C5RTQNnh.mjs +0 -1
- package/dist/cloudflare-process-wcnaQ5JG.mjs +0 -392
- package/dist/cloudflare-user-output-zEwuGrEJ.mjs +0 -19
- package/dist/collect-8i0wU63d.mjs +0 -1
- package/dist/deploy-rUunHBNJ.mjs +0 -2
- package/dist/discover-Diq0l6TZ.mjs +0 -1
- package/dist/gen-BQ7itmK7.mjs +0 -1
- package/dist/help-Ld6XFol7.mjs +0 -1
- package/dist/login-C-n1rA0s.mjs +0 -1
- package/dist/migrate-CKn30rmw.mjs +0 -1
- package/dist/operator-args-BCCohcz3.mjs +0 -722
- package/dist/operator-cmd-BnLoIO2A.mjs +0 -1
- package/dist/output-BsdnNpxa.mjs +0 -1
- package/dist/platform-args-Rgp86xa7.mjs +0 -1
- package/dist/platform-management-7Bf_OgS5.mjs +0 -1
- package/dist/prepare-CI7_C9Xf.mjs +0 -1
- package/dist/project-zero-trust-DrRyAHW1.mjs +0 -64
- package/dist/provision-DdWqRmmr.mjs +0 -1
- package/dist/resolve-project-C5wC-Hoi.mjs +0 -1
- package/dist/route-types-CrODgORq.mjs +0 -655
- package/dist/validate-DY1U9rET.mjs +0 -1
- package/dist/wrangler-DM3GOqck.mjs +0 -1
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import { A as confirm, K as select, L as log, O as cancel, X as text, tt as isCancel } from "./dist-
|
|
1
|
+
import { A as confirm, K as select, L as log, O as cancel, X as text, tt as isCancel } from "./dist-Cr_xGE_K.mjs";
|
|
2
2
|
import { a as join, c as resolve, i as isAbsolute, n as dirname, s as relative, t as basename } from "./dist-DMYe8CZJ.mjs";
|
|
3
|
-
import { i as materializeCloudflareConfig, l as ensureGitignoreLines } from "./cloudflare-config-
|
|
4
|
-
import {
|
|
5
|
-
import { n as readProjectPaths, o as TYPED_CONFIG_FILE } from "./project-paths-
|
|
6
|
-
import { F as canRewriteVoidProjectConfig, I as renderVoidConfig, L as writeVoidProjectConfig, M as writeProvisionedWranglerConfig, i as LATEST_KNOWN_COMPAT_DATE } from "./wrangler-
|
|
7
|
-
import { c as getDatabaseCasing, l as getDatabaseDialect, p as readConfig, s as databaseConfigValue } from "./config-
|
|
8
|
-
import { r as writeDrizzleConfig, t as PLACEHOLDER_DB_URL } from "./config-
|
|
9
|
-
import { n as snapshotDrizzleOutputs } from "./generate-
|
|
10
|
-
import { r as detectFramework } from "./plugin-inference-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { t as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { t as
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
3
|
+
import { i as materializeCloudflareConfig, l as ensureGitignoreLines, n as VOID_LOCK_FILE } from "./cloudflare-config-D9UFH_A5.mjs";
|
|
4
|
+
import { i as ensureProjectTsconfig, r as createProjectTsconfig } from "./project-tsconfig-BOA4ym99.mjs";
|
|
5
|
+
import { n as readProjectPaths, o as TYPED_CONFIG_FILE } from "./project-paths-2ENfCCih.mjs";
|
|
6
|
+
import { F as canRewriteVoidProjectConfig, I as renderVoidConfig, L as writeVoidProjectConfig, M as writeProvisionedWranglerConfig, i as LATEST_KNOWN_COMPAT_DATE } from "./wrangler-DVe5KV5G.mjs";
|
|
7
|
+
import { c as getDatabaseCasing, l as getDatabaseDialect, p as readConfig, s as databaseConfigValue } from "./config-Dv5jri1-.mjs";
|
|
8
|
+
import { r as writeDrizzleConfig, t as PLACEHOLDER_DB_URL } from "./config-BSoW3QCB.mjs";
|
|
9
|
+
import { n as snapshotDrizzleOutputs } from "./generate-Dq2Bgw75.mjs";
|
|
10
|
+
import { r as detectFramework } from "./plugin-inference-7O11_E4H.mjs";
|
|
11
|
+
import { t as hasOwnKey } from "./has-own-key-D9QEnAkF.mjs";
|
|
12
|
+
import { i as readPackageJson, n as hasPackageDependency, t as getPackageDependencies } from "./package-json-4xUI3xLz.mjs";
|
|
13
|
+
import { n as getOwnVersion, r as getPackageDir, t as detectAgents } from "./agents-64FnLwxP.mjs";
|
|
14
|
+
import { t as connectCloudflare } from "./cloudflare-connect-BgpHcSg3.mjs";
|
|
15
|
+
import { c as getToken } from "./auth-DlLDymuc.mjs";
|
|
16
|
+
import { r as PlatformClient } from "./client-ImIe7Mjq.mjs";
|
|
17
|
+
import { a as promptProjectSelection, r as promptAndCreateProject } from "./create-project-CY7sP8sI.mjs";
|
|
18
|
+
import { t as promptForLoginToken } from "./login-BSOSah1j.mjs";
|
|
19
|
+
import { c as writeDeploymentPlatform, n as readDeploymentPlatform, r as readProjectConfig, t as attachSelectedPlatform, u as writeProjectConfig } from "./project-dh9431bN.mjs";
|
|
20
|
+
import { t as parseDotenvFile } from "./dotenv-BG6RQavH.mjs";
|
|
21
|
+
import { i as migrateFrameworkAdapterPaths, t as migrateLegacyVoidConfig } from "./migrate-BNZL1hee.mjs";
|
|
22
|
+
import { _ as printDone, a as createSpinner, f as formatUrl, g as note, l as formatDuration, v as printNextStep, y as printSuccess } from "./output-BZLnu0z8.mjs";
|
|
23
|
+
import { i as saveDiscoveredPlatform, t as discoverPlatform } from "./platform-cmd-DJ-fOYhL.mjs";
|
|
24
|
+
import { d as findWorkspaceMemberRoot, f as findWorkspaceRoot, h as patchViteConfigWithVoidPlugin, m as stripYamlLineComment, p as parsePackageManagerField, s as formatProjectCommand } from "./cloudflare-process-60r4Z2Zf.mjs";
|
|
25
25
|
import { i as hasLocalLockfile, n as drizzleKitBin, r as findInstalledYarnPnpRuntime, t as buildDrizzleKitSpawnEnv } from "./yarn-pnp-DgWbE7z5.mjs";
|
|
26
26
|
import { createRequire } from "node:module";
|
|
27
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
28
|
-
import { parseSync } from "vite";
|
|
27
|
+
import { closeSync, createReadStream, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
29
28
|
import { isRecord } from "@void/deploy-core";
|
|
29
|
+
import { constants, tmpdir } from "node:os";
|
|
30
30
|
import { parseArgs } from "node:util";
|
|
31
31
|
import { parse } from "jsonc-parser";
|
|
32
|
-
import { spawnSync } from "node:child_process";
|
|
32
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
33
|
+
import { once } from "node:events";
|
|
33
34
|
import { parseDocument } from "yaml";
|
|
34
35
|
// src/cli/deploy-setup.ts
|
|
35
36
|
async function maybeSetupDeployProject(root) {
|
|
@@ -123,15 +124,9 @@ function renderEnvTs(entries) {
|
|
|
123
124
|
"url"
|
|
124
125
|
].filter((h) => helpers.has(h));
|
|
125
126
|
const lines = [];
|
|
126
|
-
lines.push(`import { defineEnv, ${importList.join(", ")} } from 'void/env'
|
|
127
|
-
lines.push("");
|
|
128
|
-
lines.push(`// Scaffolded from .env. Inference is conservative — review each`);
|
|
129
|
-
lines.push(`// entry and tighten types as needed (e.g. oneOf([...]), url(), .optional(),`);
|
|
130
|
-
lines.push(`// .default(value), or a Standard Schema validator from valibot/zod/arktype).`);
|
|
131
|
-
lines.push(`export default defineEnv({`);
|
|
127
|
+
lines.push(`import { defineEnv, ${importList.join(", ")} } from 'void/env';`, "", `// Scaffolded from .env. Inference is conservative — review each`, `// entry and tighten types as needed (e.g. oneOf([...]), url(), .optional(),`, `// .default(value), or a Standard Schema validator from valibot/zod/arktype).`, `export default defineEnv({`);
|
|
132
128
|
for (const entry of entries) lines.push(` ${entry.key}: ${entry.helper}(),`);
|
|
133
|
-
lines.push(`})
|
|
134
|
-
lines.push("");
|
|
129
|
+
lines.push(`});`, "");
|
|
135
130
|
return lines.join("\n");
|
|
136
131
|
}
|
|
137
132
|
/**
|
|
@@ -171,18 +166,26 @@ function maybeScaffoldEnvTs(root) {
|
|
|
171
166
|
function shellDirectory() {
|
|
172
167
|
return resolve(process.cwd());
|
|
173
168
|
}
|
|
174
|
-
/** Quote
|
|
175
|
-
function
|
|
176
|
-
if (/^[A-Za-z0-9_@./:-]+$/.test(
|
|
177
|
-
return process.platform === "win32" ? `"${
|
|
169
|
+
/** Quote an argument for the user's shell, such as a path with spaces, quotes, $ or backticks. */
|
|
170
|
+
function quoteShellArgument(argument) {
|
|
171
|
+
if (/^[A-Za-z0-9_@./:-]+$/.test(argument)) return argument;
|
|
172
|
+
return process.platform === "win32" ? `"${argument}"` : `'${argument.replaceAll("'", String.raw`'\''`)}'`;
|
|
178
173
|
}
|
|
179
|
-
/**
|
|
180
|
-
|
|
174
|
+
/**
|
|
175
|
+
* The path from the user's shell to `root`, quoted as a command argument, or
|
|
176
|
+
* undefined when the shell is already there.
|
|
177
|
+
*/
|
|
178
|
+
function projectPathFromShell(root) {
|
|
181
179
|
const shell = shellDirectory();
|
|
182
180
|
const directory = resolve(root);
|
|
183
|
-
if (directory === shell) return
|
|
181
|
+
if (directory === shell) return;
|
|
184
182
|
const path = relative(shell, directory);
|
|
185
|
-
return
|
|
183
|
+
return quoteShellArgument(path.startsWith("-") ? `./${path}` : path);
|
|
184
|
+
}
|
|
185
|
+
/** Prefix `command` with a `cd` from the user's shell into `root` when they differ. */
|
|
186
|
+
function commandInProject(root, command) {
|
|
187
|
+
const path = projectPathFromShell(root);
|
|
188
|
+
return path === void 0 ? command : `cd ${path} && ${command}`;
|
|
186
189
|
}
|
|
187
190
|
// src/cli/init-git.ts
|
|
188
191
|
async function setupGit(root, git) {
|
|
@@ -208,7 +211,7 @@ async function setupGit(root, git) {
|
|
|
208
211
|
}
|
|
209
212
|
const result = spawnSync("git", ["init"], {
|
|
210
213
|
cwd: root,
|
|
211
|
-
encoding: "
|
|
214
|
+
encoding: "utf8",
|
|
212
215
|
stdio: [
|
|
213
216
|
"ignore",
|
|
214
217
|
"pipe",
|
|
@@ -224,10 +227,359 @@ async function setupGit(root, git) {
|
|
|
224
227
|
return true;
|
|
225
228
|
}
|
|
226
229
|
function initialCommitCommand(root) {
|
|
227
|
-
const
|
|
228
|
-
const git =
|
|
230
|
+
const path = projectPathFromShell(root);
|
|
231
|
+
const git = path === void 0 ? "git" : `git -C ${path}`;
|
|
229
232
|
return `${git} add -A && ${git} commit -m "chore: initial commit"`;
|
|
230
233
|
}
|
|
234
|
+
// src/cli/init-report.ts
|
|
235
|
+
/**
|
|
236
|
+
* What one `void init` run did. Init records its work here instead of logging
|
|
237
|
+
* each step, then prints a short summary when it finishes.
|
|
238
|
+
*/
|
|
239
|
+
var InitReport = class {
|
|
240
|
+
files = [];
|
|
241
|
+
/** Finished work other than file changes. */
|
|
242
|
+
completed = [];
|
|
243
|
+
/** What the user should do next. */
|
|
244
|
+
nextSteps = [];
|
|
245
|
+
/**
|
|
246
|
+
* How to finish by hand the step that init is on, such as "Run `vp install`
|
|
247
|
+
* to finish setup". Only a run that stops during that step prints it.
|
|
248
|
+
*/
|
|
249
|
+
unfinished;
|
|
250
|
+
/** The new starter in one line. See `setStarter`. */
|
|
251
|
+
starter;
|
|
252
|
+
/** Files recorded by the time the starter was created. */
|
|
253
|
+
starterFiles = /* @__PURE__ */ new Set();
|
|
254
|
+
printed = false;
|
|
255
|
+
/**
|
|
256
|
+
* Record a new starter in one line, such as "Created a React Pages starter
|
|
257
|
+
* with D1 (SQLite)". The summary shows it instead of the files recorded so
|
|
258
|
+
* far, since listing the starter's files would add little. It still lists
|
|
259
|
+
* files outside the new app (a workspace root's pnpm-workspace.yaml) and
|
|
260
|
+
* later changes to files that existed before init.
|
|
261
|
+
*/
|
|
262
|
+
setStarter(summary) {
|
|
263
|
+
this.starter = summary;
|
|
264
|
+
this.starterFiles = new Set(this.files.map((file) => file.path));
|
|
265
|
+
}
|
|
266
|
+
/** Record a new file. Later changes to it in the same run keep it a new file. */
|
|
267
|
+
created(path) {
|
|
268
|
+
const file = this.files.find((entry) => entry.path === path);
|
|
269
|
+
if (file) {
|
|
270
|
+
file.kind = "created";
|
|
271
|
+
file.details = [];
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.files.push({
|
|
275
|
+
kind: "created",
|
|
276
|
+
path,
|
|
277
|
+
details: []
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/** Record a change to an existing file. A file lists each detail once. */
|
|
281
|
+
updated(path, detail) {
|
|
282
|
+
const file = this.files.find((entry) => entry.path === path);
|
|
283
|
+
if (!file) this.files.push({
|
|
284
|
+
kind: "updated",
|
|
285
|
+
path,
|
|
286
|
+
details: [detail]
|
|
287
|
+
});
|
|
288
|
+
else if (file.kind === "updated" && !file.details.includes(detail)) file.details.push(detail);
|
|
289
|
+
}
|
|
290
|
+
/** Record a write to `path`, which `existed` before it. */
|
|
291
|
+
wrote(path, existed, detail) {
|
|
292
|
+
if (existed) this.updated(path, detail);
|
|
293
|
+
else this.created(path);
|
|
294
|
+
}
|
|
295
|
+
done(message) {
|
|
296
|
+
this.completed.push(message);
|
|
297
|
+
}
|
|
298
|
+
next(message) {
|
|
299
|
+
this.nextSteps.push(message);
|
|
300
|
+
}
|
|
301
|
+
/** One line per file: created files first, then updated files with their details aligned. */
|
|
302
|
+
fileLines(files = this.files) {
|
|
303
|
+
const created = files.filter((file) => file.kind === "created");
|
|
304
|
+
const updated = files.filter((file) => file.kind === "updated");
|
|
305
|
+
const width = Math.max(0, ...updated.map((file) => file.path.length));
|
|
306
|
+
return [...created.map((file) => `+ ${file.path}`), ...updated.map((file) => `~ ${file.path.padEnd(width)} ${file.details.join(", ")}`)];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The files the summary lists. Under a starter, these are the files outside
|
|
310
|
+
* the new app and the later changes to files that existed before init.
|
|
311
|
+
* Report paths are relative to the app and use `/`.
|
|
312
|
+
*/
|
|
313
|
+
shownFiles() {
|
|
314
|
+
if (!this.starter) return this.files;
|
|
315
|
+
return this.files.filter((file) => file.path === ".." || file.path.startsWith("../") || file.kind === "updated" && !this.starterFiles.has(file.path));
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Print the summary of a finished run: the new starter, or else the changed
|
|
319
|
+
* files. A `targeted` run (`--tsconfig`, `--github`) checks only part of the
|
|
320
|
+
* setup, so finding nothing to change there does not show that Void is set up.
|
|
321
|
+
*/
|
|
322
|
+
print(targeted = false) {
|
|
323
|
+
this.printed = true;
|
|
324
|
+
const lines = this.fileLines(this.shownFiles());
|
|
325
|
+
if (this.starter) printDone(lines.length > 0 ? [this.starter, ...lines] : this.starter);
|
|
326
|
+
else if (lines.length > 0) printDone(["Configured Void", ...lines]);
|
|
327
|
+
else printDone(targeted ? "No files changed." : "Void is already set up. No files changed.");
|
|
328
|
+
this.printOtherWork();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Run init's `steps`. If they stop early, print what they had recorded, so
|
|
332
|
+
* that the run does not leave changes it never mentioned. A failed step
|
|
333
|
+
* throws; a cancelled prompt exits the process, also from the modules that
|
|
334
|
+
* init calls, so only an exit listener sees every one.
|
|
335
|
+
*/
|
|
336
|
+
async printIfStopped(steps) {
|
|
337
|
+
const onExit = () => this.printStopped();
|
|
338
|
+
process.once("exit", onExit);
|
|
339
|
+
try {
|
|
340
|
+
await steps();
|
|
341
|
+
} catch (error) {
|
|
342
|
+
this.printStopped();
|
|
343
|
+
throw error;
|
|
344
|
+
} finally {
|
|
345
|
+
process.removeListener("exit", onExit);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Print what the run did before it stopped, and how to finish the step it
|
|
350
|
+
* stopped in. Prints nothing if there is neither.
|
|
351
|
+
*/
|
|
352
|
+
printStopped() {
|
|
353
|
+
if (this.printed) return;
|
|
354
|
+
this.printed = true;
|
|
355
|
+
const lines = this.fileLines(this.shownFiles());
|
|
356
|
+
if (this.starter) {
|
|
357
|
+
log.warn("Setup did not finish. Done so far:");
|
|
358
|
+
printDone(lines.length > 0 ? [this.starter, ...lines] : this.starter);
|
|
359
|
+
} else if (lines.length > 0) log.warn(["Setup did not finish. Files changed so far:", ...lines].join("\n"));
|
|
360
|
+
else if (this.completed.length > 0 || this.nextSteps.length > 0) log.warn("Setup did not finish. Done so far:");
|
|
361
|
+
else if (!this.unfinished) return;
|
|
362
|
+
this.printOtherWork();
|
|
363
|
+
if (this.unfinished) printNextStep(this.unfinished, { wrap: false });
|
|
364
|
+
}
|
|
365
|
+
printOtherWork() {
|
|
366
|
+
for (const message of this.completed) printDone(message);
|
|
367
|
+
for (const message of this.nextSteps) printNextStep(message);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
// src/cli/init-subprocess.ts
|
|
371
|
+
const STOP_SIGNALS = process.platform === "win32" ? ["SIGINT", "SIGTERM"] : [
|
|
372
|
+
"SIGINT",
|
|
373
|
+
"SIGTERM",
|
|
374
|
+
"SIGHUP"
|
|
375
|
+
];
|
|
376
|
+
/** How long a command that init stops has to end by itself before init kills it. */
|
|
377
|
+
const STOP_GRACE_MS = 5e3;
|
|
378
|
+
/** How long init waits for the killed processes to go. */
|
|
379
|
+
const KILL_WAIT_MS = 1e3;
|
|
380
|
+
/** How often init checks whether a stopped command has ended. */
|
|
381
|
+
const STOP_POLL_MS = 25;
|
|
382
|
+
/** Wait without the event loop, which an `exit` listener cannot return to. */
|
|
383
|
+
function sleepSync(ms) {
|
|
384
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
385
|
+
}
|
|
386
|
+
/** Read the process states from /proc, which works without `ps` (slim container images have none). */
|
|
387
|
+
function isRunningInProc(pgid) {
|
|
388
|
+
let entries;
|
|
389
|
+
try {
|
|
390
|
+
entries = readdirSync("/proc");
|
|
391
|
+
} catch {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
for (const entry of entries) {
|
|
395
|
+
if (!/^\d+$/.test(entry)) continue;
|
|
396
|
+
let stat;
|
|
397
|
+
try {
|
|
398
|
+
stat = readFileSync(`/proc/${entry}/stat`, "latin1");
|
|
399
|
+
} catch {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
const [state, , group] = stat.slice(stat.lastIndexOf(")") + 2).split(" ", 3);
|
|
403
|
+
if (Number(group) === pgid && state !== "Z" && state !== "X") return true;
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
function isRunningInPs(pgid) {
|
|
408
|
+
const listed = spawnSync("/bin/ps", [
|
|
409
|
+
"-A",
|
|
410
|
+
"-o",
|
|
411
|
+
"pgid=",
|
|
412
|
+
"-o",
|
|
413
|
+
"state="
|
|
414
|
+
], { encoding: "utf8" });
|
|
415
|
+
if (listed.status !== 0) return;
|
|
416
|
+
return listed.stdout.split("\n").some((row) => {
|
|
417
|
+
const [group, state] = row.trim().split(/\s+/);
|
|
418
|
+
return Number(group) === pgid && state !== void 0 && !state.startsWith("Z");
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Whether a process group still has a running member.
|
|
423
|
+
*
|
|
424
|
+
* A process that has exited stays in its group until its parent collects it,
|
|
425
|
+
* and Node cannot collect init's own child while an `exit` listener runs. For
|
|
426
|
+
* such a group `kill(-pgid, 0)` keeps succeeding, so read the process states.
|
|
427
|
+
*/
|
|
428
|
+
function isProcessGroupRunning(pgid, platform = process.platform) {
|
|
429
|
+
const running = platform === "linux" ? isRunningInProc(pgid) : isRunningInPs(pgid);
|
|
430
|
+
if (running !== void 0) return running;
|
|
431
|
+
try {
|
|
432
|
+
process.kill(-pgid, 0);
|
|
433
|
+
return true;
|
|
434
|
+
} catch {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function signalGroup(pgid, signal) {
|
|
439
|
+
try {
|
|
440
|
+
process.kill(-pgid, signal);
|
|
441
|
+
return true;
|
|
442
|
+
} catch {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function waitForGroupToEnd(pgid, timeoutMs) {
|
|
447
|
+
const deadline = performance.now() + timeoutMs;
|
|
448
|
+
while (isProcessGroupRunning(pgid)) {
|
|
449
|
+
if (performance.now() >= deadline) return false;
|
|
450
|
+
sleepSync(STOP_POLL_MS);
|
|
451
|
+
}
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Stop a command that init started, together with the processes it started,
|
|
456
|
+
* and return when they have ended. Init exits next: a process that still ran
|
|
457
|
+
* then would go on changing the project while the user retries.
|
|
458
|
+
*/
|
|
459
|
+
function stopCommand(child, graceMs = STOP_GRACE_MS) {
|
|
460
|
+
const pid = child?.pid;
|
|
461
|
+
if (!pid) return;
|
|
462
|
+
if (process.platform === "win32") {
|
|
463
|
+
spawnSync("taskkill", [
|
|
464
|
+
"/PID",
|
|
465
|
+
String(pid),
|
|
466
|
+
"/T",
|
|
467
|
+
"/F"
|
|
468
|
+
], {
|
|
469
|
+
stdio: "ignore",
|
|
470
|
+
windowsHide: true
|
|
471
|
+
});
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (!signalGroup(pid, "SIGTERM") || waitForGroupToEnd(pid, graceMs)) return;
|
|
475
|
+
signalGroup(pid, "SIGKILL");
|
|
476
|
+
waitForGroupToEnd(pid, KILL_WAIT_MS);
|
|
477
|
+
}
|
|
478
|
+
async function replayOutput(path) {
|
|
479
|
+
const { size } = statSync(path);
|
|
480
|
+
if (size === 0) return;
|
|
481
|
+
const output = createReadStream(path, {
|
|
482
|
+
encoding: "utf8",
|
|
483
|
+
end: size - 1
|
|
484
|
+
});
|
|
485
|
+
let endsWithNewline = true;
|
|
486
|
+
for await (const chunk of output) {
|
|
487
|
+
endsWithNewline = chunk.endsWith("\n");
|
|
488
|
+
if (!process.stdout.write(chunk)) await once(process.stdout, "drain");
|
|
489
|
+
}
|
|
490
|
+
if (!endsWithNewline) process.stdout.write("\n");
|
|
491
|
+
}
|
|
492
|
+
const onSignal = (signal) => {
|
|
493
|
+
process.exit(128 + constants.signals[signal]);
|
|
494
|
+
};
|
|
495
|
+
/** Run a command behind a spinner and print its output if it fails. */
|
|
496
|
+
async function runBehindSpinner(message, command, args, options) {
|
|
497
|
+
const { failed, undo, ...spawnOptions } = options;
|
|
498
|
+
const directory = mkdtempSync(join(tmpdir(), "void-init-"));
|
|
499
|
+
const path = join(directory, "output.log");
|
|
500
|
+
const cleanup = () => rmSync(directory, {
|
|
501
|
+
recursive: true,
|
|
502
|
+
force: true
|
|
503
|
+
});
|
|
504
|
+
let child;
|
|
505
|
+
const progress = createSpinner({
|
|
506
|
+
indicator: "timer",
|
|
507
|
+
cancelMessage: message
|
|
508
|
+
});
|
|
509
|
+
const onExit = (code) => {
|
|
510
|
+
if (child) {
|
|
511
|
+
progress.cancel(message);
|
|
512
|
+
stopCommand(child);
|
|
513
|
+
undo?.();
|
|
514
|
+
if (code === 0) process.exitCode = 130;
|
|
515
|
+
}
|
|
516
|
+
cleanup();
|
|
517
|
+
};
|
|
518
|
+
try {
|
|
519
|
+
progress.start(message);
|
|
520
|
+
process.prependListener("exit", onExit);
|
|
521
|
+
for (const signal of STOP_SIGNALS) process.on(signal, onSignal);
|
|
522
|
+
const startedAt = performance.now();
|
|
523
|
+
let status = null;
|
|
524
|
+
try {
|
|
525
|
+
status = await new Promise((resolve, reject) => {
|
|
526
|
+
const fd = openSync(path, "wx");
|
|
527
|
+
try {
|
|
528
|
+
child = spawn(command, args, {
|
|
529
|
+
...spawnOptions,
|
|
530
|
+
stdio: [
|
|
531
|
+
"ignore",
|
|
532
|
+
fd,
|
|
533
|
+
fd
|
|
534
|
+
],
|
|
535
|
+
detached: process.platform !== "win32"
|
|
536
|
+
});
|
|
537
|
+
child.once("error", reject);
|
|
538
|
+
child.once("exit", resolve);
|
|
539
|
+
} finally {
|
|
540
|
+
closeSync(fd);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
} finally {
|
|
544
|
+
if (status !== 0 && !progress.isCancelled && undo) {
|
|
545
|
+
stopCommand(child);
|
|
546
|
+
undo();
|
|
547
|
+
}
|
|
548
|
+
child = void 0;
|
|
549
|
+
if (status === 0 || !failed) progress.clear();
|
|
550
|
+
else if (!progress.isCancelled) progress.error(failed);
|
|
551
|
+
}
|
|
552
|
+
const durationMs = performance.now() - startedAt;
|
|
553
|
+
if (status !== 0 && !progress.isCancelled) await replayOutput(path);
|
|
554
|
+
return {
|
|
555
|
+
status,
|
|
556
|
+
durationMs
|
|
557
|
+
};
|
|
558
|
+
} finally {
|
|
559
|
+
process.removeListener("exit", onExit);
|
|
560
|
+
for (const signal of STOP_SIGNALS) process.removeListener(signal, onSignal);
|
|
561
|
+
cleanup();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
// ../../node_modules/.pnpm/vite-plus@1.8.0_@astrojs+compiler-rs@0.5.3_@types+node@26.6.6_@vitest+browser-preview@5_c7284c5e76ef225b77ef3ea8719234f7/node_modules/vite-plus/package.json
|
|
565
|
+
var version = "1.8.0";
|
|
566
|
+
var dependencies = {
|
|
567
|
+
"@oxc-project/runtime": "=0.159.0",
|
|
568
|
+
"@oxc-project/types": "=0.159.0",
|
|
569
|
+
"@oxlint/plugins": "=1.94.0",
|
|
570
|
+
"@vitest/browser": "5.1.1",
|
|
571
|
+
"@vitest/browser-preview": "5.1.1",
|
|
572
|
+
"@vitest/mocker": "5.1.1",
|
|
573
|
+
"@vitest/pretty-format": "5.1.1",
|
|
574
|
+
"@vitest/snapshot": "5.1.1",
|
|
575
|
+
"@vitest/spy": "5.1.1",
|
|
576
|
+
"@vitest/utils": "5.1.1",
|
|
577
|
+
"oxfmt": "=0.79.0",
|
|
578
|
+
"oxlint": "=1.94.0",
|
|
579
|
+
"tsrs": "=7.1.0-beta.tsrs4",
|
|
580
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
|
|
581
|
+
"vitest": "5.1.1"
|
|
582
|
+
};
|
|
231
583
|
// src/cli/starter-ui.css?raw
|
|
232
584
|
var starter_ui_default = ":root {\n --text: rgb(22 23 29 / 70%);\n --text-h: #16171d;\n --bg: #fff;\n --border: #e5e4e7;\n --code-bg: #f2f1f4;\n --accent: #6c3bff;\n --error: #b42318;\n --social-bg: #f2f1f4;\n --radius-inner: 4px;\n --radius-element: 6px;\n --shadow: rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;\n\n --sans: system-ui, 'Segoe UI', Roboto, sans-serif;\n --heading: system-ui, 'Segoe UI', Roboto, sans-serif;\n --mono: ui-monospace, Consolas, monospace;\n\n font: 18px/145% var(--sans);\n letter-spacing: 0.18px;\n color-scheme: light dark;\n color: var(--text);\n background: var(--bg);\n font-synthesis: none;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n\n @media (max-width: 1024px) {\n font-size: 16px;\n }\n}\n\n@supports (corner-shape: squircle) {\n :root {\n /* Squircle curves need about twice the radius to read as rounded. */\n --radius-inner: 8px;\n --radius-element: 12px;\n }\n\n :where(.starter, .starter *),\n .starter *::before,\n .starter *::after {\n corner-shape: squircle;\n }\n}\n\n@media (prefers-color-scheme: dark) {\n :root {\n --text: rgb(255 255 255 / 70%);\n --text-h: #fff;\n --bg: #16171d;\n --border: #3b3440;\n --code-bg: #3b3440;\n --accent: #b39aff;\n --error: #fda29b;\n --social-bg: #3b3440;\n --shadow: rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;\n }\n}\n\n.starter {\n width: 1126px;\n max-width: 100%;\n margin: 0 auto;\n text-align: center;\n border-inline: 1px solid var(--border);\n min-height: 100svh;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n}\n\nbody {\n margin: 0;\n}\n\nh1,\nh2 {\n font-family: var(--heading);\n font-weight: 500;\n color: var(--text-h);\n}\n\nh1 {\n font-size: 56px;\n letter-spacing: -1.68px;\n margin: 32px 0;\n @media (max-width: 1024px) {\n font-size: 36px;\n margin: 20px 0;\n }\n}\nh2 {\n font-size: 24px;\n line-height: 118%;\n letter-spacing: -0.24px;\n margin: 0 0 8px;\n @media (max-width: 1024px) {\n font-size: 20px;\n }\n}\np {\n margin: 0;\n}\n\ncode {\n font-family: var(--mono);\n display: inline-flex;\n border-radius: var(--radius-inner);\n color: var(--text-h);\n font-size: 15px;\n line-height: 135%;\n padding: 4px 8px;\n background: var(--code-bg);\n}\n\n.hero {\n position: relative;\n\n .base,\n .framework,\n .void {\n inset-inline: 0;\n margin: 0 auto;\n }\n\n .base {\n width: 170px;\n position: relative;\n z-index: 0;\n }\n\n .framework,\n .void {\n position: absolute;\n }\n\n .framework {\n z-index: 1;\n top: 34px;\n height: 28px;\n transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg) scale(1.4);\n }\n\n .void {\n z-index: 0;\n top: 107px;\n height: 22px;\n width: auto;\n transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg) scale(0.8);\n }\n}\n\n#center {\n display: flex;\n flex-direction: column;\n gap: 25px;\n padding-bottom: 24px;\n place-content: center;\n place-items: center;\n flex-grow: 1;\n\n @media (max-width: 1024px) {\n padding: 32px 20px 24px;\n gap: 18px;\n }\n}\n\n.starter-intro {\n width: min(720px, 100%);\n padding-inline: 20px;\n box-sizing: border-box;\n\n a {\n color: var(--accent);\n }\n\n @media (max-width: 1024px) {\n padding-inline: 0;\n }\n}\n\n.starter-description {\n display: grid;\n gap: 12px;\n\n > p:nth-child(2) {\n text-wrap: balance;\n }\n}\n\n.starter-demo {\n border-top: 1px solid var(--border);\n padding: 32px;\n text-align: left;\n\n @media (max-width: 1024px) {\n padding: 24px 20px;\n }\n}\n\n.demo-content {\n max-width: 640px;\n margin: 0 auto;\n display: grid;\n gap: 24px;\n\n h2 {\n margin: 0;\n }\n}\n\n.messages {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: 12px;\n\n li {\n padding: 12px 16px;\n border: 1px solid var(--border);\n border-radius: var(--radius-element);\n overflow-wrap: anywhere;\n }\n\n strong {\n display: block;\n color: var(--text-h);\n font-weight: 500;\n }\n\n small {\n font-size: 14px;\n }\n}\n\n.message-form {\n display: grid;\n gap: 12px;\n\n label {\n color: var(--text-h);\n }\n\n input,\n button {\n font: inherit;\n color: var(--text-h);\n background: var(--social-bg);\n border: 1px solid var(--border);\n border-radius: var(--radius-element);\n padding: 10px 12px;\n\n &:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n }\n }\n\n input {\n flex: 1;\n min-width: 0;\n }\n\n button {\n cursor: pointer;\n\n &:hover {\n border-color: var(--accent);\n }\n\n &:disabled {\n cursor: wait;\n opacity: 0.6;\n }\n }\n}\n\n.message-fields {\n display: flex;\n gap: 8px;\n\n @media (max-width: 480px) {\n flex-direction: column;\n }\n}\n\n.message-form [data-void-form-error] {\n color: var(--error);\n font-size: 14px;\n}\n\n#next-steps {\n display: flex;\n border-top: 1px solid var(--border);\n text-align: left;\n\n & > div {\n flex: 1 1 0;\n padding: 32px;\n @media (max-width: 1024px) {\n padding: 24px 20px;\n }\n }\n\n .icon {\n color: var(--accent);\n margin-bottom: 16px;\n width: 22px;\n height: 22px;\n }\n\n @media (max-width: 1024px) {\n flex-direction: column;\n text-align: center;\n }\n}\n\n#docs {\n border-right: 1px solid var(--border);\n\n @media (max-width: 1024px) {\n border-right: none;\n border-bottom: 1px solid var(--border);\n }\n}\n\n#next-steps ul {\n list-style: none;\n padding: 0;\n display: flex;\n gap: 8px;\n margin: 32px 0 0;\n\n a {\n color: var(--text-h);\n font-size: 16px;\n border-radius: var(--radius-element);\n background: var(--social-bg);\n display: flex;\n padding: 6px 12px;\n align-items: center;\n gap: 8px;\n text-decoration: none;\n transition: box-shadow 0.3s;\n\n &:hover {\n box-shadow: var(--shadow);\n }\n .button-icon {\n height: 18px;\n width: 18px;\n }\n }\n\n @media (max-width: 1024px) {\n margin-top: 20px;\n flex-wrap: wrap;\n justify-content: center;\n\n li {\n flex: 1 1 calc(50% - 8px);\n }\n\n a {\n width: 100%;\n justify-content: center;\n box-sizing: border-box;\n }\n }\n}\n\n#spacer {\n height: 88px;\n border-top: 1px solid var(--border);\n @media (max-width: 1024px) {\n height: 48px;\n }\n}\n\n.ticks {\n position: relative;\n width: 100%;\n\n &::before,\n &::after {\n content: '';\n position: absolute;\n top: -4.5px;\n border: 5px solid transparent;\n }\n\n &::before {\n left: 0;\n border-left-color: var(--border);\n }\n &::after {\n right: 0;\n border-right-color: var(--border);\n }\n}\n";
|
|
233
585
|
// src/cli/template.ts
|
|
@@ -249,8 +601,8 @@ const SCAFFOLD_BASE_DEV_DEPENDENCIES = {
|
|
|
249
601
|
typescript: "^7.0.2"
|
|
250
602
|
};
|
|
251
603
|
const SCAFFOLD_VITE_PLUS_DEV_DEPENDENCIES = {
|
|
252
|
-
vite:
|
|
253
|
-
"vite-plus":
|
|
604
|
+
vite: dependencies.vite,
|
|
605
|
+
"vite-plus": version
|
|
254
606
|
};
|
|
255
607
|
const SCAFFOLD_TOOLCHAIN_OPTIONS = [{
|
|
256
608
|
value: "vite-plus",
|
|
@@ -694,6 +1046,45 @@ function indent(source, spaces) {
|
|
|
694
1046
|
return source.split("\n").map((line) => " ".repeat(spaces) + line).join("\n");
|
|
695
1047
|
}
|
|
696
1048
|
// src/cli/init-vite-plus.ts
|
|
1049
|
+
/**
|
|
1050
|
+
* Resolve a project's catalog reference before invoking npx outside its
|
|
1051
|
+
* workspace. pnpm, Bun and Yarn name the default catalog `catalog:` or
|
|
1052
|
+
* `catalog:default`, and write it as `catalog` or `catalogs.default`.
|
|
1053
|
+
*/
|
|
1054
|
+
function resolveVitePlusBootstrapSpec(root, pkg) {
|
|
1055
|
+
const spec = getPackageDependencies(pkg)["vite-plus"];
|
|
1056
|
+
if (spec && !spec.startsWith("catalog:")) return spec;
|
|
1057
|
+
if (spec) {
|
|
1058
|
+
const catalog = spec.slice(8) || "default";
|
|
1059
|
+
let directory = root;
|
|
1060
|
+
while (true) {
|
|
1061
|
+
const workspace = join(directory, "pnpm-workspace.yaml");
|
|
1062
|
+
const yarnrc = join(directory, ".yarnrc.yml");
|
|
1063
|
+
const config = existsSync(workspace) ? readYaml(workspace) : readPackageJson(directory);
|
|
1064
|
+
const configs = existsSync(yarnrc) ? [config, readYaml(yarnrc)] : [config];
|
|
1065
|
+
for (const entry of configs) {
|
|
1066
|
+
const version = catalogEntries(entry, catalog)?.["vite-plus"];
|
|
1067
|
+
if (typeof version === "string" && version && !version.startsWith("catalog:")) return version;
|
|
1068
|
+
}
|
|
1069
|
+
if (existsSync(workspace) || config?.workspaces || dirname(directory) === directory) break;
|
|
1070
|
+
directory = dirname(directory);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return SCAFFOLD_VITE_PLUS_DEV_DEPENDENCIES["vite-plus"];
|
|
1074
|
+
}
|
|
1075
|
+
/** A named catalog in a workspace config, or in its `workspaces` field (Bun). */
|
|
1076
|
+
function catalogEntries(config, name) {
|
|
1077
|
+
for (const scope of [config, config?.workspaces]) {
|
|
1078
|
+
if (!scope || typeof scope !== "object") continue;
|
|
1079
|
+
const { catalog, catalogs } = scope;
|
|
1080
|
+
const named = catalogs?.[name];
|
|
1081
|
+
const entries = name === "default" ? catalog ?? named : named;
|
|
1082
|
+
if (entries && typeof entries === "object") return entries;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function readYaml(path) {
|
|
1086
|
+
return parseDocument(readFileSync(path, "utf8")).toJS();
|
|
1087
|
+
}
|
|
697
1088
|
/** Keep every Vite consumer on the core used by the selected Vite+ toolchain. */
|
|
698
1089
|
function configureVitePlusScaffold(root, packageManager, pkg) {
|
|
699
1090
|
const core = SCAFFOLD_VITE_PLUS_DEV_DEPENDENCIES.vite;
|
|
@@ -727,87 +1118,6 @@ function editYaml(root, name, edit) {
|
|
|
727
1118
|
edit(document);
|
|
728
1119
|
writeFileSync(path, document.toString());
|
|
729
1120
|
}
|
|
730
|
-
// src/cli/vite-config-patch.ts
|
|
731
|
-
function unwrap(node) {
|
|
732
|
-
while (node && [
|
|
733
|
-
"TSAsExpression",
|
|
734
|
-
"TSSatisfiesExpression",
|
|
735
|
-
"ParenthesizedExpression",
|
|
736
|
-
"TSTypeAssertion"
|
|
737
|
-
].includes(node.type)) node = node.expression;
|
|
738
|
-
return node;
|
|
739
|
-
}
|
|
740
|
-
function configObject(program) {
|
|
741
|
-
const declaration = program.body?.find((node) => node.type === "ExportDefaultDeclaration")?.declaration;
|
|
742
|
-
const exported = unwrap(declaration);
|
|
743
|
-
if (exported?.type === "ObjectExpression") return exported;
|
|
744
|
-
if (exported?.type === "CallExpression" && exported.callee?.name === "defineConfig") {
|
|
745
|
-
const firstArgument = unwrap(exported.arguments?.[0]);
|
|
746
|
-
if (firstArgument?.type === "ObjectExpression") return firstArgument;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
function propertyName(property) {
|
|
750
|
-
if (property.type !== "Property" || property.computed || property.kind !== "init") return;
|
|
751
|
-
return property.key?.name ?? (typeof property.key?.value === "string" ? property.key.value : void 0);
|
|
752
|
-
}
|
|
753
|
-
function nodeValue(node) {
|
|
754
|
-
const value = node?.value;
|
|
755
|
-
return value !== null && typeof value === "object" && "type" in value ? value : void 0;
|
|
756
|
-
}
|
|
757
|
-
function lineIndent(code, index) {
|
|
758
|
-
const lineStart = code.lastIndexOf("\n", index) + 1;
|
|
759
|
-
return code.slice(lineStart, index).match(/^\s*/)?.[0] ?? "";
|
|
760
|
-
}
|
|
761
|
-
/** Add the plugin only when the exported Vite configuration has an editable object and array. */
|
|
762
|
-
function patchViteConfigWithVoidPlugin(filePath, code) {
|
|
763
|
-
if (filePath.endsWith(".cjs") || filePath.endsWith(".cts")) return;
|
|
764
|
-
let program;
|
|
765
|
-
try {
|
|
766
|
-
program = parseSync(filePath, code).program;
|
|
767
|
-
} catch {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
const object = configObject(program);
|
|
771
|
-
if (!object) return;
|
|
772
|
-
const pluginProperties = object.properties?.filter((property) => propertyName(property) === "plugins") ?? [];
|
|
773
|
-
if (pluginProperties.length > 1 || nodeValue(pluginProperties[0])?.type !== "ArrayExpression") {
|
|
774
|
-
if (pluginProperties.length > 0) return;
|
|
775
|
-
}
|
|
776
|
-
const imports = program.body?.filter((node) => node.type === "ImportDeclaration") ?? [];
|
|
777
|
-
const importedName = imports.filter((node) => node.source?.value === "void").flatMap((node) => node.specifiers ?? []).find((node) => node.type === "ImportSpecifier" && node.imported?.name === "voidPlugin")?.local?.name;
|
|
778
|
-
const pluginName = importedName ?? "voidPlugin";
|
|
779
|
-
const plugins = nodeValue(pluginProperties[0]);
|
|
780
|
-
if (plugins?.elements?.some((element) => element?.type === "CallExpression" && element.callee?.name === pluginName)) return code;
|
|
781
|
-
const ms = new MagicString(code);
|
|
782
|
-
if (plugins) {
|
|
783
|
-
const insertAt = plugins.start + 1;
|
|
784
|
-
if (code.slice(insertAt, plugins.end - 1).trim() === "") {
|
|
785
|
-
if (insertAt === plugins.end - 1) ms.appendLeft(insertAt, `${pluginName}()`);
|
|
786
|
-
else ms.overwrite(insertAt, plugins.end - 1, `${pluginName}()`);
|
|
787
|
-
} else {
|
|
788
|
-
const indent = lineIndent(code, pluginProperties[0].start);
|
|
789
|
-
const next = code[insertAt];
|
|
790
|
-
ms.appendLeft(insertAt, next === "\n" || next === "\r" ? `\n${indent} ${pluginName}(),` : `${pluginName}(), `);
|
|
791
|
-
}
|
|
792
|
-
} else {
|
|
793
|
-
if (object.properties?.some((property) => property.type === "SpreadElement")) return;
|
|
794
|
-
if (code.slice(object.start + 1, object.end - 1).trim() === "") {
|
|
795
|
-
const replacement = ` plugins: [${pluginName}()] `;
|
|
796
|
-
if (object.start + 1 === object.end - 1) ms.appendLeft(object.start + 1, replacement);
|
|
797
|
-
else ms.overwrite(object.start + 1, object.end - 1, replacement);
|
|
798
|
-
} else {
|
|
799
|
-
const indent = lineIndent(code, object.start);
|
|
800
|
-
const next = code[object.start + 1];
|
|
801
|
-
ms.appendLeft(object.start + 1, next === "\n" || next === "\r" ? `\n${indent} plugins: [${pluginName}()],` : ` plugins: [${pluginName}()],`);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (!importedName) {
|
|
805
|
-
const insertAt = imports.length > 0 ? imports[imports.length - 1].end : code.startsWith("#!") ? code.indexOf("\n") + 1 : 0;
|
|
806
|
-
const prefix = insertAt > 0 && code[insertAt - 1] !== "\n" ? "\n" : "";
|
|
807
|
-
ms.appendLeft(insertAt, `${prefix}import { voidPlugin } from "void";\n`);
|
|
808
|
-
}
|
|
809
|
-
return ms.toString();
|
|
810
|
-
}
|
|
811
1121
|
// src/cli/init.ts
|
|
812
1122
|
const SCAFFOLD_STARTER_MODES = [
|
|
813
1123
|
"sqlite",
|
|
@@ -844,7 +1154,7 @@ function parseInitArgs(args) {
|
|
|
844
1154
|
});
|
|
845
1155
|
} catch (error) {
|
|
846
1156
|
const message = error instanceof Error ? error.message : String(error);
|
|
847
|
-
throw new Error(`init: ${message}
|
|
1157
|
+
throw new Error(`init: ${message}.`, { cause: error });
|
|
848
1158
|
}
|
|
849
1159
|
return {
|
|
850
1160
|
tsconfig: parsed.values.tsconfig === true,
|
|
@@ -971,7 +1281,7 @@ function asRecord(value) {
|
|
|
971
1281
|
}
|
|
972
1282
|
function parseJsoncFile(path) {
|
|
973
1283
|
const errors = [];
|
|
974
|
-
const parsed = asRecord(parse(readFileSync(path, "
|
|
1284
|
+
const parsed = asRecord(parse(readFileSync(path, "utf8"), errors));
|
|
975
1285
|
return errors.length === 0 ? parsed : null;
|
|
976
1286
|
}
|
|
977
1287
|
function uniqueStrings(values) {
|
|
@@ -1082,7 +1392,7 @@ function createVoidTsconfigPatch(root, outputBaseDir) {
|
|
|
1082
1392
|
return collectTsconfigPatchFromConfig(createProjectTsconfig(root, void 0, hasSchema, hasSchema), join(root, ".void", "tsconfig.json"), root, outputBaseDir, /* @__PURE__ */ new Set());
|
|
1083
1393
|
}
|
|
1084
1394
|
function hasTopLevelYamlKey(yaml, key) {
|
|
1085
|
-
const keyPattern = new RegExp(`^${key.
|
|
1395
|
+
const keyPattern = new RegExp(`^${key.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)}\\s*:`);
|
|
1086
1396
|
return yaml.split(/\r?\n/).some((rawLine) => {
|
|
1087
1397
|
const line = stripYamlLineComment(rawLine);
|
|
1088
1398
|
return keyPattern.test(line);
|
|
@@ -1090,7 +1400,7 @@ function hasTopLevelYamlKey(yaml, key) {
|
|
|
1090
1400
|
}
|
|
1091
1401
|
function isEmptyProjectAllowedPnpmWorkspaceFile(root) {
|
|
1092
1402
|
try {
|
|
1093
|
-
return !hasTopLevelYamlKey(readFileSync(join(root, "pnpm-workspace.yaml"), "
|
|
1403
|
+
return !hasTopLevelYamlKey(readFileSync(join(root, "pnpm-workspace.yaml"), "utf8"), "packages");
|
|
1094
1404
|
} catch {
|
|
1095
1405
|
return false;
|
|
1096
1406
|
}
|
|
@@ -1118,7 +1428,7 @@ function isScaffoldableEmptyProject(root) {
|
|
|
1118
1428
|
if (!existsSync(packageJsonPath)) return true;
|
|
1119
1429
|
let pkgRaw;
|
|
1120
1430
|
try {
|
|
1121
|
-
pkgRaw = JSON.parse(readFileSync(packageJsonPath, "
|
|
1431
|
+
pkgRaw = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
1122
1432
|
} catch {
|
|
1123
1433
|
return false;
|
|
1124
1434
|
}
|
|
@@ -1132,7 +1442,7 @@ function isScaffoldableEmptyProject(root) {
|
|
|
1132
1442
|
const scripts = asRecord(pkg.scripts) ?? {};
|
|
1133
1443
|
for (const [name, command] of Object.entries(scripts)) {
|
|
1134
1444
|
if (!(name in EMPTY_PROJECT_ALLOWED_SCRIPTS)) return false;
|
|
1135
|
-
const allowed = EMPTY_PROJECT_ALLOWED_SCRIPTS[name];
|
|
1445
|
+
const allowed = hasOwnKey(EMPTY_PROJECT_ALLOWED_SCRIPTS, name) ? EMPTY_PROJECT_ALLOWED_SCRIPTS[name] : void 0;
|
|
1136
1446
|
if (allowed === void 0) continue;
|
|
1137
1447
|
if (typeof command !== "string" || !allowed.has(command)) return false;
|
|
1138
1448
|
}
|
|
@@ -1183,16 +1493,8 @@ async function resolveInitRoot(root) {
|
|
|
1183
1493
|
}
|
|
1184
1494
|
const nextRoot = join(root, folder.trim());
|
|
1185
1495
|
mkdirSync(nextRoot, { recursive: true });
|
|
1186
|
-
log.info(`Scaffolding in ${nextRoot}`);
|
|
1187
1496
|
return nextRoot;
|
|
1188
1497
|
}
|
|
1189
|
-
function parsePackageManagerField(pkg) {
|
|
1190
|
-
if (!pkg || typeof pkg !== "object") return;
|
|
1191
|
-
const raw = pkg.packageManager;
|
|
1192
|
-
if (typeof raw !== "string") return;
|
|
1193
|
-
const name = raw.split("@", 1)[0]?.trim();
|
|
1194
|
-
if (name === "npm" || name === "pnpm" || name === "yarn" || name === "bun") return name;
|
|
1195
|
-
}
|
|
1196
1498
|
/**
|
|
1197
1499
|
* Whether pnpm manages `root`. pnpm keeps the lockfile and Corepack pin at the
|
|
1198
1500
|
* workspace root, so a member without local markers inherits them, but a local
|
|
@@ -1212,14 +1514,14 @@ function isPnpmProject(root, pkg) {
|
|
|
1212
1514
|
* A scratch app outside the workspace globs is a separate project.
|
|
1213
1515
|
*/
|
|
1214
1516
|
function hasAncestorPnpmMarkers(start) {
|
|
1215
|
-
const workspaceRoot =
|
|
1517
|
+
const workspaceRoot = findWorkspaceMemberRoot(start);
|
|
1216
1518
|
if (workspaceRoot === void 0) return false;
|
|
1217
|
-
if (!isWorkspaceSubpackage(workspaceRoot, start)) return false;
|
|
1218
1519
|
if (existsSync(join(workspaceRoot, "pnpm-workspace.yaml"))) return true;
|
|
1219
1520
|
if (existsSync(join(workspaceRoot, "pnpm-lock.yaml"))) return true;
|
|
1220
1521
|
const pkgPath = join(workspaceRoot, "package.json");
|
|
1221
1522
|
if (existsSync(pkgPath)) try {
|
|
1222
|
-
|
|
1523
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
1524
|
+
if (parsePackageManagerField(pkg) === "pnpm") return true;
|
|
1223
1525
|
} catch {}
|
|
1224
1526
|
return false;
|
|
1225
1527
|
}
|
|
@@ -1251,188 +1553,17 @@ function isVoidResolvableFrom(start) {
|
|
|
1251
1553
|
}
|
|
1252
1554
|
return false;
|
|
1253
1555
|
}
|
|
1254
|
-
/**
|
|
1255
|
-
* Nearest ancestor of `start` (excluding `start`) with a `pnpm-workspace.yaml`
|
|
1256
|
-
* or a `package.json#workspaces` field.
|
|
1257
|
-
*/
|
|
1258
|
-
function findWorkspaceRoot(start) {
|
|
1259
|
-
let dir = dirname(start);
|
|
1260
|
-
while (true) {
|
|
1261
|
-
const pkgPath = join(dir, "package.json");
|
|
1262
|
-
if (existsSync(pkgPath)) try {
|
|
1263
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
1264
|
-
if (pkg && typeof pkg === "object" && "workspaces" in pkg) return dir;
|
|
1265
|
-
} catch {}
|
|
1266
|
-
if (existsSync(join(dir, "pnpm-workspace.yaml"))) return dir;
|
|
1267
|
-
const parent = dirname(dir);
|
|
1268
|
-
if (parent === dir) return;
|
|
1269
|
-
dir = parent;
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Member globs from `pnpm-workspace.yaml#packages` or `package.json#workspaces`
|
|
1274
|
-
* (an array or `{ packages }`). Empty when none can be read.
|
|
1275
|
-
*/
|
|
1276
|
-
function readWorkspacePatterns(workspaceRoot) {
|
|
1277
|
-
const pnpmWorkspacePath = join(workspaceRoot, "pnpm-workspace.yaml");
|
|
1278
|
-
if (existsSync(pnpmWorkspacePath)) try {
|
|
1279
|
-
return extractPnpmWorkspacePackages(readFileSync(pnpmWorkspacePath, "utf-8"));
|
|
1280
|
-
} catch {
|
|
1281
|
-
return [];
|
|
1282
|
-
}
|
|
1283
|
-
const pkgPath = join(workspaceRoot, "package.json");
|
|
1284
|
-
if (existsSync(pkgPath)) try {
|
|
1285
|
-
const workspaces = JSON.parse(readFileSync(pkgPath, "utf-8")).workspaces;
|
|
1286
|
-
if (Array.isArray(workspaces)) return workspaces.filter((x) => typeof x === "string");
|
|
1287
|
-
if (workspaces && typeof workspaces === "object") {
|
|
1288
|
-
const packages = workspaces.packages;
|
|
1289
|
-
if (Array.isArray(packages)) return packages.filter((x) => typeof x === "string");
|
|
1290
|
-
}
|
|
1291
|
-
} catch {
|
|
1292
|
-
return [];
|
|
1293
|
-
}
|
|
1294
|
-
return [];
|
|
1295
|
-
}
|
|
1296
|
-
/** Strip a trailing YAML comment, keeping `#` inside quotes (`- "path #hash/*"`). */
|
|
1297
|
-
function stripYamlLineComment(line) {
|
|
1298
|
-
let inSingle = false;
|
|
1299
|
-
let inDouble = false;
|
|
1300
|
-
for (let i = 0; i < line.length; i++) {
|
|
1301
|
-
const ch = line[i];
|
|
1302
|
-
if (inSingle) {
|
|
1303
|
-
if (ch === "'") inSingle = false;
|
|
1304
|
-
continue;
|
|
1305
|
-
}
|
|
1306
|
-
if (inDouble) {
|
|
1307
|
-
if (ch === "\"") inDouble = false;
|
|
1308
|
-
continue;
|
|
1309
|
-
}
|
|
1310
|
-
if (ch === "'") {
|
|
1311
|
-
inSingle = true;
|
|
1312
|
-
continue;
|
|
1313
|
-
}
|
|
1314
|
-
if (ch === "\"") {
|
|
1315
|
-
inDouble = true;
|
|
1316
|
-
continue;
|
|
1317
|
-
}
|
|
1318
|
-
if (ch === "#" && i > 0 && /\s/.test(line[i - 1])) return line.slice(0, i).replace(/\s+$/, "");
|
|
1319
|
-
}
|
|
1320
|
-
return line;
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* Read the `packages:` list of a `pnpm-workspace.yaml` in block (`- 'apps/*'`)
|
|
1324
|
-
* or flow (`packages: ['apps/*']`) form.
|
|
1325
|
-
*/
|
|
1326
|
-
function extractPnpmWorkspacePackages(yaml) {
|
|
1327
|
-
const lines = yaml.split(/\r?\n/);
|
|
1328
|
-
const patterns = [];
|
|
1329
|
-
let inPackages = false;
|
|
1330
|
-
for (const rawLine of lines) {
|
|
1331
|
-
const line = stripYamlLineComment(rawLine);
|
|
1332
|
-
const inlineMatch = line.match(/^\s*packages\s*:\s*\[(.*)\]\s*$/);
|
|
1333
|
-
if (inlineMatch) {
|
|
1334
|
-
const items = inlineMatch[1].match(/(['"])(?:(?!\1).)*\1|[^,\s]+/g) ?? [];
|
|
1335
|
-
for (const raw of items) {
|
|
1336
|
-
const unquoted = raw.trim().replace(/^(['"])(.*)\1$/, "$2");
|
|
1337
|
-
if (unquoted) patterns.push(unquoted);
|
|
1338
|
-
}
|
|
1339
|
-
inPackages = false;
|
|
1340
|
-
continue;
|
|
1341
|
-
}
|
|
1342
|
-
if (/^\s*packages\s*:\s*$/.test(line)) {
|
|
1343
|
-
inPackages = true;
|
|
1344
|
-
continue;
|
|
1345
|
-
}
|
|
1346
|
-
if (!inPackages) continue;
|
|
1347
|
-
if (/^[A-Za-z_][\w-]*\s*:\s*(?:\S.*)?$/.test(line) && !/^\s/.test(line)) {
|
|
1348
|
-
inPackages = false;
|
|
1349
|
-
continue;
|
|
1350
|
-
}
|
|
1351
|
-
const m = line.match(/^\s*-\s*(['"]?)([^'"\s][^'"]*?)\1\s*$/);
|
|
1352
|
-
if (m) patterns.push(m[2]);
|
|
1353
|
-
}
|
|
1354
|
-
return patterns;
|
|
1355
|
-
}
|
|
1356
|
-
/** Expand `{a,b}` brace groups, including several groups in one pattern. */
|
|
1357
|
-
function expandBraces(pattern) {
|
|
1358
|
-
const match = pattern.match(/^([^{}]*)\{([^{}]*)\}(.*)$/);
|
|
1359
|
-
if (!match) return [pattern];
|
|
1360
|
-
const [, before, group, after] = match;
|
|
1361
|
-
const options = group.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
1362
|
-
if (options.length === 0) return [pattern];
|
|
1363
|
-
const results = [];
|
|
1364
|
-
for (const opt of options) for (const sub of expandBraces(before + opt + after)) results.push(sub);
|
|
1365
|
-
return results;
|
|
1366
|
-
}
|
|
1367
|
-
function matchesWorkspacePattern(relPath, pattern) {
|
|
1368
|
-
return expandBraces(pattern).some((p) => matchesSingleWorkspacePattern(relPath, p));
|
|
1369
|
-
}
|
|
1370
|
-
function matchesSingleWorkspacePattern(relPath, pattern) {
|
|
1371
|
-
const normalizedPattern = pattern.replace(/^\.\/+/, "");
|
|
1372
|
-
return matchSegments(relPath.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean), 0, normalizedPattern.replace(/^\/+|\/+$/g, "").split("/").filter(Boolean).map(compilePatternSegment), 0);
|
|
1373
|
-
}
|
|
1374
|
-
function compilePatternSegment(seg) {
|
|
1375
|
-
if (seg === "**") return { kind: "globstar" };
|
|
1376
|
-
if (!seg.includes("*")) return {
|
|
1377
|
-
kind: "literal",
|
|
1378
|
-
value: seg
|
|
1379
|
-
};
|
|
1380
|
-
return {
|
|
1381
|
-
kind: "regex",
|
|
1382
|
-
re: new RegExp("^" + seg.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*") + "$")
|
|
1383
|
-
};
|
|
1384
|
-
}
|
|
1385
|
-
function matchSegments(path, pi, pat, qi) {
|
|
1386
|
-
while (qi < pat.length) {
|
|
1387
|
-
const seg = pat[qi];
|
|
1388
|
-
if (seg.kind === "globstar") {
|
|
1389
|
-
if (qi === pat.length - 1) return true;
|
|
1390
|
-
for (let k = pi; k <= path.length; k++) if (matchSegments(path, k, pat, qi + 1)) return true;
|
|
1391
|
-
return false;
|
|
1392
|
-
}
|
|
1393
|
-
if (pi >= path.length) return false;
|
|
1394
|
-
if (seg.kind === "literal") {
|
|
1395
|
-
if (seg.value !== path[pi]) return false;
|
|
1396
|
-
} else if (!seg.re.test(path[pi])) return false;
|
|
1397
|
-
pi++;
|
|
1398
|
-
qi++;
|
|
1399
|
-
}
|
|
1400
|
-
return pi === path.length;
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Whether `root` matches a workspace glob and no `!` glob. A nested app outside
|
|
1404
|
-
* the globs is a separate project.
|
|
1405
|
-
*/
|
|
1406
|
-
function isWorkspaceSubpackage(workspaceRoot, root) {
|
|
1407
|
-
const relPath = relative(workspaceRoot, root);
|
|
1408
|
-
if (relPath === "" || relPath.startsWith("..")) return false;
|
|
1409
|
-
const normalized = relPath.split(/[\\/]/).join("/");
|
|
1410
|
-
const patterns = readWorkspacePatterns(workspaceRoot);
|
|
1411
|
-
if (patterns.length === 0) return false;
|
|
1412
|
-
let matched = false;
|
|
1413
|
-
for (const raw of patterns) {
|
|
1414
|
-
const isNegation = raw.startsWith("!");
|
|
1415
|
-
if (matchesWorkspacePattern(normalized, isNegation ? raw.slice(1) : raw)) {
|
|
1416
|
-
if (isNegation) return false;
|
|
1417
|
-
matched = true;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
return matched;
|
|
1421
|
-
}
|
|
1422
1556
|
/** Workspace membership, even when the member manages its own install. */
|
|
1423
1557
|
function isInsideWorkspaceSubpackage(root) {
|
|
1424
|
-
|
|
1425
|
-
if (workspaceRoot === void 0) return false;
|
|
1426
|
-
return isWorkspaceSubpackage(workspaceRoot, root);
|
|
1558
|
+
return findWorkspaceMemberRoot(root) !== void 0;
|
|
1427
1559
|
}
|
|
1428
1560
|
/**
|
|
1429
1561
|
* The workspace root that should install for `root`: set when `root` is a
|
|
1430
1562
|
* member without its own lockfile or non-pnpm Corepack pin, as in `isPnpmProject`.
|
|
1431
1563
|
*/
|
|
1432
1564
|
function resolveWorkspaceDeferral(root, pkg) {
|
|
1433
|
-
const workspaceRoot =
|
|
1565
|
+
const workspaceRoot = findWorkspaceMemberRoot(root);
|
|
1434
1566
|
if (workspaceRoot === void 0) return;
|
|
1435
|
-
if (!isWorkspaceSubpackage(workspaceRoot, root)) return;
|
|
1436
1567
|
if (hasLocalLockfile(root)) return;
|
|
1437
1568
|
const localPm = parsePackageManagerField(pkg);
|
|
1438
1569
|
if (localPm === "bun" || localPm === "yarn" || localPm === "npm") return;
|
|
@@ -1442,7 +1573,7 @@ function detectProjectState(root) {
|
|
|
1442
1573
|
let hasTypescript = false;
|
|
1443
1574
|
let pkg;
|
|
1444
1575
|
try {
|
|
1445
|
-
pkg = JSON.parse(readFileSync(join(root, "package.json"), "
|
|
1576
|
+
pkg = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
1446
1577
|
const pkgRecord = pkg ?? {};
|
|
1447
1578
|
hasTypescript = "typescript" in {
|
|
1448
1579
|
...asRecord(pkgRecord.dependencies) ?? {},
|
|
@@ -1501,9 +1632,10 @@ function resolveScaffoldDependencySpec(root, packageName, fallbackVersion) {
|
|
|
1501
1632
|
return fallbackVersion;
|
|
1502
1633
|
}
|
|
1503
1634
|
function defaultPackageName(root) {
|
|
1504
|
-
return basename(root).toLowerCase().
|
|
1635
|
+
return basename(root).toLowerCase().replaceAll(/[^a-z0-9-]/g, "-") || "my-app";
|
|
1505
1636
|
}
|
|
1506
|
-
|
|
1637
|
+
/** Returns whether it removed a dependency from package.json, which leaves the lockfile stale. */
|
|
1638
|
+
function setupTsconfig(root, state, report, pagesFramework) {
|
|
1507
1639
|
const tsconfigPath = join(root, "tsconfig.json");
|
|
1508
1640
|
if (state.hasTsconfig) {
|
|
1509
1641
|
let tsconfig;
|
|
@@ -1513,9 +1645,9 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1513
1645
|
tsconfig = parsed;
|
|
1514
1646
|
} catch {
|
|
1515
1647
|
log.warn("Could not parse tsconfig.json, skipping");
|
|
1516
|
-
return;
|
|
1648
|
+
return false;
|
|
1517
1649
|
}
|
|
1518
|
-
|
|
1650
|
+
const changes = [];
|
|
1519
1651
|
const rootPathBaseDir = effectiveConfigPathBaseDir(tsconfig, tsconfigPath);
|
|
1520
1652
|
const existingPatch = collectTsconfigPatchFromConfig(tsconfig, tsconfigPath, root, rootPathBaseDir, /* @__PURE__ */ new Set());
|
|
1521
1653
|
const voidPatch = createVoidTsconfigPatch(root, rootPathBaseDir);
|
|
@@ -1525,22 +1657,19 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1525
1657
|
if (typeof extendsValue === "string") tsconfig.extends = [extendsValue, target];
|
|
1526
1658
|
else if (Array.isArray(extendsValue)) tsconfig.extends = [...extendsValue, target];
|
|
1527
1659
|
else tsconfig.extends = target;
|
|
1528
|
-
|
|
1529
|
-
log.step("Updated tsconfig.json — added extends .void/tsconfig.json");
|
|
1660
|
+
changes.push("extends .void/tsconfig.json");
|
|
1530
1661
|
}
|
|
1531
1662
|
const compilerOptions = asRecord(tsconfig.compilerOptions) ?? {};
|
|
1532
1663
|
tsconfig.compilerOptions = compilerOptions;
|
|
1533
1664
|
const types = Array.isArray(compilerOptions.types) ? compilerOptions.types.filter((value) => typeof value === "string") : [];
|
|
1534
1665
|
if (!types.includes("void/env")) {
|
|
1535
1666
|
types.push("void/env");
|
|
1536
|
-
|
|
1537
|
-
log.step("Updated tsconfig.json — added void/env to types");
|
|
1667
|
+
changes.push("added void/env to types");
|
|
1538
1668
|
}
|
|
1539
1669
|
const cfIdx = types.indexOf("@cloudflare/workers-types");
|
|
1540
1670
|
if (cfIdx !== -1) {
|
|
1541
1671
|
types.splice(cfIdx, 1);
|
|
1542
|
-
|
|
1543
|
-
log.step("Removed @cloudflare/workers-types from tsconfig types (included in void/env)");
|
|
1672
|
+
changes.push("removed @cloudflare/workers-types from types");
|
|
1544
1673
|
}
|
|
1545
1674
|
compilerOptions.types = types;
|
|
1546
1675
|
const existingFiles = uniqueStrings(existingPatch.files);
|
|
@@ -1548,8 +1677,7 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1548
1677
|
const files = uniqueStrings([...existingFiles, ...voidPatch.files]);
|
|
1549
1678
|
if (JSON.stringify(tsconfig.files) !== JSON.stringify(files)) {
|
|
1550
1679
|
tsconfig.files = files;
|
|
1551
|
-
|
|
1552
|
-
log.step("Updated tsconfig.json — merged generated Void type files");
|
|
1680
|
+
changes.push("merged Void type files");
|
|
1553
1681
|
}
|
|
1554
1682
|
}
|
|
1555
1683
|
if (Object.keys(existingPatch.paths).length > 0 || asRecord(compilerOptions.paths) !== null) {
|
|
@@ -1558,21 +1686,22 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1558
1686
|
const existingPaths = readPaths(compilerOptions.paths);
|
|
1559
1687
|
if (JSON.stringify(existingPaths) !== JSON.stringify(paths)) {
|
|
1560
1688
|
compilerOptions.paths = paths;
|
|
1561
|
-
|
|
1562
|
-
log.step("Updated tsconfig.json — merged generated Void path aliases");
|
|
1689
|
+
changes.push("merged Void path aliases");
|
|
1563
1690
|
}
|
|
1564
1691
|
}
|
|
1565
|
-
if (
|
|
1692
|
+
if (changes.length > 0) {
|
|
1566
1693
|
const { extends: ext, ...rest } = tsconfig;
|
|
1567
1694
|
const ordered = {
|
|
1568
1695
|
extends: ext,
|
|
1569
1696
|
...rest
|
|
1570
1697
|
};
|
|
1571
1698
|
writeFileSync(tsconfigPath, JSON.stringify(ordered, null, 2) + "\n");
|
|
1572
|
-
|
|
1699
|
+
for (const change of changes) report.updated("tsconfig.json", change);
|
|
1700
|
+
}
|
|
1701
|
+
let dependencyRemoved = false;
|
|
1573
1702
|
try {
|
|
1574
1703
|
const pkgPath = join(root, "package.json");
|
|
1575
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "
|
|
1704
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
1576
1705
|
let pkgUpdated = false;
|
|
1577
1706
|
if (pkg.dependencies?.["@cloudflare/workers-types"]) {
|
|
1578
1707
|
delete pkg.dependencies["@cloudflare/workers-types"];
|
|
@@ -1584,10 +1713,11 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1584
1713
|
}
|
|
1585
1714
|
if (pkgUpdated) {
|
|
1586
1715
|
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
1587
|
-
|
|
1588
|
-
|
|
1716
|
+
report.updated("package.json", "removed @cloudflare/workers-types");
|
|
1717
|
+
dependencyRemoved = true;
|
|
1589
1718
|
}
|
|
1590
1719
|
} catch {}
|
|
1720
|
+
return dependencyRemoved;
|
|
1591
1721
|
} else {
|
|
1592
1722
|
const tsconfig = {
|
|
1593
1723
|
extends: "./.void/tsconfig.json",
|
|
@@ -1612,104 +1742,89 @@ function setupTsconfig(root, state, pagesFramework) {
|
|
|
1612
1742
|
]
|
|
1613
1743
|
};
|
|
1614
1744
|
writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
|
|
1615
|
-
|
|
1616
|
-
if (!state.hasTypescript)
|
|
1745
|
+
report.created("tsconfig.json");
|
|
1746
|
+
if (!state.hasTypescript) report.next("Install typescript as a dev dependency");
|
|
1747
|
+
return false;
|
|
1617
1748
|
}
|
|
1618
1749
|
}
|
|
1619
|
-
|
|
1750
|
+
/** The project's Cloudflare config, or null when it is missing, unreadable or invalid. */
|
|
1751
|
+
function readProjectWranglerConfig(root) {
|
|
1620
1752
|
const configPath = materializeCloudflareConfig(root);
|
|
1621
|
-
if (!existsSync(configPath)) return;
|
|
1753
|
+
if (!existsSync(configPath)) return null;
|
|
1622
1754
|
try {
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
}
|
|
1755
|
+
return parseJsoncFile(configPath);
|
|
1756
|
+
} catch {
|
|
1757
|
+
return null;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
function readProjectWranglerCompatDate(root) {
|
|
1761
|
+
const date = readProjectWranglerConfig(root)?.compatibility_date;
|
|
1762
|
+
return typeof date === "string" ? date : void 0;
|
|
1627
1763
|
}
|
|
1628
1764
|
/**
|
|
1629
1765
|
* Ensure wrangler.jsonc exists with `compatibility_date` and `nodejs_als` flag
|
|
1630
1766
|
* for class B/C meta-frameworks that need it for local dev.
|
|
1631
1767
|
*/
|
|
1632
|
-
function setupWranglerConfig(root, framework) {
|
|
1768
|
+
function setupWranglerConfig(root, framework, report) {
|
|
1633
1769
|
if (framework.class === "a") return;
|
|
1634
|
-
const
|
|
1770
|
+
const configExisted = existsSync(materializeCloudflareConfig(root));
|
|
1771
|
+
const lockExisted = existsSync(join(root, VOID_LOCK_FILE));
|
|
1772
|
+
const before = readProjectWranglerConfig(root);
|
|
1635
1773
|
const result = writeProvisionedWranglerConfig(root, {
|
|
1636
1774
|
compatibilityDate: LATEST_KNOWN_COMPAT_DATE,
|
|
1637
1775
|
compatibilityFlags: ["nodejs_als"]
|
|
1638
1776
|
});
|
|
1639
|
-
if (result.modified)
|
|
1640
|
-
|
|
1777
|
+
if (!result.modified) return;
|
|
1778
|
+
const flags = before?.compatibility_flags;
|
|
1779
|
+
const detail = [...before?.compatibility_date === void 0 ? ["pinned compatibility_date"] : [], ...Array.isArray(flags) && flags.includes("nodejs_als") ? [] : ["added nodejs_als"]].join(", ");
|
|
1780
|
+
if (basename(result.configPath) !== ".void-wrangler.jsonc") report.wrote(relative(root, result.configPath), configExisted, detail);
|
|
1781
|
+
else if (existsSync(join(root, "void.lock.json"))) report.wrote(VOID_LOCK_FILE, lockExisted, detail);
|
|
1641
1782
|
}
|
|
1642
|
-
function ensureVoidWorkerCompatibilityDate(root) {
|
|
1783
|
+
function ensureVoidWorkerCompatibilityDate(root, report) {
|
|
1643
1784
|
const config = readConfig(root);
|
|
1644
1785
|
if (typeof config.target === "string" && config.target !== "cloudflare") return;
|
|
1645
1786
|
const worker = asRecord(config.worker) ?? {};
|
|
1646
1787
|
if (typeof worker.compatibility_date === "string" && worker.compatibility_date.length > 0) return;
|
|
1647
1788
|
const compatibilityDate = readProjectWranglerCompatDate(root) ?? "2026-02-24";
|
|
1648
1789
|
if (!canRewriteVoidProjectConfig(root)) {
|
|
1649
|
-
|
|
1650
|
-
|
|
1790
|
+
const lockExisted = existsSync(join(root, VOID_LOCK_FILE));
|
|
1791
|
+
if (writeProvisionedWranglerConfig(root, { compatibilityDate }).modified) report.wrote(VOID_LOCK_FILE, lockExisted, "pinned compatibility_date");
|
|
1651
1792
|
return;
|
|
1652
1793
|
}
|
|
1653
1794
|
config.worker = {
|
|
1654
1795
|
...worker,
|
|
1655
1796
|
compatibility_date: compatibilityDate
|
|
1656
1797
|
};
|
|
1657
|
-
|
|
1658
|
-
log.step("Pinned worker compatibility_date in void.config.ts");
|
|
1798
|
+
writeConfigFile(root, config, report, "pinned compatibility_date");
|
|
1659
1799
|
}
|
|
1660
|
-
/** Write `
|
|
1661
|
-
function
|
|
1662
|
-
const
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
else next.database = database;
|
|
1666
|
-
writeVoidProjectConfig(root, next);
|
|
1667
|
-
}
|
|
1668
|
-
function clearConfiguredDatabase(root, messages, options) {
|
|
1669
|
-
const config = readConfig(root);
|
|
1670
|
-
if (getDatabaseDialect(config) === "sqlite") {
|
|
1671
|
-
if (!options.quiet) log.info(messages.unchanged);
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1674
|
-
writeDatabaseDialect(root, config, "sqlite");
|
|
1675
|
-
if (!options.quiet) log.step(messages.updated);
|
|
1800
|
+
/** Write `void.config.ts` and record it with `detail`. */
|
|
1801
|
+
function writeConfigFile(root, config, report, detail) {
|
|
1802
|
+
const existed = existsSync(join(root, TYPED_CONFIG_FILE));
|
|
1803
|
+
writeVoidProjectConfig(root, config);
|
|
1804
|
+
report.wrote(TYPED_CONFIG_FILE, existed, detail);
|
|
1676
1805
|
}
|
|
1806
|
+
const DATABASE_LABELS = {
|
|
1807
|
+
sqlite: "D1 (SQLite)",
|
|
1808
|
+
postgresql: "PostgreSQL",
|
|
1809
|
+
mysql: "MySQL"
|
|
1810
|
+
};
|
|
1677
1811
|
/** Remove `database` entirely: its casing alone still makes Void serve `void/db`. */
|
|
1678
|
-
function removeDatabaseConfig(root) {
|
|
1812
|
+
function removeDatabaseConfig(root, report) {
|
|
1679
1813
|
const config = readConfig(root);
|
|
1680
|
-
if (config.database === void 0)
|
|
1681
|
-
log.info("No database configured yet");
|
|
1682
|
-
return;
|
|
1683
|
-
}
|
|
1814
|
+
if (config.database === void 0) return;
|
|
1684
1815
|
const next = { ...config };
|
|
1685
1816
|
delete next.database;
|
|
1686
|
-
|
|
1687
|
-
log.step("Removed database config from void.config.ts");
|
|
1817
|
+
writeConfigFile(root, next, report, "removed database");
|
|
1688
1818
|
}
|
|
1689
|
-
|
|
1819
|
+
/** Write `dialect` to the config's `database`, keeping its casing. */
|
|
1820
|
+
function applyDatabaseDialect(root, dialect, report) {
|
|
1690
1821
|
const config = readConfig(root);
|
|
1691
|
-
if (
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
if (!options.quiet) log.step("Configured PostgreSQL in void.config.ts");
|
|
1698
|
-
return;
|
|
1699
|
-
}
|
|
1700
|
-
if (dialect === "mysql") {
|
|
1701
|
-
if (getDatabaseDialect(config) === "mysql") {
|
|
1702
|
-
if (!options.quiet) log.info("MySQL already configured in void.config.ts");
|
|
1703
|
-
return;
|
|
1704
|
-
}
|
|
1705
|
-
writeDatabaseDialect(root, config, "mysql");
|
|
1706
|
-
if (!options.quiet) log.step("Configured MySQL in void.config.ts");
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1709
|
-
clearConfiguredDatabase(root, {
|
|
1710
|
-
unchanged: "Using default D1 (SQLite) configuration",
|
|
1711
|
-
updated: "Updated void.config.ts to use the default D1 (SQLite) configuration"
|
|
1712
|
-
}, options);
|
|
1822
|
+
if (getDatabaseDialect(config) === dialect) return;
|
|
1823
|
+
const next = { ...config };
|
|
1824
|
+
const database = databaseConfigValue(dialect, getDatabaseCasing(config));
|
|
1825
|
+
if (database === void 0) delete next.database;
|
|
1826
|
+
else next.database = database;
|
|
1827
|
+
writeConfigFile(root, next, report, `database: ${DATABASE_LABELS[dialect]}`);
|
|
1713
1828
|
}
|
|
1714
1829
|
function detectDatabaseSetup(root) {
|
|
1715
1830
|
const dialect = getDatabaseDialect(readConfig(root));
|
|
@@ -1717,12 +1832,12 @@ function detectDatabaseSetup(root) {
|
|
|
1717
1832
|
if (hasDrizzleSchema(root) || existsSync(readProjectPaths(root).migrationsDir) || existsSync(join(root, "migrations"))) return "sqlite";
|
|
1718
1833
|
return "none";
|
|
1719
1834
|
}
|
|
1720
|
-
function applyDatabaseSetup(root, choice) {
|
|
1835
|
+
function applyDatabaseSetup(root, choice, report) {
|
|
1721
1836
|
if (choice === "none") {
|
|
1722
|
-
removeDatabaseConfig(root);
|
|
1837
|
+
removeDatabaseConfig(root, report);
|
|
1723
1838
|
return;
|
|
1724
1839
|
}
|
|
1725
|
-
applyDatabaseDialect(root, choice);
|
|
1840
|
+
applyDatabaseDialect(root, choice, report);
|
|
1726
1841
|
}
|
|
1727
1842
|
/**
|
|
1728
1843
|
* A prompt cannot be answered when stdin is not a terminal, so fail with the
|
|
@@ -1862,7 +1977,7 @@ async function ensureVoidPlatformConnection(root) {
|
|
|
1862
1977
|
let selectedApiUrl = null;
|
|
1863
1978
|
let promptedForPlatform = false;
|
|
1864
1979
|
try {
|
|
1865
|
-
const { getApiUrl, getSiteDomain } = await import("./auth-
|
|
1980
|
+
const { getApiUrl, getSiteDomain } = await import("./auth-Boz0lrb3.mjs");
|
|
1866
1981
|
selectedApiUrl = getApiUrl(root);
|
|
1867
1982
|
getSiteDomain(root);
|
|
1868
1983
|
} catch (error) {
|
|
@@ -1904,6 +2019,12 @@ function getDevCommand(root, framework) {
|
|
|
1904
2019
|
function getNodeVersionLine(root) {
|
|
1905
2020
|
return `${existsSync(join(root, ".node-version")) ? "node-version-file: .node-version" : "node-version: lts/*"}\n check-latest: true`;
|
|
1906
2021
|
}
|
|
2022
|
+
const projectVoidRunner = {
|
|
2023
|
+
npm: "npx void",
|
|
2024
|
+
pnpm: "pnpm exec void",
|
|
2025
|
+
yarn: "yarn void",
|
|
2026
|
+
bun: "bunx void"
|
|
2027
|
+
};
|
|
1907
2028
|
function getWorkflowSetupSteps(root, pm) {
|
|
1908
2029
|
const nodeVersion = getNodeVersionLine(root);
|
|
1909
2030
|
switch (pm) {
|
|
@@ -1914,7 +2035,7 @@ function getWorkflowSetupSteps(root, pm) {
|
|
|
1914
2035
|
${nodeVersion}
|
|
1915
2036
|
cache: pnpm`,
|
|
1916
2037
|
install: " - run: pnpm install --frozen-lockfile",
|
|
1917
|
-
runner:
|
|
2038
|
+
runner: projectVoidRunner[pm]
|
|
1918
2039
|
};
|
|
1919
2040
|
case "yarn": return {
|
|
1920
2041
|
setup: ` - uses: actions/setup-node@v6
|
|
@@ -1922,7 +2043,7 @@ function getWorkflowSetupSteps(root, pm) {
|
|
|
1922
2043
|
${nodeVersion}
|
|
1923
2044
|
cache: yarn`,
|
|
1924
2045
|
install: " - run: yarn install --immutable",
|
|
1925
|
-
runner:
|
|
2046
|
+
runner: projectVoidRunner[pm]
|
|
1926
2047
|
};
|
|
1927
2048
|
case "bun": return {
|
|
1928
2049
|
setup: ` - uses: oven-sh/setup-bun@v2
|
|
@@ -1930,7 +2051,7 @@ function getWorkflowSetupSteps(root, pm) {
|
|
|
1930
2051
|
with:
|
|
1931
2052
|
${nodeVersion}`,
|
|
1932
2053
|
install: " - run: bun install --frozen-lockfile",
|
|
1933
|
-
runner:
|
|
2054
|
+
runner: projectVoidRunner[pm]
|
|
1934
2055
|
};
|
|
1935
2056
|
default: return {
|
|
1936
2057
|
setup: ` - uses: actions/setup-node@v6
|
|
@@ -1938,7 +2059,7 @@ function getWorkflowSetupSteps(root, pm) {
|
|
|
1938
2059
|
${nodeVersion}
|
|
1939
2060
|
cache: npm`,
|
|
1940
2061
|
install: " - run: npm ci",
|
|
1941
|
-
runner:
|
|
2062
|
+
runner: projectVoidRunner[pm]
|
|
1942
2063
|
};
|
|
1943
2064
|
}
|
|
1944
2065
|
}
|
|
@@ -2022,7 +2143,8 @@ ${install}
|
|
|
2022
2143
|
${runner} deploy --platform void --project "$VOID_PROJECT"
|
|
2023
2144
|
`;
|
|
2024
2145
|
}
|
|
2025
|
-
|
|
2146
|
+
const WORKFLOW_FILE = ".github/workflows/void-deploy.yml";
|
|
2147
|
+
function setupGithubActions(root, state, report, platform = "void", platformApiUrl) {
|
|
2026
2148
|
const workflowDir = join(root, ".github", "workflows");
|
|
2027
2149
|
const workflowPath = join(workflowDir, "void-deploy.yml");
|
|
2028
2150
|
if (existsSync(workflowPath)) {
|
|
@@ -2032,7 +2154,7 @@ function setupGithubActions(root, state, platform = "void", platformApiUrl) {
|
|
|
2032
2154
|
const slug = readProjectConfig(root)?.slug ?? null;
|
|
2033
2155
|
mkdirSync(workflowDir, { recursive: true });
|
|
2034
2156
|
writeFileSync(workflowPath, getWorkflowYaml(root, state.packageManager, slug, platform, platformApiUrl));
|
|
2035
|
-
|
|
2157
|
+
report.created(WORKFLOW_FILE);
|
|
2036
2158
|
if (platform === "cloudflare") note("Pushes to main will deploy through the same readiness-gated Cloudflare path.\nAdd a scoped CLOUDFLARE_API_TOKEN repository secret; PostgreSQL/MySQL apps also need DATABASE_URL.\nKeep cloudflare.account_id in void.config.ts.", "GitHub Actions Cloudflare deploy");
|
|
2037
2159
|
else if (slug) note(`Pushes to main will build and deploy "${slug}" via GitHub OIDC — no token to store.\nConnect the repo to your project in the Void dashboard to authorize it.`, "GitHub Actions OIDC deploy");
|
|
2038
2160
|
else note("Pushes to main will build and deploy via GitHub OIDC — no token to store.\nSet a VOID_PROJECT repository variable (Settings → Secrets and variables → Actions → Variables)\nto your project slug, and connect the repo to your project in the Void dashboard.", "GitHub Actions OIDC deploy");
|
|
@@ -2041,26 +2163,26 @@ function setupGithubActions(root, state, platform = "void", platformApiUrl) {
|
|
|
2041
2163
|
* Replace the `vars.VOID_PROJECT` placeholder in `void-deploy.yml` with a slug
|
|
2042
2164
|
* linked after the workflow was written. Returns false when there is none.
|
|
2043
2165
|
*/
|
|
2044
|
-
function patchWorkflowProjectSlug(root, slug) {
|
|
2045
|
-
const workflowPath = join(root,
|
|
2166
|
+
function patchWorkflowProjectSlug(root, slug, report) {
|
|
2167
|
+
const workflowPath = join(root, WORKFLOW_FILE);
|
|
2046
2168
|
if (!existsSync(workflowPath)) return false;
|
|
2047
|
-
const yaml = readFileSync(workflowPath, "
|
|
2169
|
+
const yaml = readFileSync(workflowPath, "utf8");
|
|
2048
2170
|
const placeholderBlock = " # Set a VOID_PROJECT repository variable to your project slug\n # (Settings → Secrets and variables → Actions → Variables).\n VOID_PROJECT: ${{ vars.VOID_PROJECT }}";
|
|
2049
2171
|
if (!yaml.includes(placeholderBlock)) return false;
|
|
2050
2172
|
writeFileSync(workflowPath, yaml.replace(placeholderBlock, ` VOID_PROJECT: ${slug}`));
|
|
2051
|
-
|
|
2173
|
+
report.updated(WORKFLOW_FILE, "set VOID_PROJECT");
|
|
2052
2174
|
return true;
|
|
2053
2175
|
}
|
|
2054
|
-
function writeFileIfMissing(root, filePath, content) {
|
|
2176
|
+
function writeFileIfMissing(root, filePath, content, report) {
|
|
2055
2177
|
const fullPath = join(root, filePath);
|
|
2056
2178
|
if (existsSync(fullPath)) return;
|
|
2057
2179
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
2058
2180
|
writeFileSync(fullPath, content);
|
|
2059
|
-
|
|
2181
|
+
report.created(filePath);
|
|
2060
2182
|
}
|
|
2061
|
-
function ensureGitignore(root) {
|
|
2183
|
+
function ensureGitignore(root, report) {
|
|
2062
2184
|
const existed = existsSync(join(root, ".gitignore"));
|
|
2063
|
-
if (ensureGitignoreLines(root, SCAFFOLD_GITIGNORE_LINES).length > 0)
|
|
2185
|
+
if (ensureGitignoreLines(root, SCAFFOLD_GITIGNORE_LINES).length > 0) report.wrote(".gitignore", existed, "added Void defaults");
|
|
2064
2186
|
}
|
|
2065
2187
|
/** Removes each block-style top-level `key:` block; `removed` holds its non-blank lines. */
|
|
2066
2188
|
function removeTopLevelYamlBlock(yaml, key) {
|
|
@@ -2121,7 +2243,7 @@ function insertPnpmAllowBuilds(yaml, allowBuilds) {
|
|
|
2121
2243
|
let insertIndex = packagesIndex + 1;
|
|
2122
2244
|
while (insertIndex < lines.length && (lines[insertIndex].trim() === "" || /^\s/.test(lines[insertIndex]))) insertIndex += 1;
|
|
2123
2245
|
lines.splice(insertIndex, 0, "", ...allowBuilds.split("\n"), "");
|
|
2124
|
-
return `${lines.join("\n").
|
|
2246
|
+
return `${lines.join("\n").replaceAll(/\n{3,}/g, "\n\n")}\n`;
|
|
2125
2247
|
}
|
|
2126
2248
|
function resolvePnpmConfigRoot(root, pkg) {
|
|
2127
2249
|
if (existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "pnpm-lock.yaml")) || parsePackageManagerField(pkg) === "pnpm") return root;
|
|
@@ -2129,11 +2251,12 @@ function resolvePnpmConfigRoot(root, pkg) {
|
|
|
2129
2251
|
if (workspaceRoot !== void 0 && hasAncestorPnpmMarkers(root)) return workspaceRoot;
|
|
2130
2252
|
return root;
|
|
2131
2253
|
}
|
|
2132
|
-
function ensurePnpmAllowBuilds(root, pkg) {
|
|
2254
|
+
function ensurePnpmAllowBuilds(root, pkg, report) {
|
|
2133
2255
|
const configRoot = resolvePnpmConfigRoot(root, pkg);
|
|
2134
2256
|
const workspacePath = join(configRoot, "pnpm-workspace.yaml");
|
|
2135
2257
|
const displayPath = configRoot === root ? "pnpm-workspace.yaml" : relative(root, workspacePath);
|
|
2136
|
-
const
|
|
2258
|
+
const existed = existsSync(workspacePath);
|
|
2259
|
+
const before = existed ? readFileSync(workspacePath, "utf8") : "";
|
|
2137
2260
|
const inline = /^allowBuilds:[ \t]*([^\s#].*)$/m.exec(before)?.[1];
|
|
2138
2261
|
if (inline !== void 0) {
|
|
2139
2262
|
const missing = PNPM_BUILD_DEFAULTS.filter(([name]) => !new RegExp(`[{,]\\s*["']?${name}["']?\\s*:`).test(inline));
|
|
@@ -2145,76 +2268,90 @@ function ensurePnpmAllowBuilds(root, pkg) {
|
|
|
2145
2268
|
const after = insertPnpmAllowBuilds(current.yaml, pnpmAllowBuildsYaml(current.removed, legacy.removed));
|
|
2146
2269
|
if (after !== before) {
|
|
2147
2270
|
writeFileSync(workspacePath, after);
|
|
2148
|
-
|
|
2271
|
+
report.wrote(displayPath, existed, "approved builds");
|
|
2149
2272
|
}
|
|
2150
2273
|
}
|
|
2151
|
-
|
|
2274
|
+
/** The tool that installs a project: `vp` when it uses Vite+, else its package manager. */
|
|
2275
|
+
function projectInstaller(pkg, packageManager) {
|
|
2276
|
+
return pkg !== null && hasPackageDependency(pkg, "vite-plus") ? "vp" : packageManager;
|
|
2277
|
+
}
|
|
2278
|
+
/** Decide how to install the project's dependencies. */
|
|
2279
|
+
function resolveProjectInstall(root, packageManager) {
|
|
2152
2280
|
const pkg = readPackageJson(root);
|
|
2153
|
-
const
|
|
2154
|
-
const
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
"--yes",
|
|
2177
|
-
process.platform === "win32" ? `"${packageArg}"` : packageArg,
|
|
2178
|
-
"vp",
|
|
2179
|
-
...args
|
|
2180
|
-
];
|
|
2181
|
-
}
|
|
2281
|
+
const installer = projectInstaller(pkg, packageManager);
|
|
2282
|
+
const args = installer === "vp" || packageManager === "pnpm" ? ["install", "--no-frozen-lockfile"] : ["install"];
|
|
2283
|
+
const manualArgs = args.join(" ");
|
|
2284
|
+
const install = {
|
|
2285
|
+
installer,
|
|
2286
|
+
command: installer,
|
|
2287
|
+
args,
|
|
2288
|
+
manualCommand: `${installer} ${manualArgs}`
|
|
2289
|
+
};
|
|
2290
|
+
if (installer !== "vp" || !pkg) return install;
|
|
2291
|
+
let localBin;
|
|
2292
|
+
try {
|
|
2293
|
+
const require = createRequire(join(root, "package.json"));
|
|
2294
|
+
localBin = join(dirname(require.resolve("vite-plus/package.json")), "bin/vp");
|
|
2295
|
+
} catch {}
|
|
2296
|
+
if (localBin) {
|
|
2297
|
+
const runtime = process.versions.bun ? "bun" : "node";
|
|
2298
|
+
return {
|
|
2299
|
+
...install,
|
|
2300
|
+
command: process.execPath,
|
|
2301
|
+
args: [localBin, ...args],
|
|
2302
|
+
manualCommand: `${runtime} ${quoteShellArgument(relative(root, localBin))} ${manualArgs}`
|
|
2303
|
+
};
|
|
2182
2304
|
}
|
|
2183
|
-
|
|
2305
|
+
if (spawnSync("vp", ["--version"], {
|
|
2306
|
+
cwd: root,
|
|
2307
|
+
stdio: "ignore",
|
|
2308
|
+
shell: process.platform === "win32",
|
|
2309
|
+
timeout: 5e3
|
|
2310
|
+
}).status === 0) return install;
|
|
2311
|
+
const vitePlus = `vite-plus@${resolveVitePlusBootstrapSpec(root, pkg)}`;
|
|
2312
|
+
const packageArg = `--package=${vitePlus}`;
|
|
2313
|
+
return {
|
|
2314
|
+
installer,
|
|
2315
|
+
command: "npx",
|
|
2316
|
+
args: [
|
|
2317
|
+
"--yes",
|
|
2318
|
+
process.platform === "win32" ? `"${packageArg}"` : packageArg,
|
|
2319
|
+
"vp",
|
|
2320
|
+
...args
|
|
2321
|
+
],
|
|
2322
|
+
manualCommand: `npx -p ${quoteShellArgument(vitePlus)} vp ${manualArgs}`
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
/** Install the project's dependencies. Returns how long the installer ran, in milliseconds. */
|
|
2326
|
+
async function installProjectDependencies(root, install) {
|
|
2327
|
+
const { installer, command, args } = install;
|
|
2328
|
+
const result = await runBehindSpinner(`Installing dependencies with ${installer}`, command, args, {
|
|
2184
2329
|
cwd: root,
|
|
2185
|
-
|
|
2186
|
-
|
|
2330
|
+
shell: command !== process.execPath && process.platform === "win32",
|
|
2331
|
+
failed: `Failed to install dependencies with ${installer}`
|
|
2187
2332
|
});
|
|
2188
|
-
if (result.error) throw result.error;
|
|
2189
2333
|
if (result.status !== 0) throw new Error(`${installer} install failed with exit code ${result.status ?? "unknown"}`);
|
|
2190
|
-
|
|
2334
|
+
return result.durationMs;
|
|
2191
2335
|
}
|
|
2192
|
-
|
|
2336
|
+
/** Generate the first migration for the schema that a starter or the demo created. */
|
|
2337
|
+
async function generateStarterMigration(root, starterMode) {
|
|
2193
2338
|
const dialect = starterMode;
|
|
2194
2339
|
const configPath = writeDrizzleConfig(root, PLACEHOLDER_DB_URL[dialect], dialect);
|
|
2195
2340
|
const rollBack = snapshotDrizzleOutputs(readProjectPaths(root).migrationsDir);
|
|
2196
|
-
|
|
2197
|
-
const result = spawnSync(process.execPath, [
|
|
2341
|
+
if ((await runBehindSpinner("Generating the initial database migration", process.execPath, [
|
|
2198
2342
|
drizzleKitBin,
|
|
2199
2343
|
"generate",
|
|
2200
2344
|
"--config",
|
|
2201
2345
|
configPath
|
|
2202
2346
|
], {
|
|
2203
2347
|
cwd: root,
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
});
|
|
2208
|
-
if (result.error || result.status !== 0) rollBack();
|
|
2209
|
-
if (result.error) throw result.error;
|
|
2210
|
-
if (result.status !== 0) {
|
|
2211
|
-
const detail = [result.stderr, result.stdout].filter(Boolean).join("\n").trim();
|
|
2212
|
-
throw new Error(["Failed to generate the starter database migration.", ...detail ? [detail] : []].join("\n\n"));
|
|
2213
|
-
}
|
|
2214
|
-
log.step("Generated initial Drizzle migration");
|
|
2348
|
+
env: buildDrizzleKitSpawnEnv(root),
|
|
2349
|
+
undo: rollBack
|
|
2350
|
+
})).status !== 0) throw new Error("Failed to generate the initial database migration.");
|
|
2215
2351
|
}
|
|
2216
|
-
function scaffoldPagesApp(root, packageManager, framework, starterMode, toolchain) {
|
|
2352
|
+
function scaffoldPagesApp(root, packageManager, framework, starterMode, toolchain, report) {
|
|
2217
2353
|
const packageJsonPath = join(root, "package.json");
|
|
2354
|
+
const packageJsonExisted = existsSync(packageJsonPath);
|
|
2218
2355
|
const template = createPagesStarterTemplate({
|
|
2219
2356
|
framework,
|
|
2220
2357
|
starterMode,
|
|
@@ -2223,8 +2360,8 @@ function scaffoldPagesApp(root, packageManager, framework, starterMode, toolchai
|
|
|
2223
2360
|
adapterPackageSpec: resolveScaffoldDependencySpec(root, SCAFFOLD_FRAMEWORKS[framework].adapterPackage, getOwnVersion())
|
|
2224
2361
|
});
|
|
2225
2362
|
let pkg = {};
|
|
2226
|
-
if (
|
|
2227
|
-
pkg = asRecord(JSON.parse(readFileSync(packageJsonPath, "
|
|
2363
|
+
if (packageJsonExisted) try {
|
|
2364
|
+
pkg = asRecord(JSON.parse(readFileSync(packageJsonPath, "utf8"))) ?? {};
|
|
2228
2365
|
} catch {
|
|
2229
2366
|
throw new Error("Could not parse package.json in empty project");
|
|
2230
2367
|
}
|
|
@@ -2242,15 +2379,24 @@ function scaffoldPagesApp(root, packageManager, framework, starterMode, toolchai
|
|
|
2242
2379
|
const devDependencies = asRecord(pkg.devDependencies) ?? {};
|
|
2243
2380
|
pkg.dependencies = dependencies;
|
|
2244
2381
|
pkg.devDependencies = devDependencies;
|
|
2382
|
+
let existingDependencies = getPackageDependencies(pkg);
|
|
2383
|
+
const workspace = resolveWorkspaceDeferral(root, pkg);
|
|
2384
|
+
if (!existingDependencies["vite-plus"] && workspace) {
|
|
2385
|
+
const workspacePackage = readPackageJson(workspace.workspaceRoot);
|
|
2386
|
+
if (workspacePackage) existingDependencies = getPackageDependencies(workspacePackage);
|
|
2387
|
+
}
|
|
2388
|
+
const existingVite = existingDependencies.vite;
|
|
2389
|
+
const preserveVitePlus = !!existingDependencies["vite-plus"] && (existingVite?.startsWith("npm:@voidzero-dev/vite-plus-core@") || existingVite?.startsWith("catalog:"));
|
|
2245
2390
|
let dependencyAdded = false;
|
|
2246
2391
|
const ensureDependency = (group, name, fallbackVersion) => {
|
|
2247
2392
|
const otherGroup = group === "dependencies" ? "devDependencies" : "dependencies";
|
|
2248
2393
|
const targetGroup = group === "dependencies" ? dependencies : devDependencies;
|
|
2249
2394
|
const sourceGroup = otherGroup === "dependencies" ? dependencies : devDependencies;
|
|
2250
|
-
const
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2253
|
-
|
|
2395
|
+
const isVitePlusDependency = toolchain === "vite-plus" && (name === "vite" || name === "vite-plus");
|
|
2396
|
+
const existing = isVitePlusDependency && preserveVitePlus ? existingDependencies[name] : targetGroup[name] ?? sourceGroup[name];
|
|
2397
|
+
const version = isVitePlusDependency && !preserveVitePlus ? fallbackVersion : existing ?? fallbackVersion;
|
|
2398
|
+
if (targetGroup[name] !== version) {
|
|
2399
|
+
targetGroup[name] = version;
|
|
2254
2400
|
dependencyAdded = true;
|
|
2255
2401
|
}
|
|
2256
2402
|
if (sourceGroup[name]) {
|
|
@@ -2260,24 +2406,18 @@ function scaffoldPagesApp(root, packageManager, framework, starterMode, toolchai
|
|
|
2260
2406
|
};
|
|
2261
2407
|
for (const [name, version] of Object.entries(template.dependencies)) ensureDependency("dependencies", name, version);
|
|
2262
2408
|
for (const [name, version] of Object.entries(template.devDependencies)) ensureDependency("devDependencies", name, version);
|
|
2263
|
-
if (packageManager === "pnpm" || isPnpmProject(root, pkg)) ensurePnpmAllowBuilds(root, pkg);
|
|
2264
|
-
if (toolchain === "vite-plus") configureVitePlusScaffold(packageManager === "pnpm" ? resolvePnpmConfigRoot(root, pkg) : root, packageManager, pkg);
|
|
2409
|
+
if (packageManager === "pnpm" || isPnpmProject(root, pkg)) ensurePnpmAllowBuilds(root, pkg, report);
|
|
2410
|
+
if (toolchain === "vite-plus" && !preserveVitePlus) configureVitePlusScaffold(packageManager === "pnpm" ? resolvePnpmConfigRoot(root, pkg) : root, packageManager, pkg);
|
|
2265
2411
|
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2266
|
-
|
|
2267
|
-
for (const [filePath, content] of Object.entries(template.files)) writeFileIfMissing(root, filePath, content);
|
|
2268
|
-
ensureGitignore(root);
|
|
2269
|
-
if (starterMode !== "static") applyDatabaseDialect(root, starterMode,
|
|
2270
|
-
if (starterMode === "postgresql") {
|
|
2271
|
-
const devCommand = getDevCommand(root);
|
|
2272
|
-
note(`Add DATABASE_URL to .env before running \`${devCommand}\`.\nVoid uses that direct connection for local PostgreSQL development.`, "PostgreSQL local dev");
|
|
2273
|
-
} else if (starterMode === "mysql") {
|
|
2274
|
-
const devCommand = getDevCommand(root);
|
|
2275
|
-
note(`Add DATABASE_URL to .env before running \`${devCommand}\`.\nVoid uses that direct connection for local MySQL development.`, "MySQL local dev");
|
|
2276
|
-
}
|
|
2412
|
+
report.wrote("package.json", packageJsonExisted, "added starter scripts and dependencies");
|
|
2413
|
+
for (const [filePath, content] of Object.entries(template.files)) writeFileIfMissing(root, filePath, content, report);
|
|
2414
|
+
ensureGitignore(root, report);
|
|
2415
|
+
if (starterMode !== "static") applyDatabaseDialect(root, starterMode, report);
|
|
2416
|
+
if (starterMode === "postgresql" || starterMode === "mysql") report.next(`Add DATABASE_URL to .env before running \`${getDevCommand(root)}\` (Void uses it for local ${DATABASE_LABELS[starterMode]} development)`);
|
|
2277
2417
|
return dependencyAdded;
|
|
2278
2418
|
}
|
|
2279
2419
|
/** Returns whether a dependency was added. */
|
|
2280
|
-
function ensureExistingProjectPackage(root, options = {}) {
|
|
2420
|
+
function ensureExistingProjectPackage(root, report, options = {}) {
|
|
2281
2421
|
const packageJsonPath = join(root, "package.json");
|
|
2282
2422
|
const voidSpec = resolveScaffoldDependencySpec(root, "void", getOwnVersion());
|
|
2283
2423
|
const plainViteSetup = options.plainViteSetup ?? true;
|
|
@@ -2286,7 +2426,7 @@ function ensureExistingProjectPackage(root, options = {}) {
|
|
|
2286
2426
|
if (existsSync(packageJsonPath)) {
|
|
2287
2427
|
existedBefore = true;
|
|
2288
2428
|
try {
|
|
2289
|
-
pkg = asRecord(JSON.parse(readFileSync(packageJsonPath, "
|
|
2429
|
+
pkg = asRecord(JSON.parse(readFileSync(packageJsonPath, "utf8"))) ?? {};
|
|
2290
2430
|
} catch {
|
|
2291
2431
|
throw new Error("Could not parse package.json while configuring Void");
|
|
2292
2432
|
}
|
|
@@ -2294,9 +2434,13 @@ function ensureExistingProjectPackage(root, options = {}) {
|
|
|
2294
2434
|
const fallbackName = defaultPackageName(root);
|
|
2295
2435
|
let changed = !existedBefore;
|
|
2296
2436
|
let dependencyAdded = false;
|
|
2437
|
+
const addedPackages = [];
|
|
2438
|
+
const addedScripts = [];
|
|
2439
|
+
let addedName = false;
|
|
2297
2440
|
if (!pkg.name || typeof pkg.name !== "string") {
|
|
2298
2441
|
pkg.name = fallbackName;
|
|
2299
2442
|
changed = true;
|
|
2443
|
+
addedName = true;
|
|
2300
2444
|
}
|
|
2301
2445
|
if (!existedBefore && pkg.private === void 0) {
|
|
2302
2446
|
pkg.private = true;
|
|
@@ -2312,10 +2456,12 @@ function ensureExistingProjectPackage(root, options = {}) {
|
|
|
2312
2456
|
if (typeof scripts.dev !== "string") {
|
|
2313
2457
|
scripts.dev = "vite";
|
|
2314
2458
|
changed = true;
|
|
2459
|
+
addedScripts.push("dev");
|
|
2315
2460
|
}
|
|
2316
2461
|
if (typeof scripts.build !== "string") {
|
|
2317
2462
|
scripts.build = "vite build";
|
|
2318
2463
|
changed = true;
|
|
2464
|
+
addedScripts.push("build");
|
|
2319
2465
|
}
|
|
2320
2466
|
}
|
|
2321
2467
|
const devDependencies = asRecord(pkg.devDependencies) ?? {};
|
|
@@ -2324,16 +2470,23 @@ function ensureExistingProjectPackage(root, options = {}) {
|
|
|
2324
2470
|
devDependencies.void = voidSpec;
|
|
2325
2471
|
changed = true;
|
|
2326
2472
|
dependencyAdded = true;
|
|
2473
|
+
addedPackages.push("void");
|
|
2327
2474
|
}
|
|
2328
2475
|
if (plainViteSetup && !hasPackageDependency(pkg, "vite", DEPENDENCY_FIELDS)) {
|
|
2329
2476
|
devDependencies.vite = SCAFFOLD_BASE_DEV_DEPENDENCIES.vite;
|
|
2330
2477
|
changed = true;
|
|
2331
2478
|
dependencyAdded = true;
|
|
2479
|
+
addedPackages.push("vite");
|
|
2332
2480
|
}
|
|
2333
|
-
if (isPnpmProject(root, pkg)) ensurePnpmAllowBuilds(root, pkg);
|
|
2481
|
+
if (isPnpmProject(root, pkg)) ensurePnpmAllowBuilds(root, pkg, report);
|
|
2334
2482
|
if (changed) {
|
|
2335
2483
|
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2336
|
-
|
|
2484
|
+
const added = [
|
|
2485
|
+
...addedPackages,
|
|
2486
|
+
...addedScripts.length > 0 ? [`${addedScripts.join("/")} ${addedScripts.length > 1 ? "scripts" : "script"}`] : [],
|
|
2487
|
+
...addedName ? ["name"] : []
|
|
2488
|
+
];
|
|
2489
|
+
report.wrote("package.json", existedBefore, `added ${new Intl.ListFormat("en").format(added)}`);
|
|
2337
2490
|
}
|
|
2338
2491
|
return dependencyAdded;
|
|
2339
2492
|
}
|
|
@@ -2367,34 +2520,31 @@ function noteManualFrameworkConfigSetup(framework) {
|
|
|
2367
2520
|
}
|
|
2368
2521
|
noteManualViteConfigSetup();
|
|
2369
2522
|
}
|
|
2370
|
-
function ensureExistingProjectViteConfig(root, framework) {
|
|
2523
|
+
function ensureExistingProjectViteConfig(root, report, framework) {
|
|
2371
2524
|
if (framework?.class === "c") {
|
|
2372
2525
|
noteManualFrameworkConfigSetup(framework);
|
|
2373
2526
|
return;
|
|
2374
2527
|
}
|
|
2375
2528
|
const configPath = findViteConfig(root);
|
|
2376
2529
|
if (!configPath) {
|
|
2377
|
-
writeFileIfMissing(root, getGeneratedViteConfigPath(root), getBasicVoidViteConfig());
|
|
2530
|
+
writeFileIfMissing(root, getGeneratedViteConfigPath(root), getBasicVoidViteConfig(), report);
|
|
2378
2531
|
return;
|
|
2379
2532
|
}
|
|
2380
2533
|
const fullPath = join(root, configPath);
|
|
2381
|
-
const original = readFileSync(fullPath, "
|
|
2534
|
+
const original = readFileSync(fullPath, "utf8");
|
|
2382
2535
|
const updated = patchViteConfigWithVoidPlugin(configPath, original);
|
|
2383
2536
|
if (updated === void 0) {
|
|
2384
2537
|
noteManualViteConfigSetup(configPath);
|
|
2385
2538
|
return;
|
|
2386
2539
|
}
|
|
2387
|
-
if (updated === original)
|
|
2388
|
-
log.info(`${configPath} already includes voidPlugin()`);
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2540
|
+
if (updated === original) return;
|
|
2391
2541
|
writeFileSync(fullPath, updated);
|
|
2392
|
-
|
|
2542
|
+
report.updated(configPath, "added voidPlugin()");
|
|
2393
2543
|
}
|
|
2394
2544
|
/** Returns whether a dependency was added. */
|
|
2395
|
-
function setupExistingProject(root, framework) {
|
|
2396
|
-
const dependencyAdded = ensureExistingProjectPackage(root, { plainViteSetup: framework?.class !== "c" });
|
|
2397
|
-
ensureExistingProjectViteConfig(root, framework);
|
|
2545
|
+
function setupExistingProject(root, report, framework) {
|
|
2546
|
+
const dependencyAdded = ensureExistingProjectPackage(root, report, { plainViteSetup: framework?.class !== "c" });
|
|
2547
|
+
ensureExistingProjectViteConfig(root, report, framework);
|
|
2398
2548
|
return dependencyAdded;
|
|
2399
2549
|
}
|
|
2400
2550
|
/** The demo `posts` table for the database dialect that init configured. */
|
|
@@ -2441,13 +2591,13 @@ function demoFiles(root) {
|
|
|
2441
2591
|
* `setupExistingProject` has already declared `void` in `package.json`.
|
|
2442
2592
|
* The caller skips the demo when any of its files exists, so these writes never replace user code.
|
|
2443
2593
|
*/
|
|
2444
|
-
function scaffoldDemo(root, dialect) {
|
|
2594
|
+
function scaffoldDemo(root, dialect, report) {
|
|
2445
2595
|
const devCommand = getDevCommand(root);
|
|
2446
2596
|
const paths = readProjectPaths(root);
|
|
2447
2597
|
const files = demoFiles(root);
|
|
2448
2598
|
mkdirSync(paths.dbDir, { recursive: true });
|
|
2449
2599
|
writeFileSync(files.schema, demoSchemaSource(dialect));
|
|
2450
|
-
|
|
2600
|
+
report.created(relative(root, files.schema));
|
|
2451
2601
|
mkdirSync(join(paths.routesDir, "api"), { recursive: true });
|
|
2452
2602
|
writeFileSync(files.route, `import { defineHandler } from "void";
|
|
2453
2603
|
import { db } from "void/db";
|
|
@@ -2458,7 +2608,7 @@ export const GET = defineHandler(async () => {
|
|
|
2458
2608
|
return db.select().from(posts);
|
|
2459
2609
|
});
|
|
2460
2610
|
`);
|
|
2461
|
-
|
|
2611
|
+
report.created(relative(root, files.route));
|
|
2462
2612
|
ensureProjectTsconfig(root, void 0, true, true, { paths });
|
|
2463
2613
|
mkdirSync(paths.ssrDir, { recursive: true });
|
|
2464
2614
|
writeFileSync(files.client, `import { fetch } from "void/client";
|
|
@@ -2472,7 +2622,7 @@ console.log(posts);
|
|
|
2472
2622
|
// posts[0].body ← string (type-checked)
|
|
2473
2623
|
// posts[0].nope ← TypeScript error
|
|
2474
2624
|
`);
|
|
2475
|
-
|
|
2625
|
+
report.created(relative(root, files.client));
|
|
2476
2626
|
note(`SQL migration → DB types → Route handler → Route types → Typed fetch
|
|
2477
2627
|
|
|
2478
2628
|
Run \`${devCommand}\` and open src/demo.ts to see the types in action.\nTry changing the migration or handler — types update automatically.`, "Type Safety Demo");
|
|
@@ -2480,18 +2630,15 @@ Run \`${devCommand}\` and open src/demo.ts to see the types in action.\nTry chan
|
|
|
2480
2630
|
const MARKER_VERSION_SOURCE = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?` + String.raw`(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?`;
|
|
2481
2631
|
const MARKER_CLOSE = "<!--/injected-by-void-->";
|
|
2482
2632
|
const MARKER_BLOCK_RE = new RegExp(String.raw`^<!--injected-by-void-v${MARKER_VERSION_SOURCE}-->\r?\n[\s\S]*?^<!--\/injected-by-void-->\r?$`, "m");
|
|
2483
|
-
async function injectAgentBlock(root, newProject) {
|
|
2633
|
+
async function injectAgentBlock(root, newProject, report) {
|
|
2484
2634
|
const filePath = "AGENTS.md";
|
|
2485
2635
|
const fullPath = join(root, filePath);
|
|
2486
2636
|
const version = getOwnVersion();
|
|
2487
|
-
const template = readFileSync(join(getPackageDir(), "AGENTS_TEMPLATE.md"), "
|
|
2637
|
+
const template = readFileSync(join(getPackageDir(), "AGENTS_TEMPLATE.md"), "utf8");
|
|
2488
2638
|
const block = `${`<!--injected-by-void-v${version}-->`}\n${template}\n${MARKER_CLOSE}`;
|
|
2489
|
-
const existing = existsSync(fullPath) ? readFileSync(fullPath, "
|
|
2639
|
+
const existing = existsSync(fullPath) ? readFileSync(fullPath, "utf8") : null;
|
|
2490
2640
|
const managedBlock = existing?.match(MARKER_BLOCK_RE);
|
|
2491
|
-
if (managedBlock?.[0] === block)
|
|
2492
|
-
log.info(`${filePath} already has Void instructions (v${version})`);
|
|
2493
|
-
return;
|
|
2494
|
-
}
|
|
2641
|
+
if (managedBlock?.[0] === block) return;
|
|
2495
2642
|
if (!newProject) {
|
|
2496
2643
|
if (process.env.CI || !process.stdin.isTTY) {
|
|
2497
2644
|
log.info(`Skipping ${filePath} setup without an interactive terminal; read node_modules/void/docs/.`);
|
|
@@ -2511,30 +2658,53 @@ async function injectAgentBlock(root, newProject) {
|
|
|
2511
2658
|
if (managedBlock) {
|
|
2512
2659
|
const updated = existing.replace(MARKER_BLOCK_RE, block);
|
|
2513
2660
|
writeFileSync(fullPath, updated);
|
|
2514
|
-
|
|
2661
|
+
report.updated(filePath, "updated Void instructions");
|
|
2515
2662
|
} else {
|
|
2516
2663
|
const separator = existing.endsWith("\n") ? "\n" : "\n\n";
|
|
2517
2664
|
writeFileSync(fullPath, existing + separator + block + "\n");
|
|
2518
|
-
|
|
2665
|
+
report.updated(filePath, "added Void instructions");
|
|
2519
2666
|
}
|
|
2520
2667
|
} else {
|
|
2521
2668
|
writeFileSync(fullPath, block + "\n");
|
|
2522
|
-
|
|
2669
|
+
report.created(filePath);
|
|
2523
2670
|
}
|
|
2524
2671
|
}
|
|
2672
|
+
/** The summary of a new starter, such as "Created a React Pages starter with D1 (SQLite)". */
|
|
2673
|
+
function describeStarter(framework, starterMode, folder) {
|
|
2674
|
+
const label = SCAFFOLD_FRAMEWORKS[framework].label;
|
|
2675
|
+
const starter = starterMode === "static" ? `Created a static ${label} Pages starter` : `Created a ${label} Pages starter with ${DATABASE_LABELS[starterMode]}`;
|
|
2676
|
+
return folder ? `${starter} in ./${folder}` : starter;
|
|
2677
|
+
}
|
|
2525
2678
|
async function runInitCommand(root, initArgs) {
|
|
2526
2679
|
console.log();
|
|
2680
|
+
const report = new InitReport();
|
|
2681
|
+
await report.printIfStopped(() => runInitSteps(root, report, initArgs));
|
|
2682
|
+
}
|
|
2683
|
+
async function runInitSteps(root, report, initArgs) {
|
|
2527
2684
|
const targeted = Boolean(initArgs && (initArgs.tsconfig || initArgs.github));
|
|
2685
|
+
const requestedRoot = root;
|
|
2528
2686
|
if (!targeted) root = await resolveInitRoot(root);
|
|
2687
|
+
/** The new folder for the project, when the user asked init to create one. */
|
|
2688
|
+
const subfolder = root === requestedRoot ? void 0 : relative(requestedRoot, root);
|
|
2529
2689
|
const newProject = isScaffoldableEmptyProject(root) && !existsSync(join(root, "AGENTS.md"));
|
|
2530
2690
|
const hadTypedConfig = existsSync(join(root, TYPED_CONFIG_FILE));
|
|
2531
|
-
|
|
2691
|
+
const missingBeforeMigration = [
|
|
2692
|
+
TYPED_CONFIG_FILE,
|
|
2693
|
+
VOID_LOCK_FILE,
|
|
2694
|
+
".gitignore"
|
|
2695
|
+
].filter((file) => !existsSync(join(root, file)));
|
|
2696
|
+
if (migrateLegacyVoidConfig(root)) {
|
|
2697
|
+
for (const file of missingBeforeMigration) if (existsSync(join(root, file))) report.created(file);
|
|
2698
|
+
report.done(`Migrated project configuration to ${TYPED_CONFIG_FILE}`);
|
|
2699
|
+
const migrated = [TYPED_CONFIG_FILE, VOID_LOCK_FILE].filter((file) => existsSync(join(root, file)));
|
|
2700
|
+
report.next(`Commit ${new Intl.ListFormat("en").format(migrated)}`);
|
|
2701
|
+
}
|
|
2532
2702
|
const workspaceSubpackage = isInsideWorkspaceSubpackage(root);
|
|
2533
2703
|
if (workspaceSubpackage && initArgs?.git !== void 0) throw new Error("init: The --git/--no-git options are not available when adding a package to an existing monorepo.");
|
|
2534
2704
|
const framework = detectFramework(root);
|
|
2535
2705
|
const scaffoldStarter = !targeted && !framework && isScaffoldableEmptyProject(root);
|
|
2536
2706
|
if (framework) log.info(`Detected ${framework.name} framework`);
|
|
2537
|
-
else if (scaffoldStarter) log.info("Empty project detected. Creating a Pages starter.");
|
|
2707
|
+
else if (scaffoldStarter) log.info(subfolder ? `Creating a Pages starter in ./${subfolder}.` : "Empty project detected. Creating a Pages starter.");
|
|
2538
2708
|
else if (!targeted) log.info("Existing project detected. Configuring Void.");
|
|
2539
2709
|
const gitInitialized = !workspaceSubpackage && (!targeted || initArgs?.git !== void 0) ? await setupGit(root, initArgs?.git) : false;
|
|
2540
2710
|
const preScaffoldState = detectProjectState(root);
|
|
@@ -2556,14 +2726,15 @@ async function runInitCommand(root, initArgs) {
|
|
|
2556
2726
|
const existingPackageJson = readPackageJson(root);
|
|
2557
2727
|
const hasPackageManager = hasLocalLockfile(root) || existsSync(join(root, "pnpm-workspace.yaml")) || parsePackageManagerField(existingPackageJson) !== void 0 || resolveWorkspaceDeferral(root, existingPackageJson) !== void 0;
|
|
2558
2728
|
const scaffoldPackageManager = scaffoldToolchain === "vite-plus" && !hasPackageManager ? "pnpm" : preScaffoldState.packageManager;
|
|
2559
|
-
const scaffoldWroteDeps = scaffoldPagesApp(root, scaffoldPackageManager, scaffoldedPagesFramework, starterMode, scaffoldToolchain);
|
|
2729
|
+
const scaffoldWroteDeps = scaffoldPagesApp(root, scaffoldPackageManager, scaffoldedPagesFramework, starterMode, scaffoldToolchain, report);
|
|
2730
|
+
report.setStarter(describeStarter(scaffoldedPagesFramework, starterMode, subfolder));
|
|
2560
2731
|
const deferral = resolveWorkspaceDeferral(root, readPackageJson(root));
|
|
2561
2732
|
const voidResolvable = isVoidResolvableFrom(root);
|
|
2562
2733
|
if (deferral && (!voidResolvable || scaffoldWroteDeps)) {
|
|
2563
2734
|
workspaceSubpackageSkip = true;
|
|
2564
2735
|
const relRoot = relative(deferral.workspaceRoot, root) || ".";
|
|
2565
|
-
const dbFollowUp = starterMode === "static" ? "" :
|
|
2566
|
-
note(`Scaffolded the Pages starter in ./${relRoot}.\n\nRun your workspace install from ${deferral.workspaceRoot} to pick up the new dependencies
|
|
2736
|
+
const dbFollowUp = starterMode === "static" ? "." : `,\nthen run \`void db generate\` from ./${relRoot} to create the initial migration.`;
|
|
2737
|
+
note(`Scaffolded the Pages starter in ./${relRoot}.\n\nRun your workspace install from ${deferral.workspaceRoot} to pick up the new dependencies${dbFollowUp}`, "Workspace subpackage");
|
|
2567
2738
|
} else if (scaffoldWroteDeps || !voidResolvable) scaffoldAddedDependencies = true;
|
|
2568
2739
|
if (starterMode !== "static") scaffoldedStarterMode = starterMode;
|
|
2569
2740
|
didScaffoldStarter = true;
|
|
@@ -2571,7 +2742,7 @@ async function runInitCommand(root, initArgs) {
|
|
|
2571
2742
|
const state = detectProjectState(root);
|
|
2572
2743
|
const pagesFramework = scaffoldedPagesFramework ?? detectPagesFramework(root);
|
|
2573
2744
|
if (!targeted && !didScaffoldStarter) {
|
|
2574
|
-
const dependencyAdded = setupExistingProject(root, framework);
|
|
2745
|
+
const dependencyAdded = setupExistingProject(root, report, framework);
|
|
2575
2746
|
const voidResolvable = isVoidResolvableFrom(root);
|
|
2576
2747
|
if (dependencyAdded || !voidResolvable) {
|
|
2577
2748
|
const deferral = resolveWorkspaceDeferral(root, readPackageJson(root));
|
|
@@ -2582,25 +2753,27 @@ async function runInitCommand(root, initArgs) {
|
|
|
2582
2753
|
} else scaffoldAddedDependencies = true;
|
|
2583
2754
|
}
|
|
2584
2755
|
}
|
|
2756
|
+
let packageDependencyRemoved = false;
|
|
2585
2757
|
if (!targeted || initArgs?.tsconfig) {
|
|
2586
2758
|
state.typescriptWanted = true;
|
|
2587
|
-
setupTsconfig(root, state, pagesFramework);
|
|
2759
|
+
packageDependencyRemoved = setupTsconfig(root, state, report, pagesFramework);
|
|
2588
2760
|
}
|
|
2589
2761
|
if (state.typescriptWanted) {
|
|
2590
2762
|
const hasSchema = hasDrizzleSchema(root);
|
|
2591
2763
|
ensureProjectTsconfig(root, void 0, hasSchema, hasSchema);
|
|
2592
2764
|
}
|
|
2593
|
-
ensureGitignore(root);
|
|
2594
|
-
if (!targeted) ensureVoidWorkerCompatibilityDate(root);
|
|
2595
|
-
if (framework) setupWranglerConfig(root, framework);
|
|
2765
|
+
ensureGitignore(root, report);
|
|
2766
|
+
if (!targeted) ensureVoidWorkerCompatibilityDate(root, report);
|
|
2767
|
+
if (framework) setupWranglerConfig(root, framework, report);
|
|
2596
2768
|
if (!hadTypedConfig) migrateFrameworkAdapterPaths(root);
|
|
2597
|
-
if (!targeted && !didScaffoldStarter) applyDatabaseSetup(root, await promptDatabaseSetup(root));
|
|
2598
|
-
await injectAgentBlock(root, newProject);
|
|
2769
|
+
if (!targeted && !didScaffoldStarter) applyDatabaseSetup(root, await promptDatabaseSetup(root), report);
|
|
2770
|
+
await injectAgentBlock(root, newProject, report);
|
|
2599
2771
|
const agents = detectAgents(root);
|
|
2600
2772
|
if (agents.length > 0) {
|
|
2601
|
-
const { linkSkillsForSpecificAgents } = await import("./skills-
|
|
2602
|
-
linkSkillsForSpecificAgents(root, agents);
|
|
2603
|
-
|
|
2773
|
+
const { linkSkillsForSpecificAgents } = await import("./skills-C-csz78e.mjs");
|
|
2774
|
+
const linked = linkSkillsForSpecificAgents(root, agents).map((agent) => agent.displayName);
|
|
2775
|
+
if (linked.length > 0) report.done(`Linked Void skills for ${new Intl.ListFormat("en").format(linked)}`);
|
|
2776
|
+
}
|
|
2604
2777
|
if (!targeted && !framework && !didScaffoldStarter) {
|
|
2605
2778
|
const existingDemoFiles = Object.values(demoFiles(root)).filter((file) => existsSync(file));
|
|
2606
2779
|
if (state.hasRoutes || state.hasMigrations || state.hasPages) log.info("Project already has pages, routes, or migrations, skipping demo");
|
|
@@ -2616,7 +2789,7 @@ async function runInitCommand(root, initArgs) {
|
|
|
2616
2789
|
}
|
|
2617
2790
|
if (scaffold) {
|
|
2618
2791
|
const demoDialect = getDatabaseDialect(readConfig(root));
|
|
2619
|
-
scaffoldDemo(root, demoDialect);
|
|
2792
|
+
scaffoldDemo(root, demoDialect, report);
|
|
2620
2793
|
const voidResolvable = isVoidResolvableFrom(root);
|
|
2621
2794
|
const deferral = resolveWorkspaceDeferral(root, readPackageJson(root));
|
|
2622
2795
|
if (deferral && !voidResolvable) {
|
|
@@ -2639,7 +2812,7 @@ async function runInitCommand(root, initArgs) {
|
|
|
2639
2812
|
let shouldSetupGithub = targeted ? initArgs?.github === true : deploymentPlatform !== "none";
|
|
2640
2813
|
if (shouldSetupGithub && !workspaceSubpackage && deploymentPlatform !== "cloudflare" && deploymentPlatform !== "none") {
|
|
2641
2814
|
if (!voidPlatformDiscovery) {
|
|
2642
|
-
const { getApiUrl } = await import("./auth-
|
|
2815
|
+
const { getApiUrl } = await import("./auth-Boz0lrb3.mjs");
|
|
2643
2816
|
voidPlatformDiscovery = await discoverPlatform(getApiUrl(root));
|
|
2644
2817
|
}
|
|
2645
2818
|
if (!voidPlatformDiscovery.capabilities.githubActions) {
|
|
@@ -2650,31 +2823,49 @@ async function runInitCommand(root, initArgs) {
|
|
|
2650
2823
|
}
|
|
2651
2824
|
}
|
|
2652
2825
|
if (shouldSetupGithub && !workspaceSubpackage) {
|
|
2653
|
-
if (targeted) setupGithubActions(root, state, deploymentPlatform === "cloudflare" ? "cloudflare" : "void", voidPlatformDiscovery?.apiUrl);
|
|
2826
|
+
if (targeted) setupGithubActions(root, state, report, deploymentPlatform === "cloudflare" ? "cloudflare" : "void", voidPlatformDiscovery?.apiUrl);
|
|
2654
2827
|
else {
|
|
2655
2828
|
const setupGha = await confirm({ message: "Create .github/workflows/void-deploy.yml to deploy on pushes to main?" });
|
|
2656
2829
|
if (isCancel(setupGha)) {
|
|
2657
2830
|
cancel("Setup cancelled.");
|
|
2658
2831
|
process.exit(0);
|
|
2659
2832
|
}
|
|
2660
|
-
if (setupGha) setupGithubActions(root, state, deploymentPlatform === "cloudflare" ? "cloudflare" : "void", voidPlatformDiscovery?.apiUrl);
|
|
2833
|
+
if (setupGha) setupGithubActions(root, state, report, deploymentPlatform === "cloudflare" ? "cloudflare" : "void", voidPlatformDiscovery?.apiUrl);
|
|
2661
2834
|
}
|
|
2662
2835
|
} else if (workspaceSubpackage && shouldSetupGithub) log.info("Skipping GitHub Actions setup: workflow files must live at the repo root, not in a workspace subpackage.");
|
|
2663
2836
|
if (!targeted) {
|
|
2664
2837
|
const scaffoldResult = maybeScaffoldEnvTs(root);
|
|
2665
2838
|
if (scaffoldResult.written) {
|
|
2666
2839
|
const rel = relative(root, scaffoldResult.written) || "env.ts";
|
|
2667
|
-
|
|
2668
|
-
|
|
2840
|
+
report.created(rel);
|
|
2841
|
+
report.next(scaffoldResult.entries.length > 0 ? `Review the inferred types in ${rel}` : `Add your environment variables to ${rel} with \`defineEnv({...})\``);
|
|
2669
2842
|
}
|
|
2670
2843
|
}
|
|
2671
|
-
|
|
2672
|
-
|
|
2844
|
+
const migrationMode = workspaceSubpackageSkip ? void 0 : scaffoldedStarterMode;
|
|
2845
|
+
const manualMigration = `${state.packageManager === "pnpm" && projectInstaller(readPackageJson(root), state.packageManager) === "vp" ? process.platform === "win32" ? String.raw`.\node_modules\.bin\void.cmd` : "./node_modules/.bin/void" : projectVoidRunner[state.packageManager]} db generate`;
|
|
2846
|
+
if (scaffoldAddedDependencies) {
|
|
2847
|
+
const install = resolveProjectInstall(root, state.packageManager);
|
|
2848
|
+
const manualInstall = commandInProject(root, install.manualCommand);
|
|
2849
|
+
report.unfinished = migrationMode ? `Run \`${manualInstall}\`, then \`${manualMigration}\` to finish setup` : `Run \`${manualInstall}\` to finish setup`;
|
|
2850
|
+
const duration = await installProjectDependencies(root, install);
|
|
2851
|
+
report.done(`Installed dependencies in ${formatDuration(duration)}`);
|
|
2852
|
+
} else if (packageDependencyRemoved && !workspaceSubpackageSkip) {
|
|
2853
|
+
const installer = projectInstaller(readPackageJson(root), state.packageManager);
|
|
2854
|
+
const manualInstall = commandInProject(root, `${installer} install`);
|
|
2855
|
+
report.next(`Run \`${manualInstall}\` to update your lockfile`);
|
|
2856
|
+
}
|
|
2857
|
+
if (migrationMode) {
|
|
2858
|
+
report.unfinished = `Run \`${commandInProject(root, manualMigration)}\` to finish setup`;
|
|
2859
|
+
await generateStarterMigration(root, migrationMode);
|
|
2860
|
+
report.done("Generated the initial database migration");
|
|
2861
|
+
}
|
|
2862
|
+
report.unfinished = void 0;
|
|
2673
2863
|
if (!targeted && deploymentPlatform === "void") {
|
|
2674
2864
|
const linked = await maybeSetupDeployProject(root);
|
|
2675
|
-
if (linked?.slug) patchWorkflowProjectSlug(root, linked.slug);
|
|
2865
|
+
if (linked?.slug) patchWorkflowProjectSlug(root, linked.slug, report);
|
|
2676
2866
|
}
|
|
2677
|
-
if (gitInitialized)
|
|
2867
|
+
if (gitInitialized) report.next(`Git (optional): ${initialCommitCommand(root)}`);
|
|
2868
|
+
report.print(targeted);
|
|
2678
2869
|
if (workspaceSubpackageSkip) {
|
|
2679
2870
|
if (scaffoldedStarterMode) printSuccess("Project initialized. Run your workspace install, then `void db generate` to finish setup.");
|
|
2680
2871
|
else printSuccess("Project initialized. Run your workspace install to finish setup.");
|