fix: fixed bootstrap overwrtting .env file and improved bool handling for js use

This commit is contained in:
2026-01-05 09:35:04 +01:00
parent 28c6bdeaa2
commit f023b24aa7
2 changed files with 18 additions and 15 deletions

View File

@@ -359,19 +359,20 @@ class SettingsBootstrap:
value = "true" if value else "false"
output_lines.append(f"{key}={value}\n")
# Variable not in schema
# If it exists in current .env, use that value, otherwise keep template
elif key in self.existing_env:
output_lines.append(f"{key}={self.existing_env[key]}\n")
else:
# Variable not in schema
# If it exists in current .env, use that value, otherwise keep template
if key in self.existing_env:
output_lines.append(f"{key}={self.existing_env[key]}\n")
else:
output_lines.append(line)
output_lines.append(line)
else:
# Keep any other lines as-is
output_lines.append(line)
# Append custom variables from existing .env that aren't in .env.example
custom_vars = {k: v for k, v in self.existing_env.items() if k not in processed_keys}
custom_vars = {
k: v for k, v in self.existing_env.items() if k not in processed_keys
}
if custom_vars:
output_lines.append("\n# --- CUSTOM VARIABLES ---\n")
output_lines.append("# Variables added manually (not in .env.example)\n")

View File

@@ -150,7 +150,9 @@ class TestTemplatePreservation:
class TestSecretPreservation:
"""Test that secrets are never overwritten."""
def test_preserves_existing_secrets(self, test_toml_with_all_types, test_env_example):
def test_preserves_existing_secrets(
self, test_toml_with_all_types, test_env_example
):
"""Test that existing secrets are preserved across multiple bootstraps."""
from alfred.settings_schema import load_schema