mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
chore(docs): clean up environment variables (#36036)
Our environment variables are a bit of a mess, so cleaning them up: - We have duplicate environment variables that resolve to the same thing but just have different names, deduplicating all of these - We have a .env.development (for publicly safe variables) and a .env.example, we really only need one - Privately, we have a .env (for running scripts) and a .env.local (for Next.js). Changing the dotenv source for scripts, so again we only need one
This commit is contained in:
1 parent
33b9e1ed29
commit
f58eead769
13 files changed
+61
-58
No files matched your search
@@ -11,7 +11,7 @@
|
||||
* the last Git commit date.
|
||||
*/
|
||||
|
||||
import 'dotenv/config'
|
||||
import _configureDotEnv from './utils/dotenv'
|
||||
|
||||
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
|
||||
import matter from 'gray-matter'
|
||||
@@ -25,6 +25,8 @@ import { SimpleGit, simpleGit } from 'simple-git'
|
||||
import { parse } from 'smol-toml'
|
||||
import { Section } from './helpers.mdx.js'
|
||||
|
||||
const _ = _configureDotEnv
|
||||
|
||||
interface Options {
|
||||
reset: boolean
|
||||
}
|
||||
@@ -47,7 +49,7 @@ type SectionWithChecksum = Omit<Section, 'heading'> &
|
||||
|
||||
const REQUIRED_ENV_VARS = {
|
||||
SUPABASE_URL: 'NEXT_PUBLIC_SUPABASE_URL',
|
||||
SERVICE_ROLE_KEY: 'SUPABASE_SERVICE_ROLE_KEY',
|
||||
SERVICE_ROLE_KEY: 'SUPABASE_SECRET_KEY',
|
||||
} as const
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import _configureDotEnv from './utils/dotenv'
|
||||
|
||||
import 'dotenv/config'
|
||||
import fs from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
@@ -13,6 +15,8 @@ import {
|
||||
type SearchSource,
|
||||
} from './search/sources/index.js'
|
||||
|
||||
const _ = _configureDotEnv
|
||||
|
||||
interface Source {
|
||||
title: string
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import _configureDotenv from '../utils/dotenv'
|
||||
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import 'dotenv/config'
|
||||
import { parseArgs } from 'node:util'
|
||||
import { OpenAI } from 'openai'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import type { Json, Section } from '../helpers.mdx.js'
|
||||
import { fetchAllSources } from './sources/index.js'
|
||||
|
||||
const _ = _configureDotenv
|
||||
|
||||
const args = parseArgs({
|
||||
options: {
|
||||
refresh: {
|
||||
@@ -18,19 +21,20 @@ async function generateEmbeddings() {
|
||||
const shouldRefresh = Boolean(args.values.refresh)
|
||||
|
||||
const requiredEnvVars = [
|
||||
'DOCS_GITHUB_APP_ID',
|
||||
'DOCS_GITHUB_APP_INSTALLATION_ID',
|
||||
'DOCS_GITHUB_APP_PRIVATE_KEY',
|
||||
'NEXT_PUBLIC_MISC_ANON_KEY',
|
||||
'NEXT_PUBLIC_MISC_URL',
|
||||
'NEXT_PUBLIC_SUPABASE_URL',
|
||||
'SUPABASE_SERVICE_ROLE_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'NEXT_PUBLIC_MISC_USE_URL',
|
||||
'NEXT_PUBLIC_MISC_USE_ANON_KEY',
|
||||
'SEARCH_GITHUB_APP_ID',
|
||||
'SEARCH_GITHUB_APP_INSTALLATION_ID',
|
||||
'SEARCH_GITHUB_APP_PRIVATE_KEY',
|
||||
'SUPABASE_SECRET_KEY',
|
||||
]
|
||||
|
||||
if (requiredEnvVars.some((name) => !process.env[name])) {
|
||||
const missingEnvVars = requiredEnvVars.filter((name) => !process.env[name])
|
||||
if (missingEnvVars.length > 0) {
|
||||
throw new Error(
|
||||
`Environment variables ${requiredEnvVars.join(
|
||||
`Environment variables ${missingEnvVars.join(
|
||||
', '
|
||||
)} are required: skipping embeddings generation`
|
||||
)
|
||||
@@ -38,8 +42,7 @@ async function generateEmbeddings() {
|
||||
|
||||
const supabaseClient = createClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
process.env.SUPABASE_SECRET_KEY,
|
||||
{
|
||||
auth: {
|
||||
persistSession: false,
|
||||
|
||||
@@ -25,11 +25,9 @@ export type DiscussionsResponse = {
|
||||
}
|
||||
}
|
||||
|
||||
const appId = process.env.SEARCH_GITHUB_APP_ID ?? process.env.DOCS_GITHUB_APP_ID
|
||||
const installationId =
|
||||
process.env.SEARCH_GITHUB_APP_INSTALLATION_ID ?? process.env.DOCS_GITHUB_APP_INSTALLATION_ID
|
||||
const privateKey =
|
||||
process.env.SEARCH_GITHUB_APP_PRIVATE_KEY ?? process.env.DOCS_GITHUB_APP_PRIVATE_KEY
|
||||
const appId = process.env.DOCS_GITHUB_APP_ID
|
||||
const installationId = process.env.DOCS_GITHUB_APP_INSTALLATION_ID
|
||||
const privateKey = process.env.DOCS_GITHUB_APP_PRIVATE_KEY
|
||||
|
||||
/**
|
||||
* Fetches GitHub discussions for a repository + category
|
||||
|
||||
@@ -8,9 +8,8 @@ type PartnerData = {
|
||||
overview: string // The Markdown content for indexing
|
||||
}
|
||||
|
||||
const supabaseUrl = process.env.NEXT_PUBLIC_MISC_USE_URL ?? process.env.NEXT_PUBLIC_MISC_URL
|
||||
const supabaseAnonKey =
|
||||
process.env.NEXT_PUBLIC_MISC_USE_ANON_KEY ?? process.env.NEXT_PUBLIC_MISC_ANON_KEY
|
||||
const supabaseUrl = process.env.NEXT_PUBLIC_MISC_URL
|
||||
const supabaseAnonKey = process.env.NEXT_PUBLIC_MISC_ANON_KEY
|
||||
|
||||
let supabaseClient: SupabaseClient
|
||||
function getSupabaseClient() {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
dotenv.config({ path: '.env.local' })
|
||||
|
||||
export default undefined
|
||||
Reference in new issue
Block a user