README
README
This node package is mainly consists of domain models that need to be shared with other AMAG application.
This package was created by following the step by step instruction on https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c
Understanding of scripts command in Package.json
- prepare will run both BEFORE the package is packed and published, and on local npm install. Perfect for running building the code.
- prepublishOnly will run BEFORE prepare and ONLY on npm publish.
- preversion will run before bumping a new package version. To be extra sure that we’re not bumping a version with bad code, why not run lint here as well?
- version will run after a new version has been bumped. If your package has a git repository, like in our case, a commit and a new version-tag will be made every time you bump a new version. This command will run BEFORE the commit is made.
- postversion will run after the commit has been made. A perfect place for pushing the commit as well as the tag.
Publish package on npm account
Login to NPM account first
npm login
Bumping a new patch version of the package
Make sue nothing is checked out in your local repository before bumping a version. Run the following command. Our preversion, version, and postversion will run, create a new tag in git and push it to our remote repository. Then after you can Publish the package.
npm version patch
Publish to npm account
The same version can not be published. Make sure you have bumped the version by running above command. Then after run the following command. You will see that the package will first be built by the prepare script, then test and lint will run by the prepublishOnly script before the package is published.
npm publish
Unpublishing entier package
Please note that unpublished package, can not be republished for 24 hours.
npm unpublish amag-corelib -f
To install this package in other application
npm install amag-corelib
Unit Testing with Jtest
- test file must be ended with .test.ts
- test file under the src and its subfolder will be executed by running the following command
npm test