JavaScript monorepo starter package using:
- lerna
- babel
- jest
- commitlint
- commitizen
- husky
Clone this repository
git clone https://github.com/lukeaus/js-client-server-common-monorepo-starter
Change directory into new
cd js-client-server-common-monorepo-starter
Remove example packages folder
rm -rf packages/
Install
npm install
Create a new pacakge
npx lerna create <name>
Congratulations - you have a monorepo containing one package.
Uses Lerna for package management.
Separate packages stored in ./packages
Common devDependencies should be installed into the monorepo root package.json
npm install --save-dev -E
If you want to run the same script on each packages repository, either
- use
lerna run <cmd>
; or - create a command in monorepo root package.json
Get started
npm install
This will also run lerna boostrap
.
All Lerna commands
Run the command below. It will ask which packages you changed and will automatically create CHANGELOG.md files in modified packages.
npm run commit
If the commit fails, run the following to prevent having to redo the commit message
npm run commit:retry
If publishing a package for first time, run this instead
npm run publish:initial
Git push and publish changes to git repo and publish to npm for an existing package
npm run publish
All dev dependencies should be added to the top level of the project.
npm install --save-dev -E pkg
lerna add some-ext-pkg@0.1.0 --scope=my-pkg-name
where 'my-pkg-name' is the name of your package in 'packages'.
Don't require from a different package (in 'pacakages').
Instead require it through the package manager.
lerna add my-pkg-name-foo my-pkg-name-bar --scope=my-pkg-name-baz
View changes to specific repo
git log packages/foo