ref0-git 0.0.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +127 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +562 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +487 -0
- package/app/apps/github/src/palette/server.ts +107 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +606 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +528 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +69 -0
- package/dist/cli/helpers.mjs +184 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +136 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +80 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +203 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +460 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +384 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { fitted, ignoring, lines, withCli, withDependencies, withLines } from "./files.mjs";
|
|
2
|
+
import { catalog } from "./metadata.mjs";
|
|
3
|
+
import { basePathLines, eventsLines, gitImports, gitPackages, githubHandler, header, looseObjects } from "./git-module.mjs";
|
|
4
|
+
import { itemsAt, parseJsonc, stringAt, withEntries, withValue } from "./jsonc.mjs";
|
|
5
|
+
import { filled, templates, unless } from "./template.mjs";
|
|
6
|
+
import { specOf } from "./versions.mjs";
|
|
7
|
+
import * as Redacted from "effect/Redacted";
|
|
8
|
+
// src/init/cloudflare.ts
|
|
9
|
+
/**
|
|
10
|
+
* What `init` writes for Git on Cloudflare, without the app: `src/git.ts`, the Worker's entry for
|
|
11
|
+
* its layout, the `Env` it binds, and Git's part merged into `wrangler.jsonc`, `package.json`,
|
|
12
|
+
* `.gitignore` and `.dev.vars`. Every file is a function of the choices and the layout alone, so a
|
|
13
|
+
* file that still reads as one of these can be proved untouched.
|
|
14
|
+
*/
|
|
15
|
+
/** The files that hold secrets on Cloudflare: `.gitignore` ends with them, and `init` refuses one Git tracks. */
|
|
16
|
+
const secretFiles = [".dev.vars"];
|
|
17
|
+
/** The secrets Git's Worker takes: the admin's, which signs in to make repos and tokens. */
|
|
18
|
+
const gitSecrets = ["ADMIN_TOKEN"];
|
|
19
|
+
/** The handlers an entry imports from `src/git.ts`, and how it routes to them. */
|
|
20
|
+
const routing = {
|
|
21
|
+
github: {
|
|
22
|
+
names: "github, rest",
|
|
23
|
+
first: (request) => `(await github.route(${request})) ?? (await rest.route(${request}))`
|
|
24
|
+
},
|
|
25
|
+
api: {
|
|
26
|
+
names: "rest",
|
|
27
|
+
first: (request) => `(await rest.route(${request}))`
|
|
28
|
+
},
|
|
29
|
+
git: {
|
|
30
|
+
names: "git",
|
|
31
|
+
first: (request) => `(await git.route(${request}))`
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/** The bindings and classes Git needs. */
|
|
35
|
+
const gitClasses = [{
|
|
36
|
+
name: "RECORDS",
|
|
37
|
+
class_name: "Records"
|
|
38
|
+
}, {
|
|
39
|
+
name: "JOBS",
|
|
40
|
+
class_name: "Jobs"
|
|
41
|
+
}];
|
|
42
|
+
/** The infra import of a `src/git.ts` with no bucket. */
|
|
43
|
+
const looseInfraImport = "import { cloudflare, jobObject, recordsObject } from '@ref0/infra/cloudflare';";
|
|
44
|
+
/** The end of a `src/git.ts`'s adapter with no bucket. */
|
|
45
|
+
const looseAdapterEnd = "jobs: env.JOBS });";
|
|
46
|
+
/** `src/git.ts`: `examples/git-worker`'s own, with what it serves, the store and the queue as chosen. */
|
|
47
|
+
const gitModule = (choices, envFile) => {
|
|
48
|
+
const packs = choices.objects === "packs";
|
|
49
|
+
const queue = choices.queue === "on";
|
|
50
|
+
const github = choices.serve === "github";
|
|
51
|
+
const xdiff = {
|
|
52
|
+
line: "import xdiff from '@ref0/git/xdiff.wasm';",
|
|
53
|
+
last: true
|
|
54
|
+
};
|
|
55
|
+
const basePath = basePathLines(choices);
|
|
56
|
+
return filled(templates.workerGit, {
|
|
57
|
+
header: `${header(choices, "Cloudflare")}\n`,
|
|
58
|
+
gitImports: `${gitImports(choices, xdiff)}\n`,
|
|
59
|
+
infraImport: unless(packs, looseInfraImport),
|
|
60
|
+
envFile: `'${envFile}'`,
|
|
61
|
+
safety: unless(packs, "binds the objects"),
|
|
62
|
+
bucket: unless(packs, ""),
|
|
63
|
+
adapterBucket: unless(packs, looseAdapterEnd),
|
|
64
|
+
merge: unless(queue, ""),
|
|
65
|
+
objects: unless(packs, looseObjects),
|
|
66
|
+
uploads: unless(packs, ""),
|
|
67
|
+
basePath: basePath === false ? void 0 : `${basePath}\n`,
|
|
68
|
+
queue: unless(queue, ""),
|
|
69
|
+
events: github ? `${eventsLines}\n` : void 0,
|
|
70
|
+
github: github ? `${githubHandler}\n` : void 0,
|
|
71
|
+
rest: choices.serve === "git" ? "" : void 0
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/** `src/worker.ts`'s default export, for what it serves past the example's REST. */
|
|
75
|
+
const workerExports = {
|
|
76
|
+
github: lines("/** The drop-in's URLs, then Git's REST and protocol, then a JSON `404`. */", "export default {", " fetch: async (request) => (await github.route(request)) ?? rest.fetch(request),", "} satisfies ExportedHandler<Env>;", ""),
|
|
77
|
+
git: "/** Git's protocol and sign-in, then a JSON `404`. */\nexport default { fetch: git.fetch } satisfies ExportedHandler<Env>;\n"
|
|
78
|
+
};
|
|
79
|
+
/** `src/worker.ts`, the entry of a Worker `init` writes whole: `examples/git-worker`'s own. */
|
|
80
|
+
const workerEntry = (choices) => filled(templates.workerEntry, {
|
|
81
|
+
names: `import { ${routing[choices.serve].names} } from './git.ts';`,
|
|
82
|
+
exports: choices.serve === "api" ? void 0 : workerExports[choices.serve]
|
|
83
|
+
});
|
|
84
|
+
/** `main`'s path as `src/git-entry.ts` imports it. */
|
|
85
|
+
const fromEntry = (main) => {
|
|
86
|
+
const up = main.startsWith("src/") ? main.slice(4) : `../${main}`;
|
|
87
|
+
return up.startsWith("../") ? up : `./${up}`;
|
|
88
|
+
};
|
|
89
|
+
/** `src/git-entry.ts`: an existing Worker's new `main`, which runs its own after Git's URLs. */
|
|
90
|
+
const wrappedEntry = (choices, main) => lines("// This Worker's entry, written by `ref0-git init`: Git's URLs first, then the Worker in", `// \`${main}\`, whose other exports and handlers it keeps. \`wrangler.jsonc\`'s \`main\` names it.`, `import worker from '${fromEntry(main)}';`, "", `import { ${routing[choices.serve].names} } from './git.ts';`, "", `export * from '${fromEntry(main)}';`, "", "export { Jobs, Records } from './git.ts';", "", "export default {", " ...worker,", " fetch: async (...call: Parameters<typeof worker.fetch>) =>", ` ${routing[choices.serve].first("call[0]")} ?? worker.fetch(...call),`, "};", "");
|
|
91
|
+
/** `src/server.ts`: Start's server entry, Git's URLs before the app's. */
|
|
92
|
+
const startEntry = (choices) => lines("// Start's server entry, written by `ref0-git init`: Git's URLs first, then the app.", "// `wrangler.jsonc`'s `main` names it, so the Worker exports Git's two classes too.", "import handler, { createServerEntry } from '@tanstack/react-start/server-entry';", "", `import { ${routing[choices.serve].names} } from './git.ts';`, "", "export { Jobs, Records } from './git.ts';", "", "export default createServerEntry({", fitted(" fetch: async (request) =>", `${routing[choices.serve].first("request")} ?? handler.fetch(request),`), "});", "");
|
|
93
|
+
/** `src/env.ts`, or `src/git-env.ts` beside a project's own: `examples/git-worker`'s, as the store has it. */
|
|
94
|
+
const envModule = (choices) => {
|
|
95
|
+
const packs = choices.objects === "packs";
|
|
96
|
+
return filled(templates.workerEnv, {
|
|
97
|
+
types: unless(packs, "import type { DurableObjectNamespace } from '@cloudflare/workers-types';"),
|
|
98
|
+
bucket: unless(packs, ""),
|
|
99
|
+
signing: unless(packs, "")
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const bucketName = (name) => `${name}-packs`;
|
|
103
|
+
/** `wrangler.jsonc`'s bucket line, with its newline, for a store that has one. */
|
|
104
|
+
const bucketLine = (choices, name) => choices.objects === "packs" ? ` "r2_buckets": [{ "binding": "PACKS", "bucket_name": "${bucketName(name)}" }],\n` : "";
|
|
105
|
+
/** `wrangler.jsonc` for a Worker `init` writes whole: `examples/git-worker`'s, named `name`. */
|
|
106
|
+
const wranglerConfig = (choices, name) => {
|
|
107
|
+
const packs = choices.objects === "packs";
|
|
108
|
+
return filled(templates.workerWrangler, {
|
|
109
|
+
about: unless(packs, "Durable Object classes"),
|
|
110
|
+
signing: unless(packs, ""),
|
|
111
|
+
name: ` "name": ${JSON.stringify(name)},`,
|
|
112
|
+
bucket: bucketLine(choices, name),
|
|
113
|
+
vars: packs ? ` "vars": { "PACKS_BUCKET": "${bucketName(name)}" },\n` : ""
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
/** The classes a config's migrations make, and how many migrations it has. */
|
|
117
|
+
const migrated = (text) => {
|
|
118
|
+
const migrations = itemsAt(parseJsonc(text), ["migrations"]);
|
|
119
|
+
return {
|
|
120
|
+
classes: migrations.flatMap((migration) => itemsAt(migration, ["new_sqlite_classes"]).flatMap((each) => stringAt(each, []) ?? [])),
|
|
121
|
+
tags: migrations.length
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/** The string each item of the array at `path` of a config holds at `key`. */
|
|
125
|
+
const bound = (text, path, key) => itemsAt(parseJsonc(text), path).flatMap((item) => stringAt(item, [key]) ?? []);
|
|
126
|
+
/** Each string a TOML config sets `key` to, basic or literal, on a line of its own or in an array. */
|
|
127
|
+
const tomlStrings = (text, key) => [...text.matchAll(new RegExp(`^\\s*${key}\\s*=\\s*(\\[[^\\]]*\\]|"[^"]*"|'[^']*')`, "gm"))].flatMap((line) => [...(line[1] ?? "").matchAll(/"([^"]*)"|'([^']*)'/g)].map((each) => each[1] ?? each[2] ?? ""));
|
|
128
|
+
/**
|
|
129
|
+
* What `doctor` reads of a Worker's config, `wrangler.jsonc` or `wrangler.json` as JSONC, and
|
|
130
|
+
* `wrangler.toml`, which `init` writes nothing into, by its lines: its `main`, the Durable Objects
|
|
131
|
+
* it binds, the classes its migrations make, the buckets it binds and the D1 databases it binds
|
|
132
|
+
* with their migrations.
|
|
133
|
+
*/
|
|
134
|
+
const configParts = (file, text) => file === "wrangler.toml" ? {
|
|
135
|
+
main: tomlStrings(text, "main")[0],
|
|
136
|
+
bindings: tomlStrings(text, "name"),
|
|
137
|
+
classes: tomlStrings(text, "new_sqlite_classes"),
|
|
138
|
+
buckets: tomlStrings(text, "binding"),
|
|
139
|
+
databases: []
|
|
140
|
+
} : {
|
|
141
|
+
main: stringAt(parseJsonc(text), ["main"]),
|
|
142
|
+
bindings: bound(text, ["durable_objects", "bindings"], "name"),
|
|
143
|
+
classes: migrated(text).classes,
|
|
144
|
+
buckets: bound(text, ["r2_buckets"], "binding"),
|
|
145
|
+
databases: itemsAt(parseJsonc(text), ["d1_databases"]).flatMap((item) => stringAt(item, ["migrations_dir"]) === void 0 ? [] : stringAt(item, ["binding"]) ?? [])
|
|
146
|
+
};
|
|
147
|
+
/** `text`, a Worker's config, with what Git needs of it added and its `main` set to `main`. */
|
|
148
|
+
const mergeWrangler = (text, choices, name, main) => {
|
|
149
|
+
const bindings = bound(text, ["durable_objects", "bindings"], "name");
|
|
150
|
+
const classes = gitClasses.filter((each) => !bindings.includes(each.name));
|
|
151
|
+
const { classes: done, tags } = migrated(text);
|
|
152
|
+
const unmigrated = gitClasses.flatMap((each) => done.includes(each.class_name) ? [] : [each.class_name]);
|
|
153
|
+
const steps = [(from) => withEntries(from, ["durable_objects", "bindings"], classes), (from) => unmigrated.length === 0 ? from : withEntries(from, ["migrations"], [{
|
|
154
|
+
tag: `v${tags + 1}`,
|
|
155
|
+
new_sqlite_classes: unmigrated
|
|
156
|
+
}])];
|
|
157
|
+
if (choices.objects === "packs") {
|
|
158
|
+
const held = itemsAt(parseJsonc(text), ["r2_buckets"]).find((item) => stringAt(item, ["binding"]) === "PACKS");
|
|
159
|
+
const packsBucket = stringAt(held, ["bucket_name"]) ?? bucketName(name);
|
|
160
|
+
steps.push((from) => held !== void 0 ? from : withEntries(from, ["r2_buckets"], [{
|
|
161
|
+
binding: "PACKS",
|
|
162
|
+
bucket_name: packsBucket
|
|
163
|
+
}]), (from) => withEntries(from, ["vars"], { PACKS_BUCKET: packsBucket }));
|
|
164
|
+
}
|
|
165
|
+
if (main !== void 0) steps.push((from) => withValue(from, ["main"], main));
|
|
166
|
+
return steps.reduce((from, step) => step(from), text);
|
|
167
|
+
};
|
|
168
|
+
/** The tools a Worker `init` writes whole builds with. */
|
|
169
|
+
const tools = {
|
|
170
|
+
"@cloudflare/workers-types": catalog["@cloudflare/workers-types"],
|
|
171
|
+
typescript: catalog.typescript,
|
|
172
|
+
wrangler: catalog.wrangler
|
|
173
|
+
};
|
|
174
|
+
/** `package.json` with Git's packages added where it doesn't name them. */
|
|
175
|
+
const mergePackage = (choices, name, own, vendor) => (current) => {
|
|
176
|
+
const git = Object.fromEntries(gitPackages(choices).map((each) => [each, specOf(each, vendor)]));
|
|
177
|
+
if (current === void 0) return withCli(`${JSON.stringify({
|
|
178
|
+
name,
|
|
179
|
+
private: true,
|
|
180
|
+
type: "module",
|
|
181
|
+
scripts: {
|
|
182
|
+
dev: "wrangler dev",
|
|
183
|
+
deploy: "wrangler deploy"
|
|
184
|
+
},
|
|
185
|
+
dependencies: git,
|
|
186
|
+
devDependencies: tools
|
|
187
|
+
}, null, 2)}\n`, vendor);
|
|
188
|
+
const added = withCli(withDependencies(current, git), vendor);
|
|
189
|
+
return own ? withEntries(added, ["devDependencies"], tools) : added;
|
|
190
|
+
};
|
|
191
|
+
/** `.dev.vars` with each of `names` that it doesn't set, as a secret `secret` makes. */
|
|
192
|
+
const devVars = (names, secret) => ({
|
|
193
|
+
path: ".dev.vars",
|
|
194
|
+
kind: "merge",
|
|
195
|
+
secrets: names,
|
|
196
|
+
merge: (current) => withLines(current, names.map((name) => `${name}=${Redacted.value(secret())}`), (line) => line.split("=")[0] ?? "")
|
|
197
|
+
});
|
|
198
|
+
/** Alchemy's lines for Git's part of a Worker's `env`, as the Alchemy guide gives them. */
|
|
199
|
+
const alchemyLines = (choices, _name) => [
|
|
200
|
+
" RECORDS: Cloudflare.DurableObject(\"Records\"),",
|
|
201
|
+
" JOBS: Cloudflare.DurableObject(\"Jobs\"),",
|
|
202
|
+
...choices.objects === "packs" ? [" PACKS: Cloudflare.R2.Bucket(\"Packs\"),"] : [],
|
|
203
|
+
" ADMIN_TOKEN: Config.Redacted(\"ADMIN_TOKEN\"),"
|
|
204
|
+
];
|
|
205
|
+
/** The lines a `wrangler.toml` needs, since `init` writes no TOML. */
|
|
206
|
+
const tomlLines = (choices, name) => [
|
|
207
|
+
...gitClasses.flatMap((each) => [
|
|
208
|
+
"[[durable_objects.bindings]]",
|
|
209
|
+
`name = "${each.name}"`,
|
|
210
|
+
`class_name = "${each.class_name}"`
|
|
211
|
+
]),
|
|
212
|
+
...choices.objects === "packs" ? [
|
|
213
|
+
"[[r2_buckets]]",
|
|
214
|
+
"binding = \"PACKS\"",
|
|
215
|
+
`bucket_name = "${bucketName(name)}"`,
|
|
216
|
+
"[vars]",
|
|
217
|
+
`PACKS_BUCKET = "${bucketName(name)}"`
|
|
218
|
+
] : [],
|
|
219
|
+
"[[migrations]]",
|
|
220
|
+
"tag = \"git-v1\"",
|
|
221
|
+
"new_sqlite_classes = [\"Records\", \"Jobs\"]"
|
|
222
|
+
];
|
|
223
|
+
/** What a Worker's own entry needs, to answer Git's URLs first and export its classes. */
|
|
224
|
+
const entryLines = (choices, _name) => [
|
|
225
|
+
`import { ${routing[choices.serve].names} } from './git.ts';`,
|
|
226
|
+
"export { Jobs, Records } from './git.ts';",
|
|
227
|
+
"// First in its fetch, before its own routes:",
|
|
228
|
+
`const answered = ${routing[choices.serve].first("request")};`,
|
|
229
|
+
"if (answered !== undefined) return answered;"
|
|
230
|
+
];
|
|
231
|
+
/** The lines each kind of manual step prints. */
|
|
232
|
+
const manualLines = {
|
|
233
|
+
alchemy: alchemyLines,
|
|
234
|
+
toml: tomlLines,
|
|
235
|
+
class: entryLines,
|
|
236
|
+
server: entryLines
|
|
237
|
+
};
|
|
238
|
+
const manualSays = {
|
|
239
|
+
alchemy: ["alchemy.run.ts", "Alchemy declares the Worker's bindings: add these to its env"],
|
|
240
|
+
toml: ["wrangler.toml", "init writes no TOML: add these to it"],
|
|
241
|
+
class: ["its entry", "The Worker's default export is a class or has no fetch: add these to it"],
|
|
242
|
+
server: ["src/server.ts", "The app has its own server entry: add these to it"]
|
|
243
|
+
};
|
|
244
|
+
/** The Worker's entry `init` writes for a layout, and the `main` it sets. */
|
|
245
|
+
const entryOf = (choices, layout) => {
|
|
246
|
+
switch (layout.kind) {
|
|
247
|
+
case "own": return {
|
|
248
|
+
path: "src/worker.ts",
|
|
249
|
+
text: workerEntry(choices),
|
|
250
|
+
main: void 0
|
|
251
|
+
};
|
|
252
|
+
case "wrapped": return {
|
|
253
|
+
path: "src/git-entry.ts",
|
|
254
|
+
text: wrappedEntry(choices, layout.main),
|
|
255
|
+
main: "src/git-entry.ts"
|
|
256
|
+
};
|
|
257
|
+
case "start": return {
|
|
258
|
+
path: "src/server.ts",
|
|
259
|
+
text: startEntry(choices),
|
|
260
|
+
main: "src/server.ts"
|
|
261
|
+
};
|
|
262
|
+
case "manual":
|
|
263
|
+
case "mount": return;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
/** Everything `init` writes for `choices` in `project`, with `secret` making each new secret. */
|
|
267
|
+
const cloudflareOutput = (choices, project, secret, vendor) => {
|
|
268
|
+
const { layout, name } = project;
|
|
269
|
+
const own = layout.kind === "own";
|
|
270
|
+
const envFile = own ? "env.ts" : "git-env.ts";
|
|
271
|
+
const entry = entryOf(choices, layout);
|
|
272
|
+
const config = project.config?.file ?? "wrangler.jsonc";
|
|
273
|
+
return {
|
|
274
|
+
files: [
|
|
275
|
+
...config !== "wrangler.toml" && !(layout.kind === "manual" && layout.why === "alchemy") ? [{
|
|
276
|
+
path: config,
|
|
277
|
+
kind: "merge",
|
|
278
|
+
merge: (current) => current === void 0 ? wranglerConfig(choices, name) : mergeWrangler(current, choices, name, entry?.main)
|
|
279
|
+
}] : [],
|
|
280
|
+
{
|
|
281
|
+
path: "package.json",
|
|
282
|
+
kind: "merge",
|
|
283
|
+
merge: mergePackage(choices, name, own, vendor)
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
path: "src/git.ts",
|
|
287
|
+
kind: "whole",
|
|
288
|
+
text: gitModule(choices, `./${envFile}`)
|
|
289
|
+
},
|
|
290
|
+
...entry === void 0 ? [] : [{
|
|
291
|
+
path: entry.path,
|
|
292
|
+
kind: "whole",
|
|
293
|
+
text: entry.text
|
|
294
|
+
}],
|
|
295
|
+
{
|
|
296
|
+
path: `src/${envFile}`,
|
|
297
|
+
kind: "whole",
|
|
298
|
+
text: envModule(choices)
|
|
299
|
+
},
|
|
300
|
+
devVars(gitSecrets, secret),
|
|
301
|
+
{
|
|
302
|
+
path: ".gitignore",
|
|
303
|
+
kind: "merge",
|
|
304
|
+
merge: (current) => ignoring(current, ["node_modules", ".wrangler"], secretFiles)
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
manual: layout.kind !== "manual" ? [] : [{
|
|
308
|
+
path: manualSays[layout.why][0],
|
|
309
|
+
why: "yours",
|
|
310
|
+
says: manualSays[layout.why][1],
|
|
311
|
+
lines: manualLines[layout.why](choices, name)
|
|
312
|
+
}, ...layout.why === "alchemy" || layout.why === "toml" ? [{
|
|
313
|
+
path: "its entry",
|
|
314
|
+
why: "yours",
|
|
315
|
+
says: "Answer Git's URLs first in the Worker's entry",
|
|
316
|
+
lines: entryLines(choices)
|
|
317
|
+
}] : []],
|
|
318
|
+
packages: gitPackages(choices),
|
|
319
|
+
needs: [],
|
|
320
|
+
secret: "ADMIN_TOKEN, made for wrangler dev, in .dev.vars",
|
|
321
|
+
next: "Check it, then deploy it"
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
export { bucketLine, bucketName, cloudflareOutput, configParts, devVars, gitClasses, gitModule, gitSecrets, looseAdapterEnd, looseInfraImport, mergePackage, mergeWrangler, secretFiles };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { newFramework } from "./frameworks.mjs";
|
|
2
|
+
import { nodeAt, parseJsonc } from "./jsonc.mjs";
|
|
3
|
+
import { nextConfigAnchor } from "./next.mjs";
|
|
4
|
+
import { shellWord } from "./shell.mjs";
|
|
5
|
+
import { svelteAdapterAnchor } from "./sveltekit.mjs";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
// src/init/create.ts
|
|
8
|
+
/** The create commands' packages, at the versions each was run at on 20 Nov, as `init.md` lists. */
|
|
9
|
+
const creators = {
|
|
10
|
+
next: "create-next-app@16.4.6",
|
|
11
|
+
sveltekit: "sv@1.7.1",
|
|
12
|
+
nuxt: "create-nuxt@4.1.0"
|
|
13
|
+
};
|
|
14
|
+
/** The values `--framework` takes, in the table's order. */
|
|
15
|
+
const creatable = Object.keys(creators);
|
|
16
|
+
/**
|
|
17
|
+
* The platforms a new app from each create command runs on, the first what `--yes` takes: a new
|
|
18
|
+
* app is Node's, and Next.js's on Vercel too. Making one a Worker is its own setup.
|
|
19
|
+
*/
|
|
20
|
+
const createPlatforms = {
|
|
21
|
+
next: ["node", "vercel"],
|
|
22
|
+
sveltekit: ["node"],
|
|
23
|
+
nuxt: ["node"]
|
|
24
|
+
};
|
|
25
|
+
/** Each framework's config, as its anchor line alone: what `init` edits there, and nothing else. */
|
|
26
|
+
const anchors = {
|
|
27
|
+
next: [["next.config.ts", nextConfigAnchor]],
|
|
28
|
+
sveltekit: [["vite.config.ts", `import adapter from ${svelteAdapterAnchor};\n`]],
|
|
29
|
+
nuxt: []
|
|
30
|
+
};
|
|
31
|
+
/** The `package.json` a create command writes, as `creatorFolder` stands it in: two-space JSON. */
|
|
32
|
+
const creatorManifest = Schema.encodeSync(Schema.fromJsonString(Schema.Struct({
|
|
33
|
+
name: Schema.String,
|
|
34
|
+
dependencies: Schema.Record(Schema.String, Schema.String)
|
|
35
|
+
}), { space: 2 }));
|
|
36
|
+
/**
|
|
37
|
+
* What a create command's folder holds for `--dry-run`, which runs nothing: only what `init` relies
|
|
38
|
+
* on each command writing, not its files. That's a `package.json` naming the framework at the major
|
|
39
|
+
* `init` was tested with, under the project's name, an empty `.gitignore`, and, for Next.js and
|
|
40
|
+
* SvelteKit, their config's anchor line, which a real run edits in the file the command actually
|
|
41
|
+
* wrote. A real run whose command wrote no anchor gives the step `template_changed` instead.
|
|
42
|
+
*/
|
|
43
|
+
const creatorFolder = (framework, folder, name) => {
|
|
44
|
+
const { dependency, majors } = newFramework(framework);
|
|
45
|
+
const major = majors.at(-1);
|
|
46
|
+
const read = new Map([
|
|
47
|
+
["package.json", `${creatorManifest({
|
|
48
|
+
name,
|
|
49
|
+
dependencies: { [dependency]: major === void 0 ? "*" : `^${major}` }
|
|
50
|
+
})}\n`],
|
|
51
|
+
[".gitignore", ""],
|
|
52
|
+
...anchors[framework]
|
|
53
|
+
]);
|
|
54
|
+
return {
|
|
55
|
+
name: folder.name,
|
|
56
|
+
entries: [...read.keys()],
|
|
57
|
+
read: (path) => read.get(path),
|
|
58
|
+
isFolder: () => false,
|
|
59
|
+
userAgent: folder.userAgent
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/** How each package manager runs a package it hasn't installed, without asking first. */
|
|
63
|
+
const runners = {
|
|
64
|
+
npm: ["npx", "--yes"],
|
|
65
|
+
pnpm: ["pnpm", "dlx"],
|
|
66
|
+
yarn: ["yarn", "dlx"],
|
|
67
|
+
bun: ["bunx"]
|
|
68
|
+
};
|
|
69
|
+
/** A create command's own arguments, after its package, for `dir`, `manager` and the platform it's for. */
|
|
70
|
+
const argumentsOf = {
|
|
71
|
+
next: (dir, manager) => [
|
|
72
|
+
dir,
|
|
73
|
+
"--yes",
|
|
74
|
+
"--ts",
|
|
75
|
+
"--app",
|
|
76
|
+
"--empty",
|
|
77
|
+
"--no-tailwind",
|
|
78
|
+
"--no-eslint",
|
|
79
|
+
"--no-biome",
|
|
80
|
+
"--no-src-dir",
|
|
81
|
+
"--no-react-compiler",
|
|
82
|
+
"--no-cache-components",
|
|
83
|
+
"--no-agents-md",
|
|
84
|
+
"--no-agent-feedback",
|
|
85
|
+
"--import-alias",
|
|
86
|
+
"@/*",
|
|
87
|
+
`--use-${manager}`,
|
|
88
|
+
"--skip-install",
|
|
89
|
+
"--disable-git"
|
|
90
|
+
],
|
|
91
|
+
sveltekit: (dir, manager) => [
|
|
92
|
+
"create",
|
|
93
|
+
dir,
|
|
94
|
+
"--template",
|
|
95
|
+
"minimal",
|
|
96
|
+
"--types",
|
|
97
|
+
"ts",
|
|
98
|
+
"--no-add-ons",
|
|
99
|
+
"--no-install",
|
|
100
|
+
"--package-manager",
|
|
101
|
+
manager
|
|
102
|
+
],
|
|
103
|
+
nuxt: (dir, manager) => [
|
|
104
|
+
dir,
|
|
105
|
+
"--template",
|
|
106
|
+
"minimal",
|
|
107
|
+
"--no-install",
|
|
108
|
+
"--no-gitInit",
|
|
109
|
+
"--packageManager",
|
|
110
|
+
manager,
|
|
111
|
+
"--no-modules",
|
|
112
|
+
"--force"
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
/** The create command for `framework` in `dir` on `platform`, run through `manager`. */
|
|
116
|
+
const createCommand = (framework, dir, manager, platform) => {
|
|
117
|
+
const argv = [
|
|
118
|
+
...runners[manager],
|
|
119
|
+
creators[framework],
|
|
120
|
+
...argumentsOf[framework](dir, manager, platform)
|
|
121
|
+
];
|
|
122
|
+
return {
|
|
123
|
+
line: argv.map(shellWord).join(" "),
|
|
124
|
+
argv
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/** Whether a create command's `package.json` names its framework, as one that ran through does. */
|
|
128
|
+
const created = (framework, packageJson) => {
|
|
129
|
+
const tree = packageJson === void 0 ? void 0 : parseJsonc(packageJson);
|
|
130
|
+
return ["dependencies", "devDependencies"].some((key) => nodeAt(tree, [key, newFramework(framework).dependency]) !== void 0);
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* `create_failed`'s document, for a create command that exited non-zero, or 0 with no
|
|
134
|
+
* `package.json` naming the framework: what ran, how it ended, and the paths it left, which are
|
|
135
|
+
* the command's and stay. Its next step removes them and runs the same `init` again.
|
|
136
|
+
*/
|
|
137
|
+
const createFailed = (framework, command, ended, left) => ({
|
|
138
|
+
reason: "create_failed",
|
|
139
|
+
headline: ended.exit === 0 ? `${creators[framework]} exited 0 but wrote no package.json naming ${newFramework(framework).dependency}` : `${creators[framework]} ${ended.signal === null ? `exited ${ended.exit ?? "without a status"}` : `stopped on ${ended.signal}`}`,
|
|
140
|
+
data: {
|
|
141
|
+
create: {
|
|
142
|
+
command: {
|
|
143
|
+
line: command.line,
|
|
144
|
+
argv: command.argv
|
|
145
|
+
},
|
|
146
|
+
...ended
|
|
147
|
+
},
|
|
148
|
+
left
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
export { creatable, createCommand, createFailed, createPlatforms, created, creatorFolder, creators };
|