Files
supabase/apps/studio/scripts/dispatch.js
T
Alaister Young a93d70f1f7 feat(studio): route dev/build/start through STUDIO_FRAMEWORK dispatcher
The top-level dev/build/start scripts now run scripts/dispatch.js, which
loads .env.local via node --env-file-if-exists and execs either the
:next or :tanstack variant based on STUDIO_FRAMEWORK. Locally the env
var lives in apps/studio/.env.local (gitignored) so the developer's
machine opts into TanStack; Vercel's Next.js prod project leaves it
unset and gets the next path. Adds :tanstack variants alongside the
existing :next ones for explicit selection.
2026-05-20 19:43:30 +07:00

30 lines
1.0 KiB
JavaScript

#!/usr/bin/env node
// Dispatch a top-level npm script (dev/build/start) to either the next- or
// tanstack-flavoured variant based on STUDIO_FRAMEWORK. Invoked from
// package.json scripts wrapped in `node --env-file-if-exists=.env.local`,
// so a local .env.local opts the developer into the TanStack path while
// the Vercel Next.js prod project (no env var) gets the next path.
//
// Usage: node scripts/dispatch.js <target>
// target ∈ { dev, build, start }
//
// Resolves to `pnpm run <target>:<framework>` where framework is `tanstack`
// when STUDIO_FRAMEWORK=tanstack, otherwise `next`.
import { spawnSync } from 'node:child_process'
const target = process.argv[2]
if (!target) {
console.error('dispatch.js: missing target (expected one of: dev, build, start)')
process.exit(2)
}
const framework = process.env.STUDIO_FRAMEWORK === 'tanstack' ? 'tanstack' : 'next'
const script = `${target}:${framework}`
const result = spawnSync('pnpm', ['run', script], {
stdio: 'inherit',
env: process.env,
})
process.exit(result.status ?? 1)