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.
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 8s
CI / Go — edge-gateway build (push) Successful in 19s

This commit is contained in:
TheOnlyMace
2026-07-05 14:40:57 +02:00
parent 20e044d32b
commit 2126e7bebf
82 changed files with 233 additions and 12 deletions

28
scripts/dev-bg.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PID_FILE="$ROOT/.logs/dev.pid"
LOG_FILE="$ROOT/.logs/dev.log"
mkdir -p "$ROOT/.logs"
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "Dev server läuft bereits (PID $(cat "$PID_FILE"))."
echo "Log: $LOG_FILE"
exit 0
fi
# Next.js Dev braucht einen sauberen .next-Ordner (Production-Build stört).
rm -rf "$ROOT/apps/web/.next"
# shellcheck source=scripts/load-env.sh
source "$ROOT/scripts/load-env.sh"
cd "$ROOT"
nohup pnpm turbo run dev >"$LOG_FILE" 2>&1 &
echo $! >"$PID_FILE"
echo "Dev server gestartet (PID $(cat "$PID_FILE"))."
echo "Log: $LOG_FILE"
echo "Web: http://localhost:3000"

34
scripts/dev-stop.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PID_FILE="$ROOT/.logs/dev.pid"
if [[ -f "$PID_FILE" ]]; then
PID="$(cat "$PID_FILE")"
if kill -0 "$PID" 2>/dev/null; then
kill "$PID" 2>/dev/null || true
sleep 1
kill -0 "$PID" 2>/dev/null && kill -9 "$PID" 2>/dev/null || true
echo "Dev server gestoppt (PID $PID)."
else
echo "Prozess $PID läuft nicht mehr."
fi
rm -f "$PID_FILE"
else
echo "Kein Dev-Server-PID-File gefunden."
fi
# Turbo/Next/Nest Kindprozesse beenden (Ports 30003003 freigeben).
pkill -f "turbo run dev" 2>/dev/null || true
pkill -f "next dev" 2>/dev/null || true
pkill -f "nest start --watch" 2>/dev/null || true
pkill -f "tsx watch src/index.ts" 2>/dev/null || true
for port in 3000 3001 3002 3003; do
if command -v fuser >/dev/null 2>&1; then
fuser -k "${port}/tcp" 2>/dev/null || true
elif command -v lsof >/dev/null 2>&1; then
lsof -ti ":${port}" -sTCP:LISTEN 2>/dev/null | xargs -r kill -9 2>/dev/null || true
fi
done

31
scripts/load-env.sh Executable file
View 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) + ';');
}
}
"
)"

25
scripts/run-with-env.mjs Normal file
View File

@@ -0,0 +1,25 @@
import { spawnSync } from 'node:child_process';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
const root = resolve(import.meta.dirname, '..');
const envFile = resolve(root, '.env');
if (existsSync(envFile)) {
process.loadEnvFile(envFile);
}
const [command, ...args] = process.argv.slice(2);
if (!command) {
console.error('Usage: node scripts/run-with-env.mjs <command> [args...]');
process.exit(1);
}
const result = spawnSync(command, args, {
cwd: root,
stdio: 'inherit',
env: process.env,
});
process.exit(result.status ?? 1);