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,184 @@
|
|
|
1
|
+
import { failure } from "./failure.mjs";
|
|
2
|
+
import { gitRun } from "./git.mjs";
|
|
3
|
+
import { node } from "./node.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as FileSystem from "effect/FileSystem";
|
|
6
|
+
// src/cli/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Which of Git's credential helpers `git credential approve` stores a host's token with, read from
|
|
9
|
+
* Git's config, never by running a helper: Git's approve stores with every `credential.helper`
|
|
10
|
+
* whose section matches the URL, in config order, an empty value clearing those before it. The
|
|
11
|
+
* match here is ref0-git's own and counts too many rather than too few: it ignores a section's
|
|
12
|
+
* user, port and path, and honours a clearing value only where Git surely applies it, so a drift
|
|
13
|
+
* from Git can only refuse a helper that was safe.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* At most how many bytes of credential config, and how many of its entries, login reads. Past
|
|
17
|
+
* either it refuses: a list cut short could leave out a plain-text helper.
|
|
18
|
+
*/
|
|
19
|
+
const credentialConfigBytes = 65536;
|
|
20
|
+
/** The helpers that keep a secret in memory or in the platform's encrypted store, never a file. */
|
|
21
|
+
const safeHelpers = /* @__PURE__ */ new Set([
|
|
22
|
+
"cache",
|
|
23
|
+
"osxkeychain",
|
|
24
|
+
"wincred",
|
|
25
|
+
"libsecret",
|
|
26
|
+
"manager",
|
|
27
|
+
"manager-core"
|
|
28
|
+
]);
|
|
29
|
+
/** Git Credential Manager's names, whose store `credential.credentialStore` sets, `plaintext` among them. */
|
|
30
|
+
const storeSetByConfig = /* @__PURE__ */ new Set(["manager", "manager-core"]);
|
|
31
|
+
/** Where a config entry comes from, as a person finds it: a file's path, or `command line`. */
|
|
32
|
+
const originOf = (shown) => {
|
|
33
|
+
if (shown.startsWith("file:")) return shown.slice(5);
|
|
34
|
+
return shown.endsWith(":") ? shown.slice(0, -1) : shown;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Each entry of `git config -z --show-origin --get-regexp`'s output, which is the origin, a NUL,
|
|
38
|
+
* the key, then a line break and the value where there is one, and a NUL; `undefined` when the
|
|
39
|
+
* output isn't in that shape. Git lowercases the section and the key, never the subsection.
|
|
40
|
+
*/
|
|
41
|
+
const entriesOf = (listed) => {
|
|
42
|
+
const fields = listed.split("\0");
|
|
43
|
+
if (fields.pop() !== "" || fields.length % 2 !== 0) return void 0;
|
|
44
|
+
const entries = [];
|
|
45
|
+
for (let at = 0; at < fields.length; at += 2) {
|
|
46
|
+
const [origin = "", item = ""] = fields.slice(at, at + 2);
|
|
47
|
+
const keyEnd = item.indexOf("\n");
|
|
48
|
+
const name = keyEnd === -1 ? item : item.slice(0, keyEnd);
|
|
49
|
+
if (!name.startsWith("credential.")) return void 0;
|
|
50
|
+
const rest = name.slice(11);
|
|
51
|
+
const dot = rest.lastIndexOf(".");
|
|
52
|
+
entries.push({
|
|
53
|
+
origin: originOf(origin),
|
|
54
|
+
section: dot === -1 ? void 0 : rest.slice(0, dot),
|
|
55
|
+
key: dot === -1 ? rest : rest.slice(dot + 1),
|
|
56
|
+
value: keyEnd === -1 ? void 0 : item.slice(keyEnd + 1)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return entries;
|
|
60
|
+
};
|
|
61
|
+
/** `text` with its `%XX` escapes decoded, or as it is where one doesn't decode. */
|
|
62
|
+
const decoded = (text) => {
|
|
63
|
+
try {
|
|
64
|
+
return decodeURIComponent(text);
|
|
65
|
+
} catch {
|
|
66
|
+
return text;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* A host as Git's urlmatch compares it: in lower case, one trailing dot dropped, so
|
|
71
|
+
* `GIT.Acme.dev.` names `git.acme.dev`.
|
|
72
|
+
*/
|
|
73
|
+
const gitHost = (host) => host.toLowerCase().replace(/\.$/, "");
|
|
74
|
+
/**
|
|
75
|
+
* The scheme and host a `credential.<url>` section names, either left out where it names none,
|
|
76
|
+
* which matches any. Git reads a full URL or a partial one, as `git.acme.dev` or `https://`; this
|
|
77
|
+
* reads both alike, decodes the host's `%XX` escapes and drops the user, port and path.
|
|
78
|
+
*/
|
|
79
|
+
const sectionUrl = (section) => {
|
|
80
|
+
const schemeEnd = section.indexOf("://");
|
|
81
|
+
const scheme = schemeEnd > 0 ? section.slice(0, schemeEnd).toLowerCase() : void 0;
|
|
82
|
+
const rest = schemeEnd === -1 ? section : section.slice(schemeEnd + 3);
|
|
83
|
+
const authorityEnd = rest.search(/[/?#]/);
|
|
84
|
+
const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
|
|
85
|
+
const hostPort = authority.slice(authority.lastIndexOf("@") + 1);
|
|
86
|
+
const host = hostPort.startsWith("[") ? hostPort.slice(0, hostPort.indexOf("]") + 1) : hostPort.replace(/:[^:]*$/, "");
|
|
87
|
+
return {
|
|
88
|
+
scheme,
|
|
89
|
+
host: host === "" ? void 0 : gitHost(decoded(host))
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/** Whether `pattern` names `host`, label by label, a `*` label standing for any one label. */
|
|
93
|
+
const hostMatches = (pattern, host) => {
|
|
94
|
+
const patterns = pattern.split(".");
|
|
95
|
+
const labels = host.split(".");
|
|
96
|
+
return patterns.length === labels.length && patterns.every((label, at) => label === "*" || label === labels[at]);
|
|
97
|
+
};
|
|
98
|
+
/** Whether Git may apply an entry of `section` to `login`'s URL: unscoped, or naming its scheme and host. */
|
|
99
|
+
const mayApply = (section, login) => {
|
|
100
|
+
if (section === void 0) return true;
|
|
101
|
+
const { scheme, host } = sectionUrl(section);
|
|
102
|
+
return (scheme === void 0 || scheme === login.scheme) && (host === void 0 || hostMatches(host, login.host));
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Whether Git surely applies a clearing `helper =` of `section` to `login`'s URL: unscoped, or
|
|
106
|
+
* naming exactly its origin, with no user or path, so it can't clear a helper Git keeps.
|
|
107
|
+
*/
|
|
108
|
+
const surelyApplies = (section, login) => section === void 0 || section.replace(/\/$/, "") === login.origin;
|
|
109
|
+
/**
|
|
110
|
+
* The program a helper's value runs, by the name Git's own and the platform helpers have: `cache`
|
|
111
|
+
* for `cache --timeout=3600`, `libsecret` for `/usr/lib/git-core/git-credential-libsecret`.
|
|
112
|
+
* `undefined` for a `!` command, any word a shell would read as more than a plain word, a value
|
|
113
|
+
* holding a tab, a line break or another control character, or a path that isn't a
|
|
114
|
+
* `git-credential-*` program, since ref0-git can't tell what that keeps. A path is trusted by the
|
|
115
|
+
* name it gives, as Git's config names it.
|
|
116
|
+
*/
|
|
117
|
+
const programOf = (value) => /^(?:([A-Za-z0-9][A-Za-z0-9-]*)|\/(?:[\w.+,@%~-]+\/)*git-credential-([A-Za-z0-9-]+))(?: +[\w./=:+,@%~-]+)*(?![\s\S])/.exec(value)?.slice(1).find((name) => name !== void 0);
|
|
118
|
+
/**
|
|
119
|
+
* What a refusal names a helper `programOf` can't name by: a plain word's or a path's first word,
|
|
120
|
+
* without its arguments, or `a ! command` or `a shell command`, never the command itself.
|
|
121
|
+
*/
|
|
122
|
+
const labelOf = (value) => {
|
|
123
|
+
if (value === void 0) return "(no value)";
|
|
124
|
+
if (value.startsWith("!")) return "a ! command";
|
|
125
|
+
return /^[\w./+,@%~-]+(?= |(?![\s\S]))/.exec(value)?.[0] ?? "a shell command";
|
|
126
|
+
};
|
|
127
|
+
/** The helpers approve stores `origin`'s credential with, as `entries` set them, in order. */
|
|
128
|
+
const helpersFor = (entries, origin) => {
|
|
129
|
+
const url = new URL(origin);
|
|
130
|
+
const login = {
|
|
131
|
+
scheme: url.protocol.slice(0, -1),
|
|
132
|
+
host: gitHost(url.hostname),
|
|
133
|
+
origin: url.origin
|
|
134
|
+
};
|
|
135
|
+
const applying = entries.filter((entry) => mayApply(entry.section, login));
|
|
136
|
+
const plaintextStore = node.process.env["GCM_CREDENTIAL_STORE"]?.toLowerCase() === "plaintext" || applying.some((entry) => entry.key === "credentialstore" && entry.value?.toLowerCase() === "plaintext");
|
|
137
|
+
let helpers = [];
|
|
138
|
+
for (const entry of applying) {
|
|
139
|
+
if (entry.key !== "helper") continue;
|
|
140
|
+
if (entry.value === "") {
|
|
141
|
+
if (surelyApplies(entry.section, login)) helpers = [];
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const program = entry.value === void 0 ? void 0 : programOf(entry.value);
|
|
145
|
+
const safe = program !== void 0 && safeHelpers.has(program) && !(plaintextStore && storeSetByConfig.has(program));
|
|
146
|
+
helpers.push({
|
|
147
|
+
label: program ?? labelOf(entry.value),
|
|
148
|
+
origin: entry.origin,
|
|
149
|
+
plaintext: !safe
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return helpers;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The helpers `git credential approve` stores `origin`'s credential with, as Git's config sets
|
|
156
|
+
* them, read by the same Git, in the same folder and environment, as approve, so an `includeIf`
|
|
157
|
+
* resolves alike. It refuses config it can't read, or past `credentialConfigBytes` or
|
|
158
|
+
* `credentialConfigEntries`.
|
|
159
|
+
*/
|
|
160
|
+
const credentialHelpers = Effect.fnUntraced(function* (origin) {
|
|
161
|
+
const listed = yield* gitRun([
|
|
162
|
+
"config",
|
|
163
|
+
"-z",
|
|
164
|
+
"--show-origin",
|
|
165
|
+
"--get-regexp",
|
|
166
|
+
String.raw`^credential\..*(helper|credentialstore)$`
|
|
167
|
+
], { stdoutMost: credentialConfigBytes });
|
|
168
|
+
if (listed.overflowed) return yield* failure("credential_config_too_large", `Can't check Git's credential helpers. Its credential config passes ${credentialConfigBytes / 1024} KiB`, "Remove the credential entries you no longer use from your Git config, then sign in again");
|
|
169
|
+
const entries = listed.status === 1 && listed.stdout === "" ? [] : entriesOf(listed.stdout);
|
|
170
|
+
if (listed.status === null || listed.status > 1 || entries === void 0) return yield* failure("credential_config_unread", `Couldn't read Git's credential config: ${listed.stderr.trim().split("\n")[0] || "git config failed"}`, "Fix the config Git names, as `git config --list` shows it, then sign in again");
|
|
171
|
+
if (entries.length > 128) return yield* failure("credential_config_too_large", `Can't check Git's credential helpers. Its config holds more than 128 credential entries`, "Remove the credential entries you no longer use from your Git config, then sign in again");
|
|
172
|
+
return helpersFor(entries, origin);
|
|
173
|
+
});
|
|
174
|
+
/** The helper to set up where none is, for this machine's platform. */
|
|
175
|
+
const platformHelpers = /* @__PURE__ */ new Map([["darwin", "osxkeychain"], ["win32", "manager"]]);
|
|
176
|
+
const suggestedHelper = () => platformHelpers.get(node.process.platform) ?? "libsecret";
|
|
177
|
+
/** Whether `program` is on a later `git push`'s `PATH`, which lacks `npx`'s `node_modules/.bin`. */
|
|
178
|
+
const onPath = Effect.fnUntraced(function* (program) {
|
|
179
|
+
const fs = yield* FileSystem.FileSystem;
|
|
180
|
+
const folders = (node.process.env["PATH"] ?? "").split(":").filter((folder) => folder !== "" && !folder.endsWith("/node_modules/.bin"));
|
|
181
|
+
for (const folder of folders) if (yield* fs.exists(`${folder}/${program}`).pipe(Effect.orElseSucceed(() => false))) return true;
|
|
182
|
+
return false;
|
|
183
|
+
});
|
|
184
|
+
export { credentialConfigBytes, credentialHelpers, onPath, suggestedHelper };
|
|
@@ -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 };
|