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,46 @@
1
+ -- Better Auth 1.7.19's tables, with @better-auth/passkey's and the organization plugin's, for the
2
+ -- starter's options in src/signin/auth.ts, on Postgres: people by their login (username), their
3
+ -- password accounts and passkeys, sessions with each one's sealed Git token, orgs and their
4
+ -- members, `owner_names`' claims on the logins people and orgs share, `avatar`'s pictures of
5
+ -- people, orgs and repos, and the rate limit's counts.
6
+ -- Written by Better Auth's getMigrations from those options on a database with no tables, as
7
+ -- credentials.test.ts checks, with `collate "C"` on the logins, `username` and `slug`, so a
8
+ -- search's range of their indexes is their prefix's; apply it once, before the app's first
9
+ -- start, as `psql -f` does.
10
+ create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" boolean not null, "image" text, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz default CURRENT_TIMESTAMP not null, "username" text collate "C" unique);
11
+
12
+ create table "session" ("id" text not null primary key, "expiresAt" timestamptz not null, "token" text not null unique, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade, "activeOrganizationId" text, "gitTokenId" text, "gitToken" text);
13
+
14
+ create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" timestamptz, "refreshTokenExpiresAt" timestamptz, "scope" text, "password" text, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz not null);
15
+
16
+ create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" timestamptz not null, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz default CURRENT_TIMESTAMP not null);
17
+
18
+ create table "passkey" ("id" text not null primary key, "name" text, "publicKey" text not null, "userId" text not null references "user" ("id") on delete cascade, "credentialID" text not null unique, "counter" integer not null, "deviceType" text not null, "backedUp" boolean not null, "transports" text, "createdAt" timestamptz, "aaguid" text);
19
+
20
+ create table "organization" ("id" text not null primary key, "name" text not null, "slug" text collate "C" not null unique, "logo" text, "createdAt" timestamptz not null, "metadata" text);
21
+
22
+ create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" timestamptz not null);
23
+
24
+ create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "status" text not null, "expiresAt" timestamptz not null, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "inviterId" text not null references "user" ("id") on delete cascade);
25
+
26
+ create table "owner_names" ("id" text not null primary key, "claim" text not null, "claimedAt" timestamptz not null, "held" boolean not null);
27
+
28
+ create table "avatar" ("id" text not null primary key, "kind" text not null, "type" text not null, "bytes" text not null, "size" integer not null, "hash" text not null, "updatedAt" timestamptz not null);
29
+
30
+ create table "rateLimit" ("id" text not null primary key, "key" text not null unique, "count" integer not null, "lastRequest" bigint not null);
31
+
32
+ create index "session_userId_idx" on "session" ("userId");
33
+
34
+ create index "account_userId_idx" on "account" ("userId");
35
+
36
+ create index "verification_identifier_idx" on "verification" ("identifier");
37
+
38
+ create index "passkey_userId_idx" on "passkey" ("userId");
39
+
40
+ create index "member_organizationId_idx" on "member" ("organizationId");
41
+
42
+ create index "member_userId_idx" on "member" ("userId");
43
+
44
+ create index "invitation_organizationId_idx" on "invitation" ("organizationId");
45
+
46
+ create index "invitation_email_idx" on "invitation" ("email");
@@ -0,0 +1,19 @@
1
+ -- Better Auth 1.7.19's tables for the starter's options in src/signin/auth.ts: people by their login
2
+ -- (username), their password accounts, sessions with each one's sealed Git token, and the
3
+ -- rate limit's counts. Written by Better Auth's getMigrations from those options; apply it with
4
+ -- `wrangler d1 migrations apply AUTH_DB`, --local for `npm run dev` or --remote once deployed.
5
+ create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null, "username" text unique);
6
+
7
+ create table "session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade, "gitTokenId" text, "gitToken" text);
8
+
9
+ create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null);
10
+
11
+ create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date not null, "updatedAt" date not null);
12
+
13
+ create table "rateLimit" ("id" text not null primary key, "key" text not null unique, "count" integer not null, "lastRequest" bigint not null);
14
+
15
+ create index "session_userId_idx" on "session" ("userId");
16
+
17
+ create index "account_userId_idx" on "account" ("userId");
18
+
19
+ create index "verification_identifier_idx" on "verification" ("identifier");
@@ -0,0 +1,9 @@
1
+ -- @better-auth/passkey 1.7.19's table for the starter's options in src/signin/auth.ts: each
2
+ -- person's passkeys, by the public key that checks them. Written by Better Auth's getMigrations
3
+ -- from those options, less 0001's tables. A credential ID is unique, since the plugin finds a
4
+ -- sign-in's passkey by it: the options' `unique-credential-id` plugin says so, and each dialect's
5
+ -- migration has it. Apply it as 0001 says.
6
+
7
+ create table "passkey" ("id" text not null primary key, "name" text, "publicKey" text not null, "userId" text not null references "user" ("id") on delete cascade, "credentialID" text not null unique, "counter" integer not null, "deviceType" text not null, "backedUp" integer not null, "transports" text, "createdAt" date, "aaguid" text);
8
+
9
+ create index "passkey_userId_idx" on "passkey" ("userId");
@@ -0,0 +1,22 @@
1
+ -- Better Auth 1.7.19's tables for orgs, added to 0001's and 0002's by the organization plugin in
2
+ -- src/signin/auth.ts: orgs by their login (slug), their members, the invitations the starter
3
+ -- turns off, each session's active org, and owner_names, the one namespace people's logins and
4
+ -- orgs' slugs share (Q631). Written by Better Auth's getMigrations from those options over 0002.
5
+ -- Apply it with `wrangler d1 migrations apply AUTH_DB`, as 0001.
6
+ alter table "session" add column "activeOrganizationId" text;
7
+
8
+ create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" date not null, "metadata" text);
9
+
10
+ create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" date not null);
11
+
12
+ create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "status" text not null, "expiresAt" date not null, "createdAt" date not null, "inviterId" text not null references "user" ("id") on delete cascade);
13
+
14
+ create table "owner_names" ("id" text not null primary key, "claim" text not null, "claimedAt" date not null, "held" integer not null);
15
+
16
+ create index "member_organizationId_idx" on "member" ("organizationId");
17
+
18
+ create index "member_userId_idx" on "member" ("userId");
19
+
20
+ create index "invitation_organizationId_idx" on "invitation" ("organizationId");
21
+
22
+ create index "invitation_email_idx" on "invitation" ("email");
@@ -0,0 +1,6 @@
1
+ -- The app's avatars, added to 0003's tables by the avatars plugin in src/signin/auth.ts: a person's,
2
+ -- an org's and a repo's picture in one table, each row under its kind and its owner's ID, as
3
+ -- `user:<id>`, `org:<id>` or `repo:<REST id>`, with its kind, sniffed type, bytes as base64, their
4
+ -- count and their SHA-256. Written by Better Auth's getMigrations from those options over 0003.
5
+ -- Apply it with `wrangler d1 migrations apply AUTH_DB`, as 0001.
6
+ create table "avatar" ("id" text not null primary key, "kind" text not null, "type" text not null, "bytes" text not null, "size" integer not null, "hash" text not null, "updatedAt" date not null);
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@ref0/github-app",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "The web app over Git and the GitHub drop-in: one Worker with TanStack Start",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "imports": {
9
+ "#/components/ui/*": "./src/components/ui/*.tsx",
10
+ "#/components/*": "./src/components/*.tsx",
11
+ "#/hooks/*": "./src/hooks/*.ts",
12
+ "#/lib/*": "./src/lib/*.ts"
13
+ },
14
+ "scripts": {
15
+ "dev": "vp dev",
16
+ "build": "vp build",
17
+ "deploy": "vp build && wrangler deploy",
18
+ "generate": "openapi-typescript ../../packages/git/docs/openapi.json -o generated/git-rest.ts"
19
+ },
20
+ "dependencies": {
21
+ "@base-ui/react": "catalog:",
22
+ "@better-auth/passkey": "catalog:",
23
+ "@dicebear/core": "catalog:",
24
+ "@dicebear/styles": "catalog:",
25
+ "@fontsource-variable/geist": "catalog:",
26
+ "@fontsource-variable/inter": "catalog:",
27
+ "@octokit/openapi-types": "catalog:",
28
+ "@pierre/diffs": "catalog:",
29
+ "@pierre/icons": "catalog:",
30
+ "@pierre/trees": "catalog:",
31
+ "@pierre/words": "catalog:",
32
+ "@ref0/git": "workspace:*",
33
+ "@ref0/github": "workspace:*",
34
+ "@ref0/infra": "workspace:*",
35
+ "@tanstack/react-query": "catalog:",
36
+ "@tanstack/react-router": "catalog:",
37
+ "@tanstack/react-router-ssr-query": "catalog:",
38
+ "@tanstack/react-start": "catalog:",
39
+ "better-auth": "catalog:",
40
+ "class-variance-authority": "catalog:",
41
+ "cmdk": "catalog:",
42
+ "cn": "catalog:",
43
+ "date-fns": "catalog:",
44
+ "diff": "catalog:",
45
+ "effect": "catalog:",
46
+ "github-slugger": "catalog:",
47
+ "kysely": "catalog:",
48
+ "lucide-react": "catalog:",
49
+ "openapi-fetch": "catalog:",
50
+ "openapi-react-query": "catalog:",
51
+ "pele": "catalog:",
52
+ "react": "catalog:",
53
+ "react-day-picker": "catalog:",
54
+ "react-dom": "catalog:",
55
+ "sonner": "catalog:"
56
+ },
57
+ "devDependencies": {
58
+ "@cloudflare/vite-plugin": "catalog:",
59
+ "@cloudflare/workers-types": "catalog:",
60
+ "@effect/vitest": "catalog:",
61
+ "@tailwindcss/vite": "catalog:",
62
+ "@types/better-sqlite3": "catalog:",
63
+ "@types/hast": "catalog:",
64
+ "@types/node": "catalog:",
65
+ "@types/react": "catalog:",
66
+ "@types/react-dom": "catalog:",
67
+ "@vitejs/plugin-react": "catalog:",
68
+ "better-sqlite3": "catalog:",
69
+ "fake-indexeddb": "catalog:",
70
+ "happy-dom": "catalog:",
71
+ "hast-util-from-html": "catalog:",
72
+ "openapi-typescript": "catalog:",
73
+ "shadcn": "catalog:",
74
+ "tailwindcss": "catalog:",
75
+ "tw-animate-css": "catalog:",
76
+ "typescript": "catalog:",
77
+ "vite-plus": "catalog:",
78
+ "wrangler": "catalog:"
79
+ }
80
+ }
@@ -0,0 +1,385 @@
1
+ import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { useNavigate } from '@tanstack/react-router';
3
+ import { GitBranchIcon, SearchIcon, Trash2Icon } from 'lucide-react';
4
+ import { useDeferredValue, useState, type FormEvent } from 'react';
5
+ import { toast } from 'sonner';
6
+
7
+ import { Go } from '../code/controls.tsx';
8
+ import { treeHref, type RepoPlace } from '../code/places.ts';
9
+ import { refPages, type RefRow } from '../code/ref-pages.ts';
10
+ import { More } from '../components/item-list.tsx';
11
+ import { RelativeTime } from '../components/relative-time.tsx';
12
+ import { Alert, AlertDescription } from '../components/ui/alert.tsx';
13
+ import {
14
+ AlertDialog,
15
+ AlertDialogCancel,
16
+ AlertDialogContent,
17
+ AlertDialogDescription,
18
+ AlertDialogFooter,
19
+ AlertDialogHeader,
20
+ AlertDialogTitle,
21
+ AlertDialogTrigger,
22
+ } from '../components/ui/alert-dialog.tsx';
23
+ import { Badge } from '../components/ui/badge.tsx';
24
+ import { Button } from '../components/ui/button.tsx';
25
+ import {
26
+ Combobox,
27
+ ComboboxContent,
28
+ ComboboxEmpty,
29
+ ComboboxInput,
30
+ ComboboxItem,
31
+ ComboboxList,
32
+ } from '../components/ui/combobox.tsx';
33
+ import {
34
+ Dialog,
35
+ DialogContent,
36
+ DialogDescription,
37
+ DialogFooter,
38
+ DialogHeader,
39
+ DialogTitle,
40
+ DialogTrigger,
41
+ } from '../components/ui/dialog.tsx';
42
+ import {
43
+ Empty,
44
+ EmptyDescription,
45
+ EmptyHeader,
46
+ EmptyMedia,
47
+ EmptyTitle,
48
+ } from '../components/ui/empty.tsx';
49
+ import { Field, FieldError, FieldGroup, FieldLabel } from '../components/ui/field.tsx';
50
+ import { Input } from '../components/ui/input.tsx';
51
+ import { InputGroup, InputGroupAddon, InputGroupInput } from '../components/ui/input-group.tsx';
52
+ import { Skeleton } from '../components/ui/skeleton.tsx';
53
+ import { UserAvatar } from '../components/user-avatar.tsx';
54
+ import { useAllowed } from '../hooks/allowed.ts';
55
+ import {
56
+ branchesPerPage,
57
+ createBranch,
58
+ deleteBranch,
59
+ forgetBranches,
60
+ listedBranches,
61
+ } from './branches.ts';
62
+ import { CreateButton } from '../components/create-button.tsx';
63
+ import { ListToolbar } from '../components/list-toolbar.tsx';
64
+
65
+ /** A branch's row: its name, the default's badge, its tip's author and age, and its delete. */
66
+ function BranchRow({
67
+ place,
68
+ row,
69
+ isDefault,
70
+ canDelete,
71
+ }: {
72
+ readonly place: RepoPlace;
73
+ readonly row: RefRow;
74
+ readonly isDefault: boolean;
75
+ readonly canDelete: boolean;
76
+ }) {
77
+ return (
78
+ <li className="flex min-h-14 items-center gap-3 px-4 py-2">
79
+ <div className="flex min-w-0 grow flex-col gap-1 sm:flex-row sm:items-center sm:gap-3">
80
+ <span className="flex min-w-0 items-center gap-2">
81
+ <Go
82
+ href={treeHref(place, row.name, '')}
83
+ className="font-mono text-sm font-semibold wrap-anywhere hover:underline"
84
+ >
85
+ {row.name}
86
+ </Go>
87
+ {isDefault && <Badge variant="secondary">Default</Badge>}
88
+ </span>
89
+ {row.author !== undefined && (
90
+ <span className="flex shrink-0 items-center gap-1.5 text-meta whitespace-nowrap text-muted-foreground sm:ml-auto">
91
+ Updated
92
+ <UserAvatar login={row.author.name} size="sm" account="user" />
93
+ <RelativeTime at={row.author.date} />
94
+ </span>
95
+ )}
96
+ </div>
97
+ {canDelete && !isDefault && <DeleteBranch place={place} name={row.name} />}
98
+ </li>
99
+ );
100
+ }
101
+
102
+ /**
103
+ * A branch's delete, which asks first in an AlertDialog. The dialog stays open until the server
104
+ * answers, so a refusal, such as a protected branch's, shows in it in the server's words.
105
+ */
106
+ function DeleteBranch({ place, name }: { readonly place: RepoPlace; readonly name: string }) {
107
+ const client = useQueryClient();
108
+ const [open, setOpen] = useState(false);
109
+ const remove = useMutation({
110
+ mutationFn: () => deleteBranch(place, name),
111
+ onSuccess: async () => {
112
+ setOpen(false);
113
+ toast.success(`Deleted ${name}`);
114
+ await forgetBranches(client, place);
115
+ },
116
+ });
117
+
118
+ return (
119
+ <AlertDialog
120
+ open={open}
121
+ onOpenChange={(next) => {
122
+ setOpen(next);
123
+ remove.reset();
124
+ }}
125
+ >
126
+ <AlertDialogTrigger
127
+ render={
128
+ <Button variant="destructive" size="icon-sm" aria-label={`Delete branch ${name}`} />
129
+ }
130
+ >
131
+ <Trash2Icon />
132
+ </AlertDialogTrigger>
133
+ <AlertDialogContent>
134
+ <AlertDialogHeader>
135
+ <AlertDialogTitle className="wrap-anywhere">Delete branch {name}?</AlertDialogTitle>
136
+ <AlertDialogDescription>
137
+ Its commits stay where another branch or tag reaches them. This can&apos;t be undone.
138
+ </AlertDialogDescription>
139
+ </AlertDialogHeader>
140
+ {remove.error !== null && (
141
+ <Alert variant="destructive">
142
+ <AlertDescription className="wrap-anywhere">{remove.error.message}</AlertDescription>
143
+ </Alert>
144
+ )}
145
+ <AlertDialogFooter>
146
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
147
+ <Button variant="destructive" disabled={remove.isPending} onClick={() => remove.mutate()}>
148
+ Delete branch
149
+ </Button>
150
+ </AlertDialogFooter>
151
+ </AlertDialogContent>
152
+ </AlertDialog>
153
+ );
154
+ }
155
+
156
+ /**
157
+ * New branch's dialog: a name, and "Branch from", which offers the page's branches until something
158
+ * is typed, then the server's matches for it, so a branch past the loaded pages can be picked here.
159
+ */
160
+ function NewBranch({
161
+ place,
162
+ from,
163
+ }: {
164
+ readonly place: RepoPlace;
165
+ readonly from: readonly RefRow[];
166
+ }) {
167
+ const client = useQueryClient();
168
+ const [open, setOpen] = useState(false);
169
+ const [name, setName] = useState('');
170
+ const loaded = from.filter((row) => row.commit !== undefined);
171
+ const [chosen, setChosen] = useState<RefRow | undefined>(undefined);
172
+ const picked = chosen ?? loaded[0];
173
+ const [typed, setTyped] = useState<string | undefined>(undefined);
174
+ const asked = useDeferredValue(typed ?? '');
175
+ const searching = asked !== '' && asked !== picked?.name;
176
+ const found = useInfiniteQuery({
177
+ ...refPages(place, { prefix: 'refs/heads/', first: branchesPerPage, search: asked }),
178
+ enabled: open && searching,
179
+ });
180
+ const matches = (found.data?.pages[0]?.rows ?? []).filter((row) => row.commit !== undefined);
181
+ const offered = searching ? matches : loaded;
182
+ const byName = new Map([...loaded, ...matches].map((row) => [row.name, row]));
183
+ const create = useMutation({
184
+ mutationFn: async () => {
185
+ if (picked?.commit === undefined) throw new Error('Pick a branch to start from');
186
+
187
+ await createBranch(place, name.trim(), picked.commit);
188
+ },
189
+ onSuccess: async () => {
190
+ setOpen(false);
191
+ toast.success(`Created ${name.trim()}`);
192
+ setName('');
193
+ await forgetBranches(client, place);
194
+ },
195
+ });
196
+
197
+ const submit = (event: FormEvent<HTMLFormElement>) => {
198
+ event.preventDefault();
199
+
200
+ if (name.trim() === '' || create.isPending) return;
201
+
202
+ create.mutate();
203
+ };
204
+
205
+ return (
206
+ <Dialog
207
+ open={open}
208
+ onOpenChange={(next) => {
209
+ setOpen(next);
210
+ setTyped(undefined);
211
+ create.reset();
212
+ }}
213
+ >
214
+ <DialogTrigger render={<CreateButton>New branch</CreateButton>} />
215
+ <DialogContent className="sm:max-w-md">
216
+ <DialogHeader>
217
+ <DialogTitle>Create a branch</DialogTitle>
218
+ <DialogDescription>It starts at the tip of the branch you pick.</DialogDescription>
219
+ </DialogHeader>
220
+ <form noValidate onSubmit={submit} className="flex flex-col gap-4">
221
+ <FieldGroup>
222
+ <Field data-invalid={create.isError}>
223
+ <FieldLabel htmlFor="branch-name">Name</FieldLabel>
224
+ <Input
225
+ id="branch-name"
226
+ autoComplete="off"
227
+ autoFocus
228
+ spellCheck={false}
229
+ aria-invalid={create.isError}
230
+ value={name}
231
+ onChange={(event) => {
232
+ setName(event.target.value);
233
+ create.reset();
234
+ }}
235
+ />
236
+ {create.isError && <FieldError>{create.error.message}</FieldError>}
237
+ </Field>
238
+ <Field>
239
+ <FieldLabel htmlFor="branch-from">Branch from</FieldLabel>
240
+ <Combobox
241
+ items={offered.map((row) => row.name)}
242
+ value={picked?.name ?? null}
243
+ onValueChange={(value: string | null) => {
244
+ const row = value === null ? undefined : byName.get(value);
245
+ if (row !== undefined) setChosen(row);
246
+ }}
247
+ inputValue={typed ?? picked?.name ?? ''}
248
+ onInputValueChange={setTyped}
249
+ autoHighlight
250
+ >
251
+ <ComboboxInput id="branch-from" className="w-full" spellCheck={false} />
252
+ <ComboboxContent>
253
+ <ComboboxEmpty>
254
+ {found.isFetching ? 'Searching…' : `No branches match ${asked}`}
255
+ </ComboboxEmpty>
256
+ <ComboboxList>
257
+ {(branch: string) => (
258
+ <ComboboxItem key={branch} value={branch}>
259
+ {branch}
260
+ </ComboboxItem>
261
+ )}
262
+ </ComboboxList>
263
+ </ComboboxContent>
264
+ </Combobox>
265
+ </Field>
266
+ </FieldGroup>
267
+ <DialogFooter>
268
+ <Button
269
+ type="submit"
270
+ disabled={name.trim() === '' || picked === undefined || create.isPending}
271
+ >
272
+ Create branch
273
+ </Button>
274
+ </DialogFooter>
275
+ </form>
276
+ </DialogContent>
277
+ </Dialog>
278
+ );
279
+ }
280
+
281
+ /** The branches page's search box: Enter goes to the page of names that contain its text. */
282
+ function BranchSearch({ place, search }: { readonly place: RepoPlace; readonly search: string }) {
283
+ const navigate = useNavigate();
284
+ const [text, setText] = useState(search);
285
+
286
+ return (
287
+ <form
288
+ role="search"
289
+ className="min-w-0"
290
+ onSubmit={(event) => {
291
+ event.preventDefault();
292
+ const q = text.trim();
293
+ void navigate({
294
+ to: '/$owner/$repo/branches',
295
+ params: place,
296
+ search: q === '' ? {} : { q },
297
+ });
298
+ }}
299
+ >
300
+ <InputGroup size="lg">
301
+ <InputGroupInput
302
+ name="q"
303
+ aria-label="Search branches"
304
+ placeholder="Search branches…"
305
+ value={text}
306
+ spellCheck={false}
307
+ onChange={(event) => setText(event.target.value)}
308
+ />
309
+ <InputGroupAddon>
310
+ <SearchIcon />
311
+ </InputGroupAddon>
312
+ </InputGroup>
313
+ </form>
314
+ );
315
+ }
316
+
317
+ /**
318
+ * The repo's branches, the default first, then 30 at a time by name as More reads them: each with
319
+ * its tip's author and age, and, for someone Git would let push, a delete and New branch. One call
320
+ * reads a page, a search's too.
321
+ */
322
+ export function BranchList({
323
+ place,
324
+ search,
325
+ }: {
326
+ readonly place: RepoPlace;
327
+ readonly search: string;
328
+ }) {
329
+ const allowed = useAllowed(place);
330
+ const canPush = allowed.has('push');
331
+ const pages = useInfiniteQuery(
332
+ refPages(place, { prefix: 'refs/heads/', first: branchesPerPage, search }),
333
+ );
334
+ const read = pages.data?.pages ?? [];
335
+ const rows = read.flatMap((page, index) => listedBranches(page, index === 0, search));
336
+ const main = read[0]?.defaultBranch;
337
+ const from = main === undefined ? rows : [main, ...rows.filter((row) => row.name !== main.name)];
338
+
339
+ return (
340
+ <div className="flex flex-col gap-3">
341
+ <ListToolbar
342
+ search={<BranchSearch key={search} place={place} search={search} />}
343
+ buttons={canPush ? <NewBranch place={place} from={from} /> : undefined}
344
+ />
345
+ {pages.error !== null ? (
346
+ <Alert variant="destructive">
347
+ <AlertDescription>{pages.error.message}. Reload the page to try again.</AlertDescription>
348
+ </Alert>
349
+ ) : pages.data === undefined ? (
350
+ <Skeleton className="h-40" />
351
+ ) : rows.length === 0 ? (
352
+ <Empty>
353
+ <EmptyHeader>
354
+ <EmptyMedia variant="icon">
355
+ <GitBranchIcon />
356
+ </EmptyMedia>
357
+ <EmptyTitle>
358
+ {search === '' ? 'No branches here' : `No branches match ${search}`}
359
+ </EmptyTitle>
360
+ <EmptyDescription>
361
+ {search === ''
362
+ ? 'A branch names a line of commits, such as the default one.'
363
+ : 'Search finds branches whose names contain the text.'}
364
+ </EmptyDescription>
365
+ </EmptyHeader>
366
+ </Empty>
367
+ ) : (
368
+ <div className="rounded-lg border">
369
+ <ul aria-label="Branches" className="divide-y">
370
+ {rows.map((row) => (
371
+ <BranchRow
372
+ key={row.name}
373
+ place={place}
374
+ row={row}
375
+ isDefault={row.name === main?.name}
376
+ canDelete={canPush}
377
+ />
378
+ ))}
379
+ </ul>
380
+ <More pages={pages} label="More branches" />
381
+ </div>
382
+ )}
383
+ </div>
384
+ );
385
+ }
@@ -0,0 +1,55 @@
1
+ import type { QueryClient } from '@tanstack/react-query';
2
+
3
+ import { github } from '../clients/clients.ts';
4
+ import type { RepoPlace } from '../code/places.ts';
5
+ import type { RefPage, RefRow } from '../code/ref-pages.ts';
6
+ import { failure } from '../hooks/answers.ts';
7
+
8
+ /** How many branches a page reads, as the app's other lists' pages, More reading the next. */
9
+ export const branchesPerPage = 30;
10
+
11
+ /**
12
+ * A page's rows as the branches page lists them: the default branch first on the first page,
13
+ * unless a search is typed, then the rest by name, the default left out of every page after it so
14
+ * it shows once.
15
+ */
16
+ export const listedBranches = (
17
+ page: RefPage,
18
+ first: boolean,
19
+ search: string,
20
+ ): readonly RefRow[] => {
21
+ const main = page.defaultBranch;
22
+ if (search !== '' || main === undefined) return page.rows;
23
+
24
+ const rest = page.rows.filter((row) => row.name !== main.name);
25
+
26
+ return first ? [main, ...rest] : rest;
27
+ };
28
+
29
+ /** Makes branch `name` at commit `sha`: GitHub's `POST git/refs`, or its refusal's words. */
30
+ export const createBranch = async (place: RepoPlace, name: string, sha: string) => {
31
+ const answer = await github.POST('/repos/{owner}/{repo}/git/refs', {
32
+ params: { path: place },
33
+ body: { ref: `refs/heads/${name}`, sha },
34
+ });
35
+ if (answer.data === undefined) throw failure("The branch wasn't made", answer);
36
+ };
37
+
38
+ /**
39
+ * Deletes branch `name`: GitHub's `DELETE git/refs`, or its refusal's words, such as a protected
40
+ * branch's.
41
+ */
42
+ export const deleteBranch = async (place: RepoPlace, name: string) => {
43
+ const answer = await github.DELETE('/repos/{owner}/{repo}/git/refs/{ref}', {
44
+ params: { path: { ...place, ref: `heads/${name}` } },
45
+ });
46
+ if (!answer.response.ok) throw failure("The branch wasn't deleted", answer);
47
+ };
48
+
49
+ /** Forgets the repo's pages of refs and the ref switcher's names, which a change to a branch moves. */
50
+ export const forgetBranches = async (client: QueryClient, place: RepoPlace) => {
51
+ await Promise.all([
52
+ client.invalidateQueries({ queryKey: ['ref-pages', place.owner, place.repo] }),
53
+ client.invalidateQueries({ queryKey: ['refs', place.owner, place.repo] }),
54
+ ]);
55
+ };