ref0-git 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +122 -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 +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -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 +538 -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 +48 -0
- package/dist/cli/helpers.mjs +51 -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 +79 -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 +75 -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 +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -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 +383 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import type { components, operations } 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 { everyPage, failure } from '../hooks/answers.ts';
|
|
9
|
+
import { type Pictures, picturesOf } from '../hooks/avatars.ts';
|
|
10
|
+
import { nextCursor } from '../hooks/repos.ts';
|
|
11
|
+
import { searchQueryOf, type IssueFilter } from './search.ts';
|
|
12
|
+
|
|
13
|
+
/** An issue, or a pull request's issue view, as GitHub's REST answers it. */
|
|
14
|
+
export type RestIssue = components['schemas']['issue'];
|
|
15
|
+
|
|
16
|
+
type RestComment = components['schemas']['issue-comment'];
|
|
17
|
+
|
|
18
|
+
/** A label, as an issue carries it and the repo lists it. */
|
|
19
|
+
export interface Label {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** Six hex digits, with no `#`. */
|
|
22
|
+
readonly color: string;
|
|
23
|
+
readonly description: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A milestone, by the number the drop-in files it under. */
|
|
27
|
+
export interface Milestone {
|
|
28
|
+
readonly number: number;
|
|
29
|
+
readonly title: string;
|
|
30
|
+
readonly state: 'open' | 'closed';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** An issue in the fields its row and its page read. */
|
|
34
|
+
export interface Issue {
|
|
35
|
+
readonly number: number;
|
|
36
|
+
readonly title: string;
|
|
37
|
+
readonly body: string;
|
|
38
|
+
readonly state: 'open' | 'closed';
|
|
39
|
+
readonly author: string;
|
|
40
|
+
readonly created: string;
|
|
41
|
+
readonly comments: number;
|
|
42
|
+
readonly labels: readonly Label[];
|
|
43
|
+
readonly assignees: readonly string[];
|
|
44
|
+
readonly milestone: Milestone | null;
|
|
45
|
+
/** Its author's and assignees' pictures, as the answer named them. */
|
|
46
|
+
readonly pictures: Pictures;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A comment on an issue. */
|
|
50
|
+
export interface Comment {
|
|
51
|
+
readonly id: number;
|
|
52
|
+
readonly author: string;
|
|
53
|
+
readonly body: string;
|
|
54
|
+
readonly created: string;
|
|
55
|
+
/** Its author's picture, as the answer named it. */
|
|
56
|
+
readonly pictures: Pictures;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const RestLabel = Schema.Struct({
|
|
60
|
+
name: Schema.String,
|
|
61
|
+
color: Schema.String,
|
|
62
|
+
description: Schema.NullOr(Schema.String),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const restLabel = Schema.decodeUnknownOption(RestLabel);
|
|
66
|
+
|
|
67
|
+
const bareName = Schema.decodeUnknownOption(Schema.String);
|
|
68
|
+
|
|
69
|
+
/** A label as the REST answer gives it: GitHub's types allow its name alone, as a string. */
|
|
70
|
+
const labelOf = (label: RestIssue['labels'][number]): Label =>
|
|
71
|
+
Option.getOrElse(restLabel(label), (): Label => ({
|
|
72
|
+
name: Option.getOrElse(bareName(label), () => ''),
|
|
73
|
+
color: 'ededed',
|
|
74
|
+
description: null,
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The fields an issue's view and a pull request's share, which the issue pages read. A search's
|
|
79
|
+
* result may answer its assignees as `null`, which is none.
|
|
80
|
+
*/
|
|
81
|
+
export type IssueFields = Pick<
|
|
82
|
+
RestIssue,
|
|
83
|
+
| 'number'
|
|
84
|
+
| 'title'
|
|
85
|
+
| 'body'
|
|
86
|
+
| 'state'
|
|
87
|
+
| 'user'
|
|
88
|
+
| 'created_at'
|
|
89
|
+
| 'comments'
|
|
90
|
+
| 'labels'
|
|
91
|
+
| 'milestone'
|
|
92
|
+
> & { readonly assignees?: RestIssue['assignees'] | null };
|
|
93
|
+
|
|
94
|
+
export const issueOf = (issue: IssueFields): Issue => ({
|
|
95
|
+
number: issue.number,
|
|
96
|
+
title: issue.title,
|
|
97
|
+
body: issue.body ?? '',
|
|
98
|
+
state: issue.state === 'closed' ? 'closed' : 'open',
|
|
99
|
+
author: issue.user?.login ?? 'ghost',
|
|
100
|
+
created: issue.created_at,
|
|
101
|
+
comments: issue.comments,
|
|
102
|
+
labels: issue.labels.map(labelOf),
|
|
103
|
+
assignees: (issue.assignees ?? []).map((user) => user.login),
|
|
104
|
+
milestone:
|
|
105
|
+
issue.milestone === null
|
|
106
|
+
? null
|
|
107
|
+
: {
|
|
108
|
+
number: issue.milestone.number,
|
|
109
|
+
title: issue.milestone.title,
|
|
110
|
+
state: issue.milestone.state,
|
|
111
|
+
},
|
|
112
|
+
pictures: picturesOf([issue.user, ...(issue.assignees ?? [])]),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const commentOf = (comment: RestComment): Comment => ({
|
|
116
|
+
id: Number(comment.id),
|
|
117
|
+
author: comment.user?.login ?? 'ghost',
|
|
118
|
+
body: comment.body ?? '',
|
|
119
|
+
created: comment.created_at,
|
|
120
|
+
pictures: picturesOf([comment.user]),
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
/** What the repo's issues can be filed under: its labels, milestones, and who they can be assigned to. */
|
|
124
|
+
export interface Vocabulary {
|
|
125
|
+
readonly labels: readonly Label[];
|
|
126
|
+
readonly milestones: readonly Milestone[];
|
|
127
|
+
readonly assignees: readonly string[];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The repo's labels, milestones and assignees. */
|
|
131
|
+
export const vocabularyOf = (place: RepoPlace) =>
|
|
132
|
+
queryOptions({
|
|
133
|
+
queryKey: ['issue-vocabulary', place.owner, place.repo],
|
|
134
|
+
queryFn: async (): Promise<Vocabulary> => {
|
|
135
|
+
const path = { path: place };
|
|
136
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
137
|
+
const paging = (after: string | undefined) => ({ ...{ per_page: 100, after } });
|
|
138
|
+
const [labels, milestones, assignees] = await Promise.all([
|
|
139
|
+
everyPage(async (after) => {
|
|
140
|
+
const answer = await github.GET('/repos/{owner}/{repo}/labels', {
|
|
141
|
+
params: { ...path, query: paging(after) },
|
|
142
|
+
});
|
|
143
|
+
if (answer.data === undefined) throw failure("The labels didn't load", answer);
|
|
144
|
+
|
|
145
|
+
return { rows: answer.data.map(labelOf), link: answer.response.headers.get('link') };
|
|
146
|
+
}),
|
|
147
|
+
everyPage(async (after) => {
|
|
148
|
+
const answer = await github.GET('/repos/{owner}/{repo}/milestones', {
|
|
149
|
+
params: { ...path, query: { ...paging(after), state: 'all' } },
|
|
150
|
+
});
|
|
151
|
+
if (answer.data === undefined) throw failure("The milestones didn't load", answer);
|
|
152
|
+
|
|
153
|
+
const rows = answer.data.map((held) => ({
|
|
154
|
+
number: held.number,
|
|
155
|
+
title: held.title,
|
|
156
|
+
state: held.state,
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
return { rows, link: answer.response.headers.get('link') };
|
|
160
|
+
}),
|
|
161
|
+
everyPage(async (after) => {
|
|
162
|
+
const answer = await github.GET('/repos/{owner}/{repo}/assignees', {
|
|
163
|
+
params: { ...path, query: paging(after) },
|
|
164
|
+
});
|
|
165
|
+
if (answer.data === undefined) throw failure("The assignees didn't load", answer);
|
|
166
|
+
|
|
167
|
+
const rows = answer.data.map((user) => user.login);
|
|
168
|
+
|
|
169
|
+
return { rows, link: answer.response.headers.get('link') };
|
|
170
|
+
}),
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
return { labels: labels.rows, milestones: milestones.rows, assignees: assignees.rows };
|
|
174
|
+
},
|
|
175
|
+
staleTime: 30_000,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/** The issues a list page shows, as GitHub's own pages show them. */
|
|
179
|
+
export const issuesPerPage = 25;
|
|
180
|
+
|
|
181
|
+
/** A page of issues, and the cursor of the one after it. */
|
|
182
|
+
export interface IssuePage {
|
|
183
|
+
readonly issues: readonly Issue[];
|
|
184
|
+
readonly next: string | undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** What GitHub's REST takes to list a repo's issues. */
|
|
188
|
+
export type ListQuery = NonNullable<operations['issues/list-for-repo']['parameters']['query']>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The list's query for `filter`: a milestone by its title, as the box names it, is the number
|
|
192
|
+
* the drop-in filters by. `undefined` when the filter names a milestone the repo hasn't got, which
|
|
193
|
+
* no issue is in.
|
|
194
|
+
*/
|
|
195
|
+
export const listQuery = (filter: IssueFilter, vocabulary: Vocabulary): ListQuery | undefined => {
|
|
196
|
+
const { milestone, assignee } = filter;
|
|
197
|
+
const number =
|
|
198
|
+
milestone?.kind === 'named'
|
|
199
|
+
? vocabulary.milestones.find((held) => held.title === milestone.name)?.number
|
|
200
|
+
: undefined;
|
|
201
|
+
if (milestone?.kind === 'named' && number === undefined) return undefined;
|
|
202
|
+
|
|
203
|
+
const query: ListQuery = {
|
|
204
|
+
state: filter.state,
|
|
205
|
+
direction: filter.order === 'oldest' ? 'asc' : 'desc',
|
|
206
|
+
per_page: issuesPerPage,
|
|
207
|
+
};
|
|
208
|
+
if (filter.labels.length > 0) query.labels = filter.labels.join(',');
|
|
209
|
+
|
|
210
|
+
if (milestone !== undefined) query.milestone = String(number ?? 'none');
|
|
211
|
+
|
|
212
|
+
if (assignee !== undefined) query.assignee = assignee.kind === 'none' ? 'none' : assignee.name;
|
|
213
|
+
|
|
214
|
+
if (filter.author !== undefined) query.creator = filter.author;
|
|
215
|
+
|
|
216
|
+
return query;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* An issue or a pull request as a list reads it: from the repo's issue list, or a search's
|
|
221
|
+
* result, whose item carries the same fields.
|
|
222
|
+
*/
|
|
223
|
+
export type Listed = IssueFields & {
|
|
224
|
+
readonly draft?: boolean;
|
|
225
|
+
readonly pull_request?: { readonly merged_at?: string | null };
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/** A page a list reads, from `after`: what it lists, and where the next page starts. */
|
|
229
|
+
export type Lister = (
|
|
230
|
+
after: string | undefined,
|
|
231
|
+
) => Promise<{ readonly listed: readonly Listed[]; readonly next: string | undefined }>;
|
|
232
|
+
|
|
233
|
+
/** The repo's issue list under `query`, a page from `after`, the drop-in's cursor. */
|
|
234
|
+
export const listedBy =
|
|
235
|
+
(place: RepoPlace, query: ListQuery, what: string): Lister =>
|
|
236
|
+
async (after) => {
|
|
237
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
238
|
+
const paging = { ...query, after };
|
|
239
|
+
const answer = await github.GET('/repos/{owner}/{repo}/issues', {
|
|
240
|
+
params: { path: place, query: { ...paging } },
|
|
241
|
+
});
|
|
242
|
+
if (answer.data === undefined) throw failure(`${what} didn't load`, answer);
|
|
243
|
+
|
|
244
|
+
return { listed: answer.data, next: nextCursor(answer.response.headers.get('link')) };
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* What the drop-in's search finds for `q`, a page from `after`, the page's number, newest created
|
|
249
|
+
* first unless `q` names a `sort:`, as `GET /search/issues` orders them.
|
|
250
|
+
*/
|
|
251
|
+
export const searchedBy =
|
|
252
|
+
(q: string, what: string): Lister =>
|
|
253
|
+
async (after) => {
|
|
254
|
+
const page = after === undefined ? 1 : Number(after);
|
|
255
|
+
const answer = await github.GET('/search/issues', {
|
|
256
|
+
params: { query: { q, per_page: issuesPerPage, page } },
|
|
257
|
+
});
|
|
258
|
+
if (answer.data === undefined) throw failure(`${what} didn't load`, answer);
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
listed: answer.data.items,
|
|
262
|
+
next: nextCursor(answer.response.headers.get('link'), 'page'),
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/** How a list reads on: what it keeps of each page, and up to how many pages. */
|
|
267
|
+
export interface Reading<Row> {
|
|
268
|
+
readonly keep: (listed: readonly Listed[]) => Promise<readonly Row[]>;
|
|
269
|
+
readonly reads: number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The rows `keep` makes of what `lister` lists, after `after`, and the cursor to read on from. A
|
|
274
|
+
* page `keep` makes no rows of reads on to the next, so no page shows nothing while more is
|
|
275
|
+
* left, up to `reads` pages.
|
|
276
|
+
*/
|
|
277
|
+
export const readOn = async <Row>(
|
|
278
|
+
lister: Lister,
|
|
279
|
+
after: string | undefined,
|
|
280
|
+
{ keep, reads }: Reading<Row>,
|
|
281
|
+
): Promise<{ readonly rows: readonly Row[]; readonly next: string | undefined }> => {
|
|
282
|
+
let cursor = after;
|
|
283
|
+
|
|
284
|
+
for (let read = 1; ; read += 1) {
|
|
285
|
+
const { listed, next } = await lister(cursor);
|
|
286
|
+
const rows = await keep(listed);
|
|
287
|
+
cursor = next;
|
|
288
|
+
|
|
289
|
+
if (rows.length > 0 || cursor === undefined || read >= reads) return { rows, next: cursor };
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The page reader for `filter`'s list: the drop-in's search for `query` once the box holds words,
|
|
295
|
+
* which only search matches, else the repo's issue list, filtered as `listQuery` writes it.
|
|
296
|
+
* `undefined` when no issue can match.
|
|
297
|
+
*/
|
|
298
|
+
export const listerOf = (
|
|
299
|
+
place: RepoPlace,
|
|
300
|
+
filter: IssueFilter,
|
|
301
|
+
query: ListQuery | undefined,
|
|
302
|
+
searched: string | undefined,
|
|
303
|
+
what: string,
|
|
304
|
+
): Lister | undefined => {
|
|
305
|
+
if (filter.words.length === 0)
|
|
306
|
+
return query === undefined ? undefined : listedBy(place, query, what);
|
|
307
|
+
|
|
308
|
+
if (searched === undefined) {
|
|
309
|
+
throw new Error(`${what} didn't load: search can't read a name holding a quote`);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return searchedBy(searched, what);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* A page of the repo's issues under `filter`, after `after`. The drop-in lists pull requests
|
|
317
|
+
* among them, as GitHub's REST does, and the page leaves those out, reading on past a page of
|
|
318
|
+
* pull requests alone.
|
|
319
|
+
*/
|
|
320
|
+
export const issuePage = async (
|
|
321
|
+
place: RepoPlace,
|
|
322
|
+
filter: IssueFilter,
|
|
323
|
+
vocabulary: Vocabulary,
|
|
324
|
+
after: string | undefined,
|
|
325
|
+
): Promise<IssuePage> => {
|
|
326
|
+
const what = 'The issues';
|
|
327
|
+
const lister = listerOf(
|
|
328
|
+
place,
|
|
329
|
+
filter,
|
|
330
|
+
listQuery(filter, vocabulary),
|
|
331
|
+
searchQueryOf(place, filter),
|
|
332
|
+
what,
|
|
333
|
+
);
|
|
334
|
+
if (lister === undefined) return { issues: [], next: undefined };
|
|
335
|
+
|
|
336
|
+
const keep = async (listed: readonly Listed[]) =>
|
|
337
|
+
listed.flatMap((issue) => (issue.pull_request === undefined ? [issueOf(issue)] : []));
|
|
338
|
+
const reading = { keep, reads: Number.POSITIVE_INFINITY };
|
|
339
|
+
const { rows, next } = await readOn(lister, after, reading);
|
|
340
|
+
|
|
341
|
+
return { issues: rows, next };
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const firstPage: string | undefined = undefined;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Where the repo's issue lists are read, one under each filter: their pages and nothing else, so a
|
|
348
|
+
* change can write into their rows. The rest of the repo's issue reads, such as the tabs' counts,
|
|
349
|
+
* sit beside it under `['issues', owner, repo]`.
|
|
350
|
+
*/
|
|
351
|
+
export const issueLists = (place: RepoPlace) =>
|
|
352
|
+
['issues', place.owner, place.repo, 'list'] as const;
|
|
353
|
+
|
|
354
|
+
/** The repo's issues under `filter`, a page at a time as the reader asks for more. */
|
|
355
|
+
export const issueList = (place: RepoPlace, filter: IssueFilter, vocabulary: Vocabulary) => ({
|
|
356
|
+
queryKey: [...issueLists(place), filter] as const,
|
|
357
|
+
queryFn: ({ pageParam }: { readonly pageParam: string | undefined }) =>
|
|
358
|
+
issuePage(place, filter, vocabulary, pageParam),
|
|
359
|
+
initialPageParam: firstPage,
|
|
360
|
+
getNextPageParam: (last: IssuePage) => last.next,
|
|
361
|
+
staleTime: 10_000,
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
/** A page of the repo's authors, as its issues read newest first named them, and the next's cursor. */
|
|
365
|
+
export interface AuthorPage {
|
|
366
|
+
readonly logins: readonly string[];
|
|
367
|
+
readonly next: string | undefined;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** The issues and pull requests a page of authors reads them from. */
|
|
371
|
+
const authorsPerPage = 100;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Who opened an issue or a pull request in the repo, a page of 100 of them at a time, newest
|
|
375
|
+
* first. The drop-in lists no repo's authors and searches no people, so the Author menu reads
|
|
376
|
+
* them from the repo's issue list, which holds its pull requests too, as GitHub's does.
|
|
377
|
+
*/
|
|
378
|
+
export const authorsOf = (place: RepoPlace) => ({
|
|
379
|
+
queryKey: ['issue-authors', place.owner, place.repo] as const,
|
|
380
|
+
queryFn: async ({ pageParam }: { readonly pageParam: string | undefined }) => {
|
|
381
|
+
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
382
|
+
const paging = { ...{ per_page: authorsPerPage, after: pageParam } };
|
|
383
|
+
const answer = await github.GET('/repos/{owner}/{repo}/issues', {
|
|
384
|
+
params: { path: place, query: { ...paging, state: 'all' } },
|
|
385
|
+
});
|
|
386
|
+
if (answer.data === undefined) throw failure("The authors didn't load", answer);
|
|
387
|
+
|
|
388
|
+
const logins = answer.data.flatMap((issue) => (issue.user === null ? [] : [issue.user.login]));
|
|
389
|
+
|
|
390
|
+
return { logins, next: nextCursor(answer.response.headers.get('link')) };
|
|
391
|
+
},
|
|
392
|
+
initialPageParam: firstPage,
|
|
393
|
+
getNextPageParam: (last: AuthorPage) => last.next,
|
|
394
|
+
staleTime: 30_000,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* What's at an issue's number: an issue, or a pull request as the issues API answers it, or
|
|
399
|
+
* `null` for nothing the viewer can read.
|
|
400
|
+
*/
|
|
401
|
+
export type Numbered = { readonly kind: 'issue' | 'pull'; readonly issue: Issue } | null;
|
|
402
|
+
|
|
403
|
+
/** The issue `number`, or what else the number is. */
|
|
404
|
+
export const issueAt = (place: RepoPlace, number: number) =>
|
|
405
|
+
queryOptions({
|
|
406
|
+
queryKey: ['issue', place.owner, place.repo, number],
|
|
407
|
+
queryFn: async (): Promise<Numbered> => {
|
|
408
|
+
const answer = await github.GET('/repos/{owner}/{repo}/issues/{issue_number}', {
|
|
409
|
+
params: { path: { ...place, issue_number: number } },
|
|
410
|
+
});
|
|
411
|
+
if (answer.response.status === 404) return null;
|
|
412
|
+
|
|
413
|
+
if (answer.data === undefined) throw failure("The issue didn't load", answer);
|
|
414
|
+
|
|
415
|
+
const kind: 'issue' | 'pull' = answer.data.pull_request === undefined ? 'issue' : 'pull';
|
|
416
|
+
|
|
417
|
+
return { kind, issue: issueOf(answer.data) };
|
|
418
|
+
},
|
|
419
|
+
staleTime: 10_000,
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
/** A page of an issue's comments, oldest first, and the cursor of the one after it. */
|
|
423
|
+
export interface CommentPage {
|
|
424
|
+
readonly comments: readonly Comment[];
|
|
425
|
+
readonly next: string | undefined;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** An issue's comments, oldest first, 100 a page as the reader asks for more. */
|
|
429
|
+
export const commentsOf = (place: RepoPlace, number: number) => ({
|
|
430
|
+
queryKey: ['issue-comments', place.owner, place.repo, number] as const,
|
|
431
|
+
queryFn: async ({ pageParam }: { readonly pageParam: string | undefined }) => {
|
|
432
|
+
const paging = { per_page: 100, after: pageParam };
|
|
433
|
+
const answer = await github.GET('/repos/{owner}/{repo}/issues/{issue_number}/comments', {
|
|
434
|
+
params: { path: { ...place, issue_number: number }, query: { ...paging } },
|
|
435
|
+
});
|
|
436
|
+
if (answer.data === undefined) throw failure("The comments didn't load", answer);
|
|
437
|
+
|
|
438
|
+
const page: CommentPage = {
|
|
439
|
+
comments: answer.data.map(commentOf),
|
|
440
|
+
next: nextCursor(answer.response.headers.get('link')),
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
return page;
|
|
444
|
+
},
|
|
445
|
+
initialPageParam: firstPage,
|
|
446
|
+
getNextPageParam: (last: CommentPage) => last.next,
|
|
447
|
+
staleTime: 10_000,
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
/** A new issue's title and text. */
|
|
451
|
+
export interface Written {
|
|
452
|
+
readonly title: string;
|
|
453
|
+
readonly body: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** Files a new issue, and answers its number. */
|
|
457
|
+
export const createIssue = async (place: RepoPlace, written: Written) => {
|
|
458
|
+
const answer = await github.POST('/repos/{owner}/{repo}/issues', {
|
|
459
|
+
params: { path: place },
|
|
460
|
+
body: written,
|
|
461
|
+
});
|
|
462
|
+
if (answer.data === undefined) throw failure("The issue wasn't created", answer);
|
|
463
|
+
|
|
464
|
+
return answer.data.number;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/** What a change to an issue sets: any of its fields, and labels and assignees by name. */
|
|
468
|
+
export interface IssueChange {
|
|
469
|
+
readonly title?: string;
|
|
470
|
+
readonly body?: string;
|
|
471
|
+
readonly state?: 'open' | 'closed';
|
|
472
|
+
readonly labels?: readonly string[];
|
|
473
|
+
readonly assignees?: readonly string[];
|
|
474
|
+
/** The milestone's number, or `null` for none. */
|
|
475
|
+
readonly milestone?: number | null;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** What GitHub's REST takes to change an issue. */
|
|
479
|
+
type IssueBody = NonNullable<
|
|
480
|
+
operations['issues/update']['requestBody']
|
|
481
|
+
>['content']['application/json'];
|
|
482
|
+
|
|
483
|
+
/** Changes the issue `number`, and answers it as it is after. */
|
|
484
|
+
export const changeIssue = async (place: RepoPlace, number: number, change: IssueChange) => {
|
|
485
|
+
const { labels, assignees, ...fields } = change;
|
|
486
|
+
const body: IssueBody = { ...fields };
|
|
487
|
+
if (labels !== undefined) body.labels = [...labels];
|
|
488
|
+
|
|
489
|
+
if (assignees !== undefined) body.assignees = [...assignees];
|
|
490
|
+
|
|
491
|
+
const answer = await github.PATCH('/repos/{owner}/{repo}/issues/{issue_number}', {
|
|
492
|
+
params: { path: { ...place, issue_number: number } },
|
|
493
|
+
body,
|
|
494
|
+
});
|
|
495
|
+
if (answer.data === undefined) throw failure("The issue didn't change", answer);
|
|
496
|
+
|
|
497
|
+
return issueOf(answer.data);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
/** Comments on the issue `number`. */
|
|
501
|
+
export const addComment = async (place: RepoPlace, number: number, body: string) => {
|
|
502
|
+
const answer = await github.POST('/repos/{owner}/{repo}/issues/{issue_number}/comments', {
|
|
503
|
+
params: { path: { ...place, issue_number: number } },
|
|
504
|
+
body: { body },
|
|
505
|
+
});
|
|
506
|
+
if (answer.data === undefined) throw failure("The comment wasn't added", answer);
|
|
507
|
+
|
|
508
|
+
return commentOf(answer.data);
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
/** Rewrites the comment `id`. */
|
|
512
|
+
export const editComment = async (place: RepoPlace, id: number, body: string) => {
|
|
513
|
+
const answer = await github.PATCH('/repos/{owner}/{repo}/issues/comments/{comment_id}', {
|
|
514
|
+
params: { path: { ...place, comment_id: id } },
|
|
515
|
+
body: { body },
|
|
516
|
+
});
|
|
517
|
+
if (answer.data === undefined) throw failure("The comment didn't change", answer);
|
|
518
|
+
|
|
519
|
+
return commentOf(answer.data);
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/** A label's fields as a write sends them: no description is an empty one. */
|
|
523
|
+
const labelBody = (label: Label) => ({
|
|
524
|
+
name: label.name,
|
|
525
|
+
color: label.color,
|
|
526
|
+
description: label.description ?? '',
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
/** Makes a label in the repo, so an issue can carry it. */
|
|
530
|
+
export const createLabel = async (place: RepoPlace, label: Label) => {
|
|
531
|
+
const answer = await github.POST('/repos/{owner}/{repo}/labels', {
|
|
532
|
+
params: { path: place },
|
|
533
|
+
body: labelBody(label),
|
|
534
|
+
});
|
|
535
|
+
if (answer.data === undefined) throw failure("The label wasn't created", answer);
|
|
536
|
+
|
|
537
|
+
return labelOf(answer.data);
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
/** Changes the label named `name` to `label`, which may rename it. */
|
|
541
|
+
export const editLabel = async (place: RepoPlace, name: string, label: Label) => {
|
|
542
|
+
const answer = await github.PATCH('/repos/{owner}/{repo}/labels/{name}', {
|
|
543
|
+
params: { path: { ...place, name } },
|
|
544
|
+
body: { new_name: label.name, color: label.color, description: label.description ?? '' },
|
|
545
|
+
});
|
|
546
|
+
if (answer.data === undefined) throw failure("The label didn't change", answer);
|
|
547
|
+
|
|
548
|
+
return labelOf(answer.data);
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
/** Makes a milestone in the repo, so an issue can be in it. */
|
|
552
|
+
export const createMilestone = async (place: RepoPlace, title: string) => {
|
|
553
|
+
const answer = await github.POST('/repos/{owner}/{repo}/milestones', {
|
|
554
|
+
params: { path: place },
|
|
555
|
+
body: { title },
|
|
556
|
+
});
|
|
557
|
+
if (answer.data === undefined) throw failure("The milestone wasn't created", answer);
|
|
558
|
+
|
|
559
|
+
const made: Milestone = {
|
|
560
|
+
number: answer.data.number,
|
|
561
|
+
title: answer.data.title,
|
|
562
|
+
state: answer.data.state,
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
return made;
|
|
566
|
+
};
|