ref0-git 0.0.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +127 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +562 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +487 -0
- package/app/apps/github/src/palette/server.ts +107 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +606 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +528 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +69 -0
- package/dist/cli/helpers.mjs +184 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +136 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +80 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +203 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +460 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +384 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useNavigate } from '@tanstack/react-router';
|
|
3
|
+
import { TagIcon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { Go } from '../code/controls.tsx';
|
|
6
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
7
|
+
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
8
|
+
import { TabIndicator, tabLinkClass } from '../components/tab-indicator.tsx';
|
|
9
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
10
|
+
import { Button } from '../components/ui/button.tsx';
|
|
11
|
+
import {
|
|
12
|
+
Empty,
|
|
13
|
+
EmptyDescription,
|
|
14
|
+
EmptyHeader,
|
|
15
|
+
EmptyMedia,
|
|
16
|
+
EmptyTitle,
|
|
17
|
+
} from '../components/ui/empty.tsx';
|
|
18
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
19
|
+
import { useAllowed } from '../hooks/allowed.ts';
|
|
20
|
+
import { ReleaseView } from './release-view.tsx';
|
|
21
|
+
import { deleteRelease, latestRelease, releaseList, type Release } from './releases.ts';
|
|
22
|
+
import { CreateButton } from '../components/create-button.tsx';
|
|
23
|
+
import { ListToolbar } from '../components/list-toolbar.tsx';
|
|
24
|
+
|
|
25
|
+
/** The releases' own links: Releases, Tags, and a new release for whoever may make one. */
|
|
26
|
+
export function ReleasesBar({
|
|
27
|
+
place,
|
|
28
|
+
current,
|
|
29
|
+
}: {
|
|
30
|
+
readonly place: RepoPlace;
|
|
31
|
+
readonly current: string;
|
|
32
|
+
}) {
|
|
33
|
+
const allowed = useAllowed(place);
|
|
34
|
+
const base = `/${place.owner}/${place.repo}`;
|
|
35
|
+
// Underlined as the repo's own tabs are, since each is a page of its own.
|
|
36
|
+
const tab = (name: string, href: string) => (
|
|
37
|
+
<li>
|
|
38
|
+
<Go
|
|
39
|
+
href={href}
|
|
40
|
+
aria-current={current === name ? 'page' : undefined}
|
|
41
|
+
className={`flex px-3 py-2 ${tabLinkClass}`}
|
|
42
|
+
>
|
|
43
|
+
{name}
|
|
44
|
+
</Go>
|
|
45
|
+
</li>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<ListToolbar
|
|
50
|
+
className="border-b"
|
|
51
|
+
tabs={
|
|
52
|
+
<nav aria-label="Releases">
|
|
53
|
+
<ul className="relative -mb-px flex gap-1 text-sm">
|
|
54
|
+
{tab('Releases', `${base}/releases`)}
|
|
55
|
+
{tab('Tags', `${base}/tags`)}
|
|
56
|
+
<TabIndicator />
|
|
57
|
+
</ul>
|
|
58
|
+
</nav>
|
|
59
|
+
}
|
|
60
|
+
buttons={
|
|
61
|
+
allowed.has('release.create') ? (
|
|
62
|
+
<CreateButton hotkey className="mb-1.5" render={<Go href={`${base}/releases/new`} />}>
|
|
63
|
+
Draft a new release
|
|
64
|
+
</CreateButton>
|
|
65
|
+
) : undefined
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The repo's releases, newest first, 10 a page, with More releases while more are left. */
|
|
72
|
+
export function ReleaseList({ place }: { readonly place: RepoPlace }) {
|
|
73
|
+
const pages = useInfiniteQuery(releaseList(place));
|
|
74
|
+
const latest = useQuery(latestRelease(place)).data;
|
|
75
|
+
const allowed = useAllowed(place);
|
|
76
|
+
const releases = pages.data?.pages.flatMap((page) => page.releases) ?? [];
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="flex flex-col gap-3">
|
|
80
|
+
{pages.error !== null ? (
|
|
81
|
+
<Alert variant="destructive">
|
|
82
|
+
<AlertDescription>{pages.error.message}. Reload the page to try again.</AlertDescription>
|
|
83
|
+
</Alert>
|
|
84
|
+
) : pages.data === undefined ? (
|
|
85
|
+
<Skeleton className="h-40" />
|
|
86
|
+
) : releases.length === 0 ? (
|
|
87
|
+
<Empty>
|
|
88
|
+
<EmptyHeader>
|
|
89
|
+
<EmptyMedia variant="icon">
|
|
90
|
+
<TagIcon />
|
|
91
|
+
</EmptyMedia>
|
|
92
|
+
<EmptyTitle>There aren't any releases here</EmptyTitle>
|
|
93
|
+
<EmptyDescription>
|
|
94
|
+
A release packages a tag's source with its notes and files.
|
|
95
|
+
</EmptyDescription>
|
|
96
|
+
</EmptyHeader>
|
|
97
|
+
</Empty>
|
|
98
|
+
) : (
|
|
99
|
+
releases.map((release) => (
|
|
100
|
+
<ReleaseView
|
|
101
|
+
key={release.id}
|
|
102
|
+
place={place}
|
|
103
|
+
release={release}
|
|
104
|
+
latest={release.tag === latest?.tag}
|
|
105
|
+
allowed={allowed}
|
|
106
|
+
heading="h2"
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
)}
|
|
110
|
+
{pages.hasNextPage && (
|
|
111
|
+
<Button
|
|
112
|
+
variant="outline"
|
|
113
|
+
className="self-center"
|
|
114
|
+
disabled={pages.isFetchingNextPage}
|
|
115
|
+
onClick={() => void pages.fetchNextPage()}
|
|
116
|
+
>
|
|
117
|
+
More releases
|
|
118
|
+
</Button>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A release's page: the release, and Delete for whoever may delete it, asked in a dialog. */
|
|
125
|
+
export function ReleasePage({
|
|
126
|
+
place,
|
|
127
|
+
release,
|
|
128
|
+
}: {
|
|
129
|
+
readonly place: RepoPlace;
|
|
130
|
+
readonly release: Release;
|
|
131
|
+
}) {
|
|
132
|
+
const allowed = useAllowed(place);
|
|
133
|
+
const latest = useQuery(latestRelease(place)).data;
|
|
134
|
+
const navigate = useNavigate();
|
|
135
|
+
const client = useQueryClient();
|
|
136
|
+
const deleted = useMutation({
|
|
137
|
+
mutationFn: () => deleteRelease(place, release.id),
|
|
138
|
+
onSuccess: async () => {
|
|
139
|
+
await client.invalidateQueries({ queryKey: ['releases', place.owner, place.repo] });
|
|
140
|
+
await client.invalidateQueries({ queryKey: latestRelease(place).queryKey });
|
|
141
|
+
await navigate({ href: `/${place.owner}/${place.repo}/releases` });
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className="flex flex-col gap-3">
|
|
147
|
+
<ReleasesBar place={place} current="" />
|
|
148
|
+
<ReleaseView
|
|
149
|
+
place={place}
|
|
150
|
+
release={release}
|
|
151
|
+
latest={release.tag === latest?.tag}
|
|
152
|
+
allowed={allowed}
|
|
153
|
+
heading="h1"
|
|
154
|
+
/>
|
|
155
|
+
{allowed.has('release.delete') && (
|
|
156
|
+
<div className="flex flex-col items-start gap-2">
|
|
157
|
+
<ConfirmAction
|
|
158
|
+
label="Delete release"
|
|
159
|
+
title={`Delete the release ${release.name}?`}
|
|
160
|
+
description={`Its notes and files are deleted for good. Its tag, ${release.tag}, stays where it is.`}
|
|
161
|
+
disabled={deleted.isPending}
|
|
162
|
+
onConfirm={() => deleted.mutate()}
|
|
163
|
+
/>
|
|
164
|
+
{deleted.error !== null && (
|
|
165
|
+
<Alert variant="destructive">
|
|
166
|
+
<AlertDescription>{deleted.error.message}</AlertDescription>
|
|
167
|
+
</Alert>
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { FileArchiveIcon, PackageIcon, TagIcon } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
import { archiveLink, type ArchiveAsk } from '../clients/transfers.ts';
|
|
5
|
+
import { day, Go, sizeText } from '../code/controls.tsx';
|
|
6
|
+
import { releaseEditHref, releaseHref, type RepoPlace } from '../code/places.ts';
|
|
7
|
+
import { Markdown } from '../components/markdown/markdown.tsx';
|
|
8
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
9
|
+
import { Badge } from '../components/ui/badge.tsx';
|
|
10
|
+
import { Button, buttonVariants } from '../components/ui/button.tsx';
|
|
11
|
+
import {
|
|
12
|
+
Card,
|
|
13
|
+
CardAction,
|
|
14
|
+
CardContent,
|
|
15
|
+
CardDescription,
|
|
16
|
+
CardFooter,
|
|
17
|
+
CardHeader,
|
|
18
|
+
CardTitle,
|
|
19
|
+
} from '../components/ui/card.tsx';
|
|
20
|
+
import {
|
|
21
|
+
Table,
|
|
22
|
+
TableBody,
|
|
23
|
+
TableCell,
|
|
24
|
+
TableHead,
|
|
25
|
+
TableHeader,
|
|
26
|
+
TableRow,
|
|
27
|
+
} from '../components/ui/table.tsx';
|
|
28
|
+
import type { PageOperation } from '../clients/allowed.ts';
|
|
29
|
+
import { downloadHref, type Release } from './releases.ts';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A ref's source as a zip and a tarball: each asks the drop-in, as the session's holder, for the
|
|
33
|
+
* archive's signed link, then follows it, so the session's token never reaches the page.
|
|
34
|
+
*/
|
|
35
|
+
export function SourceCode({
|
|
36
|
+
place,
|
|
37
|
+
at,
|
|
38
|
+
short = false,
|
|
39
|
+
}: {
|
|
40
|
+
readonly place: RepoPlace;
|
|
41
|
+
readonly at: string;
|
|
42
|
+
/** Labels the buttons `zip` and `tar.gz`, as a list's row does; their names stay whole. */
|
|
43
|
+
readonly short?: boolean;
|
|
44
|
+
}) {
|
|
45
|
+
const asked = useMutation({
|
|
46
|
+
mutationFn: async (format: ArchiveAsk['format']) => {
|
|
47
|
+
const data = { owner: place.owner, repo: place.repo, ref: at, format };
|
|
48
|
+
const { link } = await archiveLink({ data });
|
|
49
|
+
if (link === null) throw new Error("The archive isn't available");
|
|
50
|
+
|
|
51
|
+
window.location.assign(link);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
57
|
+
<Button
|
|
58
|
+
variant="outline"
|
|
59
|
+
size="sm"
|
|
60
|
+
aria-label="Source code (zip)"
|
|
61
|
+
onClick={() => asked.mutate('zipball')}
|
|
62
|
+
>
|
|
63
|
+
<FileArchiveIcon data-icon="inline-start" />
|
|
64
|
+
{short ? 'zip' : 'Source code (zip)'}
|
|
65
|
+
</Button>
|
|
66
|
+
<Button
|
|
67
|
+
variant="outline"
|
|
68
|
+
size="sm"
|
|
69
|
+
aria-label="Source code (tar.gz)"
|
|
70
|
+
onClick={() => asked.mutate('tarball')}
|
|
71
|
+
>
|
|
72
|
+
<FileArchiveIcon data-icon="inline-start" />
|
|
73
|
+
{short ? 'tar.gz' : 'Source code (tar.gz)'}
|
|
74
|
+
</Button>
|
|
75
|
+
{asked.error !== null && (
|
|
76
|
+
<Alert variant="destructive">
|
|
77
|
+
<AlertDescription>{asked.error.message}</AlertDescription>
|
|
78
|
+
</Alert>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* One release as GitHub draws it: its name and badges, its tag, author and date, its notes through
|
|
86
|
+
* the Markdown renderer, and its assets, each a plain link the app's download route streams.
|
|
87
|
+
*/
|
|
88
|
+
export function ReleaseView({
|
|
89
|
+
place,
|
|
90
|
+
release,
|
|
91
|
+
latest,
|
|
92
|
+
allowed,
|
|
93
|
+
heading,
|
|
94
|
+
}: {
|
|
95
|
+
readonly place: RepoPlace;
|
|
96
|
+
readonly release: Release;
|
|
97
|
+
readonly latest: boolean;
|
|
98
|
+
readonly allowed: ReadonlySet<PageOperation>;
|
|
99
|
+
readonly heading: 'h1' | 'h2';
|
|
100
|
+
}) {
|
|
101
|
+
const Heading = heading;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<article aria-label={release.name}>
|
|
105
|
+
<Card>
|
|
106
|
+
<CardHeader>
|
|
107
|
+
<CardTitle className="flex flex-wrap items-center gap-2">
|
|
108
|
+
<Heading className="text-lg font-semibold wrap-anywhere">
|
|
109
|
+
<Go href={releaseHref(place, release.tag)} className="hover:underline">
|
|
110
|
+
{release.name}
|
|
111
|
+
</Go>
|
|
112
|
+
</Heading>
|
|
113
|
+
{latest && (
|
|
114
|
+
<Badge variant="outline" className="border-state-open text-state-open">
|
|
115
|
+
Latest
|
|
116
|
+
</Badge>
|
|
117
|
+
)}
|
|
118
|
+
{release.prerelease && <Badge variant="outline">Pre-release</Badge>}
|
|
119
|
+
{release.draft && <Badge variant="secondary">Draft</Badge>}
|
|
120
|
+
</CardTitle>
|
|
121
|
+
<CardDescription className="flex flex-wrap items-center gap-1 wrap-anywhere">
|
|
122
|
+
<TagIcon aria-hidden className="size-3" />
|
|
123
|
+
{release.tag} · {release.author} {release.draft ? 'drafted' : 'released'}{' '}
|
|
124
|
+
{day.format(new Date(release.at))}
|
|
125
|
+
</CardDescription>
|
|
126
|
+
{allowed.has('release.update') && (
|
|
127
|
+
<CardAction>
|
|
128
|
+
<Go
|
|
129
|
+
href={releaseEditHref(place, release.tag)}
|
|
130
|
+
className={buttonVariants({ variant: 'outline', size: 'sm' })}
|
|
131
|
+
>
|
|
132
|
+
Edit
|
|
133
|
+
</Go>
|
|
134
|
+
</CardAction>
|
|
135
|
+
)}
|
|
136
|
+
</CardHeader>
|
|
137
|
+
{release.body.trim() !== '' && (
|
|
138
|
+
<CardContent>
|
|
139
|
+
<Markdown
|
|
140
|
+
text={release.body}
|
|
141
|
+
context={{ kind: 'comment', repo: `${place.owner}/${place.repo}` }}
|
|
142
|
+
/>
|
|
143
|
+
</CardContent>
|
|
144
|
+
)}
|
|
145
|
+
<CardFooter className="flex-col items-stretch">
|
|
146
|
+
<section id="assets" aria-label="Assets" className="flex flex-col gap-2">
|
|
147
|
+
<h3 className="font-semibold">Assets {release.assets.length + 2}</h3>
|
|
148
|
+
{release.assets.length > 0 && (
|
|
149
|
+
<Table aria-label="Files" className="border">
|
|
150
|
+
<TableHeader>
|
|
151
|
+
<TableRow>
|
|
152
|
+
<TableHead>Name</TableHead>
|
|
153
|
+
<TableHead className="text-right">Size</TableHead>
|
|
154
|
+
</TableRow>
|
|
155
|
+
</TableHeader>
|
|
156
|
+
<TableBody>
|
|
157
|
+
{release.assets.map((asset) => (
|
|
158
|
+
<TableRow key={asset.id}>
|
|
159
|
+
<TableCell className="whitespace-normal">
|
|
160
|
+
<a
|
|
161
|
+
href={downloadHref(place, asset)}
|
|
162
|
+
download
|
|
163
|
+
className="flex items-center gap-2 wrap-anywhere hover:underline"
|
|
164
|
+
>
|
|
165
|
+
<PackageIcon aria-hidden className="size-3 shrink-0" />
|
|
166
|
+
{asset.name}
|
|
167
|
+
</a>
|
|
168
|
+
</TableCell>
|
|
169
|
+
<TableCell className="text-right text-muted-foreground tabular-nums">
|
|
170
|
+
{sizeText(asset.size)}
|
|
171
|
+
</TableCell>
|
|
172
|
+
</TableRow>
|
|
173
|
+
))}
|
|
174
|
+
</TableBody>
|
|
175
|
+
</Table>
|
|
176
|
+
)}
|
|
177
|
+
<SourceCode place={place} at={release.tag} />
|
|
178
|
+
</section>
|
|
179
|
+
</CardFooter>
|
|
180
|
+
</Card>
|
|
181
|
+
</article>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import type { components } from '@octokit/openapi-types';
|
|
2
|
+
import { queryOptions } from '@tanstack/react-query';
|
|
3
|
+
import * as Option from 'effect/Option';
|
|
4
|
+
import * as Schema from 'effect/Schema';
|
|
5
|
+
|
|
6
|
+
import { github } from '../clients/clients.ts';
|
|
7
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
8
|
+
import { everyNamedPage, failure } from '../hooks/answers.ts';
|
|
9
|
+
import { readRefPage } from '../code/ref-pages.ts';
|
|
10
|
+
import { nextCursor } from '../hooks/repos.ts';
|
|
11
|
+
|
|
12
|
+
type RestRelease = components['schemas']['release'];
|
|
13
|
+
|
|
14
|
+
/** A file a release carries. */
|
|
15
|
+
export interface Asset {
|
|
16
|
+
readonly id: number;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly size: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A release, as its page shows it. */
|
|
22
|
+
export interface Release {
|
|
23
|
+
readonly id: number;
|
|
24
|
+
readonly tag: string;
|
|
25
|
+
/** The branch or commit its tag is made from, while the tag doesn't exist yet. */
|
|
26
|
+
readonly target: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly body: string;
|
|
29
|
+
readonly draft: boolean;
|
|
30
|
+
readonly prerelease: boolean;
|
|
31
|
+
readonly author: string;
|
|
32
|
+
/** When it was published, or made, for a draft. */
|
|
33
|
+
readonly at: string;
|
|
34
|
+
readonly assets: readonly Asset[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const releaseOf = (release: RestRelease): Release => ({
|
|
38
|
+
id: release.id,
|
|
39
|
+
tag: release.tag_name,
|
|
40
|
+
target: release.target_commitish,
|
|
41
|
+
name: release.name ?? release.tag_name,
|
|
42
|
+
body: release.body ?? '',
|
|
43
|
+
draft: release.draft,
|
|
44
|
+
prerelease: release.prerelease,
|
|
45
|
+
author: release.author.login,
|
|
46
|
+
at: release.published_at ?? release.created_at,
|
|
47
|
+
assets: release.assets.map((asset) => ({ id: asset.id, name: asset.name, size: asset.size })),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/** How many releases a page of the list shows, as GitHub's does. */
|
|
51
|
+
export const releasesPerPage = 10;
|
|
52
|
+
|
|
53
|
+
/** A page of releases, and the cursor of the one after it. */
|
|
54
|
+
export interface ReleasePage {
|
|
55
|
+
readonly releases: readonly Release[];
|
|
56
|
+
readonly next: string | undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A page of `perPage` releases from cursor `after`. */
|
|
60
|
+
const readReleases = async (place: RepoPlace, perPage: number, after: string | undefined) => {
|
|
61
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
62
|
+
const paging = { per_page: perPage, after };
|
|
63
|
+
const answer = await github.GET('/repos/{owner}/{repo}/releases', {
|
|
64
|
+
params: { path: place, query: { ...paging } },
|
|
65
|
+
});
|
|
66
|
+
if (answer.data === undefined) throw failure("The releases didn't load", answer);
|
|
67
|
+
|
|
68
|
+
const page: ReleasePage = {
|
|
69
|
+
releases: answer.data.map(releaseOf),
|
|
70
|
+
next: nextCursor(answer.response.headers.get('link')),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return page;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const firstPage: string | undefined = undefined;
|
|
77
|
+
|
|
78
|
+
/** The repo's releases, newest first, a page at a time as the reader asks for more. */
|
|
79
|
+
export const releaseList = (place: RepoPlace) => ({
|
|
80
|
+
queryKey: ['releases', place.owner, place.repo] as const,
|
|
81
|
+
queryFn: ({ pageParam }: { readonly pageParam: string | undefined }) =>
|
|
82
|
+
readReleases(place, releasesPerPage, pageParam),
|
|
83
|
+
initialPageParam: firstPage,
|
|
84
|
+
getNextPageParam: (last: ReleasePage) => last.next,
|
|
85
|
+
staleTime: 10_000,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** How many pages of 100 releases a draft is looked for in, newest first. */
|
|
89
|
+
const draftPages = 10;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The draft on `tag`, which only its list shows: the drop-in, as GitHub, finds no draft by its
|
|
93
|
+
* tag, and lists drafts only to whoever may edit the repo's releases.
|
|
94
|
+
*/
|
|
95
|
+
const draftOn = async (place: RepoPlace, tag: string) => {
|
|
96
|
+
let after: string | undefined;
|
|
97
|
+
|
|
98
|
+
for (let page = 0; page < draftPages; page += 1) {
|
|
99
|
+
const read = await readReleases(place, 100, after);
|
|
100
|
+
const draft = read.releases.find((release) => release.tag === tag);
|
|
101
|
+
if (draft !== undefined) return draft;
|
|
102
|
+
|
|
103
|
+
after = read.next;
|
|
104
|
+
|
|
105
|
+
if (after === undefined) break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** The repo's latest release, as GitHub marks it, or `null` when it has none. */
|
|
112
|
+
export const latestRelease = (place: RepoPlace) =>
|
|
113
|
+
queryOptions({
|
|
114
|
+
queryKey: ['release', place.owner, place.repo, 'latest'],
|
|
115
|
+
queryFn: async (): Promise<Release | null> => {
|
|
116
|
+
const answer = await github.GET('/repos/{owner}/{repo}/releases/latest', {
|
|
117
|
+
params: { path: place },
|
|
118
|
+
});
|
|
119
|
+
if (answer.response.status === 404) return null;
|
|
120
|
+
|
|
121
|
+
if (answer.data === undefined) throw failure("The latest release didn't load", answer);
|
|
122
|
+
|
|
123
|
+
return releaseOf(answer.data);
|
|
124
|
+
},
|
|
125
|
+
staleTime: 10_000,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/** The release of `tag`, or its draft, or `null` when there's none the viewer can read. */
|
|
129
|
+
export const releaseAt = (place: RepoPlace, tag: string) =>
|
|
130
|
+
queryOptions({
|
|
131
|
+
queryKey: ['release', place.owner, place.repo, 'tag', tag],
|
|
132
|
+
queryFn: async () => {
|
|
133
|
+
const answer = await github.GET('/repos/{owner}/{repo}/releases/tags/{tag}', {
|
|
134
|
+
params: { path: { ...place, tag } },
|
|
135
|
+
});
|
|
136
|
+
if (answer.response.status === 404) return draftOn(place, tag);
|
|
137
|
+
|
|
138
|
+
if (answer.data === undefined) throw failure("The release didn't load", answer);
|
|
139
|
+
|
|
140
|
+
return releaseOf(answer.data);
|
|
141
|
+
},
|
|
142
|
+
staleTime: 10_000,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/** What a release's form sets. A new tag is made at `target`, a branch. */
|
|
146
|
+
export interface Drafted {
|
|
147
|
+
readonly tag: string;
|
|
148
|
+
readonly target: string;
|
|
149
|
+
readonly name: string;
|
|
150
|
+
readonly body: string;
|
|
151
|
+
readonly draft: boolean;
|
|
152
|
+
readonly prerelease: boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const bodyOf = (drafted: Drafted) => ({
|
|
156
|
+
tag_name: drafted.tag,
|
|
157
|
+
target_commitish: drafted.target,
|
|
158
|
+
name: drafted.name,
|
|
159
|
+
body: drafted.body,
|
|
160
|
+
draft: drafted.draft,
|
|
161
|
+
prerelease: drafted.prerelease,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
/** Publishes a release, or saves it as a draft, and answers it as it's made. */
|
|
165
|
+
export const createRelease = async (place: RepoPlace, drafted: Drafted) => {
|
|
166
|
+
const answer = await github.POST('/repos/{owner}/{repo}/releases', {
|
|
167
|
+
params: { path: place },
|
|
168
|
+
body: bodyOf(drafted),
|
|
169
|
+
});
|
|
170
|
+
if (answer.data === undefined) throw failure("The release wasn't made", answer);
|
|
171
|
+
|
|
172
|
+
return releaseOf(answer.data);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** Changes release `id`, and answers it as it is after. */
|
|
176
|
+
export const changeRelease = async (place: RepoPlace, id: number, drafted: Drafted) => {
|
|
177
|
+
const answer = await github.PATCH('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
178
|
+
params: { path: { ...place, release_id: id } },
|
|
179
|
+
body: bodyOf(drafted),
|
|
180
|
+
});
|
|
181
|
+
if (answer.data === undefined) throw failure("The release didn't change", answer);
|
|
182
|
+
|
|
183
|
+
return releaseOf(answer.data);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/** Deletes release `id`; its tag stays. */
|
|
187
|
+
export const deleteRelease = async (place: RepoPlace, id: number) => {
|
|
188
|
+
const answer = await github.DELETE('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
189
|
+
params: { path: { ...place, release_id: id } },
|
|
190
|
+
});
|
|
191
|
+
if (!answer.response.ok) throw failure("The release wasn't deleted", answer);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** Deletes asset `id` from its release. */
|
|
195
|
+
export const deleteAsset = async (place: RepoPlace, id: number) => {
|
|
196
|
+
const answer = await github.DELETE('/repos/{owner}/{repo}/releases/assets/{asset_id}', {
|
|
197
|
+
params: { path: { ...place, asset_id: id } },
|
|
198
|
+
});
|
|
199
|
+
if (!answer.response.ok) throw failure("The asset wasn't deleted", answer);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const segment = encodeURIComponent;
|
|
203
|
+
|
|
204
|
+
/** An uploaded asset, as the drop-in answers it. */
|
|
205
|
+
const UploadedAsset = Schema.Struct({
|
|
206
|
+
id: Schema.Number,
|
|
207
|
+
name: Schema.String,
|
|
208
|
+
size: Schema.Number,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const uploadedOf = Schema.decodeUnknownOption(UploadedAsset);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Uploads `file` to release `id`, streamed from the browser through the app's upload route,
|
|
215
|
+
* which adds the session; the page never holds its bytes. Answers the asset it made. When no
|
|
216
|
+
* answer comes, the upload may still have landed: `lost` is called before it fails.
|
|
217
|
+
*/
|
|
218
|
+
export const uploadAsset = async (
|
|
219
|
+
place: RepoPlace,
|
|
220
|
+
id: number,
|
|
221
|
+
file: File,
|
|
222
|
+
lost: () => void,
|
|
223
|
+
): Promise<Asset> => {
|
|
224
|
+
const path = `/uploads/${segment(place.owner)}/${segment(place.repo)}/${id}`;
|
|
225
|
+
const sent = fetch(`${path}?name=${segment(file.name)}`, {
|
|
226
|
+
method: 'POST',
|
|
227
|
+
body: file,
|
|
228
|
+
headers: { 'content-type': file.type === '' ? 'application/octet-stream' : file.type },
|
|
229
|
+
});
|
|
230
|
+
const answer = await sent.catch(() => {
|
|
231
|
+
lost();
|
|
232
|
+
throw new Error(`${file.name}'s upload got no answer: submit again to finish`);
|
|
233
|
+
});
|
|
234
|
+
const said: unknown = await answer.json().catch(() => undefined);
|
|
235
|
+
|
|
236
|
+
if (answer.ok) {
|
|
237
|
+
return Option.getOrThrowWith(uploadedOf(said), () => new Error(`${file.name}: no asset`));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// The host's platform may cap a request below the drop-in's limit, as Cloudflare's plans do.
|
|
241
|
+
if (answer.status === 413) {
|
|
242
|
+
throw new Error(`${file.name} didn't upload: it's larger than this host takes in one request`);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
throw failure(`${file.name} didn't upload`, { error: said, response: answer });
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/** A plain link to `asset`'s bytes, which the app's download route streams with the session. */
|
|
249
|
+
export const downloadHref = (place: RepoPlace, asset: Asset) =>
|
|
250
|
+
`/downloads/${segment(place.owner)}/${segment(place.repo)}/${asset.id}`;
|
|
251
|
+
|
|
252
|
+
/** A tag: the commit it names, when its author made it, and whether a release is made from it. */
|
|
253
|
+
export interface Tag {
|
|
254
|
+
readonly name: string;
|
|
255
|
+
/** Missing for a tag whose chain ends at a tree or a blob, which no commit dates. */
|
|
256
|
+
readonly commit: string | undefined;
|
|
257
|
+
readonly date: string | undefined;
|
|
258
|
+
readonly released: boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Tag names in version order: `v1.10` after `v1.9`. */
|
|
262
|
+
const versions = new Intl.Collator('en', { numeric: true });
|
|
263
|
+
|
|
264
|
+
/** The repo's tags, newest version first, and whether it has more than were read. */
|
|
265
|
+
export interface Tags {
|
|
266
|
+
readonly tags: readonly Tag[];
|
|
267
|
+
readonly more: boolean;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The repo's tags, newest version first: the drop-in lists them by name, so the page reads them,
|
|
272
|
+
* each with its commit's author and date, as up to 100 a call for `pagesMost` calls, and orders
|
|
273
|
+
* those; `more` says the repo has more than that. A page that reads tags' targets can hold fewer
|
|
274
|
+
* than 100 and still name the next, as the drop-in's `refTargets` bound has it. The newest 100 releases, read beside them, say which
|
|
275
|
+
* tags a release is made from: one call more.
|
|
276
|
+
*/
|
|
277
|
+
export const tagsOf = (place: RepoPlace) =>
|
|
278
|
+
queryOptions({
|
|
279
|
+
queryKey: ['tags', place.owner, place.repo],
|
|
280
|
+
queryFn: async (): Promise<Tags> => {
|
|
281
|
+
const [read, releases] = await Promise.all([
|
|
282
|
+
everyNamedPage(async (after) => {
|
|
283
|
+
const page = await readRefPage(place, {
|
|
284
|
+
prefix: 'refs/tags/',
|
|
285
|
+
first: 100,
|
|
286
|
+
after,
|
|
287
|
+
search: '',
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return { rows: page.rows, next: page.next };
|
|
291
|
+
}),
|
|
292
|
+
readReleases(place, 100, undefined),
|
|
293
|
+
]);
|
|
294
|
+
const released = new Set(releases.releases.map((release) => release.tag));
|
|
295
|
+
|
|
296
|
+
const tags = read.rows
|
|
297
|
+
.map((row): Tag => ({
|
|
298
|
+
name: row.name,
|
|
299
|
+
commit: row.commit,
|
|
300
|
+
date: row.author?.date,
|
|
301
|
+
released: released.has(row.name),
|
|
302
|
+
}))
|
|
303
|
+
.toSorted((a, b) => versions.compare(b.name, a.name));
|
|
304
|
+
|
|
305
|
+
return { tags, more: read.more };
|
|
306
|
+
},
|
|
307
|
+
staleTime: 30_000,
|
|
308
|
+
});
|