Skip to content

fix(cli): ignore and clean up folders left with only +types - #205

Merged
benatespina merged 3 commits into
mainfrom
fix/generate-stale-types-folders
Oct 17, 2026
Merged

benatespina merged 3 commits into
mainfrom
fix/generate-stale-types-folders

Conversation

@benatespina

@benatespina benatespina commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Deleting or renaming an aggregate or a read model left its generated +types behind. The next bounda generate took that folder for a module, failed with "a read model needs a view.ts with its fields" and stopped before removeOrphans could clean it up, so the app would not start until someone deleted the folder by hand.
  • Discovery now skips a folder that holds nothing but +types (and Finder's .DS_Store), at any depth, and the run removes those files along with the folders it empties.

Changes

  • discover.ts: list() leaves out directories that contain only +types directories, recursively. This applies at every level: aggregates, read models, projections/<aggregate>/, commands/, and so on, which also keeps a leftover aggregate out of the set used to check projection and process folders.
  • .DS_Store does not count: on macOS Finder drops one into every folder it opens, which would otherwise bring the failure back. A folder with only a .DS_Store is still reported.
  • write.ts: removeOrphans also removes a directory once removing orphans has emptied it, .DS_Store aside. A folder that was already empty belongs to the user and stays, and the app directory is never removed.
  • Tests for both: leftovers ignored at any depth; an empty folder, or one with anything next to +types, is still reported; emptied folders pruned while pre-existing empty ones stay.
  • docs/reference/cli.md and a patch changeset for @bounda-dev/cli.

Key Features

  • A stale +types tree no longer blocks bounda generate, --watch or the Vite plugin.
  • Folders the user created and has not filled yet still get the usual convention error.

Quality

  • pnpm check green.
  • Stryker on @bounda-dev/cli: discover.ts 95.74 %, write.ts 95.65 %. No surviving mutant is in the new logic; the one at write.ts:81 is equivalent, since walking a file reads it as empty.

Deleting or renaming an aggregate or a read model left its generated
+types behind. The next `bounda generate` took that folder for a module,
failed with "a read model needs a view.ts with its fields" and stopped
before removeOrphans could clean it up, so the app could not start until
the folder was deleted by hand.

Discovery now skips a folder that holds nothing but +types at any depth,
and removeOrphans also removes the folders its removal leaves empty. An
empty folder, or one with anything next to +types, is still reported.
Opening a folder in Finder drops a .DS_Store into it, so a deleted read
model whose folder held +types and .DS_Store was still taken for a
module and generation failed as before. Folder metadata no longer counts
when telling leftovers apart, and a folder emptied of +types is removed
with its .DS_Store. A folder with only a .DS_Store is still reported.
@benatespina
benatespina force-pushed the fix/generate-stale-types-folders branch from 40969ff to e465291 Compare October 17, 2026 14:19
@benatespina
benatespina merged commit a52ee3e into main Oct 17, 2026
5 checks passed
@benatespina
benatespina deleted the fix/generate-stale-types-folders branch October 17, 2026 14:57
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.

1 participant