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,148 @@
|
|
|
1
|
+
import { githubRoutes } from "./github-routes.mjs";
|
|
2
|
+
// src/init/routes.ts
|
|
3
|
+
const all = [
|
|
4
|
+
"DELETE",
|
|
5
|
+
"GET",
|
|
6
|
+
"HEAD",
|
|
7
|
+
"PATCH",
|
|
8
|
+
"POST",
|
|
9
|
+
"PUT"
|
|
10
|
+
];
|
|
11
|
+
/** The server module's export Git's route calls, and the words for what it serves, by `--serve`. */
|
|
12
|
+
const served = {
|
|
13
|
+
github: {
|
|
14
|
+
calls: "serve",
|
|
15
|
+
says: "the drop-in's links, REST, then Git's protocol and sign-in"
|
|
16
|
+
},
|
|
17
|
+
api: {
|
|
18
|
+
calls: "rest",
|
|
19
|
+
says: "REST, then Git's protocol and sign-in"
|
|
20
|
+
},
|
|
21
|
+
git: {
|
|
22
|
+
calls: "git",
|
|
23
|
+
says: "Git's protocol and sign-in"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** Whether `route` is a root `.git` URL, `gh repo clone`'s, rather than one of the drop-in's prefixes. */
|
|
27
|
+
const rootGit = (route) => route.path.startsWith(":owner/:repo.git/");
|
|
28
|
+
/** The drop-in's prefixes at the root, as `@ref0/github`'s list has them: `api/v3` and the rest. */
|
|
29
|
+
const dropInPrefixes = githubRoutes.filter((route) => !rootGit(route));
|
|
30
|
+
/** The root `.git` endings the drop-in takes, after `/<owner>/<repo>.git/`, as the list has them. */
|
|
31
|
+
const rootGitEndings = githubRoutes.filter(rootGit).map((route) => ({
|
|
32
|
+
...route,
|
|
33
|
+
end: route.path.slice(17)
|
|
34
|
+
}));
|
|
35
|
+
/**
|
|
36
|
+
* The root `.git` endings as one alternation, in a pattern's words: its `slash`, and what follows
|
|
37
|
+
* a slash for one segment or more: `info/lfs/.*` for a Next.js source, `info\/lfs\/.+` in a regex.
|
|
38
|
+
*/
|
|
39
|
+
const rootGitPattern = (form) => rootGitEndings.map((ending) => {
|
|
40
|
+
return `${ending.end.replaceAll("/", form.slash)}${{
|
|
41
|
+
none: "",
|
|
42
|
+
segment: `${form.slash}[^/]+`,
|
|
43
|
+
rest: `${form.slash}${form.more}`,
|
|
44
|
+
optional: `(?:${form.slash}.*)?`
|
|
45
|
+
}[ending.tail]}`;
|
|
46
|
+
}).join("|");
|
|
47
|
+
/** What each drop-in route's file says it serves, by its path: a route the list adds says the general words. */
|
|
48
|
+
const dropInSays = /* @__PURE__ */ new Map([
|
|
49
|
+
["api/v3", "GitHub's REST, where `gh` and Octokit look for it."],
|
|
50
|
+
["api/graphql", "GitHub's GraphQL, where `gh` looks for it."],
|
|
51
|
+
["api/uploads", "Release asset uploads, as GitHub's uploads host takes them."],
|
|
52
|
+
["avatars/u", "An account's default avatar, as GitHub serves it."]
|
|
53
|
+
]);
|
|
54
|
+
/** Git's route under the base path, and with `--serve github` the drop-in's at the root. */
|
|
55
|
+
const gitRoutes = (choices) => {
|
|
56
|
+
const base = choices.basePath.replace(/^\/|\/$/g, "");
|
|
57
|
+
const git = {
|
|
58
|
+
at: base,
|
|
59
|
+
tail: "rest",
|
|
60
|
+
says: `Git's URLs under \`/${base}\`: ${served[choices.serve].says}.`,
|
|
61
|
+
calls: served[choices.serve].calls,
|
|
62
|
+
methods: all
|
|
63
|
+
};
|
|
64
|
+
if (choices.serve !== "github") return [git];
|
|
65
|
+
return [git, ...dropInPrefixes.map((route) => ({
|
|
66
|
+
at: route.path,
|
|
67
|
+
tail: route.tail,
|
|
68
|
+
says: dropInSays.get(route.path) ?? "The drop-in's own URL, as GitHub serves it.",
|
|
69
|
+
calls: "github",
|
|
70
|
+
methods: route.methods
|
|
71
|
+
}))];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The matcher a mount beside an app calls for each `--serve`, and its package: the path Git, or
|
|
75
|
+
* the drop-in, answers a URL at, or `undefined` for the app's.
|
|
76
|
+
*/
|
|
77
|
+
const pathMatchers = {
|
|
78
|
+
github: {
|
|
79
|
+
name: "githubPathOf",
|
|
80
|
+
from: "@ref0/github"
|
|
81
|
+
},
|
|
82
|
+
api: {
|
|
83
|
+
name: "gitPathOf",
|
|
84
|
+
from: "@ref0/git"
|
|
85
|
+
},
|
|
86
|
+
git: {
|
|
87
|
+
name: "gitPathOf",
|
|
88
|
+
from: "@ref0/git"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/** The base path as a matcher takes it, with no trailing slash: `''` for the root. */
|
|
92
|
+
const matcherBase = (choices) => choices.basePath.replace(/\/$/, "");
|
|
93
|
+
/**
|
|
94
|
+
* A mount's call of its matcher over the URL `url`, as printed source: the path Git, or the
|
|
95
|
+
* drop-in, answers it at, or `undefined` for the app's.
|
|
96
|
+
*/
|
|
97
|
+
const matcherCall = (choices) => `${pathMatchers[choices.serve].name}(url, '${matcherBase(choices)}')`;
|
|
98
|
+
/** The server module's export a mount beside an app hands Git's URLs to, by `--serve`. */
|
|
99
|
+
const servedBy = (choices) => served[choices.serve].calls;
|
|
100
|
+
/**
|
|
101
|
+
* Git's routes in a framework that routes by its files, Astro or React Router, which have no
|
|
102
|
+
* rewrite of Next.js's or reroute of SvelteKit's: with `--serve github`, `gh`'s root Git URLs too,
|
|
103
|
+
* `/<owner>/<repo>.git/` then Smart HTTP's or LFS's ending, as `@ref0/github`'s `urls.ts` matches
|
|
104
|
+
* them, which Git answers at its own URL under the base path. A server's other paths under `.git/`
|
|
105
|
+
* stay its own. `:repo.git` is the parameter `repo`, then `.git`.
|
|
106
|
+
*/
|
|
107
|
+
const fileRoutes = (choices) => {
|
|
108
|
+
if (choices.serve !== "github") return gitRoutes(choices);
|
|
109
|
+
return [...gitRoutes(choices), ...rootGitEndings.map((ending) => ({
|
|
110
|
+
at: ending.path,
|
|
111
|
+
tail: ending.tail,
|
|
112
|
+
says: `gh's Git URLs at the root, which Git answers as its own under \`${choices.basePath}\`.`,
|
|
113
|
+
calls: "serve",
|
|
114
|
+
methods: ending.methods
|
|
115
|
+
}))];
|
|
116
|
+
};
|
|
117
|
+
/** `to`'s import specifier from the file at `from`, both from the project's root: relative, with no `.ts`. */
|
|
118
|
+
const importOf = (from, to) => {
|
|
119
|
+
const here = from.split("/").slice(0, -1);
|
|
120
|
+
const there = to.replace(/\.ts$/, "").split("/");
|
|
121
|
+
const differs = here.findIndex((part, at) => part !== there[at]);
|
|
122
|
+
const shared = differs === -1 ? here.length : differs;
|
|
123
|
+
const ups = here.length - shared;
|
|
124
|
+
return `${ups === 0 ? "./" : "../".repeat(ups)}${there.slice(shared).join("/")}`;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* A route file's handler, `git`, over the server module at `module`, as printed source. The
|
|
128
|
+
* matcher names the path Git answers the URL the framework parsed at, its dot segments resolved,
|
|
129
|
+
* so a route's own pattern never decides, and Git answers in place there: no 308 for `gh`'s root
|
|
130
|
+
* URLs. A path the matcher names no Git path for gets a 404. The module loads on the first
|
|
131
|
+
* request, since a framework's build loads each route module, and one that imported the server
|
|
132
|
+
* module at its top would open the database and want `ADMIN_TOKEN` then.
|
|
133
|
+
*/
|
|
134
|
+
const routeHandler = (choices, file, module) => [
|
|
135
|
+
"const git = async (request: Request) => {",
|
|
136
|
+
" const url = new URL(request.url);",
|
|
137
|
+
` const path = ${matcherCall(choices)};`,
|
|
138
|
+
" if (path === undefined) return new Response(null, { status: 404 });",
|
|
139
|
+
"",
|
|
140
|
+
" url.pathname = path;",
|
|
141
|
+
` const { ${servedBy(choices)} } = await import('${importOf(file, module)}');`,
|
|
142
|
+
"",
|
|
143
|
+
` return ${servedBy(choices)}.fetch(new Request(url, request));`,
|
|
144
|
+
"};"
|
|
145
|
+
];
|
|
146
|
+
/** The matcher's import, for a route file or a mount beside an app. */
|
|
147
|
+
const matcherImport = (choices) => `import { ${pathMatchers[choices.serve].name} } from '${pathMatchers[choices.serve].from}';`;
|
|
148
|
+
export { dropInPrefixes, fileRoutes, gitRoutes, importOf, matcherCall, matcherImport, pathMatchers, rootGitEndings, rootGitPattern, routeHandler, servedBy };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { fitted, lines } from "./files.mjs";
|
|
2
|
+
import { storePackages } from "./metadata.mjs";
|
|
3
|
+
// src/init/stores.ts
|
|
4
|
+
/** The records store, woken by the wake the platform's file declares as `wake`. */
|
|
5
|
+
const recordsPart = (records) => records === "postgres" ? {
|
|
6
|
+
external: ["import pg from 'pg';"],
|
|
7
|
+
infra: ["postgres"],
|
|
8
|
+
code: `const store = postgres(new pg.Pool({ connectionString: need('DATABASE_URL') }), { wake });`,
|
|
9
|
+
variables: ["DATABASE_URL"],
|
|
10
|
+
dependencies: [["pg", storePackages.pg]],
|
|
11
|
+
devDependencies: [["@types/pg", storePackages["@types/pg"]]]
|
|
12
|
+
} : {
|
|
13
|
+
external: ["import { createClient } from '@libsql/client';"],
|
|
14
|
+
infra: ["turso", "tursoPlatform"],
|
|
15
|
+
code: lines("// A database per repo in one Turso group, made at its first write over Turso's Platform API.", "const group = need('TURSO_GROUP');", "", "const databases = tursoPlatform({", " organization: need('TURSO_ORGANIZATION'),", " group,", " region: need('TURSO_REGION'),", " apiToken: need('TURSO_API_TOKEN'),", "});", "", "const store = turso({", " group,", " databases,", " groupToken: need('TURSO_GROUP_TOKEN'),", " createClient,", " wake,", "});"),
|
|
16
|
+
variables: [
|
|
17
|
+
"TURSO_ORGANIZATION",
|
|
18
|
+
"TURSO_GROUP",
|
|
19
|
+
"TURSO_REGION",
|
|
20
|
+
"TURSO_API_TOKEN",
|
|
21
|
+
"TURSO_GROUP_TOKEN"
|
|
22
|
+
],
|
|
23
|
+
dependencies: [["@libsql/client", storePackages["@libsql/client"]]],
|
|
24
|
+
devDependencies: []
|
|
25
|
+
};
|
|
26
|
+
/** An S3 bucket, whose keys `s3()` reads from the environment itself. */
|
|
27
|
+
const s3Part = {
|
|
28
|
+
external: [],
|
|
29
|
+
infra: ["s3"],
|
|
30
|
+
code: lines("// s3() reads AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY itself.", "const bucket = s3({", " endpoint: need('S3_ENDPOINT'),", " region: need('S3_REGION'),", " bucket: need('S3_BUCKET'),", "});"),
|
|
31
|
+
variables: [
|
|
32
|
+
"S3_ENDPOINT",
|
|
33
|
+
"S3_REGION",
|
|
34
|
+
"S3_BUCKET",
|
|
35
|
+
"AWS_ACCESS_KEY_ID",
|
|
36
|
+
"AWS_SECRET_ACCESS_KEY"
|
|
37
|
+
],
|
|
38
|
+
dependencies: [],
|
|
39
|
+
devDependencies: []
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The server module's `need()`, which every part reads its variables through: an empty value, as
|
|
43
|
+
* a `NAME=` line leaves it, reads as unset. `where` says where the person sets them, a phrase the
|
|
44
|
+
* platform's file picks, never a flag's or a file's text.
|
|
45
|
+
*/
|
|
46
|
+
const needHelper = (where) => lines(`/** A variable the project sets, in ${where}. */`, "const need = (name: string) => {", " const value = process.env[name];", fitted(" if (value === undefined || value === '')", `throw new Error(\`Set \${name} in ${where}\`);`), "", " return value;", "};");
|
|
47
|
+
/** `.env.example`: `header`'s comment lines, then each of `variables` with an empty value. */
|
|
48
|
+
const envExample = (header, variables) => lines(...header.map((line) => `# ${line}`), ...variables.map((name) => `${name}=`), "");
|
|
49
|
+
/** The variables `parts` read, in order, which the person sets: an Output's `needs`. */
|
|
50
|
+
const needsOf = (parts) => parts.flatMap((part) => part.variables);
|
|
51
|
+
export { envExample, needHelper, needsOf, recordsPart, s3Part };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { lines } from "./files.mjs";
|
|
2
|
+
import { parseJsonc, stringAt, withEntries } from "./jsonc.mjs";
|
|
3
|
+
import { gitRoutes, rootGitPattern } from "./routes.mjs";
|
|
4
|
+
// src/init/sveltekit.ts
|
|
5
|
+
/**
|
|
6
|
+
* What `init` writes in a SvelteKit project on Node, under adapter-node: a `+server.ts` for Git's
|
|
7
|
+
* URLs under the base path and one for each of the drop-in's paths at the root, `hooks.server.ts`
|
|
8
|
+
* to start the jobs, and `hooks.ts`'s `reroute` for `gh`'s root Git URLs. Each route loads the
|
|
9
|
+
* server module on its first request: `vite build` loads every route to read its options.
|
|
10
|
+
*/
|
|
11
|
+
/** `to`'s import specifier from the file at `from`: relative, as Vite resolves it with its `.ts`. */
|
|
12
|
+
const importOf = (from, to) => {
|
|
13
|
+
const ups = from.split("/").length - 2;
|
|
14
|
+
return `${ups === 0 ? "./" : "../".repeat(ups)}${to.replace(/^src\//, "")}`;
|
|
15
|
+
};
|
|
16
|
+
/** SvelteKit's folders for each parameter a route ends with: a rest parameter matches no segment too. */
|
|
17
|
+
const svelteTails = {
|
|
18
|
+
rest: "[...path]/",
|
|
19
|
+
optional: "[...path]/",
|
|
20
|
+
segment: "[id]/",
|
|
21
|
+
none: ""
|
|
22
|
+
};
|
|
23
|
+
/** SvelteKit's route files for `choices`, over `framework`'s server module. */
|
|
24
|
+
const svelteRouteFiles = (choices, framework) => gitRoutes(choices).map((route) => {
|
|
25
|
+
const path = `src/routes/${route.at}/${svelteTails[route.tail]}+server.ts`;
|
|
26
|
+
return {
|
|
27
|
+
path,
|
|
28
|
+
kind: "whole",
|
|
29
|
+
text: lines(`// ${route.says} Written by \`ref0-git init\`.`, "import type { RequestHandler } from './$types';", "", "// Loaded on the first request, so `vite build`, which loads each route to read its options, opens", "// no database and needs no secret.", "const git: RequestHandler = async ({ request }) => {", ` const { ${route.calls} } = await import('${importOf(path, framework.serverModule)}');`, "", ` return ${route.calls}.fetch(request);`, "};", "", `export { ${route.methods.map((method) => `git as ${method}`).join(", ")} };`, "")
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
/** What the `init` hook names: Kit's type and `building`, which keeps it out of a build. */
|
|
33
|
+
const initImports = ["import type { ServerInit } from '@sveltejs/kit/hooks';", "import { building } from '$app/env';"];
|
|
34
|
+
/** The `init` hook's body, which starts Git's jobs once in each server process, never in a build. */
|
|
35
|
+
const initLines = (framework) => [
|
|
36
|
+
"export const init: ServerInit = async () => {",
|
|
37
|
+
" if (building) return;",
|
|
38
|
+
"",
|
|
39
|
+
` const { jobs } = await import('${importOf("src/hooks.server.ts", framework.serverModule)}');`,
|
|
40
|
+
" jobs.start();",
|
|
41
|
+
"};"
|
|
42
|
+
];
|
|
43
|
+
/** `src/hooks.server.ts`, where the project has none. */
|
|
44
|
+
const svelteServerHooks = (framework) => lines("// Starts Git's jobs once in each SvelteKit server process. Written by `ref0-git init`.", ...initImports, "", ...initLines(framework), "");
|
|
45
|
+
/** The `init` hook as a step in the person's own `hooks.server.*`: its imports, then the hook. */
|
|
46
|
+
const svelteInitLines = (framework) => [
|
|
47
|
+
...initImports,
|
|
48
|
+
"",
|
|
49
|
+
...initLines(framework)
|
|
50
|
+
];
|
|
51
|
+
const rerouteImports = ["import type { Reroute } from '@sveltejs/kit/hooks';"];
|
|
52
|
+
/**
|
|
53
|
+
* `gh`'s root Git URLs, `/<owner>/<repo>.git/` then Smart HTTP's or LFS's ending, as
|
|
54
|
+
* `@ref0/github`'s `urls.ts` matches them, rerouted to Git's route under the base path. `reroute`
|
|
55
|
+
* changes only the path SvelteKit routes by: the route gets the request as it came, query kept, and
|
|
56
|
+
* the drop-in answers its root URL with a 308 under the base path, or, for an LFS POST, in place.
|
|
57
|
+
*/
|
|
58
|
+
const rerouteLines = (choices) => [
|
|
59
|
+
"const gitRoot =",
|
|
60
|
+
` /^\\/[^/]+\\/[^/]+\\.git\\/(${rootGitPattern({
|
|
61
|
+
slash: "\\/",
|
|
62
|
+
more: ".+"
|
|
63
|
+
})})$/;`,
|
|
64
|
+
"",
|
|
65
|
+
"export const reroute: Reroute = ({ url }) =>",
|
|
66
|
+
` gitRoot.test(url.pathname) ? \`${choices.basePath.replace(/\/$/, "")}\${url.pathname}\` : undefined;`
|
|
67
|
+
];
|
|
68
|
+
/** The reroute as a step in the person's own `hooks.*`: its import, then `reroute`. */
|
|
69
|
+
const svelteRerouteLines = (choices) => [
|
|
70
|
+
...rerouteImports,
|
|
71
|
+
"",
|
|
72
|
+
...rerouteLines(choices)
|
|
73
|
+
];
|
|
74
|
+
/** `src/hooks.ts`, where the project has none. */
|
|
75
|
+
const svelteHooks = (choices) => lines("// gh's Git URLs at the root, `/<owner>/<repo>.git/…`, to Git's route. Written by `ref0-git init`.", ...rerouteImports, "", ...rerouteLines(choices), "");
|
|
76
|
+
/**
|
|
77
|
+
* The adapter `sv create` imports in its `vite.config.ts`: `init` swaps it for adapter-node, whose
|
|
78
|
+
* server runs Git's jobs between requests, in the file the create command actually wrote, when the
|
|
79
|
+
* import is in it exactly once.
|
|
80
|
+
*/
|
|
81
|
+
const svelteAdapterAnchor = "'@sveltejs/adapter-auto'";
|
|
82
|
+
/** What the anchor becomes: adapter-node's import. */
|
|
83
|
+
const svelteNodeAdapter = "'@sveltejs/adapter-node'";
|
|
84
|
+
/** `text` on adapter-node, or `undefined` where its adapter-auto import isn't there exactly once. */
|
|
85
|
+
const onAdapterNode = (text) => {
|
|
86
|
+
const at = text.indexOf(svelteAdapterAnchor);
|
|
87
|
+
if (at === -1 || text.includes("'@sveltejs/adapter-auto'", at + 1)) return void 0;
|
|
88
|
+
return `${text.slice(0, at)}${svelteNodeAdapter}${text.slice(at + 24)}`;
|
|
89
|
+
};
|
|
90
|
+
/** adapter-node's limit, 512 KB by default for every route, lifted so a push of any size gets in. */
|
|
91
|
+
const bodySizeLimit = "BODY_SIZE_LIMIT=Infinity";
|
|
92
|
+
/**
|
|
93
|
+
* SvelteKit's `start`, the one framework start `init` writes. adapter-node reads `BODY_SIZE_LIMIT`
|
|
94
|
+
* as its handler loads, before `server.init` runs the hook that imports the server module, which
|
|
95
|
+
* loads `.env`: only Node's own `--env-file` reaches it in time.
|
|
96
|
+
*/
|
|
97
|
+
const svelteStart = "node --env-file-if-exists=.env build";
|
|
98
|
+
/** `package.json`'s `start`, or `undefined`. */
|
|
99
|
+
const startOf = (packageJson) => packageJson === void 0 ? void 0 : stringAt(parseJsonc(packageJson), ["scripts", "start"]);
|
|
100
|
+
/** `package.json` with SvelteKit's `start`, where it has none. */
|
|
101
|
+
const withSvelteStart = (text) => withEntries(text, ["scripts"], { start: svelteStart });
|
|
102
|
+
/** The step for the person's own `start`, where it neither loads `.env` nor sets the limit. */
|
|
103
|
+
const svelteStartStep = (packageJson) => {
|
|
104
|
+
const start = startOf(packageJson);
|
|
105
|
+
if (start === void 0 || /--env-file|\bBODY_SIZE_LIMIT=/.test(start)) return [];
|
|
106
|
+
return [{
|
|
107
|
+
path: "package.json",
|
|
108
|
+
why: "yours",
|
|
109
|
+
says: "Load .env in your start script: adapter-node reads BODY_SIZE_LIMIT before Git's module loads .env",
|
|
110
|
+
lines: [`"start": "${svelteStart}"`]
|
|
111
|
+
}];
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Where `node build`, as `npm start` runs it, gets `BODY_SIZE_LIMIT=Infinity`, or `undefined` where
|
|
115
|
+
* it keeps a limit. The value it reads is the first of the `start` script's own assignment, the
|
|
116
|
+
* environment, which `--env-file` never overrides, and the env file the script loads. `.env`
|
|
117
|
+
* alone counts for nothing: the server module loads it too late.
|
|
118
|
+
*/
|
|
119
|
+
const svelteBodyLimit = (read, env) => {
|
|
120
|
+
const start = startOf(read("package.json")) ?? "";
|
|
121
|
+
const file = /--env-file(?:-if-exists)?[= ](\S+)/.exec(start)?.[1];
|
|
122
|
+
const inFile = file === void 0 ? void 0 : /^BODY_SIZE_LIMIT=(.*)$/m.exec(read(file) ?? "")?.[1];
|
|
123
|
+
const seen = [
|
|
124
|
+
{
|
|
125
|
+
from: "package.json's start script",
|
|
126
|
+
value: /\bBODY_SIZE_LIMIT=(\S+)/.exec(start)?.[1]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
from: "The environment",
|
|
130
|
+
value: env["BODY_SIZE_LIMIT"]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
from: `${file ?? ""}, which the start script loads,`,
|
|
134
|
+
value: inFile
|
|
135
|
+
}
|
|
136
|
+
].find((each) => each.value !== void 0);
|
|
137
|
+
return seen?.value === "Infinity" ? seen.from : void 0;
|
|
138
|
+
};
|
|
139
|
+
export { bodySizeLimit, onAdapterNode, svelteAdapterAnchor, svelteBodyLimit, svelteHooks, svelteInitLines, svelteNodeAdapter, svelteRerouteLines, svelteRouteFiles, svelteServerHooks, svelteStart, svelteStartStep, withSvelteStart };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import templates_default from "./templates.mjs";
|
|
2
|
+
import * as Predicate from "effect/Predicate";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
// src/init/template.ts
|
|
5
|
+
/** A template's decoder, its slots' names those `names` lists, so a renamed slot fails to load. */
|
|
6
|
+
const templateOf = (names) => Schema.Array(Schema.Union([Schema.String, Schema.Struct({
|
|
7
|
+
slot: Schema.Literals(names),
|
|
8
|
+
text: Schema.String
|
|
9
|
+
})]));
|
|
10
|
+
/** The slots of the app's `src/git.ts` on Cloudflare: the store's and the queue's. */
|
|
11
|
+
const appGitSlots = [
|
|
12
|
+
"gitImport",
|
|
13
|
+
"queueTypes",
|
|
14
|
+
"infraImport",
|
|
15
|
+
"safety",
|
|
16
|
+
"bucket",
|
|
17
|
+
"adapterAbout",
|
|
18
|
+
"adapterBucket",
|
|
19
|
+
"queueMerge",
|
|
20
|
+
"objects",
|
|
21
|
+
"uploads",
|
|
22
|
+
"queue"
|
|
23
|
+
];
|
|
24
|
+
/** The slots of the app's `src/git.ts` on Node: Node's head and parts, the store's and the queue's. */
|
|
25
|
+
const appGitNodeSlots = [
|
|
26
|
+
"head",
|
|
27
|
+
"queueMerge",
|
|
28
|
+
"objects",
|
|
29
|
+
"uploads",
|
|
30
|
+
"queue",
|
|
31
|
+
"engine",
|
|
32
|
+
"database",
|
|
33
|
+
"ipHeader",
|
|
34
|
+
"classes"
|
|
35
|
+
];
|
|
36
|
+
/** The slots of the app's `src/env.ts`, and the example Worker's. */
|
|
37
|
+
const appEnvSlots = [
|
|
38
|
+
"types",
|
|
39
|
+
"bucket",
|
|
40
|
+
"signing"
|
|
41
|
+
];
|
|
42
|
+
/** The slots of the app's `wrangler.jsonc`. */
|
|
43
|
+
const appWranglerSlots = [
|
|
44
|
+
"about",
|
|
45
|
+
"signing",
|
|
46
|
+
"name",
|
|
47
|
+
"vars",
|
|
48
|
+
"bucket",
|
|
49
|
+
"database"
|
|
50
|
+
];
|
|
51
|
+
/** The slots of the example Worker's `src/git.ts`: what it serves, the store's and the queue's. */
|
|
52
|
+
const workerGitSlots = [
|
|
53
|
+
"header",
|
|
54
|
+
"gitImports",
|
|
55
|
+
"infraImport",
|
|
56
|
+
"envFile",
|
|
57
|
+
"safety",
|
|
58
|
+
"bucket",
|
|
59
|
+
"adapterBucket",
|
|
60
|
+
"merge",
|
|
61
|
+
"objects",
|
|
62
|
+
"uploads",
|
|
63
|
+
"basePath",
|
|
64
|
+
"queue",
|
|
65
|
+
"events",
|
|
66
|
+
"github",
|
|
67
|
+
"rest"
|
|
68
|
+
];
|
|
69
|
+
/** The slots of the example Worker's `src/worker.ts`: what it serves. */
|
|
70
|
+
const workerEntrySlots = ["names", "exports"];
|
|
71
|
+
/** The slots of the example Worker's `src/env.ts`. */
|
|
72
|
+
const workerEnvSlots = [
|
|
73
|
+
"types",
|
|
74
|
+
"bucket",
|
|
75
|
+
"signing"
|
|
76
|
+
];
|
|
77
|
+
/** The slots of the example Worker's `wrangler.jsonc`. */
|
|
78
|
+
const workerWranglerSlots = [
|
|
79
|
+
"about",
|
|
80
|
+
"signing",
|
|
81
|
+
"name",
|
|
82
|
+
"bucket",
|
|
83
|
+
"vars"
|
|
84
|
+
];
|
|
85
|
+
const Names = Schema.Array(Schema.String);
|
|
86
|
+
/** What the app needs on each platform, as `apps/github/src/platform.ts` says: `doctor` checks it. */
|
|
87
|
+
const Platforms = Schema.Struct({
|
|
88
|
+
cloudflare: Schema.Struct({
|
|
89
|
+
secrets: Names,
|
|
90
|
+
bound: Names,
|
|
91
|
+
optional: Names,
|
|
92
|
+
signing: Names,
|
|
93
|
+
dev: Names,
|
|
94
|
+
secretFile: Schema.String,
|
|
95
|
+
database: Schema.Struct({
|
|
96
|
+
binding: Schema.String,
|
|
97
|
+
migrations: Schema.String
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
node: Schema.Struct({
|
|
101
|
+
required: Names,
|
|
102
|
+
secrets: Names,
|
|
103
|
+
optional: Names,
|
|
104
|
+
dev: Names,
|
|
105
|
+
secretFile: Schema.String,
|
|
106
|
+
database: Schema.Struct({
|
|
107
|
+
file: Schema.String,
|
|
108
|
+
migrations: Schema.String
|
|
109
|
+
}),
|
|
110
|
+
entry: Schema.String,
|
|
111
|
+
jobs: Schema.String
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
const Templates = Schema.Struct({
|
|
115
|
+
appGit: templateOf(appGitSlots),
|
|
116
|
+
appGitNode: templateOf(appGitNodeSlots),
|
|
117
|
+
appEnv: templateOf(appEnvSlots),
|
|
118
|
+
appWrangler: templateOf(appWranglerSlots),
|
|
119
|
+
appConfigs: Schema.Record(Schema.String, Schema.String),
|
|
120
|
+
nodeServer: Schema.String,
|
|
121
|
+
nodeConfigs: Schema.Record(Schema.String, Schema.String),
|
|
122
|
+
nodeServerConfig: Schema.String,
|
|
123
|
+
nodeVite: Schema.String,
|
|
124
|
+
workerGit: templateOf(workerGitSlots),
|
|
125
|
+
workerEntry: templateOf(workerEntrySlots),
|
|
126
|
+
workerEnv: templateOf(workerEnvSlots),
|
|
127
|
+
workerWrangler: templateOf(workerWranglerSlots),
|
|
128
|
+
platforms: Platforms,
|
|
129
|
+
appYours: Schema.Array(Schema.Tuple([Schema.String, Schema.String]))
|
|
130
|
+
});
|
|
131
|
+
/** The templates, as the pack wrote them. */
|
|
132
|
+
const templates = Schema.decodeUnknownSync(Templates)(templates_default);
|
|
133
|
+
/** What the app needs on each platform, which `doctor` checks a setup for. */
|
|
134
|
+
const { platforms } = templates;
|
|
135
|
+
/**
|
|
136
|
+
* `template`'s text, each slot `slots` gives a text filled with it, and each it leaves `undefined`
|
|
137
|
+
* or out as its source has it.
|
|
138
|
+
*/
|
|
139
|
+
const filled = (template, slots) => template.map((piece) => Predicate.isString(piece) ? piece : slots[piece.slot] ?? piece.text).join("");
|
|
140
|
+
/** What a slot holds for a choice the source didn't make: `text`, else `undefined`, the source's own. */
|
|
141
|
+
const unless = (made, text) => made ? void 0 : text;
|
|
142
|
+
export { appEnvSlots, appGitNodeSlots, appGitSlots, appWranglerSlots, filled, platforms, templates, unless, workerEntrySlots, workerEnvSlots, workerGitSlots, workerWranglerSlots };
|