Node.js, npm
Prerequisites
Eligible images
|
Build, run tests, and publish in a Node.js project
Currently, Automation does not provide any API for working with npm. So, the only way to build, test, and publish Node.js projects is to use the npm
tool in shell scripts.
The content of .space.kts
might look like follows:
In more details:
env["REGISTRY"]
: specifies an npm registry.npm ci
: installs npm dependencies.npm run build
: runsbuild
step if it exists.npm run test
: runs tests../publish.sh
: runs the publishing script. See details below.
The publish.sh
script authenticates in the registry using the .npmrc
file and then publishes the npm package:
In more details:
registry = $REGISTRY
: specifies registry URL using the environment variable set in .space.kts.$JB_SPACE_CLIENT_ID
and$JB_SPACE_CLIENT_SECRET
: environment variables that authenticate the Automation service in Space Packages.VERSION="0.0.$JB_SPACE_EXECUTION_NUMBER"
: uses the$JB_SPACE_EXECUTION_NUMBER
to specify the package version based on the script run number.