Skip to content

Latest commit

 

History

History
159 lines (127 loc) · 11.7 KB

README.md

File metadata and controls

159 lines (127 loc) · 11.7 KB

Lerna-Lite 🐉

License: MIT TypeScript npm NPM downloads lerna--lite

PR jest codecov Actions Status

Lerna-Lite is a super light version of the original Lerna


License

MIT License

About Lerna-Lite

Lerna-Lite differs from the original Lerna in the sense that it only includes 3 commands (1 is optional) out of 15 commands that the original Lerna has. It also assume that you have already setup a Workspace through NPM, Yarn or any other technology that will take care of the symlinks (Lerna-Lite does not include the bootstrap command hence the need for a pre-setup workspace), so make sure that your workspace is properly setup before installing Lerna-Lite.

Why create this lib/fork?

Mainly for the following reasons:

  1. the original Lerna is no longer maintained (dependencies are out of date)
  2. create a lighter lib that still provide Lerna's approach of Versioning and Publishing by following the Conventional Commits and also automatically create Conventional-Changelog for each package of the workspace. We don't need all packages of Lerna anymore since NPM Workspaces (or other technologies) came out.
  3. add some little extras while keeping the lib small.
    • the lib is smaller because we only copied 3 out of 15 commands from Lerna
  4. rewrite the lib with TypeScript

This lib will help you with

Version & Publish commands

  • Automate the rolling of new Versions (independent or fixed) for all your workspace packages
    • it will automatically add Commit & Tag your new Version in Git & create new GitHub or GitLab Release when enabled
  • Automate the creation of Changelogs for all your packages by reading all Conventional Commits
    • each package will get its own changelog and a combined changelog will also be created in the root
  • Automate the repository Publish of your new versions for all your packages (NPM or other platform)

Run command (optional)

  • Run is an optional package that will help you run npm script in parallel and in topological order.

Lerna-Lite Packages

Package Name Version Description Changes
@lerna-lite/cli npm Lerna-Lite Version/Publish comands CLI changelog
@lerna-lite/core npm Lerna-Lite core & shared methods changelog
@lerna-lite/publish npm Publish packages in the current workspace changelog
@lerna-lite/run npm Run command and CLI to run npm scripts in the workspace changelog
@lerna-lite/version npm Bump Version & write Changelogs changelog

Project Demo?

You want to see a demo project? Sure, you're looking at it 😉

Yes indeed, this lib was created as an NPM Workspace specifically for the purpose of demoing and testing of its own code. All changelogs and published versions were created by the lib itself, how sweet is that? You will also find that it has its own lerna.json config file just as well as you would when using the lib.

See it in Action 🎦

You can see a small video of a new version release on this Release Demo - Wiki - Confused with all the options? Consult the multiple links below.

References

README Badge

Using Lerna-Lite? Add a README badge to show it off: lerna--lite

[![lerna--lite](https://img.shields.io/badge/maintained%20with-lerna--lite-cc00ff)](https://github.com/ghiscoding/lerna-lite)

Installation

Run the following commands to install Lerna-Lite in your project and/or install it globally once with the -g option.

Command Install Description Included
📑 version npm install @lerna-lite/cli create new version for each workspace package Yes
✉️ publish npm install @lerna-lite/cli publish each workspace package Yes
🏃 run npm install @lerna-lite/run run npm script in each workspace package Optional

Note: the default lerna CLI is only including 2 built-in commands (publish and version), while the (run) command is optional and must be installed separately as shown below.

# Lerna CLI which includes `publish`, `version` commands
npm install @lerna-lite/cli  # OR yard add @lerna-lite/cli

# install optional `run` command
npm install @lerna-lite/run  # OR yarn add @lerna-lite/run

Usage

Add custom NPM Scripts or simply run the commands in a shell with Lerna-Lite CLI.

// package.json / npm scripts
"scripts": {
  "new-version": "lerna version",
  "new-publish": "lerna publish from-package",
  "run-tests": "lerna run test", // optional `run` command
}

Configuration

You could configure and run Lerna in 3 different ways:

  1. via a lerna.json file
  2. via a "lerna": {} property directly under your package.json
  3. or by passing arguments directly directly in the shell when executing the command.

You can find more info by reading about the lerna.json - Wiki.

Migration for Lerna Users

If you are migrating from Lerna, it should be fairly easy to just replace Lerna with Lerna-Lite in your dependencies and that's about it, the CLI commands are the same, take a look at the quick steps shown below:

  1. remove Lerna from your local & global dependencies
npm uninstall lerna     # OR yarn remove lerna
npm uninstall -g lerna  # OR yarn global remove lerna
  1. install Lerna-Lite CLI to get version and publish commands
    • run command is optional and can be installed separately as shown below
# Lerna CLI (`version` & `publish` commands)
npm install @lerna-lite/cli

# install optional `run` command
npm install @lerna-lite/run

Development / Contribution

If you wish to contribute to the project, please follow these steps

  1. clone the lib:
    • git clone https://github.com/ghiscoding/lerna-lite
  2. install with NPM:
    • npm install
  3. run a TypeScript (TSC) build
    • npm run build
  4. add/run Jest unit tests (make sure to run the previous step first):
    • npm run jest # OR npm run jest:watch
  5. you can troubleshoot/debug the code via the VSCode debugger launch configs that were setup

Contributions

Feel free to contribute any Pull Request, PRs are very welcome. 👷👷‍♀️

Also please note that I'm just a simple developer & user of this lib, the same as you are, my knowledge of the library is also probably similar to yours but together we can make it better (and lighter).

Troubleshooting

If you have problems running the lib and your problems are related to Git commands that were executed, then we suggest to first try with the --git-dry-run option to see if it helps in finding the error(s) you may have. Another great, and possibly much more useful suggestion, is to search in the original Lerna issues list and see if any solution could help you (remember that Lerna-Lite is a fork of the original code from Lerna and it works the same way). Lastly, if that is not enough and you wish to troubleshoot yourself, then read this Troubleshooting - Wiki to possibly troubleshoot yourself in your own environment.