Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check-types": "npm run lint && supabase stop && npm run dbdiff",
"lint": "tsx scripts/lint.ts",
"lint:fix": "tsx scripts/lint.ts -f",
"build": "if [ $HOME != '/vercel' ]; then\n supabase start && supabase migrations up && (supabase gen types typescript --local --schema public > types.gen.ts)\nfi",
"build": "tsx scripts/build.ts",
"gentypes:production": "supabase start && supabase gen types typescript --project-id \"$SUPABASE_PROJECT_ID\" --schema public > types.gen.ts",
"dbdiff": "supabase stop && supabase db diff",
"dbdiff:save": "supabase stop && supabase db diff -f",
Expand Down
19 changes: 19 additions & 0 deletions packages/database/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { execSync } from "node:child_process";
import { writeFileSync } from "fs"
import { join, dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));
const projectRoot = join(__dirname, '..');

if (process.env.HOME !== '/vercel') {
try {
execSync('supabase start');
execSync('supabase migrations up');
const stdout = execSync('supabase gen types typescript --local --schema public', { encoding: 'utf8' });
writeFileSync(join(projectRoot, 'types.gen.ts'), stdout);
} catch (err) {
console.error(err);
throw err;
}
}