A CLI tool (sonar) that integrates SonarQube Server and Cloud into developer workflows.
Use the package.json scripts for full test runs.
bun run lint # ESLint (TypeScript-aware, includes import sort)
bun run lint:fix # Auto-fix safe issues
bun run typecheck # tsc --noEmit
bun run test:unit # All unit tests
bun run test:integration # All integration tests, no coverage (local development)
bun run test:all # Unit + integration
bun run test:coverage # Full merged lcov report (unit + integration, slow)- Unit:
bun test <file>— no setup needed. - Integration: run
bun run pretest:integrationonce first (builds binary, sets up resources), thenbun test <file>as many times as needed.
- Always fix TypeScript errors before considering a task done.
- Never attempt to fix linting issues until the implementation is correct.
- Use
import typefor type-only imports. - MANDATORY: After editing any
.tsfile, runbun run formatto format all source files at once, orbun x prettier --write <file>for a single file.
Each command lives in src/cli/commands/. The command tree is defined in src/cli/command-tree.ts and the entry point is src/index.ts.
To add a new command: add it to src/cli/command-tree.ts and implement the logic in a new folder under src/cli/commands/.
Please declare commands using the type defined in src/cli/commands/_common/sonar-command.ts.
By default, new commands should register a authenticatedAction(), only technical commands will use anonymousAction().
Please use the exception types defined in src/cli/commands/_common/error.ts for production code. If you need to throw an error from a mock in test code, it's fine to use the generic Error type.
- Persistent state (server URL, org, project) is managed via
src/lib/state-manager.ts. - Tokens are stored in the system keychain via
src/lib/keychain.ts— never store tokens in plain files. - All path and URL constants live in
src/lib/config-constants.ts— import from there instead of hardcoding.
Please try to create integration tests in priority. If the test is too complicated to set up, write unit tests. Try to get inspiration from other tests to follow the same structure.
- Unit tests:
tests/unit/— run withbun test:unit - Integration tests:
tests/integration/— require env vars. They are using a harness to help set up tests and make assertions. Run withbun test:integration. - The UI module has a built-in mock system (
src/ui/mock.ts) — use it instead of mocking stdout directly.
When adding, removing, or changing commands, scripts, or project structure, update CLAUDE.md, and AGENTS.md to reflect the change before finishing.