This library is based on https://github.com/bcgov/entity/blob/master/rfcs/rfc-shared-components.md.
The Storybook (sample) pages for this library are at https://bcgov.github.io/bcrs-shared-components/.
*** NOTE: USE NODE VERSION 20 FOR THE STEPS BELOW ***
git clone git@github.com:bcgov/bcrs-shared-components.git
cd bcrs-shared-components
git fetch --all
git reset --hard origin/main
Warning: this overwrites any uncommitted changes on your branch! Stash first if needed.
git co -b my-feature-branch
npm i // if new repo
npm i --global lerna@^5.6.2 // if you didn't do this previously
NOTE: Step 5 to 9 are only for adding new component
lerna bootstrap --hoist
This updates the node_modules/ in the sub-folders.
npm run test:unit MyComponent
npm run build-storybook
npm run storybook
NOTE: rebuilding Storybook will delete file .nojekyll
. Do not commit this change, ie, restore this file.
Storybook should open in your browser (and will auto-rebuild on code changes).
Note: GitHub Pages are used to serve the Storybook app folder. As this requires a developer to build before committing, they should ensure that they are building the latest code (ie, including all other recent changes in the repo).
git push --set-upstream origin my-feature-branch
git co main
git fetch origin
git rebase
lerna version --include-merged-tags
Note: This step will create new tags and commit them!
lerna publish from-package
Note: For this step, you need to be logged in to NPM (along with permissions on this library)... follow the prompts if applicable.
If you want, you can create a new shared package for supporting code (eg, "mixins"). Or, you can just create a local copy of the files that you need (eg, with only the content that you need) that your shared component will use when running in Storybook. When your component is running in your actual app, it would use the app's copy of those files.
To create a new package:
- create the new package folder (eg, "./src/mixins")
- add the code files
- add a package.json file with version = "0.0.0" (see others as examples)
- add the package name to the "packages" array in lerna.json
- commit the changes
- run
lerna version --include-merged-tags
to version your package to "1.0.0" - run
lerna publish from-package
to publish your package to npm