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,297 @@
|
|
|
1
|
+
import { detectFrameworks } from "./frameworks.mjs";
|
|
2
|
+
import { itemsAt, nodeAt, parseJsonc, stringAt as stringAt$1 } from "./jsonc.mjs";
|
|
3
|
+
// src/init/detect.ts
|
|
4
|
+
const managers = [
|
|
5
|
+
"npm",
|
|
6
|
+
"pnpm",
|
|
7
|
+
"yarn",
|
|
8
|
+
"bun"
|
|
9
|
+
];
|
|
10
|
+
const newProjectFiles = /^(\.git|\.gitignore|README.*|LICENSE.*)$/i;
|
|
11
|
+
/**
|
|
12
|
+
* Why a folder with a `package.json` reads as Node: it has none of the files the other kinds do. A
|
|
13
|
+
* library or a monorepo's root reads as Node too, and the Folder row says so first.
|
|
14
|
+
*/
|
|
15
|
+
const nodeBecause = "no Worker, Vercel project or framework init knows";
|
|
16
|
+
/** The servers a Node project depends on that make it a Node server. */
|
|
17
|
+
const nodeServers = /* @__PURE__ */ new Set([
|
|
18
|
+
"express",
|
|
19
|
+
"hono",
|
|
20
|
+
"fastify",
|
|
21
|
+
"@hono/node-server"
|
|
22
|
+
]);
|
|
23
|
+
/** A framework's name with its article, as a Folder row reads it: `an Astro`, `a Hono`. */
|
|
24
|
+
const aFramework = (says) => `${/^[AEIOU]/.test(says) ? "an" : "a"} ${says}`;
|
|
25
|
+
const configFiles = [
|
|
26
|
+
"wrangler.jsonc",
|
|
27
|
+
"wrangler.json",
|
|
28
|
+
"wrangler.toml"
|
|
29
|
+
];
|
|
30
|
+
const lockfiles = [
|
|
31
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
32
|
+
["yarn.lock", "yarn"],
|
|
33
|
+
["bun.lock", "bun"],
|
|
34
|
+
["bun.lockb", "bun"],
|
|
35
|
+
["package-lock.json", "npm"]
|
|
36
|
+
];
|
|
37
|
+
/** A Worker's or package's name, as wrangler takes it. */
|
|
38
|
+
const nameOf = (raw) => raw.toLowerCase().replace(/^@[^/]*\//, "").replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "git";
|
|
39
|
+
/** The string at `path` of a JSONC text, if it's one. */
|
|
40
|
+
const stringAt = (text, path) => text === void 0 ? void 0 : stringAt$1(parseJsonc(text), path);
|
|
41
|
+
/** The names a `package.json` depends on. */
|
|
42
|
+
const dependencies = (text) => {
|
|
43
|
+
const tree = text === void 0 ? void 0 : parseJsonc(text);
|
|
44
|
+
return ["dependencies", "devDependencies"].flatMap((key) => {
|
|
45
|
+
const found = nodeAt(tree, [key]);
|
|
46
|
+
return found?.kind === "object" ? found.members.map((member) => member.key) : [];
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/** The choices a `src/git.ts` that `init` wrote holds, from its imports and calls. */
|
|
50
|
+
const readBack = (text) => {
|
|
51
|
+
const named = new Set([...text.matchAll(/^import \{([^}]*)\} from '@ref0\/infra[^']*';$/gm)].flatMap((found) => (found[1] ?? "").split(",").map((each) => each.trim())));
|
|
52
|
+
const imports = (face) => named.has(face);
|
|
53
|
+
const vercel = imports("vercelQueues");
|
|
54
|
+
const onNode = !vercel && (imports("poller") || imports("sqlite"));
|
|
55
|
+
if (!vercel && !onNode && !imports("cloudflare")) return void 0;
|
|
56
|
+
const loose = /\bloose\(\)/.test(text);
|
|
57
|
+
const shared = {
|
|
58
|
+
serve: text.includes("from '@ref0/github'") ? "github" : text.includes("from '@ref0/git/rest'") ? "api" : "git",
|
|
59
|
+
app: text.includes("from './signin/auth.ts'") ? "ref0" : "none",
|
|
60
|
+
queue: text.includes("mergeQueue(") ? "on" : "off",
|
|
61
|
+
basePath: /^ {2}basePath: '([^']*)',$/m.exec(text)?.[1] ?? "/"
|
|
62
|
+
};
|
|
63
|
+
if (vercel) return {
|
|
64
|
+
...shared,
|
|
65
|
+
platform: "vercel",
|
|
66
|
+
records: imports("turso") ? "turso" : "postgres",
|
|
67
|
+
objects: "packs",
|
|
68
|
+
bucket: imports("s3") ? "s3" : "vercel-blob",
|
|
69
|
+
vercelPlan: text.includes("maxDuration: '800 seconds'") ? "pro" : "hobby"
|
|
70
|
+
};
|
|
71
|
+
if (onNode) return {
|
|
72
|
+
...shared,
|
|
73
|
+
platform: "node",
|
|
74
|
+
records: imports("sqlite") ? "sqlite" : imports("postgres") ? "postgres" : "turso",
|
|
75
|
+
objects: loose ? "loose" : "packs",
|
|
76
|
+
bucket: loose ? "none" : imports("s3") ? "s3" : "disk",
|
|
77
|
+
vercelPlan: "none"
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...shared,
|
|
81
|
+
platform: "cloudflare",
|
|
82
|
+
records: "durable-objects",
|
|
83
|
+
objects: loose ? "loose" : "packs",
|
|
84
|
+
bucket: loose ? "none" : "r2",
|
|
85
|
+
vercelPlan: "none"
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** A cron schedule that runs more often than once a day: its minute or hour isn't one number. */
|
|
89
|
+
const subDaily = (schedule) => {
|
|
90
|
+
const [minute, hour] = schedule.trim().split(/\s+/);
|
|
91
|
+
return !/^\d+$/.test(minute ?? "") || !/^\d+$/.test(hour ?? "");
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The Vercel plan a `vercel.json` needs: Pro when a cron runs more often than daily or a function
|
|
95
|
+
* may run past 300 s, which Hobby refuses to deploy; else Hobby, which deploys anywhere.
|
|
96
|
+
*/
|
|
97
|
+
const planOf = (text) => {
|
|
98
|
+
const tree = parseJsonc(text);
|
|
99
|
+
const functions = nodeAt(tree, ["functions"]);
|
|
100
|
+
const durations = functions?.kind === "object" ? functions.members.flatMap((member) => {
|
|
101
|
+
const found = nodeAt(member.value, ["maxDuration"]);
|
|
102
|
+
return found?.kind === "value" ? [Number(found.raw)] : [];
|
|
103
|
+
}) : [];
|
|
104
|
+
const schedules = itemsAt(tree, ["crons"]).flatMap((each) => stringAt$1(each, ["schedule"]) ?? []);
|
|
105
|
+
return durations.some((each) => each > 300) || schedules.some(subDaily) ? "pro" : "hobby";
|
|
106
|
+
};
|
|
107
|
+
/** Each platform's name, as a refusal says it. */
|
|
108
|
+
const platformSays = {
|
|
109
|
+
cloudflare: "Cloudflare",
|
|
110
|
+
vercel: "Vercel",
|
|
111
|
+
node: "Node"
|
|
112
|
+
};
|
|
113
|
+
/** OpenNext's Worker, which `next build` writes: Git wraps it as any Worker's `main`. */
|
|
114
|
+
const openNextMain = ".open-next/worker.js";
|
|
115
|
+
/** A file under `src/`'s path from the folder, from an import in `src/` such as `./index.ts`. */
|
|
116
|
+
const fromSrc = (specifier) => new URL(specifier, "file:///src/").pathname.slice(1);
|
|
117
|
+
/** Where Git goes in an existing Worker whose `main` is `main`. */
|
|
118
|
+
const workerLayout = (folder, main, held) => {
|
|
119
|
+
if (main === "src/worker.ts" && held) return { kind: "own" };
|
|
120
|
+
if (main === openNextMain) return {
|
|
121
|
+
kind: "wrapped",
|
|
122
|
+
main
|
|
123
|
+
};
|
|
124
|
+
if (main === "src/git-entry.ts") {
|
|
125
|
+
const wrapped = /^import worker from '([^']+)';$/m.exec(folder.read(main) ?? "")?.[1];
|
|
126
|
+
if (wrapped !== void 0) return {
|
|
127
|
+
kind: "wrapped",
|
|
128
|
+
main: fromSrc(wrapped)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const entry = main === void 0 ? void 0 : folder.read(main);
|
|
132
|
+
const wraps = entry !== void 0 && !/^export default class\b/m.test(entry) && !(/^export default \{/m.test(entry) && !/\bfetch\b/.test(entry));
|
|
133
|
+
return main !== void 0 && wraps ? {
|
|
134
|
+
kind: "wrapped",
|
|
135
|
+
main
|
|
136
|
+
} : {
|
|
137
|
+
kind: "manual",
|
|
138
|
+
why: "class"
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* The folder's project, or why `init` can't set Git up in it. Of several frameworks, Git goes in
|
|
143
|
+
* the one `named` names, else the one whose server module a run wrote, else the first found.
|
|
144
|
+
*/
|
|
145
|
+
const detect = (folder, wanted, named) => {
|
|
146
|
+
const frameworks = detectFrameworks(folder);
|
|
147
|
+
const heldIn = (path) => {
|
|
148
|
+
const text = folder.read(path);
|
|
149
|
+
return text === void 0 ? void 0 : readBack(text);
|
|
150
|
+
};
|
|
151
|
+
const framework = frameworks.find((each) => each.name === named) ?? frameworks.find((each) => heldIn(each.serverModule) !== void 0) ?? frameworks[0];
|
|
152
|
+
const held = heldIn(framework?.serverModule ?? "src/git.ts");
|
|
153
|
+
const runsOn = (platform) => framework?.platforms.includes(platform) ?? true;
|
|
154
|
+
const toNode = runsOn("node") && !(runsOn("cloudflare") && runsOn("vercel")) && (wanted ?? held?.platform) === "node";
|
|
155
|
+
const packageJson = folder.read("package.json");
|
|
156
|
+
const depends = dependencies(packageJson);
|
|
157
|
+
const configFile = toNode ? void 0 : configFiles.find((file) => folder.read(file) !== void 0);
|
|
158
|
+
const config = configFile === void 0 ? void 0 : {
|
|
159
|
+
file: configFile,
|
|
160
|
+
text: folder.read(configFile) ?? ""
|
|
161
|
+
};
|
|
162
|
+
const isNew = folder.entries.every((entry) => newProjectFiles.test(entry));
|
|
163
|
+
const lock = lockfiles.find(([file]) => folder.entries.includes(file));
|
|
164
|
+
const agent = managers.find((each) => folder.userAgent?.startsWith(`${each}/`) === true);
|
|
165
|
+
const packageManager = lock !== void 0 ? {
|
|
166
|
+
value: lock[1],
|
|
167
|
+
from: "detected",
|
|
168
|
+
detectedFrom: lock[0]
|
|
169
|
+
} : {
|
|
170
|
+
value: agent ?? "npm",
|
|
171
|
+
from: "recommended"
|
|
172
|
+
};
|
|
173
|
+
const name = nameOf(stringAt(config?.file === "wrangler.toml" ? void 0 : config?.text, ["name"]) ?? stringAt(packageJson, ["name"]) ?? folder.name);
|
|
174
|
+
const fromGit = (value) => ({
|
|
175
|
+
value,
|
|
176
|
+
from: "detected",
|
|
177
|
+
detectedFrom: "src/git.ts"
|
|
178
|
+
});
|
|
179
|
+
const heldChoices = held === void 0 ? {} : {
|
|
180
|
+
serve: fromGit(held.serve),
|
|
181
|
+
app: fromGit(held.app),
|
|
182
|
+
records: fromGit(held.records),
|
|
183
|
+
objects: fromGit(held.objects),
|
|
184
|
+
bucket: fromGit(held.bucket),
|
|
185
|
+
queue: fromGit(held.queue),
|
|
186
|
+
basePath: fromGit(held.basePath),
|
|
187
|
+
vercelPlan: fromGit(held.vercelPlan)
|
|
188
|
+
};
|
|
189
|
+
const vercelJson = folder.read("vercel.json");
|
|
190
|
+
const base = {
|
|
191
|
+
config,
|
|
192
|
+
vercelJson,
|
|
193
|
+
held,
|
|
194
|
+
name,
|
|
195
|
+
packageJson,
|
|
196
|
+
packageManager,
|
|
197
|
+
framework,
|
|
198
|
+
frameworks
|
|
199
|
+
};
|
|
200
|
+
if (isNew) return {
|
|
201
|
+
...base,
|
|
202
|
+
project: "new",
|
|
203
|
+
says: `${folder.name}, empty: a new project`,
|
|
204
|
+
layout: { kind: "own" },
|
|
205
|
+
detected: {}
|
|
206
|
+
};
|
|
207
|
+
const start = depends.includes("@tanstack/react-start");
|
|
208
|
+
const alchemy = folder.entries.includes("alchemy.run.ts");
|
|
209
|
+
const vercel = !toNode && (vercelJson !== void 0 || folder.read(".vercel/project.json") !== void 0 || depends.some((each) => each.startsWith("@vercel/")));
|
|
210
|
+
const onWorker = config !== void 0 || alchemy;
|
|
211
|
+
const platforms = framework?.platforms ?? (start ? ["cloudflare", "node"] : []);
|
|
212
|
+
if (onWorker ? framework !== void 0 && !runsOn("cloudflare") : vercel && platforms.length > 0 && !platforms.includes("vercel")) return {
|
|
213
|
+
reason: "not_on_platform",
|
|
214
|
+
headline: `${framework?.says ?? "TanStack Start"} runs Git on ${platforms.map((each) => platformSays[each]).join(" and ")} only: ${onWorker ? "its Cloudflare adapter" : "Vercel's build of it"} gives Git's jobs no function or class of their own. Run init with --platform node`
|
|
215
|
+
};
|
|
216
|
+
if (config === void 0 && !alchemy && vercel) {
|
|
217
|
+
const from = vercelJson !== void 0 ? "vercel.json" : packageJson === void 0 ? ".vercel/project.json" : "package.json";
|
|
218
|
+
const plan = held?.platform !== "vercel" && vercelJson !== void 0 ? { vercelPlan: {
|
|
219
|
+
value: planOf(vercelJson),
|
|
220
|
+
from: "detected",
|
|
221
|
+
detectedFrom: "vercel.json"
|
|
222
|
+
} } : {};
|
|
223
|
+
return {
|
|
224
|
+
...base,
|
|
225
|
+
project: held?.platform === "vercel" ? "new" : "existing",
|
|
226
|
+
says: held?.platform === "vercel" ? `${folder.name}, set up by init` : `${folder.name}, ${framework === void 0 ? "a Vercel project" : `${aFramework(framework.says)} project on Vercel`}: ${from}`,
|
|
227
|
+
layout: { kind: "own" },
|
|
228
|
+
detected: {
|
|
229
|
+
platform: {
|
|
230
|
+
value: "vercel",
|
|
231
|
+
from: "detected",
|
|
232
|
+
detectedFrom: from
|
|
233
|
+
},
|
|
234
|
+
...plan,
|
|
235
|
+
...heldChoices
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (config === void 0 && !alchemy) {
|
|
240
|
+
if (packageJson === void 0) return {
|
|
241
|
+
reason: "not_a_project",
|
|
242
|
+
headline: `${folder.name} has files but no package.json or wrangler.jsonc`
|
|
243
|
+
};
|
|
244
|
+
const ours = held?.platform === "node" && held.app === "ref0" || held?.platform === "node" && (folder.read("src/main.ts") ?? "").includes("from './git.ts'");
|
|
245
|
+
const server = depends.some((each) => nodeServers.has(each));
|
|
246
|
+
const because = framework === void 0 ? nodeBecause : `${framework.says} with no vercel.json or wrangler.jsonc, which run it elsewhere`;
|
|
247
|
+
return {
|
|
248
|
+
...base,
|
|
249
|
+
project: ours ? "new" : "existing",
|
|
250
|
+
says: ours ? `${folder.name}, set up by init` : framework === void 0 ? `${folder.name}, a Node ${server ? "server" : "project"}: package.json, with ${nodeBecause}` : `${folder.name}, ${aFramework(framework.says)} project: package.json`,
|
|
251
|
+
layout: ours ? { kind: "own" } : { kind: "mount" },
|
|
252
|
+
detected: {
|
|
253
|
+
platform: {
|
|
254
|
+
value: "node",
|
|
255
|
+
from: "detected",
|
|
256
|
+
...framework?.adapter?.name === "node" ? {
|
|
257
|
+
detectedFrom: framework.adapter.file,
|
|
258
|
+
because: "adapter-node"
|
|
259
|
+
} : {
|
|
260
|
+
detectedFrom: "package.json",
|
|
261
|
+
because
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
...heldChoices
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const platform = {
|
|
269
|
+
value: "cloudflare",
|
|
270
|
+
from: "detected",
|
|
271
|
+
detectedFrom: alchemy ? "alchemy.run.ts" : config?.file ?? "wrangler.jsonc"
|
|
272
|
+
};
|
|
273
|
+
const main = config?.file === "wrangler.toml" ? void 0 : stringAt(config?.text, ["main"]);
|
|
274
|
+
const ours = main === "src/server.ts" && (folder.read(main) ?? "").includes("from './git.ts'");
|
|
275
|
+
const layout = alchemy ? {
|
|
276
|
+
kind: "manual",
|
|
277
|
+
why: "alchemy"
|
|
278
|
+
} : held?.app === "ref0" ? { kind: "own" } : config?.file === "wrangler.toml" ? {
|
|
279
|
+
kind: "manual",
|
|
280
|
+
why: "toml"
|
|
281
|
+
} : start ? ours || folder.read("src/server.ts") === void 0 ? { kind: "start" } : {
|
|
282
|
+
kind: "manual",
|
|
283
|
+
why: "server"
|
|
284
|
+
} : workerLayout(folder, main, held !== void 0);
|
|
285
|
+
const says = alchemy ? `${folder.name}, an Alchemy project: alchemy.run.ts` : start ? `${folder.name}, a TanStack Start app on Cloudflare` : `${folder.name}, a Worker: ${config?.file ?? ""}${main === void 0 ? "" : `, main ${main}`}`;
|
|
286
|
+
return {
|
|
287
|
+
...base,
|
|
288
|
+
project: layout.kind === "own" ? "new" : "existing",
|
|
289
|
+
says: layout.kind === "own" ? `${folder.name}, set up by init` : says,
|
|
290
|
+
layout,
|
|
291
|
+
detected: {
|
|
292
|
+
platform,
|
|
293
|
+
...heldChoices
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
export { detect, planOf, readBack };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { parseJsonc, stringAt, withEntries, withValue } from "./jsonc.mjs";
|
|
2
|
+
import { nodePackages } from "./metadata.mjs";
|
|
3
|
+
import { initWrote, specOf } from "./versions.mjs";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
// src/init/files.ts
|
|
6
|
+
/** The parts that are strings, one a line: a part that's `false` is left out. */
|
|
7
|
+
const lines = (...parts) => parts.filter(Predicate.isString).join("\n");
|
|
8
|
+
/** An import of `names` from `from`, on one line, or one name a line past the formatter's width. */
|
|
9
|
+
const importLine = (names, from) => {
|
|
10
|
+
const line = `import { ${names.join(", ")} } from '${from}';`;
|
|
11
|
+
return line.length <= 100 ? line : lines("import {", ...names.map((name) => ` ${name},`), `} from '${from}';`);
|
|
12
|
+
};
|
|
13
|
+
/** `names` as a sentence lists them: `a, b and c`. */
|
|
14
|
+
const listed = (names) => names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1] ?? ""}`;
|
|
15
|
+
/** `head` and `body` on one line when it fits the formatter's width, as it leaves them, else two. */
|
|
16
|
+
const fitted = (head, body) => head.length + body.length < 100 ? `${head} ${body}` : `${head}\n ${body}`;
|
|
17
|
+
/** The served parts' words, for the files' first lines. */
|
|
18
|
+
const served = {
|
|
19
|
+
github: "GitHub-compatible",
|
|
20
|
+
api: "with its REST API",
|
|
21
|
+
git: "over Git's protocol only"
|
|
22
|
+
};
|
|
23
|
+
/** A file of lines with `lines` added at its end, on lines of their own. */
|
|
24
|
+
const appended = (current, lines) => {
|
|
25
|
+
if (lines.length === 0) return current ?? "";
|
|
26
|
+
return `${current === void 0 || current === "" || current.endsWith("\n") ? current ?? "" : `${current}\n`}${lines.join("\n")}\n`;
|
|
27
|
+
};
|
|
28
|
+
/** A file of lines with each of `wanted` that isn't there added at its end. */
|
|
29
|
+
const withLines = (current, wanted, key = (line) => line) => {
|
|
30
|
+
const have = new Set((current ?? "").split("\n").map(key));
|
|
31
|
+
const missing = wanted.filter((line) => !have.has(key(line)));
|
|
32
|
+
if (missing.length === 0) return current ?? "";
|
|
33
|
+
return appended(current, missing);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* `.gitignore` with `others`, and `secrets`, the files secrets are in, as its last rules unless they
|
|
37
|
+
* are already: any rule after one, such as `!*`, could let a secret be committed, and reading Git's
|
|
38
|
+
* rules to tell is more than `init` needs to know.
|
|
39
|
+
*/
|
|
40
|
+
const ignoring = (current, others, secrets) => {
|
|
41
|
+
const ignored = withLines(current, others);
|
|
42
|
+
const last = ignored.split("\n").map((line) => line.trimEnd()).filter((line) => line !== "" && !line.startsWith("#")).slice(-secrets.length).map((line) => line.replace(/^\//, ""));
|
|
43
|
+
return secrets.every((secret) => last.includes(secret)) ? ignored : appended(ignored, secrets);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `package.json`'s `dependencies` with each of `wanted` it doesn't name. A spec `init` wrote for
|
|
47
|
+
* Git's package, the release or a tarball in `vendor/`, moves to this run's; any other spec is the
|
|
48
|
+
* person's, and stays.
|
|
49
|
+
*/
|
|
50
|
+
const withDependencies = (current, wanted) => {
|
|
51
|
+
const moved = Object.entries(wanted).filter(([each]) => each.startsWith("@ref0/")).reduce((text, [each, spec]) => {
|
|
52
|
+
const path = ["dependencies", each];
|
|
53
|
+
const held = stringAt(parseJsonc(text), path);
|
|
54
|
+
return held !== spec && initWrote(each, held) ? withValue(text, path, spec) : text;
|
|
55
|
+
}, current);
|
|
56
|
+
return withEntries(moved, ["dependencies"], wanted);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* `package.json` with `ref0-git` in its `devDependencies` from `vendor/`, where `--from-checkout`
|
|
60
|
+
* packed it, so `npx ref0-git` runs the checkout's CLI before a release, not npm's placeholder. A
|
|
61
|
+
* spec `init` wrote from the other source moves to this run's; any other spec is the person's.
|
|
62
|
+
*/
|
|
63
|
+
const withCli = (current, vendor) => {
|
|
64
|
+
const path = ["devDependencies", "ref0-git"];
|
|
65
|
+
const held = stringAt(parseJsonc(current), path);
|
|
66
|
+
const spec = specOf("ref0-git", vendor);
|
|
67
|
+
if (held !== void 0 && held !== spec && initWrote("ref0-git", held)) return withValue(current, path, spec);
|
|
68
|
+
return vendor === void 0 || held !== void 0 ? current : withEntries(current, ["devDependencies"], { "ref0-git": spec });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* `package.json` with an `@types/node` older than `typesMajor` moved to the catalog's, where a
|
|
72
|
+
* create command wrote it in this run: `create-next-app` writes `^20`. One of the person's stays.
|
|
73
|
+
*/
|
|
74
|
+
const withCreatedTypes = (created) => (text) => {
|
|
75
|
+
const spec = stringAt(parseJsonc(text), ["devDependencies", "@types/node"]);
|
|
76
|
+
const major = Number(/^[\^~=v]*(\d+)/.exec(spec ?? "")?.[1] ?? 22);
|
|
77
|
+
if (created !== true || major >= 22) return text;
|
|
78
|
+
return withValue(text, ["devDependencies", "@types/node"], nodePackages["@types/node"]);
|
|
79
|
+
};
|
|
80
|
+
export { fitted, ignoring, importLine, lines, listed, served, withCli, withCreatedTypes, withDependencies, withLines };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { nodeAt, parseJsonc, stringAt } from "./jsonc.mjs";
|
|
2
|
+
import { nuxtGitMiddleware, nuxtJobsPlugin } from "./nuxt.mjs";
|
|
3
|
+
import { rangeMajor } from "./range-major.mjs";
|
|
4
|
+
// src/init/frameworks.ts
|
|
5
|
+
/** `init.md`'s Detection table, in its order: the first a project depends on wins. */
|
|
6
|
+
const rows = [
|
|
7
|
+
{
|
|
8
|
+
name: "next",
|
|
9
|
+
dependency: "next",
|
|
10
|
+
says: "Next.js",
|
|
11
|
+
majors: [16],
|
|
12
|
+
platforms: [
|
|
13
|
+
"cloudflare",
|
|
14
|
+
"vercel",
|
|
15
|
+
"node"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "sveltekit",
|
|
20
|
+
dependency: "@sveltejs/kit",
|
|
21
|
+
says: "SvelteKit",
|
|
22
|
+
majors: [3],
|
|
23
|
+
platforms: ["node"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "nuxt",
|
|
27
|
+
dependency: "nuxt",
|
|
28
|
+
says: "Nuxt",
|
|
29
|
+
majors: [4],
|
|
30
|
+
platforms: ["node"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "astro",
|
|
34
|
+
dependency: "astro",
|
|
35
|
+
says: "Astro",
|
|
36
|
+
majors: [7],
|
|
37
|
+
platforms: ["cloudflare", "node"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "react-router",
|
|
41
|
+
dependency: "@react-router/dev",
|
|
42
|
+
says: "React Router",
|
|
43
|
+
majors: [7, 8],
|
|
44
|
+
platforms: ["cloudflare", "node"]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "hono",
|
|
48
|
+
dependency: "hono",
|
|
49
|
+
with: "@hono/node-server",
|
|
50
|
+
says: "Hono",
|
|
51
|
+
majors: [4],
|
|
52
|
+
platforms: ["cloudflare", "node"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "express",
|
|
56
|
+
dependency: "express",
|
|
57
|
+
says: "Express",
|
|
58
|
+
majors: [5],
|
|
59
|
+
platforms: ["cloudflare", "node"]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "fastify",
|
|
63
|
+
dependency: "fastify",
|
|
64
|
+
says: "Fastify",
|
|
65
|
+
majors: [5],
|
|
66
|
+
platforms: ["cloudflare", "node"]
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
/** A framework's name in a receipt, and the dependency that says a folder's app is one. */
|
|
70
|
+
const newFramework = (name) => {
|
|
71
|
+
const row = rows.find((each) => each.name === name);
|
|
72
|
+
return {
|
|
73
|
+
says: row?.says ?? name,
|
|
74
|
+
dependency: row?.dependency ?? name,
|
|
75
|
+
/** The majors `init` was tested with, the latest last. */
|
|
76
|
+
majors: row?.majors ?? []
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const viteConfigs = [
|
|
80
|
+
"vite.config.ts",
|
|
81
|
+
"vite.config.js",
|
|
82
|
+
"vite.config.mts",
|
|
83
|
+
"vite.config.mjs"
|
|
84
|
+
];
|
|
85
|
+
/** The config files Next.js 16 reads, in the order it looks for them. */
|
|
86
|
+
const nextConfigs = [
|
|
87
|
+
"next.config.js",
|
|
88
|
+
"next.config.mjs",
|
|
89
|
+
"next.config.ts",
|
|
90
|
+
"next.config.mts"
|
|
91
|
+
];
|
|
92
|
+
const astroConfigs = [
|
|
93
|
+
"astro.config.mjs",
|
|
94
|
+
"astro.config.ts",
|
|
95
|
+
"astro.config.mts",
|
|
96
|
+
"astro.config.js"
|
|
97
|
+
];
|
|
98
|
+
/** Each name a `package.json` depends on, with its version spec. */
|
|
99
|
+
const dependencies = (text) => {
|
|
100
|
+
const tree = text === void 0 ? void 0 : parseJsonc(text);
|
|
101
|
+
return new Map(["dependencies", "devDependencies"].flatMap((key) => {
|
|
102
|
+
const found = nodeAt(tree, [key]);
|
|
103
|
+
if (found?.kind !== "object") return [];
|
|
104
|
+
return found.members.map((member) => [member.key, stringAt(member.value, []) ?? ""]);
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
/** Next.js's App Router folder, as Next picks it: root `app/` over `src/app/`, else beside pages. */
|
|
108
|
+
const appDirOf = (folder) => folder.isFolder("app") ? "app" : folder.isFolder("src/app") || !folder.isFolder("pages") && folder.isFolder("src/pages") ? "src/app" : "app";
|
|
109
|
+
/** SvelteKit's adapter, from the first `vite.config.*` that imports `@sveltejs/adapter-*`. */
|
|
110
|
+
const adapterOf = (folder) => viteConfigs.flatMap((file) => {
|
|
111
|
+
const text = folder.read(file) ?? "";
|
|
112
|
+
const name = /from\s+['"]@sveltejs\/adapter-([a-z0-9-]+)['"]/.exec(text)?.[1];
|
|
113
|
+
return name === void 0 ? [] : [{
|
|
114
|
+
name,
|
|
115
|
+
file,
|
|
116
|
+
text
|
|
117
|
+
}];
|
|
118
|
+
})[0];
|
|
119
|
+
/** The first of `paths` the folder holds, with its text. */
|
|
120
|
+
const firstOf = (folder, paths) => paths.flatMap((path) => {
|
|
121
|
+
const text = folder.read(path);
|
|
122
|
+
return text === void 0 ? [] : [{
|
|
123
|
+
path,
|
|
124
|
+
text
|
|
125
|
+
}];
|
|
126
|
+
})[0];
|
|
127
|
+
/**
|
|
128
|
+
* Astro's adapter, from the first `astro.config.*` whose `adapter:` calls an import: `node` for
|
|
129
|
+
* `@astrojs/node`, or the package's name for one outside `@astrojs/`, and the name it's imported as.
|
|
130
|
+
*/
|
|
131
|
+
const astroAdapterOf = (folder) => astroConfigs.flatMap((file) => {
|
|
132
|
+
const text = folder.read(file) ?? "";
|
|
133
|
+
const called = /\badapter\s*:\s*([A-Za-z_$][\w$]*)\s*\(/.exec(text)?.[1];
|
|
134
|
+
const from = called === void 0 ? void 0 : new RegExp(`^import\\s+${called.replaceAll("$", "\\$")}\\s+from\\s+['"]([^'"]+)['"]`, "m").exec(text)?.[1];
|
|
135
|
+
return from === void 0 ? [] : [{
|
|
136
|
+
name: from.replace(/^@astrojs\//, ""),
|
|
137
|
+
file,
|
|
138
|
+
text,
|
|
139
|
+
call: called
|
|
140
|
+
}];
|
|
141
|
+
})[0];
|
|
142
|
+
/** One row's framework in `folder`, whose `package.json` names it at `spec`. */
|
|
143
|
+
const frameworkOf = (row, spec, folder) => {
|
|
144
|
+
const major = rangeMajor(spec);
|
|
145
|
+
const version = `${row.says}${major === void 0 ? "" : ` ${major}`}`;
|
|
146
|
+
const known = major !== void 0 && row.majors.includes(major);
|
|
147
|
+
const unknown = known ? "" : ` (init knows ${row.majors.join(", ")})`;
|
|
148
|
+
const base = {
|
|
149
|
+
name: row.name,
|
|
150
|
+
says: row.says,
|
|
151
|
+
major,
|
|
152
|
+
known,
|
|
153
|
+
platforms: row.platforms
|
|
154
|
+
};
|
|
155
|
+
if (row.name === "next") {
|
|
156
|
+
const appDir = appDirOf(folder);
|
|
157
|
+
return {
|
|
158
|
+
...base,
|
|
159
|
+
serverModule: appDir === "src/app" ? "src/lib/git.ts" : "lib/git.ts",
|
|
160
|
+
appDir,
|
|
161
|
+
config: firstOf(folder, nextConfigs),
|
|
162
|
+
instrumentation: firstOf(folder, [
|
|
163
|
+
"instrumentation.ts",
|
|
164
|
+
"instrumentation.js",
|
|
165
|
+
"src/instrumentation.ts",
|
|
166
|
+
"src/instrumentation.js"
|
|
167
|
+
]),
|
|
168
|
+
platform: "node",
|
|
169
|
+
row: `${version}${unknown}, App Router in ${appDir}/, from package.json`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (row.name === "sveltekit") {
|
|
173
|
+
const adapter = adapterOf(folder);
|
|
174
|
+
const where = adapter === void 0 ? ", no adapter" : `, adapter-${adapter.name} in ${adapter.file}`;
|
|
175
|
+
return {
|
|
176
|
+
...base,
|
|
177
|
+
serverModule: "src/lib/server/git.ts",
|
|
178
|
+
adapter,
|
|
179
|
+
hooks: {
|
|
180
|
+
server: firstOf(folder, ["src/hooks.server.ts", "src/hooks.server.js"]),
|
|
181
|
+
universal: firstOf(folder, ["src/hooks.ts", "src/hooks.js"])
|
|
182
|
+
},
|
|
183
|
+
platform: adapter?.name === "node" ? "node" : void 0,
|
|
184
|
+
row: `${version}${unknown}${where}, from package.json`
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (row.name === "astro") {
|
|
188
|
+
const adapter = astroAdapterOf(folder);
|
|
189
|
+
const where = adapter === void 0 ? ", no adapter" : `, ${adapter.name} adapter in ${adapter.file}`;
|
|
190
|
+
return {
|
|
191
|
+
...base,
|
|
192
|
+
serverModule: "src/lib/git.ts",
|
|
193
|
+
config: firstOf(folder, astroConfigs),
|
|
194
|
+
adapter,
|
|
195
|
+
platform: adapter?.name === "node" ? "node" : void 0,
|
|
196
|
+
row: `${version}${unknown}${where}, from package.json`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (row.name === "nuxt") return {
|
|
200
|
+
...base,
|
|
201
|
+
serverModule: "server/git.ts",
|
|
202
|
+
nitro: {
|
|
203
|
+
plugin: firstOf(folder, [nuxtJobsPlugin]),
|
|
204
|
+
middleware: firstOf(folder, [nuxtGitMiddleware])
|
|
205
|
+
},
|
|
206
|
+
platform: "node",
|
|
207
|
+
row: `${version}${unknown}, from package.json`
|
|
208
|
+
};
|
|
209
|
+
const routesFile = row.name === "react-router" ? firstOf(folder, ["app/routes.ts"]) : void 0;
|
|
210
|
+
const flat = routesFile === void 0 ? {} : {
|
|
211
|
+
config: routesFile,
|
|
212
|
+
flatRoutes: /\bflatRoutes\(/.test(routesFile.text)
|
|
213
|
+
};
|
|
214
|
+
const routes = flat.flatRoutes === void 0 ? "" : flat.flatRoutes ? ", flatRoutes() in app/routes.ts" : ", routes listed in app/routes.ts";
|
|
215
|
+
return {
|
|
216
|
+
...base,
|
|
217
|
+
...flat,
|
|
218
|
+
serverModule: row.name === "react-router" ? "app/git.server.ts" : "src/git.ts",
|
|
219
|
+
platform: "node",
|
|
220
|
+
row: `${version}${unknown}${routes}, from package.json`
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
/** The frameworks `folder`'s `package.json` depends on, in the table's order. */
|
|
224
|
+
const detectFrameworks = (folder) => {
|
|
225
|
+
const depends = dependencies(folder.read("package.json"));
|
|
226
|
+
return rows.flatMap((row) => {
|
|
227
|
+
const spec = depends.get(row.dependency);
|
|
228
|
+
if (row.with !== void 0 && !depends.has(row.with)) return [];
|
|
229
|
+
return spec === void 0 ? [] : [frameworkOf(row, spec, folder)];
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
/** The receipt's line for the frameworks found beside the one Git goes in, which `--framework` can pick. */
|
|
233
|
+
const othersRow = (found, picked) => {
|
|
234
|
+
const others = found.filter((each) => each.name !== picked?.name);
|
|
235
|
+
return others.length === 0 ? void 0 : `Also ${others.map((each) => each.says).join(", ")}: --framework picks one`;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* The framework Git goes in: `named`, from `--framework`, among those found, or the first found;
|
|
239
|
+
* `undefined` for none. `--framework` in a folder with frameworks only picks one already there.
|
|
240
|
+
*/
|
|
241
|
+
const frameworkFor = (found, named) => {
|
|
242
|
+
if (named === void 0) return found[0];
|
|
243
|
+
return found.find((each) => each.name === named) ?? {
|
|
244
|
+
reason: "framework_differs",
|
|
245
|
+
headline: `This folder is a ${found.map((each) => each.says).join(" and ")} project, not ${named}: run init without --framework, or in an empty folder`
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
export { detectFrameworks, frameworkFor, newFramework, nextConfigs, othersRow };
|