npm install
npm run buildThe build process:
- Runs ESLint license header check (
npm run license) - Compiles TypeScript (
tsc) - Generates
build/package.jsonusing package-manifest-generator
The generated build/package.json is created from:
- Dependencies extracted from the compiled JS files
- Metadata from
.pmgrc.toml(name, description, bin, engines, etc.) - Version defaults to
SNAPSHOT(configured in.pmgrc.toml)
# Run unit tests
npm test
# Run a single test file
npx tsx --test test/unit/properties.test.ts
# Run integration tests (requires build first)
npm run build
npm run test-integrationReleases are handled by the GitHub Actions workflow (.github/workflows/release.yml) when a release is published on GitHub.
- Create a new release on GitHub
- Set the tag name (e.g.,
1.2.3) - Add a
Description:line in the release body (required for the Update Center) - The workflow will:
- Build the package with the release version
- Publish to Artifactory
- Publish to npm under two package names:
@sonar/scan(primary)sonarqube-scanner(legacy alias for backwards compatibility)
- Create a PR in sonar-update-center-properties
Example release body:
Description: Support new authentication method
## What's Changed
* SCANNPM-XXX Add new auth support by @user in #123
The npm tag is determined automatically:
| Condition | npm tag |
|---|---|
| Prerelease checkbox is checked | next |
Release body contains [skip-latest] |
release-X.x (where X is major version) |
| Otherwise | latest |
When releasing a patch for an older major version (e.g., releasing 1.2.4 when 2.x is current), you don't want to move the latest tag. To do this:
- Create the release on GitHub
- Add
[skip-latest]anywhere in the release notes body - Publish the release
The package will be published with a tag like release-1.x instead of latest, so users running npm install @sonar/scan will continue to get the current latest version.
Example release notes:
## Bug Fixes
- Fixed issue with proxy configuration
[skip-latest]
You can test the release workflow without actually publishing by using the manual trigger:
- Go to Actions → Release workflow
- Click Run workflow
- Fill in the inputs:
- Dry run: ✅ checked (skips all publish steps)
- Release tag: The version to simulate (e.g.,
1.2.3) - Release description: The description for the Update Center entry
- Simulate prerelease: Check to test prerelease behavior
- Simulate [skip-latest]: Check to test the skip-latest behavior
The workflow will run and display the npm tag that would be used without performing any actual build or publish operations. The Update Center PR is still created during dry runs so you can verify the changes (just close the PR afterwards).
The Sonar Update Center is automatically updated by the release workflow. When a release is published, the workflow creates a PR in sonar-update-center-properties to update scannernpm.properties that:
- Adds the new version entry using the
Description:from the release body - Moves the previous public version to
archivedVersions
After the release workflow completes, the following manual steps are required to fully publish the new version:
-
Merge the Update Center PR
- Review and merge the PR created in sonar-update-center-properties
- The PR link is included in the Slack notification
-
Deploy the Update Center
- Run the deploy workflow in sonar-update-center-properties
- This publishes the updated JSON to https://downloads.sonarsource.com/sonarqube/update/scannernpm.json
-
Update the Documentation
- Run the generate-release-notes workflow in sonarqube-documentation
- This creates a PR to update the scanner versions (example: sonarqube-documentation#94)
- Merge the generated PR to publish the new version at https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/scanners/npm/installing
Each version entry in scannernpm.properties follows this format:
X.Y.Z.description=Short description of the release
X.Y.Z.date=YYYY-MM-DD
X.Y.Z.changelogUrl=https://github.com/SonarSource/sonar-scanner-npm/releases/tag/X.Y.Z
X.Y.Z.downloadUrl=https://www.npmjs.com/package/@sonar/scan/v/X.Y.Z- Initial setup PR: sonar-update-center-properties#742
- Published JSON: https://downloads.sonarsource.com/sonarqube/update/scannernpm.json
- Documentation page: https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/scanners/npm/installing