From 4174afd726c996868002a9589a91cfffab19f95a Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 27 Jan 2022 15:54:59 -0500 Subject: [PATCH 1/4] allow no Supabase config in dev mode --- sites/svelte.dev/src/lib/db/client.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sites/svelte.dev/src/lib/db/client.js b/sites/svelte.dev/src/lib/db/client.js index d80110ad..6b45b41e 100644 --- a/sites/svelte.dev/src/lib/db/client.js +++ b/sites/svelte.dev/src/lib/db/client.js @@ -1,6 +1,8 @@ +import { dev } from '$app/env'; import { createClient } from '@supabase/supabase-js'; -const SUPABASE_URL = process.env['SUPABASE_URL']; -const SUPABASE_KEY = process.env['SUPABASE_KEY']; +const SUPABASE_URL = process.env.SUPABASE_URL; +const SUPABASE_KEY = process.env.SUPABASE_KEY; -export const client = createClient(SUPABASE_URL, SUPABASE_KEY, { fetch }); +export const client = + (!dev || (SUPABASE_URL && SUPABASE_KEY)) && createClient(SUPABASE_URL, SUPABASE_KEY, { fetch }); From 392dd5a2a4694348cb98c8516d6d3ebc2bc5bb47 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 27 Jan 2022 16:00:11 -0500 Subject: [PATCH 2/4] add proxy to read production REPLs in dev with no configured Supabase --- sites/svelte.dev/src/routes/repl/[id]/index.json.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sites/svelte.dev/src/routes/repl/[id]/index.json.js b/sites/svelte.dev/src/routes/repl/[id]/index.json.js index 8483d9a0..fcb262a6 100644 --- a/sites/svelte.dev/src/routes/repl/[id]/index.json.js +++ b/sites/svelte.dev/src/routes/repl/[id]/index.json.js @@ -1,3 +1,5 @@ +import { dev } from '$app/env'; +import { client } from '$lib/db/client'; import * as gist from '$lib/db/gist'; import { API_BASE } from '$lib/env'; @@ -58,6 +60,12 @@ export async function get({ params }) { }; } + if (dev && !client) { + // in dev with no local Supabase configured, proxy to production + // this lets us at least load saved REPLs + return fetch(`https://svelte.dev/repl/${params.id}.json`); + } + const app = await gist.read(params.id); if (!app) { From 27c484965a31305fde175ed95d358a0f22337b36 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 27 Jan 2022 16:07:33 -0500 Subject: [PATCH 3/4] update readme --- sites/svelte.dev/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sites/svelte.dev/README.md b/sites/svelte.dev/README.md index 3eed3b79..e71f3291 100644 --- a/sites/svelte.dev/README.md +++ b/sites/svelte.dev/README.md @@ -1,6 +1,10 @@ ## Running locally -Setup a database on [Supabase](https://supabase.com) with the instructions [here](../../db) and set the corresponding environment variables. +A local database is only required in dev mode if you want to test reading and writing saved REPLs on it. Without a local database in dev mode, the REPL will be able to load saved REPLs from the production database, but not save them. + +Note also that in dev mode, the REPL will currently only work in Chrome, as noted in the Vite documentation [here](https://vitejs.dev/guide/features.html#web-workers), pending support in Firefox for `import` statements in web workers. + +If you do want to use a database, set it up on [Supabase](https://supabase.com) with the instructions [here](../../db) and set the corresponding environment variables. Run the site sub-project: From dab78364c81e0898ee4bc4a1f00f862385a9c2ff Mon Sep 17 00:00:00 2001 From: Conduitry Date: Thu, 27 Jan 2022 16:33:23 -0500 Subject: [PATCH 4/4] Update sites/svelte.dev/README.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- sites/svelte.dev/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/svelte.dev/README.md b/sites/svelte.dev/README.md index e71f3291..3634ed4f 100644 --- a/sites/svelte.dev/README.md +++ b/sites/svelte.dev/README.md @@ -2,7 +2,7 @@ A local database is only required in dev mode if you want to test reading and writing saved REPLs on it. Without a local database in dev mode, the REPL will be able to load saved REPLs from the production database, but not save them. -Note also that in dev mode, the REPL will currently only work in Chrome, as noted in the Vite documentation [here](https://vitejs.dev/guide/features.html#web-workers), pending support in Firefox for `import` statements in web workers. +Note also that in dev mode, the REPL will currently only work in Chrome, [as noted in the Vite documentation](https://vitejs.dev/guide/features.html#web-workers), pending support in Firefox for `import` statements in web workers. If you do want to use a database, set it up on [Supabase](https://supabase.com) with the instructions [here](../../db) and set the corresponding environment variables.