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

Bug: breaking API change in one of commitlint cli's dependencies: read-pkg #887

Closed
3 tasks
htbvo opened this issue Jan 3, 2020 · 9 comments · Fixed by #888
Closed
3 tasks

Bug: breaking API change in one of commitlint cli's dependencies: read-pkg #887

htbvo opened this issue Jan 3, 2020 · 9 comments · Fixed by #888
Assignees

Comments

@htbvo
Copy link

htbvo commented Jan 3, 2020

I notice that commitlint cli in versions 8.3.0 and onwards, you're using read-pkg version 5.2.0.
Please be aware that there is a significant API change in that module starting at version 4.0.0. The read-pkg API was changed to accept an options objection where one of it's keys, cwd, specifies the directory of the package.json to read. If not specified, it will default to the current directory that commitlint is run from. This is buggy since I believe you actually want to read the package.json where commitlint is installed.

Expected Behavior

commitlint >= 8.3.0 reads package.json from install area

Current Behavior

commitlint >= 8.3.0 reads package.json from current workding directory:

cd $HOME
[hvo@hvo-mac ~]$ npx commitlint
/Users/hvo/.nvm/versions/node/v10.18.0/lib/node_modules/commitlint/node_modules/@commitlint/cli
ENOENT: no such file or directory, open '/Users/hvo/package.json'

Affected packages

  • [ x ] cli
  • core
  • prompt
  • config-angular

Possible Solution

downgrade read-pkg to 3.0.0
update the CLI to correctly use the new read-pkg API

@nfantone
Copy link

nfantone commented Jan 3, 2020

Yeah. This broke all of our CI jobs today. Happy new year, I guess?

@byCedric
Copy link
Member

byCedric commented Jan 3, 2020

Hmm, that's weird, the only breaking change from read-pkg should be the node requirement. I'll create a fix asap! Meanwhile, you can use the npx @commitlint/cli. That should work just fine.

@nfantone
Copy link

nfantone commented Jan 3, 2020

@byCedric I was under the impression that did not work either.

Or is it any different now?

@byCedric
Copy link
Member

byCedric commented Jan 3, 2020

Good catch, but that's related to using the configuration from your project. It's sort of similar, but not causing this error. It's related to an issue in a nested dependency where it looks in the wrong global npm/yarn folder for your config.

This error seems to originate from the commitlint alias. Right now it's not able to find the @commitlint/cli binary using the local package.json from commitlint. If this worked for you in 8.2.0, you are not affected by the issue you mentioned 😄

@nfantone
Copy link

nfantone commented Jan 3, 2020

@byCedric Hey, good stuff! And thanks so much for the fix. Are you planning a patch release by any chance?

@byCedric
Copy link
Member

byCedric commented Jan 3, 2020

I'm sorry we broke your CI 😄 Yes, I'm running the release as we speak. I'll comment again with the version if I'm done 😄

@nfantone
Copy link

nfantone commented Jan 3, 2020

@byCedric Don't mention it. You've been preventing worse things from happening for several months for us now. So the balance is still uneven.

@byCedric
Copy link
Member

byCedric commented Jan 3, 2020

You should be able to run npx commitlint again, version 8.3.4 is just released! Again, sorry for the inconvenience and we will do better next release! (I promise 😄) Please, do let us know if something else pops up! ❤️

@nfantone
Copy link

nfantone commented Jan 3, 2020

image

Sweet victory.

Terrific job @byCedric. Next coffee is on me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants