ref0-git 0.0.0 → 0.3.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 (385) hide show
  1. package/app/apps/github/.dev.vars.example +6 -0
  2. package/app/apps/github/README.md +70 -0
  3. package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
  4. package/app/apps/github/components.json +25 -0
  5. package/app/apps/github/generated/git-rest.ts +10444 -0
  6. package/app/apps/github/generated/routeTree.gen.ts +1242 -0
  7. package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
  8. package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
  9. package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
  10. package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
  11. package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
  12. package/app/apps/github/package.json +80 -0
  13. package/app/apps/github/src/branches/branch-list.tsx +385 -0
  14. package/app/apps/github/src/branches/branches.ts +55 -0
  15. package/app/apps/github/src/clients/allowed.ts +213 -0
  16. package/app/apps/github/src/clients/at-most.ts +17 -0
  17. package/app/apps/github/src/clients/avatars.ts +410 -0
  18. package/app/apps/github/src/clients/cached.ts +65 -0
  19. package/app/apps/github/src/clients/calls.ts +160 -0
  20. package/app/apps/github/src/clients/clients.ts +82 -0
  21. package/app/apps/github/src/clients/graphql.ts +50 -0
  22. package/app/apps/github/src/clients/host-answer.ts +28 -0
  23. package/app/apps/github/src/clients/host-calls.ts +382 -0
  24. package/app/apps/github/src/clients/icon-bytes.ts +203 -0
  25. package/app/apps/github/src/clients/proxy.ts +59 -0
  26. package/app/apps/github/src/clients/session-ended.ts +18 -0
  27. package/app/apps/github/src/clients/transfers.ts +212 -0
  28. package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
  29. package/app/apps/github/src/code/code-page.tsx +147 -0
  30. package/app/apps/github/src/code/code-tree.tsx +338 -0
  31. package/app/apps/github/src/code/controls.tsx +230 -0
  32. package/app/apps/github/src/code/file-view.tsx +450 -0
  33. package/app/apps/github/src/code/files.ts +332 -0
  34. package/app/apps/github/src/code/folder-list.tsx +122 -0
  35. package/app/apps/github/src/code/go-to-file.tsx +131 -0
  36. package/app/apps/github/src/code/highlighted.tsx +58 -0
  37. package/app/apps/github/src/code/lines.ts +46 -0
  38. package/app/apps/github/src/code/load.ts +147 -0
  39. package/app/apps/github/src/code/markdown-files.ts +58 -0
  40. package/app/apps/github/src/code/places.ts +88 -0
  41. package/app/apps/github/src/code/ref-pages.ts +179 -0
  42. package/app/apps/github/src/code/ref-switcher.tsx +203 -0
  43. package/app/apps/github/src/code/refs.ts +142 -0
  44. package/app/apps/github/src/code/repo-home.tsx +240 -0
  45. package/app/apps/github/src/code/repo.ts +105 -0
  46. package/app/apps/github/src/code/saved-reads.ts +199 -0
  47. package/app/apps/github/src/code/saved.ts +110 -0
  48. package/app/apps/github/src/code/tree-fold.ts +186 -0
  49. package/app/apps/github/src/code/trees.ts +136 -0
  50. package/app/apps/github/src/components/avatar-picture.ts +53 -0
  51. package/app/apps/github/src/components/avatar-url.ts +16 -0
  52. package/app/apps/github/src/components/confirm-action.tsx +100 -0
  53. package/app/apps/github/src/components/count.tsx +24 -0
  54. package/app/apps/github/src/components/create-button.tsx +38 -0
  55. package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
  56. package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
  57. package/app/apps/github/src/components/filter.tsx +35 -0
  58. package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
  59. package/app/apps/github/src/components/item-list.tsx +65 -0
  60. package/app/apps/github/src/components/language-dot.tsx +29 -0
  61. package/app/apps/github/src/components/list-toolbar.tsx +82 -0
  62. package/app/apps/github/src/components/markdown/editor.tsx +57 -0
  63. package/app/apps/github/src/components/markdown/markdown.css +177 -0
  64. package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
  65. package/app/apps/github/src/components/owner-card.tsx +196 -0
  66. package/app/apps/github/src/components/pull-status.tsx +34 -0
  67. package/app/apps/github/src/components/recent.ts +41 -0
  68. package/app/apps/github/src/components/relative-time.tsx +78 -0
  69. package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
  70. package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
  71. package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
  72. package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
  73. package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
  74. package/app/apps/github/src/components/review-state.tsx +75 -0
  75. package/app/apps/github/src/components/route-dialog.tsx +137 -0
  76. package/app/apps/github/src/components/save-button.tsx +58 -0
  77. package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
  78. package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
  79. package/app/apps/github/src/components/shell/create-row.tsx +49 -0
  80. package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
  81. package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
  82. package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
  83. package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
  84. package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
  85. package/app/apps/github/src/components/shell/sections.ts +31 -0
  86. package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
  87. package/app/apps/github/src/components/signin/device-card.tsx +139 -0
  88. package/app/apps/github/src/components/signin/login-form.tsx +88 -0
  89. package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
  90. package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
  91. package/app/apps/github/src/components/states/live-status.tsx +42 -0
  92. package/app/apps/github/src/components/states/states.tsx +126 -0
  93. package/app/apps/github/src/components/tab-indicator.tsx +143 -0
  94. package/app/apps/github/src/components/theme-choice.tsx +108 -0
  95. package/app/apps/github/src/components/theme-provider.tsx +126 -0
  96. package/app/apps/github/src/components/tones.ts +23 -0
  97. package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
  98. package/app/apps/github/src/components/ui/alert.tsx +78 -0
  99. package/app/apps/github/src/components/ui/avatar.tsx +106 -0
  100. package/app/apps/github/src/components/ui/badge.tsx +51 -0
  101. package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
  102. package/app/apps/github/src/components/ui/button-group.tsx +87 -0
  103. package/app/apps/github/src/components/ui/button.tsx +61 -0
  104. package/app/apps/github/src/components/ui/calendar.tsx +221 -0
  105. package/app/apps/github/src/components/ui/card.tsx +102 -0
  106. package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
  107. package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
  108. package/app/apps/github/src/components/ui/combobox.tsx +304 -0
  109. package/app/apps/github/src/components/ui/command.tsx +208 -0
  110. package/app/apps/github/src/components/ui/dialog.tsx +156 -0
  111. package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
  112. package/app/apps/github/src/components/ui/empty.tsx +100 -0
  113. package/app/apps/github/src/components/ui/field.tsx +236 -0
  114. package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
  115. package/app/apps/github/src/components/ui/input-group.tsx +163 -0
  116. package/app/apps/github/src/components/ui/input.tsx +19 -0
  117. package/app/apps/github/src/components/ui/item.tsx +201 -0
  118. package/app/apps/github/src/components/ui/kbd.tsx +27 -0
  119. package/app/apps/github/src/components/ui/label.tsx +33 -0
  120. package/app/apps/github/src/components/ui/popover.tsx +87 -0
  121. package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
  122. package/app/apps/github/src/components/ui/select.tsx +198 -0
  123. package/app/apps/github/src/components/ui/separator.tsx +22 -0
  124. package/app/apps/github/src/components/ui/sheet.tsx +138 -0
  125. package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
  126. package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
  127. package/app/apps/github/src/components/ui/sonner.tsx +47 -0
  128. package/app/apps/github/src/components/ui/styles.css +242 -0
  129. package/app/apps/github/src/components/ui/table.tsx +113 -0
  130. package/app/apps/github/src/components/ui/tabs.tsx +79 -0
  131. package/app/apps/github/src/components/ui/textarea.tsx +17 -0
  132. package/app/apps/github/src/components/ui/title.ts +6 -0
  133. package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
  134. package/app/apps/github/src/components/ui/toggle.tsx +42 -0
  135. package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
  136. package/app/apps/github/src/components/user-avatar.tsx +145 -0
  137. package/app/apps/github/src/components/view-tabs.tsx +42 -0
  138. package/app/apps/github/src/context/context.ts +133 -0
  139. package/app/apps/github/src/diffs/blobs.ts +94 -0
  140. package/app/apps/github/src/diffs/diff-view.tsx +155 -0
  141. package/app/apps/github/src/diffs/files.ts +121 -0
  142. package/app/apps/github/src/diffs/hunks.tsx +454 -0
  143. package/app/apps/github/src/diffs/patch.ts +131 -0
  144. package/app/apps/github/src/diffs/rows.ts +137 -0
  145. package/app/apps/github/src/history/commit-diff.ts +54 -0
  146. package/app/apps/github/src/history/commit-list.tsx +207 -0
  147. package/app/apps/github/src/history/commit-page.tsx +147 -0
  148. package/app/apps/github/src/history/history.ts +129 -0
  149. package/app/apps/github/src/hooks/allowed.ts +31 -0
  150. package/app/apps/github/src/hooks/answers.ts +65 -0
  151. package/app/apps/github/src/hooks/avatars.ts +54 -0
  152. package/app/apps/github/src/hooks/draft.ts +38 -0
  153. package/app/apps/github/src/hooks/open-counts.ts +127 -0
  154. package/app/apps/github/src/hooks/profiles.ts +120 -0
  155. package/app/apps/github/src/hooks/repos.ts +440 -0
  156. package/app/apps/github/src/hooks/use-mobile.ts +19 -0
  157. package/app/apps/github/src/hooks/viewer.ts +39 -0
  158. package/app/apps/github/src/inbox/count.ts +70 -0
  159. package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
  160. package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
  161. package/app/apps/github/src/inbox/marks.ts +130 -0
  162. package/app/apps/github/src/inbox/release-tags.ts +65 -0
  163. package/app/apps/github/src/inbox/search.ts +97 -0
  164. package/app/apps/github/src/inbox/subjects.ts +184 -0
  165. package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
  166. package/app/apps/github/src/inbox/subscriptions.ts +189 -0
  167. package/app/apps/github/src/inbox/threads.ts +198 -0
  168. package/app/apps/github/src/issues/changes.ts +332 -0
  169. package/app/apps/github/src/issues/counts.ts +62 -0
  170. package/app/apps/github/src/issues/issue-list.tsx +682 -0
  171. package/app/apps/github/src/issues/issue-page.tsx +533 -0
  172. package/app/apps/github/src/issues/issues.ts +566 -0
  173. package/app/apps/github/src/issues/label-dialog.tsx +310 -0
  174. package/app/apps/github/src/issues/labels-page.tsx +119 -0
  175. package/app/apps/github/src/issues/new-issue.tsx +79 -0
  176. package/app/apps/github/src/issues/parts.tsx +71 -0
  177. package/app/apps/github/src/issues/picker.tsx +298 -0
  178. package/app/apps/github/src/issues/search.ts +238 -0
  179. package/app/apps/github/src/issues/sidebar.tsx +236 -0
  180. package/app/apps/github/src/lib/cn.ts +8 -0
  181. package/app/apps/github/src/lib/highlighting.ts +13 -0
  182. package/app/apps/github/src/live/follow.ts +129 -0
  183. package/app/apps/github/src/live/sse.ts +74 -0
  184. package/app/apps/github/src/live/use-follow.ts +37 -0
  185. package/app/apps/github/src/markdown/README.md +53 -0
  186. package/app/apps/github/src/markdown/allowed-html.ts +69 -0
  187. package/app/apps/github/src/markdown/context.ts +206 -0
  188. package/app/apps/github/src/markdown/images.ts +81 -0
  189. package/app/apps/github/src/markdown/lookup.ts +127 -0
  190. package/app/apps/github/src/markdown/patches.ts +299 -0
  191. package/app/apps/github/src/markdown/query.ts +25 -0
  192. package/app/apps/github/src/markdown/references.ts +158 -0
  193. package/app/apps/github/src/markdown/render.ts +103 -0
  194. package/app/apps/github/src/names/owners.ts +51 -0
  195. package/app/apps/github/src/names/repos.ts +24 -0
  196. package/app/apps/github/src/palette/palette.tsx +562 -0
  197. package/app/apps/github/src/palette/recent.ts +116 -0
  198. package/app/apps/github/src/palette/rows.tsx +487 -0
  199. package/app/apps/github/src/palette/server.ts +107 -0
  200. package/app/apps/github/src/palette/targets.ts +306 -0
  201. package/app/apps/github/src/policy.ts +606 -0
  202. package/app/apps/github/src/private-repos.ts +47 -0
  203. package/app/apps/github/src/pulls/compare-page.tsx +342 -0
  204. package/app/apps/github/src/pulls/files-tab.tsx +776 -0
  205. package/app/apps/github/src/pulls/live.ts +124 -0
  206. package/app/apps/github/src/pulls/merge-box.tsx +367 -0
  207. package/app/apps/github/src/pulls/merge-button.ts +86 -0
  208. package/app/apps/github/src/pulls/pull-list.tsx +235 -0
  209. package/app/apps/github/src/pulls/pull-page.tsx +474 -0
  210. package/app/apps/github/src/pulls/pull.ts +468 -0
  211. package/app/apps/github/src/pulls/pulls.ts +318 -0
  212. package/app/apps/github/src/pulls/review.ts +350 -0
  213. package/app/apps/github/src/pulls/search.ts +130 -0
  214. package/app/apps/github/src/queue/queue-page.tsx +405 -0
  215. package/app/apps/github/src/queue/queue.ts +231 -0
  216. package/app/apps/github/src/releases/latest-release.tsx +55 -0
  217. package/app/apps/github/src/releases/overview.tsx +30 -0
  218. package/app/apps/github/src/releases/release-form.tsx +353 -0
  219. package/app/apps/github/src/releases/release-list.tsx +173 -0
  220. package/app/apps/github/src/releases/release-view.tsx +183 -0
  221. package/app/apps/github/src/releases/releases.ts +308 -0
  222. package/app/apps/github/src/releases/tag-list.tsx +134 -0
  223. package/app/apps/github/src/router.tsx +46 -0
  224. package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
  225. package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
  226. package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
  227. package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
  228. package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
  229. package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
  230. package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
  231. package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
  232. package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
  233. package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
  234. package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
  235. package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
  236. package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
  237. package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
  238. package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
  239. package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
  240. package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
  241. package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
  242. package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
  243. package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
  244. package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
  245. package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
  246. package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
  247. package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
  248. package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
  249. package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
  250. package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
  251. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
  252. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
  253. package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
  254. package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
  255. package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
  256. package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
  257. package/app/apps/github/src/routes/$owner/index.tsx +45 -0
  258. package/app/apps/github/src/routes/-nav.tsx +293 -0
  259. package/app/apps/github/src/routes/-root-testing.ts +107 -0
  260. package/app/apps/github/src/routes/__root.tsx +225 -0
  261. package/app/apps/github/src/routes/api.auth.$.ts +18 -0
  262. package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
  263. package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
  264. package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
  265. package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
  266. package/app/apps/github/src/routes/icons/index.tsx +12 -0
  267. package/app/apps/github/src/routes/index.tsx +48 -0
  268. package/app/apps/github/src/routes/login.tsx +24 -0
  269. package/app/apps/github/src/routes/login_.code.tsx +31 -0
  270. package/app/apps/github/src/routes/new.tsx +91 -0
  271. package/app/apps/github/src/routes/notifications.tsx +20 -0
  272. package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
  273. package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
  274. package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
  275. package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
  276. package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
  277. package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
  278. package/app/apps/github/src/routes/settings.tsx +54 -0
  279. package/app/apps/github/src/routes/signup.tsx +24 -0
  280. package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
  281. package/app/apps/github/src/seed/acme.ts +498 -0
  282. package/app/apps/github/src/seed/licenses.ts +114 -0
  283. package/app/apps/github/src/seed/seed.ts +528 -0
  284. package/app/apps/github/src/server.ts +97 -0
  285. package/app/apps/github/src/settings/account-avatar.tsx +43 -0
  286. package/app/apps/github/src/settings/avatar-section.tsx +140 -0
  287. package/app/apps/github/src/settings/avatar.ts +58 -0
  288. package/app/apps/github/src/settings/general-settings.tsx +439 -0
  289. package/app/apps/github/src/settings/general.ts +73 -0
  290. package/app/apps/github/src/settings/hook-form.tsx +195 -0
  291. package/app/apps/github/src/settings/hook-list.tsx +166 -0
  292. package/app/apps/github/src/settings/hooks.ts +87 -0
  293. package/app/apps/github/src/settings/org-settings.tsx +228 -0
  294. package/app/apps/github/src/settings/orgs.ts +116 -0
  295. package/app/apps/github/src/settings/rule-list.tsx +72 -0
  296. package/app/apps/github/src/settings/rules.ts +27 -0
  297. package/app/apps/github/src/settings/settings-layout.tsx +114 -0
  298. package/app/apps/github/src/signin/approval.ts +186 -0
  299. package/app/apps/github/src/signin/auth-client.ts +127 -0
  300. package/app/apps/github/src/signin/auth.ts +753 -0
  301. package/app/apps/github/src/signin/avatars.ts +126 -0
  302. package/app/apps/github/src/signin/client-ip.ts +39 -0
  303. package/app/apps/github/src/signin/credentials.ts +26 -0
  304. package/app/apps/github/src/signin/device-code.ts +95 -0
  305. package/app/apps/github/src/signin/device-prompt.ts +125 -0
  306. package/app/apps/github/src/signin/errors.ts +135 -0
  307. package/app/apps/github/src/signin/host-session.ts +68 -0
  308. package/app/apps/github/src/signin/orgs.ts +283 -0
  309. package/app/apps/github/src/signin/owner-names.ts +183 -0
  310. package/app/apps/github/src/signin/person-lock.ts +104 -0
  311. package/app/apps/github/src/signin/seal.ts +88 -0
  312. package/app/apps/github/src/signin/seed-people.ts +92 -0
  313. package/app/apps/github/src/signin/session.ts +48 -0
  314. package/app/apps/github/src/signin/unborn.ts +110 -0
  315. package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
  316. package/app/apps/github/src/signin/viewer.ts +74 -0
  317. package/app/apps/github/src/signin/with-headers.ts +14 -0
  318. package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
  319. package/app/apps/github/src/tokens/tokens.ts +54 -0
  320. package/app/apps/github/tsconfig.json +25 -0
  321. package/app/apps/github/tsconfig.worker.json +24 -0
  322. package/app/apps/github/vite.config.ts +21 -0
  323. package/app/pnpm-workspace.yaml +216 -0
  324. package/app/tsconfig.base.json +127 -0
  325. package/dist/LICENSE +202 -0
  326. package/dist/cli/child.mjs +42 -0
  327. package/dist/cli/commands.mjs +23 -0
  328. package/dist/cli/credentials.mjs +84 -0
  329. package/dist/cli/documents.mjs +214 -0
  330. package/dist/cli/events.mjs +55 -0
  331. package/dist/cli/failure.mjs +105 -0
  332. package/dist/cli/folders.mjs +32 -0
  333. package/dist/cli/git-remote-ref0.d.mts +1 -0
  334. package/dist/cli/git-remote-ref0.mjs +29 -0
  335. package/dist/cli/git.mjs +69 -0
  336. package/dist/cli/helpers.mjs +184 -0
  337. package/dist/cli/hosts.mjs +127 -0
  338. package/dist/cli/node.mjs +15 -0
  339. package/dist/cli/output.mjs +135 -0
  340. package/dist/cli/prompt.mjs +35 -0
  341. package/dist/cli/queue.mjs +215 -0
  342. package/dist/cli/ref0-git.d.mts +1 -0
  343. package/dist/cli/ref0-git.mjs +144 -0
  344. package/dist/cli/repos.mjs +162 -0
  345. package/dist/cli/resources.mjs +131 -0
  346. package/dist/cli/run-end.mjs +57 -0
  347. package/dist/cli/runtime.mjs +50 -0
  348. package/dist/cli/setup.mjs +1410 -0
  349. package/dist/cli/sign-in.mjs +162 -0
  350. package/dist/cli/sign-ins.mjs +136 -0
  351. package/dist/cli/sqlite.mjs +28 -0
  352. package/dist/cli/tokens.mjs +141 -0
  353. package/dist/cli/vendor.mjs +123 -0
  354. package/dist/init/app.mjs +231 -0
  355. package/dist/init/astro.mjs +49 -0
  356. package/dist/init/choices.mjs +497 -0
  357. package/dist/init/cloudflare.mjs +324 -0
  358. package/dist/init/create.mjs +151 -0
  359. package/dist/init/detect.mjs +297 -0
  360. package/dist/init/files.mjs +80 -0
  361. package/dist/init/frameworks.mjs +248 -0
  362. package/dist/init/git-module.mjs +49 -0
  363. package/dist/init/github-routes.mjs +66 -0
  364. package/dist/init/jsonc.mjs +143 -0
  365. package/dist/init/metadata.mjs +48 -0
  366. package/dist/init/mounts.mjs +109 -0
  367. package/dist/init/next.mjs +203 -0
  368. package/dist/init/node-app.mjs +189 -0
  369. package/dist/init/node.mjs +460 -0
  370. package/dist/init/nuxt.mjs +115 -0
  371. package/dist/init/output.mjs +21 -0
  372. package/dist/init/plan.mjs +82 -0
  373. package/dist/init/range-major.mjs +257 -0
  374. package/dist/init/react-router.mjs +59 -0
  375. package/dist/init/routes.mjs +148 -0
  376. package/dist/init/shell.mjs +4 -0
  377. package/dist/init/stores.mjs +51 -0
  378. package/dist/init/sveltekit.mjs +139 -0
  379. package/dist/init/template.mjs +142 -0
  380. package/dist/init/templates.mjs +343 -0
  381. package/dist/init/vercel.mjs +384 -0
  382. package/dist/init/versions.mjs +32 -0
  383. package/dist/init/workspace.mjs +20 -0
  384. package/package.json +48 -6
  385. package/README.md +0 -5
@@ -0,0 +1,384 @@
1
+ import { serveExport } from "./git-module.mjs";
2
+ import { vercelPackages } from "./metadata.mjs";
3
+ import { dropInPrefixes } from "./routes.mjs";
4
+ import { ignoring, importLine, lines, served, withCli, withCreatedTypes, withDependencies, withLines } from "./files.mjs";
5
+ import { envExample, needHelper, needsOf, recordsPart, s3Part } from "./stores.mjs";
6
+ import { inline, insertInto, itemsAt, nodeAt, parseJsonc, stringAt, withEntries } from "./jsonc.mjs";
7
+ import { nextConfigOutput, nextJobFiles, nextJobRoutes, nextRouteFiles, nextSweepPath } from "./next.mjs";
8
+ import { specOf } from "./versions.mjs";
9
+ import * as Redacted from "effect/Redacted";
10
+ import * as Predicate from "effect/Predicate";
11
+ // src/init/vercel.ts
12
+ /**
13
+ * What `init` writes for Git on Vercel's functions, without the app: `src/git.ts`, `api/git.ts`
14
+ * for every URL, `api/jobs.ts` for the queue's deliveries and `api/jobs/sweep.ts` for the cron,
15
+ * and Git's part merged into `vercel.json`, `package.json`, `.gitignore` and `.env`.
16
+ */
17
+ /** The topic `src/git.ts` sends to and `vercel.json`'s trigger names. */
18
+ const topic = "git-jobs";
19
+ /** The routes `vercel.json` gives Git: every URL's, the queue's private one and the cron's. */
20
+ const routes = {
21
+ git: "api/git.ts",
22
+ jobs: "api/jobs.ts",
23
+ sweep: "/api/jobs/sweep"
24
+ };
25
+ /** A plan's longest function run, in seconds, and its cron's schedule: Hobby allows one a day. */
26
+ const planLimits = {
27
+ hobby: {
28
+ maxDuration: 300,
29
+ schedule: "0 4 * * *"
30
+ },
31
+ pro: {
32
+ maxDuration: 800,
33
+ schedule: "* * * * *"
34
+ }
35
+ };
36
+ const limitsOf = (choices) => planLimits[choices.vercelPlan === "pro" ? "pro" : "hobby"];
37
+ /** The store's and the bucket's parts, as `init/stores.ts` writes them; Blob's is Vercel's own. */
38
+ const partsOf = (choices) => ({
39
+ records: recordsPart(choices.records === "turso" ? "turso" : "postgres"),
40
+ bucket: choices.bucket === "s3" ? s3Part : void 0
41
+ });
42
+ /** The variables the person sets: Postgres's or Turso's, then the bucket's, Blob's token its own. */
43
+ const unsetOf = (choices) => {
44
+ const { records, bucket } = partsOf(choices);
45
+ return needsOf([records, bucket ?? { variables: ["BLOB_READ_WRITE_TOKEN"] }]);
46
+ };
47
+ /** The variables `src/git.ts` needs, as `.env.example` lists them: the secrets `init` made first. */
48
+ const variablesOf = (choices) => [
49
+ "ADMIN_TOKEN",
50
+ "CRON_SECRET",
51
+ ...unsetOf(choices)
52
+ ];
53
+ /**
54
+ * `src/git.ts` on Vercel: Git, its REST and the drop-in, as chosen, and the job queue. In Next.js,
55
+ * the server module, whose jobs a route of its own takes, and which exports `serve` for Git's route.
56
+ */
57
+ const vercelGitModule = (choices, next) => {
58
+ const jobsRoute = next === void 0 ? routes.jobs : nextJobRoutes(next).jobs;
59
+ const postgres = choices.records === "postgres";
60
+ const blob = choices.bucket === "vercel-blob";
61
+ const { records, bucket } = partsOf(choices);
62
+ const github = choices.serve === "github";
63
+ const queue = choices.queue === "on";
64
+ const { maxDuration } = limitsOf(choices);
65
+ return lines(`// Git on Vercel's functions, ${served[choices.serve]}${queue ? ", with a merge queue on `main`" : ""}: records and jobs`, `// in ${postgres ? "Postgres" : "Turso"}, packs in ${blob ? "Vercel Blob" : "S3"}, and jobs woken by Vercel Queues. Written by \`ref0-git init\`, and`, "// yours to change: `init` rewrites it only while it reads as written, and `ref0-git doctor`", "// checks it.", choices.serve === "git" && "// Nothing here makes a repo over HTTP: make one from code, as `git.repos.create({ id: 'acme/app' })`.", ...records.external, "", `import { accept, createGitServer, ${queue ? "mergeQueue, " : ""}packs, reject } from '@ref0/git';`, queue && "import type { MergeInput, MergePlan } from '@ref0/git';", "import { bearer, tokens } from '@ref0/git/auth';", "import { engine } from '@ref0/git/engine';", "import { xdiff } from '@ref0/git/node';", choices.serve !== "git" && "import { createRestHandler } from '@ref0/git/rest';", github && "import { createGitHubHandler } from '@ref0/github';", importLine([
66
+ "createJobQueue",
67
+ "layerOf",
68
+ ...records.infra,
69
+ ...bucket?.infra ?? [],
70
+ ...blob ? ["vercelBlob"] : [],
71
+ "vercelQueues"
72
+ ], "@ref0/infra/promises"), "", needHelper("the project's Environment Variables"), "", "/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */", "const admin = { id: '_admin' };", "", "// Functions don't run between requests: a commit that saves a job sends a queue message, and the", "// cron in `vercel.json` sweeps for any message that was lost.", `const wake = vercelQueues({ topic: '${topic}' });`, "", records.code, "", `/** The job queue: \`${jobsRoute}\` runs what its messages and the cron's calls name. */`, "export const jobs = createJobQueue({ store });", "", bucket !== void 0 && lines(bucket.code, ""), queue && lines("/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */", "const merge = ({ entry }: MergeInput): MergePlan => ({", " method: 'merge',", " message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,", " author: {", " name: entry.actor.id,", " email: `${entry.actor.id}@users.noreply.git`,", " at: Date.now(),", " offset: 0,", " },", "});", ""), "export const git = createGitServer({", ` adapter: layerOf({ store, bucket: ${blob ? "vercelBlob()" : "bucket"}, jobs }),`, " // The functions' `maxDuration`, from `vercel.json`: a clone that would outrun it ends first, with", " // Git's own message.", ` maxDuration: '${maxDuration} seconds',`, " objects: packs(),", " engine: engine({ xdiff: await xdiff() }),", " tokens: tokens(),", ` // Vercel refuses a body over 4.5 MB, so a larger push uploads its pack to ${blob ? "Blob" : "the bucket"}.`, " pushes: { upload: { above: 4 * 1024 * 1024 } },", choices.basePath !== "/" && ` // Git's URLs, Smart HTTP, sign-in and REST, under this path.\n basePath: '${choices.basePath.replace(/\/$/, "")}',`, " auth: bearer({ token: need('ADMIN_TOKEN'), actor: admin }),", " authorize: ({ actor, operation }) => {", " if (actor.anonymous === true) return reject({ message: 'Sign in first' });", "", " if (actor.id === admin.id && operation.kind === 'push') {", " return reject({", " message: \"The admin token can't push\",", " hint: 'Make a write token for yourself: npx ref0-git tokens create --help',", " });", " }", "", " return accept();", " },", queue && " queue: mergeQueue({ target: 'refs/heads/main', merge }),", github && " // Git's events go to the drop-in, which follows each push: a pull request's head, its queue.\n events: (input) => github.events(input),", "});", "", github && "/** GitHub's REST, GraphQL, webhooks and Event Streams, so `gh` and Octokit work. */\nexport const github = createGitHubHandler(git);\n", choices.serve !== "git" && "/** Git's REST, whose `route` and `fetch` serve Git's protocol and sign-in too. */\nexport const rest = createRestHandler(git);\n", next !== void 0 && serveExport(choices));
73
+ };
74
+ /** What `api/git.ts` answers each method with, for what it serves. */
75
+ const handlers = {
76
+ github: {
77
+ names: "github, rest",
78
+ fetch: lines("/** The drop-in's URLs, then Git's REST and protocol, then a JSON `404`. */", "const fetch = async (request: Request) => (await github.route(request)) ?? rest.fetch(request);")
79
+ },
80
+ api: {
81
+ names: "rest",
82
+ fetch: "/** Git's REST and protocol, then a JSON `404`. */\nconst { fetch } = rest;"
83
+ },
84
+ git: {
85
+ names: "git",
86
+ fetch: "/** Git's protocol and sign-in, then a JSON `404`. */\nconst { fetch } = git;"
87
+ }
88
+ };
89
+ /** `api/git.ts`: every URL but the jobs' routes, by `vercel.json`'s rewrite. */
90
+ const gitRoute = (choices) => lines(`import { ${handlers[choices.serve].names} } from '../src/git.ts';`, "", handlers[choices.serve].fetch, "", "// Every URL but the jobs' routes comes here, by `vercel.json`'s rewrite.", "export {", ...[
91
+ "DELETE",
92
+ "GET",
93
+ "HEAD",
94
+ "PATCH",
95
+ "POST",
96
+ "PUT"
97
+ ].map((method) => ` fetch as ${method},`), "};", "");
98
+ /** `api/jobs.ts`: the queue's deliveries, on the function `vercel.json` gives its trigger. */
99
+ const jobsRoute = lines("import { jobs } from '../src/git.ts';", "", "/** Vercel Queues' deliveries: `vercel.json` gives this function the trigger, which makes it private. */", "export const POST = async (request: Request) =>", " (await jobs.fetch(request)) ?? new Response(null, { status: 404 });", "");
100
+ /** `api/jobs/sweep.ts`: the cron's call. */
101
+ const sweepRoute = lines("import { jobs } from '../../src/git.ts';", "", "/** The cron's sweep, refused without `CRON_SECRET`: a message for each scope with work due. */", "export const GET = async (request: Request) =>", " (await jobs.fetch(request)) ?? new Response(null, { status: 404 });", "");
102
+ /**
103
+ * The files that hold secrets on Vercel: `.env`, which `init` writes, and `.env.local`, which
104
+ * `vercel env pull` fills. `.gitignore` ends with them, and `init` refuses one Git tracks.
105
+ */
106
+ const secretFiles = [".env.local", ".env"];
107
+ /** What a rewrite's source takes after a drop-in prefix, for what may follow it. */
108
+ const after = {
109
+ optional: "(?:/|$)",
110
+ none: "$",
111
+ rest: "/",
112
+ segment: "/"
113
+ };
114
+ /** The drop-in's prefixes under `api/`, beside the functions', as one alternation: `v3(?:/|$)|…`. */
115
+ const dropInApi = dropInPrefixes.filter((route) => route.path.startsWith("api/")).map((route) => `${route.path.slice(4)}${after[route.tail]}`).join("|");
116
+ /** The drop-in's other prefixes at the root, each a source's alternative: `avatars/u/`. */
117
+ const dropInRoot = dropInPrefixes.filter((route) => !route.path.startsWith("api/")).map((route) => `|${route.path}${after[route.tail]}`).join("");
118
+ /**
119
+ * The rewrite's source: every URL but the functions' own, or every one under the base path. The
120
+ * drop-in also answers at the root: its API, avatars, and the `.git` URLs `gh repo clone` builds.
121
+ */
122
+ const rewriteSource = (choices) => {
123
+ const base = choices.basePath.replace(/\/$/, "");
124
+ const github = choices.serve === "github";
125
+ if (base === "") return github ? `/((?!api/(?!${dropInApi})).*)` : "/((?!api/).*)";
126
+ if (!github) return `${base}/:path*`;
127
+ return `/((?:${base.slice(1).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:/|$)|api/(?:${dropInApi})${dropInRoot}|[^/]+/[^/]+\\.git/).*)`;
128
+ };
129
+ const vercelParts = (choices, next) => {
130
+ const { maxDuration, schedule } = limitsOf(choices);
131
+ if (next !== void 0) {
132
+ const trigger = { experimentalTriggers: [{
133
+ type: "queue/v2beta",
134
+ topic
135
+ }] };
136
+ return {
137
+ rewrite: void 0,
138
+ functions: { [nextJobRoutes(next).jobs]: trigger },
139
+ cron: {
140
+ path: nextSweepPath,
141
+ schedule
142
+ }
143
+ };
144
+ }
145
+ return {
146
+ rewrite: {
147
+ source: rewriteSource(choices),
148
+ destination: "/api/git"
149
+ },
150
+ functions: {
151
+ [routes.git]: { maxDuration },
152
+ [routes.jobs]: {
153
+ maxDuration,
154
+ experimentalTriggers: [{
155
+ type: "queue/v2beta",
156
+ topic
157
+ }]
158
+ }
159
+ },
160
+ cron: {
161
+ path: routes.sweep,
162
+ schedule
163
+ }
164
+ };
165
+ };
166
+ /** `vercel.json` for a project `init` makes. */
167
+ const vercelConfig = (choices, next) => {
168
+ const { cron } = vercelParts(choices);
169
+ const rewrite = {
170
+ source: rewriteSource(choices),
171
+ destination: "/api/git"
172
+ };
173
+ const { maxDuration } = limitsOf(choices);
174
+ if (next !== void 0) return mergeVercel("{\n \"$schema\": \"https://openapi.vercel.sh/vercel.json\"\n}\n", choices, next);
175
+ return lines("{", " \"$schema\": \"https://openapi.vercel.sh/vercel.json\",", ` "rewrites": [${inline(rewrite)}],`, " \"functions\": {", ` "${routes.git}": { "maxDuration": ${maxDuration} },`, ` "${routes.jobs}": {`, ` "maxDuration": ${maxDuration},`, ` "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "${topic}" }]`, " }", " },", ` "crons": [${inline(cron)}]`, "}", "");
176
+ };
177
+ /** `text` with `node`'s value written as `value`. */
178
+ const replaced = (text, node, value) => `${text.slice(0, node.start)}${inline(value)}${text.slice(node.end)}`;
179
+ /** `text` with `value` at `key` of the item of `array` whose `match` is `wanted`, else the item added. */
180
+ const withItem = (text, array, match, item, key) => {
181
+ const found = itemsAt(parseJsonc(text), [array]).find((each) => stringAt(each, [match]) === item[match]);
182
+ if (found === void 0) return withEntries(text, [array], [item]);
183
+ const node = nodeAt(found, [key]);
184
+ const value = item[key] ?? "";
185
+ return node === void 0 ? insertInto(text, found, [`${JSON.stringify(key)}: ${inline(value)}`]) : stringAt(found, [key]) === value ? text : replaced(text, node, value);
186
+ };
187
+ /**
188
+ * `text` with Git's rewrite as its `rewrites`, when it has none. A list already there is the
189
+ * project's: `init` never edits it, so a host's order and conditions, such as `has`, stay theirs,
190
+ * and `rewriteSteps` prints Git's rewrite for the person to put first.
191
+ */
192
+ const withRewrite = (text, rewrite) => nodeAt(parseJsonc(text), ["rewrites"]) === void 0 ? withEntries(text, ["rewrites"], [rewrite]) : text;
193
+ /**
194
+ * The manual step a project's own `rewrites` gets when its first isn't Git's, with init's source:
195
+ * an earlier rewrite, such as a site's catch-all, takes Git's URLs, and an old source misses them.
196
+ */
197
+ const rewriteSteps = (text, choices, next) => {
198
+ const { rewrite } = vercelParts(choices, next);
199
+ if (rewrite === void 0) return [];
200
+ if (text === void 0 || nodeAt(parseJsonc(text), ["rewrites"]) === void 0) return [];
201
+ const [first] = itemsAt(parseJsonc(text), ["rewrites"]);
202
+ return stringAt(first, ["destination"]) === rewrite.destination && stringAt(first, ["source"]) === rewrite.source ? [] : [{
203
+ path: "vercel.json",
204
+ why: "yours",
205
+ says: `Put Git's rewrite first in \`rewrites\`, in place of any other to ${rewrite.destination}`,
206
+ lines: [` ${inline(rewrite)},`]
207
+ }];
208
+ };
209
+ /** A function's settings with Git's added where missing, and its `maxDuration` the plan's. */
210
+ const withFunction = (text, path, wanted, maxDuration) => {
211
+ const added = withEntries(text, ["functions"], { [path]: wanted });
212
+ const withKeys = withEntries(added, ["functions", path], wanted);
213
+ const duration = nodeAt(parseJsonc(withKeys), [
214
+ "functions",
215
+ path,
216
+ "maxDuration"
217
+ ]);
218
+ return duration === void 0 || duration.kind !== "value" || duration.raw === String(maxDuration) ? withKeys : replaced(withKeys, duration, maxDuration);
219
+ };
220
+ /** A project's `vercel.json` with Git's rewrite, functions and cron in it, at the plan's limits. */
221
+ const mergeVercel = (text, choices, next) => {
222
+ const { rewrite, functions, cron } = vercelParts(choices, next);
223
+ const { maxDuration } = limitsOf(choices);
224
+ return [
225
+ (from) => rewrite === void 0 ? from : withRewrite(from, rewrite),
226
+ ...Object.entries(functions).map(([path, wanted]) => (from) => withFunction(from, path, wanted, maxDuration)),
227
+ (from) => withItem(from, "crons", "path", cron, "schedule")
228
+ ].reduce((from, step) => step(from), text);
229
+ };
230
+ /** Git's packages and the store's and bucket's clients, as `package.json` names them. */
231
+ const dependenciesOf = (choices, vendor) => {
232
+ const { records, bucket } = partsOf(choices);
233
+ const named = [...records.dependencies, ["@ref0/git", specOf("@ref0/git", vendor)]];
234
+ if (choices.serve === "github") named.push(["@ref0/github", specOf("@ref0/github", vendor)]);
235
+ named.push(["@ref0/infra", specOf("@ref0/infra", vendor)], ...bucket?.dependencies ?? []);
236
+ if (choices.bucket === "vercel-blob") named.push(["@vercel/blob", vercelPackages["@vercel/blob"]]);
237
+ named.push(["@vercel/queue", vercelPackages["@vercel/queue"]]);
238
+ return Object.fromEntries(named);
239
+ };
240
+ /** The types `src/git.ts` is checked with. */
241
+ const devDependenciesOf = (choices) => {
242
+ const { records } = partsOf(choices);
243
+ const named = [
244
+ ["@types/node", vercelPackages["@types/node"]],
245
+ ...records.devDependencies,
246
+ ["typescript", vercelPackages.typescript]
247
+ ];
248
+ return Object.fromEntries(named);
249
+ };
250
+ const mergePackage = (choices, name, vendor) => (current) => {
251
+ if (current === void 0) {
252
+ const made = {
253
+ name,
254
+ private: true,
255
+ type: "module",
256
+ dependencies: dependenciesOf(choices, vendor),
257
+ devDependencies: devDependenciesOf(choices)
258
+ };
259
+ return withCli(`${JSON.stringify(made, null, 2)}\n`, vendor);
260
+ }
261
+ return withEntries(withCli(withDependencies(current, dependenciesOf(choices, vendor)), vendor), ["devDependencies"], devDependenciesOf(choices));
262
+ };
263
+ /**
264
+ * The next step's words: each variable set for Production, which the deploy runs, by
265
+ * `vercel env add <name> production`, after the Storage tab makes Postgres and Blob. `vercel env
266
+ * pull` brings Development's to `.env.local`, which is what `doctor` reads.
267
+ */
268
+ const nextOf = (choices) => {
269
+ const stores = [choices.records === "postgres" && "Postgres", choices.bucket === "vercel-blob" && "Blob"].filter(Predicate.isString);
270
+ const added = [
271
+ ...unsetOf(choices),
272
+ "ADMIN_TOKEN",
273
+ "CRON_SECRET"
274
+ ].map((name) => `\`vercel env add ${name} production\``);
275
+ const storage = stores.length === 0 ? "" : `Add ${stores.join(" and ")} from the project's Storage tab, then s`;
276
+ return `${storage === "" ? "S" : storage}et each variable for Production: ${added.join(", ")}. Link the folder, pull Development's with \`vercel env pull\`, then check it`;
277
+ };
278
+ /** Everything `init` writes for `choices` on Vercel, with `secret` making each new secret. */
279
+ const vercelOutput = (choices, project, secret, vendor) => {
280
+ const next = project.framework?.name === "next" ? project.framework : void 0;
281
+ const { maxDuration } = limitsOf(choices);
282
+ const config = next === void 0 ? {
283
+ files: [],
284
+ manual: []
285
+ } : nextConfigOutput(choices, next, project.created === true);
286
+ const routeFiles = next === void 0 ? [
287
+ {
288
+ path: routes.git,
289
+ kind: "whole",
290
+ text: gitRoute(choices)
291
+ },
292
+ {
293
+ path: routes.jobs,
294
+ kind: "whole",
295
+ text: jobsRoute
296
+ },
297
+ {
298
+ path: "api/jobs/sweep.ts",
299
+ kind: "whole",
300
+ text: sweepRoute
301
+ }
302
+ ] : [...nextRouteFiles(choices, next, maxDuration), ...nextJobFiles(next, maxDuration)];
303
+ return {
304
+ files: [
305
+ {
306
+ path: "vercel.json",
307
+ kind: "merge",
308
+ merge: (current) => current === void 0 ? vercelConfig(choices, next) : mergeVercel(current, choices, next)
309
+ },
310
+ {
311
+ path: "package.json",
312
+ kind: "merge",
313
+ merge: (current) => withCreatedTypes(project.created)(mergePackage(choices, project.name, vendor)(current))
314
+ },
315
+ {
316
+ path: next?.serverModule ?? "src/git.ts",
317
+ kind: "whole",
318
+ text: vercelGitModule(choices, next)
319
+ },
320
+ ...routeFiles,
321
+ ...config.files,
322
+ {
323
+ path: ".env.example",
324
+ kind: "whole",
325
+ text: envExample(["What src/git.ts reads. Set each in the project's Environment Variables; `vercel env pull`", "writes them to .env.local, and `init` made ADMIN_TOKEN and CRON_SECRET in .env."], variablesOf(choices))
326
+ },
327
+ {
328
+ path: ".env",
329
+ kind: "merge",
330
+ secrets: ["ADMIN_TOKEN", "CRON_SECRET"],
331
+ merge: (current) => withLines(current, [`ADMIN_TOKEN=${Redacted.value(secret())}`, `CRON_SECRET=${Redacted.value(secret())}`], (line) => line.split("=")[0] ?? "")
332
+ },
333
+ {
334
+ path: ".gitignore",
335
+ kind: "merge",
336
+ merge: (current) => ignoring(current, ["node_modules", ".vercel"], secretFiles)
337
+ }
338
+ ],
339
+ manual: [...rewriteSteps(project.vercelJson, choices, next), ...config.manual],
340
+ packages: [
341
+ "@ref0/git",
342
+ ...choices.serve === "github" ? ["@ref0/github"] : [],
343
+ "@ref0/infra"
344
+ ],
345
+ secret: "ADMIN_TOKEN and CRON_SECRET, made for vercel dev, in .env",
346
+ needs: unsetOf(choices),
347
+ next: nextOf(choices)
348
+ };
349
+ };
350
+ /**
351
+ * What `doctor` finds wrong in a `vercel.json` against `choices`: the rewrite to `api/git`, each
352
+ * function's `maxDuration` at the plan's, the queue's trigger on `api/jobs.ts`, and the cron.
353
+ */
354
+ const vercelProblems = (text, choices, next) => {
355
+ if (text === void 0) return ["vercel.json is missing"];
356
+ const tree = parseJsonc(text);
357
+ if (tree === void 0) return ["vercel.json isn't JSON"];
358
+ const { rewrite, cron } = vercelParts(choices, next);
359
+ const { maxDuration } = limitsOf(choices);
360
+ const jobsRoute = next === void 0 ? routes.jobs : nextJobRoutes(next).jobs;
361
+ const rewrites = itemsAt(tree, ["rewrites"]);
362
+ const gitAt = rewrite === void 0 ? 0 : rewrites.findIndex((each) => stringAt(each, ["destination"]) === rewrite.destination && stringAt(each, ["source"]) === rewrite.source);
363
+ const longest = (path) => {
364
+ const found = nodeAt(tree, [
365
+ "functions",
366
+ path,
367
+ "maxDuration"
368
+ ]);
369
+ return found?.kind === "value" ? Number(found.raw) : void 0;
370
+ };
371
+ const triggered = itemsAt(tree, [
372
+ "functions",
373
+ jobsRoute,
374
+ "experimentalTriggers"
375
+ ]).some((each) => stringAt(each, ["type"])?.startsWith("queue/") === true && stringAt(each, ["topic"]) === "git-jobs");
376
+ const schedule = itemsAt(tree, ["crons"]).filter((each) => stringAt(each, ["path"]) === cron.path).map((each) => stringAt(each, ["schedule"]))[0];
377
+ return [
378
+ ...gitAt === -1 && rewrite !== void 0 ? [`no rewrite of ${rewrite.source} to ${rewrite.destination}`] : gitAt > 0 ? [`a rewrite comes before Git's, so it takes Git's URLs first: move Git's to the top`] : [],
379
+ ...(next === void 0 ? [routes.git, routes.jobs] : []).flatMap((path) => longest(path) === maxDuration ? [] : [`${path}'s maxDuration isn't ${maxDuration}`]),
380
+ ...triggered ? [] : [`${jobsRoute} has no queue trigger on ${topic}`],
381
+ ...schedule === void 0 ? [`no cron calls ${cron.path}`] : schedule === cron.schedule ? [] : [`the cron on ${cron.path} runs at ${schedule}, not ${cron.schedule}`]
382
+ ];
383
+ };
384
+ export { mergeVercel, planLimits, routes, secretFiles, topic, variablesOf, vercelGitModule, vercelOutput, vercelProblems };
@@ -0,0 +1,32 @@
1
+ import { catalog, frameworkPackages, nodeAppPackages, nodePackages, release, storePackages, vercelPackages } from "./metadata.mjs";
2
+ // src/init/versions.ts
3
+ /**
4
+ * The versions `init` writes, pinned exactly, since npm ignores pnpm's lockfile: Git's packages at
5
+ * this release's own, and each other at the catalog's that this release was tested with. They're
6
+ * `metadata.ts`'s, which `scripts/cli-metadata.ts` writes from the manifests and the catalogs.
7
+ */
8
+ /**
9
+ * How `package.json` names one of Git's packages, or `ref0-git`: at this release, or from the
10
+ * tarball `--from-checkout` packed of it, at the checkout's own version.
11
+ */
12
+ const specOf = (name, vendor) => {
13
+ if (vendor === void 0) return release;
14
+ const path = vendor.get(name);
15
+ if (path === void 0) throw new Error(`--from-checkout packed no ${name}`);
16
+ return `file:${path}`;
17
+ };
18
+ /**
19
+ * The tarball path `--from-checkout` writes for `name` at any version, as `pnpm pack` names it:
20
+ * Git's packages in `vendor/`, and `ref0-git` in `vendor/cli/`, since `@ref0/git`'s has its name.
21
+ */
22
+ const packedPath = (name) => {
23
+ const file = name.replace("@", "").replace("/", "-").replaceAll(".", "\\.");
24
+ return new RegExp(`^file:vendor/${name === "ref0-git" ? "cli/" : ""}${file}-v?\\d[^/]*\\.tgz$`, "u");
25
+ };
26
+ /**
27
+ * Whether `init` wrote `spec` for `name`, one of Git's packages or `ref0-git`, from either source:
28
+ * the release, or the tarball `--from-checkout` names for that package. One it wrote moves to this
29
+ * run's spec; any other is the person's, a tarball of their own in `vendor/` too, and stays.
30
+ */
31
+ const initWrote = (name, spec) => spec === "0.3.0" || spec !== void 0 && packedPath(name).test(spec);
32
+ export { catalog, frameworkPackages, initWrote, nodeAppPackages, nodePackages, release, specOf, storePackages, vercelPackages };
@@ -0,0 +1,20 @@
1
+ // src/init/workspace.ts
2
+ /**
3
+ * `pnpm-workspace.yaml`'s blocks, read line by line: what `init` writes into a project's
4
+ * `package.json`, and what `scripts/cli-metadata.ts` reads the catalogs' versions from. It imports
5
+ * nothing, so the script can read the workspace before the metadata it writes exists.
6
+ */
7
+ /** The indented lines under a top-level key of `pnpm-workspace.yaml`. */
8
+ const blockOf = (workspace, key) => {
9
+ const all = workspace.split("\n");
10
+ const start = all.indexOf(`${key}:`);
11
+ if (start === -1) return [];
12
+ const end = all.findIndex((line, at) => at > start && /^\S/.test(line));
13
+ return all.slice(start + 1, end === -1 ? void 0 : end);
14
+ };
15
+ /** The workspace's versions by package name, from `pnpm-workspace.yaml`'s `catalog:` block. */
16
+ const catalogOf = (workspace) => new Map(blockOf(workspace, "catalog").flatMap((line) => {
17
+ const entry = /^ {2}'?([^':#\s][^':]*)'?: '?([^'\s]+)'?$/.exec(line);
18
+ return entry === null ? [] : [[entry[1] ?? "", entry[2] ?? ""]];
19
+ }));
20
+ export { blockOf, catalogOf };
package/package.json CHANGED
@@ -1,13 +1,55 @@
1
1
  {
2
2
  "name": "ref0-git",
3
- "version": "0.0.0",
4
- "description": "ref0's Git CLI. Reserved: the first release is coming.",
3
+ "version": "0.3.0",
4
+ "private": false,
5
+ "description": "ref0-git, the CLI for a Git host built on @ref0/git, and git-remote-ref0, its remote helper",
5
6
  "license": "Apache-2.0",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "git+https://github.com/ref-0/git.git"
9
+ "url": "git+https://github.com/ref-0/git.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "bin": {
13
+ "git-remote-ref0": "./dist/cli/git-remote-ref0.mjs",
14
+ "ref0-git": "./dist/cli/ref0-git.mjs"
9
15
  },
