fix(makefile): improve generate-env command and script
Some checks failed
continuous-integration/drone/push Build is failing

- Fix bash error in generate_env.sh with proper environment variable handling
- Add docker-compose command detection for better compatibility
- Add generate-env-prod command with production warnings
- Make generate-env non-interactive by default for easier automation
- Add generate-env-interactive for when user input is needed
- Expand .env.example with more configuration options
- Add helpful production deployment warnings

Resolves: 'make generate-env generates nonsense' issue
This commit is contained in:
2025-11-02 08:41:11 +09:00
parent e6776015fc
commit 368ee30396
3 changed files with 45 additions and 7 deletions

View File

@@ -51,14 +51,25 @@ while IFS= read -r line; do
if [[ "$confirm" = true ]]; then
# non-interactive: keep example defaults or environment overrides
if [[ -n "${!key-}" ]]; then
new_val="${!key}"
sed -i "s|^$key=.*|$key=$new_val|" "$TARGET"
env_val=""
if [[ -n "${!key:-}" ]]; then
env_val="${!key}"
fi
if [[ -n "$env_val" ]]; then
sed -i "s|^$key=.*|$key=$env_val|" "$TARGET"
fi
continue
fi
read -p "$key [$current_val]: " new_val
# Interactive mode: prompt user for each variable
if read -t 1 -n 0 2>/dev/null; then
# stdin is available for reading
read -p "$key [$current_val]: " new_val || true
else
# no stdin available, skip prompting
new_val=""
fi
if [[ -n "$new_val" ]]; then
sed -i "s|^$key=.*|$key=$new_val|" "$TARGET"
fi