ref0-git 0.0.0 → 0.2.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 +122 -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 +547 -0
  197. package/app/apps/github/src/palette/recent.ts +116 -0
  198. package/app/apps/github/src/palette/rows.tsx +455 -0
  199. package/app/apps/github/src/palette/server.ts +104 -0
  200. package/app/apps/github/src/palette/targets.ts +306 -0
  201. package/app/apps/github/src/policy.ts +600 -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 +538 -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 +48 -0
  336. package/dist/cli/helpers.mjs +51 -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 +79 -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 +75 -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 +205 -0
  368. package/dist/init/node-app.mjs +189 -0
  369. package/dist/init/node.mjs +458 -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 +383 -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,468 @@
1
+ import type { components } from '@octokit/openapi-types';
2
+ import {
3
+ queryOptions,
4
+ skipToken,
5
+ type InfiniteData,
6
+ type QueryClient,
7
+ } from '@tanstack/react-query';
8
+
9
+ import { git, github, mutate } from '../clients/clients.ts';
10
+ import type { RepoPlace } from '../code/places.ts';
11
+ import { rowOf, type CommitRow } from '../code/refs.ts';
12
+ import type { MergeMethod } from '../code/repo.ts';
13
+ import { everyPage, failure } from '../hooks/answers.ts';
14
+ import { picturesOf } from '../hooks/avatars.ts';
15
+ import {
16
+ issueHolding,
17
+ pagesWith,
18
+ withShown,
19
+ type Change,
20
+ type Changing,
21
+ type Holding,
22
+ } from '../issues/changes.ts';
23
+ import { issueOf } from '../issues/issues.ts';
24
+ import type { Protection } from './merge-button.ts';
25
+ import { pullLists, reviewsRead, type Pull, type PullPage } from './pulls.ts';
26
+
27
+ type RestPull = components['schemas']['pull-request'];
28
+
29
+ /** A branch a pull request is between, and the commit it named when the page read it. */
30
+ export interface Side {
31
+ readonly ref: string;
32
+ readonly sha: string;
33
+ }
34
+
35
+ /** A pull request in the fields its page reads. */
36
+ export interface PullDetail extends Pull {
37
+ readonly mergedBy: string | null;
38
+ /** Whether it merges cleanly, or `null` while the drop-in works it out (Q379). */
39
+ readonly mergeable: boolean | null;
40
+ readonly base: Side;
41
+ readonly head: Side;
42
+ readonly commits: number;
43
+ readonly additions: number;
44
+ readonly deletions: number;
45
+ readonly changedFiles: number;
46
+ /** Whose reviews are asked for and not yet given. */
47
+ readonly requested: readonly string[];
48
+ /** Its GraphQL node ID, which the queue's mutations name it by. */
49
+ readonly nodeId: string;
50
+ }
51
+
52
+ const detailOf = (pull: RestPull): PullDetail => {
53
+ const issue = issueOf(pull);
54
+
55
+ return {
56
+ ...issue,
57
+ pictures: new Map([...issue.pictures, ...picturesOf([pull.merged_by])]),
58
+ draft: pull.draft ?? false,
59
+ merged: pull.merged_at,
60
+ mergedBy: pull.merged_by?.login ?? null,
61
+ mergeable: pull.mergeable,
62
+ base: { ref: pull.base.ref, sha: pull.base.sha },
63
+ head: { ref: pull.head.ref, sha: pull.head.sha },
64
+ commits: pull.commits,
65
+ additions: pull.additions,
66
+ deletions: pull.deletions,
67
+ changedFiles: pull.changed_files,
68
+ requested: (pull.requested_reviewers ?? []).map((user) => user.login),
69
+ nodeId: pull.node_id,
70
+ };
71
+ };
72
+
73
+ /** How often the page asks again while the drop-in works out whether a pull request merges. */
74
+ const mergeablePoll = 2_000;
75
+
76
+ /** How often a commit's checks are read again while a page shows them. */
77
+ export const checksPoll = 5_000;
78
+
79
+ /** The pull request `number`, or `null` when the viewer can read none there. */
80
+ export const pullAt = (place: RepoPlace, number: number) =>
81
+ queryOptions({
82
+ queryKey: ['pull', place.owner, place.repo, number],
83
+ queryFn: async (): Promise<PullDetail | null> => {
84
+ const answer = await github.GET('/repos/{owner}/{repo}/pulls/{pull_number}', {
85
+ params: { path: { ...place, pull_number: number } },
86
+ });
87
+ if (answer.response.status === 404) return null;
88
+
89
+ if (answer.data === undefined) throw failure("The pull request didn't load", answer);
90
+
91
+ return detailOf(answer.data);
92
+ },
93
+ staleTime: 10_000,
94
+ // A job works mergeability out after the page first asks, so it asks again until it's known.
95
+ refetchInterval: ({ state }) =>
96
+ state.data?.state === 'open' && state.data.mergeable === null ? mergeablePoll : false,
97
+ });
98
+
99
+ /**
100
+ * Reads pull request `number` again, and the issue and pull request lists, whose rows and filters
101
+ * hold it, after a change to it.
102
+ */
103
+ export const refreshPull = (client: QueryClient, place: RepoPlace, number: number) =>
104
+ Promise.all([
105
+ client.invalidateQueries({ queryKey: pullAt(place, number).queryKey }),
106
+ client.invalidateQueries({ queryKey: ['issues', place.owner, place.repo] }),
107
+ client.invalidateQueries({ queryKey: ['pulls', place.owner, place.repo] }),
108
+ ]);
109
+
110
+ export const reviewsOf = (place: RepoPlace, pull: number) =>
111
+ queryOptions({
112
+ queryKey: ['pull-reviews', place.owner, place.repo, pull],
113
+ queryFn: async () => (await reviewsRead(place, pull)).rows,
114
+ staleTime: 10_000,
115
+ });
116
+
117
+ /**
118
+ * Where the pull request page holds the pull request `number`: its own read and its issue's, and
119
+ * the issue and pull request lists' rows.
120
+ */
121
+ export const pullHolding = (client: QueryClient, place: RepoPlace, number: number): Holding => {
122
+ const issue = issueHolding(client, place, number);
123
+ const listed = { queryKey: pullLists(place) };
124
+
125
+ return {
126
+ confirm: (shown) => {
127
+ issue.confirm(shown);
128
+ client.setQueryData(pullAt(place, number).queryKey, (pull) =>
129
+ pull === null || pull === undefined ? pull : withShown(pull, shown),
130
+ );
131
+ },
132
+ show: async (shown) => {
133
+ await issue.show(shown);
134
+ await client.cancelQueries(listed);
135
+ client.setQueriesData<InfiniteData<PullPage>>(listed, (pages) =>
136
+ pagesWith(
137
+ pages,
138
+ (page) => page.pulls,
139
+ (page, pulls) => ({ ...page, pulls }),
140
+ number,
141
+ shown,
142
+ ),
143
+ );
144
+ },
145
+ refreshed: [
146
+ ...issue.refreshed,
147
+ pullAt(place, number).queryKey,
148
+ ['pulls', place.owner, place.repo],
149
+ ],
150
+ };
151
+ };
152
+
153
+ /** Asks for the reviews of `logins`, or takes the asks back, in one call. */
154
+ const askReviews = async (
155
+ place: RepoPlace,
156
+ pull: number,
157
+ logins: readonly string[],
158
+ asked: boolean,
159
+ ) => {
160
+ const at = {
161
+ params: { path: { ...place, pull_number: pull } },
162
+ body: { reviewers: [...logins] },
163
+ };
164
+ const path = '/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers';
165
+ const answer = asked ? await github.POST(path, at) : await github.DELETE(path, at);
166
+ if (answer.error !== undefined) throw failure("The reviewers didn't change", answer);
167
+ };
168
+
169
+ const listed = new Intl.ListFormat('en', { type: 'conjunction' });
170
+
171
+ /**
172
+ * The pull request's reviewers set to `requested`, against whose reviews the drop-in last
173
+ * confirmed it asks for: one call asks those added, and one takes back those removed. Where one
174
+ * succeeds and the other fails, the success stands: only the failed part rolls back, and the
175
+ * toast names it.
176
+ */
177
+ export const reviewersChange = (changing: Changing, requested: readonly string[]): Change => ({
178
+ field: 'requested',
179
+ value: requested,
180
+ send: async () => {
181
+ const { client, place, number } = changing;
182
+ const confirmed = client.getQueryData(pullAt(place, number).queryKey)?.requested ?? [];
183
+ const added = requested.filter((login) => !confirmed.includes(login));
184
+ const removed = confirmed.filter((login) => !requested.includes(login));
185
+
186
+ const [asked, unasked] = await Promise.allSettled([
187
+ added.length === 0 ? undefined : askReviews(place, number, added, true),
188
+ removed.length === 0 ? undefined : askReviews(place, number, removed, false),
189
+ ]);
190
+ const kept =
191
+ unasked.status === 'fulfilled'
192
+ ? confirmed.filter((login) => !removed.includes(login))
193
+ : confirmed;
194
+ changing.holding.confirm({
195
+ field: 'requested',
196
+ value: asked.status === 'fulfilled' ? [...kept, ...added] : kept,
197
+ });
198
+
199
+ const failed = [
200
+ asked.status === 'rejected'
201
+ ? `Couldn't ask ${listed.format(added)} for ${added.length === 1 ? 'a review' : 'reviews'}`
202
+ : undefined,
203
+ unasked.status === 'rejected'
204
+ ? `Couldn't remove ${listed.format(removed)} as ${removed.length === 1 ? 'a reviewer' : 'reviewers'}`
205
+ : undefined,
206
+ ].filter((said) => said !== undefined);
207
+ const refused: unknown[] = [asked, unasked].flatMap((answer): unknown[] =>
208
+ answer.status === 'rejected' ? [answer.reason] : [],
209
+ );
210
+ if (failed.length > 0) throw new Error(failed.join('. '), { cause: refused[0] });
211
+ },
212
+ });
213
+
214
+ /** `pull`'s commits, oldest first, as many as GitHub lists: 250. */
215
+ export const pullCommitsOf = (place: RepoPlace, pull: number) =>
216
+ queryOptions({
217
+ queryKey: ['pull-commits', place.owner, place.repo, pull],
218
+ queryFn: async (): Promise<readonly CommitRow[]> => {
219
+ const read = await everyPage(async (after) => {
220
+ const answer = await github.GET('/repos/{owner}/{repo}/pulls/{pull_number}/commits', {
221
+ params: { path: { ...place, pull_number: pull }, query: { ...{ per_page: 100, after } } },
222
+ });
223
+ if (answer.data === undefined) throw failure("The commits didn't load", answer);
224
+
225
+ return { rows: answer.data.map(rowOf), link: answer.response.headers.get('link') };
226
+ });
227
+
228
+ return read.rows;
229
+ },
230
+ staleTime: 10_000,
231
+ });
232
+
233
+ /** A check on a commit: a status's context or a check run, and where it stands. */
234
+ export interface Check {
235
+ readonly name: string;
236
+ readonly state: 'pending' | 'success' | 'failure' | 'neutral';
237
+ readonly description: string | null;
238
+ readonly url: string | null;
239
+ }
240
+
241
+ type RunConclusion = components['schemas']['check-run']['conclusion'];
242
+
243
+ /** A check run's state, as the merge box counts it: neutral and skipped pass no one by. */
244
+ const runState = (status: string, conclusion: RunConclusion): Check['state'] => {
245
+ if (status !== 'completed') return 'pending';
246
+
247
+ if (conclusion === 'success') return 'success';
248
+
249
+ return conclusion === 'neutral' || conclusion === 'skipped' ? 'neutral' : 'failure';
250
+ };
251
+
252
+ /**
253
+ * A check's link, which whoever reported it wrote: only a web page's, so a `javascript:` URL
254
+ * never becomes a link.
255
+ */
256
+ const webUrl = (url: string | null | undefined) => {
257
+ const parsed = url === null || url === undefined ? null : URL.parse(url);
258
+
259
+ return parsed !== null && (parsed.protocol === 'https:' || parsed.protocol === 'http:')
260
+ ? parsed.href
261
+ : null;
262
+ };
263
+
264
+ /** A commit status's state, as the merge box counts it: an error fails. */
265
+ const statusState = (state: string): Check['state'] => {
266
+ if (state === 'success') return 'success';
267
+
268
+ return state === 'pending' ? 'pending' : 'failure';
269
+ };
270
+
271
+ /** The checks on `sha`: its statuses' latest by context, and its check runs, every page, by name. */
272
+ export const checksOf = (place: RepoPlace, sha: string) =>
273
+ queryOptions({
274
+ queryKey: ['checks', place.owner, place.repo, sha],
275
+ queryFn: async (): Promise<readonly Check[]> => {
276
+ const path = { path: { ...place, ref: sha } };
277
+ // `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
278
+ const [fromStatuses, fromRuns] = await Promise.all([
279
+ everyPage(async (after) => {
280
+ const answer = await github.GET('/repos/{owner}/{repo}/commits/{ref}/status', {
281
+ params: { ...path, query: { ...{ per_page: 100, after } } },
282
+ });
283
+ if (answer.data === undefined) throw failure("The statuses didn't load", answer);
284
+
285
+ const rows = answer.data.statuses.map((status): Check => ({
286
+ name: status.context,
287
+ state: statusState(status.state),
288
+ description: status.description,
289
+ url: webUrl(status.target_url),
290
+ }));
291
+
292
+ return { rows, link: answer.response.headers.get('link') };
293
+ }),
294
+ everyPage(async (after) => {
295
+ const answer = await github.GET('/repos/{owner}/{repo}/commits/{ref}/check-runs', {
296
+ params: { ...path, query: { ...{ per_page: 100, after } } },
297
+ });
298
+ if (answer.data === undefined) throw failure("The check runs didn't load", answer);
299
+
300
+ const rows = answer.data.check_runs.map((run): Check => ({
301
+ name: run.name,
302
+ state: runState(run.status, run.conclusion),
303
+ description: run.output.title,
304
+ url: webUrl(run.details_url ?? run.html_url),
305
+ }));
306
+
307
+ return { rows, link: answer.response.headers.get('link') };
308
+ }),
309
+ ]);
310
+
311
+ return [...fromStatuses.rows, ...fromRuns.rows].toSorted((a, b) =>
312
+ a.name.localeCompare(b.name),
313
+ );
314
+ },
315
+ staleTime: 10_000,
316
+ });
317
+
318
+ /** `owner/name`, as Git's REST names a repo. */
319
+ export const repoId = (place: RepoPlace) => `${place.owner}/${place.repo}`;
320
+
321
+ /** A branch by its full ref name, as Git names it. */
322
+ export const branch = (name: string) => `refs/heads/${name}`;
323
+
324
+ /** Git's protection on the branch `base`, which says how it takes changes. */
325
+ export const protectionOf = (place: RepoPlace, base: string) =>
326
+ queryOptions({
327
+ queryKey: ['protection', place.owner, place.repo, base],
328
+ queryFn: async (): Promise<Protection> => {
329
+ const answer = await git.GET('/repos/{repo}/-/protection/{ref}', {
330
+ params: { path: { repo: repoId(place), ref: branch(base) } },
331
+ });
332
+ if (answer.error !== undefined) throw failure("The branch's protection didn't load", answer);
333
+
334
+ return answer.data ?? null;
335
+ },
336
+ staleTime: 30_000,
337
+ });
338
+
339
+ /** A pull request's place in its base's queue. */
340
+ export interface Queued {
341
+ readonly entry: string;
342
+ /** How many entries are tried before it. */
343
+ readonly ahead: number;
344
+ }
345
+
346
+ /** A pull request's key in the queue: the drop-in's own, so GitHub's events name it. */
347
+ export const queueKey = (pull: number) => `pr-${pull}`;
348
+
349
+ /** How many pages of 100 the page reads through a queue: Git holds at most 1,000 entries. */
350
+ const queuePages = 10;
351
+
352
+ /** Pull request `pull`'s entry in `base`'s queue while it's open there, or `null`. */
353
+ export const queuedOf = (place: RepoPlace, base: string, pull: number) =>
354
+ queryOptions({
355
+ queryKey: ['queued', place.owner, place.repo, base, pull],
356
+ queryFn: async (): Promise<Queued | null> => {
357
+ const first = { target: branch(base), limit: '100' };
358
+ let after: string | undefined;
359
+ let ahead = 0;
360
+
361
+ for (let page = 0; page < queuePages; page += 1) {
362
+ const answer = await git.GET('/repos/{repo}/-/queue/entries', {
363
+ params: {
364
+ path: { repo: repoId(place) },
365
+ query: after === undefined ? first : { ...first, after },
366
+ },
367
+ });
368
+ // A server with no queue answers `NOT_FOUND`: nothing's queued there.
369
+ if (answer.response.status === 404) return null;
370
+
371
+ if (answer.data === undefined) throw failure("The merge queue didn't load", answer);
372
+
373
+ const entries = answer.data.items;
374
+ const at = entries.findIndex((entry) => entry.key === queueKey(pull));
375
+ const entry = entries[at];
376
+ if (entry !== undefined) return { entry: entry.id, ahead: ahead + at };
377
+
378
+ ahead += entries.length;
379
+ after = answer.data.next;
380
+
381
+ if (after === undefined) return null;
382
+ }
383
+
384
+ return null;
385
+ },
386
+ staleTime: 10_000,
387
+ });
388
+
389
+ /**
390
+ * The queue entry the page last found pull request `pull` in, or the one adding it left there.
391
+ * Nothing reads it from a server: the merge box keeps it here so that a tab away, or the entry's read
392
+ * failing, doesn't lose a merge the queue made before the drop-in recorded it.
393
+ */
394
+ export const lastEntryOf = (place: RepoPlace, pull: number) =>
395
+ queryOptions<string>({
396
+ queryKey: ['queue-last-entry', place.owner, place.repo, pull],
397
+ queryFn: skipToken,
398
+ staleTime: Infinity,
399
+ gcTime: Infinity,
400
+ });
401
+
402
+ /** Where queue entry `entry` stands: waiting or checking in its queue, or ended, merged or not. */
403
+ export const entryStateOf = (entry: string) =>
404
+ queryOptions({
405
+ queryKey: ['queue-entry', entry],
406
+ queryFn: async () => {
407
+ const answer = await git.GET('/queue/entries/{entry}', { params: { path: { entry } } });
408
+ if (answer.data === undefined) throw failure("The queue's entry didn't load", answer);
409
+
410
+ return answer.data.state;
411
+ },
412
+ });
413
+
414
+ /** Merges `pull` by `method`, if its head is still `sha`. */
415
+ export const mergePull = async (
416
+ place: RepoPlace,
417
+ pull: number,
418
+ merging: { readonly method: MergeMethod; readonly sha: string },
419
+ ) => {
420
+ const answer = await github.PUT('/repos/{owner}/{repo}/pulls/{pull_number}/merge', {
421
+ params: { path: { ...place, pull_number: pull } },
422
+ body: { merge_method: merging.method, sha: merging.sha },
423
+ });
424
+ if (answer.data === undefined) throw failure("The pull request didn't merge", answer);
425
+ };
426
+
427
+ /**
428
+ * The app's GraphQL operations on the queue, as `packages/github`'s `graphql/fixtures/app/` holds
429
+ * them, so the drop-in's served schema is held to them (Q527).
430
+ */
431
+ export const queueOperations = {
432
+ enqueue: `mutation EnqueuePullRequest($pullRequestId: ID!, $expectedHeadOid: GitObjectID) {
433
+ enqueuePullRequest(input: { pullRequestId: $pullRequestId, expectedHeadOid: $expectedHeadOid }) {
434
+ mergeQueueEntry {
435
+ id
436
+ state
437
+ }
438
+ }
439
+ }
440
+ `,
441
+ dequeue: `mutation DequeuePullRequest($id: ID!) {
442
+ dequeuePullRequest(input: { id: $id }) {
443
+ mergeQueueEntry {
444
+ id
445
+ state
446
+ }
447
+ }
448
+ }
449
+ `,
450
+ } as const;
451
+
452
+ /**
453
+ * Adds `pull` to its base's merge queue at the head the page shows, through the drop-in's
454
+ * `enqueuePullRequest`, as `gh` does: the drop-in records the entry, sends `enqueued` and opens
455
+ * its merge group, and closes the pull request once it merges (Q527). A head that moved since the
456
+ * page read it is refused, and nothing joins.
457
+ */
458
+ export const enqueuePull = (pull: PullDetail) =>
459
+ mutate("The pull request wasn't added to the queue", queueOperations.enqueue, {
460
+ pullRequestId: pull.nodeId,
461
+ expectedHeadOid: pull.head.sha,
462
+ });
463
+
464
+ /** Takes `pull` out of its base's merge queue through the drop-in's `dequeuePullRequest` (Q527). */
465
+ export const dequeuePull = (pull: Pick<PullDetail, 'nodeId'>) =>
466
+ mutate("The pull request wasn't taken out of the queue", queueOperations.dequeue, {
467
+ id: pull.nodeId,
468
+ });