- Install
asdf
if not already installed - Clone this repository
cd
into the repository
- See docs for setup
- Run
bash .git/hooks/pre-commit
from repo to execute pre-commit on staged files without commiting
What are pre-commit hooks?
- Run
yarn
to install package dependencies (follow any promptsasdf
provides) - Run
yarn bootstrap
to install necessary dependencies. - Run
yarn llink
to set up symlinks - Run
yarn build
to 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
.env
file based onenv.example
and contact Button Inc. for credentials cd
into 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 Storybook
above
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
develop
called [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.json
of 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.md
files intolib
directory to publish the packages based offlib
directory.
- 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
develop
merge event, newStorybook
static artifacts are deployed to github pages instorybook
branch. - Build and deploy storybook:
yarn build-storybook:button
oryarn build-storybook:bcgov
yarn deploy-storybook
Runningyarn deploy-storybook
does this:- storybook-deployer allows to generate a default index.html that links to all of the loaded storybooks in
packages
directory. - As
storybook-deployer
deploys storybook using PAT in CI environment, we only usestorybook-deployer
to generate the artifacts, and we force updatestorybook
branch 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