A full-featured CRM built with React, shadcn/ui, and Supabase.
Add supabase secrets setup in remote init script.
Matthieu Hochlander8f49b4b6ed07
diff --git a/scripts/supabase-remote-init.mjs b/scripts/supabase-remote-init.mjsindex 81984d33..b2bca972 100644--- a/scripts/supabase-remote-init.mjs+++ b/scripts/supabase-remote-init.mjs@@ -30,6 +30,12 @@ import fs from "node:fs";databasePassword,});+ await setupSupabaseSecrets({+ projectRef,+ publishableKey,+ secretKey,+ });+await persistSupabaseEnv({projectRef,publishableKey,@@ -150,6 +156,7 @@ async function setupDatabase({ databasePassword }) {async function fetchApiKeys({ projectRef }) {let publishableKey = "";+ let secretKey = "";try {const { stdout, exitCode } = await execa("npx",@@ -185,6 +192,14 @@ async function fetchApiKeys({ projectRef }) {(key) => key.type === "publishable",)?.api_key;}++ // Prioritize the default secret key, but any secret key will work.+ secretKey = jsonOutput.find(+ (key) => key.type === "secret" && key.name === "default",+ )?.api_key;+ if (!secretKey) {+ secretKey = jsonOutput.find((key) => key.type === "secret")?.api_key;+ }}} catch (e) {console.error("Failed to fetch API keys");@@ -192,12 +207,30 @@ async function fetchApiKeys({ projectRef }) {throw e;}- if (publishableKey === "") {+ if (publishableKey === "" || secretKey === "") {await sleep(1000);return fetchApiKeys({ projectRef });}- return { publishableKey };+ return { publishableKey, secretKey };+}++async function setupSupabaseSecrets({ projectRef, publishableKey, secretKey }) {+ await execa(+ "npx",+ [+ "supabase",+ "secrets",+ "set",+ `SB_PUBLISHABLE_KEY=${publishableKey}`,+ `SB_SECRET_KEY=${secretKey}`,+ "--project-ref",+ projectRef,+ ],+ {+ stdio: "inherit",+ },+ );}async function persistSupabaseEnv({ projectRef, publishableKey }) {