Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Mar 19, 2019
1 parent a8eff23 commit c78d9a0
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 42 deletions.
21 changes: 17 additions & 4 deletions commands/version/README.md
Expand Up @@ -39,7 +39,8 @@ If you have any packages with a prerelease version number (e.g. `2.0.0-beta.3`)
- [`--allow-branch`](#--allow-branch-glob)
- [`--amend`](#--amend)
- [`--conventional-commits`](#--conventional-commits)
- [`--conventional-commits-prerelease`](#--conventional-commits-prerelease)
- [`--conventional-graduate`](#--conventional-graduate)
- [`--conventional-prerelease`](#--conventional-prerelease)
- [`--changelog-preset`](#--changelog-preset)
- [`--exact`](#--exact)
- [`--force-publish`](#--force-publish)
Expand Down Expand Up @@ -117,13 +118,25 @@ When run with this flag, `lerna version` will use the [Conventional Commits Spec

Passing [`--no-changelog`](#--no-changelog) will disable the generation (or updating) of `CHANGELOG.md` files.

### `--conventional-commits-prerelease`
### `--conventional-prerelease`

```sh
lerna version --conventional-commits --conventional-commits-prerelease
lerna version --conventional-commits --conventional-prerelease
```

Provides automated prerelease versioning, works with both fixed and independent versioning. The version itself is only bumped if the current prerelease version does not meet the recommended bump level - for example, `package@1.0.1` will be bumped if features or breaking changes are present in the commits, while `package@2.0.0-alpha.0` will never be bumped while in prerelease, because `2.0.0` will be able to contain breaking changes. If no bump should occur, the numeric prerelease identifier is incremented, eg. `package@2.0.0-alpha.0 => package@2.0.0-alpha.1`.
Provides automated prerelease versioning, works with both fixed and independent versioning. The version itself is only bumped if the current prerelease version does not meet the recommended bump level - for example, `package@1.0.1` will be bumped if features or breaking changes are present in the commits, while `package@2.0.0-alpha.0` will only ever receive prerelease identifier bumps, eg. `package@2.0.0-alpha.0 => package@2.0.0-alpha.1`, because `2.0.0` will be a major release and contain any type of change.

### `--conventional-graduate`

```sh
lerna version --conventional-commits --conventional-graduate=package-2,package-4

# force all prerelease packages to be graduated
lerna version --conventional-commits --conventional-graduate
```
When run with this flag, `lerna version` will graduate the specified packages (comma-separated) or all packages using `*`. Any non-prerelease packages are ignored. As always when running `lerna version`, all packages that depend on a package that is being released will themselves be released, but only specified packages will be graduated to a non-prerelease version.

"Graduating" a package means bumping to the non-prerelease variant of a prerelease version, eg. `package-1@1.0.0-alpha.0 => package-1@1.0.0`.

### `--changelog-preset`

Expand Down
4 changes: 3 additions & 1 deletion commands/version/index.js
Expand Up @@ -241,7 +241,9 @@ class VersionCommand extends Command {

// amending a commit probably means the working tree is dirty
if (this.commitAndTag && this.gitOpts.amend !== true) {
const check = this.options.forcePublish ? checkWorkingTree.throwIfUncommitted : checkWorkingTree;
const { forcePublish, conventionalCommits, conventionalGraduate } = this.options;
const checkUncommittedOnly = forcePublish || (conventionalCommits && conventionalGraduate);
const check = checkUncommittedOnly ? checkWorkingTree.throwIfUncommitted : checkWorkingTree;
tasks.unshift(() => check(this.execOpts));
} else {
this.logger.warn("version", "Skipping working tree validation, proceed at your own risk");
Expand Down
129 changes: 92 additions & 37 deletions integration/lerna-publish-conventional-independent-prerelease.test.js
Expand Up @@ -26,34 +26,61 @@ test(`lerna publish --conventional-prerelease independent w/ changelog`, async (
let args;
let stdout;

await commitChangeToPackage(cwd, "package-1", "feat(package-1): Add foo", { foo: true });
await commitChangeToPackage(cwd, "package-1", "fix(package-1): Fix foo", { foo: false });
await commitChangeToPackage(cwd, "package-2", "fix(package-2): Fix bar", { bar: true });
await commitChangeToPackage(
cwd,
"package-3",
`feat(package-3): Add baz feature${os.EOL}${os.EOL}BREAKING CHANGE: yup`,
{ baz: true }
);
args = ["publish", "--conventional-commits", "--yes"];
({ stdout } = await cliRunner(cwd, env)(...args));
expect(stdout).toMatchInlineSnapshot(`
Changes:
- package-1: 1.0.0 => 1.0.1
- package-2: 2.0.0 => 2.0.1
- package-3: 3.0.0 => 4.0.0
- package-4: 4.0.0 => 4.0.1
- package-5: 5.0.0 => 5.0.1 (private)
Successfully published:
- package-1@1.0.1
- package-2@2.0.1
- package-3@4.0.0
- package-4@4.0.1
`);

// Test subsequent prereleases to ensure proper versioning.
await commitChangeToPackage(cwd, "package-1", "feat(package-1): Add foo", { foo: true });
await commitChangeToPackage(cwd, "package-1", "fix(package-1): Fix foo", { foo: false });
args = ["publish", "--conventional-commits", "--conventional-prerelease", "--yes"];
({ stdout } = await cliRunner(cwd, env)(...args));
expect(stdout).toMatchInlineSnapshot(`
Changes:
- package-1: 1.0.0 => 1.1.0-alpha.0
- package-2: 2.0.0 => 2.0.1-alpha.0
- package-3: 3.0.0 => 4.0.0-alpha.0
- package-4: 4.0.0 => 4.0.1-alpha.0
- package-5: 5.0.0 => 5.0.1-alpha.0 (private)
- package-1: 1.0.1 => 1.1.0-alpha.0
- package-2: 2.0.1 => 2.0.2-alpha.0
- package-3: 4.0.0 => 4.0.1-alpha.0
- package-5: 5.0.1 => 5.0.2-alpha.0 (private)
Successfully published:
- package-1@1.1.0-alpha.0
- package-2@2.0.1-alpha.0
- package-3@4.0.0-alpha.0
- package-4@4.0.1-alpha.0
- package-2@2.0.2-alpha.0
- package-3@4.0.1-alpha.0
`);

await commitChangeToPackage(cwd, "package-4", "feat(package-4): Add thing", { thing: true });
({ stdout } = await cliRunner(cwd, env)(...args));
expect(stdout).toMatchInlineSnapshot(`
Changes:
- package-4: 4.0.1 => 4.1.0-alpha.0
Successfully published:
- package-4@4.1.0-alpha.0
`);

// Test subsequent prereleases to ensure proper versioning.
await commitChangeToPackage(
cwd,
"package-1",
Expand All @@ -67,23 +94,19 @@ Successfully published:
`feat(package-3): Add bar feature${os.EOL}${os.EOL}BREAKING CHANGE: yup`,
{ bar: true }
);
await commitChangeToPackage(cwd, "package-4", "feat(package-4): Add thing", { thing: true });
({ stdout } = await cliRunner(cwd, env)(...args));

expect(stdout).toMatchInlineSnapshot(`
Changes:
- package-1: 1.1.0-alpha.0 => 2.0.0-alpha.0
- package-2: 2.0.1-alpha.0 => 2.0.1-alpha.1
- package-3: 4.0.0-alpha.0 => 4.0.0-alpha.1
- package-4: 4.0.1-alpha.0 => 4.1.0-alpha.0
- package-5: 5.0.1-alpha.0 => 5.0.1-alpha.1 (private)
- package-2: 2.0.2-alpha.0 => 2.0.2-alpha.1
- package-3: 4.0.1-alpha.0 => 4.0.1-alpha.1
- package-5: 5.0.2-alpha.0 => 5.0.2-alpha.1 (private)
Successfully published:
- package-1@2.0.0-alpha.0
- package-2@2.0.1-alpha.1
- package-3@4.0.0-alpha.1
- package-4@4.1.0-alpha.0
- package-2@2.0.2-alpha.1
- package-3@4.0.1-alpha.1
`);

// Test graduation of specific prereleased package
Expand All @@ -93,14 +116,14 @@ Successfully published:
Changes:
- package-1: 2.0.0-alpha.0 => 2.0.0
- package-2: 2.0.1-alpha.1 => 2.0.1
- package-3: 4.0.0-alpha.1 => 4.0.0
- package-5: 5.0.1-alpha.1 => 5.0.1 (private)
- package-2: 2.0.2-alpha.1 => 2.0.2
- package-3: 4.0.1-alpha.1 => 4.0.1
- package-5: 5.0.2-alpha.1 => 5.0.2 (private)
Successfully published:
- package-1@2.0.0
- package-2@2.0.1
- package-3@4.0.0
- package-2@2.0.2
- package-3@4.0.1
`);

// Test graduation of all prereleased packages
Expand Down Expand Up @@ -162,7 +185,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
# 1.1.0-alpha.0 (YYYY-MM-DD)
# [1.1.0-alpha.0](/compare/package-1@1.0.1...package-1@1.1.0-alpha.0) (YYYY-MM-DD)
### Bug Fixes
Expand All @@ -174,6 +197,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **package-1:** Add foo ([SHA](COMMIT_URL))
## 1.0.1 (YYYY-MM-DD)
**Note:** Version bump only for package package-1
`);

/**
Expand All @@ -185,15 +216,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.0.1](/compare/package-2@2.0.1-alpha.1...package-2@2.0.1) (YYYY-MM-DD)
## [2.0.2](/compare/package-2@2.0.2-alpha.1...package-2@2.0.2) (YYYY-MM-DD)
**Note:** Version bump only for package package-2
## [2.0.1-alpha.1](/compare/package-2@2.0.1-alpha.0...package-2@2.0.1-alpha.1) (YYYY-MM-DD)
## [2.0.2-alpha.1](/compare/package-2@2.0.2-alpha.0...package-2@2.0.2-alpha.1) (YYYY-MM-DD)
### Bug Fixes
Expand All @@ -204,7 +235,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
## 2.0.1-alpha.0 (YYYY-MM-DD)
## [2.0.2-alpha.0](/compare/package-2@2.0.1...package-2@2.0.2-alpha.0) (YYYY-MM-DD)
**Note:** Version bump only for package package-2
## 2.0.1 (YYYY-MM-DD)
### Bug Fixes
Expand All @@ -222,15 +261,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.0.0](/compare/package-3@4.0.0-alpha.1...package-3@4.0.0) (YYYY-MM-DD)
## [4.0.1](/compare/package-3@4.0.1-alpha.1...package-3@4.0.1) (YYYY-MM-DD)
**Note:** Version bump only for package package-3
# [4.0.0-alpha.1](/compare/package-3@4.0.0-alpha.0...package-3@4.0.0-alpha.1) (YYYY-MM-DD)
## [4.0.1-alpha.1](/compare/package-3@4.0.1-alpha.0...package-3@4.0.1-alpha.1) (YYYY-MM-DD)
### Features
Expand All @@ -246,7 +285,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
# 4.0.0-alpha.0 (YYYY-MM-DD)
## [4.0.1-alpha.0](/compare/package-3@4.0.0...package-3@4.0.1-alpha.0) (YYYY-MM-DD)
**Note:** Version bump only for package package-3
# 4.0.0 (YYYY-MM-DD)
### Features
Expand Down Expand Up @@ -277,7 +324,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
# [4.1.0-alpha.0](/compare/package-4@4.0.1-alpha.0...package-4@4.1.0-alpha.0) (YYYY-MM-DD)
# [4.1.0-alpha.0](/compare/package-4@4.0.1...package-4@4.1.0-alpha.0) (YYYY-MM-DD)
### Features
Expand All @@ -288,7 +335,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
## 4.0.1-alpha.0 (YYYY-MM-DD)
## 4.0.1 (YYYY-MM-DD)
**Note:** Version bump only for package package-4
Expand All @@ -303,23 +350,31 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.0.1](/compare/package-5@5.0.1-alpha.1...package-5@5.0.1) (YYYY-MM-DD)
## [5.0.2](/compare/package-5@5.0.2-alpha.1...package-5@5.0.2) (YYYY-MM-DD)
**Note:** Version bump only for package package-5
## [5.0.2-alpha.1](/compare/package-5@5.0.2-alpha.0...package-5@5.0.2-alpha.1) (YYYY-MM-DD)
**Note:** Version bump only for package package-5
## [5.0.1-alpha.1](/compare/package-5@5.0.1-alpha.0...package-5@5.0.1-alpha.1) (YYYY-MM-DD)
## [5.0.2-alpha.0](/compare/package-5@5.0.1...package-5@5.0.2-alpha.0) (YYYY-MM-DD)
**Note:** Version bump only for package package-5
## 5.0.1-alpha.0 (YYYY-MM-DD)
## 5.0.1 (YYYY-MM-DD)
**Note:** Version bump only for package package-5
Expand Down

0 comments on commit c78d9a0

Please sign in to comment.