void 0.1.6 → 0.7.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.
Files changed (333) hide show
  1. package/AGENT_PROMPT.md +15 -0
  2. package/README.md +62 -123
  3. package/dist/auth-BdsJ0Aff.d.mts +43 -0
  4. package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
  5. package/dist/auth-migrations-BAtAck2g.mjs +117 -0
  6. package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
  7. package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
  8. package/dist/cache-W82I8ihI.mjs +47 -0
  9. package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
  10. package/dist/cf-access-Dee5cXxL.mjs +22 -0
  11. package/dist/chunk-DJd-R1mw.mjs +34 -0
  12. package/dist/cli/cli.d.mts +1 -0
  13. package/dist/cli/cli.mjs +1807 -0
  14. package/dist/client-snXOjrp1.mjs +565 -0
  15. package/dist/collect-CjeZgz5D.mjs +55 -0
  16. package/dist/config-BIa9HwVX.mjs +573 -0
  17. package/dist/config-BzM9Dy7T.mjs +37 -0
  18. package/dist/config-CvHtTM0q.mjs +30 -0
  19. package/dist/create-project-BIA15W7z.mjs +90 -0
  20. package/dist/db-DsRoMcfN.mjs +895 -0
  21. package/dist/defer-DcxEsVH1.mjs +49 -0
  22. package/dist/delete-DAP6yDc7.mjs +64 -0
  23. package/dist/deploy-BPKblFx6.mjs +2424 -0
  24. package/dist/discover-B7FkXBLB.mjs +40 -0
  25. package/dist/dist-DUyXJLkq.mjs +2667 -0
  26. package/dist/dist-Dayj3gCK.mjs +1287 -0
  27. package/dist/domain-BGofcQ6I.mjs +79 -0
  28. package/dist/dotenv-DwO4ti0Z.mjs +173 -0
  29. package/dist/drizzle-NnudE_UN.mjs +232 -0
  30. package/dist/env-CyG3tvU0.mjs +301 -0
  31. package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
  32. package/dist/env-raw-BDL4TvdN.mjs +32 -0
  33. package/dist/env-types-DknSA4SO.mjs +64 -0
  34. package/dist/env-validation-DJKjR_8q.mjs +163 -0
  35. package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
  36. package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
  37. package/dist/gen-U0Ktr4Zd.mjs +761 -0
  38. package/dist/handler-B0ds0OHJ.d.mts +269 -0
  39. package/dist/head-P-egrtFE.d.mts +45 -0
  40. package/dist/headers-DCXc7mDs.mjs +279 -0
  41. package/dist/index.d.mts +32 -0
  42. package/dist/index.mjs +4695 -0
  43. package/dist/init-C7wS5iGP.mjs +2625 -0
  44. package/dist/link-p2R6NbgN.mjs +49 -0
  45. package/dist/list-Bfel-QLc.mjs +113 -0
  46. package/dist/log-DXdqnmhF.mjs +26 -0
  47. package/dist/login-CkcXUiIu.mjs +72 -0
  48. package/dist/logs-DmkrRvx6.mjs +98 -0
  49. package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
  50. package/dist/mcp-CaQzfeUi.mjs +373 -0
  51. package/dist/node-DDfXj10V.mjs +54 -0
  52. package/dist/output-BwlcIYSR.mjs +139 -0
  53. package/dist/pages/client.d.mts +198 -0
  54. package/dist/pages/client.mjs +980 -0
  55. package/dist/pages/head-client.d.mts +15 -0
  56. package/dist/pages/head-client.mjs +90 -0
  57. package/dist/pages/head.d.mts +2 -0
  58. package/dist/pages/head.mjs +112 -0
  59. package/dist/pages/index.d.mts +38 -0
  60. package/dist/pages/index.mjs +76 -0
  61. package/dist/pages/islands-plugin.d.mts +50 -0
  62. package/dist/pages/islands-plugin.mjs +195 -0
  63. package/dist/pages/prefetch.d.mts +31 -0
  64. package/dist/pages/prefetch.mjs +90 -0
  65. package/dist/pages/protocol.d.mts +3 -0
  66. package/dist/pages/protocol.mjs +193 -0
  67. package/dist/pages/serialize.d.mts +10 -0
  68. package/dist/pages/serialize.mjs +14 -0
  69. package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
  70. package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
  71. package/dist/prepare-BAtWufvm.mjs +99 -0
  72. package/dist/preset-D4I73kT4.mjs +221 -0
  73. package/dist/project-TqORyHn8.mjs +72 -0
  74. package/dist/project-cmd-B7lQp3F3.mjs +67 -0
  75. package/dist/project-slug-CKam8lF9.mjs +11 -0
  76. package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
  77. package/dist/protocol-BWzXs2A2.d.mts +34 -0
  78. package/dist/providers-B3aMxWzP.mjs +67 -0
  79. package/dist/resolve-project-Br5BR03U.mjs +29 -0
  80. package/dist/rollback-gyC59l7U.mjs +92 -0
  81. package/dist/route-types-DReF1gUY.mjs +255 -0
  82. package/dist/routes-stub.d.mts +55 -0
  83. package/dist/routes-stub.mjs +1 -0
  84. package/dist/runner-6Ep3fNQu.mjs +123 -0
  85. package/dist/runner-pg-D0wWHYnr.mjs +57 -0
  86. package/dist/runtime/ai.d.mts +127 -0
  87. package/dist/runtime/ai.mjs +348 -0
  88. package/dist/runtime/auth-client-react.d.mts +8 -0
  89. package/dist/runtime/auth-client-react.mjs +6 -0
  90. package/dist/runtime/auth-client-solid.d.mts +8 -0
  91. package/dist/runtime/auth-client-solid.mjs +6 -0
  92. package/dist/runtime/auth-client-svelte.d.mts +8 -0
  93. package/dist/runtime/auth-client-svelte.mjs +6 -0
  94. package/dist/runtime/auth-client-vue.d.mts +8 -0
  95. package/dist/runtime/auth-client-vue.mjs +6 -0
  96. package/dist/runtime/auth-client.d.mts +8 -0
  97. package/dist/runtime/auth-client.mjs +6 -0
  98. package/dist/runtime/auth.d.mts +2 -0
  99. package/dist/runtime/auth.mjs +22 -0
  100. package/dist/runtime/better-auth-pg.d.mts +11 -0
  101. package/dist/runtime/better-auth-pg.mjs +51 -0
  102. package/dist/runtime/better-auth.d.mts +11 -0
  103. package/dist/runtime/better-auth.mjs +33 -0
  104. package/dist/runtime/client.d.mts +6 -0
  105. package/dist/runtime/client.mjs +5 -0
  106. package/dist/runtime/db-pg.d.mts +2 -0
  107. package/dist/runtime/db-pg.mjs +1 -0
  108. package/dist/runtime/db.d.mts +17 -0
  109. package/dist/runtime/db.mjs +30 -0
  110. package/dist/runtime/drizzle-arktype.d.mts +1 -0
  111. package/dist/runtime/drizzle-arktype.mjs +2 -0
  112. package/dist/runtime/drizzle-valibot.d.mts +1 -0
  113. package/dist/runtime/drizzle-valibot.mjs +2 -0
  114. package/dist/runtime/drizzle-zod.d.mts +1 -0
  115. package/dist/runtime/drizzle-zod.mjs +2 -0
  116. package/dist/runtime/env-helpers.d.mts +2 -0
  117. package/dist/runtime/env-helpers.mjs +173 -0
  118. package/dist/runtime/env-public-client.d.mts +22 -0
  119. package/dist/runtime/env-public-client.mjs +54 -0
  120. package/dist/runtime/env-public.d.mts +143 -0
  121. package/dist/runtime/env-public.mjs +366 -0
  122. package/dist/runtime/env.d.mts +13 -0
  123. package/dist/runtime/env.mjs +51 -0
  124. package/dist/runtime/fetch-stream.d.mts +51 -0
  125. package/dist/runtime/fetch-stream.mjs +81 -0
  126. package/dist/runtime/fetch.d.mts +59 -0
  127. package/dist/runtime/fetch.mjs +18 -0
  128. package/dist/runtime/handler.d.mts +3 -0
  129. package/dist/runtime/handler.mjs +85 -0
  130. package/dist/runtime/isr.d.mts +26 -0
  131. package/dist/runtime/isr.mjs +43 -0
  132. package/dist/runtime/kv.d.mts +48 -0
  133. package/dist/runtime/kv.mjs +106 -0
  134. package/dist/runtime/log.d.mts +24 -0
  135. package/dist/runtime/log.mjs +31 -0
  136. package/dist/runtime/migration-handler-pg.d.mts +6 -0
  137. package/dist/runtime/migration-handler-pg.mjs +85 -0
  138. package/dist/runtime/migration-handler.d.mts +19 -0
  139. package/dist/runtime/migration-handler.mjs +92 -0
  140. package/dist/runtime/queues.d.mts +7 -0
  141. package/dist/runtime/queues.mjs +8 -0
  142. package/dist/runtime/remote/binding-handler.d.mts +15 -0
  143. package/dist/runtime/remote/binding-handler.mjs +208 -0
  144. package/dist/runtime/remote/index.d.mts +8 -0
  145. package/dist/runtime/remote/index.mjs +461 -0
  146. package/dist/runtime/response.d.mts +14 -0
  147. package/dist/runtime/response.mjs +30 -0
  148. package/dist/runtime/sandbox.d.mts +17 -0
  149. package/dist/runtime/sandbox.mjs +19 -0
  150. package/dist/runtime/schema-d1.d.mts +1 -0
  151. package/dist/runtime/schema-d1.mjs +2 -0
  152. package/dist/runtime/schema-pg.d.mts +1 -0
  153. package/dist/runtime/schema-pg.mjs +2 -0
  154. package/dist/runtime/seed.d.mts +30 -0
  155. package/dist/runtime/seed.mjs +6 -0
  156. package/dist/runtime/storage.d.mts +7 -0
  157. package/dist/runtime/storage.mjs +14 -0
  158. package/dist/runtime/validator.d.mts +2 -0
  159. package/dist/runtime/validator.mjs +72 -0
  160. package/dist/runtime/ws-server.d.mts +26 -0
  161. package/dist/runtime/ws-server.mjs +296 -0
  162. package/dist/runtime/ws.d.mts +123 -0
  163. package/dist/runtime/ws.mjs +103 -0
  164. package/dist/scan-Ba4hFwlH.mjs +324 -0
  165. package/dist/scan-C6HMEIdW.mjs +318 -0
  166. package/dist/secret-CeRSukgM.mjs +109 -0
  167. package/dist/skills-ipldjlKE.mjs +62 -0
  168. package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
  169. package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
  170. package/dist/sveltekit.d.mts +20 -0
  171. package/dist/sveltekit.mjs +61 -0
  172. package/dist/types-mHOEwpW4.d.mts +57 -0
  173. package/dist/validate-CaMavMxu.mjs +146 -0
  174. package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
  175. package/getting-started-prompt.txt +26 -0
  176. package/package.json +322 -30
  177. package/schema.json +364 -0
  178. package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
  179. package/skills/void/SKILL.md +75 -0
  180. package/skills/void/command/void.md +7 -0
  181. package/skills/void/docs/guide/ai.md +235 -0
  182. package/skills/void/docs/guide/app-types.md +103 -0
  183. package/skills/void/docs/guide/auth.md +257 -0
  184. package/skills/void/docs/guide/database/d1.md +106 -0
  185. package/skills/void/docs/guide/database/postgresql.md +106 -0
  186. package/skills/void/docs/guide/database.md +418 -0
  187. package/skills/void/docs/guide/deployment.md +98 -0
  188. package/skills/void/docs/guide/edge/headers.md +79 -0
  189. package/skills/void/docs/guide/edge/prerendering.md +83 -0
  190. package/skills/void/docs/guide/edge/redirects.md +116 -0
  191. package/skills/void/docs/guide/edge/revalidation.md +131 -0
  192. package/skills/void/docs/guide/edge/rewrites.md +354 -0
  193. package/skills/void/docs/guide/edge/static-assets.md +72 -0
  194. package/skills/void/docs/guide/env-vars.md +298 -0
  195. package/skills/void/docs/guide/index.md +80 -0
  196. package/skills/void/docs/guide/jobs.md +91 -0
  197. package/skills/void/docs/guide/kv.md +107 -0
  198. package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
  199. package/skills/void/docs/guide/pages-routing/head.md +130 -0
  200. package/skills/void/docs/guide/pages-routing/islands.md +405 -0
  201. package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
  202. package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
  203. package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
  204. package/skills/void/docs/guide/pages-routing/overview.md +236 -0
  205. package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
  206. package/skills/void/docs/guide/queues.md +140 -0
  207. package/skills/void/docs/guide/quickstart.md +233 -0
  208. package/skills/void/docs/guide/remote-dev.md +67 -0
  209. package/skills/void/docs/guide/sandboxes.md +82 -0
  210. package/skills/void/docs/guide/server-routing.md +246 -0
  211. package/skills/void/docs/guide/ssg.md +74 -0
  212. package/skills/void/docs/guide/ssr.md +105 -0
  213. package/skills/void/docs/guide/storage.md +67 -0
  214. package/skills/void/docs/guide/type-safety.md +179 -0
  215. package/skills/void/docs/guide/typed-fetch.md +113 -0
  216. package/skills/void/docs/guide/websockets.md +190 -0
  217. package/skills/void/docs/index.md +48 -0
  218. package/skills/void/docs/integrations/agents.md +84 -0
  219. package/skills/void/docs/integrations/cloudflare.md +284 -0
  220. package/skills/void/docs/integrations/frameworks/analog.md +182 -0
  221. package/skills/void/docs/integrations/frameworks/astro.md +197 -0
  222. package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
  223. package/skills/void/docs/integrations/frameworks/overview.md +136 -0
  224. package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
  225. package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
  226. package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
  227. package/skills/void/docs/integrations/hono.md +97 -0
  228. package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
  229. package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
  230. package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
  231. package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
  232. package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
  233. package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
  234. package/skills/void/docs/node_modules/vitepress/README.md +28 -0
  235. package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
  236. package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
  237. package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
  238. package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
  239. package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
  240. package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
  241. package/skills/void/docs/node_modules/void/README.md +89 -0
  242. package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
  243. package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
  244. package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
  245. package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
  246. package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
  247. package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
  248. package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
  249. package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
  250. package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
  251. package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
  252. package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
  253. package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
  254. package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
  255. package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
  256. package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
  257. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
  258. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
  259. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
  260. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
  261. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
  262. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
  263. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
  264. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
  265. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
  266. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
  267. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
  268. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
  269. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
  270. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
  271. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
  272. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
  273. package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
  274. package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
  275. package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
  276. package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
  277. package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
  278. package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
  279. package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
  280. package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
  281. package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
  282. package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
  283. package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
  284. package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
  285. package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
  286. package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
  287. package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
  288. package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  289. package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
  290. package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
  291. package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
  292. package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
  293. package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
  294. package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
  295. package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
  296. package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
  297. package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
  298. package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
  299. package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
  300. package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
  301. package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
  302. package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
  303. package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
  304. package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
  305. package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
  306. package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
  307. package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
  308. package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
  309. package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
  310. package/skills/void/docs/reference/api.md +917 -0
  311. package/skills/void/docs/reference/cli.md +561 -0
  312. package/skills/void/docs/reference/config.md +408 -0
  313. package/skills/void/docs/reference/resource-inference.md +149 -0
  314. package/skills/void/docs/reference/structure.md +176 -0
  315. package/.npmignore +0 -29
  316. package/.travis.yml +0 -9
  317. package/favicon.ico +0 -0
  318. package/index.js +0 -14
  319. package/lib/Job.js +0 -150
  320. package/lib/Void.js +0 -99
  321. package/lib/scan.js +0 -19
  322. package/test/credentials.js +0 -20
  323. package/test/job.js +0 -64
  324. package/test/static/dir1/test6.html +0 -0
  325. package/test/static/dir2/test7.html +0 -0
  326. package/test/static/dir2/test8.html +0 -0
  327. package/test/static/dir2/test9.html +0 -0
  328. package/test/static/test1.html +0 -0
  329. package/test/static/test2.html +0 -0
  330. package/test/static/test3.html +0 -0
  331. package/test/void.js +0 -31
  332. /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
  333. /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
