Skip to content

fix: scope apso generate formatting to generated output only (#70)#78

Merged
cultron merged 1 commit into
mainfrom
fix/generate-format-scope
Jun 13, 2026
Merged

fix: scope apso generate formatting to generated output only (#70)#78
cultron merged 1 commit into
mainfrom
fix/generate-format-scope

Conversation

@cultron

@cultron cultron commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Closes #70

Problem

apso generate's format step delegated to the target project's npm run format, whose broad glob (e.g. {src,test}/**/*.ts) reformatted the entire project tree on every run — rewriting hand-written code that has nothing to do with code generation.

Fix

  • base-command: extract a generic runCommand(command, args, silent); runNpmCommand now delegates to it.
  • generate: format via npx prettier --write <rootFolder>/autogen/**/*.ts, scoped to the generated output dir (the stale src/guards glob was unnecessary — guards live under autogen/). Guard formatting on generatedFileCount > 0, and warn when .apsorc defines no entities.

Verification

End-to-end against a throwaway project containing a deliberately mis-formatted hand-written file outside autogen:

  • With entities → prettier targeted only …/src/autogen/**/*.ts; the hand-written file was byte-identical afterward (previously it would have been reformatted).
  • Build ✅ · lint 0 errors ✅

Note: this change was previously committed onto feat/import-supabase-data (PR #69); it has been moved here as a standalone PR and dropped from that branch so each lands independently.

🤖 Generated with Claude Code

The generate format step delegated to the target project's `npm run format`,
whose broad glob (e.g. `{src,test}/**/*.ts`) reformatted the entire project
tree on every run, rewriting hand-written code. Run prettier directly against
the generated output dir instead, and skip formatting when nothing was
generated.

- base-command: extract generic runCommand(command, args, silent); runNpmCommand
  delegates to it.
- generate: format via `npx prettier --write <rootFolder>/autogen/**/*.ts`
  (scoped to generated files; the stale src/guards glob was unnecessary since
  guards live under autogen/). Guard formatting on generatedFileCount > 0 and
  warn when .apsorc defines no entities.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cultron
cultron merged commit 189147a into main Jun 13, 2026
2 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 format step reformats the entire src/ tree, not only generated code

1 participant