@ttvuong/best-practice
v1.0.6
Published
@hemidi/best-practice — SonarQube helper
Readme
@hemidi/best-practice — SonarQube helper
Usage
- Initialize sonar config:
npx midi-sonar --init - Preferred: set token via environment (or .env):
- macOS/Linux:
SONAR_TOKEN=YOUR_TOKEN npx midi-sonar --scan - Windows PowerShell:
$env:SONAR_TOKEN='YOUR_TOKEN'; npm run sonar - Or place
SONAR_TOKEN=YOUR_TOKENin a local.env(not committed) then runnpm run sonar
- macOS/Linux:
- Verify readiness:
npx midi-sonar --verify
What it does
- Adds
sonar-project.propertiesfrom a template tailored for NestJS/Angular defaults. - Adds npm scripts:
sonar,sonar:run,sonar:verify. - Uses the local
sonar-scannerif available in PATH. It does not configure your SonarQube server.
Token
- Do NOT store tokens in package.json scripts.
- Provide via environment variable
SONAR_TOKEN(recommended). Optionally--token=YOUR_TOKENfor ad-hoc runs.
Install SonarScanner CLI
- Follow SonarSource docs: https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/sonarscanner/
- Ensure the
sonar-scannerexecutable is available in your PATH.
