ref0-git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +122 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +538 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +48 -0
- package/dist/cli/helpers.mjs +51 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +79 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +75 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +383 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// src/init/templates.json
|
|
2
|
+
var templates_default = {
|
|
3
|
+
appGit: [
|
|
4
|
+
{
|
|
5
|
+
"slot": "gitImport",
|
|
6
|
+
"text": "import { createGitServer, mergeQueue, packs } from '@ref0/git';"
|
|
7
|
+
},
|
|
8
|
+
"\n",
|
|
9
|
+
{
|
|
10
|
+
"slot": "queueTypes",
|
|
11
|
+
"text": "import type { MergeInput, MergePlan } from '@ref0/git';\n"
|
|
12
|
+
},
|
|
13
|
+
"import { tokens } from '@ref0/git/auth';\nimport { engine } from '@ref0/git/engine';\nimport { createRestHandler } from '@ref0/git/rest';\nimport xdiff from '@ref0/git/xdiff.wasm';\nimport { createGitHubHandler } from '@ref0/github';\n",
|
|
14
|
+
{
|
|
15
|
+
"slot": "infraImport",
|
|
16
|
+
"text": "import { cloudflare, jobObject, r2, recordsObject } from '@ref0/infra/cloudflare';"
|
|
17
|
+
},
|
|
18
|
+
"\nimport { env as bindings } from 'cloudflare:workers';\n\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` ",
|
|
19
|
+
{
|
|
20
|
+
"slot": "safety",
|
|
21
|
+
"text": "binds the objects, the bucket and D1"
|
|
22
|
+
},
|
|
23
|
+
" and sets `APP_ORIGIN`; the\n// secrets come from `wrangler secret put`, or `.dev.vars` locally.\nexport const env = bindings as Env;\n\n",
|
|
24
|
+
{
|
|
25
|
+
"slot": "bucket",
|
|
26
|
+
"text": "const {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, a push's pack uploads to the bucket in parts, past Workers' 100 MB body.\nconst bucket =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? r2(env.PACKS)\n : r2(env.PACKS, {\n signing: { accountId, bucket: env.PACKS_BUCKET, accessKeyId, secretAccessKey },\n });\n\n"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"slot": "adapterAbout",
|
|
30
|
+
"text": "/** Git's records, jobs and packs, whose store"
|
|
31
|
+
},
|
|
32
|
+
" also keeps the local seed's progress. */\nexport const adapter = cloudflare({ records: env.RECORDS, ",
|
|
33
|
+
{
|
|
34
|
+
"slot": "adapterBucket",
|
|
35
|
+
"text": "jobs: env.JOBS, bucket });"
|
|
36
|
+
},
|
|
37
|
+
"\n\n",
|
|
38
|
+
{
|
|
39
|
+
"slot": "queueMerge",
|
|
40
|
+
"text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at: Date.now(), offset: 0 },\n };\n};\n\n"
|
|
41
|
+
},
|
|
42
|
+
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\nexport const policy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: async (prefix, most, host) => privateReposOf(git)(prefix, most, host),\n});\n\n/** Git, with the device flow's sign-in for `gh` and `ref0-git login`. */\nexport const git = createGitServer({\n adapter,\n",
|
|
43
|
+
{
|
|
44
|
+
"slot": "objects",
|
|
45
|
+
"text": " objects: packs(),"
|
|
46
|
+
},
|
|
47
|
+
"\n engine: engine({ xdiff }),\n tokens: tokens(),\n",
|
|
48
|
+
{
|
|
49
|
+
"slot": "uploads",
|
|
50
|
+
"text": " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },\n"
|
|
51
|
+
},
|
|
52
|
+
" auth: appAuth({ adminToken: env.ADMIN_TOKEN, admin, key: sessionKey }),\n authorize: policy.authorize,\n",
|
|
53
|
+
{
|
|
54
|
+
"slot": "queue",
|
|
55
|
+
"text": " // Each repo's `main` has a merge queue, beside the merge button: its protection still takes a\n // direct merge, as GitHub's does on a branch whose rules don't ask for the queue.\n queue: mergeQueue({ target: 'refs/heads/main', merge: queueMerge }),\n"
|
|
56
|
+
},
|
|
57
|
+
" // Git's events go to the drop-in, which follows each push: a pull request's head, its queue.\n events: (input) => github.events(input),\n rules: { push: hostRules.map((each) => each.rule) },\n // The page decides in the person's session, from the Better Auth below and Git's own `identify`.\n signIn: {\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request) => git.identify(request),\n origin: env.APP_ORIGIN,\n }),\n },\n});\n\n/**\n * Better Auth, made at a request that needs it, not the isolate's start: who signs up and in, in\n * `AUTH_DB`, each session with a Git token of its own. It's kept once a request's check settles.\n */\nexport const auth = readyAuth(() => {\n const tokens = git.tokens;\n if (tokens === undefined) throw new Error('Sessions mint Git tokens: pass tokens() to Git');\n\n return starterAuth({\n database: env.AUTH_DB,\n secret: env.SESSION_SECRET,\n origin: env.APP_ORIGIN,\n signUp: env.SIGN_UP !== 'closed',\n key: sessionKey,\n tokens,\n // Cloudflare's own, which it sets on every request in place of any the caller sent.\n ipHeader: 'cf-connecting-ip',\n ownsRepos: async (login) => {\n const listed = await git.repos.list({\n actor: admin,\n prefix: `${login}/`,\n page: { limit: 1 },\n });\n\n return listed.kind !== 'success' || listed.value.items.length > 0;\n },\n });\n});\n\n/**\n * The drop-in, joined to `git` here, before its first request, with the host's directory, and the\n * owner index, so `org:` and `user:` search an owner's repos, its private ones by the hook.\n */\nexport const github = createGitHubHandler(git, {\n authorize: policy.authorizeGitHub,\n people: policy.people,\n ownerIndex: { readableRepos: policy.readableRepos },\n});\n\n/** Git's REST, whose `route` serves Git's own URLs too: Smart HTTP and sign-in. */\nexport const rest = createRestHandler(git);\n\n/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = recordsObject(adapter);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = jobObject(adapter);\n"
|
|
58
|
+
],
|
|
59
|
+
appGitNode: [
|
|
60
|
+
{
|
|
61
|
+
"slot": "head",
|
|
62
|
+
"text": "import { createGitServer, mergeQueue, packs } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport { tokens } from '@ref0/git/auth';\nimport { engine } from '@ref0/git/engine';\nimport { createRestHandler } from '@ref0/git/rest';\nimport xdiff from '@ref0/git/xdiff.wasm';\nimport { createGitHubHandler } from '@ref0/github';\nimport { cloudflare, jobObject, r2, recordsObject } from '@ref0/infra/cloudflare';\nimport { env as bindings } from 'cloudflare:workers';\n\nimport type { Env } from './env.ts';\nimport { admin, approvalPage, hostPolicy, hostRules } from './policy.ts';\nimport { privateReposOf } from './private-repos.ts';\nimport { readyAdapter, readyAuth, starterAuth } from './signin/auth.ts';\nimport { avatars } from './signin/avatars.ts';\nimport { appAuth } from './signin/host-session.ts';\nimport { orgsOver } from './signin/orgs.ts';\nimport { sealKey } from './signin/seal.ts';\n\n// SAFETY: `wrangler.jsonc` binds the objects, the bucket and D1 and sets `APP_ORIGIN`; the\n// secrets come from `wrangler secret put`, or `.dev.vars` locally.\nexport const env = bindings as Env;\n\nconst {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, a push's pack uploads to the bucket in parts, past Workers' 100 MB body.\nconst bucket =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? r2(env.PACKS)\n : r2(env.PACKS, {\n signing: { accountId, bucket: env.PACKS_BUCKET, accessKeyId, secretAccessKey },\n });\n\n/** Git's records, jobs and packs, whose store also keeps the local seed's progress. */\nexport const adapter = cloudflare({ records: env.RECORDS, jobs: env.JOBS, bucket });\n\n"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"slot": "queueMerge",
|
|
66
|
+
"text": "/**\n * How the queue writes an entry's link onto `main`: a merge commit, by the person who added it, as\n * a pull request's merge button writes one, and titled as GitHub titles it for a pull request's\n * entry, keyed `pr-<number>`.\n */\nconst queueMerge = ({ entry }: MergeInput): MergePlan => {\n const [owner = ''] = entry.repo.split('/');\n const branch = entry.source.replace(/^refs\\/heads\\//, '');\n const pull = /^pr-([1-9]\\d*)$/.exec(entry.key)?.[1];\n const title =\n pull === undefined ? `Merge ${branch}` : `Merge pull request #${pull} from ${owner}/${branch}`;\n const login = entry.subject?.id ?? entry.actor.id;\n const hostname = new URL(env.APP_ORIGIN).hostname;\n\n return {\n method: 'merge',\n message: `${title}\\n`,\n author: { name: login, email: `${login}@users.noreply.${hostname}`, at: Date.now(), offset: 0 },\n };\n};\n\n"
|
|
67
|
+
},
|
|
68
|
+
"/** The key sessions and host sessions are sealed under, derived once an isolate from its secret. */\nexport const sessionKey = sealKey(env.SESSION_SECRET);\n\n/**\n * Who owns what, and the drop-in's people and orgs, over Better Auth's tables, which `auth` makes\n * at the first request that reads them.\n */\nexport const directory = orgsOver(async () => readyAdapter(await auth()));\n\n/** People's, orgs' and repos' pictures, in Better Auth's database, as `directory` reads it. */\nexport const pictures = avatars(async () => readyAdapter(await auth()));\n\nexport const policy = hostPolicy(directory, {\n origin: env.APP_ORIGIN,\n avatars: pictures,\n privateRepos: async (prefix, most, host) => privateReposOf(git)(prefix, most, host),\n});\n\n/** Git, with the device flow's sign-in for `gh` and `ref0-git login`. */\nexport const git = createGitServer({\n adapter,\n",
|
|
69
|
+
{
|
|
70
|
+
"slot": "objects",
|
|
71
|
+
"text": " objects: packs(),"
|
|
72
|
+
},
|
|
73
|
+
"\n",
|
|
74
|
+
{
|
|
75
|
+
"slot": "engine",
|
|
76
|
+
"text": " engine: engine({ xdiff }),"
|
|
77
|
+
},
|
|
78
|
+
"\n tokens: tokens(),\n",
|
|
79
|
+
{
|
|
80
|
+
"slot": "uploads",
|
|
81
|
+
"text": " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },\n"
|
|
82
|
+
},
|
|
83
|
+
" auth: appAuth({ adminToken: env.ADMIN_TOKEN, admin, key: sessionKey }),\n authorize: policy.authorize,\n",
|
|
84
|
+
{
|
|
85
|
+
"slot": "queue",
|
|
86
|
+
"text": " // Each repo's `main` has a merge queue, beside the merge button: its protection still takes a\n // direct merge, as GitHub's does on a branch whose rules don't ask for the queue.\n queue: mergeQueue({ target: 'refs/heads/main', merge: queueMerge }),\n"
|
|
87
|
+
},
|
|
88
|
+
" // Git's events go to the drop-in, which follows each push: a pull request's head, its queue.\n events: (input) => github.events(input),\n rules: { push: hostRules.map((each) => each.rule) },\n // The page decides in the person's session, from the Better Auth below and Git's own `identify`.\n signIn: {\n approvalPage: approvalPage({\n auth: () => auth(),\n sealKey: sessionKey,\n identify: (request) => git.identify(request),\n origin: env.APP_ORIGIN,\n }),\n },\n});\n\n/**\n * Better Auth, made at a request that needs it, not the isolate's start: who signs up and in, in\n * `AUTH_DB`, each session with a Git token of its own. It's kept once a request's check settles.\n */\nexport const auth = readyAuth(() => {\n const tokens = git.tokens;\n if (tokens === undefined) throw new Error('Sessions mint Git tokens: pass tokens() to Git');\n\n return starterAuth({\n",
|
|
89
|
+
{
|
|
90
|
+
"slot": "database",
|
|
91
|
+
"text": " database: env.AUTH_DB,"
|
|
92
|
+
},
|
|
93
|
+
"\n secret: env.SESSION_SECRET,\n origin: env.APP_ORIGIN,\n signUp: env.SIGN_UP !== 'closed',\n key: sessionKey,\n tokens,\n",
|
|
94
|
+
{
|
|
95
|
+
"slot": "ipHeader",
|
|
96
|
+
"text": " // Cloudflare's own, which it sets on every request in place of any the caller sent.\n ipHeader: 'cf-connecting-ip',\n"
|
|
97
|
+
},
|
|
98
|
+
" ownsRepos: async (login) => {\n const listed = await git.repos.list({\n actor: admin,\n prefix: `${login}/`,\n page: { limit: 1 },\n });\n\n return listed.kind !== 'success' || listed.value.items.length > 0;\n },\n });\n});\n\n/**\n * The drop-in, joined to `git` here, before its first request, with the host's directory, and the\n * owner index, so `org:` and `user:` search an owner's repos, its private ones by the hook.\n */\nexport const github = createGitHubHandler(git, {\n authorize: policy.authorizeGitHub,\n people: policy.people,\n ownerIndex: { readableRepos: policy.readableRepos },\n});\n\n/** Git's REST, whose `route` serves Git's own URLs too: Smart HTTP and sign-in. */\nexport const rest = createRestHandler(git);\n",
|
|
99
|
+
{
|
|
100
|
+
"slot": "classes",
|
|
101
|
+
"text": "\n/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = recordsObject(adapter);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = jobObject(adapter);\n"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
appEnv: [
|
|
105
|
+
{
|
|
106
|
+
"slot": "types",
|
|
107
|
+
"text": "import type { D1Database, DurableObjectNamespace, R2Bucket } from '@cloudflare/workers-types';"
|
|
108
|
+
},
|
|
109
|
+
"\n\n/** What `wrangler.jsonc` binds and sets, and the Worker's secrets. */\nexport interface Env {\n /** `Records`: the records objects, one per scope. */\n readonly RECORDS: DurableObjectNamespace;\n /** `Jobs`: the job objects, one per scope and job. */\n readonly JOBS: DurableObjectNamespace;\n",
|
|
110
|
+
{
|
|
111
|
+
"slot": "bucket",
|
|
112
|
+
"text": " /** The packs' bucket, and its name, which a signed link names. */\n readonly PACKS: R2Bucket;\n readonly PACKS_BUCKET: string;\n"
|
|
113
|
+
},
|
|
114
|
+
" /** People and their sessions: Better Auth's tables, which `migrations/sql/` makes. */\n readonly AUTH_DB: D1Database;\n /** Signs in as the admin, who makes repos and tokens and never pushes, and vouches at sign-in. */\n readonly ADMIN_TOKEN: string;\n /** At least 32 characters: what signs Better Auth's cookie, and seals each session's Git token. */\n readonly SESSION_SECRET: string;\n /** Where the app is served, such as `https://git.example.com`: Better Auth takes POSTs from it. */\n readonly APP_ORIGIN: string;\n /** `closed` turns sign-up off, so only the people already signed up sign in. Open when unset. */\n readonly SIGN_UP?: string;\n",
|
|
115
|
+
{
|
|
116
|
+
"slot": "signing",
|
|
117
|
+
"text": " /** R2's S3 credentials for the packs' bucket: with all three, a large push uploads its pack. */\n readonly R2_ACCOUNT_ID?: string;\n readonly R2_ACCESS_KEY_ID?: string;\n readonly R2_SECRET_ACCESS_KEY?: string;\n"
|
|
118
|
+
},
|
|
119
|
+
" /** In dev only, at least 15 characters: the password the seed signs Pip and Mo up with. */\n readonly DEMO_PASSWORD?: string;\n}\n"
|
|
120
|
+
],
|
|
121
|
+
appWrangler: [
|
|
122
|
+
"// The app and Git in one Worker: its two ",
|
|
123
|
+
{
|
|
124
|
+
"slot": "about",
|
|
125
|
+
"text": "Durable Object classes, an R2 bucket, and D1"
|
|
126
|
+
},
|
|
127
|
+
" for its people.\n// `ADMIN_TOKEN` and `SESSION_SECRET` are its secrets, set with `wrangler secret put`, or locally in\n// `.dev.vars`, which `ref0-git init` made. `APP_ORIGIN` is where it's served, the one origin sign-in\n// takes a POST from. `wrangler d1 create` adds `AUTH_DB`'s `database_id` on deploy, and\n// `migrations/sql/` holds its tables, which `wrangler d1 migrations apply AUTH_DB --local` makes locally.\n",
|
|
128
|
+
{
|
|
129
|
+
"slot": "signing",
|
|
130
|
+
"text": "// With R2's S3 credentials too, as the secrets `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID` and\n// `R2_SECRET_ACCESS_KEY`, a large push uploads its pack to the bucket in parts.\n"
|
|
131
|
+
},
|
|
132
|
+
"// A request may use five minutes of CPU, Workers' most: a clone takes up to 0.2 s of it a MiB.\n{\n",
|
|
133
|
+
{
|
|
134
|
+
"slot": "name",
|
|
135
|
+
"text": " \"name\": \"git-app\","
|
|
136
|
+
},
|
|
137
|
+
"\n \"main\": \"src/server.ts\",\n \"limits\": { \"cpu_ms\": 300000 },\n \"compatibility_date\": \"2026-11-01\",\n",
|
|
138
|
+
{
|
|
139
|
+
"slot": "vars",
|
|
140
|
+
"text": " \"vars\": { \"APP_ORIGIN\": \"http://localhost:5173\", \"PACKS_BUCKET\": \"git-app-packs\" },"
|
|
141
|
+
},
|
|
142
|
+
"\n \"durable_objects\": {\n \"bindings\": [\n { \"name\": \"RECORDS\", \"class_name\": \"Records\" },\n { \"name\": \"JOBS\", \"class_name\": \"Jobs\" },\n ],\n },\n",
|
|
143
|
+
{
|
|
144
|
+
"slot": "bucket",
|
|
145
|
+
"text": " \"r2_buckets\": [{ \"binding\": \"PACKS\", \"bucket_name\": \"git-app-packs\" }],\n"
|
|
146
|
+
},
|
|
147
|
+
" \"d1_databases\": [\n",
|
|
148
|
+
{
|
|
149
|
+
"slot": "database",
|
|
150
|
+
"text": " { \"binding\": \"AUTH_DB\", \"database_name\": \"git-app-auth\", \"migrations_dir\": \"migrations/sql\" },"
|
|
151
|
+
},
|
|
152
|
+
"\n ],\n \"migrations\": [{ \"tag\": \"v1\", \"new_sqlite_classes\": [\"Records\", \"Jobs\"] }],\n}\n"
|
|
153
|
+
],
|
|
154
|
+
appConfigs: {
|
|
155
|
+
"tsconfig.json": "// The app's pages, routes, clients and sign-in: DOM, as a browser runs them, and Start's server\n// functions beside them. The Worker's entry and Git are `tsconfig.worker.json`'s, typed by\n// workers-types with no DOM, and the tests `tsconfig.test.json`'s, in Node. Each file is in the\n// one whose globals it runs with, and the root's `tsconfig.json` references all three.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"jsx\": \"react-jsx\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.tsbuildinfo\",\n \"types\": [\"vite-plus/client\"]\n },\n \"include\": [\"src/**/*.ts\", \"src/**/*.tsx\", \"generated/**/*.ts\"],\n \"exclude\": [\n \"src/**/*.test.ts\",\n \"src/**/testing/**\",\n \"src/seed/**\",\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/signin/approval.ts\"\n ]\n}\n",
|
|
156
|
+
"tsconfig.worker.json": "// The Worker, typed as Cloudflare types one: workers-types' globals and no DOM, so `Request` and\n// `Response` are a Worker's. The pages are `tsconfig.app.json`'s, and the files both run, sealing\n// and names, are in each.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"lib\": [\"ES2023\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.worker.tsbuildinfo\",\n \"types\": [\"@cloudflare/workers-types\", \"vite-plus/client\"]\n },\n \"include\": [\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/context/**/*.ts\",\n \"src/names/**/*.ts\",\n \"src/seed/**/*.ts\",\n \"src/signin/approval.ts\",\n \"src/signin/seal.ts\"\n ],\n \"exclude\": [\"src/**/*.test.ts\", \"src/seed/testing/built-app.ts\"]\n}\n"
|
|
157
|
+
},
|
|
158
|
+
nodeServer: "import handler, { createServerEntry } from '@tanstack/react-start/server-entry';\n\nimport type { AppContext } from './context/context.ts';\nimport {\n adapter,\n auth,\n directory,\n env,\n git,\n github,\n pictures,\n policy,\n rest,\n sessionKey,\n} from './git.ts';\nimport { hostRules } from './policy.ts';\nimport { shownRules } from './settings/rules.ts';\nimport { sessionCookieOf, sessionEnder, sessionFrom } from './signin/auth.ts';\nimport { withClientIp } from './signin/client-ip.ts';\nimport { withoutHostSession } from './signin/host-session.ts';\n\n/** The drop-in's URLs, then Git's Smart HTTP and sign-in, then its REST: a URL one of them owns. */\nconst owned = async (request: Request) =>\n (await github.route(request)) ?? (await git.route(request)) ?? (await rest.route(request));\n\n/** Git's answer for a URL it doesn't own: the app's server calls never reach the app. */\nconst api = async (request: Request) => (await owned(request)) ?? rest.fetch(request);\n\n/** The host's push rules, as a repo's settings show them. */\nconst rules = shownRules(hostRules);\n\n/** Whether the dev seed runs: `vite.config.ts` sets it true only under the dev server. */\ndeclare const __DEV_SEED__: boolean;\n\nlet seeding: Promise<void> | undefined;\n\n/**\n * In dev only, the seed, once an isolate, before its first answer: Pip and Mo sign up with\n * `DEMO_PASSWORD` and make the demo org `acme`, a host with no repos gets its repos, and a seed cut\n * off finishes. It signs them up in whatever database `AUTH_DB` points at under the dev server,\n * the local D1 unless the host sets `\"remote\": true` on it, so `.dev.vars.example`'s known\n * `DEMO_PASSWORD` is changed before the dev server points at a remote database.\n */\nconst seeded = () => {\n seeding ??= Promise.all([import('./signin/seed-people.ts'), import('./seed/seed.ts')])\n .then(async ([{ seedPeople }, { seed }]) => {\n if (env.DEMO_PASSWORD === undefined) throw new Error('Set DEMO_PASSWORD in .env');\n\n await seedPeople(await auth(), { origin: env.APP_ORIGIN, password: env.DEMO_PASSWORD });\n\n return seed({\n fetch: api,\n origin: env.APP_ORIGIN,\n adminToken: env.ADMIN_TOKEN,\n store: adapter.store,\n });\n })\n .then(\n () => undefined,\n (cause: unknown) => console.error('The seed stopped, and goes on at the next start:', cause),\n );\n\n return seeding;\n};\n\n/** Q8's order: the drop-in, then Git, then the app. A URL one owns never falls through. */\nexport default createServerEntry({\n fetch: async (incoming) => {\n // A host session is the app's server's to set in this Worker, never a caller's to send\n // (Q520): every route, the APIs, the app and any upgrade, sees the request without one.\n // The caller's address, for the rate limit, set by this server in place of any the caller sent.\n const request = withoutHostSession(withClientIp(incoming, env.CLIENT_IP_HEADER));\n if (__DEV_SEED__) await seeded();\n\n const answered = await owned(request);\n if (answered !== undefined) return answered;\n\n const context: AppContext = {\n api,\n sealKey: await sessionKey,\n // Better Auth is made only for a request that reads it, and checked in that request (#480).\n auth: async (each) => (await auth()).handler(each),\n session: async (each) => sessionFrom(await auth(), sessionKey)(each),\n endSession: async (each) => sessionEnder(await auth())(each),\n sessionCookie: async () => sessionCookieOf(await auth())(),\n identify: git.identify,\n authorize: policy.authorize,\n authorizeGitHub: policy.authorizeGitHub,\n rules,\n avatars: pictures,\n accounts: directory,\n git,\n };\n\n return handler.fetch(request, { context });\n },\n});\n",
|
|
159
|
+
nodeConfigs: { "tsconfig.json": "// The app's pages, routes, clients and sign-in: DOM, as a browser runs them, and Start's server\n// functions beside them. The server and Git are `tsconfig.server.json`'s, typed by\n// Node's types with no DOM, and the tests `tsconfig.test.json`'s, in Node. Each file is in the\n// one whose globals it runs with, and the root's `tsconfig.json` references all three.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"jsx\": \"react-jsx\",\n \"lib\": [\"ES2023\", \"DOM\", \"DOM.Iterable\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.tsbuildinfo\",\n \"types\": [\"vite-plus/client\"]\n },\n \"include\": [\"src/**/*.ts\", \"src/**/*.tsx\", \"generated/**/*.ts\"],\n \"exclude\": [\n \"src/**/*.test.ts\",\n \"src/**/testing/**\",\n \"src/seed/**\",\n \"src/server.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/signin/approval.ts\"\n ]\n}\n" },
|
|
160
|
+
nodeServerConfig: "// The server, typed as Node runs it: Node's globals and no DOM. The pages are `tsconfig.json`'s,\n// and the files both run, sealing and names, are in each.\n{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"composite\": true,\n \"lib\": [\"ES2023\"],\n \"tsBuildInfoFile\": \"./node_modules/.cache/tsconfig.server.tsbuildinfo\",\n \"types\": [\"node\", \"vite-plus/client\"]\n },\n \"include\": [\n \"src/server.ts\",\n \"server/**/*.ts\",\n \"scripts/**/*.ts\",\n \"src/git.ts\",\n \"src/policy.ts\",\n \"src/env.ts\",\n \"src/context/**/*.ts\",\n \"src/names/**/*.ts\",\n \"src/seed/**/*.ts\",\n \"src/signin/approval.ts\",\n \"src/signin/seal.ts\"\n ],\n \"exclude\": [\"src/**/*.test.ts\", \"src/seed/testing/built-app.ts\"]\n}\n",
|
|
161
|
+
nodeVite: "import tailwindcss from '@tailwindcss/vite';\nimport { tanstackStart } from '@tanstack/react-start/plugin/vite';\nimport viteReact from '@vitejs/plugin-react';\nimport { nitro } from 'nitro/vite';\nimport { defineConfig } from 'vite-plus';\n\n// Start's server build runs in Node through Nitro, which scans `server/` for the jobs' plugin.\nexport default defineConfig(({ command }) => ({\n // The dev seed is on only under the dev server, `vp dev`: every build drops it and its imports,\n // whatever its mode or `NODE_ENV`.\n define: { __DEV_SEED__: JSON.stringify(command === 'serve') },\n plugins: [\n tanstackStart({\n // NodeNext, as the repo types it, resolves only imports that name their extension.\n router: { generatedRouteTree: '../generated/routeTree.gen.ts', addExtensions: true },\n }),\n nitro({ serverDir: './server' }),\n viteReact(),\n tailwindcss(),\n ],\n}));\n",
|
|
162
|
+
workerGit: [
|
|
163
|
+
{
|
|
164
|
+
"slot": "header",
|
|
165
|
+
"text": "// Git on Cloudflare, with its REST API, with a merge queue on `main`. Written by\n// `ref0-git init`, and yours to change: `init` rewrites it only while it reads as written, and\n// `ref0-git doctor` checks it.\n"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"slot": "gitImports",
|
|
169
|
+
"text": "import { accept, createGitServer, mergeQueue, packs, reject } from '@ref0/git';\nimport type { MergeInput, MergePlan } from '@ref0/git';\nimport { bearer, tokens } from '@ref0/git/auth';\nimport { engine } from '@ref0/git/engine';\nimport { createRestHandler } from '@ref0/git/rest';\nimport xdiff from '@ref0/git/xdiff.wasm';\n"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"slot": "infraImport",
|
|
173
|
+
"text": "import { cloudflare, jobObject, r2, recordsObject } from '@ref0/infra/cloudflare';"
|
|
174
|
+
},
|
|
175
|
+
"\nimport { env as bindings } from 'cloudflare:workers';\n\nimport type { Env } from ",
|
|
176
|
+
{
|
|
177
|
+
"slot": "envFile",
|
|
178
|
+
"text": "'./env.ts'"
|
|
179
|
+
},
|
|
180
|
+
";\n\n// SAFETY: `wrangler.jsonc` ",
|
|
181
|
+
{
|
|
182
|
+
"slot": "safety",
|
|
183
|
+
"text": "binds the objects and the bucket"
|
|
184
|
+
},
|
|
185
|
+
", and `ADMIN_TOKEN` is its secret.\nconst env = bindings as Env;\n\n/** Who `ADMIN_TOKEN` signs in as: it makes repos and tokens, and never pushes. */\nconst admin = { id: '_admin' };\n\n",
|
|
186
|
+
{
|
|
187
|
+
"slot": "bucket",
|
|
188
|
+
"text": "const {\n R2_ACCOUNT_ID: accountId,\n R2_ACCESS_KEY_ID: accessKeyId,\n R2_SECRET_ACCESS_KEY: secretAccessKey,\n} = env;\n\n// With R2's S3 credentials, a push's pack uploads to the bucket in parts, past Workers' 100 MB body.\nconst bucket =\n accountId === undefined || accessKeyId === undefined || secretAccessKey === undefined\n ? r2(env.PACKS)\n : r2(env.PACKS, {\n signing: { accountId, bucket: env.PACKS_BUCKET, accessKeyId, secretAccessKey },\n });\n\n"
|
|
189
|
+
},
|
|
190
|
+
"const adapter = cloudflare({ records: env.RECORDS, ",
|
|
191
|
+
{
|
|
192
|
+
"slot": "adapterBucket",
|
|
193
|
+
"text": "jobs: env.JOBS, bucket });"
|
|
194
|
+
},
|
|
195
|
+
"\n\n",
|
|
196
|
+
{
|
|
197
|
+
"slot": "merge",
|
|
198
|
+
"text": "/** How the queue writes an entry onto `main`: a merge commit, by whoever added it. */\nconst merge = ({ entry }: MergeInput): MergePlan => ({\n method: 'merge',\n message: `Merge ${entry.source.replace(/^refs\\/heads\\//, '')}\\n`,\n author: {\n name: entry.actor.id,\n email: `${entry.actor.id}@users.noreply.git`,\n at: Date.now(),\n offset: 0,\n },\n});\n\n"
|
|
199
|
+
},
|
|
200
|
+
"export const git = createGitServer({\n adapter,\n",
|
|
201
|
+
{
|
|
202
|
+
"slot": "objects",
|
|
203
|
+
"text": " objects: packs(),"
|
|
204
|
+
},
|
|
205
|
+
"\n engine: engine({ xdiff }),\n tokens: tokens(),\n",
|
|
206
|
+
{
|
|
207
|
+
"slot": "uploads",
|
|
208
|
+
"text": " // A push past 64 MiB may upload its pack, once the bucket signs parts.\n pushes: { upload: { above: 64 * 1024 * 1024 } },\n"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"slot": "basePath",
|
|
212
|
+
"text": ""
|
|
213
|
+
},
|
|
214
|
+
" auth: bearer({ token: env.ADMIN_TOKEN, actor: admin }),\n authorize: ({ actor, operation }) => {\n if (actor.anonymous === true) return reject({ message: 'Sign in first' });\n\n if (actor.id === admin.id && operation.kind === 'push') {\n return reject({\n message: \"The admin token can't push\",\n hint: 'Make a write token for yourself: npx ref0-git tokens create --help',\n });\n }\n\n return accept();\n },\n",
|
|
215
|
+
{
|
|
216
|
+
"slot": "queue",
|
|
217
|
+
"text": " queue: mergeQueue({ target: 'refs/heads/main', merge }),\n"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"slot": "events",
|
|
221
|
+
"text": ""
|
|
222
|
+
},
|
|
223
|
+
"});\n\n",
|
|
224
|
+
{
|
|
225
|
+
"slot": "github",
|
|
226
|
+
"text": ""
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"slot": "rest",
|
|
230
|
+
"text": "/** Git's REST, whose `route` and `fetch` serve Git's protocol and sign-in too. */\nexport const rest = createRestHandler(git);\n\n"
|
|
231
|
+
},
|
|
232
|
+
"/** The records objects, one per scope, as `wrangler.jsonc`'s `class_name`s name them. */\nexport const Records = recordsObject(adapter);\n\n/** The job objects, one per scope and job, which a records object's alarm rings. */\nexport const Jobs = jobObject(adapter);\n"
|
|
233
|
+
],
|
|
234
|
+
workerEntry: [
|
|
235
|
+
"import type { Env } from './env.ts';\n",
|
|
236
|
+
{
|
|
237
|
+
"slot": "names",
|
|
238
|
+
"text": "import { rest } from './git.ts';"
|
|
239
|
+
},
|
|
240
|
+
"\n\nexport { Jobs, Records } from './git.ts';\n\n",
|
|
241
|
+
{
|
|
242
|
+
"slot": "exports",
|
|
243
|
+
"text": "/** Git's REST and protocol, then a JSON `404`. */\nexport default { fetch: rest.fetch } satisfies ExportedHandler<Env>;\n"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
workerEnv: [
|
|
247
|
+
{
|
|
248
|
+
"slot": "types",
|
|
249
|
+
"text": "import type { DurableObjectNamespace, R2Bucket } from '@cloudflare/workers-types';"
|
|
250
|
+
},
|
|
251
|
+
"\n\n/** What `wrangler.jsonc` binds for Git, and the Worker's secrets. */\nexport interface Env {\n /** `Records`: the records objects, one per scope. */\n readonly RECORDS: DurableObjectNamespace;\n /** `Jobs`: the job objects, one per scope and job. */\n readonly JOBS: DurableObjectNamespace;\n",
|
|
252
|
+
{
|
|
253
|
+
"slot": "bucket",
|
|
254
|
+
"text": " /** The packs' bucket, and its name, which a signed link names. */\n readonly PACKS: R2Bucket;\n readonly PACKS_BUCKET: string;\n"
|
|
255
|
+
},
|
|
256
|
+
" /** Signs in as the admin, who makes repos and tokens and never pushes. */\n readonly ADMIN_TOKEN: string;\n",
|
|
257
|
+
{
|
|
258
|
+
"slot": "signing",
|
|
259
|
+
"text": " /** R2's S3 credentials for the packs' bucket: with all three, a large push uploads its pack. */\n readonly R2_ACCOUNT_ID?: string;\n readonly R2_ACCESS_KEY_ID?: string;\n readonly R2_SECRET_ACCESS_KEY?: string;\n"
|
|
260
|
+
},
|
|
261
|
+
"}\n"
|
|
262
|
+
],
|
|
263
|
+
workerWrangler: [
|
|
264
|
+
"// Git on Cloudflare: one Worker and its two ",
|
|
265
|
+
{
|
|
266
|
+
"slot": "about",
|
|
267
|
+
"text": "Durable Object classes, and an R2 bucket"
|
|
268
|
+
},
|
|
269
|
+
". Written by\n// `ref0-git init`. `ADMIN_TOKEN` is its one secret: `wrangler secret put ADMIN_TOKEN`.\n",
|
|
270
|
+
{
|
|
271
|
+
"slot": "signing",
|
|
272
|
+
"text": "// With R2's S3 credentials too, as the secrets `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID` and\n// `R2_SECRET_ACCESS_KEY`, a large push uploads its pack to the bucket in parts.\n"
|
|
273
|
+
},
|
|
274
|
+
"// A request may use five minutes of CPU, Workers' most: a clone takes up to 0.2 s of it a MiB.\n{\n",
|
|
275
|
+
{
|
|
276
|
+
"slot": "name",
|
|
277
|
+
"text": " \"name\": \"git\","
|
|
278
|
+
},
|
|
279
|
+
"\n \"main\": \"src/worker.ts\",\n \"limits\": { \"cpu_ms\": 300000 },\n \"compatibility_date\": \"2026-11-01\",\n \"durable_objects\": {\n \"bindings\": [\n { \"name\": \"RECORDS\", \"class_name\": \"Records\" },\n { \"name\": \"JOBS\", \"class_name\": \"Jobs\" },\n ],\n },\n",
|
|
280
|
+
{
|
|
281
|
+
"slot": "bucket",
|
|
282
|
+
"text": " \"r2_buckets\": [{ \"binding\": \"PACKS\", \"bucket_name\": \"git-packs\" }],\n"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"slot": "vars",
|
|
286
|
+
"text": " \"vars\": { \"PACKS_BUCKET\": \"git-packs\" },\n"
|
|
287
|
+
},
|
|
288
|
+
" \"migrations\": [{ \"tag\": \"v1\", \"new_sqlite_classes\": [\"Records\", \"Jobs\"] }],\n}\n"
|
|
289
|
+
],
|
|
290
|
+
platforms: {
|
|
291
|
+
"cloudflare": {
|
|
292
|
+
"secrets": ["ADMIN_TOKEN", "SESSION_SECRET"],
|
|
293
|
+
"bound": [
|
|
294
|
+
"RECORDS",
|
|
295
|
+
"JOBS",
|
|
296
|
+
"PACKS",
|
|
297
|
+
"PACKS_BUCKET",
|
|
298
|
+
"AUTH_DB",
|
|
299
|
+
"APP_ORIGIN"
|
|
300
|
+
],
|
|
301
|
+
"optional": [
|
|
302
|
+
"SIGN_UP",
|
|
303
|
+
"R2_ACCOUNT_ID",
|
|
304
|
+
"R2_ACCESS_KEY_ID",
|
|
305
|
+
"R2_SECRET_ACCESS_KEY"
|
|
306
|
+
],
|
|
307
|
+
"signing": [
|
|
308
|
+
"R2_ACCOUNT_ID",
|
|
309
|
+
"R2_ACCESS_KEY_ID",
|
|
310
|
+
"R2_SECRET_ACCESS_KEY"
|
|
311
|
+
],
|
|
312
|
+
"dev": ["DEMO_PASSWORD"],
|
|
313
|
+
"secretFile": ".dev.vars",
|
|
314
|
+
"database": {
|
|
315
|
+
"binding": "AUTH_DB",
|
|
316
|
+
"migrations": "migrations/sql"
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"node": {
|
|
320
|
+
"required": [
|
|
321
|
+
"ADMIN_TOKEN",
|
|
322
|
+
"SESSION_SECRET",
|
|
323
|
+
"APP_ORIGIN"
|
|
324
|
+
],
|
|
325
|
+
"secrets": ["ADMIN_TOKEN", "SESSION_SECRET"],
|
|
326
|
+
"optional": ["SIGN_UP", "CLIENT_IP_HEADER"],
|
|
327
|
+
"dev": ["DEMO_PASSWORD"],
|
|
328
|
+
"secretFile": ".env",
|
|
329
|
+
"database": {
|
|
330
|
+
"file": ".data/auth.db",
|
|
331
|
+
"migrations": "migrations"
|
|
332
|
+
},
|
|
333
|
+
"entry": "src/server.ts",
|
|
334
|
+
"jobs": "server/plugins/jobs.ts"
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
appYours: [
|
|
338
|
+
["`src/policy.ts`", "Who may read and write what: by default, anyone reads a public repo, a person writes under their own login, an org's members write under its login, and a repo is made only under a login someone holds"],
|
|
339
|
+
["`src/git.ts`", "Git's options: each repo's `main` has a merge queue beside the merge button, and the checks the queue waits on"],
|
|
340
|
+
["`wrangler.jsonc`", "The Worker's name, its two Durable Object classes, its R2 bucket, its D1, `APP_ORIGIN` and `SIGN_UP`"]
|
|
341
|
+
]
|
|
342
|
+
};
|
|
343
|
+
export { templates_default as default };
|