lerna / lerna/lerna

--ignoreChanges is not respected.

Open
#4,144 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
36.1k
Forks
2.3k
Avg merge
1d 4h
Merged PRs (30d)
50

Description

Lerna Version: 8.1.9

Current Behavior

Hi all,

I'm running into an issue where in my CICD pipeline, I do a hotswap of .npmrc for an alternative cicd.npmrc with a mv cicd.npmrc .npmrc command prior to running lerna version/lerna publish

I've tried configuring Lerna according to the documentation and various issues I've seen around this, with my lerna.json configured as so:

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "independent",
  "command": {
    "publish": {
      "ignoreChanges": [
        ".npmrc",
        "cicd.npmrc"
      ]
    }
  },
  "packages": [
    "packages/*"
  ]
}

I've also tried configuring my lerna CLI as such

npx lerna publish --ignore-changes 'cicd.npmrc' '.npmrc' --canary --exact --dist-tag ${CI_COMMIT_REF_SLUG} --preid "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" --yes ${FORCED_PKGLIST} --concurrency 1

However end result is I get this output

Image

Expected Behavior

As far as I can tell, the issue is that the code for checking the working directory here

https://github.com/lerna/lerna/blob/c3e601bee1bd6416e8b067ec8121abd996163d86/libs/core/src/lib/collect-uncommitted.ts#L32

completely ignores the configuration that's passed in. I would expect the ignoreChanges configuration to work as expected.

Related Issues

It seems like this may be related to this issue https://github.com/lerna/lerna/issues/2522 which was never resolved.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with libs/core/src/lib/collect-uncommitted.ts at the linked check, then trace how ignoreChanges from lerna.json and the --ignore-changes CLI option reaches it. Reproduce the CICD .npmrc swap with lerna version or publish and confirm that the configured .npmrc and cicd.npmrc changes are ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
release
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.