in src/utils/watch_and_rebuild.py [0:0]
def rebuild_template(self):
try:
# Clean output directory
project_path = (
pathlib.Path(self.output_dir) / self.project_name
if self.output_dir
else pathlib.Path(self.project_name)
)
# Check if the project directory exists and remove it
if project_path.exists():
console.print(
f"Removing existing directory: {project_path}", style="yellow"
)
shutil.rmtree(project_path)
# Rebuild using the CLI tool with agent and deployment target
cmd = [
"uv",
"run",
"-m",
"src.cli.main",
"create",
str(self.project_name),
"--agent",
self.agent_name,
"--deployment-target",
self.deployment_target,
"--output-dir",
str(self.output_dir) if self.output_dir else ".",
"--auto-approve",
"--region",
self.region,
]
# Add extra parameters if provided
if self.extra_params:
# Split comma-separated parameters and add them individually
for param in self.extra_params.split(','):
cmd.append(param.strip())
console.print(f"Executing: {' '.join(cmd)}", style="bold blue")
subprocess.run(cmd, check=True)
console.print("✨ Template rebuilt successfully!", style="bold green")
except subprocess.CalledProcessError as e:
console.print(f"Error rebuilding template: {e}", style="bold red")
except Exception as e:
console.print(f"Unexpected error: {e}", style="bold red")