To work with this repository you'll need to install yarn
and lerna
globally on your machine.
Installing yarn
:
brew install yarn
Installing lerna
:
yarn global add lerna
To link all packages together and install all dependencies, you should use
lerna bootstrap
This will:
- Install all external dependencies
- Symlink together all the Lerna packages that are dependencies of each other.
- Run prepublish in all bootstrapped packages.
With the help of yarn workspaces
, any external dependency will be installed in the root and linked to all packages instead of installed in every package on it's own.
yarn workspace <workspace_name> <command>
This will run the chosen Yarn command in the selected workspace.
Example:
yarn workspace @maf/b2b add @testing-library/react -D
This will add @testing-library/react
as devDependency
in your packages/b2b/package.json
.
This command can be used to run any script you'd like on a specific workspace: test
, dist
and every script defined in the workspace package.json
.
yarn add @babel/cli -DW
This will install @babel/cli
as a devDependency
on the monorepo root. the -D
is for devDependency
, the -W
is to install in the root.
To run scripts on all workspaces, we use lerna
.
All you need to do is run lerna run
and the script you want.
This command will run the test
script defined in every workspace
lerna run test
lerna run test --since master
This will run test
script defined in the workspaces that changed from master
branch.
lerna diff
This will print all the changes from master
by commits.
lerna changed
This will print all packages changed from master
by name.