beachball not updating package-lock.json version field when publishing
See original GitHub issueHello,
I am using beachball to manage a single-package repo (not a monorepo), which it says on the beachball site: “single or monorepo”. I’m using npm. I understand that the majority of monorepo users are using yarn, but npm is popular in the single repo ecosystem. Also, the best practice for npm is to use lockfiles (package-lock.json).
The issue is that package-lock.json files have a version
field that corresponds to the version
field of package.json, but beachball does not update this field in package-lock.json. Other tooling does, such as the npm version
command.
Currently our workaround is to do some manual script wrangling with git:
# Beachball doesn't update package-lock.json files when publishing.
- npx beachball publish --yes --no-push
- npm i --package-lock-only
- git add -A
- git commit -m "applying package updates [skip ci]"
- git push --set-upstream origin main
This is a bit uglier than the happy path:
npx beachball publish --yes --message "applying package updates [skip ci]"
This related issue (https://github.com/microsoft/beachball/issues/482) saw the same issue and added a postpublish hook, but it’s not clear how to use it.
I do use beachball with yarn in other monorepos and it’s wonderful. It would just be nice if beachball updated the lockfile. Would this be hard?
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
That would be a cleaner solution for sure, plus we would get all of the standard pre/post version script goodness that’s standard in npm. According to https://github.com/microsoft/beachball/issues/482#issuecomment-772955130 they are only using beachball with yarn, so I’m guessing we won’t get much love on npm support 😭
I have a few ideas:
bumpScript
where we could set it tonpm version --no-git-tag-version ${version}
oryarn version --no-git-tag-version ${version}
. If it’s not set, it would do the current behavior of just modifying the appropriatepackage.json
files. Seems like that has the potential to simplify a lot of stuff and be a robust solution 🤔packageManager
that could be set tonpm
,yarnclassic
,yarn2
, etc… That might be a nicer developer experience 🤷It was partially because my original script did the following:
So my original script deleted the
node_modules
folder before regenerating the lock file. When it does that all the transitive dependencies of your application are redownloaded and the lock file is created with new versions.If you don’t delete the
node_modules
folder thennpm install --package-lock-only --ignore-scripts
will try and create a lock file using the currentnode_modules
structure. While it is unlikely that build resulted in changes (for example parcel will add new packages automatically) or that packages were deprecated during that time there is no guarantee that thenpm install
won’t result in new or unexpected packages being added due to transitive dependencies.