# Lockstep and independent

> How bump puts packages into units in lockstep and independent mode, the default tags and messages, targets, dependents, reasons, and --all.

bump releases **units**. A unit is a set of packages that release together, with one version and one tag. The mode decides the units:

- **Lockstep**, the default: all versioned packages are one unit.
- **Independent**: each [group](/groups/) is a unit, and each versioned package outside a group is a unit.

All units are dense: when a unit is released, every package in it gets the new version, changed or not.

## Lockstep

Lockstep needs no config. All versioned packages share one version and one tag.

This repository has two packages at `1.2.0`, and the tag `v1.2.0`. Only `@acme/cli` changed:

```console
$ bump minor
BUMP 1.2.0 → 1.3.0  (changed)
     @acme/core, @acme/cli
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
DONE Committed d7a31fe v1.3.0
     Tagged v1.3.0
```

The `BUMP` line has no name, because the lockstep unit has none. The line below it lists the packages of the unit. Both packages get `1.3.0`.

Every package must have the same version. If not, bump stops with `All packages must share one version in lockstep mode`, and lists each package and its version. Set one version in all manifests, and commit. Then tag that commit, or run once with `--adopt`. See [Anchors](/how-it-works/#anchors).

Lockstep has no targets. A target stops with `Targets need "independent": true in bump.json`.

## Independent

Set `independent` in the config:

```jsonc [bump.json]
{
  "independent": true
}
```

Each versioned package is now a unit of its own, with its own version and tag. To release some packages together, put them in a [group](/groups/).

This repository has four packages. `@acme/cli` depends on `@acme/core`, and `web` depends on `@acme/cli`. `@acme/core` and `@acme/utils` changed:

```console
$ bump minor
BUMP @acme/core 1.2.0 → 1.3.0  (changed)
BUMP @acme/cli 0.4.1 → 0.4.2  (dependent)
BUMP @acme/utils 0.3.0 → 0.4.0  (changed)
BUMP web 2.0.0 → 2.0.1  (dependent)
EDIT web dependencies["@acme/cli"] ^0.4.1 → ^0.4.2
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
DONE Committed 8022289 release: @acme/core@1.3.0, @acme/cli@0.4.2, @acme/utils@0.4.0, web@2.0.1
     Tagged @acme/core@1.3.0, @acme/cli@0.4.2, @acme/utils@0.4.0, web@2.0.1
```

The changed units get `minor`. Their dependents get a patch. All of them share one commit, and each gets its own tag.

bump lists the units so that each comes after the units it depends on. Among the units whose dependencies are already listed, the smallest name comes first. The tags and the commit message use the same order.

## Tags and messages

The `tag` and `message` keys of the config set the tag name and the commit subject. Their defaults depend on the mode:

| Mode | `tag` | `message` | Example tag | Example message |
| --- | --- | --- | --- | --- |
| Lockstep | `v{version}` | `v{version}` | `v1.3.0` | `v1.3.0` |
| Independent | `{name}@{version}` | `release: {tags}` | `@acme/cli@0.4.2` | `release: @acme/core@1.3.0, @acme/cli@0.4.2` |

`{version}` is the new version, `{name}` is the unit name, and `{tags}` is the list of new tags. See [Templates](/config/#templates) for the rules of each placeholder, and [`tag`](/config/#tag) for how bump finds earlier releases by the tag name.

## Targets

In independent mode, you can name the units to release after the type:

```console
$ bump patch @acme/cli --dryrun
BUMP @acme/cli 0.4.1 → 0.4.2  (target)
BUMP web 2.0.0 → 2.0.1  (dependent)
EDIT web dependencies["@acme/cli"] ^0.4.1 → ^0.4.2
DONE Dry run; no files were written
```

- A target is a package name or a group name. The name of a group member selects the whole group.
- A target is released, changed or not.
- Other changed units are not released. Here `@acme/core` and `@acme/utils` changed, but they wait for a later release.
- The units that depend on a target are still released, as `dependent`.

Unknown names stop the release. bump lists all of them:

```console
$ bump patch @acme/nope foo --dryrun
FAIL Unknown targets: "@acme/nope", "foo"
```

A package with no version cannot be a target.

## Dependents

A unit depends on another unit when one of its packages has a runtime dependency on a package of the other unit. These fields are runtime dependencies:

- npm: `dependencies`, `peerDependencies`, `optionalDependencies`.
- Cargo: `[dependencies]`, `[build-dependencies]`, and their `[target.<cfg>]` forms.

Dev dependencies (`devDependencies`, `[dev-dependencies]`) cause no release. They still get [range edits](/how-it-works/#range-rewrite).

When a unit is released, bump also releases each unit that depends on it, directly or through other units. In the first example of [Independent](#independent), `web` depends on `@acme/core` only through `@acme/cli`, and it is released too.

### The type of a dependent

The command's type is for the changed units and the targets, not for their dependents. A dependent gets:

| Current version of the dependent | A dependency gets a prerelease | Type |
| --- | --- | --- |
| stable | no | `patch` |
| stable | yes | `prepatch` |
| prerelease | either | `prerelease` |

See [Prereleases](/prereleases/#dependents) for the preid of a dependent.

A unit that is released only because of a dependency has the reason `dependent`. See [Reasons](/how-it-works/#reasons). Here `@acme/cli` changed, but the target is `@acme/core`:

```console
$ bump minor @acme/core --dryrun
BUMP @acme/core 1.2.0 → 1.3.0  (target)
BUMP @acme/cli 0.4.1 → 0.4.2  (dependent)
BUMP web 2.0.0 → 2.0.1  (dependent)
EDIT web dependencies["@acme/cli"] ^0.4.1 → ^0.4.2
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
DONE Dry run; no files were written
```

`@acme/cli` gets a patch, not `minor`. To give it `minor` too, name it: `bump minor @acme/core @acme/cli`.

Dependencies can form a cycle. bump releases every unit in the cycle, and continues the order at the smallest remaining name.

## Reasons

The reason in parentheses tells you why a unit is released: `target`, `first`, `adopted`, `changed`, `all`, or `dependent`. In lockstep mode, the one unit has `first`, `adopted`, `changed`, or `all`. See [Reasons](/how-it-works/#reasons) for the rules.

## Release all

`--all` releases every unit, changed or not.

In lockstep mode, it releases the one unit when nothing changed:

```console
$ bump patch --all --dryrun
BUMP 1.3.0 → 1.3.1  (all)
     @acme/core, @acme/cli
EDIT @acme/cli dependencies["@acme/core"] ^1.3.0 → ^1.3.1
DONE Dry run; no files were written
```

In independent mode, every unit gets the command's type. A unit that changed keeps the reason `changed`:

```console
$ bump patch --all --dryrun
BUMP @acme/core 1.2.0 → 1.2.1  (changed)
BUMP @acme/cli 0.4.1 → 0.4.2  (all)
BUMP @acme/utils 0.3.0 → 0.3.1  (changed)
BUMP web 2.0.0 → 2.0.1  (all)
EDIT web dependencies["@acme/cli"] ^0.4.1 → ^0.4.2
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.2.1
DONE Dry run; no files were written
```

`--all` and targets cannot go together:

```console
$ bump patch --all @acme/cli
FAIL Cannot combine --all with targets
```
