lerna-publish
A simple script for publishing Lerna monorepo projects.
Installation
Install using
# If using npm
npm install -D @k88/lerna-publish
# If using yarn
yarn add -D @k88/lerna-publish
Usage
Add the following three scripts to your package.json's scripts
:
{
"scripts": {
"publish:alpha": "lerna-publish alpha",
"publish:beta": "lerna-publish beta",
"publish:public": "lerna-publish public"
}
}
Details
The script will perform the following tasks:
- Check publish version (see below for more detail)
- Removes all dist/lib/node_modules directory
- Performs a fresh
npm install
- Runs
npm run lint
- Runs
npm run test
- Runs
npm run build
- Publishes the packages
Publish types
This script safeguards performing public/beta/alpha
publication based on:
-
public
may only run onmain
branch -
beta
may only run onv\d-beta
branch (i.e.v1-beta
,v2-beta
,v3-beta
, etc) -
alpha
may only run on non-beta/non-publich branches
Distribution Tags
The following tags are published:
- The
public
publish pushes alatest
dist tag - The
beta
publish pushes abeta
dist tag - The
alpha
publish pushes aalpha
dist tag
Version bump
You can pass an optional patch/minor/major
argument to change the version bump. By default, a patch
is published. Some examples are:
# Publishes a patch beta
npm run publish:beta
# Publishes a minor public
npm run publish:public minor
No package-lock.json
If you do not want to keep your package-file.json, provide NO_PACKAGE_LOCK=1 lerna-publish ...
to force-remove the lock.