diff --git a/apps/roam/scripts/compile.ts b/apps/roam/scripts/compile.ts index 19d36b71f..dcc682461 100644 --- a/apps/roam/scripts/compile.ts +++ b/apps/roam/scripts/compile.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import esbuild from "esbuild"; import fs from "fs"; import path from "path"; @@ -159,6 +160,9 @@ export const compile = ({ bundle: true, format, define: { + "process.env.SUPABASE_USE_DB": dbEnv.SUPABASE_USE_DB + ? `"${dbEnv.SUPABASE_USE_DB}"` + : "null", "process.env.SUPABASE_URL": dbEnv.SUPABASE_URL ? `"${dbEnv.SUPABASE_URL}"` : "null", diff --git a/apps/roam/src/index.ts b/apps/roam/src/index.ts index 1bed828d4..ca4de9197 100644 --- a/apps/roam/src/index.ts +++ b/apps/roam/src/index.ts @@ -120,7 +120,7 @@ export default runExtension(async (onloadArgs) => { text: "(BETA) Suggestive Mode Enabled", }).value; - if (isSuggestiveModeEnabled) { + if (isSuggestiveModeEnabled && process.env.SUPABASE_USE_DB !== "none") { initializeSupabaseSync(); } diff --git a/packages/database/src/dbDotEnv.mjs b/packages/database/src/dbDotEnv.mjs index 023af9f17..73f4fcdb1 100644 --- a/packages/database/src/dbDotEnv.mjs +++ b/packages/database/src/dbDotEnv.mjs @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import { readFileSync, existsSync } from "node:fs"; import { join, dirname, basename } from "node:path"; import { fileURLToPath } from "node:url"; @@ -69,10 +70,12 @@ export const envFilePath = () => { }; export const envContents = () => { + const variant = getVariant(); const path = envFilePath(); if (!path) { // Fallback to process.env when running in production environments const raw = { + SUPABASE_USE_DB: variant, SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_ANON_KEY: process.env.SUPABASE_ANON_KEY, NEXT_API_ROOT: process.env.NEXT_API_ROOT, @@ -80,7 +83,10 @@ export const envContents = () => { return Object.fromEntries(Object.entries(raw).filter(([, v]) => !!v)); } const data = readFileSync(path, "utf8"); - return dotenv.parse(data); + return { + ...dotenv.parse(data), + SUPABASE_USE_DB: variant, + }; }; let configDone = false;