Supplying Version Information to Sonarqube for NPM Projects

One of the optional Analysis Parameters for Sonarqube is the project version. For Maven projects this is automatically picked up from the pom.xml file, but this is not the case for NPM projects even though they have a version in the package.json file.

Running a scan with a manually supplied version number just requires an additional parameter to be supplied.

sonar-scanner -Dsonar.projectVersion=<version number>

There are many different approaches that can be taken to extract out the version number from the package.json file.

Using only node, this one-liner will work.

$ node -pe "require('./package.json').version"

If you have the fabulous jq installed this would also work.

$ cat package.json | jq -r .version

Once you have an approach that works for you, this can be setup as a script in the package.json file to save a bit of typing of commands later on. The latter approach, using jq is a little bit cleaner to do this with as it does not require escaping.

  "name": "open-apivisualiser",
  "version": "0.0.1",
  "scripts": {
    "sonar": "sonar-scanner -Dsonar.projectVersion=$(cat ./package.json | jq -r .version)"


Homebridge, Docker, and Wake-on-Lan

Continuing on from the previous post in this series, I have been doing a bit more investigation into solving the issues I was having with the homebridge-samsung-tizen plugin. All the features of the plugin were functioning as expected, with the exception of powering on the TV. This depends on Wake-on-Lan, which by default only works in the same network subnet, something which is not true unless the docker container is ran in host network mode. I have now found how to configure this to work.

» Continue reading

Publishing a Compodoc Site to Nexus

Recently I have been looking at Compodoc for generating documentation sites for Angular projects. Some of these projects are for libraries that will be reused elsewhere, so this documentation requires to be published somewhere.

The libraries are published as NPM modules to a Sonatype Nexus instance, so it would be ideal if the documentation could be published to the same place.

» Continue reading

Selective Generation with Swagger Codegen

Swagger Codegen is a tool for generating server stubs and client SDKs for any API defined with an OpenAPI specification. This is particularly useful when you are following a spec-first API development approach.

When generating the stub code for the backend powering the API, it may not always be desirable to generate stubs for every endpoint in the same module. This will depend on the number of endpoints in your API definition, and your approach to the contents of deployed services (Microservices or otherwise). There does not appear to be a documented way to only generate stubs for some API paths using this tool. There does however appear to be an undocumented one.

» Continue reading