Skip to content

fix(folder-structure-cruiser): return exit code 1 when violations are found#268

Merged
Komoszek merged 4 commits into
mainfrom
szpont/folder-cruiser-exit-code-0b20
May 12, 2026
Merged

fix(folder-structure-cruiser): return exit code 1 when violations are found#268
Komoszek merged 4 commits into
mainfrom
szpont/folder-cruiser-exit-code-0b20

Conversation

@Komoszek

@Komoszek Komoszek commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • changed both validators (validateCrossFeatureImports, validateSharedComponent) to return the number of detected violations instead of swallowing failures
  • updated CLI entrypoint (src/bin.ts) to set process.exitCode = 1 when violations are detected
  • switched to program.parseAsync().catch(...) so runtime errors also result in non-zero exit code
  • addressed review feedback:
    • restored summary wording to violation(s) in both validators, as requested in PR comments
    • unified CLI runtime error logging to use shared logger.error
    • strengthened cross-feature-imports allow-cases to assert violationsCount === 0 using fixtures that actually satisfy the rule
  • adjusted tests to assert the new return contract and updated README return types

Verification

  • previously verified in this branch:
    • npx vitest run --config packages/folder-structure-cruiser/vite.config.mts
    • npx nx build folder-structure-cruiser
    • CLI smoke checks for exit codes (1 on violations, 0 on clean run)
  • current environment note: node/npm binaries are unavailable right now, so tests could not be re-run for this last wording-only change

Slack Thread

Open in Web Open in Cursor 

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates folder-structure-cruiser so validations report violation counts to callers and the CLI exits with a non-zero status when violations (or runtime errors) are detected.

Changes:

  • Change validateCrossFeatureImports and validateSharedComponent to return the number of detected violations.
  • Update CLI (src/bin.ts) to set process.exitCode = 1 when violations are found, and use parseAsync().catch(...) for runtime error handling.
  • Update tests and README to reflect the new return contract.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/folder-structure-cruiser/src/commands/validateSharedComponent.ts Return violation count and keep console output behavior.
packages/folder-structure-cruiser/src/commands/validateCrossFeatureImports.ts Return violation count and keep console output behavior.
packages/folder-structure-cruiser/src/bin.ts Set exit code based on violations; catch async parse/runtime errors.
packages/folder-structure-cruiser/README.md Document updated return type (Promise<number>).
packages/folder-structure-cruiser/tests/shared-components.spec.ts Assert returned violation count in tests.
packages/folder-structure-cruiser/tests/cross-feature-imports.spec.ts Assert returned violation count in tests (partially).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/folder-structure-cruiser/src/commands/validateCrossFeatureImports.ts Outdated
Comment thread packages/folder-structure-cruiser/src/commands/validateSharedComponent.ts Outdated
Comment thread packages/folder-structure-cruiser/src/bin.ts
Comment thread packages/folder-structure-cruiser/__tests__/cross-feature-imports.spec.ts Outdated
Comment thread packages/folder-structure-cruiser/__tests__/cross-feature-imports.spec.ts Outdated
Comment thread packages/folder-structure-cruiser/__tests__/cross-feature-imports.spec.ts Outdated
@Komoszek

Copy link
Copy Markdown
Contributor Author

@cursor fix comments

@cursor

cursor Bot commented Apr 28, 2026

Copy link
Copy Markdown

Zrobione — poprawiłem komentarze z review i wypchnąłem zmiany.

Co naprawiłem

  • Grammar fix w obu komendach:
    • violations(s) → poprawne violation / violations zależnie od liczby.
  • Spójne logowanie błędów w CLI:
    • handleCommandError w src/bin.ts używa teraz logger.error(...) zamiast console.error(...).
  • Testy “should allow …” w cross-feature-imports.spec.ts:
    • teraz asercje są mocne (violationsCount === 0) i używają ścieżek/fikstur, które rzeczywiście spełniają regułę, żeby test był stabilny.

Weryfikacja

  • uruchomione i zielone:
    • npx vitest run --config packages/folder-structure-cruiser/vite.config.mts

Git / PR

Open in Web Open in Cursor 

Comment thread packages/folder-structure-cruiser/src/commands/validateCrossFeatureImports.ts Outdated
cursoragent and others added 3 commits May 12, 2026 11:36
Co-authored-by: Łukasz Komoszyński <Komoszek@users.noreply.github.com>
Co-authored-by: Łukasz Komoszyński <Komoszek@users.noreply.github.com>
Co-authored-by: Łukasz Komoszyński <Komoszek@users.noreply.github.com>
@Komoszek Komoszek force-pushed the szpont/folder-cruiser-exit-code-0b20 branch from 5a670ee to 2f144bd Compare May 12, 2026 09:45
@Komoszek Komoszek marked this pull request as ready for review May 12, 2026 09:45
@Komoszek Komoszek merged commit 8da0bd7 into main May 12, 2026
1 check passed
@Komoszek Komoszek deleted the szpont/folder-cruiser-exit-code-0b20 branch May 12, 2026 15:22
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.

4 participants