Skip to content
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

Lerna publishes packages based on files that should be ignored #1508

Closed
theetrain opened this issue Jul 19, 2018 · 6 comments
Closed

Lerna publishes packages based on files that should be ignored #1508

theetrain opened this issue Jul 19, 2018 · 6 comments

Comments

@theetrain
Copy link
Contributor

theetrain commented Jul 19, 2018

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
@evocateur
Copy link
Member

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.

@yvele
Copy link

yvele commented Oct 19, 2018

I don't get it... I'm using lerna 3.4.3 and running lerna diff give me nothing.... but running lerna updated returns ALL packages 🤔

PS: I've updated my ignoreChanges to use globstars (**/package-lock.json)

@yvele
Copy link

yvele commented Oct 19, 2018

By the way, the documentation is not using globstars https://github.com/lerna/lerna/blame/master/README.md#L148

@yvele
Copy link

yvele commented 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 ⁉️

@evocateur
Copy link
Member

@yvele Yep, that's a feature that isn't very well documented. Basically, the scoping works at multiple levels, merged in reverse. So a root-level property will apply to every command, whereas a property scoped to command.publish will only apply to lerna publish (and lerna version, but that's a special case with publish).

@lock
Copy link

lock bot commented Feb 26, 2019

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants