- Install
asdfif not already installed - Clone this repository
cdinto the repository
- See docs for setup
- Run
bash .git/hooks/pre-commitfrom repo to execute pre-commit on staged files without commiting
What are pre-commit hooks?
- Run
yarnto install package dependencies (follow any promptsasdfprovides) - Run
yarn bootstrapto install necessary dependencies. - Run
yarn llinkto set up symlinks - Run
yarn buildto compile all packages - Run
yarn storybook:<theme>where<theme>isbcgov,button, or your custom theme - Storybook will open in a browser
To run unit tests in all packages, run yarn test:jest
To generate happo screenshots locally:
- create an
.envfile based onenv.exampleand contact Button Inc. for credentials cdinto the desired package and runyarn happo run
To install a new package:
- in the root directory,
yarn add [packageName] -W - if you have any trouble with directories or files not being found, re-run the commands from
Build and Run Storybookabove
To install a new package to a Lerna sub-package
- in the root directory,
lerna add [packageName] [--scope={subPackage}] [--dev](eg.lerna add typescript --scope=@button-inc/button-theme --dev) - see the Lerna documentation
To build, run yarn bootstrap followed by yarn llink followed by yarn build-storybook:<theme> where theme is one of:
- button
- bcgov
To test build locally, run npx http-server ./storybook-static after building.
It runs a set of checks in github actions to ensure that new changes meet the code conventions and standards.
- Unit tests
- Pre-commit hooks
It generates build artifacts to deploy/publish a new storybook and NPM package versions.
In order to avoid potential side effects using lerna version/publish commands, we deploy packages individually using helper scripts in the scripts directory.
- Create a new branch off
developcalled [issue#]-release-[library] (library is base, button, or bcgov) - Log into the NPM registry. (See Toolkit credentials in 1Password.)
npm login
- Update the version in the
package.jsonof the target package. - Publish the target package to NPM registry using Make command.
- In the target directory,
make publish
- it copies
package.json,LICENSE, andREADME.mdfiles intolibdirectory to publish the packages based offlibdirectory.
- If desired, update the version of the other packages that reference the updated package. (This happens automatically when you update the base library.)
- In the root directory,
yarn sync-version --name=<package-name>
- Merge the release branch into
develop.
- On
developmerge event, newStorybookstatic artifacts are deployed to github pages instorybookbranch. - Build and deploy storybook:
yarn build-storybook:buttonoryarn build-storybook:bcgovyarn deploy-storybookRunningyarn deploy-storybookdoes this:- storybook-deployer allows to generate a default index.html that links to all of the loaded storybooks in
packagesdirectory. - As
storybook-deployerdeploys storybook using PAT in CI environment, we only usestorybook-deployerto generate the artifacts, and we force updatestorybookbranch using Deploy Key to have fine-grained controls over permissions.
- storybook-deployer allows to generate a default index.html that links to all of the loaded storybooks in