This commit is contained in:
user
2026-03-27 20:06:38 +02:00
commit 8c45efc92e
544 changed files with 33060 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import re
from pathlib import Path
ENV_ASSIGNMENT_RE = re.compile(
r"^(\s*(?:export\s+)?)([A-Za-z_][A-Za-z0-9_]*)(\s*=\s*)(.*)$"
)
def split_inline_comment(rhs: str) -> tuple[str, str]:
in_single = False
in_double = False
escaped = False
for i, char in enumerate(rhs):
if escaped:
escaped = False
continue
if char == "\\":
escaped = True
continue
if char == "'" and not in_double:
in_single = not in_single
continue
if char == '"' and not in_single:
in_double = not in_double
continue
if char == "#" and not in_single and not in_double:
if i == 0 or rhs[i - 1].isspace():
return rhs[:i], rhs[i:]
return rhs, ""
def transform_line(line: str) -> str:
stripped = line.strip()
if stripped == "" or stripped.startswith("#"):
return line
newline = ""
raw = line
if line.endswith("\r\n"):
newline = "\r\n"
raw = line[:-2]
elif line.endswith("\n"):
newline = "\n"
raw = line[:-1]
match = ENV_ASSIGNMENT_RE.match(raw)
if not match:
return line
prefix, key, delimiter, rhs = match.groups()
value_part, comment_part = split_inline_comment(rhs)
trailing_ws = value_part[len(value_part.rstrip()) :]
placeholder = f"${{{{project.{key}}}}}"
return f"{prefix}{key}{delimiter}{placeholder}{trailing_ws}{comment_part}{newline}"
def generate_example_env(source_path: Path, target_path: Path) -> None:
lines = source_path.read_text(encoding="utf-8").splitlines(keepends=True)
transformed = [transform_line(line) for line in lines]
target_path.write_text("".join(transformed), encoding="utf-8")
def main() -> None:
parser = argparse.ArgumentParser(
description="Generate .env.example using ${{project.KEY}} placeholders."
)
parser.add_argument("--source", default=".env", help="Path to source .env file")
parser.add_argument(
"--target", default=".env.example", help="Path to output .env.example file"
)
args = parser.parse_args()
source_path = Path(args.source)
target_path = Path(args.target)
if not source_path.exists():
raise FileNotFoundError(f"Source env file not found: {source_path}")
generate_example_env(source_path, target_path)
if __name__ == "__main__":
main()

7
scripts/migrate.sh Executable file
View File

@@ -0,0 +1,7 @@
echo "🔄 Migrating Primary DB"
cd packages/db
pnpm run db:migrate
cd ../../

15
scripts/populate.env.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# copy over the environment variables from the base /.env file to all other apps & packages in apps/* and packages/*
for dir in apps/*; do
if [ -d "$dir" ]; then
cp .env $dir/.env
fi
done
for dir in packages/*; do
if [ -d "$dir" ]; then
cp .env $dir/.env
fi
done

14
scripts/prod.start.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
APP_PATH=$1
if [ -z "$APP_PATH" ]; then
echo "Usage: prod.start.sh <app path>"
exit 1
fi
echo "Starting $APP_PATH"
cd $APP_PATH
pnpm run prod

3
scripts/spinup.dev.env.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
docker compose -f dev/docker-compose.dev.yaml up --wait -d

3
scripts/teardown.dev.env.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
docker compose -f dev/docker-compose.dev.yaml down --remove-orphans