10
16
  "files": [
11
- "README.md"
12
- ]
13
- }
17
+ "app",
18
+ "dist"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ "./package.json": "./package.json"
24
+ },
25
+ "dependencies": {
26
+ "@effect/platform-node-shared": "4.1.4",
27
+ "@ref0/git": "0.3.0",
28
+ "@ref0/infra": "0.3.0",
29
+ "diff": "9.0.0",
30
+ "effect": "4.1.4"
31
+ },
32
+ "devDependencies": {
33
+ "@cloudflare/workers-types": "5.20261116.1",
34
+ "@effect/vitest": "4.1.4",
35
+ "@libsql/client": "0.18.0",
36
+ "@libsql/kysely-libsql": "0.4.1",
37
+ "@ref0/github": "0.3.0",
38
+ "@tanstack/react-start": "1.169.5",
39
+ "@types/node": "24.19.2",
40
+ "@types/pg": "8.23.1",
41
+ "@types/semver": "7.8.0",
42
+ "@vercel/blob": "2.9.0",
43
+ "@vercel/queue": "0.11.0",
44
+ "ajv": "8.20.0",
45
+ "h3": "1.15.11",
46
+ "kysely": "0.29.9",
47
+ "nitro": "3.0.261103-rc",
48
+ "path-to-regexp": "6.3.0",
49
+ "pg": "8.23.1",
50
+ "semver": "7.8.6",
51
+ "vite-plus": "1.7.0",
52
+ "vitest": "5.1.0"
53
+ },
54
+ "scripts": {}
55
+ }
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # ref0-git
2
-
3
- The command-line tool for `@ref0/git`, run as `npx ref0-git <command>`.
4
-
5
- This version holds the name and does nothing yet. Follow https://github.com/ref-0/git for the first release.