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
feat(version): Update 'version' field of package-lock.json #1998
Comments
Related : #1415 |
Oh, I hadn't found that one, sorry. |
Should we close this issue? It seems #1415 had a working workaround... To add 2p., I use Lerna to manage bunch of npm packages and lockfiles within npm packages are neither published to npm nor desired. I block lockfiles inside packages using I guess it depends, what are those packages you use the Lerna for, if it's front-end pieces maybe lockfiles are desired. |
The role of lerna is to maintain easily consistency in the monorepo. (discussing about the usage or utility of package-lock.json is not the purpose i think). |
What if you did a |
It's simple enough, and we're already manipulating the package.json during |
I can offer some details for whoever might decide to work on a PR for this. There are two points in the lifecycle in which a The publish work around that I've had success with is this script: #! /bin/bash
lerna publish --yes --no-push
lerna exec -- npm install --package-lock-only --ignore-scripts --no-audit
git add **/package-lock.json
git commit --amend --no-edit
VERSION=`node -pe "require('$PWD/package.json').version;"`
git tag -f "v${VERSION}"
git push --follow-tags A quick summary is that The above script only works for a project using fixed versions. I would love to see this added to |
@lizardruss Thanks for sharing the snippet. VERSION=`node -pe "require('$PWD/package.json').version;"` Is the version populated in your root's |
Yes, that part is just to read the version. You could use |
@evocateur I'm thinking of opening a pull-request for this feature. Is there any particular way you'd like to see this implemented. I've been fairly buried in the lerna code for the last 3 weeks and I think I have a good understanding of how it all connects together. My first thought was to put this "feature" behind a flag, then update this method to also handle the package-lock file updates. Does that seem sane? |
@evocateur I didn't end up putting the feature behind a flag. Once I found where I thought would be a sane place to make the change, it just fell in naturally. There is a check to see if there is a |
This bug has been fixed in latest lerna, see lerna/lerna#1998
Expected Behavior
I would expect
lerna version
to update theversion
field ofpackage-lock.json
files in packages that it updates the version of.Current Behavior
Currently it seems like
lerna version
only updatespackage.json
.Solution
Update the
version
field inpackage-lock.json
andnpm-shrinkwrap.json
. Edit: andyarn.lock
I guess, and who knows what else, which also might explain why this isn't currently implemented.Steps to Reproduce (for bugs)
lerna init
lerna create foo
cd packages/foo && npm install && cd ../..
(generatepackage-lock.json
)lerna version
grep version packages/a/package{,-lock}.json
lerna.json
Context
I haven't encountered any actual problems with it, but it just looks weird (and it's wrong too).
Your Environment
lerna --version
3.13.0
npm --version
6.9.0
yarn --version
node --version
v11.11.0
The text was updated successfully, but these errors were encountered: