question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lerna publishes packages based on files that should be ignored

See original GitHub issue

Potentially 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yvelecommented, Oct 19, 2018

I don’t get it… in your README the property ignoreChanges is nested within command.publish

But in you own lerna.json https://github.com/lerna/lerna/blob/master/lerna.json ignoreChanges property is at JSON root level ⁉️

1reaction
evocateurcommented, Jul 25, 2018

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), implicit matchBase was too magical.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ignore changed files when publishing with Lerna
You can use the --ignore-changes flag to prevent lerna from publishing new versions when it finds changes in specific file types.
Read more >
How to exclude all packages in directory from being published?
The ignoreChanges will ignore file changes when running lerna version but as the docs said, it won't stop from publishing that package.
Read more >
@lerna/version - npm
This command works regardless of whether the current HEAD has been released, similar to --force-publish , except that any non-prerelease packages are ignored....
Read more >
Untitled
When run, this command will: 1. Add `lerna` as a [`devDependency`](https://docs.npmjs.com/files/package.json#devdependencies) in `package.json` if it ...
Read more >
Troubleshooting | Lerna
This can cause an issue where Lerna will ignore previously published ... also need to add the following to your .npmrc file on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found