mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 18:05:11 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Refactor, bug fix. Part 1 of 6 in a stack that splits the library redesign into reviewable pieces. This one is the foundation the rest build on and has no visual change. ## What is the current behavior? Three build steps each reimplement "where does this registry file land in the user's project": `process-registry`'s `getDefaultPath`, `registry/utils`' `uniqBy` on `file.path`, and the Markdown exporter. They disagree, which produces real bugs: - A Vue block whose files come from `node_modules/@supabase/vue-blocks/` keeps its package path, so the installer writes the package folder into the user's project. - `registryItemAppend` builds its `docs` string from `(item.docs, items.flatMap(...))` — a comma expression, so the item's own docs are discarded. - A name collision between a block file and its client's file silently keeps one of the two. - Install commands guess the CLI family from substrings in the item name, so `infinite-query-composable` — a Vue block with neither "vue" nor "nuxtjs" in its name — gets the React CLI. - Production Vue installs use `@supabase/<name>`, but the `@supabase` namespace is registered with shadcn, not shadcn-vue. - `build:registry`, `build:content`, `build:markdown` and `build:llms` run in parallel, but the last three read `public/r`. ## What is the new behavior? `lib/registry-resolution.ts` owns installed-path derivation, first-party dependency naming, deduplication, and cycle detection, and every consumer calls it. `build-registry` validates the whole registry against shadcn's schema and resolves every item, so a broken reference fails the build instead of shipping. `clean-registry` throws rather than logging past a failure. Pages declare their install `framework` explicitly instead of it being inferred, and production Vue installs use the absolute registry URL. The build steps are serialized behind `build:prepare`, and a new `library-tests.yml` workflow runs the library's tests, checks the generated registry is committed, and builds the app. ## Additional context Regenerated registry artifacts are the mechanical result of the resolution fix — the Vue client items and the OAuth consent items that gained their client's docs. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added explicit React and Vue framework selection for library blocks and installation commands. * Improved registry resolution, dependency handling, path validation, and Vue file normalization. * Added support for reliable local, preview, and production registry URLs. * **Documentation** * Updated Vue and Nuxt installation documentation to identify the Vue framework explicitly. * **Bug Fixes** * Preserved combined documentation and validated generated registry content more consistently. * **Tests** * Added coverage for installation commands, registry resolution, dependency handling, and generated artifacts. * **Chores** * Added automated pull-request checks for library tests and builds. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
97 lines
5.7 KiB
TypeScript
97 lines
5.7 KiB
TypeScript
import { type RegistryItem } from 'shadcn/schema'
|
|
|
|
import { clients } from './clients'
|
|
import currentUserAvatar from './default/blocks/current-user-avatar/registry-item.json' with { type: 'json' }
|
|
import dropzone from './default/blocks/dropzone/registry-item.json' with { type: 'json' }
|
|
import headlessAppTanstack from './default/blocks/headless-app-tanstack/registry-item.json' with { type: 'json' }
|
|
import infiniteQueryHook from './default/blocks/infinite-query-hook/registry-item.json' with { type: 'json' }
|
|
import mcpServer from './default/blocks/mcp-server/registry-item.json' with { type: 'json' }
|
|
import oauthConsentNextjs from './default/blocks/oauth-consent-nextjs/registry-item.json' with { type: 'json' }
|
|
import oauthConsentReactRouter from './default/blocks/oauth-consent-react-router/registry-item.json' with { type: 'json' }
|
|
import oauthConsentReact from './default/blocks/oauth-consent-react/registry-item.json' with { type: 'json' }
|
|
import oauthConsentTanstack from './default/blocks/oauth-consent-tanstack/registry-item.json' with { type: 'json' }
|
|
import passwordBasedAuthNextjs from './default/blocks/password-based-auth-nextjs/registry-item.json' with { type: 'json' }
|
|
import passwordBasedAuthReactRouter from './default/blocks/password-based-auth-react-router/registry-item.json' with { type: 'json' }
|
|
import passwordBasedAuthReact from './default/blocks/password-based-auth-react/registry-item.json' with { type: 'json' }
|
|
import passwordBasedAuthTanstack from './default/blocks/password-based-auth-tanstack/registry-item.json' with { type: 'json' }
|
|
import realtimeAvatarStack from './default/blocks/realtime-avatar-stack/registry-item.json' with { type: 'json' }
|
|
import realtimeChat from './default/blocks/realtime-chat/registry-item.json' with { type: 'json' }
|
|
import realtimeCursor from './default/blocks/realtime-cursor/registry-item.json' with { type: 'json' }
|
|
import realtimeFlow from './default/blocks/realtime-flow/registry-item.json' with { type: 'json' }
|
|
import realtimeMonaco from './default/blocks/realtime-monaco/registry-item.json' with { type: 'json' }
|
|
import safeNextPath from './default/blocks/safe-next-path/registry-item.json' with { type: 'json' }
|
|
import socialAuthNextjs from './default/blocks/social-auth-nextjs/registry-item.json' with { type: 'json' }
|
|
import socialAuthReactRouter from './default/blocks/social-auth-react-router/registry-item.json' with { type: 'json' }
|
|
import socialAuthReact from './default/blocks/social-auth-react/registry-item.json' with { type: 'json' }
|
|
import socialAuthTanstack from './default/blocks/social-auth-tanstack/registry-item.json' with { type: 'json' }
|
|
import tanstackDbNextjs from './default/blocks/tanstack-db/registry-item.json' with { type: 'json' }
|
|
import { registryItemAppend } from './utils'
|
|
|
|
const combine = (component: RegistryItem) => {
|
|
return clients.flatMap((client) => {
|
|
return registryItemAppend(
|
|
{
|
|
...component,
|
|
name: `${component.name}-${client.name.replace('supabase-client-', '')}`,
|
|
},
|
|
[client]
|
|
)
|
|
})
|
|
}
|
|
|
|
const nextjsClient = clients.find((client) => client.name === 'supabase-client-nextjs')
|
|
const reactClient = clients.find((client) => client.name === 'supabase-client-react')
|
|
const tanstackClient = clients.find((client) => client.name === 'supabase-client-tanstack')
|
|
const reactRouterClient = clients.find((client) => client.name === 'supabase-client-react-router')
|
|
|
|
// Reuse the MCP runtime at build time so installing the headless app writes
|
|
// exactly one tool entrypoint, already wired to its example tools.
|
|
const headlessApp = {
|
|
...headlessAppTanstack,
|
|
files: [
|
|
...headlessAppTanstack.files,
|
|
...mcpServer.files.filter(
|
|
(file) => !headlessAppTanstack.files.some((ownFile) => ownFile.target === file.target)
|
|
),
|
|
],
|
|
} as RegistryItem
|
|
|
|
export const blocks = [
|
|
safeNextPath as RegistryItem,
|
|
|
|
registryItemAppend(passwordBasedAuthNextjs as RegistryItem, [nextjsClient!]),
|
|
registryItemAppend(passwordBasedAuthReact as RegistryItem, [reactClient!]),
|
|
registryItemAppend(passwordBasedAuthReactRouter as RegistryItem, [reactRouterClient!]),
|
|
registryItemAppend(passwordBasedAuthTanstack as RegistryItem, [tanstackClient!]),
|
|
|
|
registryItemAppend(socialAuthNextjs as RegistryItem, [nextjsClient!]),
|
|
registryItemAppend(socialAuthReact as RegistryItem, [reactClient!]),
|
|
registryItemAppend(socialAuthReactRouter as RegistryItem, [reactRouterClient!]),
|
|
registryItemAppend(socialAuthTanstack as RegistryItem, [tanstackClient!]),
|
|
|
|
...combine(dropzone as RegistryItem),
|
|
...combine(realtimeCursor as RegistryItem),
|
|
...combine(currentUserAvatar as RegistryItem),
|
|
...combine(realtimeAvatarStack as RegistryItem),
|
|
...combine(realtimeChat as RegistryItem),
|
|
...combine(realtimeFlow as RegistryItem),
|
|
...combine(realtimeMonaco as RegistryItem),
|
|
// infinite query hook is intentionally not combined with the clients since it depends on clients having database types.
|
|
infiniteQueryHook as RegistryItem,
|
|
|
|
// Backend-only Deno Edge Function block. Every file has an explicit target,
|
|
// so it can be installed directly into a Supabase project.
|
|
mcpServer as RegistryItem,
|
|
|
|
// Composes the auth, OAuth consent and MCP server blocks into one app.
|
|
registryItemAppend(headlessApp, [tanstackClient!]),
|
|
|
|
registryItemAppend(oauthConsentNextjs as RegistryItem, [nextjsClient!]),
|
|
registryItemAppend(oauthConsentReact as RegistryItem, [reactClient!]),
|
|
registryItemAppend(oauthConsentReactRouter as RegistryItem, [reactRouterClient!]),
|
|
registryItemAppend(oauthConsentTanstack as RegistryItem, [tanstackClient!]),
|
|
|
|
// tanstack-db is served dynamically via API route, but we register it here for the static build
|
|
registryItemAppend(tanstackDbNextjs as RegistryItem, [nextjsClient!]),
|
|
] as RegistryItem[]
|