Skip to content

Commit a4b8649

Browse files
Phase 2: Zero-config .env generation
1 parent 375465a commit a4b8649

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

pythoncms/cli.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Run the sample command as ``pythoncms welcome [OPTIONS] NAME``
1515
"""
1616
import os
17+
import secrets
1718
import subprocess
1819
import sys
1920
from pathlib import Path
@@ -47,9 +48,6 @@ def start(name, run):
4748
return
4849

4950
# Copy the project structure
50-
# We copy the parent of this file (pythoncms/ directory)
51-
# but we need to exclude things like __pycache__ and cli.py from the target if needed
52-
# actually the original logic was trycopytree(str(path.parent.absolute()), dest)
5351
trycopytree(str(path.parent.absolute()), dest)
5452

5553
# Cleanup target
@@ -60,10 +58,17 @@ def start(name, run):
6058
trymkfile(os.path.join(dest, "requirements.txt"), reqs)
6159

6260
# Setup .env
63-
env_demo = os.path.join(dest, ".env_demo")
6461
env_real = os.path.join(dest, ".env")
65-
if os.path.exists(env_demo):
66-
os.rename(env_demo, env_real)
62+
63+
env_content = f"""ACTIVE_FRONT_THEME = 'editorial'
64+
ACTIVE_BACK_THEME = 'sneat'
65+
APP_NAME = 'Demo'
66+
ACTIVE_ICONSET = 'boxicons'
67+
SITE_TITLE = 'Site title'
68+
SITE_DESCRIPTION = 'Site title'
69+
SECRET_KEY = '{secrets.token_hex(32)}'
70+
"""
71+
trymkfile(env_real, env_content)
6772

6873
click.echo(f"🍭 Pythoncms project {name} is ready!")
6974

0 commit comments

Comments
 (0)