-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(version): add --changelog-skip-unstable option #3882
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,3 +438,285 @@ describe(`lerna publish --conventional-prerelease/graduate fixed w/ changelog`, | |
`); | ||
}); | ||
}); | ||
|
||
describe(`lerna publish --conventional-prerelease/graduate fixed w/ stable changelog`, () => { | ||
let cwd: string; | ||
|
||
beforeAll(async () => { | ||
({ cwd } = await cloneFixture("normal", "chore: init repo")); | ||
await gitTag(cwd, "v1.0.0"); | ||
}); | ||
|
||
test(`release specified stable packages as prerelease, ignoring specified packages`, async () => { | ||
const args = [ | ||
"publish", | ||
"--conventional-commits", | ||
"--conventional-prerelease", | ||
"--yes", | ||
]; | ||
await commitChangeToPackage(cwd, "package-1", "feat(package-1): Add foo", { foo: true }); | ||
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 } | ||
); | ||
|
||
const { stdout } = await cliRunner(cwd, env)(...args); | ||
expect(stdout).toMatchInlineSnapshot(` | ||
|
||
Changes: | ||
- package-1: 1.0.0 => 2.0.0-alpha.0 | ||
- package-2: 1.0.0 => 2.0.0-alpha.0 | ||
- package-3: 1.0.0 => 2.0.0-alpha.0 | ||
- package-5: 1.0.0 => 2.0.0-alpha.0 (private) | ||
|
||
Successfully published: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
`); | ||
}); | ||
|
||
test(`graduate prerelease packages`, async () => { | ||
const args = [ | ||
"publish", | ||
"--conventional-commits", | ||
"--conventional-graduate", | ||
"--changelog-skip-unstable", | ||
"--yes", | ||
]; | ||
await commitChangeToPackage(cwd, "package-1", "feat(package-1): Add baz", { baz: true }); | ||
|
||
const { stdout } = await cliRunner(cwd, env)(...args); | ||
// package-4 is bumped because the graduation to 2.0.0 is a breaking change | ||
// Lerna bumps ALL packages when there is a breaking change when on fixed mode | ||
expect(stdout).toMatchInlineSnapshot(` | ||
|
||
Changes: | ||
- package-1: 2.0.0-alpha.0 => 2.0.0 | ||
- package-2: 2.0.0-alpha.0 => 2.0.0 | ||
- package-3: 2.0.0-alpha.0 => 2.0.0 | ||
- package-4: 1.0.0 => 2.0.0 | ||
- package-5: 2.0.0-alpha.0 => 2.0.0 (private) | ||
|
||
Successfully published: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
`); | ||
}); | ||
|
||
test(`generate accurate changelog`, async () => { | ||
// ensure changelog header is not duplicated | ||
const args = ["publish", "--conventional-commits", "--changelog-skip-unstable", "--yes"]; | ||
await commitChangeToPackage(cwd, "package-2", "fix(package-2): And another thing", { thing: true }); | ||
await cliRunner(cwd, env)(...args); | ||
|
||
const changelogFilePaths = await globby(["**/CHANGELOG.md"], { | ||
cwd, | ||
absolute: true, | ||
followSymbolicLinks: false, | ||
}); | ||
const [rootChangelog, pkg1Changelog, pkg2Changelog, pkg3Changelog] = | ||
await Promise.all(changelogFilePaths.sort().map((fp) => fs.readFile(fp, "utf8"))); | ||
|
||
/** | ||
* ./CHANGELOG.md | ||
*/ | ||
expect(rootChangelog).toMatchInlineSnapshot(` | ||
# Change Log | ||
|
||
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/v2.0.0...v2.0.1) (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** And another thing ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0](/compare/v1.0.0...v2.0.0) (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add baz ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
# 2.0.0-alpha.0 (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** Fix bar ([SHA](COMMIT_URL)) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add foo ([SHA](COMMIT_URL)) | ||
* **package-3:** Add baz feature ([SHA](COMMIT_URL)) | ||
|
||
|
||
### BREAKING CHANGES | ||
|
||
* **package-3:** yup | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0-alpha.0](/compare/v1.0.0...v2.0.0-alpha.0) (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** Fix bar ([SHA](COMMIT_URL)) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add foo ([SHA](COMMIT_URL)) | ||
* **package-3:** Add baz feature ([SHA](COMMIT_URL)) | ||
|
||
|
||
### BREAKING CHANGES | ||
|
||
* **package-3:** yup | ||
|
||
`); | ||
|
||
expect(pkg1Changelog).toMatchInlineSnapshot(` | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
# [2.0.0](/compare/v1.0.0...v2.0.0) (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add baz ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
# 2.0.0-alpha.0 (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add foo ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0-alpha.0](/compare/v1.0.0...v2.0.0-alpha.0) (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-1:** Add foo ([SHA](COMMIT_URL)) | ||
|
||
`); | ||
|
||
expect(pkg2Changelog).toMatchInlineSnapshot(` | ||
# Change Log | ||
|
||
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/v2.0.0...v2.0.1) (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** And another thing ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0](/compare/v1.0.0...v2.0.0) (YYYY-MM-DD) | ||
|
||
|
||
|
||
# 2.0.0-alpha.0 (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** Fix bar ([SHA](COMMIT_URL)) | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0-alpha.0](/compare/v1.0.0...v2.0.0-alpha.0) (YYYY-MM-DD) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **package-2:** Fix bar ([SHA](COMMIT_URL)) | ||
|
||
`); | ||
|
||
expect(pkg3Changelog).toMatchInlineSnapshot(` | ||
# Change Log | ||
|
||
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/v2.0.0...v2.0.1) (YYYY-MM-DD) | ||
|
||
**Note:** Version bump only for package package-3 | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0](/compare/v1.0.0...v2.0.0) (YYYY-MM-DD) | ||
|
||
|
||
|
||
# 2.0.0-alpha.0 (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-3:** Add baz feature ([SHA](COMMIT_URL)) | ||
|
||
|
||
### BREAKING CHANGES | ||
|
||
* **package-3:** yup | ||
|
||
|
||
|
||
|
||
|
||
# [2.0.0-alpha.0](/compare/v1.0.0...v2.0.0-alpha.0) (YYYY-MM-DD) | ||
|
||
|
||
### Features | ||
|
||
* **package-3:** Add baz feature ([SHA](COMMIT_URL)) | ||
|
||
|
||
### BREAKING CHANGES | ||
|
||
* **package-3:** yup | ||
|
||
`); | ||
}); | ||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.0.0-alpha.0 appears twice in this markdown file. This shouldn't happen, as users looking at version 2.0.0 won't care which specific prerelease version the feature was added in. Instead, we should get the changes from all the prereleases aggregated together with the changes from 2.0.0 itself, so it would look like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fahslaj I do agree that this is the expected markup.
conventional-changelog/conventional-changelog#675 suggests this is an issue with
conventional-changelog
. However, tests in this PR with independent versioning seem to be correct and the prerelease changes are properly aggregated see here. Any suggestions ?