Monorepo for Guardian UIs
The following packages live in libs/@guardian/*
and are published to NPM:
- @guardian/ab-core
- @guardian/ab-react
- @guardian/browserslist-config
- @guardian/core-web-vitals
- @guardian/eslint-config
- @guardian/identity-auth
- @guardian/identity-auth-frontend
- @guardian/libs
- @guardian/newsletter-types
- @guardian/prettier
- @guardian/source
- @guardian/source-development-kitchen
- @guardian/tsconfig
- Clone the repo
- Run a task.
You'll be prompted to install any missing requirements if they are needed...
Tasks that apply to all projects are defined in the Makefile
:
make build
builds all projectsmake build-storybook
builds all storybooksmake changeset
creates a new changesetmake changeset-version
takes changesets that have been made and updates versions and dependencies of packages, as well as writing changelogs updates the lockfile with the updated versions of the packages changesets/changesets#421make clean
removes all build artifacts and task cachesmake dev
runs the dev targets for all projects in single instancemake e2e
runs the e2e tests for all projectsmake fix
attemps to fix lint errors across all projectsmake formatting:check
check repo for formatting errorsmake lint
checks all projects for lint errorsmake ls
lists availablemake
targetsmake storybooks
runs storybook for all projects in single instancemake test
runs the unit tests for all projectsmake test:coverage
get test coverage for CSTI projectsmake tsc
type-checking all projectsmake validate
makes sure absolutely everything is workingmake verify-dist
runs unit tests against dist for all projects
Project-specific tasks are defined as scripts
in their package.json
, and can be run with make <project>:<script>
:
make @guardian/ab-core:build
make @guardian/ab-core:dev
make @guardian/ab-core:fix
make @guardian/ab-core:lint
make @guardian/ab-core:test
make @guardian/ab-core:tsc
make @guardian/ab-core:verify-dist
make @guardian/ab-react:build
make @guardian/ab-react:dev
make @guardian/ab-react:fix
make @guardian/ab-react:lint
make @guardian/ab-react:test
make @guardian/ab-react:tsc
make @guardian/ab-react:verify-dist
make @guardian/browserslist-config:fix
make @guardian/browserslist-config:lint
make @guardian/browserslist-config:tsc
make @guardian/browserslist-config:update-readme
make @guardian/core-web-vitals:build
make @guardian/core-web-vitals:dev
make @guardian/core-web-vitals:fix
make @guardian/core-web-vitals:lint
make @guardian/core-web-vitals:test
make @guardian/core-web-vitals:tsc
make @guardian/core-web-vitals:verify-dist
make @guardian/eslint-config:fix
make @guardian/eslint-config:lint
make @guardian/identity-auth:build
make @guardian/identity-auth:dev
make @guardian/identity-auth:fix
make @guardian/identity-auth:lint
make @guardian/identity-auth:test
make @guardian/identity-auth:tsc
make @guardian/identity-auth:verify-dist
make @guardian/identity-auth-frontend:build
make @guardian/identity-auth-frontend:dev
make @guardian/identity-auth-frontend:fix
make @guardian/identity-auth-frontend:lint
make @guardian/identity-auth-frontend:test
make @guardian/identity-auth-frontend:tsc
make @guardian/identity-auth-frontend:verify-dist
make @guardian/libs:build
make @guardian/libs:dev
make @guardian/libs:e2e
make @guardian/libs:e2e:ui
make @guardian/libs:fix
make @guardian/libs:lint
make @guardian/libs:sourcepoint-integration-test
make @guardian/libs:test
make @guardian/libs:tsc
make @guardian/libs:verify-dist
make @guardian/newsletter-types:build
make @guardian/newsletter-types:dev
make @guardian/newsletter-types:fix
make @guardian/newsletter-types:lint
make @guardian/newsletter-types:tsc
make @guardian/prettier:fix
make @guardian/prettier:lint
make @guardian/prettier:tsc
make @guardian/source:build
make @guardian/source:build-generated
make @guardian/source:build-storybook
make @guardian/source:create-icons
make @guardian/source:dev
make @guardian/source:fix
make @guardian/source:lint
make @guardian/source:storybook
make @guardian/source:test
make @guardian/source:tsc
make @guardian/source:verify-dist
make @guardian/source-development-kitchen:build
make @guardian/source-development-kitchen:build-storybook
make @guardian/source-development-kitchen:dev
make @guardian/source-development-kitchen:fix
make @guardian/source-development-kitchen:lint
make @guardian/source-development-kitchen:storybook
make @guardian/source-development-kitchen:test
make @guardian/source-development-kitchen:tsc
make @guardian/source-development-kitchen:verify-dist
make github-pages:build
make github-pages:dev
make github-pages:start
make github-pages:tsc
make storybooks:dev
CSNX uses Chromatic for visual regression testing, and all PRs require the Chromatic checks to pass before merging.
However, each run costs money, so we only want to run Chromatic when a PR is ready to merge (rather than for every push, for example).
Therefore, initially, Chromatic checks will not run.
When your PR is ready, add the run_chromatic
label. This will starts Chromatic checks.
Note
Each push while the label is applied will trigger new checks, so you may want to remove the label if you're making more changes.
Once all checks pass, you're good to merge.
Libs within CSNX are available as NPM packages. We use Changesets to automate this release process.
To publish your changes to NPM, run make changeset
. This will open the Changesets CLI, and you will be offered a list of packages to release. Once you've selected the changed package/s you'll be given the option of major
, minor
or patch
release. Select one of these and add a description.
This will create a "changeset": a .md
file containing the release information. When you merge your branch, the changeset will be picked up by the Changests GHA, which will in turn create a release PR. To complete the NPM release merge this second PR.
You will be prompted to install the recommended extensions when you open the repo.
There is also a suggested settings file (./.vscode/settings.json.default) with some defaults you may useful. It covers project-specific enhancements, useful settings for common extensions etc.
If you want to use any/all of them, create a copy of the file and remove the .default
extension.
n.b. these are your personal settings for this repo, so add anything else you find useful and remove/change anything you don't like.
If you get a command not found
error or a message saying you're using the wrong version of Node when commiting using a GUI (VSCode, GitHub desktop etc), add a ~/.config/husky/init.sh
file and load your Node version manager there.
Note
This used be located in ~/.huskyrc
. If you set that up before, you will need to recreate it at ~/.config/husky/init.sh
.
mkdir -p ~/.config/husky && cp ~/.huskyrc $_/init.sh
For example, if you use fnm
:
# ~/.config/husky/init.sh
eval "$(fnm env)"
fnm use
Or for asdf
:
# ~/.config/husky/init.sh (installed with git)
. $HOME/.asdf/asdf.sh
# ~/.config/husky/init.sh (installed with brew on intel macs)
. /usr/local/opt/asdf/libexec/asdf.sh
# ~/.config/husky/init.sh (installed with brew on apple silicon)
. /opt/homebrew/opt/asdf/asdf.sh
Or for nvm
:
# ~/.config/husky/init.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && nvm use
See https://typicode.github.io/husky/how-to.html for more info.