Improved dry mode message.
This commit is contained in:
+20
-20
@@ -38,7 +38,7 @@ def ruff_sort_imports(files: list[Path], dry_run: bool = False) -> None:
|
|||||||
if not py_files:
|
if not py_files:
|
||||||
return
|
return
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would run ruff import sorting on {len(py_files)} files")
|
print(f"🔧 Would run ruff import sorting on {len(py_files)} files")
|
||||||
return
|
return
|
||||||
print("🔧 Ruff isort on modified files")
|
print("🔧 Ruff isort on modified files")
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
@@ -582,7 +582,7 @@ def patch_app_file(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would patch {path}")
|
print(f"✅ Would patch {path}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
path.write_text(content, "UTF-8", newline="\n")
|
path.write_text(content, "UTF-8", newline="\n")
|
||||||
@@ -673,7 +673,7 @@ def patch_vite_config(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would patch {path}")
|
print(f"✅ Would patch {path}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
path.write_text(content, "UTF-8", newline="\n")
|
path.write_text(content, "UTF-8", newline="\n")
|
||||||
@@ -773,7 +773,7 @@ def patch_frontend_health_check(frontend_dir: Path, dry_run: bool = False) -> bo
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would patch {target_file}")
|
print(f"✅ Would patch {target_file}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
target_file.write_text(content, "UTF-8", newline="\n")
|
target_file.write_text(content, "UTF-8", newline="\n")
|
||||||
@@ -825,7 +825,7 @@ def write_file(
|
|||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
action = "overwrite" if exists else "create"
|
action = "overwrite" if exists else "create"
|
||||||
print(f"[DRY RUN] Would {action} {path}")
|
print(f"✅ Would {action} {path}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
@@ -854,7 +854,7 @@ def _write_fallback_file(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would create {fallback_path} (original customized by user)")
|
print(f"✅ Would create {fallback_path} (original customized by user)")
|
||||||
_new_files_written.append((fallback_path, original_path))
|
_new_files_written.append((fallback_path, original_path))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -997,7 +997,7 @@ def ensure_python_project(project_dir: Path, dry_run: bool = False) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would run: uv init {project_dir}")
|
print(f"📦 Would run: uv init {project_dir}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
print("📦 No pyproject.toml found, initializing Python project...")
|
print("📦 No pyproject.toml found, initializing Python project...")
|
||||||
@@ -1041,7 +1041,7 @@ def ensure_frontend(project_dir: Path, dry_run: bool = False) -> bool:
|
|||||||
create_cmd = create_vue_commands[js_name]
|
create_cmd = create_vue_commands[js_name]
|
||||||
|
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would run: {' '.join(create_cmd)}")
|
print(f"🎨 Would run: {' '.join(create_cmd)}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
print("🎨 No frontend/ found, creating Vue project...")
|
print("🎨 No frontend/ found, creating Vue project...")
|
||||||
@@ -1085,7 +1085,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
# Create project directory if it doesn't exist
|
# Create project directory if it doesn't exist
|
||||||
if not project_dir.exists():
|
if not project_dir.exists():
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would create directory: {project_dir}")
|
print(f"✅ Would create directory: {project_dir}")
|
||||||
else:
|
else:
|
||||||
project_dir.mkdir(parents=True)
|
project_dir.mkdir(parents=True)
|
||||||
print(f"✅ Created {project_dir}")
|
print(f"✅ Created {project_dir}")
|
||||||
@@ -1108,12 +1108,9 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
if not module_name:
|
if not module_name:
|
||||||
# Derive from directory name
|
# Derive from directory name
|
||||||
module_name = project_dir.name.replace("-", "_")
|
module_name = project_dir.name.replace("-", "_")
|
||||||
print(f"📦 Using module name from directory: {module_name}")
|
print(f"📦 Module: {module_name} (from directory name)")
|
||||||
|
else:
|
||||||
# Title for templates
|
print(f"📦 Module: {module_name}")
|
||||||
project_title = module_name.replace("_", " ").title()
|
|
||||||
|
|
||||||
print(f"📦 Module: {module_name}")
|
|
||||||
|
|
||||||
# Determine port configuration
|
# Determine port configuration
|
||||||
# Priority: --ports argument > existing project values > defaults
|
# Priority: --ports argument > existing project values > defaults
|
||||||
@@ -1133,6 +1130,9 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
f"📡 Ports: default={default_port}, vite={vite_port}, dev={dev_port} {ports_note}"
|
f"📡 Ports: default={default_port}, vite={vite_port}, dev={dev_port} {ports_note}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Title for templates
|
||||||
|
project_title = module_name.replace("_", " ").title()
|
||||||
|
|
||||||
# Template variables
|
# Template variables
|
||||||
tpl_vars = {
|
tpl_vars = {
|
||||||
"MODULE_NAME": module_name,
|
"MODULE_NAME": module_name,
|
||||||
@@ -1179,7 +1179,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
obsolete_util = fastapi_vue_scripts / "util.py"
|
obsolete_util = fastapi_vue_scripts / "util.py"
|
||||||
if obsolete_util.exists():
|
if obsolete_util.exists():
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print(f"[DRY RUN] Would remove obsolete {obsolete_util}")
|
print(f"🗑️ Would remove obsolete {obsolete_util}")
|
||||||
else:
|
else:
|
||||||
obsolete_util.unlink()
|
obsolete_util.unlink()
|
||||||
print(f"🗑️ Removed obsolete {obsolete_util}")
|
print(f"🗑️ Removed obsolete {obsolete_util}")
|
||||||
@@ -1306,7 +1306,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
if new_content == old_content:
|
if new_content == old_content:
|
||||||
print(f"✔️ {pyproject_path} (already up to date)")
|
print(f"✔️ {pyproject_path} (already up to date)")
|
||||||
elif dry_run:
|
elif dry_run:
|
||||||
print(f"[DRY RUN] Would update {pyproject_path}")
|
print(f"✅ Would update {pyproject_path}")
|
||||||
else:
|
else:
|
||||||
pyproject_path.write_text(new_content, "UTF-8", newline="\n")
|
pyproject_path.write_text(new_content, "UTF-8", newline="\n")
|
||||||
print(f"✅ Updated {pyproject_path}")
|
print(f"✅ Updated {pyproject_path}")
|
||||||
@@ -1319,7 +1319,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
if b"frontend-build" in gitignore_content:
|
if b"frontend-build" in gitignore_content:
|
||||||
print("✔️ .gitignore (frontend-build already ignored)")
|
print("✔️ .gitignore (frontend-build already ignored)")
|
||||||
elif dry_run:
|
elif dry_run:
|
||||||
print(f"[DRY RUN] Would add {gitignore_entry} to .gitignore")
|
print(f"✅ Would add {gitignore_entry} to .gitignore")
|
||||||
else:
|
else:
|
||||||
nl = b"\r\n" if b"\r\n" in gitignore_content else b"\n"
|
nl = b"\r\n" if b"\r\n" in gitignore_content else b"\n"
|
||||||
suffix = b"" if gitignore_content.endswith(nl) else nl
|
suffix = b"" if gitignore_content.endswith(nl) else nl
|
||||||
@@ -1328,7 +1328,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
)
|
)
|
||||||
print(f"✅ Added {gitignore_entry} to .gitignore")
|
print(f"✅ Added {gitignore_entry} to .gitignore")
|
||||||
elif dry_run:
|
elif dry_run:
|
||||||
print(f"[DRY RUN] Would create .gitignore with {gitignore_entry}")
|
print(f"✅ Would create .gitignore with {gitignore_entry}")
|
||||||
else:
|
else:
|
||||||
gitignore_path.write_text(f"{gitignore_entry}\n", "UTF-8", newline="\n")
|
gitignore_path.write_text(f"{gitignore_entry}\n", "UTF-8", newline="\n")
|
||||||
print("✅ Created .gitignore")
|
print("✅ Created .gitignore")
|
||||||
@@ -1336,7 +1336,7 @@ def cmd_setup(args: argparse.Namespace) -> int:
|
|||||||
# === Add dependencies using uv ===
|
# === Add dependencies using uv ===
|
||||||
ruff_sort_imports(_python_files_to_format, dry_run=dry_run)
|
ruff_sort_imports(_python_files_to_format, dry_run=dry_run)
|
||||||
if dry_run:
|
if dry_run:
|
||||||
print("[DRY RUN] Would add: fastapi[standard], fastapi-vue, httpx (dev only)")
|
print("📦 Would add: fastapi[standard], fastapi-vue, httpx (dev only)")
|
||||||
else:
|
else:
|
||||||
print("📦 Dependencies")
|
print("📦 Dependencies")
|
||||||
uv_add_packages(["fastapi[standard]", "fastapi-vue"], cwd=project_dir)
|
uv_add_packages(["fastapi[standard]", "fastapi-vue"], cwd=project_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user