Lerna publishes packages based on files that should be ignored
See original GitHub issuePotentially related to #1357
Expected Behavior
Given the following commit, and the lerna config below:
feat(package1): add feature
# Affected files
# packages/package1/index.jsx
# packages/package2/README.md
When running lerna publish --conventional-commits
, it bumps package1
by a minor version.
Current Behavior
Given the following commit, and the lerna config below:
feat(package1): add feature
# Affected files
# packages/package1/index.jsx
# packages/package2/README.md
When running lerna publish --conventional-commits
, it bumps package1
and package2
by a minor version, even though the only affected file in package2
is a *.md
file that is meant to be ignored as configured below.
Possible Solution
If my understanding is correct, lerna publish --conventional-commits
determines what packages require version bumps based on their commit message types, and then walks through changes from the last relevant tag to the current HEAD.
When walking through commits, we can ignore files files as configured in the commands.publish.ignore
setting in lerna.json. This way, packages that were not intended to receive version bumps no longer will. With some direction, I can help contribute since this would help avoid unintended publishes or git acrobatics.
Steps to Reproduce (for bugs)
If the description above is unclear, I can provide a demonstration repository with reproduction steps.
lerna.json
{
"lerna": "2.9.0",
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"commands": {
"publish": {
"ignore": ["*.md", "*.spec.jsx", "*.snap", "@tds/core-selector-counter"]
}
}
}
Context
In my team, we use lerna to publish multiple packages using independent
mode. We avoid files such as markdown, tests, and snapshots as determiners of version bumps. Though we try to keep the scopes of our commits restricted to individual packages, sometimes other files get added due to precommit linting hooks.
The hope is for the commands.publish.ignore
setting to work consistently when determining changes in lerna updated
as well as the actual packages determined to require version bumps. There are other small ways that can help make lerna’s version changes more apparent to users, and I’ll leave that idea in a separate ticket #1509.
Your Environment
Executable | Version |
---|---|
lerna --version |
2.9.0 |
npm --version |
6.1.0 |
yarn --version |
1.6.0 |
node --version |
8.11.3 |
OS | Version |
---|---|
macOS Sierra | 10.13.6 |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
I don’t get it… in your README the property
ignoreChanges
is nested withincommand.publish
But in you own lerna.json https://github.com/lerna/lerna/blob/master/lerna.json
ignoreChanges
property is at JSON root level ⁉️lerna@next
fixes this by renaming the option--ignore-changes
/ignoreChanges
, making clear that it is a list of file globs, not package names (like the other--ignore
options).The globs themselves should have globstars (
**/*.md
), implicitmatchBase
was too magical.