ref0-git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { HostInput } from "./documents.mjs";
|
|
2
|
+
import { fillCredential } from "./credentials.mjs";
|
|
3
|
+
import { failure, unsafeCredential, usageFailure } from "./failure.mjs";
|
|
4
|
+
import { gitRun } from "./git.mjs";
|
|
5
|
+
import { node } from "./node.mjs";
|
|
6
|
+
import { CliModes, printable, say, secrets } from "./output.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Redacted from "effect/Redacted";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import * as Flag from "effect/cli/Flag";
|
|
12
|
+
import { createRestClient } from "@ref0/git/rest";
|
|
13
|
+
// src/cli/hosts.ts
|
|
14
|
+
/**
|
|
15
|
+
* The hosts `ref0-git` is signed in to, and the one a command talks to. Git's helpers can't list
|
|
16
|
+
* what they keep, so `login` records each host's endpoint, and no secret, in Git's global config as
|
|
17
|
+
* `ref0-git.host`, and `logout` removes it.
|
|
18
|
+
*/
|
|
19
|
+
const hostKey = "ref0-git.host";
|
|
20
|
+
const decodeHost = Schema.decodeUnknownOption(HostInput);
|
|
21
|
+
/** `host` as a `Host`, as `HostInput` reads it, or `undefined`. */
|
|
22
|
+
const parsedHost = (host) => Option.getOrUndefined(decodeHost(host));
|
|
23
|
+
/**
|
|
24
|
+
* `host` as a person wrote it, with all before its last `@` and after its scheme as `***`: it may
|
|
25
|
+
* hold a password, even one the parser can't read.
|
|
26
|
+
*/
|
|
27
|
+
const shownHost = (host) => host.replace(/^([a-z][a-z0-9+.-]*:\/\/)?.*@/is, "$1***@");
|
|
28
|
+
/** `host` as a `Host`, or a usage failure saying how one is named. */
|
|
29
|
+
const hostOf = (host) => {
|
|
30
|
+
const parsed = parsedHost(host);
|
|
31
|
+
return parsed === void 0 ? usageFailure("invalid_host", `${printable(shownHost(host))} isn't a host`, "Name it as git.acme.dev, as git.acme.dev/git where Git is under a path, or as http://localhost:5173/git for a local one") : Effect.succeed(parsed);
|
|
32
|
+
};
|
|
33
|
+
/** How a host is written for a person: its endpoint, without `https://`. */
|
|
34
|
+
const hostName = (host) => host.endpoint.startsWith("https://") ? host.endpoint.slice(8) : host.endpoint;
|
|
35
|
+
/**
|
|
36
|
+
* Each host signed in to, as `login` recorded its endpoint, and a bare origin as one at the root.
|
|
37
|
+
* A record that isn't a host is left out.
|
|
38
|
+
*/
|
|
39
|
+
const signedInHosts = gitRun([
|
|
40
|
+
"config",
|
|
41
|
+
"--global",
|
|
42
|
+
"--get-all",
|
|
43
|
+
hostKey
|
|
44
|
+
]).pipe(Effect.map((ran) => (ran.status === 0 ? ran.stdout.split("\n").filter(Boolean) : []).flatMap((record) => {
|
|
45
|
+
const host = parsedHost(record);
|
|
46
|
+
return host === void 0 ? [] : [{
|
|
47
|
+
...host,
|
|
48
|
+
record
|
|
49
|
+
}];
|
|
50
|
+
})));
|
|
51
|
+
/**
|
|
52
|
+
* Sets, or with `unset` removes, a key of Git's global config, failing when Git couldn't, as when
|
|
53
|
+
* another `git` holds the file's lock. Removing a key that isn't there is done.
|
|
54
|
+
*/
|
|
55
|
+
const globalConfig = (args, options = {}) => Effect.flatMap(gitRun([
|
|
56
|
+
"config",
|
|
57
|
+
"--global",
|
|
58
|
+
...options.unset === true ? ["--unset-all"] : [],
|
|
59
|
+
...args
|
|
60
|
+
]), (ran) => ran.status === 0 || options.unset === true && ran.status === 5 ? Effect.void : Effect.fail(failure("config_not_written", "Git couldn't write its global config", "Check no other git holds its lock and the file is writable, then run it again")));
|
|
61
|
+
const recordHost = (host) => globalConfig([
|
|
62
|
+
"--add",
|
|
63
|
+
hostKey,
|
|
64
|
+
host.endpoint
|
|
65
|
+
]);
|
|
66
|
+
/** Removes each `ref0-git.host` record written exactly as `record`. */
|
|
67
|
+
const forgetHost = (record) => globalConfig([
|
|
68
|
+
"--fixed-value",
|
|
69
|
+
hostKey,
|
|
70
|
+
record
|
|
71
|
+
], { unset: true });
|
|
72
|
+
/**
|
|
73
|
+
* The host the checkout's `origin` remote is under, when it's signed in to: the one with the
|
|
74
|
+
* longest endpoint, so a host under `/git` wins over the same origin's root.
|
|
75
|
+
*/
|
|
76
|
+
const checkoutHost = (hosts) => gitRun([
|
|
77
|
+
"remote",
|
|
78
|
+
"get-url",
|
|
79
|
+
"origin"
|
|
80
|
+
], { cwd: node.process.cwd() }).pipe(Effect.map((ran) => {
|
|
81
|
+
const url = ran.status === 0 ? URL.parse(ran.stdout.trim()) : null;
|
|
82
|
+
if (url === null) return void 0;
|
|
83
|
+
const remote = `${url.origin}${url.pathname}`;
|
|
84
|
+
return hosts.filter((host) => remote.startsWith(`${host.endpoint}/`)).toSorted((a, b) => b.endpoint.length - a.endpoint.length)[0];
|
|
85
|
+
}));
|
|
86
|
+
const hostFlag = Flag.String("host").pipe(Flag.withDescription("The host to use, when the checkout or your one sign-in does not say"), Flag.withMetavar("HOST"), Flag.optional);
|
|
87
|
+
/**
|
|
88
|
+
* The host a command talks to: `--host`, else the checkout's `origin` when signed in there, named on
|
|
89
|
+
* stderr, else the one signed in to. Otherwise a usage failure, whose next step is `naming`.
|
|
90
|
+
*/
|
|
91
|
+
const chosenHost = Effect.fnUntraced(function* (flag, naming = "Name one with --host") {
|
|
92
|
+
if (Option.isSome(flag)) return yield* hostOf(flag.value);
|
|
93
|
+
const hosts = yield* signedInHosts;
|
|
94
|
+
const fromCheckout = yield* checkoutHost(hosts);
|
|
95
|
+
if (fromCheckout !== void 0) {
|
|
96
|
+
if (!(yield* CliModes).json) yield* say(`Using ${hostName(fromCheckout)}, this checkout's origin`);
|
|
97
|
+
return fromCheckout;
|
|
98
|
+
}
|
|
99
|
+
const [only, ...others] = hosts;
|
|
100
|
+
if (only !== void 0 && others.length === 0) return only;
|
|
101
|
+
return yield* only === void 0 ? usageFailure("no_host", "You're not signed in to a host", "Sign in, naming the host, with login") : usageFailure("host_ambiguous", `You're signed in to ${hosts.length} hosts: ${hosts.map(hostName).join(", ")}`, naming);
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* A host's REST client, at its endpoint, with the token Git's helpers keep for its origin, or a
|
|
105
|
+
* failure saying to sign in.
|
|
106
|
+
*/
|
|
107
|
+
const remoteOf = Effect.fnUntraced(function* (chosen) {
|
|
108
|
+
const { endpoint, origin } = chosen;
|
|
109
|
+
const host = hostName(chosen);
|
|
110
|
+
const credential = yield* fillCredential(new URL(`${origin}/`)).pipe(Effect.mapError(() => unsafeCredential(host)));
|
|
111
|
+
if (credential === void 0) return yield* failure("not_signed_in", `You're not signed in to ${host}`, {
|
|
112
|
+
says: "Sign in",
|
|
113
|
+
run: [["login", host]]
|
|
114
|
+
});
|
|
115
|
+
const token = Redacted.value(credential.password);
|
|
116
|
+
secrets.hide(token);
|
|
117
|
+
return {
|
|
118
|
+
endpoint,
|
|
119
|
+
origin,
|
|
120
|
+
host,
|
|
121
|
+
client: createRestClient({
|
|
122
|
+
url: endpoint,
|
|
123
|
+
credentials: { token }
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
export { chosenHost, forgetHost, globalConfig, hostFlag, hostName, hostOf, parsedHost, recordHost, remoteOf, signedInHosts };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/cli/node.ts
|
|
2
|
+
function missingNode() {
|
|
3
|
+
throw new Error("git-remote-ref0 runs in Node");
|
|
4
|
+
}
|
|
5
|
+
const process = globalThis.process ?? missingNode();
|
|
6
|
+
const node = {
|
|
7
|
+
process,
|
|
8
|
+
fs: process.getBuiltinModule("node:fs"),
|
|
9
|
+
sqlite: () => process.getBuiltinModule("node:sqlite")
|
|
10
|
+
};
|
|
11
|
+
/** `chunk` written to `stream`, once it's taken. */
|
|
12
|
+
const written = (stream, chunk) => new Promise((done, failed) => {
|
|
13
|
+
stream.write(chunk, (error) => error === void 0 || error === null ? done() : failed(error));
|
|
14
|
+
});
|
|
15
|
+
export { node, written };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { shellWord } from "../init/shell.mjs";
|
|
2
|
+
import { node, written } from "./node.mjs";
|
|
3
|
+
import { secretScrubber } from "@ref0/git/remote-helper";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Redacted from "effect/Redacted";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as GlobalFlag from "effect/cli/GlobalFlag";
|
|
8
|
+
import * as DateTime from "effect/DateTime";
|
|
9
|
+
import * as Flag from "effect/cli/Flag";
|
|
10
|
+
// src/cli/output.ts
|
|
11
|
+
/**
|
|
12
|
+
* What `ref0-git` prints, and where: the answer alone on stdout, everything else on stderr. The
|
|
13
|
+
* modes are read once, here, from the global flags, the environment and the terminals; no command
|
|
14
|
+
* reads `isTTY` or `CI` itself.
|
|
15
|
+
*/
|
|
16
|
+
const { process } = node;
|
|
17
|
+
const JsonFlag = GlobalFlag.Setting("json")({ flag: Flag.Boolean("json").pipe(Flag.withDescription("Print the host's answer as one JSON document"), Flag.withDefault(false)) });
|
|
18
|
+
const NonInteractiveFlag = GlobalFlag.Setting("non-interactive")({ flag: Flag.Boolean("non-interactive").pipe(Flag.withDescription("Never prompt, and print bare IDs"), Flag.withDefault(false)) });
|
|
19
|
+
var CliModes = class extends Context.Service()("ref0-git/CliModes") {};
|
|
20
|
+
/** The modes, from the flags given and the process. */
|
|
21
|
+
const modesOf = (flags) => {
|
|
22
|
+
const ci = (process.env["CI"] ?? "") !== "" && process.env["CI"] !== "false";
|
|
23
|
+
const terminals = process.stdin.isTTY === true && process.stderr.isTTY === true;
|
|
24
|
+
return {
|
|
25
|
+
json: flags.json,
|
|
26
|
+
interactive: !flags.json && !flags.nonInteractive && !ci && terminals,
|
|
27
|
+
stdoutTerminal: process.stdout.isTTY === true,
|
|
28
|
+
stdinTerminal: process.stdin.isTTY === true
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Whether boolean flag `--name` is on in `args`, as the parser reads it: its last `--name`,
|
|
33
|
+
* `--name=true`, `--name=false` or `--no-name` before a `--`.
|
|
34
|
+
*/
|
|
35
|
+
const flagOn = (args, name) => {
|
|
36
|
+
const end = args.indexOf("--");
|
|
37
|
+
let on = false;
|
|
38
|
+
for (const arg of end === -1 ? args : args.slice(0, end)) {
|
|
39
|
+
if (arg === `--${name}` || arg === `--${name}=true`) on = true;
|
|
40
|
+
if (arg === `--no-${name}` || arg === `--${name}=false`) on = false;
|
|
41
|
+
}
|
|
42
|
+
return on;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Every secret this run has read, minted or been given, which nothing it prints may hold: a
|
|
46
|
+
* hostile host's refusal could echo the token it was sent.
|
|
47
|
+
*/
|
|
48
|
+
const secrets = secretScrubber({ links: false });
|
|
49
|
+
/** Control and format characters, bidirectional and zero-width ones among them, and line breaks. */
|
|
50
|
+
const unprintable = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu;
|
|
51
|
+
/** Text the CLI didn't write, such as a repo's name, made safe to print on one line. */
|
|
52
|
+
const printable = (text) => secrets.scrub(text.replaceAll("\n", " ").replace(unprintable, ""));
|
|
53
|
+
const write = (stream, text) => Effect.promise(() => written(stream, text).catch(() => void 0));
|
|
54
|
+
/** Text on stderr as it is: a prompt's drawing, or a failed child's output. */
|
|
55
|
+
const stderrText = (text) => write(process.stderr, text);
|
|
56
|
+
/**
|
|
57
|
+
* The lines the run's end prints on stderr for what it left, one a leftover, each with the
|
|
58
|
+
* system's words, so the person can remove it. Internal: exported for `commands.test.ts` alone,
|
|
59
|
+
* since `ref0-git.ts`, which prints them, runs when it's imported.
|
|
60
|
+
*/
|
|
61
|
+
const leftoverLines = (left) => left.map(({ path, says }) => `ref0-git: left ${printable(path)}, ${printable(says)}\n`).join("");
|
|
62
|
+
/** Lines on stderr. */
|
|
63
|
+
const say = (...lines) => write(process.stderr, lines.map((line) => `${line}\n`).join(""));
|
|
64
|
+
/** The answer on stdout, a line. */
|
|
65
|
+
const answer = (text) => write(process.stdout, `${text}\n`);
|
|
66
|
+
/**
|
|
67
|
+
* A REST answer as the one document `--json` prints, on stdout, with no secret in it: a host's
|
|
68
|
+
* answer could echo one. It keeps REST's shape, which the REST client's decode is the contract of.
|
|
69
|
+
*/
|
|
70
|
+
const document = (value) => write(process.stdout, `${secrets.scrub(JSON.stringify(value))}\n`);
|
|
71
|
+
/**
|
|
72
|
+
* One of the CLI's own documents, by its Schema's encoder from `documents.ts`, as `document` writes
|
|
73
|
+
* a REST answer.
|
|
74
|
+
*/
|
|
75
|
+
const cliDocument = (json, value) => write(process.stdout, `${secrets.scrub(json(value))}\n`);
|
|
76
|
+
/** How a person runs `ref0-git`: `npx` takes it from its own package, `ref0-git` (Q641). */
|
|
77
|
+
const runAs = ["npx", "ref0-git"];
|
|
78
|
+
/**
|
|
79
|
+
* One line of a stream on stdout, as `document` writes it: `false` once stdout has closed, as
|
|
80
|
+
* `| head` closes it, so a read ends there.
|
|
81
|
+
*/
|
|
82
|
+
const streamed = (value) => {
|
|
83
|
+
const line = `${secrets.scrub(JSON.stringify(value))}\n`;
|
|
84
|
+
return Effect.promise(() => written(process.stdout, line).then(() => true, () => false));
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* `--show-token --json`'s document: `token`, the secret it delivers as it is, then `record`
|
|
88
|
+
* scrubbed, as every other document is, since a hostile host could echo a secret in it.
|
|
89
|
+
*/
|
|
90
|
+
const shown = (token, record) => write(process.stdout, `${JSON.stringify({ token: Redacted.value(token) }).slice(0, -1)},${secrets.scrub(JSON.stringify(record)).slice(1)}\n`);
|
|
91
|
+
/**
|
|
92
|
+
* A next step's command, as its argv and as a person pastes it. Each word goes through
|
|
93
|
+
* `printable`, since one can be the host's, as a list's cursor is.
|
|
94
|
+
*/
|
|
95
|
+
const commandOf = (argv) => {
|
|
96
|
+
const full = [...runAs, ...argv.map(printable)];
|
|
97
|
+
return {
|
|
98
|
+
line: full.map(shellWord).join(" "),
|
|
99
|
+
argv: full
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/** A command of `ref0-git`'s as a person pastes it. */
|
|
103
|
+
const commandLine = (argv) => commandOf(argv).line;
|
|
104
|
+
/** A next step's commands, the first with `stdinFrom` piped into it, its name in `stdin`. */
|
|
105
|
+
const stepCommands = (next) => next.run.map((argv, at) => {
|
|
106
|
+
const command = commandOf(argv);
|
|
107
|
+
const from = at === 0 ? next.stdinFrom : void 0;
|
|
108
|
+
if (from === void 0) return command;
|
|
109
|
+
return {
|
|
110
|
+
...command,
|
|
111
|
+
line: `printf '%s' "$${from}" | ${command.line}`,
|
|
112
|
+
stdin: { env: from }
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
/** A next step's lines, after a blank one: its words, then each command indented 4 spaces. */
|
|
116
|
+
const nextLines = (next) => [
|
|
117
|
+
"",
|
|
118
|
+
` ${next.says}:`,
|
|
119
|
+
...stepCommands(next).map((command) => ` ${command.line}`)
|
|
120
|
+
];
|
|
121
|
+
/** A next step as `--json`'s documents carry it. */
|
|
122
|
+
const nextDocument = (next) => ({
|
|
123
|
+
says: `${next.says}:`,
|
|
124
|
+
run: stepCommands(next)
|
|
125
|
+
});
|
|
126
|
+
/** `YYYY-MM-DD`, a token's expiry. */
|
|
127
|
+
const utcDay = (at) => DateTime.formatIso(DateTime.makeUnsafe(at)).slice(0, 10);
|
|
128
|
+
/** A label and its value, aligned as a receipt's fields are. */
|
|
129
|
+
const field = ([label, value]) => ` ${label.padEnd(16)}${value}`;
|
|
130
|
+
/** A receipt on stderr: what happened, its fields, then the next step, if any. */
|
|
131
|
+
const receipt = (options) => {
|
|
132
|
+
const lines = [`✓ ${options.done}`, ...(options.fields ?? []).map(field)];
|
|
133
|
+
return say(...lines, ...options.next === void 0 ? [] : nextLines(options.next));
|
|
134
|
+
};
|
|
135
|
+
export { CliModes, JsonFlag, NonInteractiveFlag, answer, cliDocument, commandLine, document, field, flagOn, leftoverLines, modesOf, nextDocument, nextLines, printable, receipt, runAs, say, secrets, shown, stderrText, streamed, utcDay };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { field, stderrText } from "./output.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Terminal from "effect/Terminal";
|
|
4
|
+
import * as Queue from "effect/Queue";
|
|
5
|
+
// src/cli/prompt.ts
|
|
6
|
+
/** The question and its options, `at` selected. */
|
|
7
|
+
const shown = (question, options, at) => [`? ${question}`, ...options.map((option, index) => `${index === at ? ">" : " "} ${option.label}`)].map((line) => `${line}\n`).join("");
|
|
8
|
+
/** The selection after `input`, or `'take'` or `'cancel'`. */
|
|
9
|
+
const keyed = (input, at, count) => {
|
|
10
|
+
const { name, ctrl } = input.key;
|
|
11
|
+
return ctrl && name === "c" ? "cancel" : name === "return" || name === "enter" ? "take" : name === "up" || name === "k" ? (at + count - 1) % count : name === "down" || name === "j" ? (at + 1) % count : at;
|
|
12
|
+
};
|
|
13
|
+
/** `row`'s answer, once a person takes one of `options`, which then reads as a receipt's field. */
|
|
14
|
+
const select = Effect.fnUntraced(function* (row, question, options) {
|
|
15
|
+
const terminal = yield* Terminal.Terminal;
|
|
16
|
+
const erased = `\u001b[${options.length + 1}A\u001b[J`;
|
|
17
|
+
yield* stderrText(shown(question, options, 0));
|
|
18
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
19
|
+
const keys = yield* terminal.readInput;
|
|
20
|
+
let at = 0;
|
|
21
|
+
for (;;) {
|
|
22
|
+
const next = yield* Queue.take(keys).pipe(Effect.map((input) => keyed(input, at, options.length)), Effect.orElseSucceed(() => "cancel"));
|
|
23
|
+
if (next === "cancel") return yield* Effect.interrupt;
|
|
24
|
+
if (next === "take") {
|
|
25
|
+
const taken = options[at] ?? options[0];
|
|
26
|
+
yield* stderrText(`${erased}${field([row, taken?.label ?? ""])}\n`);
|
|
27
|
+
if (taken !== void 0) return taken.value;
|
|
28
|
+
} else {
|
|
29
|
+
at = next;
|
|
30
|
+
yield* stderrText(`${erased}${shown(question, options, at)}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
export { keyed, select };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { answered, usageFailure } from "./failure.mjs";
|
|
2
|
+
import { hostFlag } from "./hosts.mjs";
|
|
3
|
+
import { CliModes, answer, document, field, printable } from "./output.mjs";
|
|
4
|
+
import { called, changed, listed, pageFlags, pagesOf, remoteFor, repoArgument } from "./resources.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Command from "effect/cli/Command";
|
|
8
|
+
import * as Flag from "effect/cli/Flag";
|
|
9
|
+
import * as Argument from "effect/cli/Argument";
|
|
10
|
+
import { branchRef, shortTarget } from "@ref0/git";
|
|
11
|
+
// src/cli/queue.ts
|
|
12
|
+
/**
|
|
13
|
+
* `queue`: a repo's merge queue. An entry's, a hold's and a candidate's ID names its repo, so the
|
|
14
|
+
* commands on one take the ID alone. A hold on an entry takes it as `--entry`, since a repo can be
|
|
15
|
+
* named like one.
|
|
16
|
+
*/
|
|
17
|
+
const idArgument = (name, what) => Argument.String(name).pipe(Argument.withDescription(`The ${what}'s ID, as the queue printed it`));
|
|
18
|
+
const targetFlag = Flag.String("target").pipe(Flag.withDescription("The branch it merges into: the repo's default branch when it's left out"), Flag.withMetavar("BRANCH"), Flag.optional);
|
|
19
|
+
/** The branch `--target` names, else the repo's default branch, as the host says it. */
|
|
20
|
+
const targetOf = (remote, repo, target) => Option.isSome(target) ? Effect.succeed(branchRef(target.value)) : Effect.flatMap(answered(remote.host, (signal) => remote.client.repos.get(repo, { signal })), (info) => info.defaultBranch === void 0 ? Effect.fail(usageFailure("no_default_branch", `${printable(repo)} shows you no default branch`, "Name the branch with --target")) : Effect.succeed(info.defaultBranch));
|
|
21
|
+
const add = Command.make("add", {
|
|
22
|
+
repo: repoArgument,
|
|
23
|
+
host: hostFlag,
|
|
24
|
+
source: Flag.String("source").pipe(Flag.withDescription("The branch to merge, at its tip on the host"), Flag.withMetavar("BRANCH")),
|
|
25
|
+
target: targetFlag,
|
|
26
|
+
key: Flag.String("key").pipe(Flag.withDescription("The entry's key, so an add sent again joins it: the source's name when it's left out"), Flag.withMetavar("KEY"), Flag.optional),
|
|
27
|
+
priority: Flag.Int("priority").pipe(Flag.withDescription("Higher goes first"), Flag.withMetavar("NUMBER"), Flag.optional),
|
|
28
|
+
jump: Flag.Boolean("jump").pipe(Flag.withDescription("Put it first, rebuilding the candidates behind it"), Flag.withDefault(false))
|
|
29
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
30
|
+
const remote = yield* remoteFor(flags.host);
|
|
31
|
+
const ask = (call) => answered(remote.host, call);
|
|
32
|
+
const source = branchRef(flags.source);
|
|
33
|
+
const target = yield* targetOf(remote, flags.repo, flags.target);
|
|
34
|
+
const tip = yield* ask((signal) => remote.client.refs.get(flags.repo, {
|
|
35
|
+
ref: source,
|
|
36
|
+
signal
|
|
37
|
+
}));
|
|
38
|
+
const added = yield* ask((signal) => {
|
|
39
|
+
const input = {
|
|
40
|
+
target,
|
|
41
|
+
source,
|
|
42
|
+
head: tip.oid,
|
|
43
|
+
key: Option.getOrElse(flags.key, () => shortTarget(source)),
|
|
44
|
+
signal
|
|
45
|
+
};
|
|
46
|
+
if (Option.isSome(flags.priority)) input.priority = flags.priority.value;
|
|
47
|
+
if (flags.jump) input.jump = true;
|
|
48
|
+
return remote.client.queue.add(flags.repo, input);
|
|
49
|
+
});
|
|
50
|
+
const entry = added.entry.id;
|
|
51
|
+
yield* changed(added, entry, {
|
|
52
|
+
done: `${added.repeat ? "Already added" : "Added"} ${printable(shortTarget(source))} to the queue for ${printable(shortTarget(target))} in ${printable(flags.repo)}`,
|
|
53
|
+
fields: [
|
|
54
|
+
["Entry", printable(entry)],
|
|
55
|
+
["Head", printable(tip.oid)],
|
|
56
|
+
["Ahead", String(added.ahead)],
|
|
57
|
+
...added.replaced === void 0 ? [] : [["Replaced", printable(added.replaced)]]
|
|
58
|
+
],
|
|
59
|
+
next: {
|
|
60
|
+
says: "Wait for it to land",
|
|
61
|
+
run: [[
|
|
62
|
+
"events",
|
|
63
|
+
"listen",
|
|
64
|
+
flags.repo,
|
|
65
|
+
"--host",
|
|
66
|
+
remote.host,
|
|
67
|
+
"--entry",
|
|
68
|
+
entry,
|
|
69
|
+
"--event",
|
|
70
|
+
"queue.entry.merged,queue.entry.failed"
|
|
71
|
+
]]
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
})).pipe(Command.withDescription("Add a branch to a target's queue"));
|
|
75
|
+
const remove = Command.make("remove", {
|
|
76
|
+
entry: idArgument("ENTRY", "entry"),
|
|
77
|
+
host: hostFlag
|
|
78
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
79
|
+
const done = yield* called(flags.host, (client, signal) => client.queue.remove(flags.entry, { signal }));
|
|
80
|
+
yield* changed(done.value, flags.entry, { done: `Removed ${printable(flags.entry)} from the queue on ${done.host}` });
|
|
81
|
+
})).pipe(Command.withDescription("Take an entry out of the queue"));
|
|
82
|
+
/** An entry's row, as `queue list` prints it. */
|
|
83
|
+
const entryLine = (entry) => [
|
|
84
|
+
entry.id,
|
|
85
|
+
entry.state + (entry.pinned === true ? " pinned" : ""),
|
|
86
|
+
shortTarget(entry.source),
|
|
87
|
+
entry.head.slice(0, 12),
|
|
88
|
+
entry.lanes.join(",")
|
|
89
|
+
].map(printable).join(" ").trimEnd();
|
|
90
|
+
const list = Command.make("list", {
|
|
91
|
+
repo: repoArgument,
|
|
92
|
+
host: hostFlag,
|
|
93
|
+
target: targetFlag,
|
|
94
|
+
...pageFlags
|
|
95
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
96
|
+
const remote = yield* remoteFor(flags.host);
|
|
97
|
+
const target = yield* targetOf(remote, flags.repo, flags.target);
|
|
98
|
+
const command = (host) => [...[
|
|
99
|
+
"queue",
|
|
100
|
+
"list",
|
|
101
|
+
flags.repo,
|
|
102
|
+
"--host",
|
|
103
|
+
host,
|
|
104
|
+
"--target",
|
|
105
|
+
shortTarget(target)
|
|
106
|
+
]];
|
|
107
|
+
const read = yield* pagesOf(remote, flags, command, entryLine, (client, page, signal) => client.queue.list(flags.repo, {
|
|
108
|
+
target,
|
|
109
|
+
page,
|
|
110
|
+
signal
|
|
111
|
+
}));
|
|
112
|
+
yield* listed(read, {
|
|
113
|
+
line: entryLine,
|
|
114
|
+
none: `Nothing in the queue of ${printable(flags.repo)}`,
|
|
115
|
+
command,
|
|
116
|
+
choice: flags
|
|
117
|
+
});
|
|
118
|
+
})).pipe(Command.withDescription("List a target's entries, in the order they're tried in"));
|
|
119
|
+
const show = Command.make("show", {
|
|
120
|
+
entry: idArgument("ENTRY", "entry"),
|
|
121
|
+
host: hostFlag
|
|
122
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
123
|
+
const entry = (yield* called(flags.host, (client, signal) => client.queue.get(flags.entry, { signal }))).value;
|
|
124
|
+
if ((yield* CliModes).json) return yield* document(entry);
|
|
125
|
+
const rows = [
|
|
126
|
+
["Entry", printable(entry.id)],
|
|
127
|
+
["Repo", printable(entry.repo)],
|
|
128
|
+
["State", entry.state + (entry.pinned === true ? ", pinned" : "")],
|
|
129
|
+
["Source", printable(shortTarget(entry.source))],
|
|
130
|
+
["Target", printable(shortTarget(entry.target))],
|
|
131
|
+
["Head", printable(entry.head)],
|
|
132
|
+
["Key", printable(entry.key)],
|
|
133
|
+
["Lanes", printable(entry.lanes.join(", "))],
|
|
134
|
+
...entry.report?.summary === void 0 ? [] : [["Report", printable(entry.report.summary)]]
|
|
135
|
+
];
|
|
136
|
+
yield* answer(rows.map((row) => field(row).trimStart()).join("\n"));
|
|
137
|
+
})).pipe(Command.withDescription("Show an entry, with its lanes and its last report"));
|
|
138
|
+
/** What a hold names: an `--entry` alone, or a REPO and its `--target`. */
|
|
139
|
+
const heldOf = (flags) => {
|
|
140
|
+
const [repo, entry, target] = [
|
|
141
|
+
flags.repo,
|
|
142
|
+
flags.entry,
|
|
143
|
+
flags.target
|
|
144
|
+
].map(Option.getOrUndefined);
|
|
145
|
+
if (entry !== void 0 && repo === void 0 && target === void 0) return { entry };
|
|
146
|
+
if (entry === void 0 && repo !== void 0 && target !== void 0) return {
|
|
147
|
+
entry: void 0,
|
|
148
|
+
repo,
|
|
149
|
+
target
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const hold = Command.make("hold", {
|
|
153
|
+
repo: repoArgument.pipe(Argument.optional),
|
|
154
|
+
host: hostFlag,
|
|
155
|
+
entry: Flag.String("entry").pipe(Flag.withDescription("Hold this entry, instead of a REPO and --target"), Flag.withMetavar("ENTRY"), Flag.optional),
|
|
156
|
+
target: Flag.String("target").pipe(Flag.withDescription("Hold the REPO's queue for this branch"), Flag.withMetavar("BRANCH"), Flag.optional),
|
|
157
|
+
reason: Flag.String("reason").pipe(Flag.withDescription("Why, as the hold shows it"), Flag.withMetavar("TEXT"))
|
|
158
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
159
|
+
const what = heldOf(flags);
|
|
160
|
+
if (what === void 0) return yield* usageFailure("missing_target", "Hold a REPO with --target, or an --entry alone", {
|
|
161
|
+
says: "See its help",
|
|
162
|
+
run: [[
|
|
163
|
+
"queue",
|
|
164
|
+
"hold",
|
|
165
|
+
"--help"
|
|
166
|
+
]]
|
|
167
|
+
});
|
|
168
|
+
const held = yield* called(flags.host, (client, signal) => what.entry !== void 0 ? client.queue.hold(what.entry, {
|
|
169
|
+
reason: flags.reason,
|
|
170
|
+
signal
|
|
171
|
+
}) : client.queue.hold(what.repo, {
|
|
172
|
+
target: branchRef(what.target),
|
|
173
|
+
reason: flags.reason,
|
|
174
|
+
signal
|
|
175
|
+
}));
|
|
176
|
+
const id = held.value.hold.id;
|
|
177
|
+
yield* changed(held.value, id, {
|
|
178
|
+
done: `Held ${printable(what.entry !== void 0 ? what.entry : `${what.repo}'s ${what.target}`)} on ${held.host}`,
|
|
179
|
+
fields: [["Hold", printable(id)]],
|
|
180
|
+
next: {
|
|
181
|
+
says: "Release it",
|
|
182
|
+
run: [[
|
|
183
|
+
"queue",
|
|
184
|
+
"release",
|
|
185
|
+
id,
|
|
186
|
+
"--host",
|
|
187
|
+
held.host
|
|
188
|
+
]]
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
})).pipe(Command.withDescription("Hold an entry, or a target's whole queue"));
|
|
192
|
+
const release = Command.make("release", {
|
|
193
|
+
hold: idArgument("HOLD", "hold"),
|
|
194
|
+
host: hostFlag
|
|
195
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
196
|
+
const done = yield* called(flags.host, (client, signal) => client.queue.release(flags.hold, { signal }));
|
|
197
|
+
yield* changed(done.value, flags.hold, { done: `Released ${printable(flags.hold)} on ${done.host}` });
|
|
198
|
+
})).pipe(Command.withDescription("Release a hold"));
|
|
199
|
+
const retry = Command.make("retry", {
|
|
200
|
+
candidate: idArgument("CANDIDATE", "candidate"),
|
|
201
|
+
host: hostFlag
|
|
202
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
203
|
+
const done = yield* called(flags.host, (client, signal) => client.queue.retry(flags.candidate, { signal }));
|
|
204
|
+
yield* changed(done.value, done.value.candidate, { done: `Closed ${printable(done.value.candidate)} to try its entries again, on ${done.host}` });
|
|
205
|
+
})).pipe(Command.withDescription("Close a candidate and try its entries again"));
|
|
206
|
+
const queueCommand = Command.make("queue").pipe(Command.withDescription("A repo's merge queue (experimental)"), Command.withSubcommands([
|
|
207
|
+
add,
|
|
208
|
+
remove,
|
|
209
|
+
list,
|
|
210
|
+
show,
|
|
211
|
+
hold,
|
|
212
|
+
release,
|
|
213
|
+
retry
|
|
214
|
+
]));
|
|
215
|
+
export { queueCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|