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,231 @@
|
|
|
1
|
+
import { queryOptions, type QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import type { components } from '../../generated/git-rest.ts';
|
|
4
|
+
import { git, github } from '../clients/clients.ts';
|
|
5
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
6
|
+
import { everyNamedPage, everyPage, failure } from '../hooks/answers.ts';
|
|
7
|
+
import {
|
|
8
|
+
branch,
|
|
9
|
+
dequeuePull,
|
|
10
|
+
enqueuePull,
|
|
11
|
+
pullAt,
|
|
12
|
+
repoId,
|
|
13
|
+
type PullDetail,
|
|
14
|
+
} from '../pulls/pull.ts';
|
|
15
|
+
|
|
16
|
+
export type QueueEntry = components['schemas']['QueueEntry'];
|
|
17
|
+
|
|
18
|
+
export type QueueHold = components['schemas']['QueueHold'];
|
|
19
|
+
|
|
20
|
+
/** The branch the host queues: its `main`, as `git.ts` sets the queue up. */
|
|
21
|
+
export const queuedBranch = 'main';
|
|
22
|
+
|
|
23
|
+
const target = branch(queuedBranch);
|
|
24
|
+
|
|
25
|
+
/** How often the queue's page reads it again, until Git's events can start from now. */
|
|
26
|
+
export const queuePoll = 5_000;
|
|
27
|
+
|
|
28
|
+
/** How many entries a page of the queue shows. */
|
|
29
|
+
const entriesPerPage = 100;
|
|
30
|
+
|
|
31
|
+
/** A page of the queue's entries, in the order the queue tries them, and the next page's cursor. */
|
|
32
|
+
export interface EntryPage {
|
|
33
|
+
readonly entries: readonly QueueEntry[];
|
|
34
|
+
readonly next: string | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const firstPage: string | undefined = undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The queue's open entries, a page at a time as the reader asks for more: an empty first page
|
|
41
|
+
* when the host keeps no queue, as Git answers `NOT_FOUND` then.
|
|
42
|
+
*/
|
|
43
|
+
export const queueEntries = (place: RepoPlace) => ({
|
|
44
|
+
queryKey: ['queue', place.owner, place.repo, 'entries'] as const,
|
|
45
|
+
queryFn: async ({ pageParam }: { readonly pageParam: string | undefined }) => {
|
|
46
|
+
const first = { target, limit: `${entriesPerPage}` };
|
|
47
|
+
const answer = await git.GET('/repos/{repo}/-/queue/entries', {
|
|
48
|
+
params: {
|
|
49
|
+
path: { repo: repoId(place) },
|
|
50
|
+
query: pageParam === undefined ? first : { ...first, after: pageParam },
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (answer.response.status === 404) return { entries: [], next: undefined };
|
|
54
|
+
|
|
55
|
+
if (answer.data === undefined) throw failure("The merge queue didn't load", answer);
|
|
56
|
+
|
|
57
|
+
return { entries: answer.data.items, next: answer.data.next };
|
|
58
|
+
},
|
|
59
|
+
initialPageParam: firstPage,
|
|
60
|
+
getNextPageParam: (last: EntryPage) => last.next,
|
|
61
|
+
staleTime: 2_000,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/** As many holds as a page of Git's lists holds at most. */
|
|
65
|
+
const limit = '100';
|
|
66
|
+
|
|
67
|
+
/** The holds on the whole of the queue, each with why. */
|
|
68
|
+
export const queueHolds = (place: RepoPlace) =>
|
|
69
|
+
queryOptions({
|
|
70
|
+
queryKey: ['queue', place.owner, place.repo, 'holds'],
|
|
71
|
+
queryFn: async (): Promise<readonly QueueHold[]> => {
|
|
72
|
+
// Git lists entries' holds here too, each by the entry it was made on.
|
|
73
|
+
const read = await everyNamedPage(async (after) => {
|
|
74
|
+
const answer = await git.GET('/repos/{repo}/-/queue/holds', {
|
|
75
|
+
params: {
|
|
76
|
+
path: { repo: repoId(place) },
|
|
77
|
+
// A hundred a page, so ten pages hold the 1,000 active holds Git keeps at most.
|
|
78
|
+
query: after === undefined ? { target, limit } : { target, limit, after },
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
if (answer.response.status === 404) return { rows: [], next: undefined };
|
|
82
|
+
|
|
83
|
+
if (answer.data === undefined) throw failure("The queue's holds didn't load", answer);
|
|
84
|
+
|
|
85
|
+
return { rows: answer.data.items, next: answer.data.next };
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return read.rows.filter((hold) => 'target' in hold);
|
|
89
|
+
},
|
|
90
|
+
staleTime: 2_000,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The holds on `entry`, each with why: those made on it, and, while it's its key's, those made on
|
|
95
|
+
* entries it replaced, which a hold follows.
|
|
96
|
+
*/
|
|
97
|
+
export const entryHolds = (place: RepoPlace, entry: string) =>
|
|
98
|
+
queryOptions({
|
|
99
|
+
queryKey: ['queue', place.owner, place.repo, 'holds', entry],
|
|
100
|
+
queryFn: async (): Promise<readonly QueueHold[]> => {
|
|
101
|
+
const read = await everyNamedPage(async (after) => {
|
|
102
|
+
const answer = await git.GET('/queue/entries/{entry}/holds', {
|
|
103
|
+
params: { path: { entry }, query: after === undefined ? { limit } : { limit, after } },
|
|
104
|
+
});
|
|
105
|
+
if (answer.data === undefined) throw failure("The entry's holds didn't load", answer);
|
|
106
|
+
|
|
107
|
+
return { rows: answer.data.items, next: answer.data.next };
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return read.rows;
|
|
111
|
+
},
|
|
112
|
+
staleTime: 2_000,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** A commit the queue built to try entries together before it merges them: what its checks run on. */
|
|
116
|
+
export interface Candidate {
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly sha: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The queue's open candidates that Git has built, in the order it opened them, each a commit its
|
|
123
|
+
* checks run on: none when the host keeps no queue, as Git answers `NOT_FOUND` then. One still
|
|
124
|
+
* building has no commit yet, so nothing to check.
|
|
125
|
+
*/
|
|
126
|
+
export const queueCandidates = (place: RepoPlace) =>
|
|
127
|
+
queryOptions({
|
|
128
|
+
queryKey: ['queue', place.owner, place.repo, 'candidates'],
|
|
129
|
+
queryFn: async (): Promise<readonly Candidate[]> => {
|
|
130
|
+
const read = await everyNamedPage(async (after) => {
|
|
131
|
+
const answer = await git.GET('/repos/{repo}/-/queue/candidates', {
|
|
132
|
+
params: {
|
|
133
|
+
path: { repo: repoId(place) },
|
|
134
|
+
query: after === undefined ? { target, limit } : { target, limit, after },
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
if (answer.response.status === 404) return { rows: [], next: undefined };
|
|
138
|
+
|
|
139
|
+
if (answer.data === undefined) throw failure("The queue's candidates didn't load", answer);
|
|
140
|
+
|
|
141
|
+
return { rows: answer.data.items, next: answer.data.next };
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return read.rows.flatMap(({ id, commit }) =>
|
|
145
|
+
commit === undefined ? [] : [{ id, sha: commit }],
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
staleTime: 2_000,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
/** The pull request an entry merges, from its key: the drop-in keys its own `pr-<number>`. */
|
|
152
|
+
export const pullOfEntry = (entry: QueueEntry) => {
|
|
153
|
+
const number = /^pr-([1-9]\d*)$/.exec(entry.key)?.[1];
|
|
154
|
+
|
|
155
|
+
return number === undefined ? undefined : Number(number);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The titles of the open pull requests into the queued branch, by number, for the entries' rows:
|
|
160
|
+
* one list read for the whole queue, since every entry's pull request is open there.
|
|
161
|
+
*/
|
|
162
|
+
export const queuedTitles = (place: RepoPlace) =>
|
|
163
|
+
queryOptions({
|
|
164
|
+
queryKey: ['queue', place.owner, place.repo, 'titles'],
|
|
165
|
+
queryFn: async (): Promise<ReadonlyMap<number, string>> => {
|
|
166
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
167
|
+
const read = await everyPage(async (after) => {
|
|
168
|
+
const answer = await github.GET('/repos/{owner}/{repo}/pulls', {
|
|
169
|
+
params: {
|
|
170
|
+
path: place,
|
|
171
|
+
query: { ...{ state: 'open', base: queuedBranch, per_page: 100, after } },
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
if (answer.data === undefined) throw failure("The pull requests didn't load", answer);
|
|
175
|
+
|
|
176
|
+
const rows = answer.data.map((pull) => [pull.number, pull.title] as const);
|
|
177
|
+
|
|
178
|
+
return { rows, link: answer.response.headers.get('link') };
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return new Map(read.rows);
|
|
182
|
+
},
|
|
183
|
+
staleTime: 10_000,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/** Reads the queue again, and each pull request's place in it, after the page changes it. */
|
|
187
|
+
export const refreshQueue = (client: QueryClient, place: RepoPlace) =>
|
|
188
|
+
Promise.all([
|
|
189
|
+
client.invalidateQueries({ queryKey: ['queue', place.owner, place.repo] }),
|
|
190
|
+
client.invalidateQueries({ queryKey: ['queued', place.owner, place.repo] }),
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Pull request `number`, read again, if the queue may take it: it must be open, ready rather than
|
|
195
|
+
* a draft, and merge into the queued branch, as its merge box asks.
|
|
196
|
+
*/
|
|
197
|
+
export const queueable = async (client: QueryClient, place: RepoPlace, number: number) => {
|
|
198
|
+
const pull = await client.fetchQuery({ ...pullAt(place, number), staleTime: 0 });
|
|
199
|
+
if (pull === null) throw new Error(`There's no pull request #${number} here`);
|
|
200
|
+
|
|
201
|
+
if (pull.state !== 'open' || pull.merged !== null)
|
|
202
|
+
throw new Error(`Pull request #${number} isn't open`);
|
|
203
|
+
|
|
204
|
+
if (pull.draft) throw new Error(`Pull request #${number} is a draft: mark it ready first`);
|
|
205
|
+
|
|
206
|
+
if (pull.base.ref !== queuedBranch)
|
|
207
|
+
throw new Error(`Pull request #${number} merges into ${pull.base.ref}, not ${queuedBranch}`);
|
|
208
|
+
|
|
209
|
+
return pull;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Adds `chosen` to the queue at the head the person confirmed, once it's checked again it may go:
|
|
214
|
+
* a head pushed since is refused, as `expectedHeadOid` is, and nothing joins.
|
|
215
|
+
*/
|
|
216
|
+
export const addPull = async (client: QueryClient, place: RepoPlace, chosen: PullDetail) => {
|
|
217
|
+
await queueable(client, place, chosen.number);
|
|
218
|
+
|
|
219
|
+
await enqueuePull(chosen);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Takes pull request `number` out of the queue through the drop-in, which names it by its node ID:
|
|
224
|
+
* read again, so a pull request gone since the page read it says so.
|
|
225
|
+
*/
|
|
226
|
+
export const removePull = async (client: QueryClient, place: RepoPlace, number: number) => {
|
|
227
|
+
const pull = await client.fetchQuery({ ...pullAt(place, number), staleTime: 0 });
|
|
228
|
+
if (pull === null) throw new Error(`There's no pull request #${number} here`);
|
|
229
|
+
|
|
230
|
+
await dequeuePull(pull);
|
|
231
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { TagIcon } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
import { Go } from '../code/controls.tsx';
|
|
5
|
+
import { releaseHref, type RepoPlace } from '../code/places.ts';
|
|
6
|
+
import { RelativeTime } from '../components/relative-time.tsx';
|
|
7
|
+
import { Badge } from '../components/ui/badge.tsx';
|
|
8
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
9
|
+
import { latestRelease } from './releases.ts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The repo's latest release, under a heading that links to all of them, as GitHub's column beside
|
|
13
|
+
* a repository's code shows it. Its route reads it before it draws, so it holds its place.
|
|
14
|
+
*/
|
|
15
|
+
export function LatestRelease({ place }: { readonly place: RepoPlace }) {
|
|
16
|
+
const latest = useQuery(latestRelease(place));
|
|
17
|
+
const release = latest.data;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<section aria-label="Releases" className="flex flex-col gap-3">
|
|
21
|
+
<h2 className="text-sm font-medium">
|
|
22
|
+
<Go href={`/${place.owner}/${place.repo}/releases`} className="hover:underline">
|
|
23
|
+
Releases
|
|
24
|
+
</Go>
|
|
25
|
+
</h2>
|
|
26
|
+
{latest.error !== null && release === undefined ? (
|
|
27
|
+
<p className="text-muted-foreground">The latest release didn't load.</p>
|
|
28
|
+
) : release === undefined ? (
|
|
29
|
+
<Skeleton className="h-9" />
|
|
30
|
+
) : release === null ? (
|
|
31
|
+
<p className="text-muted-foreground">No releases published.</p>
|
|
32
|
+
) : (
|
|
33
|
+
<Go
|
|
34
|
+
href={releaseHref(place, release.tag)}
|
|
35
|
+
className="group pressable pressable-row flex items-start gap-2"
|
|
36
|
+
>
|
|
37
|
+
<TagIcon aria-hidden className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
|
|
38
|
+
<span className="flex min-w-0 flex-col gap-0.5">
|
|
39
|
+
<span className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
|
40
|
+
<span className="min-w-0 font-medium [overflow-wrap:anywhere] underline-offset-4 group-hover:text-link group-hover:underline">
|
|
41
|
+
{release.name}
|
|
42
|
+
</span>
|
|
43
|
+
<Badge variant="outline" className="border-state-open text-state-open">
|
|
44
|
+
Latest
|
|
45
|
+
</Badge>
|
|
46
|
+
</span>
|
|
47
|
+
<span className="text-muted-foreground">
|
|
48
|
+
<RelativeTime at={release.at} />
|
|
49
|
+
</span>
|
|
50
|
+
</span>
|
|
51
|
+
</Go>
|
|
52
|
+
)}
|
|
53
|
+
</section>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { readAhead } from '../clients/cached.ts';
|
|
4
|
+
import { loadHome, type HomeLoad } from '../code/load.ts';
|
|
5
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
6
|
+
import { RepoHome } from '../code/repo-home.tsx';
|
|
7
|
+
import { LatestRelease } from './latest-release.tsx';
|
|
8
|
+
import { latestRelease } from './releases.ts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A repository's overview, or `undefined` where no repository is: its home's load, with its latest
|
|
12
|
+
* release read beside it, so the server draws both. A failure of the release shows in its own
|
|
13
|
+
* section, not as the page's.
|
|
14
|
+
*/
|
|
15
|
+
export const loadOverview = async (
|
|
16
|
+
client: QueryClient,
|
|
17
|
+
place: RepoPlace,
|
|
18
|
+
): Promise<HomeLoad | undefined> => {
|
|
19
|
+
const [load] = await Promise.all([
|
|
20
|
+
loadHome(client, place),
|
|
21
|
+
readAhead(client, latestRelease(place)),
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
return load;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** A repository's home, at its default branch, with its latest release beside the code. */
|
|
28
|
+
export function Overview({ load, place }: { readonly load: HomeLoad; readonly place: RepoPlace }) {
|
|
29
|
+
return <RepoHome load={load} beside={<LatestRelease place={place} />} />;
|
|
30
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useNavigate } from '@tanstack/react-router';
|
|
3
|
+
import { LockIcon, PackageIcon } from 'lucide-react';
|
|
4
|
+
import { useRef, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { assetBytesMost } from '../clients/transfers.ts';
|
|
7
|
+
import { sizeText } from '../code/controls.tsx';
|
|
8
|
+
import { releaseHref, type RepoPlace } from '../code/places.ts';
|
|
9
|
+
import { refNames } from '../code/repo.ts';
|
|
10
|
+
import { HotkeyHint, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
11
|
+
import { MarkdownEditor } from '../components/markdown/editor.tsx';
|
|
12
|
+
import { SaveButton } from '../components/save-button.tsx';
|
|
13
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
14
|
+
import { Button } from '../components/ui/button.tsx';
|
|
15
|
+
import { Checkbox } from '../components/ui/checkbox.tsx';
|
|
16
|
+
import { Field, FieldDescription, FieldGroup, FieldLabel } from '../components/ui/field.tsx';
|
|
17
|
+
import { LoadFailed } from '../components/states/states.tsx';
|
|
18
|
+
import { Input } from '../components/ui/input.tsx';
|
|
19
|
+
import {
|
|
20
|
+
Select,
|
|
21
|
+
SelectContent,
|
|
22
|
+
SelectGroup,
|
|
23
|
+
SelectItem,
|
|
24
|
+
SelectTrigger,
|
|
25
|
+
SelectValue,
|
|
26
|
+
} from '../components/ui/select.tsx';
|
|
27
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
28
|
+
import {
|
|
29
|
+
Table,
|
|
30
|
+
TableBody,
|
|
31
|
+
TableCell,
|
|
32
|
+
TableHead,
|
|
33
|
+
TableHeader,
|
|
34
|
+
TableRow,
|
|
35
|
+
} from '../components/ui/table.tsx';
|
|
36
|
+
import { allowedHere } from '../hooks/allowed.ts';
|
|
37
|
+
import { useDraft } from '../hooks/draft.ts';
|
|
38
|
+
import {
|
|
39
|
+
changeRelease,
|
|
40
|
+
createRelease,
|
|
41
|
+
deleteAsset,
|
|
42
|
+
uploadAsset,
|
|
43
|
+
type Asset,
|
|
44
|
+
type Drafted,
|
|
45
|
+
type Release,
|
|
46
|
+
} from './releases.ts';
|
|
47
|
+
|
|
48
|
+
/** What a release's form takes: `target`, the default branch, which a new release's Target starts at. */
|
|
49
|
+
interface FormProps {
|
|
50
|
+
readonly place: RepoPlace;
|
|
51
|
+
readonly target: string;
|
|
52
|
+
readonly release?: Release;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A release's form, new or an edit of `release`, for a viewer the drop-in lets make or change one;
|
|
57
|
+
* anyone else is told they can't, never offered a form that fails.
|
|
58
|
+
*/
|
|
59
|
+
export function ReleaseForm(props: FormProps) {
|
|
60
|
+
const asked = useQuery(allowedHere(props.place));
|
|
61
|
+
const allowed = asked.data;
|
|
62
|
+
const operation = props.release === undefined ? 'release.create' : 'release.update';
|
|
63
|
+
|
|
64
|
+
// A refresh that fails keeps the answer it had, and the form with what's typed in it.
|
|
65
|
+
if (allowed === undefined) {
|
|
66
|
+
return asked.error === null ? (
|
|
67
|
+
<Skeleton className="h-96" />
|
|
68
|
+
) : (
|
|
69
|
+
<LoadFailed message="What you may do here didn't load" />
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!allowed.has(operation)) {
|
|
74
|
+
return (
|
|
75
|
+
<Alert>
|
|
76
|
+
<LockIcon />
|
|
77
|
+
<AlertDescription>
|
|
78
|
+
{props.release === undefined
|
|
79
|
+
? `You can't make releases in ${props.place.owner}/${props.place.repo}.`
|
|
80
|
+
: `You can't edit ${props.release.name}.`}
|
|
81
|
+
</AlertDescription>
|
|
82
|
+
</Alert>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return <ReleaseFields {...props} />;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The form's fields. Its files upload once the release is saved, one at a time, each streamed
|
|
91
|
+
* through the app; a submit after a failure changes the release already saved and uploads only
|
|
92
|
+
* the files that didn't.
|
|
93
|
+
*/
|
|
94
|
+
function ReleaseFields({ place, target, release }: FormProps) {
|
|
95
|
+
const client = useQueryClient();
|
|
96
|
+
const navigate = useNavigate();
|
|
97
|
+
const held = useRef(release);
|
|
98
|
+
// Files sent whose answer never came: each may have landed.
|
|
99
|
+
const unsure = useRef(new Set<File>());
|
|
100
|
+
const draft = useDraft(
|
|
101
|
+
{
|
|
102
|
+
tag: release?.tag ?? '',
|
|
103
|
+
name: release?.name ?? '',
|
|
104
|
+
body: release?.body ?? '',
|
|
105
|
+
prerelease: release?.prerelease ?? false,
|
|
106
|
+
},
|
|
107
|
+
(fields) => ({ ...fields, tag: fields.tag.trim(), name: fields.name.trim() }),
|
|
108
|
+
);
|
|
109
|
+
const { tag, name, body, prerelease } = draft.fields;
|
|
110
|
+
const [files, setFiles] = useState<readonly File[]>([]);
|
|
111
|
+
const [assets, setAssets] = useState(release?.assets ?? []);
|
|
112
|
+
const [from, setFrom] = useState(release?.target ?? target);
|
|
113
|
+
const branches = useQuery({
|
|
114
|
+
queryKey: ['release-targets', place.owner, place.repo],
|
|
115
|
+
queryFn: async () => (await refNames(place, 'branches', undefined)).names,
|
|
116
|
+
enabled: release === undefined,
|
|
117
|
+
});
|
|
118
|
+
// The default branch is offered first, though it's past the first page the drop-in lists.
|
|
119
|
+
const targets = [...new Set([target, ...(branches.data ?? [])])];
|
|
120
|
+
const tooLarge = files.filter((file) => file.size > assetBytesMost);
|
|
121
|
+
|
|
122
|
+
const saved = useMutation({
|
|
123
|
+
mutationFn: async (draft: boolean) => {
|
|
124
|
+
const drafted: Drafted = {
|
|
125
|
+
tag: tag.trim(),
|
|
126
|
+
target: from,
|
|
127
|
+
name: name.trim(),
|
|
128
|
+
body,
|
|
129
|
+
draft,
|
|
130
|
+
prerelease,
|
|
131
|
+
};
|
|
132
|
+
const at = held.current;
|
|
133
|
+
const made =
|
|
134
|
+
at === undefined
|
|
135
|
+
? await createRelease(place, drafted)
|
|
136
|
+
: await changeRelease(place, at.id, drafted);
|
|
137
|
+
held.current = made;
|
|
138
|
+
|
|
139
|
+
// A file sent whose answer was lost landed when the release now has an asset the form
|
|
140
|
+
// didn't know of, of its name and size: it's done, and isn't sent again. Any other file
|
|
141
|
+
// is sent, and one whose name is taken is refused.
|
|
142
|
+
const known = new Set(assets.map((asset) => asset.name));
|
|
143
|
+
const isFile = (asset: Asset, file: File) =>
|
|
144
|
+
asset.name === file.name && asset.size === file.size;
|
|
145
|
+
const landed = made.assets.filter(
|
|
146
|
+
(asset) =>
|
|
147
|
+
!known.has(asset.name) && [...unsure.current].some((file) => isFile(asset, file)),
|
|
148
|
+
);
|
|
149
|
+
const done = new Set(files.filter((file) => landed.some((asset) => isFile(asset, file))));
|
|
150
|
+
setFiles((left) => left.filter((each) => !done.has(each)));
|
|
151
|
+
setAssets((shown) => [...shown, ...landed]);
|
|
152
|
+
|
|
153
|
+
for (const file of files.filter((each) => !done.has(each))) {
|
|
154
|
+
const asset = await uploadAsset(place, made.id, file, () => unsure.current.add(file));
|
|
155
|
+
setFiles((left) => left.filter((each) => each !== file));
|
|
156
|
+
setAssets((shown) => [...shown, asset]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return made;
|
|
160
|
+
},
|
|
161
|
+
onSettled: () => client.invalidateQueries({ queryKey: ['release', place.owner, place.repo] }),
|
|
162
|
+
onSuccess: async (made) => {
|
|
163
|
+
await client.invalidateQueries({ queryKey: ['releases', place.owner, place.repo] });
|
|
164
|
+
await navigate({ href: releaseHref(place, made.tag) });
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const removed = useMutation({
|
|
169
|
+
mutationFn: async (id: number) => {
|
|
170
|
+
await deleteAsset(place, id);
|
|
171
|
+
setAssets((shown) => shown.filter((asset) => asset.id !== id));
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const ready = tag.trim() !== '' && tooLarge.length === 0 && !saved.isPending;
|
|
176
|
+
// An edit, or a file to upload, is a change. Publishing a draft, or saving a published release
|
|
177
|
+
// as a draft again, changes the release without one, so each stays open on its own.
|
|
178
|
+
const changed = draft.changed || files.length > 0;
|
|
179
|
+
const publishes = release === undefined || release.draft || changed;
|
|
180
|
+
const drafts = release === undefined || !release.draft || changed;
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<form
|
|
184
|
+
aria-label={release === undefined ? 'New release' : `Edit ${release.name}`}
|
|
185
|
+
className="flex flex-col gap-3"
|
|
186
|
+
onSubmit={(event) => {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
|
|
189
|
+
if (ready && publishes) saved.mutate(false);
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<FieldGroup>
|
|
193
|
+
<Field>
|
|
194
|
+
<FieldLabel htmlFor="release-tag" required>
|
|
195
|
+
Tag
|
|
196
|
+
</FieldLabel>
|
|
197
|
+
<Input
|
|
198
|
+
id="release-tag"
|
|
199
|
+
value={tag}
|
|
200
|
+
required
|
|
201
|
+
onChange={(event) => draft.set({ tag: event.target.value })}
|
|
202
|
+
/>
|
|
203
|
+
<FieldDescription>
|
|
204
|
+
A tag that doesn't exist yet is made from {from} when the release is published.
|
|
205
|
+
</FieldDescription>
|
|
206
|
+
</Field>
|
|
207
|
+
{release === undefined && (
|
|
208
|
+
<Field>
|
|
209
|
+
<FieldLabel htmlFor="release-target">Target</FieldLabel>
|
|
210
|
+
<Select
|
|
211
|
+
items={targets.map((each) => ({ value: each, label: each }))}
|
|
212
|
+
value={from}
|
|
213
|
+
onValueChange={(picked: string | null) => setFrom(picked ?? target)}
|
|
214
|
+
>
|
|
215
|
+
<SelectTrigger id="release-target" className="w-full sm:w-64">
|
|
216
|
+
<SelectValue />
|
|
217
|
+
</SelectTrigger>
|
|
218
|
+
<SelectContent>
|
|
219
|
+
<SelectGroup>
|
|
220
|
+
{targets.map((each) => (
|
|
221
|
+
<SelectItem key={each} value={each}>
|
|
222
|
+
{each}
|
|
223
|
+
</SelectItem>
|
|
224
|
+
))}
|
|
225
|
+
</SelectGroup>
|
|
226
|
+
</SelectContent>
|
|
227
|
+
</Select>
|
|
228
|
+
</Field>
|
|
229
|
+
)}
|
|
230
|
+
<Field>
|
|
231
|
+
<FieldLabel htmlFor="release-name">Release title</FieldLabel>
|
|
232
|
+
<Input
|
|
233
|
+
id="release-name"
|
|
234
|
+
value={name}
|
|
235
|
+
onChange={(event) => draft.set({ name: event.target.value })}
|
|
236
|
+
/>
|
|
237
|
+
</Field>
|
|
238
|
+
<Field>
|
|
239
|
+
<FieldLabel>Notes</FieldLabel>
|
|
240
|
+
<MarkdownEditor
|
|
241
|
+
repo={`${place.owner}/${place.repo}`}
|
|
242
|
+
label="Notes"
|
|
243
|
+
value={body}
|
|
244
|
+
onChange={(next) => draft.set({ body: next })}
|
|
245
|
+
placeholder="Describe this release"
|
|
246
|
+
/>
|
|
247
|
+
</Field>
|
|
248
|
+
{assets.length > 0 && (
|
|
249
|
+
<Table aria-label="Assets" className="border">
|
|
250
|
+
<TableHeader>
|
|
251
|
+
<TableRow>
|
|
252
|
+
<TableHead>Name</TableHead>
|
|
253
|
+
<TableHead className="text-right">Size</TableHead>
|
|
254
|
+
<TableHead>
|
|
255
|
+
<span className="sr-only">Delete</span>
|
|
256
|
+
</TableHead>
|
|
257
|
+
</TableRow>
|
|
258
|
+
</TableHeader>
|
|
259
|
+
<TableBody>
|
|
260
|
+
{assets.map((asset) => (
|
|
261
|
+
<TableRow key={asset.id}>
|
|
262
|
+
{/* A file's name can be long: the cell wraps it, not the dialog. */}
|
|
263
|
+
<TableCell className="whitespace-normal">
|
|
264
|
+
<span className="flex items-center gap-2 wrap-anywhere">
|
|
265
|
+
<PackageIcon aria-hidden className="size-3 shrink-0" />
|
|
266
|
+
{asset.name}
|
|
267
|
+
</span>
|
|
268
|
+
</TableCell>
|
|
269
|
+
<TableCell className="text-right text-muted-foreground tabular-nums">
|
|
270
|
+
{sizeText(asset.size)}
|
|
271
|
+
</TableCell>
|
|
272
|
+
<TableCell className="text-right">
|
|
273
|
+
<Button
|
|
274
|
+
type="button"
|
|
275
|
+
variant="destructive"
|
|
276
|
+
size="sm"
|
|
277
|
+
aria-label={`Delete ${asset.name}`}
|
|
278
|
+
disabled={removed.isPending}
|
|
279
|
+
onClick={() => removed.mutate(asset.id)}
|
|
280
|
+
>
|
|
281
|
+
Delete
|
|
282
|
+
</Button>
|
|
283
|
+
</TableCell>
|
|
284
|
+
</TableRow>
|
|
285
|
+
))}
|
|
286
|
+
</TableBody>
|
|
287
|
+
</Table>
|
|
288
|
+
)}
|
|
289
|
+
<Field data-invalid={tooLarge.length > 0 || undefined}>
|
|
290
|
+
<FieldLabel htmlFor="release-files">Attach binaries</FieldLabel>
|
|
291
|
+
<Input
|
|
292
|
+
id="release-files"
|
|
293
|
+
type="file"
|
|
294
|
+
multiple
|
|
295
|
+
aria-invalid={tooLarge.length > 0 || undefined}
|
|
296
|
+
onChange={(event) => setFiles([...(event.target.files ?? [])])}
|
|
297
|
+
/>
|
|
298
|
+
<FieldDescription>
|
|
299
|
+
Each file at most {sizeText(assetBytesMost)}, the drop-in's limit, as GitHub's. A host
|
|
300
|
+
may take less in one request.
|
|
301
|
+
</FieldDescription>
|
|
302
|
+
{files.length > 0 && (
|
|
303
|
+
<FieldDescription>
|
|
304
|
+
To upload: {files.map((file) => file.name).join(', ')}
|
|
305
|
+
</FieldDescription>
|
|
306
|
+
)}
|
|
307
|
+
</Field>
|
|
308
|
+
<Field orientation="horizontal">
|
|
309
|
+
<Checkbox
|
|
310
|
+
id="release-prerelease"
|
|
311
|
+
checked={prerelease}
|
|
312
|
+
onCheckedChange={(checked) => draft.set({ prerelease: checked })}
|
|
313
|
+
/>
|
|
314
|
+
<FieldLabel htmlFor="release-prerelease">Set as a pre-release</FieldLabel>
|
|
315
|
+
</Field>
|
|
316
|
+
</FieldGroup>
|
|
317
|
+
{tooLarge.length > 0 && (
|
|
318
|
+
<Alert variant="destructive">
|
|
319
|
+
<AlertDescription>
|
|
320
|
+
{tooLarge.map((file) => file.name).join(', ')} is past the limit.
|
|
321
|
+
</AlertDescription>
|
|
322
|
+
</Alert>
|
|
323
|
+
)}
|
|
324
|
+
<div className="flex justify-end gap-2">
|
|
325
|
+
<Button
|
|
326
|
+
type="button"
|
|
327
|
+
variant="outline"
|
|
328
|
+
disabled={!ready || !drafts}
|
|
329
|
+
onClick={() => saved.mutate(true)}
|
|
330
|
+
>
|
|
331
|
+
Save draft
|
|
332
|
+
</Button>
|
|
333
|
+
<SaveButton
|
|
334
|
+
changed={publishes}
|
|
335
|
+
pending={saved.isPending}
|
|
336
|
+
disabled={!ready}
|
|
337
|
+
data-hotkey={hotkeys.submit}
|
|
338
|
+
>
|
|
339
|
+
{release === undefined || release.draft ? 'Publish release' : 'Update release'}
|
|
340
|
+
<HotkeyHint keys={hotkeys.submit} />
|
|
341
|
+
</SaveButton>
|
|
342
|
+
</div>
|
|
343
|
+
{[saved.error, removed.error].map(
|
|
344
|
+
(error) =>
|
|
345
|
+
error !== null && (
|
|
346
|
+
<Alert key={error.message} variant="destructive">
|
|
347
|
+
<AlertDescription>{error.message}</AlertDescription>
|
|
348
|
+
</Alert>
|
|
349
|
+
),
|
|
350
|
+
)}
|
|
351
|
+
</form>
|
|
352
|
+
);
|
|
353
|
+
}
|