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,538 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CreatedToken,
|
|
3
|
+
GitAdapter,
|
|
4
|
+
GitError,
|
|
5
|
+
Oid,
|
|
6
|
+
RefName,
|
|
7
|
+
RepoId,
|
|
8
|
+
Result,
|
|
9
|
+
Signature,
|
|
10
|
+
} from '@ref0/git';
|
|
11
|
+
import { createRestClient } from '@ref0/git/rest';
|
|
12
|
+
import type { RestClient } from '@ref0/git/rest';
|
|
13
|
+
import * as Schema from 'effect/Schema';
|
|
14
|
+
|
|
15
|
+
import { org, pip, repos } from './acme.ts';
|
|
16
|
+
import type { Person, SeedCommit, SeedIssue, SeedPull, SeedRepo } from './acme.ts';
|
|
17
|
+
|
|
18
|
+
/** What the seed writes through: the host's own handler and its store, and the admin secret. */
|
|
19
|
+
export interface SeedHost {
|
|
20
|
+
/** The host's handler, which every write goes through, as a request from outside would. */
|
|
21
|
+
readonly fetch: (request: Request) => Promise<Response>;
|
|
22
|
+
/** Where the host is served, which the seed's requests name. */
|
|
23
|
+
readonly origin: string;
|
|
24
|
+
/** Signs in as the admin, who makes the org's repos and each person's token. */
|
|
25
|
+
readonly adminToken: string;
|
|
26
|
+
/** The adapter's store, which keeps the seed's progress beside Git's own records. */
|
|
27
|
+
readonly store: Store;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What a call to `seed` did: made what was missing, or left a host that needs none. */
|
|
31
|
+
export type SeedOutcome = 'seeded' | 'skipped';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `running` from the seed's first write, `done` once it made everything; `since` dates its commits.
|
|
35
|
+
* `tokensExpire` is when the tokens each start of a running seed makes expire, saved before it
|
|
36
|
+
* makes them, which tells them apart from the host's own if their answers are lost. Each is kept
|
|
37
|
+
* until it passes, as a start's create can still land after a later start has swept.
|
|
38
|
+
*/
|
|
39
|
+
const Progress = Schema.Struct({
|
|
40
|
+
state: Schema.Literals(['running', 'done']),
|
|
41
|
+
since: Schema.Number,
|
|
42
|
+
tokensExpire: Schema.optionalKey(Schema.Array(Schema.Number)),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
type Progress = typeof Progress.Type;
|
|
46
|
+
|
|
47
|
+
const decodeProgress = Schema.decodeUnknownSync(Progress);
|
|
48
|
+
|
|
49
|
+
type Store = GitAdapter['store'];
|
|
50
|
+
|
|
51
|
+
/** The `app/seed` record, in a scope of the app's own, apart from Git's `git/` scopes. */
|
|
52
|
+
const progressScope = 'app';
|
|
53
|
+
|
|
54
|
+
const progressKey = { collection: 'seed', id: org.login } as const;
|
|
55
|
+
|
|
56
|
+
const day = 24 * 60 * 60 * 1000;
|
|
57
|
+
|
|
58
|
+
/** How long a person's seed token lasts: the seed revokes it when it ends, and a cut one expires. */
|
|
59
|
+
const tokenLife = 60 * 60 * 1000;
|
|
60
|
+
|
|
61
|
+
const value = <A>(result: Result<A>, doing: string): A => {
|
|
62
|
+
if (result.kind === 'success') return result.value;
|
|
63
|
+
|
|
64
|
+
throw new Error(`The seed couldn't ${doing}: ${result.error.code}, ${result.error.message}`);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const missing = (error: GitError) => error.code === 'NOT_FOUND';
|
|
68
|
+
|
|
69
|
+
const readProgress = async (store: Store) => {
|
|
70
|
+
const snapshot = await store.read(progressScope, [progressKey]);
|
|
71
|
+
const row = snapshot.results[0]?.[0];
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
version: snapshot.version,
|
|
75
|
+
progress: row === undefined ? undefined : decodeProgress(row.value),
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Saves `progress` if nothing moved the record since `version`; whether it did. */
|
|
80
|
+
const saveProgress = async (store: Store, version: number, progress: Progress) => {
|
|
81
|
+
const committed = await store.commit(progressScope, {
|
|
82
|
+
id: `seed-${progress.state}-${progress.since}-${progress.tokensExpire?.at(-1) ?? 0}`,
|
|
83
|
+
expect: version,
|
|
84
|
+
put: [{ ...progressKey, value: progress }],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return committed.ok;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The progress to go on from: a cut seed's, or a new one when the host holds no repos. A host
|
|
92
|
+
* whose seed is done, or that has repos of its own, gets none.
|
|
93
|
+
*/
|
|
94
|
+
const begin = async (store: Store, admin: RestClient): Promise<Progress | undefined> => {
|
|
95
|
+
const { version, progress } = await readProgress(store);
|
|
96
|
+
if (progress !== undefined) return progress.state === 'running' ? progress : undefined;
|
|
97
|
+
|
|
98
|
+
const listed = value(await admin.repos.list({ page: { limit: 1 } }), 'list the repos');
|
|
99
|
+
if (listed.items.length > 0) return undefined;
|
|
100
|
+
|
|
101
|
+
const started: Progress = { state: 'running', since: Date.now() };
|
|
102
|
+
if (await saveProgress(store, version, started)) return started;
|
|
103
|
+
|
|
104
|
+
// Another start wrote it first: go on from its progress.
|
|
105
|
+
return (await readProgress(store)).progress;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const signature = (person: Person, since: number, daysAgo: number): Signature => ({
|
|
109
|
+
name: person.name,
|
|
110
|
+
email: person.email,
|
|
111
|
+
at: since - daysAgo * day,
|
|
112
|
+
offset: 0,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** A drop-in call's JSON body: the fields GitHub's REST takes for each of the seed's writes. */
|
|
116
|
+
type Body = Readonly<Record<string, string | number | readonly string[]>>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* One drop-in call as `person`, and its answer's status and text: a lookup's 404 is an answer,
|
|
120
|
+
* anything else past 299 stops the seed.
|
|
121
|
+
*/
|
|
122
|
+
type Call = (
|
|
123
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH',
|
|
124
|
+
path: string,
|
|
125
|
+
body?: Body,
|
|
126
|
+
) => Promise<{ readonly status: number; readonly text: string }>;
|
|
127
|
+
|
|
128
|
+
const dropInCall =
|
|
129
|
+
(host: SeedHost, token: string): Call =>
|
|
130
|
+
async (method, path, body) => {
|
|
131
|
+
const headers = new Headers({
|
|
132
|
+
accept: 'application/vnd.github+json',
|
|
133
|
+
authorization: `Bearer ${token}`,
|
|
134
|
+
});
|
|
135
|
+
const init: RequestInit = { method, headers };
|
|
136
|
+
|
|
137
|
+
if (body !== undefined) {
|
|
138
|
+
headers.set('content-type', 'application/json');
|
|
139
|
+
init.body = JSON.stringify(body);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const response = await host.fetch(new Request(new URL(`/api/v3${path}`, host.origin), init));
|
|
143
|
+
const text = await response.text();
|
|
144
|
+
|
|
145
|
+
if (response.status >= 300 && !(method === 'GET' && response.status === 404)) {
|
|
146
|
+
throw new Error(`The seed's ${method} ${path} answered ${response.status}: ${text}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { status: response.status, text };
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** What the seed reads back from the drop-in, to find what it made before. */
|
|
153
|
+
const Numbered = Schema.Struct({ number: Schema.Number });
|
|
154
|
+
|
|
155
|
+
const Issues = Schema.Array(
|
|
156
|
+
Schema.Struct({
|
|
157
|
+
number: Schema.Number,
|
|
158
|
+
title: Schema.String,
|
|
159
|
+
state: Schema.String,
|
|
160
|
+
pull_request: Schema.optional(Schema.Unknown),
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const Authored = Schema.Array(
|
|
165
|
+
Schema.Struct({
|
|
166
|
+
user: Schema.NullOr(Schema.Struct({ login: Schema.String })),
|
|
167
|
+
body: Schema.optional(Schema.NullOr(Schema.String)),
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const decodePulls = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Array(Numbered)));
|
|
172
|
+
|
|
173
|
+
const decodeIssues = Schema.decodeUnknownSync(Schema.fromJsonString(Issues));
|
|
174
|
+
|
|
175
|
+
const decodeAuthored = Schema.decodeUnknownSync(Schema.fromJsonString(Authored));
|
|
176
|
+
|
|
177
|
+
const decodeNumbered = Schema.decodeUnknownSync(Schema.fromJsonString(Numbered));
|
|
178
|
+
|
|
179
|
+
/** A repo's milestones, by their titles. */
|
|
180
|
+
const decodeTitled = Schema.decodeUnknownSync(
|
|
181
|
+
Schema.fromJsonString(
|
|
182
|
+
Schema.Array(Schema.Struct({ number: Schema.Number, title: Schema.String })),
|
|
183
|
+
),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
/** The milestone an issue or a pull request is on. */
|
|
187
|
+
const decodeMilestoned = Schema.decodeUnknownSync(
|
|
188
|
+
Schema.fromJsonString(
|
|
189
|
+
Schema.Struct({ milestone: Schema.NullOr(Schema.Struct({ number: Schema.Number })) }),
|
|
190
|
+
),
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const decodeMerged = Schema.decodeUnknownSync(
|
|
194
|
+
Schema.fromJsonString(Schema.Struct({ merged: Schema.Boolean })),
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Who the seed acts as: the admin's Git calls and drop-in calls, and each person's Git calls and
|
|
199
|
+
* drop-in calls.
|
|
200
|
+
*/
|
|
201
|
+
interface Cast {
|
|
202
|
+
readonly admin: RestClient;
|
|
203
|
+
readonly adminCall: Call;
|
|
204
|
+
readonly git: (person: Person) => RestClient;
|
|
205
|
+
readonly call: (person: Person) => Call;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const makeRepo = async (admin: RestClient, id: RepoId) => {
|
|
209
|
+
const found = await admin.repos.get(id, {});
|
|
210
|
+
if (found.kind === 'success') return;
|
|
211
|
+
|
|
212
|
+
if (!missing(found.error)) value(found, `read ${id}`);
|
|
213
|
+
|
|
214
|
+
value(await admin.repos.create({ id, public: true }), `make ${id}`);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** Each commit in turn on `parent`, as `git commit` makes them; their IDs, oldest first. */
|
|
218
|
+
const commitAll = async (
|
|
219
|
+
git: RestClient,
|
|
220
|
+
id: RepoId,
|
|
221
|
+
parent: Oid | undefined,
|
|
222
|
+
commits: readonly SeedCommit[],
|
|
223
|
+
since: number,
|
|
224
|
+
) => {
|
|
225
|
+
const made: Oid[] = [];
|
|
226
|
+
let tip = parent;
|
|
227
|
+
|
|
228
|
+
for (const commit of commits) {
|
|
229
|
+
const created = await git.commits.create(id, {
|
|
230
|
+
parents: tip === undefined ? [] : [tip],
|
|
231
|
+
changes: Object.entries(commit.files).map(([path, content]) => ({ path, content })),
|
|
232
|
+
message: `${commit.message}\n`,
|
|
233
|
+
author: signature(commit.by, since, commit.daysAgo),
|
|
234
|
+
});
|
|
235
|
+
tip = value(created, `commit "${commit.message}" to ${id}`).oid;
|
|
236
|
+
made.push(tip);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return made;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The repo's history, pushed as Pip: its commits, each dated from `since`, so a seed started again
|
|
244
|
+
* makes the same objects, then each branch and the tag that isn't there yet, at once.
|
|
245
|
+
*/
|
|
246
|
+
const pushHistory = async (git: RestClient, id: RepoId, repo: SeedRepo, since: number) => {
|
|
247
|
+
const main = await commitAll(git, id, undefined, repo.main, since);
|
|
248
|
+
const refs: { readonly ref: RefName; readonly to: Oid }[] = [];
|
|
249
|
+
refs.push({ ref: 'refs/heads/main', to: main.at(-1) ?? '' });
|
|
250
|
+
|
|
251
|
+
for (const branch of repo.branches) {
|
|
252
|
+
const made = await commitAll(git, id, main[branch.from], branch.commits, since);
|
|
253
|
+
refs.push({ ref: `refs/heads/${branch.name}`, to: made.at(-1) ?? '' });
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const { release } = repo;
|
|
257
|
+
|
|
258
|
+
if (release !== undefined) {
|
|
259
|
+
const tagged = repo.main[release.at];
|
|
260
|
+
const tag = await git.tags.create(id, {
|
|
261
|
+
object: main[release.at] ?? '',
|
|
262
|
+
tag: release.tag,
|
|
263
|
+
tagger: signature(pip, since, (tagged?.daysAgo ?? 0) - 1),
|
|
264
|
+
message: `${release.title}\n`,
|
|
265
|
+
});
|
|
266
|
+
refs.push({ ref: `refs/tags/${release.tag}`, to: value(tag, `tag ${release.tag}`).oid });
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const absent = [];
|
|
270
|
+
|
|
271
|
+
for (const { ref, to } of refs) {
|
|
272
|
+
const found = await git.refs.get(id, { ref });
|
|
273
|
+
if (found.kind === 'success') continue;
|
|
274
|
+
|
|
275
|
+
if (!missing(found.error)) value(found, `read ${ref}`);
|
|
276
|
+
absent.push({ ref, from: null, to });
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (absent.length === 0) return;
|
|
280
|
+
|
|
281
|
+
const updated = value(await git.refs.update(id, { updates: absent, atomic: true }), 'push');
|
|
282
|
+
const refused = updated.updates.find((update) => update.kind === 'rejected');
|
|
283
|
+
if (refused !== undefined) throw new Error(`The seed's push of ${refused.ref} was refused`);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/** Each label that isn't there yet, made by Pip. */
|
|
287
|
+
const makeLabels = async (call: Call, path: string, repo: SeedRepo) => {
|
|
288
|
+
for (const label of repo.labels) {
|
|
289
|
+
const found = await call('GET', `${path}/labels/${encodeURIComponent(label.name)}`);
|
|
290
|
+
if (found.status === 404) await call('POST', `${path}/labels`, { ...label });
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/** Each of the repo's milestones' numbers, by its title: made where it isn't there yet. */
|
|
295
|
+
const makeMilestones = async (call: Call, path: string, repo: SeedRepo) => {
|
|
296
|
+
const listed = decodeTitled(
|
|
297
|
+
(await call('GET', `${path}/milestones?state=all&per_page=100`)).text,
|
|
298
|
+
);
|
|
299
|
+
const numbers = new Map<string, number>();
|
|
300
|
+
|
|
301
|
+
for (const title of repo.milestones ?? []) {
|
|
302
|
+
const number =
|
|
303
|
+
listed.find((milestone) => milestone.title === title)?.number ??
|
|
304
|
+
decodeNumbered((await call('POST', `${path}/milestones`, { title })).text).number;
|
|
305
|
+
numbers.set(title, number);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return numbers;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/** Puts the issue or pull request `number` on `milestone`, unless it's on it already. */
|
|
312
|
+
const placeOn = async (call: Call, path: string, number: number, milestone?: number) => {
|
|
313
|
+
if (milestone === undefined) return;
|
|
314
|
+
|
|
315
|
+
const issue = decodeMilestoned((await call('GET', `${path}/issues/${number}`)).text);
|
|
316
|
+
|
|
317
|
+
if (issue.milestone?.number !== milestone) {
|
|
318
|
+
await call('PATCH', `${path}/issues/${number}`, { milestone });
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/** Whether `person` already wrote `body` among a pull request's reviews or an issue's comments. */
|
|
323
|
+
const wrote = (listed: string, person: Person, body?: string) =>
|
|
324
|
+
decodeAuthored(listed).some(
|
|
325
|
+
(item) => item.user?.login === person.login && (body === undefined || item.body === body),
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
/** The pull request from its branch, opened by its author if it isn't open yet, then reviewed. */
|
|
329
|
+
const openPull = async (
|
|
330
|
+
cast: Cast,
|
|
331
|
+
path: string,
|
|
332
|
+
pull: SeedPull,
|
|
333
|
+
milestones: ReadonlyMap<string, number>,
|
|
334
|
+
) => {
|
|
335
|
+
const author = cast.call(pull.by);
|
|
336
|
+
const query = `state=all&head=${org.login}:${encodeURIComponent(pull.branch)}`;
|
|
337
|
+
const [found] = decodePulls((await author('GET', `${path}/pulls?${query}`)).text);
|
|
338
|
+
const number =
|
|
339
|
+
found?.number ??
|
|
340
|
+
decodeNumbered(
|
|
341
|
+
(
|
|
342
|
+
await author('POST', `${path}/pulls`, {
|
|
343
|
+
title: pull.title,
|
|
344
|
+
body: pull.body,
|
|
345
|
+
head: pull.branch,
|
|
346
|
+
base: 'main',
|
|
347
|
+
})
|
|
348
|
+
).text,
|
|
349
|
+
).number;
|
|
350
|
+
await placeOn(author, path, number, milestones.get(pull.milestone ?? ''));
|
|
351
|
+
|
|
352
|
+
const reviewer = cast.call(pull.review.by);
|
|
353
|
+
const reviews = await reviewer('GET', `${path}/pulls/${number}/reviews`);
|
|
354
|
+
|
|
355
|
+
if (!wrote(reviews.text, pull.review.by)) {
|
|
356
|
+
const { event, body } = pull.review;
|
|
357
|
+
await reviewer('POST', `${path}/pulls/${number}/reviews`, { event, body });
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (!pull.merged) return;
|
|
361
|
+
|
|
362
|
+
const state = decodeMerged((await author('GET', `${path}/pulls/${number}`)).text);
|
|
363
|
+
|
|
364
|
+
if (!state.merged) {
|
|
365
|
+
await author('PUT', `${path}/pulls/${number}/merge`, { merge_method: 'merge' });
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
/** The issue by its title, opened by its author if it isn't open yet, its comments, then closed. */
|
|
370
|
+
const openIssue = async (
|
|
371
|
+
cast: Cast,
|
|
372
|
+
path: string,
|
|
373
|
+
issue: SeedIssue,
|
|
374
|
+
milestones: ReadonlyMap<string, number>,
|
|
375
|
+
) => {
|
|
376
|
+
const author = cast.call(issue.by);
|
|
377
|
+
const listed = decodeIssues((await author('GET', `${path}/issues?state=all&per_page=100`)).text);
|
|
378
|
+
const found = listed.find(
|
|
379
|
+
(item) => item.pull_request === undefined && item.title === issue.title,
|
|
380
|
+
);
|
|
381
|
+
const number =
|
|
382
|
+
found?.number ??
|
|
383
|
+
decodeNumbered(
|
|
384
|
+
(
|
|
385
|
+
await author('POST', `${path}/issues`, {
|
|
386
|
+
title: issue.title,
|
|
387
|
+
body: issue.body,
|
|
388
|
+
labels: issue.labels,
|
|
389
|
+
})
|
|
390
|
+
).text,
|
|
391
|
+
).number;
|
|
392
|
+
await placeOn(author, path, number, milestones.get(issue.milestone ?? ''));
|
|
393
|
+
|
|
394
|
+
for (const comment of issue.comments) {
|
|
395
|
+
const commenter = cast.call(comment.by);
|
|
396
|
+
const comments = await commenter('GET', `${path}/issues/${number}/comments?per_page=100`);
|
|
397
|
+
|
|
398
|
+
if (!wrote(comments.text, comment.by, comment.body)) {
|
|
399
|
+
await commenter('POST', `${path}/issues/${number}/comments`, { body: comment.body });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (issue.closed && found?.state !== 'closed') {
|
|
404
|
+
await author('PATCH', `${path}/issues/${number}`, {
|
|
405
|
+
state: 'closed',
|
|
406
|
+
state_reason: 'completed',
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
const publishRelease = async (call: Call, path: string, repo: SeedRepo) => {
|
|
412
|
+
const { release } = repo;
|
|
413
|
+
if (release === undefined) return;
|
|
414
|
+
|
|
415
|
+
const found = await call('GET', `${path}/releases/tags/${encodeURIComponent(release.tag)}`);
|
|
416
|
+
if (found.status !== 404) return;
|
|
417
|
+
|
|
418
|
+
await call('POST', `${path}/releases`, {
|
|
419
|
+
tag_name: release.tag,
|
|
420
|
+
name: release.title,
|
|
421
|
+
body: release.notes,
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const seedRepo = async (cast: Cast, repo: SeedRepo, since: number) => {
|
|
426
|
+
const id: RepoId = `${org.login}/${repo.name}`;
|
|
427
|
+
const path = `/repos/${id}`;
|
|
428
|
+
|
|
429
|
+
await makeRepo(cast.admin, id);
|
|
430
|
+
// A repo's settings are its admin's to change, which a person's `write` token isn't.
|
|
431
|
+
await cast.adminCall('PATCH', path, { description: repo.description });
|
|
432
|
+
await pushHistory(cast.git(pip), id, repo, since);
|
|
433
|
+
await makeLabels(cast.call(pip), path, repo);
|
|
434
|
+
const milestones = await makeMilestones(cast.call(pip), path, repo);
|
|
435
|
+
|
|
436
|
+
for (const pull of repo.pulls) await openPull(cast, path, pull, milestones);
|
|
437
|
+
|
|
438
|
+
for (const issue of repo.issues) await openIssue(cast, path, issue, milestones);
|
|
439
|
+
await publishRelease(cast.call(pip), path, repo);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
const members: ReadonlySet<string> = new Set(org.members.map((person) => person.login));
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Revokes each live token a seed cut off made for one of `org`'s people, which expires at one of
|
|
446
|
+
* `expiries`, as the seed saved before it made them: its create was made, but its answer, and so
|
|
447
|
+
* its ID, was lost, or its revoke never came. The host's own tokens expire at other times.
|
|
448
|
+
*/
|
|
449
|
+
const revokeLeft = async (
|
|
450
|
+
admin: RestClient,
|
|
451
|
+
expiries: ReadonlySet<number>,
|
|
452
|
+
after?: string,
|
|
453
|
+
): Promise<void> => {
|
|
454
|
+
const active = { state: 'active' as const };
|
|
455
|
+
const input = after === undefined ? active : { ...active, page: { after } };
|
|
456
|
+
const page = value(
|
|
457
|
+
await admin.tokens.list({ prefix: `${org.login}/` }, input),
|
|
458
|
+
'list the tokens a cut seed left',
|
|
459
|
+
);
|
|
460
|
+
const left = page.items.filter(
|
|
461
|
+
(token) =>
|
|
462
|
+
expiries.has(token.expiresAt) && token.scope === 'write' && members.has(token.subject.id),
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
for (const token of left) value(await admin.tokens.revoke(token.id), 'revoke a token it left');
|
|
466
|
+
|
|
467
|
+
if (page.next !== undefined) await revokeLeft(admin, expiries, page.next);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Seeds a host with no repos: the org `acme`, its people and their repos, pull requests and issues,
|
|
472
|
+
* each written through the host's own calls, as the admin and as each person, with a `write` token
|
|
473
|
+
* the admin makes for them. Every step looks up what it makes by name first, so a seed cut off at
|
|
474
|
+
* any step finishes on the next call and makes nothing twice. The tokens are the exception: each
|
|
475
|
+
* call makes its own and revokes them, and first revokes any a cut call left, by the expiry it
|
|
476
|
+
* saved for them, so none outlives the seed. A host with repos of its own, or a seed that's done,
|
|
477
|
+
* is left as it is.
|
|
478
|
+
*/
|
|
479
|
+
export const seed = async (host: SeedHost): Promise<SeedOutcome> => {
|
|
480
|
+
const client = (token: string) =>
|
|
481
|
+
createRestClient({ url: host.origin, credentials: { token }, transport: host.fetch });
|
|
482
|
+
const admin = client(host.adminToken);
|
|
483
|
+
|
|
484
|
+
const progress = await begin(host.store, admin);
|
|
485
|
+
if (progress === undefined) return 'skipped';
|
|
486
|
+
|
|
487
|
+
const saved = progress.tokensExpire ?? [];
|
|
488
|
+
if (saved.length > 0) await revokeLeft(admin, new Set(saved));
|
|
489
|
+
|
|
490
|
+
// This start's expiry joins those still to come, which an earlier start's create may yet use.
|
|
491
|
+
const now = Date.now();
|
|
492
|
+
const tokensExpire = now + tokenLife;
|
|
493
|
+
const latest = await readProgress(host.store);
|
|
494
|
+
const kept = (latest.progress?.tokensExpire ?? saved).filter((expiry) => expiry > now);
|
|
495
|
+
const marked = await saveProgress(host.store, latest.version, {
|
|
496
|
+
state: 'running',
|
|
497
|
+
since: progress.since,
|
|
498
|
+
tokensExpire: [...kept, tokensExpire],
|
|
499
|
+
});
|
|
500
|
+
if (!marked) throw new Error('Another start is seeding this host');
|
|
501
|
+
|
|
502
|
+
const issued = new Map<string, CreatedToken>();
|
|
503
|
+
let revoked: readonly Result<void>[] = [];
|
|
504
|
+
|
|
505
|
+
try {
|
|
506
|
+
for (const person of org.members) {
|
|
507
|
+
const token = await admin.tokens.create(
|
|
508
|
+
{ prefix: `${org.login}/` },
|
|
509
|
+
{
|
|
510
|
+
scope: 'write',
|
|
511
|
+
subject: { id: person.login },
|
|
512
|
+
expiresAt: tokensExpire,
|
|
513
|
+
},
|
|
514
|
+
);
|
|
515
|
+
issued.set(person.login, value(token, `make ${person.login}'s token`));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const secret = (person: Person) => issued.get(person.login)?.secret ?? '';
|
|
519
|
+
const cast: Cast = {
|
|
520
|
+
admin,
|
|
521
|
+
adminCall: dropInCall(host, host.adminToken),
|
|
522
|
+
git: (person) => client(secret(person)),
|
|
523
|
+
call: (person) => dropInCall(host, secret(person)),
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
for (const repo of repos) await seedRepo(cast, repo, progress.since);
|
|
527
|
+
} finally {
|
|
528
|
+
revoked = await Promise.all([...issued.values()].map((token) => admin.tokens.revoke(token.id)));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// A revoke that failed leaves the seed running, so the next call revokes what it left.
|
|
532
|
+
for (const result of revoked) value(result, "revoke a person's token");
|
|
533
|
+
|
|
534
|
+
const { version } = await readProgress(host.store);
|
|
535
|
+
await saveProgress(host.store, version, { state: 'done', since: progress.since });
|
|
536
|
+
|
|
537
|
+
return 'seeded';
|
|
538
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
2
|
+
|
|
3
|
+
import type { AppContext } from './context/context.ts';
|
|
4
|
+
import {
|
|
5
|
+
adapter,
|
|
6
|
+
auth,
|
|
7
|
+
directory,
|
|
8
|
+
env,
|
|
9
|
+
git,
|
|
10
|
+
github,
|
|
11
|
+
pictures,
|
|
12
|
+
policy,
|
|
13
|
+
rest,
|
|
14
|
+
sessionKey,
|
|
15
|
+
} from './git.ts';
|
|
16
|
+
import { hostRules } from './policy.ts';
|
|
17
|
+
import { shownRules } from './settings/rules.ts';
|
|
18
|
+
import { sessionCookieOf, sessionEnder, sessionFrom } from './signin/auth.ts';
|
|
19
|
+
import { withoutHostSession } from './signin/host-session.ts';
|
|
20
|
+
|
|
21
|
+
export { Jobs, Records } from './git.ts';
|
|
22
|
+
|
|
23
|
+
/** The drop-in's URLs, then Git's Smart HTTP and sign-in, then its REST: a URL one of them owns. */
|
|
24
|
+
const owned = async (request: Request) =>
|
|
25
|
+
(await github.route(request)) ?? (await git.route(request)) ?? (await rest.route(request));
|
|
26
|
+
|
|
27
|
+
/** Git's answer for a URL it doesn't own: the app's server calls never reach the app. */
|
|
28
|
+
const api = async (request: Request) => (await owned(request)) ?? rest.fetch(request);
|
|
29
|
+
|
|
30
|
+
/** The host's push rules, as a repo's settings show them. */
|
|
31
|
+
const rules = shownRules(hostRules);
|
|
32
|
+
|
|
33
|
+
/** Whether the dev seed runs: `vite.config.ts` sets it true only under the dev server. */
|
|
34
|
+
declare const __DEV_SEED__: boolean;
|
|
35
|
+
|
|
36
|
+
let seeding: Promise<void> | undefined;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* In dev only, the seed, once an isolate, before its first answer: Pip and Mo sign up with
|
|
40
|
+
* `DEMO_PASSWORD` and make the demo org `acme`, a host with no repos gets its repos, and a seed cut
|
|
41
|
+
* off finishes. It signs them up in whatever database `AUTH_DB` points at under the dev server,
|
|
42
|
+
* the local D1 unless the host sets `"remote": true` on it, so `.dev.vars.example`'s known
|
|
43
|
+
* `DEMO_PASSWORD` is changed before the dev server points at a remote database.
|
|
44
|
+
*/
|
|
45
|
+
const seeded = () => {
|
|
46
|
+
seeding ??= Promise.all([import('./signin/seed-people.ts'), import('./seed/seed.ts')])
|
|
47
|
+
.then(async ([{ seedPeople }, { seed }]) => {
|
|
48
|
+
if (env.DEMO_PASSWORD === undefined) throw new Error('Set DEMO_PASSWORD in .dev.vars');
|
|
49
|
+
|
|
50
|
+
await seedPeople(await auth(), { origin: env.APP_ORIGIN, password: env.DEMO_PASSWORD });
|
|
51
|
+
|
|
52
|
+
return seed({
|
|
53
|
+
fetch: api,
|
|
54
|
+
origin: env.APP_ORIGIN,
|
|
55
|
+
adminToken: env.ADMIN_TOKEN,
|
|
56
|
+
store: adapter.store,
|
|
57
|
+
});
|
|
58
|
+
})
|
|
59
|
+
.then(
|
|
60
|
+
() => undefined,
|
|
61
|
+
(cause: unknown) => console.error('The seed stopped, and goes on at the next start:', cause),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return seeding;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Q8's order: the drop-in, then Git, then the app. A URL one owns never falls through. */
|
|
68
|
+
export default createServerEntry({
|
|
69
|
+
fetch: async (incoming) => {
|
|
70
|
+
// A host session is the app's server's to set in this Worker, never a caller's to send
|
|
71
|
+
// (Q520): every route, the APIs, the app and any upgrade, sees the request without one.
|
|
72
|
+
const request = withoutHostSession(incoming);
|
|
73
|
+
if (__DEV_SEED__) await seeded();
|
|
74
|
+
|
|
75
|
+
const answered = await owned(request);
|
|
76
|
+
if (answered !== undefined) return answered;
|
|
77
|
+
|
|
78
|
+
const context: AppContext = {
|
|
79
|
+
api,
|
|
80
|
+
sealKey: await sessionKey,
|
|
81
|
+
// Better Auth is made only for a request that reads it, and checked in that request (#480).
|
|
82
|
+
auth: async (each) => (await auth()).handler(each),
|
|
83
|
+
session: async (each) => sessionFrom(await auth(), sessionKey)(each),
|
|
84
|
+
endSession: async (each) => sessionEnder(await auth())(each),
|
|
85
|
+
sessionCookie: async () => sessionCookieOf(await auth())(),
|
|
86
|
+
identify: git.identify,
|
|
87
|
+
authorize: policy.authorize,
|
|
88
|
+
authorizeGitHub: policy.authorizeGitHub,
|
|
89
|
+
rules,
|
|
90
|
+
avatars: pictures,
|
|
91
|
+
accounts: directory,
|
|
92
|
+
git,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return handler.fetch(request, { context });
|
|
96
|
+
},
|
|
97
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { avatarUrl } from '../components/avatar-url.ts';
|
|
2
|
+
import { type Account, UserAvatar } from '../components/user-avatar.tsx';
|
|
3
|
+
import { avatarAt } from '../hooks/avatars.ts';
|
|
4
|
+
import { AvatarSection } from './avatar-section.tsx';
|
|
5
|
+
|
|
6
|
+
/** What each account's picture is shown beside. */
|
|
7
|
+
const shownBeside: Record<Account, string> = {
|
|
8
|
+
user: 'Shown beside your login across the app, and to API clients as your avatar_url.',
|
|
9
|
+
org: "Shown beside the organization's name across the app, and to API clients as its avatar_url.",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A person's or an org's picture, as its settings' first section (Q757): the one Avatar section,
|
|
14
|
+
* over `/icons/{login}`. Once it changes, every `UserAvatar` of the login shows it at once.
|
|
15
|
+
*/
|
|
16
|
+
export function AccountAvatar({
|
|
17
|
+
login,
|
|
18
|
+
account,
|
|
19
|
+
refusal,
|
|
20
|
+
}: {
|
|
21
|
+
readonly login: string;
|
|
22
|
+
readonly account: Account;
|
|
23
|
+
/** Why the viewer can't change it, or none when they can. */
|
|
24
|
+
readonly refusal?: string | undefined;
|
|
25
|
+
}) {
|
|
26
|
+
return (
|
|
27
|
+
<AvatarSection
|
|
28
|
+
place={{ owner: login }}
|
|
29
|
+
title="Picture"
|
|
30
|
+
className="max-w-none"
|
|
31
|
+
heading="h2"
|
|
32
|
+
refusal={refusal}
|
|
33
|
+
description={shownBeside[account]}
|
|
34
|
+
preview={<UserAvatar login={login} account={account} size="xl" />}
|
|
35
|
+
onShown={(client, hash) =>
|
|
36
|
+
client.setQueryData(
|
|
37
|
+
avatarAt(login).queryKey,
|
|
38
|
+
hash === null ? null : avatarUrl({ owner: login }, hash),
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|