Skip to content

Commit

Permalink
🔄 [web] Adjust the method for outputting type information in Supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
usagizmo committed Apr 26, 2024
1 parent 3f042dd commit 087b556
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Supabase (`apps/backend`)

SUPABASE_DIRECT_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres

# SvelteKit (`apps/web`)

PUBLIC_GOOGLE_ANALYTICS_ID=
Expand Down
8 changes: 8 additions & 0 deletions apps/web/commands/supabase-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { config } from 'dotenv';
import { execSync } from 'node:child_process';

config();

execSync(
`supabase gen types typescript --db-url ${process.env.SUPABASE_DIRECT_URL} > ./src/lib/\\$generated/supabase-types.ts`,
);
3 changes: 0 additions & 3 deletions apps/web/commands/supabase-types.sh

This file was deleted.

3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"generate:svelte": "svelte-kit sync",
"generate:supabase-types": "./commands/supabase-types.sh",
"generate:supabase-types": "node ./commands/supabase-types.js",
"generate": "concurrently pnpm:generate:*",
"dev": "vite dev --open",
"build": "pnpm generate && vite build",
Expand Down Expand Up @@ -32,6 +32,7 @@
"@sveltejs/kit": "^2.5.5",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tailwindcss/postcss": "4.0.0-alpha.14",
"dotenv": "^16.4.5",
"supabase": "^1.162.4",
"svelte": "5.0.0-next.90",
"svelte-check": "^3.6.9",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 087b556

Please sign in to comment.