Refactor environment variable handling in package.json scripts, update .env.example for consistency, and enhance Turbo configuration for environment variable passthrough. Modify API content type parsing and resolve circular dependencies in Auth and Billing modules. Add unique username generation logic in bootstrap-admin script.
This commit is contained in:
31
scripts/load-env.sh
Executable file
31
scripts/load-env.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Loads variables from .env into the current shell via Node.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ENV_FILE="$ROOT/.env"
|
||||
|
||||
if [[ ! -f "$ENV_FILE" ]]; then
|
||||
echo ".env nicht gefunden: $ENV_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval "$(
|
||||
node --input-type=module -e "
|
||||
import { readFileSync } from 'node:fs';
|
||||
process.loadEnvFile('$ENV_FILE');
|
||||
const content = readFileSync('$ENV_FILE', 'utf8');
|
||||
for (const line of content.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith('#')) continue;
|
||||
const eq = trimmed.indexOf('=');
|
||||
if (eq === -1) continue;
|
||||
const key = trimmed.slice(0, eq).trim();
|
||||
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue;
|
||||
const value = process.env[key];
|
||||
if (value !== undefined) {
|
||||
process.stdout.write('export ' + key + '=' + JSON.stringify(value) + ';');
|
||||
}
|
||||
}
|
||||
"
|
||||
)"
|
||||
Reference in New Issue
Block a user