Skip to content

fix(generate): delete autogen files for removed entities (#157) - #162

Merged
cultron merged 1 commit into
mainfrom
fix/157-stale-autogen
Oct 28, 2026
Merged

cultron merged 1 commit into
mainfrom
fix/157-stale-autogen

Conversation

@cultron

@cultron cultron commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closes #157.

What changed

  • apso generate records every path it writes. After generation, files under the autogen folder that carry the Apso header (Generated with Apso) but were not written this run are deleted, and each removal is printed. Directories left empty are removed.
  • Files without the header (.gitkeep, template seed __init__.py/routes.go, anything hand-placed) and everything outside autogen/ (including extensions/) are never touched.
  • Cleanup is skipped when .apsorc has no entities, so a missing or empty schema cannot wipe generated code.
  • generate has no --dry-run flag, so none was added.

Tests

  • New test/commands/generate.test.ts runs the real command per language (TypeScript, Python, Go): generate Gadget + Widget, drop Widget, generate again. Widget files are gone, Gadget files are byte-identical, extensions/ and an autogen .gitkeep are untouched. All 3 fail with cleanup disabled.
  • Full suite: 394 passed. Lint: 0 errors. tsc: clean.

apso generate only overwrote files, so entities removed or renamed in
.apsorc left their entity, controller, service and DTO files in autogen/.
Track every path a run writes, then delete files under autogen/ that carry
the Apso header but were not written. Files without the header (.gitkeep,
template seeds) and anything outside autogen/ are never touched. Cleanup is
skipped when .apsorc has no entities.

Closes #157
@cultron
cultron merged commit 84a86bb into main Oct 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apso generate leaves stale files for removed entities in autogen/

1 participant