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 0f438b0
Show file tree
Hide file tree
Showing 6 changed files with 24 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
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- name: Run build 🐣
run: pnpm build
env:
SUPABASE_DIRECT_URL: ${{ secrets.SUPABASE_DIRECT_URL }}
PUBLIC_GOOGLE_ANALYTICS_ID: ${{ secrets.PUBLIC_GOOGLE_ANALYTICS_ID }}
PUBLIC_SUPABASE_URL: ${{ secrets.PUBLIC_SUPABASE_URL }}
PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.PUBLIC_SUPABASE_ANON_KEY }}
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 0f438b0

Please sign in to comment.