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,115 @@
1
+ import { lines } from "./files.mjs";
2
+ import { gitRoutes, pathMatchers } from "./routes.mjs";
3
+ // src/init/nuxt.ts
4
+ /**
5
+ * What `init` writes in a Nuxt project on Node, under Nitro's Node preset: one server middleware
6
+ * that answers Git's URLs, and with `--serve github` the drop-in's, and a Nitro plugin that starts
7
+ * the jobs. The middleware loads the server module on Git's first request, as every framework's
8
+ * routes do.
9
+ */
10
+ /** `to`'s import specifier from the file at `from`: relative, with its `.ts`, as Nitro resolves it. */
11
+ const importOf = (from, to) => {
12
+ const folders = from.split("/").slice(0, -1);
13
+ const target = to.split("/");
14
+ const shared = folders.findIndex((folder, at) => target[at] !== folder || at === target.length - 1);
15
+ const common = shared === -1 ? folders.length : shared;
16
+ const ups = folders.length - common;
17
+ return `${ups === 0 ? "./" : "../".repeat(ups)}${target.slice(common).join("/")}`;
18
+ };
19
+ /** The Nitro plugin that starts Git's jobs once in each server process, and stops them on close. */
20
+ const nuxtJobsPlugin = "server/plugins/git-jobs.ts";
21
+ /** The plugin's lines, which a step in the person's own file at that path names too. */
22
+ const pluginLines = (framework) => [
23
+ "export default defineNitroPlugin(async (nitroApp) => {",
24
+ ` const { jobs } = await import('${importOf(nuxtJobsPlugin, framework.serverModule)}');`,
25
+ "",
26
+ " const stop = jobs.start();",
27
+ " nitroApp.hooks.hook('close', () => void stop());",
28
+ "});"
29
+ ];
30
+ /** The middleware that answers Git's URLs, and the drop-in's, in front of the app's own. */
31
+ const nuxtGitMiddleware = "server/middleware/git.ts";
32
+ /**
33
+ * Git's URLs under the base path, and with `--serve github` the drop-in's at the root and `gh`'s
34
+ * root Git URLs, answered in place at the path the matcher gives, the query kept; every other path
35
+ * falls through to the app, its body unread. The matcher reads the URL Git is handed, with its dot
36
+ * segments resolved, never the raw path Nitro routes by.
37
+ */
38
+ const middlewareLines = (choices, framework) => {
39
+ const calls = gitRoutes(choices)[0]?.calls ?? "serve";
40
+ const matcher = pathMatchers[choices.serve];
41
+ return [
42
+ `import { ${matcher.name} } from '${matcher.from}';`,
43
+ "",
44
+ "export default defineEventHandler(async (event) => {",
45
+ " // The URL Git is handed, dot segments resolved, under the Host's origin: an absolute target",
46
+ " // keeps only its path and query. Then the path Git answers it at. h3's toWebRequest is",
47
+ " // called only for Git's, since its body starts reading the app's request.",
48
+ " const named = getRequestURL(event);",
49
+ " const url = new URL(`${getRequestProtocol(event)}://${getRequestHost(event)}`);",
50
+ " url.pathname = named.pathname;",
51
+ " url.search = named.search;",
52
+ ` const path = ${matcher.name}(url, '${choices.basePath.replace(/\/$/, "")}');`,
53
+ " if (path === undefined) return;",
54
+ "",
55
+ " // Loaded on Git's first request. toWebRequest reads a body without backpressure, so a fast",
56
+ " // push waits in memory while Git reads it.",
57
+ ` const { ${calls} } = await import('${importOf(nuxtGitMiddleware, framework.serverModule)}');`,
58
+ " url.pathname = path;",
59
+ "",
60
+ ` return ${calls}.fetch(new Request(url, toWebRequest(event)));`,
61
+ "});"
62
+ ];
63
+ };
64
+ /** The first line of the middleware `init` writes, which marks the file as init's to rewrite. */
65
+ const middlewareHeader = "// Git's URLs to Git, in front of the app's own. Written by `ref0-git init`.";
66
+ /** Whether a file at the middleware's path answers Git: `init`'s, or one with its lines. */
67
+ const answersGit = (text) => /\bgit(?:hub)?PathOf\(/.test(text);
68
+ /** What `doctor` finds in a Nuxt app on Node: Git's middleware, and h3's reading of a push. */
69
+ const nuxtFindings = (framework) => {
70
+ const middleware = framework.nitro?.middleware;
71
+ const answered = middleware !== void 0 && answersGit(middleware.text);
72
+ return [{
73
+ check: "Git's URLs",
74
+ ok: answered,
75
+ says: answered ? `${middleware.path} answers Git's URLs, and with the drop-in gh's root ones` : `${middleware?.path ?? `No server/middleware/git.ts`} answers no Git URL, so every clone gets Nuxt's 404: add the middleware init printed`,
76
+ blocks: "clone, fetch and push"
77
+ }, {
78
+ check: "Push memory",
79
+ ok: true,
80
+ says: "h3's toWebRequest reads a push with no backpressure, so a push that arrives faster than Git reads it waits in memory"
81
+ }];
82
+ };
83
+ /**
84
+ * Nuxt's files and steps beside the server module: the jobs plugin and Git's middleware. The
85
+ * middleware is init's to rewrite where it answers Git, so a rerun at a new base path moves it;
86
+ * a person's own file at its path gets a step.
87
+ */
88
+ const nuxtOutput = (choices, framework) => {
89
+ const plugin = framework.nitro?.plugin;
90
+ const middleware = framework.nitro?.middleware;
91
+ const ours = middleware === void 0 || middleware.text.startsWith(middlewareHeader);
92
+ return {
93
+ files: [...plugin === void 0 ? [{
94
+ path: nuxtJobsPlugin,
95
+ kind: "whole",
96
+ text: lines("// Starts Git's jobs once in each Nitro server process, and stops them as it closes.", "// Written by `ref0-git init`.", ...pluginLines(framework), "")
97
+ }] : [], ...ours ? [{
98
+ path: nuxtGitMiddleware,
99
+ kind: "whole",
100
+ text: lines(middlewareHeader, ...middlewareLines(choices, framework), "")
101
+ }] : []],
102
+ manual: [...plugin === void 0 || /\bjobs\.start\(/.test(plugin.text) ? [] : [{
103
+ path: plugin.path,
104
+ why: "yours",
105
+ says: "Start Git's jobs in a Nitro plugin, once in each server process",
106
+ lines: pluginLines(framework)
107
+ }], ...middleware === void 0 || answersGit(middleware.text) ? [] : [{
108
+ path: middleware.path,
109
+ why: "yours",
110
+ says: "Answer Git's URLs with Git, and let every other path through",
111
+ lines: middlewareLines(choices, framework)
112
+ }]]
113
+ };
114
+ };
115
+ export { nuxtFindings, nuxtGitMiddleware, nuxtJobsPlugin, nuxtOutput };
@@ -0,0 +1,21 @@
1
+ import { cloudflareOutput, secretFiles as secretFiles$1 } from "./cloudflare.mjs";
2
+ import { nodeOutput, secretFiles as secretFiles$2 } from "./node.mjs";
3
+ import { secretFiles as secretFiles$3, vercelOutput } from "./vercel.mjs";
4
+ // src/init/output.ts
5
+ /** The output of each platform `init` sets Git up on. */
6
+ const outputs = {
7
+ cloudflare: cloudflareOutput,
8
+ vercel: vercelOutput,
9
+ node: nodeOutput
10
+ };
11
+ /** The files that hold secrets on each platform. */
12
+ const secretFiles = {
13
+ cloudflare: secretFiles$1,
14
+ vercel: secretFiles$3,
15
+ node: secretFiles$2
16
+ };
17
+ /** Everything `init` writes for `choices` in `project`, on its platform, with `secret` making each new secret. */
18
+ const outputOf = (choices, project, secret, vendor) => outputs[choices.platform](choices, project, secret, vendor);
19
+ /** The files that hold secrets on `choices`' platform, which `init` refuses to write while Git tracks one. */
20
+ const secretFilesOf = (choices) => secretFiles[choices.platform];
21
+ export { outputOf, secretFilesOf };
@@ -0,0 +1,82 @@
1
+ import { parseJsonc } from "./jsonc.mjs";
2
+ import { createTwoFilesPatch } from "diff";
3
+ // src/init/plan.ts
4
+ /** `node`'s text as written, compact, so the same value reads the same wherever it's indented. */
5
+ const compact = (text, node) => node === void 0 ? void 0 : text.slice(node.start, node.end).replace(/\s+/g, "");
6
+ /**
7
+ * What `to` adds to `from` or changes in it, two JSON documents' texts, as each value it sets under
8
+ * an object's keys: what a create command's dry run says `init` adds to the `package.json` it
9
+ * hasn't written yet.
10
+ */
11
+ const addedTo = (from, to) => {
12
+ const walk = (before, after, at) => {
13
+ if (after === void 0) return [];
14
+ if (after.kind !== "object") return compact(from, before) === compact(to, after) ? [] : [{
15
+ at,
16
+ raw: to.slice(after.start, after.end)
17
+ }];
18
+ const held = before?.kind === "object" ? before.members : [];
19
+ return after.members.flatMap(({ key, value }) => walk(held.find((member) => member.key === key)?.value, value, [...at, key]));
20
+ };
21
+ return walk(parseJsonc(from), parseJsonc(to), []);
22
+ };
23
+ /** The change from `from` to `to` of `path`, as a person applies it. */
24
+ const patchOf = (path, from, to) => createTwoFilesPatch(path, `${path} (init)`, from, to, void 0, void 0, { context: 3 }).replace(/^=+\n/, "");
25
+ /**
26
+ * Each file's step, from what `read` finds: `files` for the choices asked for, and `held` for the
27
+ * choices the folder holds now, which an untouched file still reads as.
28
+ */
29
+ const plan = (files, held, read) => files.map((file) => {
30
+ const current = read(file.path);
31
+ const secrets = file.kind === "merge" ? file.secrets : void 0;
32
+ if (file.kind === "merge") {
33
+ const text = file.merge(current);
34
+ if (current === void 0) return {
35
+ path: file.path,
36
+ action: "create",
37
+ text,
38
+ secrets
39
+ };
40
+ return text === current ? {
41
+ path: file.path,
42
+ action: "unchanged",
43
+ secrets
44
+ } : {
45
+ path: file.path,
46
+ action: "merge",
47
+ text,
48
+ from: current,
49
+ patch: secrets === void 0 ? patchOf(file.path, current, text) : void 0,
50
+ secrets
51
+ };
52
+ }
53
+ if (current === void 0) return {
54
+ path: file.path,
55
+ action: "create",
56
+ text: file.text
57
+ };
58
+ if (current === file.text) return {
59
+ path: file.path,
60
+ action: "unchanged"
61
+ };
62
+ if (file.kind === "edit" && current === file.from) return {
63
+ path: file.path,
64
+ action: "edit",
65
+ text: file.text,
66
+ from: current,
67
+ edit: file.edit
68
+ };
69
+ const was = held?.find((each) => each.path === file.path);
70
+ if (was?.kind === "whole" && was.text === current) return {
71
+ path: file.path,
72
+ action: "replace",
73
+ text: file.text,
74
+ patch: patchOf(file.path, current, file.text)
75
+ };
76
+ return {
77
+ path: file.path,
78
+ action: "differs",
79
+ patch: patchOf(file.path, current, file.text)
80
+ };
81
+ });
82
+ export { addedTo, patchOf, plan };
@@ -0,0 +1,257 @@
1
+ // src/init/range-major.ts
2
+ const version = (major, minor = 0, patch = 0, pre = []) => ({
3
+ major,
4
+ minor,
5
+ patch,
6
+ pre
7
+ });
8
+ const isNumeric = (identifier) => /^\d+$/.test(identifier);
9
+ /** Two prerelease identifiers: numbers by their value, below any that isn't, and the rest in ASCII. */
10
+ const compareIdentifiers = (a, b) => {
11
+ if (isNumeric(a) !== isNumeric(b)) return isNumeric(a) ? -1 : 1;
12
+ if (isNumeric(a)) return Math.sign(Number(a) - Number(b));
13
+ if (a === b) return 0;
14
+ return a < b ? -1 : 1;
15
+ };
16
+ /** npm's precedence: by major, minor and patch, then a prerelease below its release. */
17
+ const compare = (a, b) => {
18
+ const main = a.major - b.major || a.minor - b.minor || a.patch - b.patch;
19
+ if (main !== 0) return Math.sign(main);
20
+ if (a.pre.length === 0 || b.pre.length === 0) return Math.sign(b.pre.length - a.pre.length);
21
+ for (let at = 0; at < Math.min(a.pre.length, b.pre.length); at += 1) {
22
+ const order = compareIdentifiers(a.pre[at] ?? "", b.pre[at] ?? "");
23
+ if (order !== 0) return order;
24
+ }
25
+ return Math.sign(a.pre.length - b.pre.length);
26
+ };
27
+ /** What each operator holds for, of `compare(at, bound)`. */
28
+ const within = {
29
+ "<": (order) => order < 0,
30
+ "<=": (order) => order <= 0,
31
+ ">": (order) => order > 0,
32
+ ">=": (order) => order >= 0,
33
+ "=": (order) => order === 0
34
+ };
35
+ const holds = ({ operator, version: bound }, at) => within[operator](compare(at, bound));
36
+ const sameRelease = (a, b) => a.major === b.major && a.minor === b.minor && a.patch === b.patch;
37
+ /**
38
+ * Whether npm installs `at` for `set`: every comparator holds, and a prerelease only when one of
39
+ * them names a prerelease of the same release, so `<17.0.0` takes no `17.0.0-rc.1`.
40
+ */
41
+ const takes = (set, at) => set.every((comparator) => holds(comparator, at)) && (at.pre.length === 0 || set.some(({ version: named }) => named.pre.length > 0 && sameRelease(named, at)));
42
+ const numeric = "0|[1-9]\\d*";
43
+ const part = `${numeric}|[xX*]`;
44
+ const identifier = `${numeric}|\\d*[a-zA-Z-][a-zA-Z0-9-]*`;
45
+ const dotted = (one) => `(?:${one})(?:\\.(?:${one}))*`;
46
+ /** A version as a range writes it, its build left out: `16`, `16.x`, `v16.4.6-rc.1`, or `*`. */
47
+ const plainPattern = `([v=\\s]*)(${part})(?:\\.(${part})(?:\\.(${part})(?:-(${dotted(identifier)}))?)?)?`;
48
+ /** A build, which npm drops from a range before it reads it: `+build.5`. */
49
+ const build = new RegExp(`\\+${dotted("[0-9A-Za-z-]+")}`, "g");
50
+ const plain = new RegExp(`^${plainPattern}$`);
51
+ const hyphen = new RegExp(`^\\s*(${plainPattern})\\s+-\\s+(${plainPattern})\\s*$`);
52
+ const comparator = /^(~>?|\^|[<>]?=?)(.*)$/;
53
+ /** The operators an x-range may start with, as `comparator` reads them. */
54
+ const xOperators = /* @__PURE__ */ new Map([
55
+ ["", ""],
56
+ ["=", "="],
57
+ ["<", "<"],
58
+ ["<=", "<="],
59
+ [">", ">"],
60
+ [">=", ">="]
61
+ ]);
62
+ const parsePlain = (text) => {
63
+ const found = plain.exec(text);
64
+ if (found === null) return void 0;
65
+ const parts = [
66
+ found[2],
67
+ found[3],
68
+ found[4]
69
+ ];
70
+ const leftOut = parts.findIndex((each) => each === void 0 || /^[xX*]$/.test(each));
71
+ const [major, minor, patch] = parts.map((each, at) => leftOut !== -1 && at >= leftOut ? void 0 : Number(each));
72
+ return {
73
+ major,
74
+ minor,
75
+ patch,
76
+ pre: leftOut !== -1 ? [] : (found[5] ?? "").split(".").filter((each) => each !== ""),
77
+ misordered: leftOut !== -1 && parts.slice(leftOut).some((each) => isNumeric(each ?? "")),
78
+ bare: /^\s*v?$/.test(found[1] ?? ""),
79
+ v: (found[1] ?? "").includes("v")
80
+ };
81
+ };
82
+ /** The longest version npm reads. */
83
+ const longest = 256;
84
+ /**
85
+ * Whether npm reads `at`: no part past `Number.MAX_SAFE_INTEGER`, and 256 characters at most, with
86
+ * its `v` where it's read as written.
87
+ */
88
+ const readable = (at, v = false) => [
89
+ at.major,
90
+ at.minor,
91
+ at.patch
92
+ ].every((each) => each <= Number.MAX_SAFE_INTEGER) && `${v ? "v" : ""}${at.major}.${at.minor}.${at.patch}${at.pre.length > 0 ? `-${at.pre.join(".")}` : ""}`.length <= longest;
93
+ const below = (bound) => ({
94
+ operator: "<",
95
+ version: {
96
+ ...bound,
97
+ pre: ["0"]
98
+ }
99
+ });
100
+ /** What nothing satisfies, as `<*` and `>*` take. */
101
+ const nothing = [below(version(0))];
102
+ /** `16`, `>=16.4`, `<16.x`: an operator over a version that may leave its parts out. */
103
+ const xRange = (operator, { major, minor, patch, pre, bare, v }) => {
104
+ if (major === void 0) return operator === "<" || operator === ">" ? nothing : [];
105
+ if (minor !== void 0 && patch !== void 0) {
106
+ const at = version(major, minor, patch, pre);
107
+ return bare && readable(at, v) ? [{
108
+ operator: operator === "" ? "=" : operator,
109
+ version: at
110
+ }] : void 0;
111
+ }
112
+ const low = version(major, minor ?? 0);
113
+ const next = minor === void 0 ? version(major + 1) : version(major, minor + 1);
114
+ if (operator === ">") return [{
115
+ operator: ">=",
116
+ version: next
117
+ }];
118
+ if (operator === ">=") return [{
119
+ operator: ">=",
120
+ version: low
121
+ }];
122
+ if (operator === "<") return [below(low)];
123
+ if (operator === "<=") return [below(next)];
124
+ return [{
125
+ operator: ">=",
126
+ version: low
127
+ }, below(next)];
128
+ };
129
+ /** `~16.4`: patches of the minor, or of the major when the minor is left out. */
130
+ const tilde = ({ major, minor, patch, pre }) => {
131
+ if (major === void 0) return [];
132
+ const low = version(major, minor ?? 0, patch ?? 0, patch === void 0 ? [] : pre);
133
+ const next = minor === void 0 ? version(major + 1) : version(major, minor + 1);
134
+ return [{
135
+ operator: ">=",
136
+ version: low
137
+ }, below(next)];
138
+ };
139
+ /** `^16.4.6`: anything that leaves the first nonzero part as it is. */
140
+ const caret = ({ major, minor, patch, pre }) => {
141
+ if (major === void 0) return [];
142
+ const low = version(major, minor ?? 0, patch ?? 0, patch === void 0 ? [] : pre);
143
+ const next = major !== 0 || minor === void 0 ? version(major + 1) : minor !== 0 || patch === void 0 ? version(major, minor + 1) : version(major, minor, patch + 1);
144
+ return [{
145
+ operator: ">=",
146
+ version: low
147
+ }, below(next)];
148
+ };
149
+ /** A hyphen range's whole end: npm writes one with a prerelease out again, and reads one without
150
+ * as written. */
151
+ const endOf = (at, { bare, v }) => at.pre.length > 0 || bare && readable(at, v) ? [{
152
+ operator: "<=",
153
+ version: at
154
+ }] : void 0;
155
+ /** `16 - 17.2`: from the first, at its lowest, through the second, at its highest. */
156
+ const hyphenRange = (from, to) => {
157
+ const low = from.major === void 0 ? [] : xRange(">=", from);
158
+ const high = to.major === void 0 ? [] : to.minor === void 0 || to.patch === void 0 ? xRange("<=", to) : endOf(version(to.major, to.minor, to.patch, to.pre), to);
159
+ return low === void 0 || high === void 0 ? void 0 : [...low, ...high];
160
+ };
161
+ /** One of a spec's `||` ranges as npm writes out its comparators, or none when npm refuses it. */
162
+ const readSet = (range) => {
163
+ const spanned = hyphen.exec(range);
164
+ if (spanned !== null) {
165
+ const from = parsePlain(spanned[1] ?? "");
166
+ const to = parsePlain(spanned[7] ?? "");
167
+ return from === void 0 || to === void 0 ? void 0 : hyphenRange(from, to);
168
+ }
169
+ const sets = range.replace(/(~>?|\^|[<>]?=|[<>])\s+/g, "$1").split(/\s+/).filter((word) => word !== "").map((word) => {
170
+ const [, operator = "", rest = ""] = comparator.exec(word) ?? [];
171
+ const read = parsePlain(rest);
172
+ if (read === void 0) return void 0;
173
+ if (operator.startsWith("~")) return tilde(read);
174
+ if (operator === "^") return caret(read);
175
+ const xOperator = xOperators.get(operator);
176
+ return read.misordered || xOperator === void 0 ? void 0 : xRange(xOperator, read);
177
+ });
178
+ return sets.some((each) => each === void 0) ? void 0 : sets.flatMap((each) => each ?? []);
179
+ };
180
+ /** `>=0.0.0`, which npm drops as `*`, so a prerelease of 0.0.0 that a comparator names is taken. */
181
+ const fromZero = ({ operator, version: bound }) => operator === ">=" && compare(bound, version(0)) === 0;
182
+ /**
183
+ * One of a spec's `||` ranges as the comparators npm tests, or none when npm refuses it, as it
184
+ * does a bound it can't read, though the range built it: `~16.9007199254740991.0`'s upper one.
185
+ */
186
+ const parseSet = (range) => {
187
+ const set = readSet(range.replace(build, ""));
188
+ return set === void 0 || !set.every(({ version: bound }) => readable(bound)) ? void 0 : set.filter((each) => !fromZero(each));
189
+ };
190
+ /**
191
+ * Where what `set` takes can start: 0.0.0, and each bound, the version just past it, its release
192
+ * and that release's first prerelease. What a set takes is the releases between its bounds and
193
+ * the prereleases it names, so the lowest it takes is among these, and so is the lowest it takes
194
+ * past any major but at `{major}.0.0`, which `rangeMajor` tries too.
195
+ */
196
+ /** The version just past `at`: its prerelease with a `.0` more, or the next release, which past
197
+ * the highest patch npm reads is the next minor's, and so on. */
198
+ const after = (at) => at.pre.length > 0 ? afterPrerelease(at) : at.patch < Number.MAX_SAFE_INTEGER ? version(at.major, at.minor, at.patch + 1) : at.minor < Number.MAX_SAFE_INTEGER ? version(at.major, at.minor + 1) : version(at.major + 1);
199
+ /** The characters of an identifier, in npm's order. */
200
+ const alphabet = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
201
+ /**
202
+ * The lowest identifier above `id` and no longer than it, or none: `ab` gives `ac`, `az` gives `b`,
203
+ * and `9` gives `10`. A letter's next is never all digits, which would sort below it.
204
+ */
205
+ const nextIdentifier = (id) => {
206
+ if (isNumeric(id)) return String(BigInt(id) + 1n);
207
+ for (let at = id.length - 1; at >= 0; at -= 1) {
208
+ const next = alphabet[alphabet.indexOf(id[at] ?? "") + 1];
209
+ if (next === void 0) continue;
210
+ const head = id.slice(0, at);
211
+ return isNumeric(`${head}${next}`) ? `${head}A` : `${head}${next}`;
212
+ }
213
+ };
214
+ /**
215
+ * The lowest version npm reads past a prerelease: `.0` after it while that fits in npm's 256
216
+ * characters, else its last identifier with a `-` more or the next one no longer, else an
217
+ * earlier one's, else the release itself.
218
+ */
219
+ const afterPrerelease = (at) => {
220
+ const longer = {
221
+ ...at,
222
+ pre: [...at.pre, "0"]
223
+ };
224
+ if (readable(longer)) return longer;
225
+ for (let last = at.pre.length - 1; last >= 0; last -= 1) {
226
+ const id = at.pre[last] ?? "";
227
+ const kept = at.pre.slice(0, last);
228
+ const found = [isNumeric(id) ? void 0 : `${id}-`, nextIdentifier(id)].flatMap((each) => each === void 0 ? [] : [{
229
+ ...at,
230
+ pre: [...kept, each]
231
+ }]).find((each) => readable(each));
232
+ if (found !== void 0) return found;
233
+ }
234
+ return version(at.major, at.minor, at.patch);
235
+ };
236
+ const startsOf = (set) => [version(0), ...set.flatMap(({ version: bound }) => [
237
+ bound,
238
+ after(bound),
239
+ version(bound.major, bound.minor, bound.patch),
240
+ version(bound.major, bound.minor, bound.patch, ["0"])
241
+ ])].filter((at) => readable(at));
242
+ /** The major of every version `spec` takes, when they all have one; none otherwise. */
243
+ const rangeMajor = (spec) => {
244
+ const sets = spec.split("||").map((range) => parseSet(range.trim()));
245
+ const majors = /* @__PURE__ */ new Set();
246
+ for (const set of sets) {
247
+ if (set === void 0) return void 0;
248
+ const taken = startsOf(set).filter((at) => takes(set, at));
249
+ const least = taken.reduce((low, at) => low === void 0 || compare(at, low) < 0 ? at : low, void 0);
250
+ if (least === void 0) continue;
251
+ for (const at of taken) majors.add(at.major);
252
+ const past = version(least.major + 1);
253
+ if (readable(past) && takes(set, past)) majors.add(past.major);
254
+ }
255
+ return majors.size === 1 ? [...majors][0] : void 0;
256
+ };
257
+ export { rangeMajor };
@@ -0,0 +1,59 @@
1
+ import { lines } from "./files.mjs";
2
+ import { fileRoutes, matcherImport, routeHandler } from "./routes.mjs";
3
+ // src/init/react-router.ts
4
+ /**
5
+ * What `init` writes in a React Router project on Node: a resource route for each route, whose
6
+ * `loader` and `action` hand the request to Git, and, where `app/routes.ts` lists its routes
7
+ * rather than reading them by `flatRoutes()`, the lines that list these.
8
+ */
9
+ /**
10
+ * A route's file under `app/routes/`, by `flatRoutes()`'s names, and its line in `app/routes.ts`:
11
+ * a parameter such as `:repo` is `$repo`, and the text that follows it in the segment is escaped.
12
+ */
13
+ const placeOf = (route) => {
14
+ const file = `${route.at.split("/").map((segment) => segment.replace(/^:(\w+)(.+)?$/, (_, name, rest) => rest === void 0 ? `$${name}` : `$${name}[${rest}]`)).join(".")}${{
15
+ rest: ".$",
16
+ optional: ".$",
17
+ segment: ".$id",
18
+ none: ""
19
+ }[route.tail]}.ts`;
20
+ const url = `${route.at}${{
21
+ rest: "/*",
22
+ optional: "/*",
23
+ segment: "/:id",
24
+ none: ""
25
+ }[route.tail]}`;
26
+ return {
27
+ file,
28
+ path: `app/routes/${file}`,
29
+ line: `route('${url}', 'routes/${file}'),`
30
+ };
31
+ };
32
+ /** One resource route, typed by `react-router typegen`'s `./+types/<file>`. */
33
+ const resourceRoute = (choices, route, module) => {
34
+ const { file, path } = placeOf(route);
35
+ return {
36
+ path,
37
+ kind: "whole",
38
+ text: lines(`// ${route.says} Written by \`ref0-git init\`.`, `import type { Route } from './+types/${file.replace(/\.ts$/, "")}';`, "", matcherImport(choices), "", "// Loaded on the first request, so `react-router build` opens no database and needs no secret.", ...routeHandler(choices, path, module), "", "export const loader = ({ request }: Route.LoaderArgs) => git(request);", "", "export const action = ({ request }: Route.ActionArgs) => git(request);", "")
39
+ };
40
+ };
41
+ /** React Router's resource routes for `choices`, over `framework`'s server module. */
42
+ const reactRouterRouteFiles = (choices, framework) => fileRoutes(choices).map((route) => resourceRoute(choices, route, framework.serverModule));
43
+ /** `app/routes.ts`'s lines for the routes, where it lists its routes and doesn't list these yet. */
44
+ const reactRouterSteps = (choices, framework) => {
45
+ const routes = framework.config?.text ?? "";
46
+ const missing = fileRoutes(choices).map(placeOf).filter((place) => ["\"", "'"].every((quote) => !routes.includes(`${quote}routes/${place.file}${quote}`)));
47
+ if (framework.flatRoutes === true || missing.length === 0) return [];
48
+ return [{
49
+ path: "app/routes.ts",
50
+ why: "yours",
51
+ says: "List Git's routes in app/routes.ts, which routes only the files it names, before any route of the app's that takes every path",
52
+ lines: [
53
+ "import { route } from '@react-router/dev/routes';",
54
+ "",
55
+ ...missing.map((place) => place.line)
56
+ ]
57
+ }];
58
+ };
59
+ export { reactRouterRouteFiles, reactRouterSteps };