Write generated files to disk. Returns list of created file paths.
(files: dict[str, str], dry_run: bool = False)
| 572 | |
| 573 | |
| 574 | def write_task_files(files: dict[str, str], dry_run: bool = False) -> list[str]: |
| 575 | """Write generated files to disk. Returns list of created file paths.""" |
| 576 | created = [] |
| 577 | for rel_path, content in files.items(): |
| 578 | full_path = PROJECT_ROOT / rel_path |
| 579 | if dry_run: |
| 580 | print(f" [DRY RUN] Would create: {rel_path}") |
| 581 | created.append(rel_path) |
| 582 | continue |
| 583 | |
| 584 | full_path.parent.mkdir(parents=True, exist_ok=True) |
| 585 | full_path.write_text(content) |
| 586 | |
| 587 | # Make shell scripts executable |
| 588 | if full_path.suffix == ".sh": |
| 589 | full_path.chmod(0o755) |
| 590 | |
| 591 | created.append(rel_path) |
| 592 | print(f" Created: {rel_path}") |
| 593 | |
| 594 | return created |
| 595 | |
| 596 | |
| 597 | # --------------------------------------------------------------------------- |