@@ -0,0 +1,895 @@
1
+ import { a as join, o as relative, r as extname, s as resolve } from "./pathe.M-eThtNZ-D-kmWkCS.mjs";
2
+ import { i as dim, n as cliTitle, s as import_picocolors } from "./output-BwlcIYSR.mjs";
3
+ import { c as R, g as ge, y as ye } from "./dist-Dayj3gCK.mjs";
4
+ import { r as readProjectConfig } from "./project-TqORyHn8.mjs";
5
+ import { n as PlatformClient, s as getToken } from "./client-snXOjrp1.mjs";
6
+ import { c as getDatabaseDialect, f as readConfig } from "./config-BIa9HwVX.mjs";
7
+ import { n as detectFramework } from "./plugin-inference-oZ6Ybu2_.mjs";
8
+ import { a as writeJournal, i as stripSqlExt, r as readJournal, t as collectMigrations } from "./collect-CjeZgz5D.mjs";
9
+ import { n as listDrizzleArtifacts, r as validateMigrations, t as assertJournalCoherence } from "./validate-CaMavMxu.mjs";
10
+ import { formatTimestamp } from "./gen-U0Ktr4Zd.mjs";
11
+ import { existsSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
12
+ import { fileURLToPath, pathToFileURL } from "node:url";
13
+ import { execFileSync } from "node:child_process";
14
+ //#region src/cli/db.ts
15
+ const drizzleKitBin = join(fileURLToPath(import.meta.resolve("drizzle-kit")), "..", "bin.cjs");
16
+ const DEFAULT_SEED_FILES = [
17
+ "db/seed.ts",
18
+ "db/seed.mts",
19
+ "db/seed.js",
20
+ "db/seed.mjs",
21
+ "db/seed.sql"
22
+ ];
23
+ const MODULE_SEED_EXTENSIONS = new Set([
24
+ ".ts",
25
+ ".mts",
26
+ ".js",
27
+ ".mjs"
28
+ ]);
29
+ function getLocalD1PersistRoot(root) {
30
+ const detected = detectFramework(root);
31
+ return detected && (detected.class === "b" || detected.class === "c") ? join(root, ".wrangler", "state") : join(root, ".void");
32
+ }
33
+ function runDrizzleKit(root, args) {
34
+ execFileSync(process.execPath, [drizzleKitBin, ...args], {
35
+ cwd: root,
36
+ stdio: "inherit"
37
+ });
38
+ }
39
+ function getErrorMessage(error) {
40
+ return error instanceof Error ? error.message : String(error);
41
+ }
42
+ function readEnvLocal(root) {
43
+ const envPath = join(root, ".env.local");
44
+ if (!existsSync(envPath)) return {};
45
+ const content = readFileSync(envPath, "utf-8");
46
+ const vars = {};
47
+ for (const line of content.split("\n")) {
48
+ const trimmed = line.trim();
49
+ if (!trimmed || trimmed.startsWith("#")) continue;
50
+ const eqIndex = trimmed.indexOf("=");
51
+ if (eqIndex === -1) continue;
52
+ const key = trimmed.slice(0, eqIndex).trim();
53
+ let value = trimmed.slice(eqIndex + 1).trim();
54
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
55
+ vars[key] = value;
56
+ }
57
+ return vars;
58
+ }
59
+ function getPgUrl(root) {
60
+ const url = readEnvLocal(root).DATABASE_URL;
61
+ if (!url) throw new Error("DATABASE_URL not found in .env.local. Add it to connect to your PostgreSQL database.");
62
+ return url;
63
+ }
64
+ async function withPgClient(root, fn) {
65
+ const url = getPgUrl(root);
66
+ const { Client } = await import("pg");
67
+ const client = new Client({ connectionString: url });
68
+ await client.connect();
69
+ try {
70
+ return await fn(client);
71
+ } finally {
72
+ await client.end();
73
+ }
74
+ }
75
+ function validatePendingMigrations(migrations, appliedNames) {
76
+ const pending = migrations.filter((migration) => !appliedNames.has(migration.name));
77
+ if (pending.length === 0) return;
78
+ validateMigrations(pending);
79
+ }
80
+ async function runDbCommand(root, args) {
81
+ console.log();
82
+ ge(cliTitle("db"));
83
+ const dialect = getDatabaseDialect(readConfig(root));
84
+ if (args.action === "push") await runPush(root, dialect);
85
+ else if (args.action === "generate") await runGenerate(root, dialect);
86
+ else if (args.action === "status") await runStatus(root, dialect);
87
+ else if (args.action === "reset") await runReset(root, dialect);
88
+ else if (args.action === "seed") await runSeed(root, args.file, dialect);
89
+ else if (args.action === "execute") await runExecute(root, args.command, args.file, dialect);
90
+ else if (args.action === "migrate") await runMigrate(root, dialect, args.remote);
91
+ else if (args.action === "studio") await runStudio(root, dialect);
92
+ else if (args.action === "set-url") await runSetUrl(root);
93
+ else if (args.action === "rename-migrations") await runRenameMigrations(root, dialect);
94
+ else await runExport(root, args, dialect);
95
+ }
96
+ async function runPush(root, dialect) {
97
+ const { writeDrizzleConfig } = await import("./config-BzM9Dy7T.mjs").then((n) => n.t);
98
+ let configPath;
99
+ if (dialect === "postgresql") configPath = writeDrizzleConfig(root, getPgUrl(root), "postgresql");
100
+ else {
101
+ const { mkdirSync } = await import("node:fs");
102
+ const { dirname } = await import("node:path");
103
+ const { getMiniflareDatabasePath } = await import("./runner-6Ep3fNQu.mjs");
104
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
105
+ mkdirSync(dirname(dbPath), { recursive: true });
106
+ configPath = writeDrizzleConfig(root, dbPath);
107
+ }
108
+ try {
109
+ runDrizzleKit(root, [
110
+ "push",
111
+ "--config",
112
+ configPath
113
+ ]);
114
+ } catch {
115
+ process.exit(1);
116
+ }
117
+ ye("Done.");
118
+ }
119
+ async function runGenerate(root, dialect) {
120
+ const { writeDrizzleConfig } = await import("./config-BzM9Dy7T.mjs").then((n) => n.t);
121
+ const configPath = dialect === "postgresql" ? writeDrizzleConfig(root, "postgresql://dummy", "postgresql") : writeDrizzleConfig(root, ":memory:");
122
+ try {
123
+ runDrizzleKit(root, [
124
+ "generate",
125
+ "--config",
126
+ configPath
127
+ ]);
128
+ } catch {
129
+ process.exit(1);
130
+ }
131
+ ye("Done.");
132
+ }
133
+ async function runStatus(root, dialect) {
134
+ const migrationsDir = join(root, "db", "migrations");
135
+ const allMigrations = collectMigrations(migrationsDir);
136
+ try {
137
+ assertJournalCoherence(migrationsDir, allMigrations);
138
+ } catch (err) {
139
+ R.error(getErrorMessage(err));
140
+ process.exit(1);
141
+ }
142
+ if (allMigrations.length === 0) {
143
+ R.info("No migration files found in db/migrations/");
144
+ ye("Done.");
145
+ return;
146
+ }
147
+ let localApplied;
148
+ if (dialect === "postgresql") try {
149
+ localApplied = await withPgClient(root, async (client) => {
150
+ try {
151
+ return (await client.query("SELECT name FROM _void_migrations ORDER BY name")).rows;
152
+ } catch {
153
+ return [];
154
+ }
155
+ });
156
+ } catch {
157
+ localApplied = [];
158
+ }
159
+ else {
160
+ const { getMiniflareDatabasePath, getAppliedMigrations } = await import("./runner-6Ep3fNQu.mjs");
161
+ localApplied = await getAppliedMigrations(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
162
+ }
163
+ const localSet = new Set(localApplied.map((m) => m.name));
164
+ let remoteApplied = null;
165
+ const token = getToken(root);
166
+ const config = readProjectConfig(root);
167
+ if (token && config) try {
168
+ remoteApplied = (await new PlatformClient(token, { root }).getMigrationStatus(config.projectId)).applied;
169
+ } catch {}
170
+ const remoteSet = remoteApplied ? new Set(remoteApplied.map((m) => m.name)) : null;
171
+ const lines = [];
172
+ for (const migration of allMigrations) {
173
+ const localStatus = localSet.has(migration.name) ? import_picocolors.default.green("applied") : import_picocolors.default.yellow("pending");
174
+ let remotePart = "";
175
+ if (remoteSet !== null) remotePart = ` remote: ${remoteSet.has(migration.name) ? import_picocolors.default.green("applied") : import_picocolors.default.yellow("pending")}`;
176
+ lines.push(` ${migration.name} ${dim("local:")} ${localStatus}${remotePart}`);
177
+ }
178
+ R.info(lines.join("\n"));
179
+ const localPending = allMigrations.length - localSet.size;
180
+ const parts = [`${allMigrations.length} migration(s)`];
181
+ if (localPending > 0) parts.push(`${localPending} pending locally`);
182
+ if (remoteSet !== null) {
183
+ const remotePending = allMigrations.length - remoteSet.size;
184
+ if (remotePending > 0) parts.push(`${remotePending} pending remotely`);
185
+ }
186
+ ye(parts.join(", "));
187
+ }
188
+ async function resetDatabase(root, dialect) {
189
+ const migrationsDir = join(root, "db", "migrations");
190
+ const migrations = collectMigrations(migrationsDir);
191
+ try {
192
+ assertJournalCoherence(migrationsDir, migrations);
193
+ } catch (err) {
194
+ R.error(getErrorMessage(err));
195
+ process.exit(1);
196
+ }
197
+ if (dialect === "postgresql") {
198
+ await withPgClient(root, async (client) => {
199
+ const tables = await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
200
+ for (const row of tables.rows) await client.query(`DROP TABLE IF EXISTS "${row.tablename}" CASCADE`);
201
+ });
202
+ if (migrations.length > 0) await withPgClient(root, async (client) => {
203
+ await client.query(`CREATE TABLE IF NOT EXISTS _void_migrations (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL)`);
204
+ for (const m of migrations) {
205
+ await client.query("BEGIN");
206
+ try {
207
+ await client.query(m.sql);
208
+ await client.query("INSERT INTO _void_migrations (name, applied_at) VALUES ($1, $2)", [m.name, (/* @__PURE__ */ new Date()).toISOString()]);
209
+ await client.query("COMMIT");
210
+ } catch (err) {
211
+ await client.query("ROLLBACK");
212
+ throw err;
213
+ }
214
+ }
215
+ });
216
+ return migrations.length;
217
+ }
218
+ const { getMiniflareDatabasePath, runMigrations } = await import("./runner-6Ep3fNQu.mjs");
219
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
220
+ rmSync(dbPath, { force: true });
221
+ rmSync(dbPath + "-wal", { force: true });
222
+ rmSync(dbPath + "-shm", { force: true });
223
+ return (await runMigrations(migrationsDir, dbPath)).length;
224
+ }
225
+ async function runReset(root, dialect) {
226
+ const count = await resetDatabase(root, dialect);
227
+ R.success(`Database reset. Applied ${count} migration(s).`);
228
+ if (dialect !== "postgresql") R.info(dim("Restart your dev server if it's running."));
229
+ ye("Done.");
230
+ }
231
+ async function runSeed(root, file, dialect) {
232
+ const migrationCount = await resetDatabase(root, dialect);
233
+ R.step(`Reset database. Applied ${migrationCount} migration(s).`);
234
+ const seed = resolveSeedTarget(root, file);
235
+ if (seed.kind === "sql") {
236
+ const sql = readFileSync(seed.path, "utf-8");
237
+ if (dialect === "postgresql") {
238
+ await withPgClient(root, async (client) => {
239
+ await client.query(sql);
240
+ });
241
+ R.success(`Seeded from ${seed.displayPath}.`);
242
+ ye("Done.");
243
+ return;
244
+ }
245
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-6Ep3fNQu.mjs");
246
+ const db = await openSqliteDatabase(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
247
+ try {
248
+ db.exec(sql);
249
+ } finally {
250
+ db.close();
251
+ }
252
+ } else await runSeedModule(root, seed.path, dialect);
253
+ R.success(`Seeded from ${seed.displayPath}.`);
254
+ R.info(dim("Restart your dev server if it's running."));
255
+ ye("Done.");
256
+ }
257
+ async function runExecute(root, command, file, dialect) {
258
+ if (dialect === "postgresql") {
259
+ const sql = file ? readFileSync(join(root, file), "utf-8") : command;
260
+ await withPgClient(root, async (client) => {
261
+ const result = await client.query(sql);
262
+ if (result.rows && result.rows.length > 0) printTable(result.rows);
263
+ else R.success("Executed successfully.");
264
+ });
265
+ ye("Done.");
266
+ return;
267
+ }
268
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-6Ep3fNQu.mjs");
269
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
270
+ if (!existsSync(dbPath)) {
271
+ R.error("No local database found. Run `void dev` first.");
272
+ process.exit(1);
273
+ }
274
+ const sql = file ? readFileSync(join(root, file), "utf-8") : command;
275
+ const db = await openSqliteDatabase(dbPath);
276
+ try {
277
+ const trimmed = sql.trimStart();
278
+ if (/^SELECT\b/i.test(trimmed)) {
279
+ const rows = db.prepare(sql).all();
280
+ if (rows.length === 0) R.info("No rows returned.");
281
+ else printTable(rows);
282
+ } else {
283
+ db.exec(sql);
284
+ R.success("Executed successfully.");
285
+ }
286
+ } finally {
287
+ db.close();
288
+ }
289
+ ye("Done.");
290
+ }
291
+ function printTable(rows) {
292
+ const cols = Object.keys(rows[0]);
293
+ const widths = cols.map((col) => {
294
+ let max = col.length;
295
+ for (const row of rows) {
296
+ const len = String(row[col] ?? "NULL").length;
297
+ if (len > max) max = len;
298
+ }
299
+ return max;
300
+ });
301
+ const lines = [cols.map((col, i) => col.padEnd(widths[i])).join(" "), widths.map((w) => "─".repeat(w)).join("──")];
302
+ for (const row of rows) lines.push(cols.map((col, i) => String(row[col] ?? "NULL").padEnd(widths[i])).join(" "));
303
+ console.log(lines.join("\n"));
304
+ }
305
+ async function runMigrate(root, dialect, remote) {
306
+ const migrationsDir = join(root, "db", "migrations");
307
+ const rawMigrations = collectMigrations(migrationsDir);
308
+ try {
309
+ assertJournalCoherence(migrationsDir, rawMigrations);
310
+ } catch (err) {
311
+ R.error(getErrorMessage(err));
312
+ process.exit(1);
313
+ }
314
+ if (remote) {
315
+ const token = getToken(root);
316
+ if (!token) {
317
+ R.error("Not logged in. Run `void auth login` first.");
318
+ process.exit(1);
319
+ }
320
+ const config = readProjectConfig(root);
321
+ if (!config) {
322
+ R.error("No project linked. Run `void deploy` first or link a project.");
323
+ process.exit(1);
324
+ }
325
+ if (rawMigrations.length === 0) {
326
+ R.info("No migration files found in db/migrations/");
327
+ ye("Done.");
328
+ return;
329
+ }
330
+ const client = new PlatformClient(token, { root });
331
+ let remoteApplied;
332
+ try {
333
+ const status = await client.getMigrationStatus(config.projectId);
334
+ remoteApplied = new Set(status.applied.map((m) => m.name));
335
+ } catch (err) {
336
+ R.error(`db: Failed to fetch remote migration status: '${err instanceof Error ? err.message : String(err)}'.`);
337
+ process.exit(1);
338
+ }
339
+ const pendingMigrations = rawMigrations.filter((m) => !remoteApplied.has(m.name));
340
+ if (pendingMigrations.length === 0) {
341
+ R.info("Remote database is up to date.");
342
+ ye("Done.");
343
+ return;
344
+ }
345
+ try {
346
+ validateMigrations(pendingMigrations);
347
+ } catch (err) {
348
+ R.error(getErrorMessage(err));
349
+ process.exit(1);
350
+ }
351
+ const result = await client.applyRemoteMigrations(config.projectId, pendingMigrations);
352
+ if (!result.ok) {
353
+ R.error(result.error ? `db: Remote migration failed: '${result.error}'.` : "db: Remote migration failed.");
354
+ process.exit(1);
355
+ }
356
+ if (result.applied.length === 0) R.info("Remote database is up to date.");
357
+ else {
358
+ for (const name of result.applied) R.step(name);
359
+ R.success(`Applied ${result.applied.length} migration(s) to remote database.`);
360
+ }
361
+ ye("Done.");
362
+ return;
363
+ }
364
+ if (dialect === "postgresql") {
365
+ const { applyPgMigrations } = await import("./runner-pg-D0wWHYnr.mjs");
366
+ const applied = await withPgClient(root, async (client) => {
367
+ let existingRows = [];
368
+ try {
369
+ existingRows = (await client.query("SELECT name FROM _void_migrations")).rows;
370
+ } catch {
371
+ existingRows = [];
372
+ }
373
+ try {
374
+ validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
375
+ } catch (err) {
376
+ R.error(getErrorMessage(err));
377
+ process.exit(1);
378
+ }
379
+ return applyPgMigrations(client, rawMigrations);
380
+ });
381
+ if (applied.length === 0) R.info("All migrations are up to date.");
382
+ else {
383
+ for (const name of applied) R.step(name);
384
+ R.success(`Applied ${applied.length} migration(s).`);
385
+ }
386
+ ye("Done.");
387
+ return;
388
+ }
389
+ const { getMiniflareDatabasePath, getAppliedMigrations, runMigrations } = await import("./runner-6Ep3fNQu.mjs");
390
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
391
+ try {
392
+ const existingRows = await getAppliedMigrations(dbPath);
393
+ validatePendingMigrations(rawMigrations, new Set(existingRows.map((row) => row.name)));
394
+ } catch (err) {
395
+ R.error(getErrorMessage(err));
396
+ process.exit(1);
397
+ }
398
+ const applied = await runMigrations(migrationsDir, dbPath);
399
+ if (applied.length === 0) R.info("All migrations are up to date.");
400
+ else {
401
+ for (const name of applied) R.step(name);
402
+ R.success(`Applied ${applied.length} migration(s).`);
403
+ R.info(dim("Restart your dev server if it's running."));
404
+ }
405
+ ye("Done.");
406
+ }
407
+ async function runStudio(root, dialect) {
408
+ if (dialect === "postgresql") {
409
+ const { writeDrizzleConfig } = await import("./config-BzM9Dy7T.mjs").then((n) => n.t);
410
+ const configPath = writeDrizzleConfig(root, getPgUrl(root), "postgresql");
411
+ R.info("Opening Drizzle Studio...");
412
+ try {
413
+ runDrizzleKit(root, [
414
+ "studio",
415
+ "--config",
416
+ configPath
417
+ ]);
418
+ } catch {
419
+ process.exit(1);
420
+ }
421
+ return;
422
+ }
423
+ const { writeDrizzleConfig } = await import("./config-BzM9Dy7T.mjs").then((n) => n.t);
424
+ const { getMiniflareDatabasePath } = await import("./runner-6Ep3fNQu.mjs");
425
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
426
+ if (!existsSync(dbPath)) {
427
+ R.error("No local database found. Run `void dev` first.");
428
+ process.exit(1);
429
+ }
430
+ const configPath = writeDrizzleConfig(root, dbPath);
431
+ R.info("Opening Drizzle Studio...");
432
+ try {
433
+ runDrizzleKit(root, [
434
+ "studio",
435
+ "--config",
436
+ configPath
437
+ ]);
438
+ } catch {
439
+ process.exit(1);
440
+ }
441
+ }
442
+ async function runRenameMigrations(root, dialect) {
443
+ const migrationsDir = join(root, "db", "migrations");
444
+ if (!existsSync(migrationsDir)) {
445
+ R.info("No migrations directory found.");
446
+ ye("Done.");
447
+ return;
448
+ }
449
+ const currentMigrations = collectMigrations(migrationsDir);
450
+ try {
451
+ assertJournalCoherence(migrationsDir, currentMigrations);
452
+ } catch (err) {
453
+ R.error(getErrorMessage(err));
454
+ process.exit(1);
455
+ }
456
+ if (existsSync(join(migrationsDir, "migrations.js"))) {
457
+ R.error("This project uses Drizzle's bundled migration format (db/migrations/migrations.js).\n`void db rename-migrations` cannot rename migrations in bundled mode because\n`migrations.js` contains static imports of the SQL files by filename.\n\nDelete db/migrations/migrations.js and re-run `void db generate` to migrate away\nfrom bundled mode, then retry `void db rename-migrations`.");
458
+ process.exit(1);
459
+ }
460
+ const files = readdirSync(migrationsDir).filter((f) => f.endsWith(".sql") && f !== "seed.sql").sort();
461
+ const oldStyleFiles = files.filter((f) => /^\d{1,4}_/.test(f));
462
+ if (oldStyleFiles.length === 0) {
463
+ R.info("No migrations with numeric prefixes found. Nothing to rename.");
464
+ ye("Done.");
465
+ return;
466
+ }
467
+ const timestampFiles = files.filter((f) => /^\d{14}_/.test(f));
468
+ const formatTs = formatTimestamp;
469
+ let baseTime;
470
+ if (timestampFiles.length > 0) {
471
+ const earliest = timestampFiles[0].slice(0, 14);
472
+ const y = +earliest.slice(0, 4), mo = +earliest.slice(4, 6) - 1, d = +earliest.slice(6, 8);
473
+ const h = +earliest.slice(8, 10), mi = +earliest.slice(10, 12), s = +earliest.slice(12, 14);
474
+ baseTime = new Date(Date.UTC(y, mo, d, h, mi, s - oldStyleFiles.length));
475
+ } else baseTime = /* @__PURE__ */ new Date(Date.now() - oldStyleFiles.length * 1e3);
476
+ const renames = [];
477
+ for (let i = 0; i < oldStyleFiles.length; i++) {
478
+ const oldName = oldStyleFiles[i];
479
+ const description = oldName.replace(/^\d+_/, "");
480
+ const newName = `${formatTs(new Date(baseTime.getTime() + i * 1e3))}_${description}`;
481
+ renames.push({
482
+ from: oldName,
483
+ to: newName
484
+ });
485
+ }
486
+ const journalPath = join(migrationsDir, "meta", "_journal.json");
487
+ const originalJournalBytes = existsSync(journalPath) ? readFileSync(journalPath) : null;
488
+ const metaDir = join(migrationsDir, "meta");
489
+ const snapshotPrefix = (tag) => tag.split("_")[0];
490
+ const snapshotPathFor = (tag) => join(metaDir, `${snapshotPrefix(tag)}_snapshot.json`);
491
+ const preRenameJournal = readJournal(migrationsDir);
492
+ const drizzleArtifacts = listDrizzleArtifacts(migrationsDir);
493
+ const isBareLegacyPlaceholder = preRenameJournal !== void 0 && preRenameJournal !== null && typeof preRenameJournal === "object" && Array.isArray(preRenameJournal.entries) && preRenameJournal.entries.length === 0 && drizzleArtifacts.length === 0;
494
+ if (originalJournalBytes !== null && !isBareLegacyPlaceholder) {
495
+ const missingSnapshots = [];
496
+ for (const { from } of renames) {
497
+ const fromTag = stripSqlExt(from);
498
+ if (!existsSync(snapshotPathFor(fromTag))) missingSnapshots.push(`meta/${snapshotPrefix(fromTag)}_snapshot.json`);
499
+ }
500
+ if (missingSnapshots.length > 0) {
501
+ R.error("db: Cannot rename migrations because one or more Drizzle snapshot files are missing:");
502
+ for (const p of missingSnapshots) R.error(` - db/migrations/${p}`);
503
+ R.error("\nRestore the missing snapshot(s) from version control, or reset the migration directory with `void db generate`, then retry.");
504
+ process.exit(1);
505
+ }
506
+ }
507
+ const token = getToken(root);
508
+ const config = readProjectConfig(root);
509
+ let remoteRenamed = false;
510
+ if (config && !token) {
511
+ R.error("Project is linked but you are not logged in.\nRun `void auth login` first so remote migration records can be updated.");
512
+ process.exit(1);
513
+ }
514
+ if (token && config) try {
515
+ await new PlatformClient(token, { root }).renameMigrations(config.projectId, renames);
516
+ remoteRenamed = true;
517
+ R.info("Remote migration records updated.");
518
+ } catch (err) {
519
+ R.error("db: Failed to update remote migration records. No local changes were made.\nFix the connection and run `void db rename-migrations` again.");
520
+ R.error(String(err));
521
+ process.exit(1);
522
+ }
523
+ const reverseRemote = async () => {
524
+ if (!remoteRenamed || !token || !config) return;
525
+ try {
526
+ const client = new PlatformClient(token, { root });
527
+ const reversed = renames.map(({ from, to }) => ({
528
+ from: to,
529
+ to: from
530
+ }));
531
+ await client.renameMigrations(config.projectId, reversed);
532
+ } catch {
533
+ R.warn("db: Could not reverse remote rename. Run `void deploy` to sync remote records.");
534
+ }
535
+ };
536
+ let journalRewritten = false;
537
+ const restoreJournal = () => {
538
+ if (!journalRewritten || originalJournalBytes === null) return;
539
+ try {
540
+ writeFileSync(journalPath, originalJournalBytes);
541
+ } catch (err) {
542
+ R.warn("Could not restore db/migrations/meta/_journal.json after rollback. The journal may be in a partial state.\nRegenerate it with `void db generate`, or restore it from version control.");
543
+ R.warn(String(err));
544
+ }
545
+ };
546
+ const renamed = [];
547
+ const renamedSnapshots = [];
548
+ const reverseSnapshotRenames = () => {
549
+ for (const { from, to } of renamedSnapshots) try {
550
+ renameSync(to, from);
551
+ } catch (err) {
552
+ R.warn(`db: Could not reverse snapshot rename for '${from}'. The meta/ directory may be in a partial state.`);
553
+ R.warn(String(err));
554
+ }
555
+ };
556
+ try {
557
+ for (const { from, to } of renames) {
558
+ renameSync(join(migrationsDir, from), join(migrationsDir, to));
559
+ renamed.push({
560
+ from,
561
+ to
562
+ });
563
+ R.step(`${from} → ${to}`);
564
+ const fromTag = stripSqlExt(from);
565
+ const toTag = stripSqlExt(to);
566
+ const snapshotFrom = snapshotPathFor(fromTag);
567
+ const snapshotTo = snapshotPathFor(toTag);
568
+ if (existsSync(snapshotFrom)) {
569
+ renameSync(snapshotFrom, snapshotTo);
570
+ renamedSnapshots.push({
571
+ from: snapshotFrom,
572
+ to: snapshotTo
573
+ });
574
+ }
575
+ }
576
+ } catch (err) {
577
+ reverseSnapshotRenames();
578
+ for (const { from, to } of renamed) try {
579
+ renameSync(join(migrationsDir, to), join(migrationsDir, from));
580
+ } catch {}
581
+ restoreJournal();
582
+ await reverseRemote();
583
+ R.error("db: Failed to rename migration files. All changes have been reverted.");
584
+ R.error(String(err));
585
+ process.exit(1);
586
+ }
587
+ if (originalJournalBytes !== null) try {
588
+ const journal = readJournal(migrationsDir);
589
+ if (!journal) throw new Error("db: db/migrations/meta/_journal.json disappeared mid-run. File renames will be reverted.");
590
+ const renameMap = /* @__PURE__ */ new Map();
591
+ for (const { from, to } of renames) renameMap.set(stripSqlExt(from), stripSqlExt(to));
592
+ const updatedEntries = journal.entries.map((entry) => {
593
+ const next = renameMap.get(entry.tag);
594
+ return next ? {
595
+ ...entry,
596
+ tag: next
597
+ } : entry;
598
+ });
599
+ journalRewritten = true;
600
+ writeJournal(migrationsDir, {
601
+ version: journal.version,
602
+ dialect: journal.dialect,
603
+ entries: updatedEntries
604
+ });
605
+ } catch (err) {
606
+ reverseSnapshotRenames();
607
+ for (const { from, to } of renames) try {
608
+ renameSync(join(migrationsDir, to), join(migrationsDir, from));
609
+ } catch {}
610
+ restoreJournal();
611
+ await reverseRemote();
612
+ R.error("db: Failed to update db/migrations/meta/_journal.json. File renames have been reverted.");
613
+ R.error(String(err));
614
+ process.exit(1);
615
+ }
616
+ if (dialect === "postgresql") try {
617
+ await withPgClient(root, async (client) => {
618
+ if ((await client.query(`SELECT 1 FROM information_schema.tables WHERE table_name = '_void_migrations' LIMIT 1`)).rows.length === 0) return;
619
+ await client.query("BEGIN");
620
+ try {
621
+ for (const { from, to } of renames) await client.query("UPDATE _void_migrations SET name = $1 WHERE name = $2", [to, from]);
622
+ await client.query("COMMIT");
623
+ } catch (err) {
624
+ await client.query("ROLLBACK");
625
+ throw err;
626
+ }
627
+ });
628
+ } catch (err) {
629
+ reverseSnapshotRenames();
630
+ for (const { from, to } of renames) try {
631
+ renameSync(join(migrationsDir, to), join(migrationsDir, from));
632
+ } catch {}
633
+ restoreJournal();
634
+ await reverseRemote();
635
+ R.error("db: Failed to update PostgreSQL tracking table. File renames have been reverted.\nFix the database connection and run `void db rename-migrations` again.");
636
+ R.error(String(err));
637
+ process.exit(1);
638
+ }
639
+ else {
640
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-6Ep3fNQu.mjs");
641
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
642
+ if (existsSync(dbPath)) try {
643
+ const db = await openSqliteDatabase(dbPath);
644
+ try {
645
+ const hasNew = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='_void_migrations'").get();
646
+ const hasLegacy = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='_migrations'").get();
647
+ const tableName = hasNew ? "_void_migrations" : hasLegacy ? "_migrations" : null;
648
+ if (tableName) {
649
+ const updateStmt = db.prepare(`UPDATE ${tableName} SET name = ? WHERE name = ?`);
650
+ db.transaction(() => {
651
+ for (const { from, to } of renames) updateStmt.run(to, from);
652
+ })();
653
+ }
654
+ } finally {
655
+ db.close();
656
+ }
657
+ } catch (err) {
658
+ reverseSnapshotRenames();
659
+ for (const { from, to } of renames) try {
660
+ renameSync(join(migrationsDir, to), join(migrationsDir, from));
661
+ } catch {}
662
+ restoreJournal();
663
+ await reverseRemote();
664
+ R.error("db: Failed to update SQLite tracking table. File renames have been reverted.\nFix the database issue and run `void db rename-migrations` again.");
665
+ R.error(String(err));
666
+ process.exit(1);
667
+ }
668
+ }
669
+ R.success(`Renamed ${renames.length} migration(s) to timestamp format.`);
670
+ ye("Done.");
671
+ }
672
+ async function runExport(root, args, dialect) {
673
+ if (dialect === "postgresql") {
674
+ const parts = [];
675
+ await withPgClient(root, async (client) => {
676
+ let tables;
677
+ if (args.table) {
678
+ if ((await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename = $1", [args.table])).rows.length === 0) {
679
+ R.error(`db: Table '${args.table}' not found.`);
680
+ process.exit(1);
681
+ }
682
+ tables = [args.table];
683
+ } else tables = (await client.query("SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename NOT LIKE '\\_%' ORDER BY tablename")).rows.map((row) => String(row.tablename));
684
+ for (const table of tables) {
685
+ if (!args.noSchema) {
686
+ const colDefs = (await client.query(`SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_name = $1 AND table_schema = 'public' ORDER BY ordinal_position`, [table])).rows.map((column) => {
687
+ let def = ` "${String(column.column_name)}" ${String(column.data_type)}`;
688
+ if (column.is_nullable === "NO") def += " NOT NULL";
689
+ if (column.column_default) def += ` DEFAULT ${String(column.column_default)}`;
690
+ return def;
691
+ });
692
+ parts.push(`CREATE TABLE "${table}" (\n${colDefs.join(",\n")}\n);`);
693
+ }
694
+ if (!args.noData) {
695
+ const rows = await client.query(`SELECT * FROM "${table}"`);
696
+ for (const row of rows.rows) {
697
+ const cols = Object.keys(row);
698
+ const vals = cols.map((c) => {
699
+ const v = row[c];
700
+ if (v === null) return "NULL";
701
+ if (typeof v === "number") return String(v);
702
+ return `'${String(v).replace(/'/g, "''")}'`;
703
+ });
704
+ parts.push(`INSERT INTO "${table}" (${cols.join(", ")}) VALUES (${vals.join(", ")});`);
705
+ }
706
+ }
707
+ parts.push("");
708
+ }
709
+ });
710
+ const output = parts.join("\n");
711
+ if (args.output) {
712
+ writeFileSync(join(root, args.output), output);
713
+ R.success(`Exported to ${args.output}`);
714
+ ye("Done.");
715
+ } else process.stdout.write(output);
716
+ return;
717
+ }
718
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-6Ep3fNQu.mjs");
719
+ const dbPath = getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local");
720
+ if (!existsSync(dbPath)) {
721
+ R.error("No local database found. Run `void dev` first.");
722
+ process.exit(1);
723
+ }
724
+ const db = await openSqliteDatabase(dbPath, { readonly: true });
725
+ try {
726
+ let tables;
727
+ if (args.table) {
728
+ if (!db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(args.table)) {
729
+ R.error(`db: Table '${args.table}' not found.`);
730
+ process.exit(1);
731
+ }
732
+ tables = [args.table];
733
+ } else tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE '\\_%' ESCAPE '\\' ORDER BY name").all().map((row) => String(row.name));
734
+ const parts = [];
735
+ for (const table of tables) {
736
+ if (!args.noSchema) {
737
+ const row = db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name=?").get(table);
738
+ parts.push(row.sql + ";");
739
+ }
740
+ if (!args.noData) {
741
+ const rows = db.prepare(`SELECT * FROM "${table}"`).all();
742
+ for (const row of rows) {
743
+ const cols = Object.keys(row);
744
+ const vals = cols.map((c) => {
745
+ const v = row[c];
746
+ if (v === null) return "NULL";
747
+ if (typeof v === "number") return String(v);
748
+ return `'${String(v).replace(/'/g, "''")}'`;
749
+ });
750
+ parts.push(`INSERT INTO "${table}" (${cols.join(", ")}) VALUES (${vals.join(", ")});`);
751
+ }
752
+ }
753
+ parts.push("");
754
+ }
755
+ const output = parts.join("\n");
756
+ if (args.output) {
757
+ writeFileSync(join(root, args.output), output);
758
+ R.success(`Exported to ${args.output}`);
759
+ ye("Done.");
760
+ } else process.stdout.write(output);
761
+ } finally {
762
+ db.close();
763
+ }
764
+ }
765
+ async function runSetUrl(root) {
766
+ const { readConfig: readVoidConfig, getDatabaseDialect: getDialect } = await import("./config-BIa9HwVX.mjs").then((n) => n.n);
767
+ if (getDialect(readVoidConfig(root)) !== "postgresql") {
768
+ R.error("db: This command is only for PostgreSQL projects. Set \"database\": \"pg\" in void.json.");
769
+ process.exit(1);
770
+ }
771
+ const token = getToken(root);
772
+ if (!token) {
773
+ R.error("No auth token found. Run `void auth login` first.");
774
+ process.exit(1);
775
+ }
776
+ const projectConfig = readProjectConfig(root);
777
+ if (!projectConfig) {
778
+ R.error("No project linked. Run `void deploy` first or link a project.");
779
+ process.exit(1);
780
+ }
781
+ const { text: promptText, isCancel: isCancelCheck } = await import("./dist-Dayj3gCK.mjs").then((n) => n.p);
782
+ const connectionString = await promptText({
783
+ message: "Enter your PostgreSQL connection string:",
784
+ placeholder: "postgresql://user:pass@host:5432/dbname",
785
+ validate(value = "") {
786
+ if (!value.startsWith("postgres://") && !value.startsWith("postgresql://")) return "Connection string must start with \"postgres://\" or \"postgresql://\"";
787
+ }
788
+ });
789
+ if (isCancelCheck(connectionString)) process.exit(0);
790
+ await new PlatformClient(token, { root }).setDatabaseUrl(projectConfig.projectId, connectionString);
791
+ R.success("Database URL updated.");
792
+ ye("Done.");
793
+ }
794
+ function resolveSeedTarget(root, file) {
795
+ if (file) return toSeedTarget(root, resolve(root, file), file);
796
+ const defaults = DEFAULT_SEED_FILES.filter((candidate) => existsSync(join(root, candidate)));
797
+ if (defaults.length === 0) {
798
+ R.error(`db: No seed file found. Create one of: ${DEFAULT_SEED_FILES.join(", ")} or pass --file <path>.`);
799
+ process.exit(1);
800
+ }
801
+ if (defaults.length > 1) {
802
+ R.error(`db: Multiple default seed files found: ${defaults.join(", ")}. Use --file <path> to choose one.`);
803
+ process.exit(1);
804
+ }
805
+ const [seedPath] = defaults;
806
+ return toSeedTarget(root, join(root, seedPath), seedPath);
807
+ }
808
+ function toSeedTarget(root, seedPath, displayPath) {
809
+ if (!existsSync(seedPath)) {
810
+ R.error(`db: Seed file '${seedPath}' not found.`);
811
+ process.exit(1);
812
+ }
813
+ const ext = extname(seedPath);
814
+ const normalizedDisplay = (displayPath ?? relative(root, seedPath)).replaceAll("\\", "/");
815
+ if (ext === ".sql") return {
816
+ path: seedPath,
817
+ displayPath: normalizedDisplay,
818
+ kind: "sql"
819
+ };
820
+ if (MODULE_SEED_EXTENSIONS.has(ext)) return {
821
+ path: seedPath,
822
+ displayPath: normalizedDisplay,
823
+ kind: "module"
824
+ };
825
+ R.error(`db: Unsupported seed file '${normalizedDisplay}'. Use .sql, .ts, .mts, .js, or .mjs.`);
826
+ process.exit(1);
827
+ }
828
+ async function runSeedModule(root, seedPath, dialect) {
829
+ const seed = await loadSeedFunction(seedPath);
830
+ const schema = await loadSeedSchema(root);
831
+ if (dialect === "postgresql") {
832
+ const { drizzle } = await import("drizzle-orm/node-postgres");
833
+ await withPgClient(root, async (client) => {
834
+ const options = getDrizzleSchemaOptions(schema);
835
+ const drizzleClient = client;
836
+ await seed({
837
+ dialect,
838
+ db: options ? drizzle(drizzleClient, options) : drizzle(drizzleClient),
839
+ schema
840
+ });
841
+ });
842
+ return;
843
+ }
844
+ const { drizzle } = await import("drizzle-orm/better-sqlite3");
845
+ const { getMiniflareDatabasePath, openSqliteDatabase } = await import("./runner-6Ep3fNQu.mjs");
846
+ const sqlite = await openSqliteDatabase(getMiniflareDatabasePath(getLocalD1PersistRoot(root), "local"));
847
+ try {
848
+ const options = getDrizzleSchemaOptions(schema);
849
+ await seed({
850
+ dialect,
851
+ db: options ? drizzle(sqlite, options) : drizzle(sqlite),
852
+ schema
853
+ });
854
+ } finally {
855
+ sqlite.close();
856
+ }
857
+ }
858
+ async function loadSeedFunction(seedPath) {
859
+ const mod = await importLocalModule(seedPath);
860
+ const seed = typeof mod.default === "function" ? mod.default : typeof mod.seed === "function" ? mod.seed : void 0;
861
+ if (!seed) throw new Error(`db: Seed module '${seedPath}' must export a default function or a named "seed" function.`);
862
+ return seed;
863
+ }
864
+ async function loadSeedSchema(root) {
865
+ const { discoverSchema } = await import("./discover-B7FkXBLB.mjs").then((n) => n.n);
866
+ const location = discoverSchema(root);
867
+ if (!location) return {};
868
+ if (location.type === "file") {
869
+ const mod = await importLocalModule(location.path);
870
+ return Object.fromEntries(Object.entries(mod).filter(([name]) => name !== "default" && name !== "__esModule"));
871
+ }
872
+ const files = collectSchemaModuleFiles(location.path);
873
+ const parts = await Promise.all(files.map((file) => importLocalModule(file)));
874
+ return Object.assign({}, ...parts.map((mod) => Object.fromEntries(Object.entries(mod).filter(([name]) => name !== "default"))));
875
+ }
876
+ function collectSchemaModuleFiles(dir) {
877
+ const files = [];
878
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
879
+ const fullPath = join(dir, entry.name);
880
+ if (entry.isDirectory()) {
881
+ files.push(...collectSchemaModuleFiles(fullPath));
882
+ continue;
883
+ }
884
+ if (MODULE_SEED_EXTENSIONS.has(extname(entry.name)) && !entry.name.endsWith(".d.ts") && !entry.name.endsWith(".d.mts")) files.push(fullPath);
885
+ }
886
+ return files.sort();
887
+ }
888
+ async function importLocalModule(modulePath) {
889
+ return import(`${pathToFileURL(modulePath).href}?t=${Date.now()}`);
890
+ }
891
+ function getDrizzleSchemaOptions(schema) {
892
+ return Object.keys(schema).length > 0 ? { schema } : void 0;
893
+ }
894
+ //#endregion
895
+ export { runDbCommand };