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,529 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
+ import { format } from 'date-fns';
3
+ import { CalendarIcon, KeyRoundIcon } from 'lucide-react';
4
+ import { type FormEvent, useState } from 'react';
5
+
6
+ import { type TokenRecord, tokenRepos, tokensEach } from '../clients/host-calls.ts';
7
+ import { ConfirmAction } from '../components/confirm-action.tsx';
8
+ import { RepoIcon } from '../components/repos/repo-icon.tsx';
9
+ import { LoadFailed } from '../components/states/states.tsx';
10
+ import { Alert, AlertDescription, AlertTitle } from '../components/ui/alert.tsx';
11
+ import { Badge } from '../components/ui/badge.tsx';
12
+ import { Button } from '../components/ui/button.tsx';
13
+ import { Calendar } from '../components/ui/calendar.tsx';
14
+ import {
15
+ Dialog,
16
+ DialogContent,
17
+ DialogDescription,
18
+ DialogHeader,
19
+ DialogTitle,
20
+ DialogTrigger,
21
+ } from '../components/ui/dialog.tsx';
22
+ import {
23
+ Empty,
24
+ EmptyDescription,
25
+ EmptyHeader,
26
+ EmptyMedia,
27
+ EmptyTitle,
28
+ } from '../components/ui/empty.tsx';
29
+ import {
30
+ Combobox,
31
+ ComboboxContent,
32
+ ComboboxEmpty,
33
+ ComboboxInput,
34
+ ComboboxItem,
35
+ ComboboxList,
36
+ } from '../components/ui/combobox.tsx';
37
+ import {
38
+ Field,
39
+ FieldDescription,
40
+ FieldError,
41
+ FieldGroup,
42
+ FieldLabel,
43
+ FieldLegend,
44
+ FieldSet,
45
+ } from '../components/ui/field.tsx';
46
+ import { InputGroup, InputGroupAddon, InputGroupInput } from '../components/ui/input-group.tsx';
47
+ import { Popover, PopoverContent, PopoverTrigger } from '../components/ui/popover.tsx';
48
+ import { RadioGroup, RadioGroupItem } from '../components/ui/radio-group.tsx';
49
+ import {
50
+ Select,
51
+ SelectContent,
52
+ SelectGroup,
53
+ SelectItem,
54
+ SelectTrigger,
55
+ SelectValue,
56
+ } from '../components/ui/select.tsx';
57
+ import { Skeleton } from '../components/ui/skeleton.tsx';
58
+ import {
59
+ Table,
60
+ TableBody,
61
+ TableCell,
62
+ TableHead,
63
+ TableHeader,
64
+ TableRow,
65
+ } from '../components/ui/table.tsx';
66
+ import { CopyButton } from '../code/controls.tsx';
67
+ import { useRepos, type RepoFilter } from '../hooks/repos.ts';
68
+ import { repoProblem } from '../names/repos.ts';
69
+ import {
70
+ createToken,
71
+ dayAfter,
72
+ daysUntil,
73
+ expiryRange,
74
+ type NewToken,
75
+ revokeToken,
76
+ stateOf,
77
+ tokenList,
78
+ } from './tokens.ts';
79
+ import { CreateButton } from '../components/create-button.tsx';
80
+ import { ListToolbar } from '../components/list-toolbar.tsx';
81
+
82
+ const scopes = [
83
+ ['read', 'Read'],
84
+ ['report', 'Report'],
85
+ ['write', 'Write'],
86
+ ] as const;
87
+
88
+ /** The day `at` falls on, as the list writes an expiry. */
89
+ const day = (at: number) => new Date(at).toISOString().slice(0, 10);
90
+
91
+ /**
92
+ * The lifetimes a new token offers, in days: GitHub's, then a year, and a day of the person's own
93
+ * picking, within Git's year.
94
+ */
95
+ const lifetimes = [
96
+ [7, '7 days'],
97
+ [30, '30 days'],
98
+ [60, '60 days'],
99
+ [90, '90 days'],
100
+ [365, 'A year'],
101
+ ['custom', 'Custom…'],
102
+ ] as const;
103
+
104
+ /** A day on the person's calendar, as the form writes the one a new token stops working on. */
105
+ const calendarDay = (on: Date) => format(on, 'yyyy-MM-dd');
106
+
107
+ /** The owner, or one of its repos, a tokens page is for. */
108
+ export interface TokenPlace {
109
+ readonly owner: string;
110
+ readonly repo?: string;
111
+ }
112
+
113
+ /**
114
+ * Whether `token` reaches `within`: one over every repo of the owner's reaches each of them, and
115
+ * one over a repo reaches it, and its owner.
116
+ */
117
+ export const reaches = (token: TokenRecord, within: TokenPlace) => {
118
+ if (token.repo === undefined) return token.prefix === `${within.owner}/`;
119
+
120
+ return within.repo === undefined
121
+ ? token.repo.startsWith(`${within.owner}/`)
122
+ : token.repo === `${within.owner}/${within.repo}`;
123
+ };
124
+
125
+ /** The person's repos as the drop-in orders them, the first page of which the field offers. */
126
+ const everyRepo: RepoFilter = { search: '', type: 'all', language: '', sort: 'updated' };
127
+
128
+ /**
129
+ * The signed-in person's tokens: each with its scope, its repo or prefix, its expiry and whether it
130
+ * still works, a way to revoke it, and a form for a new one, whose secret shows once.
131
+ */
132
+ export function TokensPage({
133
+ login,
134
+ within,
135
+ }: {
136
+ readonly login: string;
137
+ /** The owner, or its repo, whose page this is: only the tokens that reach it are listed. */
138
+ readonly within: TokenPlace;
139
+ }) {
140
+ const listed = useQuery(tokenList);
141
+ // A token is the person's own (Q521): another owner's page lists none, and says why.
142
+ const own = within.owner === login;
143
+ const named = within.repo === undefined ? within.owner : `${within.owner}/${within.repo}`;
144
+
145
+ return (
146
+ // A form-like page: held to a readable width, in the middle of the page.
147
+ <section aria-label="Tokens" className="mx-auto flex w-full max-w-3xl flex-col gap-6">
148
+ <ListToolbar
149
+ buttons={
150
+ <Dialog>
151
+ <DialogTrigger render={<CreateButton>New token</CreateButton>} />
152
+ <DialogContent className="max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg">
153
+ <DialogHeader>
154
+ <DialogTitle>New token</DialogTitle>
155
+ <DialogDescription>
156
+ Its secret shows once, here. Closing this dialog forgets it.
157
+ </DialogDescription>
158
+ </DialogHeader>
159
+ <NewTokenForm
160
+ login={login}
161
+ start={own ? within.repo : undefined}
162
+ elsewhere={own ? undefined : within.owner}
163
+ />
164
+ </DialogContent>
165
+ </Dialog>
166
+ }
167
+ />
168
+ {!own ? (
169
+ <Alert>
170
+ <AlertDescription>
171
+ Your tokens reach only your own repositories, under {login}, so none reach {named}.
172
+ </AlertDescription>
173
+ </Alert>
174
+ ) : listed.data === undefined ? (
175
+ listed.error === null ? (
176
+ <Skeleton className="h-32" />
177
+ ) : (
178
+ <LoadFailed message="Your tokens didn't load" />
179
+ )
180
+ ) : (
181
+ <TokenRows
182
+ tokens={listed.data.tokens.filter((token) => reaches(token, within))}
183
+ more={listed.data.more}
184
+ named={own && within.repo !== undefined ? named : undefined}
185
+ />
186
+ )}
187
+ </section>
188
+ );
189
+ }
190
+
191
+ function NewTokenForm({
192
+ login,
193
+ start = '',
194
+ elsewhere,
195
+ }: {
196
+ readonly login: string;
197
+ /** The repo of theirs it starts over, by its name: the page's own, or every one when absent. */
198
+ readonly start?: string | undefined;
199
+ /** The other owner whose page it's opened from, whose repos no token of theirs can reach. */
200
+ readonly elsewhere?: string | undefined;
201
+ }) {
202
+ const client = useQueryClient();
203
+ const [token, setToken] = useState<NewToken>({ scope: 'read', days: 30 });
204
+ const [repo, setRepo] = useState(start);
205
+ const [typed, setTyped] = useState(start);
206
+ const [tried, setTried] = useState(false);
207
+ const yours = useRepos({ kind: 'viewer', login }, everyRepo);
208
+ const names = yours.data?.pages[0]?.repos.map((each) => each.name) ?? [];
209
+ // A repo past the first page the drop-in lists is still one of theirs: what's typed is offered.
210
+ const offered = typed === '' || names.includes(typed) ? names : [...names, typed];
211
+ // The secret is held in this form's own state alone, and the mutation answers nothing, so no
212
+ // query or mutation cache ever holds it, and it's gone once the form is.
213
+ const [secret, setSecret] = useState<string>();
214
+ const made = useMutation({
215
+ mutationFn: async (asked: NewToken) => {
216
+ const created = await createToken(repo === '' ? asked : { ...asked, repo });
217
+ setSecret(created.secret);
218
+ },
219
+ onSuccess: () => client.invalidateQueries({ queryKey: ['tokens'] }),
220
+ });
221
+ const problem = repo === '' ? undefined : repoProblem(repo);
222
+ // A custom expiry is a day on the person's calendar, counted in days as the form is sent.
223
+ const [custom, setCustom] = useState(false);
224
+ const [on, setOn] = useState<Date>();
225
+ const [picking, setPicking] = useState(false);
226
+ const today = new Date();
227
+ const { first, last } = expiryRange(today);
228
+ const unpicked = custom && on === undefined ? 'Pick the day it stops working.' : undefined;
229
+
230
+ const submit = (event: FormEvent<HTMLFormElement>) => {
231
+ event.preventDefault();
232
+ setTried(true);
233
+
234
+ if (problem !== undefined || unpicked !== undefined || made.isPending) return;
235
+
236
+ // The last token's secret goes as the next is asked for, before the mutation can pause
237
+ // offline, so a slow, paused or failed create never leaves it shown as the new one.
238
+ setSecret(undefined);
239
+ made.mutate(custom && on !== undefined ? { ...token, days: daysUntil(new Date(), on) } : token);
240
+ };
241
+
242
+ return (
243
+ <form noValidate aria-label="New token" onSubmit={submit} className="flex flex-col gap-4">
244
+ <FieldGroup>
245
+ <FieldSet>
246
+ <FieldLegend variant="label">Scope</FieldLegend>
247
+ <RadioGroup
248
+ aria-label="Scope"
249
+ value={token.scope}
250
+ onValueChange={(picked) =>
251
+ setToken({
252
+ ...token,
253
+ scope: scopes.find(([each]) => each === picked)?.[0] ?? token.scope,
254
+ })
255
+ }
256
+ >
257
+ {scopes.map(([each, name]) => (
258
+ <Field key={each} orientation="horizontal">
259
+ <RadioGroupItem id={`token-scope-${each}`} value={each} />
260
+ <FieldLabel htmlFor={`token-scope-${each}`}>{name}</FieldLabel>
261
+ </Field>
262
+ ))}
263
+ </RadioGroup>
264
+ </FieldSet>
265
+ <Field data-invalid={tried && problem !== undefined}>
266
+ <FieldLabel htmlFor="token-repo">Repository</FieldLabel>
267
+ <Combobox
268
+ items={offered}
269
+ value={repo === '' ? null : repo}
270
+ onValueChange={(picked: string | null) => setRepo(picked ?? '')}
271
+ inputValue={typed}
272
+ onInputValueChange={setTyped}
273
+ autoHighlight
274
+ >
275
+ <ComboboxInput
276
+ id="token-repo"
277
+ placeholder="Every repository"
278
+ aria-invalid={tried && problem !== undefined}
279
+ showClear={repo !== ''}
280
+ />
281
+ <ComboboxContent>
282
+ <ComboboxEmpty>
283
+ {yours.isPending ? 'Reading your repositories…' : 'You have no repositories yet.'}
284
+ </ComboboxEmpty>
285
+ <ComboboxList>
286
+ {(name: string) => (
287
+ <ComboboxItem key={name} value={name}>
288
+ <RepoIcon owner={login} repo={name} />
289
+ <span className="break-all">{name}</span>
290
+ </ComboboxItem>
291
+ )}
292
+ </ComboboxList>
293
+ </ComboboxContent>
294
+ </Combobox>
295
+ <FieldDescription>
296
+ One of yours, under {login}, or none for all of them.
297
+ {elsewhere !== undefined && ` A token can't reach ${elsewhere}'s repositories.`}
298
+ </FieldDescription>
299
+ {tried && <FieldError>{problem}</FieldError>}
300
+ </Field>
301
+ <Field>
302
+ <FieldLabel htmlFor="token-days">Expiration</FieldLabel>
303
+ <div className="flex flex-wrap gap-2">
304
+ <Select<number | 'custom'>
305
+ items={lifetimes.map(([days, name]) => ({ value: days, label: name }))}
306
+ value={custom ? 'custom' : token.days}
307
+ onValueChange={(days: number | 'custom' | null) => {
308
+ if (days === 'custom') {
309
+ setCustom(true);
310
+ setPicking(true);
311
+ } else if (days !== null) {
312
+ setCustom(false);
313
+ setToken({ ...token, days });
314
+ }
315
+ }}
316
+ >
317
+ <SelectTrigger id="token-days" className="w-full sm:w-48">
318
+ <SelectValue />
319
+ </SelectTrigger>
320
+ <SelectContent>
321
+ <SelectGroup>
322
+ {lifetimes.map(([days, name]) => (
323
+ <SelectItem key={days} value={days}>
324
+ {name}
325
+ </SelectItem>
326
+ ))}
327
+ </SelectGroup>
328
+ </SelectContent>
329
+ </Select>
330
+ {custom && (
331
+ <Popover open={picking} onOpenChange={setPicking}>
332
+ <PopoverTrigger
333
+ render={
334
+ <Button
335
+ variant="outline"
336
+ aria-label="Expiration date"
337
+ aria-invalid={tried && unpicked !== undefined}
338
+ className="w-full justify-start font-normal sm:w-48"
339
+ />
340
+ }
341
+ >
342
+ <CalendarIcon data-icon="inline-start" />
343
+ {on === undefined ? 'Pick a date' : calendarDay(on)}
344
+ </PopoverTrigger>
345
+ <PopoverContent className="w-auto p-0" align="start">
346
+ <Calendar
347
+ mode="single"
348
+ selected={on}
349
+ onSelect={(picked) => {
350
+ setOn(picked);
351
+ setPicking(false);
352
+ }}
353
+ disabled={[{ before: first }, { after: last }]}
354
+ startMonth={first}
355
+ endMonth={last}
356
+ defaultMonth={on ?? first}
357
+ />
358
+ </PopoverContent>
359
+ </Popover>
360
+ )}
361
+ </div>
362
+ <FieldDescription>
363
+ {custom
364
+ ? on === undefined
365
+ ? `Any day from ${calendarDay(first)} to ${calendarDay(last)}.`
366
+ : `It stops working on ${calendarDay(on)}.`
367
+ : `It stops working on ${calendarDay(dayAfter(today, token.days))}.`}
368
+ </FieldDescription>
369
+ {tried && <FieldError>{unpicked}</FieldError>}
370
+ </Field>
371
+ </FieldGroup>
372
+ <div className="flex justify-end">
373
+ <Button type="submit" disabled={made.isPending}>
374
+ Generate token
375
+ </Button>
376
+ </div>
377
+ {secret !== undefined && (
378
+ <Alert>
379
+ <KeyRoundIcon />
380
+ <AlertTitle>Copy your token now: it won't be shown again.</AlertTitle>
381
+ <AlertDescription>
382
+ <InputGroup>
383
+ <InputGroupInput
384
+ id="token-secret"
385
+ aria-label="Your new token"
386
+ readOnly
387
+ className="font-mono text-foreground"
388
+ value={secret}
389
+ onFocus={(event) => event.currentTarget.select()}
390
+ />
391
+ <InputGroupAddon align="inline-end">
392
+ <CopyButton text={secret} label="Copy the token" look="field" />
393
+ </InputGroupAddon>
394
+ </InputGroup>
395
+ </AlertDescription>
396
+ </Alert>
397
+ )}
398
+ {made.error !== null && (
399
+ <Alert variant="destructive">
400
+ <AlertDescription>{made.error.message}</AlertDescription>
401
+ </Alert>
402
+ )}
403
+ </form>
404
+ );
405
+ }
406
+
407
+ function TokenRows({
408
+ tokens,
409
+ more,
410
+ named,
411
+ }: {
412
+ readonly tokens: readonly TokenRecord[];
413
+ readonly more: boolean;
414
+ /** The repo they're listed for, when it's one. */
415
+ readonly named?: string | undefined;
416
+ }) {
417
+ const now = Date.now();
418
+
419
+ // An empty list says "none yet" only when every place the person's tokens are kept was read.
420
+ return (
421
+ <div className="flex flex-col gap-2">
422
+ {tokens.length === 0 ? (
423
+ <Empty className="border">
424
+ <EmptyHeader>
425
+ <EmptyMedia variant="icon">
426
+ <KeyRoundIcon />
427
+ </EmptyMedia>
428
+ <EmptyTitle>
429
+ {more
430
+ ? 'No tokens found among those read'
431
+ : named === undefined
432
+ ? 'No tokens yet'
433
+ : `No tokens reach ${named} yet`}
434
+ </EmptyTitle>
435
+ <EmptyDescription>
436
+ A token lets a script or a tool use Git as you, over one repository or all of yours.
437
+ </EmptyDescription>
438
+ </EmptyHeader>
439
+ </Empty>
440
+ ) : (
441
+ <Table aria-label="Your tokens" className="border">
442
+ <TableHeader>
443
+ <TableRow>
444
+ <TableHead>Token</TableHead>
445
+ {/* On a phone, scope, repository and expiry read under the token instead. */}
446
+ <TableHead className="hidden sm:table-cell">Scope</TableHead>
447
+ <TableHead className="hidden sm:table-cell">Repository</TableHead>
448
+ <TableHead className="hidden sm:table-cell">Expires</TableHead>
449
+ <TableHead>State</TableHead>
450
+ <TableHead>
451
+ <span className="sr-only">Revoke</span>
452
+ </TableHead>
453
+ </TableRow>
454
+ </TableHeader>
455
+ <TableBody>
456
+ {tokens.map((token) => (
457
+ <TokenRow key={token.id} token={token} state={stateOf(token, now)} />
458
+ ))}
459
+ </TableBody>
460
+ </Table>
461
+ )}
462
+ {more && (
463
+ <p className="text-muted-foreground">
464
+ Only your first {tokenRepos} repositories, and {tokensEach} tokens in each place, are
465
+ read, so more may be kept than are listed here.
466
+ </p>
467
+ )}
468
+ </div>
469
+ );
470
+ }
471
+
472
+ /** What a token reaches: one repo, with its icon, or every repo under a login. */
473
+ function TokenReach({ token, over }: { readonly token: TokenRecord; readonly over: string }) {
474
+ const [owner, repo] = token.repo?.split('/') ?? [];
475
+ if (owner === undefined || repo === undefined) return over;
476
+
477
+ return (
478
+ <span className="flex items-center gap-1.5">
479
+ <RepoIcon owner={owner} repo={repo} />
480
+ <span className="min-w-0">{over}</span>
481
+ </span>
482
+ );
483
+ }
484
+
485
+ function TokenRow({ token, state }: { readonly token: TokenRecord; readonly state: string }) {
486
+ const client = useQueryClient();
487
+ const revoked = useMutation({
488
+ mutationFn: () => revokeToken(token.id),
489
+ onSuccess: () => client.invalidateQueries({ queryKey: ['tokens'] }),
490
+ });
491
+ const over = token.repo ?? `every repository under ${token.prefix ?? ''}`;
492
+
493
+ return (
494
+ <TableRow>
495
+ <TableCell className="whitespace-normal">
496
+ <div className="flex flex-col gap-1">
497
+ <code className="wrap-anywhere">{token.id}</code>
498
+ <span className="text-muted-foreground sm:hidden">
499
+ {token.scope} · {over} · expires {day(token.expiresAt)}
500
+ </span>
501
+ {revoked.error !== null && (
502
+ <Alert variant="destructive">
503
+ <AlertDescription>{revoked.error.message}</AlertDescription>
504
+ </Alert>
505
+ )}
506
+ </div>
507
+ </TableCell>
508
+ <TableCell className="hidden sm:table-cell">{token.scope}</TableCell>
509
+ <TableCell className="hidden sm:table-cell whitespace-normal wrap-anywhere">
510
+ <TokenReach token={token} over={over} />
511
+ </TableCell>
512
+ <TableCell className="hidden sm:table-cell tabular-nums">{day(token.expiresAt)}</TableCell>
513
+ <TableCell>
514
+ <Badge variant={state === 'Active' ? 'secondary' : 'outline'}>{state}</Badge>
515
+ </TableCell>
516
+ <TableCell className="text-right">
517
+ {state === 'Active' && (
518
+ <ConfirmAction
519
+ label="Revoke"
520
+ title={`Revoke ${token.id}?`}
521
+ description="It's permanent: anything using it is refused from now on, and a revoked token can't come back."
522
+ disabled={revoked.isPending}
523
+ onConfirm={() => revoked.mutate()}
524
+ />
525
+ )}
526
+ </TableCell>
527
+ </TableRow>
528
+ );
529
+ }
@@ -0,0 +1,54 @@
1
+ import { queryOptions } from '@tanstack/react-query';
2
+ import { addDays, differenceInCalendarDays, startOfDay } from 'date-fns';
3
+ import * as Schema from 'effect/Schema';
4
+
5
+ import { hostAnswer } from '../clients/host-answer.ts';
6
+ import {
7
+ type HostAsk,
8
+ TokenListing,
9
+ type TokenRecord,
10
+ tokenDaysMost,
11
+ } from '../clients/host-calls.ts';
12
+
13
+ /** A token as Git makes it: the only answer that ever carries its secret. */
14
+ const Made = Schema.Struct({ id: Schema.String, secret: Schema.String });
15
+
16
+ /** A new token, as the tokens page asks for one: over one repo of the person's, or all of them. */
17
+ export type NewToken = Omit<Extract<HostAsk, { operation: 'token.create' }>, 'operation'>;
18
+
19
+ /**
20
+ * The days a token lives to stop working on the day `on`, as the person's calendar counts them from
21
+ * `today`: a day across a clock change is still one day.
22
+ */
23
+ export const daysUntil = (today: Date, on: Date) => differenceInCalendarDays(on, today);
24
+
25
+ /** The day a token made `today` stops working, `days` on, on the person's calendar. */
26
+ export const dayAfter = (today: Date, days: number) => addDays(startOfDay(today), days);
27
+
28
+ /** The first and last days a new token may stop working on: tomorrow, and the host's last. */
29
+ export const expiryRange = (today: Date) => ({
30
+ first: dayAfter(today, 1),
31
+ last: dayAfter(today, tokenDaysMost),
32
+ });
33
+
34
+ /** Whether a token still works, was revoked, or has lapsed, at `now`. */
35
+ export const stateOf = (token: TokenRecord, now: number) => {
36
+ if (token.revokedAt !== undefined) return 'Revoked';
37
+
38
+ return token.expiresAt <= now ? 'Expired' : 'Active';
39
+ };
40
+
41
+ /** The signed-in person's tokens, as the host lists them, never with a secret. */
42
+ export const tokenList = queryOptions({
43
+ queryKey: ['tokens'],
44
+ queryFn: () => hostAnswer({ operation: 'token.list' }, TokenListing),
45
+ });
46
+
47
+ /** Makes a token: its secret, shown once, is in this answer alone. */
48
+ export const createToken = (token: NewToken) =>
49
+ hostAnswer({ operation: 'token.create', ...token }, Made);
50
+
51
+ /** Revokes one of the person's tokens. */
52
+ export const revokeToken = async (id: string) => {
53
+ await hostAnswer({ operation: 'token.revoke', id }, Schema.Undefined);
54
+ };
@@ -0,0 +1,25 @@
1
+ // The app's pages, routes, clients and sign-in: DOM, as a browser runs them, and Start's server
2
+ // functions beside them. The Worker's entry and Git are `tsconfig.worker.json`'s, typed by
3
+ // workers-types with no DOM, and the tests `tsconfig.test.json`'s, in Node. Each file is in the
4
+ // one whose globals it runs with, and the root's `tsconfig.json` references all three.
5
+ {
6
+ "extends": "../../tsconfig.base.json",
7
+ "compilerOptions": {
8
+ "composite": true,
9
+ "jsx": "react-jsx",
10
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
11
+ "tsBuildInfoFile": "./node_modules/.cache/tsconfig.tsbuildinfo",
12
+ "types": ["vite-plus/client"]
13
+ },
14
+ "include": ["src/**/*.ts", "src/**/*.tsx", "generated/**/*.ts"],
15
+ "exclude": [
16
+ "src/**/*.test.ts",
17
+ "src/**/testing/**",
18
+ "src/seed/**",
19
+ "src/server.ts",
20
+ "src/git.ts",
21
+ "src/policy.ts",
22
+ "src/env.ts",
23
+ "src/signin/approval.ts"
24
+ ]
25
+ }
@@ -0,0 +1,24 @@
1
+ // The Worker, typed as Cloudflare types one: workers-types' globals and no DOM, so `Request` and
2
+ // `Response` are a Worker's. The pages are `tsconfig.app.json`'s, and the files both run, sealing
3
+ // and names, are in each.
4
+ {
5
+ "extends": "../../tsconfig.base.json",
6
+ "compilerOptions": {
7
+ "composite": true,
8
+ "lib": ["ES2023"],
9
+ "tsBuildInfoFile": "./node_modules/.cache/tsconfig.worker.tsbuildinfo",
10
+ "types": ["@cloudflare/workers-types", "vite-plus/client"]
11
+ },
12
+ "include": [
13
+ "src/server.ts",
14
+ "src/git.ts",
15
+ "src/policy.ts",
16
+ "src/env.ts",
17
+ "src/context/**/*.ts",
18
+ "src/names/**/*.ts",
19
+ "src/seed/**/*.ts",
20
+ "src/signin/approval.ts",
21
+ "src/signin/seal.ts"
22
+ ],
23
+ "exclude": ["src/**/*.test.ts", "src/seed/testing/built-app.ts"]
24
+ }
@@ -0,0 +1,21 @@
1
+ import { cloudflare } from '@cloudflare/vite-plugin';
2
+ import tailwindcss from '@tailwindcss/vite';
3
+ import { tanstackStart } from '@tanstack/react-start/plugin/vite';
4
+ import viteReact from '@vitejs/plugin-react';
5
+ import { defineConfig } from 'vite-plus';
6
+
7
+ // Start's server build runs in the Worker: Cloudflare's plugin takes its `ssr` environment.
8
+ export default defineConfig(({ command }) => ({
9
+ // The dev seed is on only under the dev server, `vp dev`: every build drops it and its imports,
10
+ // whatever its mode or `NODE_ENV`.
11
+ define: { __DEV_SEED__: JSON.stringify(command === 'serve') },
12
+ plugins: [
13
+ cloudflare({ viteEnvironment: { name: 'ssr' } }),
14
+ tanstackStart({
15
+ // NodeNext, as the repo types it, resolves only imports that name their extension.
16
+ router: { generatedRouteTree: '../generated/routeTree.gen.ts', addExtensions: true },
17
+ }),
18
+ viteReact(),
19
+ tailwindcss(),
20
+ ],
21
+ }));