Marketplace Common
A library of reusable code for use in Uptodate Marketplace projects.
About this package
The Marketplace common package was created in May 2021 with the goal of improving code reuse and reducing code duplication in Marketplace projects. It is supposed to contain all classes, functions and constants which are used in more than one project. Instead of copying and pasting the same code from one repository to another, it is preferred that the shared code is put into this package.
What code should I put in here?
- Everything that is used in more than one place. Put it in here instead of copying and pasting (duplicating) code.
- Do not put code in here because you think it might be generally useful. If it is used in only one place, just put it there directly.
- Do not put UI components or assets (styles, fonts, images etc.) here. We will soon have a separate package for that.
Using the package
The code in this library is bundled into an NPM package and published to our private NPM registry (via AWS CodeArtifact). This makes it easy to consume the package in another project.
However, since the registry is private, you will first need to authenticate before you can install packages from it. Please refer to the documentation page for more information on how to do that.
You will probably also need to enable the CI pipeline to consume the package, which is also described in the documentation.
Publishing a new version
If you want to publish a new version of the package to the private NPM registry, you can follow these steps:
-
Bump the package version by increasing the "version"
property in the package.json file.
-
Perform a test run of the publish to see what would happen:
$ npm publish --dry-run
Most importantly, this will show you the contents of the package as they would be published.
-
Finally, once you have verified the package, publish it as follows:
$ npm publish --access public
Note: you might need to authenticate first (aws codeartifact login
). Please refer to the documentation for more information.
Note: be sure to only publish from the latest revision of the master branch. If you need to publish a pre-release for testing purposes, use the --tag
argument to npm publish
as described here: npm-prerelease.
Tip: trying out a new version before publishing
You can use the npm pack
command to store the NPM package on your local disk:
$ cd marketplace_common
$ npm pack
Assuming that your marketplace_common
directory is in /home/user/marketplace_common
and the current version of the package is 1.0.4
, npm pack
will generate the following file:
/home/user/marketplace_common/u2dv-marketplace_common-1.0.4.tgz
You can now install this package into another project using npm
as follows:
$ npm install /home/user/marketplace_common/u2dv-marketplace_common-1.0.4.tgz
Installing the package this way is 100% identical to installing the package from the package registry via the Internet. It can be a good way to verify that the package works as expected before publishing it.
Versioning considerations
Before you publish a new release, follow the semantic versioning guidelines in order to choose a new version number. Most importantly, use a major version bump (1.x
=> 2.x
) if you need to publish a breaking change.
Contributing
First, install the dependencies:
$ npm install
You can now run the tests:
$ npm test