You know, that thing that Heracles killed using
sword and fire...

A tool for managing JavaScript projects with multiple packages.

(a.k.a. "monorepos")

Lerna is:

automatic "npm link"
automatic version bumping
semantic versioning hints
other utilities

By "managing" we mean:

my-little-pony/
      lerna.json
      package.json
      package-lock.json
      ponies/
            twilight-sparkle/
            rainbow-dash/
            pinkie-pie/
                  package.json

Monorepo structure:

init
bootstrap
commit
publish

Workflow:

lerna init

Create a new Lerna repo or upgrade an existing repo to the current version of Lerna.

$ lerna init [--independent]

lerna bootstrap

(not needed if you use yarn workspaces)

Bootstrap the packages in the current Lerna repo. Installing all their dependencies and linking any cross-dependencies.

$ lerna bootstrap [--hoist] [--no-hoist glob]

lerna publish

Create a new release of the packages that have been updated. Prompts for a new version and updates all the packages on git and npm.

$ lerna publish

import
run / exec
clean
add

Useful utilities:

lerna import

$ lerna import <path-to-external-repository>

Transforms an external repository to a monorepo package.

lerna run

$ lerna run <npm script> -- [...args]

Runs an npm script in each package that contains that script.

$ lerna run test --since master
$ lerna run build --scope "foo-*"
$ lerna run watch --parallel --stream

lerna exec

$ lerna exec -- <shell command>

Runs a shell command in each package.

$ lerna exec -- ls
$ lerna exec -- rm rf ./node_modules

lerna clean

$ lerna clean [--yes] [--scope] [--ignore]

Remove the node_modules directory from all packages.

# Equivalent to:
$ lerna exec -- rm -rf ./node_modules

Why no gifs?

I have a question!

Do you like ponies?

I'm hungry, let's eat!

Where is the food?

Questions?

Thanks!

You're awesome!
See you at the next
#BouffeFront SFEIR

Lerna

By Oleg Sklyanchuk