@webprovise1/bb-permission
v1.0.17
Published
Common permission library for all Bamboo applications
Downloads
157
Readme
permission-lib
Made with create-react-library
Development
Required
Ensure your environment has the environment variable NPM_TOKEN
available or npm scripts will fail with the following error:
error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".
- .env file will not work.
- You will need to add via Environment Variables tool in Windows or simply
export NPM_TOKEN=
in *nix terminals. Any value is okay.
Install dependencies
$ yarn install
Build distribution
$ yarn build
Publish to NPM
Reference: https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions
In shorts:
- POINT 1: Treat the <major.minor.patch> version as official release or the "master branch". Only bump the official version once it needs to be deployed for alpha deployment.
- POINT 2: If the changes in other applications cannot be merged yet (due to back-end blocking, etc.) but you want to test the integration of the library: bump the major/minor/patch version and add '-alpha.<number>' (e.g: The current version is 1.0.14, you want to create a test a big feature => the new version is 2.0.0-alpha.1)
Note: For multiple people working on different features, you have to use different versions. (e.g: X and Y are working on different features, they should create separate alpha releases - 1.1.1-alpha.1 and 2.0.0-alpha.1; if they needs to re-release again just bump the specific number after alpha)
In-implementation features
If you want to deploy a test version:
- Update the
version
property ofpackage.json
file using the second method (bump the version and add alpha suffix): major.minor.patch-alpha.number - Create a merge request along with your changes
- The merge request pipeline should be triggered, including two steps:
- build (to verify if the code can be built) - this step is ran automatically
- deploy alpha to npm (to deploy the alpha version to npm) - this step must be ran manually, you cannot deploy from this step without having alpha suffix in package version
- After the alpha version is deployed, update the applications.
Official release
If the feature is approved and ready to merge into the master branch. You should do the following
- Update the
version
property ofpackage.json
file using the first method (without alpha suffix): major.minor.patch - Push the change to your existing merge request
- The merge request pipeline should be triggered, including two steps:
- build (to verify if the code can be built) - this step is ran automatically
- deploy alpha to npm (to deploy the alpha version to npm) - ignore this step, you cannot deploy from this step without having alpha suffix in package version
- Get code review, approval and merge into the master branch. The pipeline will deploy the official version to NPM.
- After the official release is deployed, update the applications.
Usage in applications
Install latest stable version:
Make sure the application project has the .npmrc
file:
# .npmrc
@webprovise1:registry=https://registry.npmjs.org
//registry.npmjs.org/:_authToken=<TOKEN - get from team lead>
$ yarn add @webprovise1/bb-permission
Install local version:
- In this library project:
$ yarn build # build files
$ yarn link # mark the project to be ready for local usage
# You should see something like these
yarn link v1.22.10
success Registered "@webprovise1/bb-permission".
info You can now run `yarn link "@webprovise1/bb-permission"` in the projects where you want to use this package and it will be used instead.
Done in 0.06s.
- In the application project:
# Start using local library
$ yarn link "@webprovise1/bb-permission"
# You should see something like these
yarn link v1.22.10
success Using linked package for "@webprovise1/bb-permission".
Done in 0.07s.
# To use the NPM version again
$ yarn unlink "@webprovise1/bb-permission"
# remove and add again if you don't see the original version
$ yarn remove @webprovise1/bb-permission
$ yarn add @webprovise1/bb-permission
Import in codebase
import { PermissionRoute, TracePermission } from '@webprovise1/bb-permission';