ref0-git 0.0.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +127 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +562 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +487 -0
- package/app/apps/github/src/palette/server.ts +107 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +606 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +528 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +69 -0
- package/dist/cli/helpers.mjs +184 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +136 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +80 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +203 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +460 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +384 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { TokenInput, logoutJson } from "./documents.mjs";
|
|
2
|
+
import { answered, failure, snakeCase, usageFailure } from "./failure.mjs";
|
|
3
|
+
import { chosenHost, hostFlag, hostName, hostOf, remoteOf } from "./hosts.mjs";
|
|
4
|
+
import { CliModes, answer, cliDocument, commandLine, document, printable, receipt, say, secrets, utcDay } from "./output.mjs";
|
|
5
|
+
import { checkedHelpers, removeSignIn, storeSignIn } from "./sign-ins.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Redacted from "effect/Redacted";
|
|
8
|
+
import * as Stream from "effect/Stream";
|
|
9
|
+
import * as Stdio from "effect/Stdio";
|
|
10
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
11
|
+
import * as Command from "effect/cli/Command";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import * as DateTime from "effect/DateTime";
|
|
14
|
+
import * as Flag from "effect/cli/Flag";
|
|
15
|
+
import { createRestClient } from "@ref0/git/rest";
|
|
16
|
+
import * as Argument from "effect/cli/Argument";
|
|
17
|
+
import * as Clock from "effect/Clock";
|
|
18
|
+
import * as Result from "effect/Result";
|
|
19
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
20
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
21
|
+
import { deviceGrant, ghClientId, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "@ref0/git/auth";
|
|
22
|
+
// src/cli/sign-in.ts
|
|
23
|
+
/**
|
|
24
|
+
* `login`, `logout` and `whoami`. A token reaches Git's helpers through `git credential approve`
|
|
25
|
+
* and comes back through `fill`, so Git and `ref0-git` share one store; it never reaches a URL, an
|
|
26
|
+
* argument, stdout or a log line. A host has one sign-in at a time: a new one replaces the last.
|
|
27
|
+
*/
|
|
28
|
+
/** How long a sign-in request may take, when the code's expiry doesn't come first. */
|
|
29
|
+
const requestMs = 3e4;
|
|
30
|
+
/**
|
|
31
|
+
* A form POST to the host's sign-in, at its origin's root whatever its base path, as GitHub's is,
|
|
32
|
+
* its JSON read by `read`, as `@ref0/git/auth` reads the server's answer, or `undefined`, within
|
|
33
|
+
* `within` ms. It follows no redirect, which could send the device code, and the token, elsewhere.
|
|
34
|
+
*/
|
|
35
|
+
const signInPost = (host, path, fields, read, within = requestMs) => HttpClient.HttpClient.pipe(Effect.flatMap((client) => client.execute(HttpClientRequest.post(`${host.origin}${path}`).pipe(HttpClientRequest.acceptJson, HttpClientRequest.bodyUrlParams(fields)))), Effect.flatMap((response) => response.text), Effect.timeout(Math.max(within, 1)), Effect.provideService(FetchHttpClient.RequestInit, { redirect: "error" }), Effect.mapError(() => failure("unreachable", `Couldn't reach ${hostName(host)}'s sign-in`, "Check the host, then sign in again")), Effect.map(read));
|
|
36
|
+
/** `HH:MM UTC`, when a wait ends. */
|
|
37
|
+
const utcTime = (at) => `${DateTime.formatIso(DateTime.makeUnsafe(at)).slice(11, 16)} UTC`;
|
|
38
|
+
const sleep = (seconds) => Effect.sleep(`${seconds} seconds`);
|
|
39
|
+
/**
|
|
40
|
+
* GitHub's device flow, as `gh auth login` runs it with `gh`'s client ID: the code and link on
|
|
41
|
+
* stderr in every mode, then a poll at the host's interval until the person decides or it expires.
|
|
42
|
+
*/
|
|
43
|
+
const deviceToken = Effect.fnUntraced(function* (host) {
|
|
44
|
+
const started = yield* signInPost(host, signInPaths.deviceCode, { client_id: ghClientId }, readDeviceCodeAnswer);
|
|
45
|
+
if (started === void 0) return yield* failure("sign_in_unavailable", `${hostName(host)} doesn't offer sign-in from a device`, "Sign in with a token instead: --with-token");
|
|
46
|
+
const link = URL.parse(started.verification_uri);
|
|
47
|
+
if (/[\s\p{Cc}\p{Cf}]/u.test(started.verification_uri) || link?.origin !== host.origin || link.username !== "" || link.password !== "") return yield* failure("sign_in_elsewhere", `${hostName(host)} sent a sign-in link to another host`, "Check the host, then sign in again");
|
|
48
|
+
const expiresIn = started.expires_in;
|
|
49
|
+
const deviceCode = started.device_code;
|
|
50
|
+
let interval = started.interval ?? 5;
|
|
51
|
+
const until = (yield* Clock.currentTimeMillis) + expiresIn * 1e3;
|
|
52
|
+
yield* say(`Signing in to ${hostName(host)} in your browser. Enter this code there:`, ` ${printable(started.user_code)}`, ` ${printable(started.verification_uri)}`, `Waiting until ${utcTime(until)}.`);
|
|
53
|
+
for (;;) {
|
|
54
|
+
yield* sleep(interval);
|
|
55
|
+
const left = until - (yield* Clock.currentTimeMillis);
|
|
56
|
+
if (left <= 0) break;
|
|
57
|
+
const polled = yield* signInPost(host, signInPaths.accessToken, {
|
|
58
|
+
client_id: ghClientId,
|
|
59
|
+
device_code: deviceCode,
|
|
60
|
+
grant_type: deviceGrant
|
|
61
|
+
}, readAccessTokenAnswer, Math.min(left, requestMs)).pipe(Effect.catchIf((failed) => failed.reason === "unreachable" && left <= requestMs, () => Effect.succeed({ error: "authorization_pending" })));
|
|
62
|
+
if (polled?.access_token !== void 0) return Redacted.make(polled.access_token);
|
|
63
|
+
const error = polled?.error;
|
|
64
|
+
if (error === "authorization_pending") continue;
|
|
65
|
+
if (error === "slow_down") {
|
|
66
|
+
interval = polled?.interval ?? interval + 5;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (error === "access_denied") return yield* failure("access_denied", `The sign-in to ${hostName(host)} was denied`);
|
|
70
|
+
if (error === "expired_token") break;
|
|
71
|
+
return yield* failure(snakeCase(error ?? "sign_in_failed"), `${hostName(host)} refused the sign-in`, polled?.error_description);
|
|
72
|
+
}
|
|
73
|
+
return yield* failure("timeout", `The code expired at ${utcTime(until)} before it was approved`, "Sign in again for a new code");
|
|
74
|
+
});
|
|
75
|
+
const decodeToken = Schema.decodeUnknownResult(TokenInput);
|
|
76
|
+
/** The token on stdin, as `TokenInput` reads it: never typed at a prompt. */
|
|
77
|
+
const tokenFromStdin = Effect.fnUntraced(function* (host) {
|
|
78
|
+
if ((yield* CliModes).stdinTerminal) return yield* usageFailure("token_not_piped", "--with-token reads the token from stdin", `Pipe it in, as \`read -rs t; printf '%s\\n' "$t" | ${commandLine([
|
|
79
|
+
"login",
|
|
80
|
+
host,
|
|
81
|
+
"--with-token"
|
|
82
|
+
])}\``);
|
|
83
|
+
const piped = yield* (yield* Stdio.Stdio).stdin.pipe(Stream.decodeText(), Stream.mkString, Effect.mapError(() => usageFailure("token_unreadable", "stdin couldn't be read to its end", "Pipe in one token, on one line")));
|
|
84
|
+
const read = decodeToken(piped);
|
|
85
|
+
return Result.isSuccess(read) ? read.success : yield* usageFailure("token_unreadable", read.failure.message, "Pipe in one token, on one line");
|
|
86
|
+
});
|
|
87
|
+
/** Who `token` signs in on the host, as `GET /me` answers. */
|
|
88
|
+
const meWith = (host, token) => answered(hostName(host), (signal) => createRestClient({
|
|
89
|
+
url: host.endpoint,
|
|
90
|
+
credentials: { token: Redacted.value(token) }
|
|
91
|
+
}).me({ signal }));
|
|
92
|
+
/** A token's coverage and scope, as a person reads it. */
|
|
93
|
+
const coverage = (token) => token.repo !== void 0 ? `${token.scope} on ${printable(token.repo)}` : token.prefix === "" ? `${token.scope} on every repo` : `${token.scope} on ${printable(token.prefix)}*`;
|
|
94
|
+
/** The sign-in group's commands, at the top of the tree. */
|
|
95
|
+
const signInCommands = [
|
|
96
|
+
Command.make("login", {
|
|
97
|
+
host: Argument.String("HOST").pipe(Argument.withDescription("The host, as git.acme.dev, git.acme.dev/git where Git is under a path, or http://localhost:5173")),
|
|
98
|
+
withToken: Flag.Boolean("with-token").pipe(Flag.withDescription("Read a token from stdin instead of signing in in the browser"), Flag.withDefault(false)),
|
|
99
|
+
allowPlaintext: Flag.Boolean("allow-plaintext").pipe(Flag.withDescription("Store the token even with a helper ref0-git can't tell keeps it encrypted"), Flag.withDefault(false))
|
|
100
|
+
}, Effect.fnUntraced(function* ({ host, withToken, allowPlaintext }) {
|
|
101
|
+
const named = yield* hostOf(host);
|
|
102
|
+
const helpers = yield* checkedHelpers(named, allowPlaintext);
|
|
103
|
+
const token = withToken ? yield* tokenFromStdin(hostName(named)) : yield* deviceToken(named);
|
|
104
|
+
secrets.hide(Redacted.value(token));
|
|
105
|
+
const me = yield* meWith(named, token);
|
|
106
|
+
const { pushes } = yield* storeSignIn(named, {
|
|
107
|
+
username: me.actor.id,
|
|
108
|
+
password: token,
|
|
109
|
+
expiresAt: me.token?.expiresAt
|
|
110
|
+
}, helpers);
|
|
111
|
+
if ((yield* CliModes).json) return yield* document(me);
|
|
112
|
+
yield* receipt({
|
|
113
|
+
done: `Signed in to ${hostName(named)} as ${printable(me.actor.id)}`,
|
|
114
|
+
fields: [
|
|
115
|
+
["Token", `In ${helpers.join(", ")}, for Git and ref0-git`],
|
|
116
|
+
["Recorded", "As ref0-git.host, in Git's global config"],
|
|
117
|
+
...me.token === void 0 ? [] : [["Expires", utcDay(me.token.expiresAt)]],
|
|
118
|
+
...pushes ? [["Pushes", "Through git-remote-ref0, for large packs"]] : []
|
|
119
|
+
],
|
|
120
|
+
next: {
|
|
121
|
+
says: "See who you are there",
|
|
122
|
+
run: [[
|
|
123
|
+
"whoami",
|
|
124
|
+
"--host",
|
|
125
|
+
hostName(named)
|
|
126
|
+
]]
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
})).pipe(Command.withDescription("Sign in, and store a token for Git and ref0-git (experimental)")),
|
|
130
|
+
Command.make("logout", { host: Argument.String("HOST").pipe(Argument.withDescription("The host to sign out of, if you are signed in to more than one"), Argument.optional) }, Effect.fnUntraced(function* ({ host }) {
|
|
131
|
+
const chosen = yield* chosenHost(host, "Name the one to sign out of, as logout's HOST").pipe(Effect.catchIf((failed) => failed.reason === "no_host", () => Effect.succeed(void 0)));
|
|
132
|
+
const mode = yield* CliModes;
|
|
133
|
+
if (chosen === void 0) return yield* mode.json ? cliDocument(logoutJson, {
|
|
134
|
+
host: null,
|
|
135
|
+
removed: false
|
|
136
|
+
}) : say("You're not signed in to a host: nothing to remove");
|
|
137
|
+
const removed = yield* removeSignIn(chosen);
|
|
138
|
+
if (mode.json) return yield* cliDocument(logoutJson, {
|
|
139
|
+
host: hostName(chosen),
|
|
140
|
+
removed
|
|
141
|
+
});
|
|
142
|
+
yield* removed ? receipt({ done: `Signed out of ${hostName(chosen)}` }) : say(`Not signed in to ${hostName(chosen)}: nothing to remove`);
|
|
143
|
+
})).pipe(Command.withDescription("Remove the stored token (experimental)")),
|
|
144
|
+
Command.make("whoami", { host: hostFlag }, Effect.fnUntraced(function* ({ host }) {
|
|
145
|
+
const remote = yield* remoteOf(yield* chosenHost(host));
|
|
146
|
+
const me = yield* answered(remote.host, (signal) => remote.client.me({ signal }));
|
|
147
|
+
if ((yield* CliModes).json) return yield* document(me);
|
|
148
|
+
const token = me.token;
|
|
149
|
+
const rows = [
|
|
150
|
+
["Host", remote.host],
|
|
151
|
+
["Actor", printable(me.actor.id)],
|
|
152
|
+
...me.subject === void 0 ? [] : [["For", printable(me.subject.id)]],
|
|
153
|
+
...token === void 0 ? [["Token", "The host's own sign-in, with no scope or expiry"]] : [
|
|
154
|
+
["Token", printable(token.id)],
|
|
155
|
+
["Scope", coverage(token)],
|
|
156
|
+
["Expires", utcDay(token.expiresAt)]
|
|
157
|
+
]
|
|
158
|
+
];
|
|
159
|
+
yield* answer(rows.map(([label, value]) => `${label.padEnd(16)}${value}`).join("\n"));
|
|
160
|
+
})).pipe(Command.withDescription("Show who you are on the host (experimental)"))
|
|
161
|
+
];
|
|
162
|
+
export { signInCommands };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { BrokenField, approveCredential, breaksField, fillCredential, rejectCredential } from "./credentials.mjs";
|
|
2
|
+
import { CliFailure, failure, unsafeCredential } from "./failure.mjs";
|
|
3
|
+
import { gitRun } from "./git.mjs";
|
|
4
|
+
import { shellWord } from "../init/shell.mjs";
|
|
5
|
+
import { credentialHelpers, onPath, suggestedHelper } from "./helpers.mjs";
|
|
6
|
+
import { forgetHost, globalConfig, hostName, recordHost, signedInHosts } from "./hosts.mjs";
|
|
7
|
+
import { printable } from "./output.mjs";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Redacted from "effect/Redacted";
|
|
10
|
+
// src/cli/sign-ins.ts
|
|
11
|
+
/**
|
|
12
|
+
* A signed-in host, kept whole: its token in Git's helpers, by its origin, its `ref0-git.host`
|
|
13
|
+
* record, by its endpoint, and, with `git-remote-ref0` on `PATH`, its origin's `pushInsteadOf`.
|
|
14
|
+
* Each origin has one sign-in, so one record; each step is checked.
|
|
15
|
+
*/
|
|
16
|
+
/** Git's config key that sends `origin`'s pushes through `git-remote-ref0`. */
|
|
17
|
+
const pushKey = (origin) => `url.ref0::${origin}/.pushInsteadOf`;
|
|
18
|
+
/**
|
|
19
|
+
* The refusal of `plain`, the helpers that may keep the token as plain text, each named with
|
|
20
|
+
* where Git's config sets it, which `--json` also carries as its `data`.
|
|
21
|
+
*/
|
|
22
|
+
const plaintextRefused = (plain) => {
|
|
23
|
+
const named = plain.map(({ label, origin }) => `${label} (${origin})`).join(", ");
|
|
24
|
+
return new CliFailure({
|
|
25
|
+
class: "usage",
|
|
26
|
+
reason: "plaintext_helper",
|
|
27
|
+
headline: `Git's ${named} credential ${plain.length === 1 ? "helper" : "helpers"} may keep the token as plain text`,
|
|
28
|
+
next: {
|
|
29
|
+
says: `Use a helper that keeps it encrypted, as \`git config --global credential.helper ${suggestedHelper()}\`, in their place, or sign in with --allow-plaintext, which stores the token with every helper Git runs, these too`,
|
|
30
|
+
run: []
|
|
31
|
+
},
|
|
32
|
+
data: { helpers: plain.map(({ label, origin }) => ({
|
|
33
|
+
helper: label,
|
|
34
|
+
origin
|
|
35
|
+
})) }
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Where Git's helpers stand for `origin`: their labels, refused when there's none, when one may
|
|
40
|
+
* keep plain text and `allowPlaintext` isn't set, or when Git asks them by repo path, which a
|
|
41
|
+
* host's one sign-in can't answer.
|
|
42
|
+
*/
|
|
43
|
+
const checkedHelpers = Effect.fnUntraced(function* (host, allowPlaintext) {
|
|
44
|
+
const { origin } = host;
|
|
45
|
+
const helpers = yield* credentialHelpers(origin);
|
|
46
|
+
if (helpers.length === 0) return yield* failure("no_credential_helper", "Git has no credential helper to keep the token in", `Set one up: \`git config --global credential.helper ${suggestedHelper()}\`, then sign in again`);
|
|
47
|
+
const plain = helpers.filter((helper) => helper.plaintext);
|
|
48
|
+
if (plain.length > 0 && !allowPlaintext) return yield* plaintextRefused(plain);
|
|
49
|
+
if ((yield* gitRun([
|
|
50
|
+
"config",
|
|
51
|
+
"--type=bool",
|
|
52
|
+
"--get-urlmatch",
|
|
53
|
+
"credential.useHttpPath",
|
|
54
|
+
`${origin}/`
|
|
55
|
+
])).stdout.trim() === "true") return yield* failure("credential_by_path", `Git asks for ${hostName(host)}'s credentials by repo, with credential.useHttpPath, so one sign-in can't reach its repos`, `Turn it off for this host: \`git config --global credential.${origin}/.useHttpPath false\`, then sign in again`);
|
|
56
|
+
return helpers.map(({ label }) => label);
|
|
57
|
+
});
|
|
58
|
+
/** At most how many earlier sign-ins login erases one at a time, each by its username, before it stores. */
|
|
59
|
+
const earlierSignIns = 8;
|
|
60
|
+
/**
|
|
61
|
+
* A command, ready to copy, that erases `username`'s entry for `url` from each of Git's helpers,
|
|
62
|
+
* or `undefined` when printing would change the username, as a line break or a NUL, so the command
|
|
63
|
+
* wouldn't name it. Each value is a word of its own, never part of `printf`'s format.
|
|
64
|
+
*/
|
|
65
|
+
const eraseCommand = (url, username) => {
|
|
66
|
+
if (printable(username) !== username) return void 0;
|
|
67
|
+
return `printf 'protocol=%s\\nhost=%s\\nusername=%s\\n\\n' ${[
|
|
68
|
+
url.protocol.slice(0, -1),
|
|
69
|
+
url.host,
|
|
70
|
+
username
|
|
71
|
+
].map(shellWord).join(" ")} | git credential reject`;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Erases each sign-in Git's helpers still keep for `url` once it's erased with no username, one at
|
|
75
|
+
* a time by its username and token, since a helper may erase only an exact username's entry. Each
|
|
76
|
+
* has a username: `fillCredential` takes an entry only with a username and a password, and Git's
|
|
77
|
+
* fill exits 128, "unable to get password from user", when a helper answers a password alone. Its
|
|
78
|
+
* fills never ask at the terminal. Past `earlierSignIns`, one still kept fails as
|
|
79
|
+
* `credential_not_erased`, before anything is stored.
|
|
80
|
+
*/
|
|
81
|
+
const eraseEarlier = Effect.fnUntraced(function* (host, url, helpers) {
|
|
82
|
+
for (let erased = 0; erased < earlierSignIns; erased++) {
|
|
83
|
+
const kept = yield* fillCredential(url);
|
|
84
|
+
if (kept === void 0) return;
|
|
85
|
+
yield* rejectCredential(url, kept);
|
|
86
|
+
}
|
|
87
|
+
const still = yield* fillCredential(url);
|
|
88
|
+
if (still === void 0) return;
|
|
89
|
+
const command = eraseCommand(url, still.username);
|
|
90
|
+
return yield* failure("credential_not_erased", `Git's ${helpers.join(", ")} helper keeps an earlier token for ${hostName(host)}`, command === void 0 ? "Erase it with the helper's own tool, since its username holds a character ref0-git won't print, then sign in again" : `Erase it with \`${command}\`, then sign in again`);
|
|
91
|
+
});
|
|
92
|
+
/** The records of `host`'s origin, its own among them when it's recorded. */
|
|
93
|
+
const recordsOf = (host) => Effect.map(signedInHosts, (hosts) => hosts.filter((one) => one.origin === host.origin));
|
|
94
|
+
/**
|
|
95
|
+
* Stores `credential` as `host`'s origin's one sign-in, once every earlier one is erased, refusing a
|
|
96
|
+
* line break a host could use to store it for another host, and forgets a host it just recorded when the helpers don't give it
|
|
97
|
+
* back. Once it's kept, the origin's other records go: the token they named is this one now.
|
|
98
|
+
*/
|
|
99
|
+
const storeSignIn = Effect.fnUntraced(function* (host, credential, helpers) {
|
|
100
|
+
const { origin } = host;
|
|
101
|
+
if (breaksField(credential.username) || breaksField(Redacted.value(credential.password))) return yield* unsafeCredential(hostName(host));
|
|
102
|
+
const url = new URL(`${origin}/`);
|
|
103
|
+
const records = yield* recordsOf(host);
|
|
104
|
+
const known = records.some((one) => one.record === host.endpoint);
|
|
105
|
+
const pushes = yield* onPath("git-remote-ref0");
|
|
106
|
+
if (!known) yield* recordHost(host);
|
|
107
|
+
const stored = Effect.gen(function* () {
|
|
108
|
+
yield* rejectCredential(url);
|
|
109
|
+
yield* eraseEarlier(host, url, helpers);
|
|
110
|
+
yield* approveCredential(url, credential);
|
|
111
|
+
const kept = yield* fillCredential(url);
|
|
112
|
+
if (kept === void 0 || Redacted.value(kept.password) !== Redacted.value(credential.password)) return yield* failure("credential_not_kept", `Git's ${helpers.join(", ")} helper didn't keep the token`, "Check the helper works, as `git credential fill` does, then sign in again");
|
|
113
|
+
yield* pushes ? globalConfig([pushKey(origin), `${origin}/`]) : globalConfig([pushKey(origin)], { unset: true });
|
|
114
|
+
});
|
|
115
|
+
const undone = Effect.andThen(forgetHost(host.endpoint), rejectCredential(url, credential));
|
|
116
|
+
yield* stored.pipe(Effect.mapError((failed) => failed instanceof BrokenField ? unsafeCredential(hostName(host)) : failed), Effect.tapError(() => known ? Effect.void : Effect.ignore(undone)));
|
|
117
|
+
for (const other of records) if (other.record !== host.endpoint) yield* forgetHost(other.record);
|
|
118
|
+
return { pushes };
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Removes `host`'s sign-in, and says whether there was a token: the kept credential, then the
|
|
122
|
+
* origin's, then each record of the origin; while a helper still gives one back, it fails and
|
|
123
|
+
* keeps the records.
|
|
124
|
+
*/
|
|
125
|
+
const removeSignIn = Effect.fnUntraced(function* (host) {
|
|
126
|
+
const { origin } = host;
|
|
127
|
+
const url = new URL(`${origin}/`);
|
|
128
|
+
const kept = yield* fillCredential(url);
|
|
129
|
+
if (kept !== void 0) yield* rejectCredential(url, kept);
|
|
130
|
+
yield* rejectCredential(url);
|
|
131
|
+
if ((yield* fillCredential(url)) !== void 0) return yield* failure("credential_not_removed", `Git's helper still keeps the token for ${hostName(host)}`, "Remove it with the helper's own tool, then sign out again");
|
|
132
|
+
for (const one of yield* recordsOf(host)) yield* forgetHost(one.record);
|
|
133
|
+
yield* globalConfig([pushKey(origin)], { unset: true });
|
|
134
|
+
return kept !== void 0;
|
|
135
|
+
}, (removing, host) => Effect.catchTag(removing, "BrokenField", () => Effect.fail(unsafeCredential(hostName(host)))));
|
|
136
|
+
export { checkedHelpers, removeSignIn, storeSignIn };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { node } from "./node.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
// src/cli/sqlite.ts
|
|
7
|
+
/** A SQLite file that couldn't be opened or read, as one that isn't a database. */
|
|
8
|
+
var SqliteUnreadable = class extends Data.TaggedError("SqliteUnreadable") {};
|
|
9
|
+
/** The local SQLite `doctor` reads, read-only: Node's own, which has no Effect service (D12). */
|
|
10
|
+
var Sqlite = class extends Context.Service()("ref0-git/cli/Sqlite") {};
|
|
11
|
+
const migrated = (path) => Effect.try({
|
|
12
|
+
try: () => {
|
|
13
|
+
if (!node.fs.existsSync(path)) return /* @__PURE__ */ new Set();
|
|
14
|
+
const database = new (node.sqlite()).DatabaseSync(path, { readOnly: true });
|
|
15
|
+
try {
|
|
16
|
+
return database.prepare("select \"name\" from \"sqlite_master\" where \"name\" = ?").all("_migrations").length === 0 ? /* @__PURE__ */ new Set() : new Set(database.prepare("select \"name\" from \"_migrations\"").all().map((row) => String(row.name)));
|
|
17
|
+
} finally {
|
|
18
|
+
database.close();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
catch: (cause) => new SqliteUnreadable({
|
|
22
|
+
path,
|
|
23
|
+
cause
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
/** `Sqlite` over `node:sqlite`. */
|
|
27
|
+
const layer = Layer.succeed(Sqlite, { migrated });
|
|
28
|
+
export { Sqlite, SqliteUnreadable, layer };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { usageFailure } from "./failure.mjs";
|
|
2
|
+
import { hostFlag } from "./hosts.mjs";
|
|
3
|
+
import { CliModes, answer, printable, receipt, secrets, shown, utcDay } from "./output.mjs";
|
|
4
|
+
import { called, changed, durationOf, listed, pageFlags, pagesOf } from "./resources.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Redacted from "effect/Redacted";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
8
|
+
import * as Command from "effect/cli/Command";
|
|
9
|
+
import * as Flag from "effect/cli/Flag";
|
|
10
|
+
import { tokenScopes, tokenStates } from "@ref0/git/rest";
|
|
11
|
+
import * as Argument from "effect/cli/Argument";
|
|
12
|
+
import * as Clock from "effect/Clock";
|
|
13
|
+
// src/cli/tokens.ts
|
|
14
|
+
/**
|
|
15
|
+
* `tokens`: create, list and revoke a host's tokens. A token `create` mints is for its subject, so
|
|
16
|
+
* it's never stored here: it's printed, alone on stdout, only with `--show-token`, which declares
|
|
17
|
+
* that delivery, and refused before anything is minted without it (Q3, as changed 21 Nov).
|
|
18
|
+
*/
|
|
19
|
+
const coverageFlags = {
|
|
20
|
+
repo: Argument.String("REPO").pipe(Argument.withDescription("The repo the token covers, as acme/app"), Argument.optional),
|
|
21
|
+
prefix: Flag.String("prefix").pipe(Flag.withDescription("Every repo whose name starts with it, as acme/, instead of a REPO"), Flag.withMetavar("PREFIX"), Flag.optional)
|
|
22
|
+
};
|
|
23
|
+
/** The repo or the prefix a token command names: exactly one of them. */
|
|
24
|
+
const targetOf = (flags) => {
|
|
25
|
+
if (Option.isSome(flags.repo) && Option.isNone(flags.prefix)) return Effect.succeed(flags.repo.value);
|
|
26
|
+
if (Option.isSome(flags.prefix) && Option.isNone(flags.repo)) return Effect.succeed({ prefix: flags.prefix.value });
|
|
27
|
+
return Effect.fail(usageFailure("missing_target", "Name a REPO or a --prefix, not both"));
|
|
28
|
+
};
|
|
29
|
+
/** What a token covers, as a person reads it. */
|
|
30
|
+
const coverage = (token) => token.repo !== void 0 ? printable(token.repo) : token.prefix === "" ? "every repo" : `${printable(token.prefix ?? "")}*`;
|
|
31
|
+
const create = Command.make("create", {
|
|
32
|
+
...coverageFlags,
|
|
33
|
+
host: hostFlag,
|
|
34
|
+
subject: Flag.String("subject").pipe(Flag.withDescription("Who the token is for: the actor it signs in as"), Flag.withMetavar("ID")),
|
|
35
|
+
scope: Flag.Literals("scope", tokenScopes).pipe(Flag.withDescription("What it may do: read, report a check, or write"), Flag.withDefault("read")),
|
|
36
|
+
expires: Flag.String("expires").pipe(Flag.withDescription("How long until it expires, as 12h or 90d"), Flag.withMetavar("DURATION"), Flag.withDefault("30d")),
|
|
37
|
+
showToken: Flag.Boolean("show-token").pipe(Flag.withDescription("Print the token on stdout, the only way to get it"), Flag.withDefault(false))
|
|
38
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
39
|
+
const target = yield* targetOf(flags);
|
|
40
|
+
const lasts = yield* durationOf("expires", flags.expires);
|
|
41
|
+
if (!flags.showToken) {
|
|
42
|
+
const named = Option.match(flags.repo, {
|
|
43
|
+
onNone: () => ["--prefix", Option.getOrElse(flags.prefix, () => "")],
|
|
44
|
+
onSome: (repo) => [repo]
|
|
45
|
+
});
|
|
46
|
+
const host = Option.match(flags.host, {
|
|
47
|
+
onNone: () => [],
|
|
48
|
+
onSome: (h) => ["--host", h]
|
|
49
|
+
});
|
|
50
|
+
return yield* usageFailure("token_not_shown", "A token for someone else goes to them, so tokens create stores none: it prints it only with --show-token", {
|
|
51
|
+
says: "Print it, to hand to its subject",
|
|
52
|
+
run: [[
|
|
53
|
+
"tokens",
|
|
54
|
+
"create",
|
|
55
|
+
...named,
|
|
56
|
+
...host,
|
|
57
|
+
"--subject",
|
|
58
|
+
flags.subject,
|
|
59
|
+
"--scope",
|
|
60
|
+
flags.scope,
|
|
61
|
+
"--expires",
|
|
62
|
+
flags.expires,
|
|
63
|
+
"--show-token"
|
|
64
|
+
]]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const now = yield* Clock.currentTimeMillis;
|
|
68
|
+
const made = yield* called(flags.host, (client, signal) => client.tokens.create(target, {
|
|
69
|
+
scope: flags.scope,
|
|
70
|
+
expiresAt: now + lasts,
|
|
71
|
+
subject: { id: flags.subject },
|
|
72
|
+
signal
|
|
73
|
+
}));
|
|
74
|
+
const { secret: received, ...record } = made.value;
|
|
75
|
+
const secret = Redacted.make(received);
|
|
76
|
+
secrets.hide(Redacted.value(secret));
|
|
77
|
+
const token = record;
|
|
78
|
+
yield* receipt({
|
|
79
|
+
done: `Created a token for ${printable(token.subject.id)} on ${made.host}`,
|
|
80
|
+
fields: [
|
|
81
|
+
["ID", printable(token.id)],
|
|
82
|
+
["Scope", `${token.scope} on ${coverage(token)}`],
|
|
83
|
+
["Expires", utcDay(token.expiresAt)]
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
if ((yield* CliModes).json) return yield* shown(secret, record);
|
|
87
|
+
yield* answer(Redacted.value(secret));
|
|
88
|
+
})).pipe(Command.withDescription("Create a token for someone, printed only with --show-token; it expires in 30 days unless --expires says"));
|
|
89
|
+
/** A token's row, as `tokens list` prints it. */
|
|
90
|
+
const tokenLine = (token) => [
|
|
91
|
+
token.id,
|
|
92
|
+
`${token.scope} on ${coverage(token)}`,
|
|
93
|
+
token.subject.id,
|
|
94
|
+
token.revokedAt === void 0 ? `expires ${utcDay(token.expiresAt)}` : "revoked"
|
|
95
|
+
].map(printable).join(" ");
|
|
96
|
+
const list = Command.make("list", {
|
|
97
|
+
...coverageFlags,
|
|
98
|
+
host: hostFlag,
|
|
99
|
+
state: Flag.Literals("state", tokenStates).pipe(Flag.withDescription("Which tokens: active, the default, expired, revoked or all"), Flag.optional),
|
|
100
|
+
...pageFlags
|
|
101
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
102
|
+
const target = yield* targetOf(flags);
|
|
103
|
+
const state = Option.getOrUndefined(flags.state);
|
|
104
|
+
const command = (host) => [
|
|
105
|
+
"tokens",
|
|
106
|
+
"list",
|
|
107
|
+
...Option.match(flags.repo, {
|
|
108
|
+
onNone: () => ["--prefix", Option.getOrElse(flags.prefix, () => "")],
|
|
109
|
+
onSome: (repo) => [repo]
|
|
110
|
+
}),
|
|
111
|
+
...["--host", host],
|
|
112
|
+
...state === void 0 ? [] : ["--state", state]
|
|
113
|
+
];
|
|
114
|
+
const read = yield* pagesOf(flags.host, flags, command, tokenLine, (client, page, signal) => {
|
|
115
|
+
const input = {
|
|
116
|
+
page,
|
|
117
|
+
signal
|
|
118
|
+
};
|
|
119
|
+
if (state !== void 0) input.state = state;
|
|
120
|
+
return client.tokens.list(target, input);
|
|
121
|
+
});
|
|
122
|
+
yield* listed(read, {
|
|
123
|
+
line: tokenLine,
|
|
124
|
+
none: "No tokens",
|
|
125
|
+
command,
|
|
126
|
+
choice: flags
|
|
127
|
+
});
|
|
128
|
+
})).pipe(Command.withDescription("List a repo's or a prefix's tokens"));
|
|
129
|
+
const revoke = Command.make("revoke", {
|
|
130
|
+
token: Argument.String("TOKEN").pipe(Argument.withDescription("The token's ID, as tokens list prints it")),
|
|
131
|
+
host: hostFlag
|
|
132
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
133
|
+
const done = yield* called(flags.host, (client, signal) => client.tokens.revoke(flags.token, { signal }));
|
|
134
|
+
yield* changed({}, flags.token, { done: `Revoked token ${printable(flags.token)} on ${done.host}` });
|
|
135
|
+
})).pipe(Command.withDescription("Revoke a token, so it signs nothing in again"));
|
|
136
|
+
const tokensCommand = Command.make("tokens").pipe(Command.withDescription("The host's tokens (experimental)"), Command.withSubcommands([
|
|
137
|
+
create,
|
|
138
|
+
list,
|
|
139
|
+
revoke
|
|
140
|
+
]));
|
|
141
|
+
export { tokensCommand };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { forget, leftBehind, notPutBack } from "./failure.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as FileSystem from "effect/FileSystem";
|
|
5
|
+
import * as Path from "effect/Path";
|
|
6
|
+
import * as Result from "effect/Result";
|
|
7
|
+
// src/cli/vendor.ts
|
|
8
|
+
const why = (error) => error.message;
|
|
9
|
+
/** A missing path's failure, which a check that it's there answers as `undefined`. */
|
|
10
|
+
const missing = (error) => Predicate.isTagged(error.reason, "NotFound") ? Effect.succeed(void 0) : Effect.fail(error);
|
|
11
|
+
/** A tag no other run's folder uses. */
|
|
12
|
+
const freshTag = () => Buffer.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(6))).toString("hex");
|
|
13
|
+
/**
|
|
14
|
+
* Puts `packed`'s tarballs into `folder`'s `vendor/`, where the specs `init` writes name them,
|
|
15
|
+
* before it writes, as one change that a failure undoes, all of it in one folder the run owns,
|
|
16
|
+
* `vendor/.ref0-init-<tag>/`, made with an exclusive `mkdir` that fails on any path already there,
|
|
17
|
+
* a link too, without following it:
|
|
18
|
+
*
|
|
19
|
+
* 1. Each tarball is written into the folder, as `<n>.part`.
|
|
20
|
+
* 2. Each destination is read without following a link: one that's there and isn't a file refuses.
|
|
21
|
+
* 3. Each is committed: a tarball already there is moved into the folder, as `<n>.kept`, then the
|
|
22
|
+
* part is renamed into place, both on `vendor/`'s own file system.
|
|
23
|
+
*
|
|
24
|
+
* A failure renames each moved tarball back and removes the one folder, which a recursive remove
|
|
25
|
+
* does without following its links, and `vendor/` and `vendor/cli/` when this run made them: a
|
|
26
|
+
* folder it can't remove is recorded as left, for the run's end to name. A destination it can't
|
|
27
|
+
* put back is `stranded`, with the file in the folder that holds its old
|
|
28
|
+
* bytes, and the folder stays. On success, the folder goes, or is recorded as left for the run's
|
|
29
|
+
* end to name. A cancel waits for all of that to end: it's uninterruptible, and waits on nothing
|
|
30
|
+
* but the disk, so no destination is left between its old tarball and its new one. The packed
|
|
31
|
+
* folder is `init`'s to remove, however the run ends.
|
|
32
|
+
*/
|
|
33
|
+
const vendored = Effect.fnUntraced(function* (packed, folder, tag = freshTag()) {
|
|
34
|
+
const fs = yield* FileSystem.FileSystem;
|
|
35
|
+
const path = yield* Path.Path;
|
|
36
|
+
const own = `${folder}/vendor/.ref0-init-${tag}`;
|
|
37
|
+
const paths = [...packed.vendor.values()];
|
|
38
|
+
const made = [];
|
|
39
|
+
const moved = [];
|
|
40
|
+
/** `at`'s own entry, a link not followed, or `undefined` when nothing is there. */
|
|
41
|
+
const entryAt = (at) => fs.lstat(at).pipe(Effect.catch(missing));
|
|
42
|
+
const removed = (at) => fs.remove(at, {
|
|
43
|
+
recursive: true,
|
|
44
|
+
force: true
|
|
45
|
+
});
|
|
46
|
+
const madeFolder = Effect.fnUntraced(function* (at) {
|
|
47
|
+
if ((yield* entryAt(at)) !== void 0) return;
|
|
48
|
+
yield* fs.makeDirectory(at, { recursive: true });
|
|
49
|
+
made.push(at);
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* `why` as the run's refusal, once `paths` are removed, latest first: each is tried, and one
|
|
53
|
+
* that stays is recorded as left, inside the mask, so the run's end names it however it ends.
|
|
54
|
+
*/
|
|
55
|
+
const refusedAfter = (why, removing) => Effect.forEach(removing(), (at) => removed(at).pipe(Effect.catch((error) => leftBehind(at, error))), { discard: true }).pipe(Effect.as({
|
|
56
|
+
kind: "refused",
|
|
57
|
+
why
|
|
58
|
+
}));
|
|
59
|
+
/** The run's folder and the folders it made, latest first. */
|
|
60
|
+
const everything = () => [own, ...made.toReversed()];
|
|
61
|
+
const vendorMade = yield* Effect.result(madeFolder(`${folder}/vendor`));
|
|
62
|
+
if (Result.isFailure(vendorMade)) return {
|
|
63
|
+
kind: "refused",
|
|
64
|
+
why: why(vendorMade.failure)
|
|
65
|
+
};
|
|
66
|
+
const ownMade = yield* Effect.result(fs.makeDirectory(own));
|
|
67
|
+
if (Result.isFailure(ownMade)) return yield* refusedAfter(why(ownMade.failure), () => made.toReversed());
|
|
68
|
+
const staged = yield* Effect.result(Effect.gen(function* () {
|
|
69
|
+
for (const [at, each] of paths.entries()) {
|
|
70
|
+
yield* fs.writeFile(`${own}/${at}.part`, yield* fs.readFile(`${packed.folder}/${each}`), { flag: "wx" });
|
|
71
|
+
yield* madeFolder(path.dirname(`${folder}/${each}`));
|
|
72
|
+
}
|
|
73
|
+
for (const each of paths) {
|
|
74
|
+
const held = yield* entryAt(`${folder}/${each}`);
|
|
75
|
+
if (held !== void 0 && held.type !== "File") return `${folder}/${each} is there and isn't a file`;
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
if (Result.isFailure(staged)) return yield* refusedAfter(why(staged.failure), everything);
|
|
79
|
+
if (staged.success !== void 0) return yield* refusedAfter(staged.success, everything);
|
|
80
|
+
const committed = yield* Effect.result(Effect.gen(function* () {
|
|
81
|
+
for (const [at, each] of paths.entries()) {
|
|
82
|
+
const to = `${folder}/${each}`;
|
|
83
|
+
const one = {
|
|
84
|
+
to,
|
|
85
|
+
kept: (yield* entryAt(to)) !== void 0 ? `${own}/${at}.kept` : void 0,
|
|
86
|
+
placed: false
|
|
87
|
+
};
|
|
88
|
+
const { kept } = one;
|
|
89
|
+
if (kept !== void 0) {
|
|
90
|
+
yield* notPutBack(one, { message: "the run stopped before it could" });
|
|
91
|
+
yield* fs.rename(to, kept).pipe(Effect.tapError(() => forget(kept)));
|
|
92
|
+
}
|
|
93
|
+
moved.push(one);
|
|
94
|
+
yield* fs.rename(`${own}/${at}.part`, to);
|
|
95
|
+
one.placed = true;
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
if (Result.isFailure(committed)) {
|
|
99
|
+
const stranded = [];
|
|
100
|
+
for (const each of moved.toReversed()) {
|
|
101
|
+
const back = each.kept !== void 0 ? fs.rename(each.kept, each.to) : each.placed ? removed(each.to) : Effect.void;
|
|
102
|
+
const putBack = yield* Effect.result(back);
|
|
103
|
+
if (each.kept !== void 0) yield* forget(each.kept);
|
|
104
|
+
if (Result.isFailure(putBack)) {
|
|
105
|
+
stranded.push({
|
|
106
|
+
to: each.to,
|
|
107
|
+
kept: each.kept
|
|
108
|
+
});
|
|
109
|
+
yield* notPutBack(each, putBack.failure);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (stranded.length > 0) return {
|
|
113
|
+
kind: "stranded",
|
|
114
|
+
why: why(committed.failure),
|
|
115
|
+
stranded
|
|
116
|
+
};
|
|
117
|
+
return yield* refusedAfter(why(committed.failure), everything);
|
|
118
|
+
}
|
|
119
|
+
for (const each of moved) if (each.kept !== void 0) yield* forget(each.kept);
|
|
120
|
+
yield* removed(own).pipe(Effect.catch((error) => leftBehind(own, error)));
|
|
121
|
+
return { kind: "placed" };
|
|
122
|
+
}, Effect.uninterruptible);
|
|
123
|
+
export { vendored };
|