chore: .env file pull for www (#19511)

This commit is contained in:
Kevin Grüneberg
2023-12-07 14:58:34 +01:00
committed by GitHub
parent 05c674e2a7
commit ae8ce04f16
8 changed files with 530 additions and 427 deletions

View File

@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev --port 3001",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node internals/getSecrets.js",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node ../../scripts/getSecrets.js -n local/docs",
"build": "next build",
"build:analyze": "ANALYZE=true next build",
"start": "next start",

View File

@@ -1,33 +0,0 @@
// for internal supabase use only
const fs = require('fs/promises')
const { SecretsManagerClient, GetSecretValueCommand } = require('@aws-sdk/client-secrets-manager')
const secretName = 'local/studio'
const region = 'ap-southeast-2'
const getSecrets = async (name, region) => {
try {
const secretsmanager = new SecretsManagerClient({ region })
const command = new GetSecretValueCommand({
SecretId: name,
})
const data = await secretsmanager.send(command)
if (!data.SecretString) {
throw new Error('Secrets not found')
}
return JSON.parse(data.SecretString)
} catch (err) {
console.log('Error getting secrets', err)
}
}
// gets secrets from secrets manager and writes it to .env.local file
getSecrets(secretName, region).then(async (secrets) => {
let secretContent = ''
for (const [secretKey, secretValue] of Object.entries(secrets)) {
secretContent += `${secretKey}="${secretValue}"\n`
}
await fs.writeFile('.env.local', secretContent.trim())
})

View File

@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev -p 8082",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node internals/getSecrets.js",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node ../../scripts/getSecrets.js -n local/studio",
"build": "next build",
"start": "next start",
"lint": "next lint",

View File

@@ -4,8 +4,7 @@
# Replace this URL with the URL of your blog app
NEXT_PUBLIC_URL="https://localhost:3000"
NEXT_PUBLIC_DOCS_URL="http://localhost:3005"
NEXT_PUBLIC_STUDIO_URL="https://localhost:8082"
NEXT_PUBLIC_REFERENCE_DOCS_URL="https://localhost:3010"
NEXT_PUBLIC_SITE_ORIGIN=http://localhost:3000
NEXT_PUBLIC_URL="http://localhost:3000"
NEXT_PUBLIC_DOCS_URL="http://localhost:3001"
NEXT_PUBLIC_STUDIO_URL="http://localhost:8082"
NEXT_PUBLIC_REFERENCE_DOCS_URL="http://localhost:3010"

View File

@@ -3,3 +3,11 @@
## Overview
Refer to the [Development Guide](../../DEVELOPERS.md) to learn how to run this site locally.
> [!NOTE]
> **Supabase internal use:** To develop on Studio locally you can pull an appropriate .env file using
```bash
npm i # install dependencies
npm run dev:secrets:pull # Supabase internal use
```

View File

@@ -5,6 +5,7 @@
"private": true,
"scripts": {
"dev": "next --port 3000",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node ../../scripts/getSecrets.js -n local/www",
"build": "next build",
"export": "next export",
"start": "next start",
@@ -65,6 +66,7 @@
"yup": "^0.32.11"
},
"devDependencies": {
"@aws-sdk/client-secrets-manager": "^3.468.0",
"@types/classnames": "^2.3.1",
"@types/dat.gui": "^0.7.10",
"@types/mdx-js__react": "^1.5.6",

889
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,18 @@
// for internal supabase use only
const fs = require('fs/promises')
const { SecretsManagerClient, GetSecretValueCommand } = require('@aws-sdk/client-secrets-manager')
const { parseArgs } = require('node:util')
const assert = require('assert')
const args = parseArgs({
options: {
secretName: { type: 'string', short: 'n' },
},
})
const secretName = args.values.secretName
assert(secretName, 'secretName is required')
const secretName = 'local/docs'
const region = 'ap-southeast-2'
const getSecrets = async (name, region) => {