Skip to content
Open
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
4 changes: 4 additions & 0 deletions apps/roam/scripts/compile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import esbuild from "esbuild";
import fs from "fs";
import path from "path";
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/roam/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 7 additions & 1 deletion packages/database/src/dbDotEnv.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -69,18 +70,23 @@ 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,
};
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;
Expand Down