ref0-git 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +122 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +538 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +48 -0
- package/dist/cli/helpers.mjs +51 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +79 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +75 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +383 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { signals } from "./credentials.mjs";
|
|
3
|
+
import { failureJson, helpJson } from "./documents.mjs";
|
|
4
|
+
import { CliFailure, cancelled, exitCodes, failure, leftovers, snakeCase, usageFailure } from "./failure.mjs";
|
|
5
|
+
import { node, written } from "./node.mjs";
|
|
6
|
+
import { CliModes, flagOn, modesOf, nextDocument, nextLines, printable, secrets } from "./output.mjs";
|
|
7
|
+
import { ref0Git } from "./commands.mjs";
|
|
8
|
+
import { runControl } from "./run-end.mjs";
|
|
9
|
+
import { layer } from "./runtime.mjs";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import * as Cause from "effect/Cause";
|
|
13
|
+
import * as Exit from "effect/Exit";
|
|
14
|
+
import * as Fiber from "effect/Fiber";
|
|
15
|
+
import * as Match from "effect/Match";
|
|
16
|
+
import * as Option from "effect/Option";
|
|
17
|
+
import * as Predicate from "effect/Predicate";
|
|
18
|
+
import * as CliConfig from "effect/cli/CliConfig";
|
|
19
|
+
import * as CliError from "effect/cli/CliError";
|
|
20
|
+
import * as CliOutput from "effect/cli/CliOutput";
|
|
21
|
+
import * as Command from "effect/cli/Command";
|
|
22
|
+
import * as GlobalFlag from "effect/cli/GlobalFlag";
|
|
23
|
+
// src/cli/ref0-git.ts
|
|
24
|
+
/**
|
|
25
|
+
* `ref0-git`, as `npx ref0-git`: its commands, and the one place a run ends, saying its failure
|
|
26
|
+
* and exiting 0, 1, 2 for usage, or 130; a defect's cause, which could hold a credential, isn't said.
|
|
27
|
+
*/
|
|
28
|
+
const { process } = node;
|
|
29
|
+
const formatter = CliOutput.defaultFormatter({ colors: false });
|
|
30
|
+
const args = process.argv.slice(2);
|
|
31
|
+
const json = flagOn(args, "json");
|
|
32
|
+
/** The lifecycle labels a description ends with, in parentheses. */
|
|
33
|
+
const labels = ["experimental", "beta"];
|
|
34
|
+
/** A description's lifecycle label, in its parentheses, and the words before it. */
|
|
35
|
+
const labelled = (description) => {
|
|
36
|
+
const label = labels.find((each) => description.endsWith(`(${each})`));
|
|
37
|
+
return label === void 0 ? {
|
|
38
|
+
description,
|
|
39
|
+
lifecycle: "stable"
|
|
40
|
+
} : {
|
|
41
|
+
description: description.slice(0, -`(${label})`.length).trimEnd(),
|
|
42
|
+
lifecycle: label
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** Help as `--help --json` prints it: the command, its arguments, flags and subcommands. */
|
|
46
|
+
const helpDocument = (help) => ({
|
|
47
|
+
command: (help.commandPath ?? []).join(" "),
|
|
48
|
+
...labelled(help.description),
|
|
49
|
+
usage: help.usage,
|
|
50
|
+
arguments: (help.args ?? []).map((arg) => ({
|
|
51
|
+
name: arg.name,
|
|
52
|
+
description: Option.getOrUndefined(arg.description),
|
|
53
|
+
required: arg.required
|
|
54
|
+
})),
|
|
55
|
+
flags: [...help.flags, ...help.globalFlags ?? []].map((flag) => ({
|
|
56
|
+
name: `--${flag.name}`,
|
|
57
|
+
description: Option.getOrUndefined(flag.description),
|
|
58
|
+
required: flag.required
|
|
59
|
+
})),
|
|
60
|
+
commands: (help.subcommands ?? []).flatMap((group) => group.commands).map((command) => ({
|
|
61
|
+
name: command.name,
|
|
62
|
+
...labelled(command.description)
|
|
63
|
+
}))
|
|
64
|
+
});
|
|
65
|
+
/** Help, as text or, with `--json`, as one document. */
|
|
66
|
+
const helpText = (help) => json ? helpJson(helpDocument(help)) : formatter.formatHelpDoc(help);
|
|
67
|
+
/** The help a parse showed with no request for it: printed only when nothing failed. */
|
|
68
|
+
let implicitHelp;
|
|
69
|
+
const printed = (text) => Effect.promise(() => written(process.stdout, `${text}\n`).catch(() => void 0));
|
|
70
|
+
/** Help asked for and the version go to stdout; help shown for a refusal waits for the run's end. */
|
|
71
|
+
const presenter = { present: Match.type().pipe(Match.tag("Help", (event) => event.reason === "Implicit" ? Effect.sync(() => {
|
|
72
|
+
implicitHelp = event.helpDoc;
|
|
73
|
+
}) : printed(helpText(event.helpDoc))), Match.tag("Version", (event) => printed(event.version)), Match.tag("InvalidInvocation", () => Effect.void), Match.exhaustive) };
|
|
74
|
+
const cliLayer = Layer.mergeAll(layer, CliConfig.layer({ builtIns: [GlobalFlag.Help, GlobalFlag.Version] }), CliOutput.layerPresenter(presenter));
|
|
75
|
+
/** A parse's refusal as the CLI's failure, naming the command's help. */
|
|
76
|
+
const usageOf = (error) => {
|
|
77
|
+
const [first] = error.errors;
|
|
78
|
+
const [, ...path] = error.commandPath;
|
|
79
|
+
return usageFailure(snakeCase(first?._tag ?? "missing_command"), first?.message ?? `${error.commandPath.join(" ")} needs a command`, {
|
|
80
|
+
says: "See its help",
|
|
81
|
+
run: [[...path, "--help"]]
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/** A cancelled run's failure: what its command's clean-up says it may have left, if anything. */
|
|
85
|
+
const cancelledFailure = () => new CliFailure({
|
|
86
|
+
class: "cancelled",
|
|
87
|
+
reason: "canceled",
|
|
88
|
+
headline: cancelled.left?.headline ?? "Canceled",
|
|
89
|
+
next: cancelled.left?.next
|
|
90
|
+
});
|
|
91
|
+
/** What ended the run, as a failure to say, or `undefined` when it finished. */
|
|
92
|
+
const failureOf = (exit) => {
|
|
93
|
+
if (Exit.isSuccess(exit)) return void 0;
|
|
94
|
+
if (Cause.hasInterruptsOnly(exit.cause)) return cancelledFailure();
|
|
95
|
+
const error = Cause.squash(exit.cause);
|
|
96
|
+
if (error instanceof CliFailure) return error;
|
|
97
|
+
if (CliError.isCliError(error) && Predicate.isTagged(error, "ShowHelp")) return error.errors.length === 0 ? "help" : usageOf(error);
|
|
98
|
+
return failure("internal_error", "Unexpected error in ref0-git. This is a bug in ref0-git", "Run it again; if it fails again, report it");
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* A failure as its words on stderr, after `ref0-git: `, or with `--json` as one line: the
|
|
102
|
+
* `cli-design` skill's error document. Every part goes through `printable`, which also takes out
|
|
103
|
+
* each secret the run holds, since a hostile host's refusal could echo one.
|
|
104
|
+
*/
|
|
105
|
+
const failureLine = (failed) => {
|
|
106
|
+
const next = failed.next === void 0 ? void 0 : {
|
|
107
|
+
says: printable(failed.next.says),
|
|
108
|
+
run: failed.next.run
|
|
109
|
+
};
|
|
110
|
+
const document = {
|
|
111
|
+
status: failed.class === "usage" ? "action_required" : "error",
|
|
112
|
+
reason: failed.reason,
|
|
113
|
+
message: printable(failed.headline),
|
|
114
|
+
nextStep: next === void 0 ? void 0 : nextDocument(next),
|
|
115
|
+
data: failed.findings === void 0 ? failed.data : { findings: failed.findings }
|
|
116
|
+
};
|
|
117
|
+
const lines = [`ref0-git: ${document.message}`, ...next === void 0 || json ? [] : nextLines(next)];
|
|
118
|
+
return json ? `${secrets.scrub(failureJson(document))}\n` : `${lines.join("\n")}\n`;
|
|
119
|
+
};
|
|
120
|
+
const fiber = Effect.runFork(Command.runWith(ref0Git, {
|
|
121
|
+
version: "0.0.0",
|
|
122
|
+
renderErrors: false
|
|
123
|
+
})(args).pipe(Effect.provide(cliLayer), Effect.provideService(CliModes, modesOf({
|
|
124
|
+
json,
|
|
125
|
+
nonInteractive: flagOn(args, "non-interactive")
|
|
126
|
+
}))));
|
|
127
|
+
process.stdout.on("error", () => void 0);
|
|
128
|
+
process.stderr.on("error", () => void 0);
|
|
129
|
+
/** The run's signals and its end, as one state machine: `run-end.ts`' `runControl`. */
|
|
130
|
+
const control = runControl({
|
|
131
|
+
stderr: (text) => written(process.stderr, text),
|
|
132
|
+
exit: (code) => process.exit(code),
|
|
133
|
+
interrupt: () => Effect.runFork(Fiber.interrupt(fiber)),
|
|
134
|
+
leftovers: () => leftovers,
|
|
135
|
+
cancelledLine: () => failureLine(cancelledFailure())
|
|
136
|
+
});
|
|
137
|
+
for (const [signal, status] of signals) process.on(signal, () => control.signal(status));
|
|
138
|
+
const ended = failureOf(await Effect.runPromise(Fiber.await(fiber)));
|
|
139
|
+
if (ended === "help" && implicitHelp !== void 0) await written(process.stdout, `${helpText(implicitHelp)}\n`).catch(() => void 0);
|
|
140
|
+
await control.ended({
|
|
141
|
+
status: ended instanceof CliFailure ? exitCodes[ended.class] : 0,
|
|
142
|
+
failureLine: ended instanceof CliFailure ? failureLine(ended) : void 0
|
|
143
|
+
});
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { hostFlag } from "./hosts.mjs";
|
|
2
|
+
import { CliModes, answer, document, field, printable } from "./output.mjs";
|
|
3
|
+
import { called, changed, listed, pageFlags, pagesOf, repoArgument } from "./resources.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Command from "effect/cli/Command";
|
|
7
|
+
import * as Flag from "effect/cli/Flag";
|
|
8
|
+
import { jobStates } from "@ref0/git/rest";
|
|
9
|
+
import { branchRef } from "@ref0/git";
|
|
10
|
+
// src/cli/repos.ts
|
|
11
|
+
/** `repos` and `work`: a host's repos, and a repo's saved work. */
|
|
12
|
+
const create = Command.make("create", {
|
|
13
|
+
repo: repoArgument,
|
|
14
|
+
host: hostFlag,
|
|
15
|
+
public: Flag.Boolean("public").pipe(Flag.withDescription("Let anyone read it"), Flag.withDefault(false)),
|
|
16
|
+
defaultBranch: Flag.String("default-branch").pipe(Flag.withDescription("Its default branch, the host's default when it's left out"), Flag.withMetavar("BRANCH"), Flag.optional)
|
|
17
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
18
|
+
const made = yield* called(flags.host, (client, signal) => {
|
|
19
|
+
const input = {
|
|
20
|
+
id: flags.repo,
|
|
21
|
+
public: flags.public,
|
|
22
|
+
signal
|
|
23
|
+
};
|
|
24
|
+
if (Option.isSome(flags.defaultBranch)) input.defaultBranch = branchRef(flags.defaultBranch.value);
|
|
25
|
+
return client.repos.create(input);
|
|
26
|
+
});
|
|
27
|
+
yield* changed(made.value, made.value.id, {
|
|
28
|
+
done: `Created repo ${printable(made.value.id)} on ${made.host}`,
|
|
29
|
+
fields: [["Clone", `${made.endpoint}/${printable(made.value.id)}.git`]],
|
|
30
|
+
next: {
|
|
31
|
+
says: "See it",
|
|
32
|
+
run: [[
|
|
33
|
+
"repos",
|
|
34
|
+
"show",
|
|
35
|
+
made.value.id,
|
|
36
|
+
"--host",
|
|
37
|
+
made.host
|
|
38
|
+
]]
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
})).pipe(Command.withDescription("Create a repo"));
|
|
42
|
+
const list = Command.make("list", {
|
|
43
|
+
host: hostFlag,
|
|
44
|
+
prefix: Flag.String("prefix").pipe(Flag.withDescription("Only repos whose names start with it, as acme/"), Flag.withMetavar("PREFIX"), Flag.optional),
|
|
45
|
+
...pageFlags
|
|
46
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
47
|
+
const prefix = Option.getOrUndefined(flags.prefix);
|
|
48
|
+
const command = (host) => [...[
|
|
49
|
+
"repos",
|
|
50
|
+
"list",
|
|
51
|
+
"--host",
|
|
52
|
+
host
|
|
53
|
+
], ...prefix === void 0 ? [] : ["--prefix", prefix]];
|
|
54
|
+
const read = yield* pagesOf(flags.host, flags, command, printable, (client, page, signal) => {
|
|
55
|
+
const input = {
|
|
56
|
+
page,
|
|
57
|
+
signal
|
|
58
|
+
};
|
|
59
|
+
if (prefix !== void 0) input.prefix = prefix;
|
|
60
|
+
return client.repos.list(input);
|
|
61
|
+
});
|
|
62
|
+
yield* listed(read, {
|
|
63
|
+
line: printable,
|
|
64
|
+
none: `No repos on ${read.host}`,
|
|
65
|
+
command,
|
|
66
|
+
choice: flags
|
|
67
|
+
});
|
|
68
|
+
})).pipe(Command.withDescription("List the repos you can read"));
|
|
69
|
+
const show = Command.make("show", {
|
|
70
|
+
repo: repoArgument,
|
|
71
|
+
host: hostFlag
|
|
72
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
73
|
+
const shown = yield* called(flags.host, (client, signal) => client.repos.get(flags.repo, { signal }));
|
|
74
|
+
const info = shown.value;
|
|
75
|
+
if ((yield* CliModes).json) return yield* document(info);
|
|
76
|
+
const rows = [
|
|
77
|
+
["Repo", printable(info.id)],
|
|
78
|
+
...info.defaultBranch === void 0 ? [] : [["Default branch", printable(info.defaultBranch)]],
|
|
79
|
+
["Visibility", info.public ? "Public" : "Private"],
|
|
80
|
+
...info.upstream === void 0 ? [] : [["Fork of", printable(info.upstream)]],
|
|
81
|
+
["Refs", String(info.stats.refs)],
|
|
82
|
+
["Clone", `${shown.endpoint}/${printable(info.id)}.git`]
|
|
83
|
+
];
|
|
84
|
+
yield* answer(rows.map((row) => field(row).trimStart()).join("\n"));
|
|
85
|
+
})).pipe(Command.withDescription("Show a repo's details"));
|
|
86
|
+
const remove = Command.make("delete", {
|
|
87
|
+
repo: repoArgument,
|
|
88
|
+
host: hostFlag
|
|
89
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
90
|
+
const done = yield* called(flags.host, (client, signal) => client.repos.delete(flags.repo, { signal }));
|
|
91
|
+
yield* changed(done.value, flags.repo, { done: `Deleted repo ${printable(flags.repo)} on ${done.host}` });
|
|
92
|
+
})).pipe(Command.withDescription("Delete a repo, its refs and its objects"));
|
|
93
|
+
const jobState = Flag.Literals("state", jobStates).pipe(Flag.withDescription("Only work in this state"), Flag.optional);
|
|
94
|
+
const jobLine = (item) => [
|
|
95
|
+
item.state,
|
|
96
|
+
item.name,
|
|
97
|
+
item.key,
|
|
98
|
+
String(item.attempt),
|
|
99
|
+
item.error ?? ""
|
|
100
|
+
].map(printable).join(" ").trimEnd();
|
|
101
|
+
const workList = Command.make("list", {
|
|
102
|
+
repo: repoArgument,
|
|
103
|
+
host: hostFlag,
|
|
104
|
+
state: jobState,
|
|
105
|
+
...pageFlags
|
|
106
|
+
}, Effect.fnUntraced(function* (flags) {
|
|
107
|
+
const state = Option.getOrUndefined(flags.state);
|
|
108
|
+
const command = (host) => [...[
|
|
109
|
+
"work",
|
|
110
|
+
"list",
|
|
111
|
+
flags.repo,
|
|
112
|
+
"--host",
|
|
113
|
+
host
|
|
114
|
+
], ...state === void 0 ? [] : ["--state", state]];
|
|
115
|
+
const read = yield* pagesOf(flags.host, flags, command, jobLine, (client, page, signal) => {
|
|
116
|
+
const input = {
|
|
117
|
+
page,
|
|
118
|
+
signal
|
|
119
|
+
};
|
|
120
|
+
if (state !== void 0) input.state = state;
|
|
121
|
+
return client.work.list(flags.repo, input);
|
|
122
|
+
});
|
|
123
|
+
yield* listed(read, {
|
|
124
|
+
line: jobLine,
|
|
125
|
+
none: `No saved work in ${printable(flags.repo)}`,
|
|
126
|
+
command,
|
|
127
|
+
choice: flags
|
|
128
|
+
});
|
|
129
|
+
})).pipe(Command.withDescription("List a repo's saved work"));
|
|
130
|
+
const jobFlags = {
|
|
131
|
+
repo: repoArgument,
|
|
132
|
+
host: hostFlag,
|
|
133
|
+
name: Flag.String("name").pipe(Flag.withDescription("The job's name, as work list prints it"), Flag.withMetavar("JOB")),
|
|
134
|
+
key: Flag.String("key").pipe(Flag.withDescription("The job's key, as work list prints it"), Flag.withMetavar("KEY"))
|
|
135
|
+
};
|
|
136
|
+
/** `work retry` or `work discard`: one job, named by its name and key. */
|
|
137
|
+
const workWrite = (verb, description) => Command.make(verb, jobFlags, Effect.fnUntraced(function* (flags) {
|
|
138
|
+
const job = {
|
|
139
|
+
name: flags.name,
|
|
140
|
+
key: flags.key
|
|
141
|
+
};
|
|
142
|
+
const done = yield* called(flags.host, (client, signal) => client.work[verb](flags.repo, {
|
|
143
|
+
...job,
|
|
144
|
+
signal
|
|
145
|
+
}));
|
|
146
|
+
yield* changed({
|
|
147
|
+
repo: flags.repo,
|
|
148
|
+
...job
|
|
149
|
+
}, flags.key, { done: `${verb === "retry" ? "Retried" : "Discarded"} ${printable(flags.name)} ${printable(flags.key)} in ${printable(flags.repo)} on ${done.host}` });
|
|
150
|
+
})).pipe(Command.withDescription(description));
|
|
151
|
+
const reposCommand = Command.make("repos").pipe(Command.withDescription("The host's repos (experimental)"), Command.withSubcommands([
|
|
152
|
+
create,
|
|
153
|
+
list,
|
|
154
|
+
show,
|
|
155
|
+
remove
|
|
156
|
+
]));
|
|
157
|
+
const workCommand = Command.make("work").pipe(Command.withDescription("A repo's saved work: jobs kept across tries (experimental)"), Command.withSubcommands([
|
|
158
|
+
workList,
|
|
159
|
+
workWrite("retry", "Run a failed job again"),
|
|
160
|
+
workWrite("discard", "Drop a failed job")
|
|
161
|
+
]));
|
|
162
|
+
export { reposCommand, workCommand };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { DurationInput } from "./documents.mjs";
|
|
2
|
+
import { CliFailure, answered, failure, usageFailure } from "./failure.mjs";
|
|
3
|
+
import { chosenHost, remoteOf } from "./hosts.mjs";
|
|
4
|
+
import { CliModes, answer, document, nextLines, printable, receipt, say } from "./output.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Flag from "effect/cli/Flag";
|
|
9
|
+
import * as Argument from "effect/cli/Argument";
|
|
10
|
+
// src/cli/resources.ts
|
|
11
|
+
/**
|
|
12
|
+
* What the host's groups share: `repos`, `tokens`, `queue`, `work` and `events` each call one
|
|
13
|
+
* host's REST client, page their lists the same way and print a change the same way.
|
|
14
|
+
*/
|
|
15
|
+
const repoArgument = Argument.String("REPO").pipe(Argument.withDescription("The repo, as acme/app"));
|
|
16
|
+
const pageFlags = {
|
|
17
|
+
limit: Flag.Int("limit").pipe(Flag.withDescription("How many to list in all, read over as many pages as it takes"), Flag.withMetavar("NUMBER"), Flag.optional),
|
|
18
|
+
next: Flag.String("next").pipe(Flag.withDescription("The page after the one a list ended, by the cursor it named"), Flag.withMetavar("CURSOR"), Flag.optional)
|
|
19
|
+
};
|
|
20
|
+
/** The host's client, for `--host` or the one the checkout or the one sign-in names. */
|
|
21
|
+
const remoteFor = (host) => Effect.flatMap(chosenHost(host), remoteOf);
|
|
22
|
+
/** The host's answer to `call`, made with its client: its refusal as the CLI's failure. */
|
|
23
|
+
const called = Effect.fnUntraced(function* (host, call) {
|
|
24
|
+
const remote = yield* remoteFor(host);
|
|
25
|
+
const value = yield* answered(remote.host, (signal) => call(remote.client, signal));
|
|
26
|
+
return {
|
|
27
|
+
...remote,
|
|
28
|
+
value
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* `--limit` items, the total wanted, read page after page from `--next`, each page asking for only
|
|
33
|
+
* the rows still wanted; without `--limit`, one page. A later page's failure keeps its class and
|
|
34
|
+
* reason, and carries the rows read and the cursor to resume at: as `--json`'s data, else printed
|
|
35
|
+
* on stdout by `line` first, so its resume step loses none. A repeated cursor, the host's bug,
|
|
36
|
+
* carries the rows read the same way, with no step, since resuming would only repeat it.
|
|
37
|
+
*/
|
|
38
|
+
const pagesOf = Effect.fnUntraced(function* (from, choice, command, line, call) {
|
|
39
|
+
const remote = Option.isOption(from) ? yield* remoteFor(from) : from;
|
|
40
|
+
const wanted = Option.getOrUndefined(choice.limit);
|
|
41
|
+
const items = [];
|
|
42
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43
|
+
let after = Option.getOrUndefined(choice.next);
|
|
44
|
+
const withRows = Effect.fnUntraced(function* (failed, holding) {
|
|
45
|
+
if (items.length === 0) return yield* failed;
|
|
46
|
+
if (!(yield* CliModes).json) yield* answer(items.map(line).join("\n"));
|
|
47
|
+
return yield* holding(items);
|
|
48
|
+
});
|
|
49
|
+
for (;;) {
|
|
50
|
+
if (after !== void 0 && seen.has(after)) {
|
|
51
|
+
const headline = `${remote.host} named page ${printable(after)} twice`;
|
|
52
|
+
return yield* withRows(failure("repeated_cursor", headline), (rows) => new CliFailure({
|
|
53
|
+
class: "failed",
|
|
54
|
+
reason: "repeated_cursor",
|
|
55
|
+
headline: `${headline}. Read ${rows.length} rows before it`,
|
|
56
|
+
next: void 0,
|
|
57
|
+
data: listingOf([...rows], void 0)
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
if (after !== void 0) seen.add(after);
|
|
61
|
+
const page = {};
|
|
62
|
+
if (wanted !== void 0) page.limit = wanted - items.length;
|
|
63
|
+
if (after !== void 0) page.after = after;
|
|
64
|
+
const resumeAt = after;
|
|
65
|
+
const listing = yield* answered(remote.host, (signal) => call(remote.client, page, signal)).pipe(Effect.catch((failed) => withRows(failed, (rows) => resumable(failed, rows, resumeAt, command(remote.host), wanted))));
|
|
66
|
+
items.push(...listing.items);
|
|
67
|
+
after = listing.next;
|
|
68
|
+
if (wanted === void 0 || after === void 0 || items.length >= wanted) return {
|
|
69
|
+
...remote,
|
|
70
|
+
value: listingOf(items, after)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
/** A listing of `items`, naming `next` when there's more. */
|
|
75
|
+
const listingOf = (items, next) => {
|
|
76
|
+
const listing = { items };
|
|
77
|
+
if (next !== void 0) listing.next = next;
|
|
78
|
+
return listing;
|
|
79
|
+
};
|
|
80
|
+
/** `argv` with `--limit` and `--next` added, for the page after `next`. */
|
|
81
|
+
const pageCommand = (argv, wanted, next) => [
|
|
82
|
+
...argv,
|
|
83
|
+
...wanted === void 0 ? [] : ["--limit", String(wanted)],
|
|
84
|
+
...next === void 0 ? [] : ["--next", next]
|
|
85
|
+
];
|
|
86
|
+
/** A later page's failure, holding the rows read before it and where to resume. */
|
|
87
|
+
const resumable = (failed, items, after, argv, wanted) => new CliFailure({
|
|
88
|
+
class: failed.class,
|
|
89
|
+
reason: failed.reason,
|
|
90
|
+
headline: `${failed.headline}. Read ${items.length} rows before the page failed`,
|
|
91
|
+
next: {
|
|
92
|
+
says: "Resume after the rows already read",
|
|
93
|
+
run: [pageCommand(argv, wanted === void 0 ? void 0 : wanted - items.length, after)]
|
|
94
|
+
},
|
|
95
|
+
data: listingOf([...items], after)
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* A list's rows: `--json`'s one document, else a line a row on stdout, an empty list said on
|
|
99
|
+
* stderr, and one with more after it naming the command for the next page, with its `--limit`.
|
|
100
|
+
*/
|
|
101
|
+
const listed = Effect.fnUntraced(function* (read, options) {
|
|
102
|
+
const listing = read.value;
|
|
103
|
+
if ((yield* CliModes).json) return yield* document(listing);
|
|
104
|
+
if (listing.items.length === 0) yield* say(options.none);
|
|
105
|
+
else yield* answer(listing.items.map(options.line).join("\n"));
|
|
106
|
+
if (listing.next !== void 0) {
|
|
107
|
+
const argv = options.command(read.host);
|
|
108
|
+
const lines = nextLines({
|
|
109
|
+
says: "Next page",
|
|
110
|
+
run: [pageCommand(argv, Option.getOrUndefined(options.choice.limit), listing.next)]
|
|
111
|
+
});
|
|
112
|
+
yield* say(...lines.slice(1));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* A change's outcome: `--json`'s document, else its receipt on stderr, and its bare ID on stdout
|
|
117
|
+
* when stdout isn't a terminal or the run doesn't prompt, for a script to read.
|
|
118
|
+
*/
|
|
119
|
+
const changed = Effect.fnUntraced(function* (value, id, shown) {
|
|
120
|
+
const modes = yield* CliModes;
|
|
121
|
+
if (modes.json) return yield* document(value);
|
|
122
|
+
yield* receipt(shown);
|
|
123
|
+
if (!modes.stdoutTerminal || !modes.interactive) yield* answer(printable(id));
|
|
124
|
+
});
|
|
125
|
+
const decodeDuration = Schema.decodeUnknownOption(DurationInput);
|
|
126
|
+
/** A duration flag's value, as `30s`, `30m`, `12h` or `30d`, in milliseconds. */
|
|
127
|
+
const durationOf = (flag, text) => Option.match(decodeDuration(text), {
|
|
128
|
+
onNone: () => Effect.fail(usageFailure("invalid_duration", `--${flag} takes a number and a unit, as 30m, 12h or 30d: not '${printable(text)}'`)),
|
|
129
|
+
onSome: Effect.succeed
|
|
130
|
+
});
|
|
131
|
+
export { called, changed, durationOf, listed, pageFlags, pagesOf, remoteFor, repoArgument };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { leftoverLines } from "./output.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
// src/cli/run-end.ts
|
|
4
|
+
/**
|
|
5
|
+
* How long a run's end waits for stderr to take its last lines before it exits anyway: 2 s. A
|
|
6
|
+
* pipe nobody reads can leave a write waiting for ever where pipes are asynchronous, as on macOS.
|
|
7
|
+
* On Linux, Node writes to a pipe synchronously, so a full one blocks in the kernel, past any bound.
|
|
8
|
+
*/
|
|
9
|
+
const flushMs = 2e3;
|
|
10
|
+
/** `text` written to `end`'s stderr, waited for at most `flushMs`, a failed write ignored. */
|
|
11
|
+
const flushed = (end, text) => Effect.runPromise(Effect.promise(() => end.stderr(text).catch(() => void 0)).pipe(Effect.timeoutOption(flushMs)));
|
|
12
|
+
/**
|
|
13
|
+
* Every signal and exit decision of a run, as one state machine, as the `cli-design` skill's
|
|
14
|
+
* interaction reference has it:
|
|
15
|
+
* - **running:** a first signal, of status `n` (130 for Ctrl-C, else 128 + n), moves it to
|
|
16
|
+
* stopping(n), which interrupts the fiber, whose cleanup runs; the fiber ending moves it to ended,
|
|
17
|
+
* exiting with its outcome's status.
|
|
18
|
+
* - **stopping(n):** a second signal, of any kind, exits at once with n's status, writing what the
|
|
19
|
+
* run has left so far and a cancelled line without waiting; the fiber ending, its cleanup run,
|
|
20
|
+
* exits with n's status too.
|
|
21
|
+
* - **ended:** nothing changes it.
|
|
22
|
+
*
|
|
23
|
+
* An end that's decided by the fiber writes what the run left, then its failure's line, in one
|
|
24
|
+
* write, waited for at most `flushMs`, then exits: no stderr write changes the status. Internal:
|
|
25
|
+
* `ref0-git.ts` is its one user, and `commands.test.ts` drives it with its own `end`.
|
|
26
|
+
*/
|
|
27
|
+
const runControl = (end) => {
|
|
28
|
+
let phase = { kind: "running" };
|
|
29
|
+
const textOf = (failureLine) => `${leftoverLines(end.leftovers())}${failureLine ?? ""}`;
|
|
30
|
+
const signal = (status) => {
|
|
31
|
+
if (phase.kind === "running") {
|
|
32
|
+
phase = {
|
|
33
|
+
kind: "stopping",
|
|
34
|
+
status
|
|
35
|
+
};
|
|
36
|
+
end.interrupt();
|
|
37
|
+
} else if (phase.kind === "stopping") {
|
|
38
|
+
const first = phase.status;
|
|
39
|
+
phase = { kind: "ended" };
|
|
40
|
+
end.stderr(textOf(end.cancelledLine())).catch(() => void 0);
|
|
41
|
+
end.exit(first);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const ended = async (outcome) => {
|
|
45
|
+
if (phase.kind === "ended") return;
|
|
46
|
+
const status = phase.kind === "stopping" ? phase.status : outcome.status;
|
|
47
|
+
phase = { kind: "ended" };
|
|
48
|
+
const text = textOf(outcome.failureLine);
|
|
49
|
+
if (text !== "") await flushed(end, text);
|
|
50
|
+
end.exit(status);
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
signal,
|
|
54
|
+
ended
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export { flushMs, runControl };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { layer as layer$1 } from "./folders.mjs";
|
|
2
|
+
import { node, written } from "./node.mjs";
|
|
3
|
+
import { layer as layer$2 } from "./sqlite.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import * as Stdio from "effect/Stdio";
|
|
7
|
+
import * as NodeChildProcessSpawner from "@effect/platform-node-shared/NodeChildProcessSpawner";
|
|
8
|
+
import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
|
|
9
|
+
import * as NodePath from "@effect/platform-node-shared/NodePath";
|
|
10
|
+
import * as NodeTerminal from "@effect/platform-node-shared/NodeTerminal";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import * as PlatformError from "effect/PlatformError";
|
|
13
|
+
import * as Sink from "effect/Sink";
|
|
14
|
+
import * as Terminal from "effect/Terminal";
|
|
15
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
16
|
+
// src/cli/runtime.ts
|
|
17
|
+
/** The run's stdio, at the process's own streams: the edge `output.ts` writes through too. */
|
|
18
|
+
const { process } = node;
|
|
19
|
+
const writing = (stream, module, method) => (text) => Effect.tryPromise({
|
|
20
|
+
try: () => written(stream, text),
|
|
21
|
+
catch: (cause) => PlatformError.badArgument({
|
|
22
|
+
module,
|
|
23
|
+
method,
|
|
24
|
+
cause
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
const stdio = Stdio.make({
|
|
28
|
+
args: Effect.sync(() => process.argv.slice(2)),
|
|
29
|
+
stdinIsTerminal: Effect.sync(() => process.stdin.isTTY === true),
|
|
30
|
+
stdoutIsTerminal: Effect.sync(() => process.stdout.isTTY === true),
|
|
31
|
+
stderrIsTerminal: Effect.sync(() => process.stderr.isTTY === true),
|
|
32
|
+
stdout: () => Sink.forEach(writing(process.stdout, "Stdio", "stdout")),
|
|
33
|
+
stderr: () => Sink.forEach(writing(process.stderr, "Stdio", "stderr")),
|
|
34
|
+
stdin: Stream.fromAsyncIterable(process.stdin, (cause) => PlatformError.badArgument({
|
|
35
|
+
module: "Stdio",
|
|
36
|
+
method: "stdin",
|
|
37
|
+
cause
|
|
38
|
+
}))
|
|
39
|
+
});
|
|
40
|
+
/** Only Ctrl-C ends a prompt's keys, which cancels the run, as Esc and Ctrl-D never did. */
|
|
41
|
+
const quits = (input) => input.key.ctrl && input.key.name === "c";
|
|
42
|
+
/** The processes, files and paths a command reaches, over Node's own. */
|
|
43
|
+
const platform = NodeChildProcessSpawner.layer.pipe(Layer.provideMerge(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer)));
|
|
44
|
+
/**
|
|
45
|
+
* What `effect/cli` and the commands ask of the platform, in Node: the run's stdio, a terminal
|
|
46
|
+
* whose keys a prompt reads, child processes, files, paths, HTTP over `fetch`, the folders `init`
|
|
47
|
+
* and `doctor` read, and SQLite.
|
|
48
|
+
*/
|
|
49
|
+
const layer = Layer.mergeAll(Layer.succeed(Stdio.Stdio, stdio), Layer.effect(Terminal.Terminal, NodeTerminal.make(quits)), platform, FetchHttpClient.layer, layer$1, layer$2);
|
|
50
|
+
export { layer, quits };
|