@k88/lerna-it v1.0.1
lerna-it
A simple script for publishing Lerna monorepo projects.
Installation
Install using
# If using npm
npm install -D @k88/lerna-it
# If using yarn
yarn add -D @k88/lerna-it
Usage
Add the following scripts to your package.json's scripts
:
{
"scripts": {
"release:alpha": "lerna-release alpha",
"release:beta": "lerna-release beta",
"release:public": "lerna-release public",
"publish": "lerna-publish"
}
}
Details
The release:*
scripts are invoked from your local machine; it will create a release tag and push the changes up.
At this point, your CI/CD pipeline should be configured to run to invoke the publish
script that would then perform the following tasks:
1) Check publish version (see below for more detail)
2) Removes all dist/lib/node_modules directory
3) Performs a fresh npm install
4) Runs npm run lint
5) Runs npm run test
6) Runs npm run build
7) Publishes the packages
Publish types
This script safeguards performing public/beta/alpha
publication based on:
public
may only run onmain
branchbeta
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 release:beta
# Publishes a minor public
npm run release:public minor
Travis Example
Here is an example of your .travis.yml
file:
before_deploy:
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> $HOME/.npmrc 2> /dev/null
deploy:
provider: script
script: "npm run publish"
skip_cleanup: true
on:
tags: true
branch: main
repo: YOUR-ORG/YOUR-REPO
branches:
- main
- /^v\d+\.\d+\.\d+.*$/