Skip to content

Publish NPM packages

The DTaaS software is developed as a monorepo with multiple npm packages.

Default npm registry

The default registry for npm packages is npmjs. The freely-accessible public packages are published to the npmjs registry. The publication step is manual.

1
2
3
4
5
npm login --registry="https://registry.npmjs.org"
cat ~/.npmrc  #shows the auth token for the registry
//registry.npmjs.org/:_authToken=xxxxxxxxxx
yarn publish --registry="https://registry.npmjs.org" \
  --no-git-tag-version --access public

At least one package is published to this registry for each release of DTaaS. This published package is used in the release scripts.

Github npm registry

The Github actions of the project publish packages. The only limitation is that the users need an access token from Github.

Private Registry

Setup private npm registry

Since publishing to npmjs is irrevocable and public, developers are encouraged to setup their own private npm registry for local development. A private npm registry will help with local publish and unpublish steps.

We recommend using verdaccio for this task. The following commands help you create a working private npm registry for development.

1
2
3
4
5
6
docker run -d --name verdaccio -p 4873:4873 verdaccio/verdaccio
npm adduser --registry http://localhost:4873 #create a user on the verdaccio registry
npm set registry http://localhost:4873/
yarn config set registry "http://localhost:4873"
yarn login --registry "http://localhost:4873" #login with the credentials for yarn utility
npm login #login with the credentials for npm utility

You can open http://localhost:4873 in your browser, login with the user credentials to see the packages published.

Publish to private npm registry

To publish a package to your local registry, do:

1
2
3
4
yarn install
yarn build #the dist/ directory is needed for publishing step
yarn publish --no-git-tag-version #increments version in package.json, publishes to registry
yarn publish #increments version in package.json, publishes to registry and adds a git tag

The package version in package.json gets updated as well. You can open http://localhost:4873 in your browser, login with the user credentials to see the packages published. Please see verdaccio docs for more information.

If there is a need to unpublish a package, ex: @dtaas/runner@0.0.2, do:

npm unpublish  --registry http://localhost:4873/ @dtaas/runner@0.0.2

To install / uninstall this utility for all users, do:

1
2
3
sudo npm install  --registry http://localhost:4873 -g @dtaas/runner
sudo npm list -g # should list @dtaas/runner in the packages
sudo npm remove --global @dtaas/runner

🚀 Use the packages

The packages available in private npm registry can be used like the regular npm packages installed from npmjs.

For example, to use @dtaas/runner@0.0.2 package, do:

sudo npm install  --registry http://localhost:4873 -g @dtaas/runner
runner # launch the digital twin runner