Lerna - DaoCasino/Documentation GitHub Wiki

Lerna Publish

Publish packages in the current project

General

To publish anything to our account token from .npmrc (our account) is needed.

Usage

npm install -g lerna
lerna bootstrap

This will create a dummy file and a packages folder.

Bootstrap

lerna bootstrap
  1. Link together all packages that depend on each other.
  2. npm install all other dependencies of each package.

Updated

lerna updated
  1. Check which packages have changed since the last release, and log it.

Publishing

lerna publish
  1. Publish each module in packages that has been updated since the last version to npm with the tag prerelease.
  2. Once all packages have been published, remove the prerelease tags and add the tags latest and stable.

If you need to publish prerelease versions, set an env variable. NPM_DIST_TAG=next lerna publish. This will add the tag you specify instead of latest and stable.

How it works

Lerna projects operate on a single version line. The version is kept in the file VERSION at the root of your project. When you run lerna publish, if a module has been updated since the last time a release was made, it will be updated to the new version you're releasing. This means that you only publish a new version of a package when you need to.

Usage

lerna publish          # publish packages that have changed since the last release
lerna publish from-git # publish packages tagged in current commit

When run, this command does one of the following things:

  • Publish packages updated since the last release (calling lerna version)
  • Publish packages tagged in the current commit (from-git).
  • Publish an unversioned "canary" release of packages (and their dependents) updated in the previous commit.

It will never publish packages which are marked as private.

Note: to publish scoped packages, you need to add the following to each package.json:

  "publishConfig": {
    "access": "public"
  }

Positionals

bump from-git

In addition to the semver keywords supported by lerna version lerna publish also supports the from-git keyword. This will identify packages tagged by lerna version and publish them to npm.

Options

lerna publish supports all of the options provided by lerna version in addition to the following:

--canary

lerna publish --canary
# 1.0.0 => 1.0.1-alpha.0+${SHA} of packages changed since the previous commit

lerna publish --canary --preid beta
# 1.0.0 => 1.0.1-beta.0+${SHA}

# The following are equivalent:
lerna publish --canary minor
lerna publish --canary preminor
# 1.0.0 => 1.1.0-alpha.0+${SHA}

When run with this flag, lerna publish publishes packages in a more granular way (per commit). Before publishing to npm, it creates the new version tag by taking the current version, bumping it to the next minor version, adding the provided meta and appending the current git sha (ex: 1.0.0 becomes 1.1.0-alpha.${SHA}).

--npm-client <client>

Must be an executable that knows how to publish packages to an npm registry. The default --npm-client is npm.

lerna publish --npm-client yarn

May also be configured in lerna.json:

{
  "command": {
    "publish": {
      "npmClient": "yarn"
    }
  }
}

--npm-tag <dist-tag>

lerna publish --npm-tag next

When run with this flag, lerna publish will publish to npm with the given npm dist-tag (defaults to latest).

This option can be used to publish a prerelease or beta version under a non-latest dist-tag, helping consumers avoid automatically upgrading to prerelease-quality code.

Note: the latest tag is the one that is used when a user runs npm install my-package. To install a different tag, a user can run npm install my-package@prerelease.

--no-verify-access

By default, lerna will verify the logged-in npm user's access to the packages about to be published. Passing this flag will disable that check.

If you are using a third-party registry that does not support npm access ls-packages, you will need to pass this flag (or set command.publish.verifyAccess to false in lerna.json).

--registry <url>

When run with this flag, forwarded npm commands will use the specified registry for your package(s).

This is useful if you do not want to explicitly set up your registry configuration in all of your package.json files individually when e.g. using private registries.

--temp-tag

When passed, this flag will alter the default publish process by first publishing all changed packages to a temporary dist-tag (lerna-temp) and then moving the new version(s) to the default dist-tag (latest).

This is not generally necessary, as Lerna will publish packages in topological order (all dependencies before dependents) by default.

--yes

lerna publish --canary --yes
# skips `Are you sure you want to publish the above changes?`

When run with this flag, lerna publish will skip all confirmation prompts.

Deprecated Options

--skip-npm

For this case you can call lerna version directly. It skips publishing to npm registry.

--skip-git

When publishing you can skip pushing packages to git (use monorepotools instead).

⚠️ **GitHub.com Fallback** ⚠️