Open gigabo opened 8 years ago
Sounds like you're looking for just lerna updated
then?
I don't think lerna updated
actually gives me what I want here.
Here's the output:
$ lerna updated
Lerna updated v1.1.0
Current version: 0.0.5
Version file location: /Users/bo/git/react-server/VERSION
Packages location: /Users/bo/git/react-server/packages
Checking packages...
- react-server
- react-server-gulp-module-tagger
What I'm looking for is: What exact changes will lerna
make before publishing.
I just want the opportunity to review the commit before it's pushed and published in my name. :)
Oh like a --dry-run
flag
Yes, exactly! Though the partial work done during the dry run in general will be just fine and I wouldn't want to do it again for the actual publish.
So what about this for an interface:
$ lerna publish --dry-run # Create the version commit
$ lerna publish # Push and publish (create commit if necessary)
$ lerna publish --abort # Revert the version commit (if present)
Yeah ok, so you don't publish what you didn't intend?
Exactly! If that interface looks okay I'd be happy to set it up and submit a PR.
I'd rather just the --dry-run
flag that give you a detailed run through of what it would do. This requires abstracting away operations that have side-effects into utilities that can be turned off via a flag, which I already wanted to do for logging (#49), I'll take this over because it will require abstraction of a lot of things.
Sounds good. Thanks @thejameskyle.
Any update on the progress here? @thejameskyle Noticed some verbose logging has been merged just wondering if this flag will be following soon?
As someone picking up lerna for the first time this would be an incredibly useful feature just for getting to grips and not worrying about blowing things up! :)
It's a tough problem because some things depend on file system state. We need to do more work to read the entire file system that it cares about at the beginning and track it throughout the entire process. This will also help performance because there are places where we are re-reading files we already have in memory.
@thejameskyle Cheers for the update!
I wonder if a proxy around node fs
and https://github.com/webpack/memory-fs would do the trick for you?
An alternative way to test what lerna will do is to install a local npm registry and publish to that:
npm i -g verdaccio
verdaccio
npm set registry http://localhost:4873
npm adduser --registry http://localhost:4873
lerna publish
Then use npm pack <name>
to inspect the tarballs it published.
(Updated to use verdaccio
which is a more up to date fork of sinopia
.)
Thanks @tamlyn! That was super helpful advice. My only addition is that you left out the step to start sinopia.
I was able to use the combination of --skip-npm
and --skip-git
to perform dry runs in order to learn how to use lerna and become familiar with how it works before making any permanent changes.
My one request is to be able to perform the git operations, but bypass git push
. I accomplished this by setting up a remote to a dummy repository and pointing to it using the --git-remote
flag.
Any plans on this feature? For now there were suggested only few workarounds. It would be lovely to have a --dry-run
in lerna.
During the last weeks I spent some time to think about this feature. It would be a great feature, at least for lerna beginners. I would go with the interface suggestion which @gigabo posted here: https://github.com/lerna/lerna/issues/51#issuecomment-183441844.
@jamiebuilds Are there any concerns? Or is this task/feature/issue free for getting picked up?
Maybe we could add some additional confirms:
$ lerna publish --conventional-commits
lerna info version 2.11.0
lerna info current version 0.0.0
lerna info Checking for updated packages...
lerna info Comparing with initial commit.
lerna info Checking for prereleased packages...
Changes:
- foo: 0.0.1 => 1.1.0
- bar: 0.0.1 => 1.1.0
? Are you sure you want write the changes to your package.json and changelog files? Yes
? Are you sure you want to push the above changes to git? Yes
? Are you sure you want to publish the above changes to npm? Yes
This would make it more obvious to the user about what is going to happen next and he could skip those questions using the --yes
flag.
Bonus: A maintainer could also alter a generated changelog / package.json before confirming the publish actions.
I'd love to see that feature :clap:
I'd like to chime in since I have similar desires in the context of continuous delivery. In the repository I help maintain, we use TravisCI to report back what packages will receive version bumps before a pull request gets merged to master
. Here is an example: https://github.com/telus/tds-core/pull/862
Our goal is to eventually set up continuous delivery of packages along with the version bump insights we recieve from lerna. In lerna 2.x, we achieved this by leveraging exposed methods from lerna. This is unfortunately brittle since there is no official API in lerna 2.x nor 3.x.
I would be satisfied if I could run lerna version --conventional-commits --no
in my CI pipeline, but there is no --no
option; having a --no
option would satisfy the 'dry run' scenario I would like to see. Consequently, as I'm in the process of upgrading to lerna 3.x, I may have to perform spawn
acrobatics to achieve the above.
I'm willing to help contribute a solution once we all arrive at a consensus.
The option --dryrun could be a part of almost all commands. I was thinking about the lerna version
command as well, to see what will happen before tagging and generating changelog files.
I could also help in this PR as well.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
what's about the dryRun command??
I was able to get an update manifest for the version
command without changing anything in fs/git only after shimming serialize
in @lerna/package
Gist https://gist.github.com/ewnd9/dfcdbf67e7099da12a3973f89d48ed81
Any status updates for a --dry-run
flag.
Like @theetrain I'm looking to use --dry-run
in a CI environment for a pre-approval, so if the decision is to go a confirmation questions route (like @jantimon suggested), a simple --no
option would serve the same purpose.
While a --dry-run
flag seems ideal there are several workarounds here which seem to do the trick. However, the crux here seems to be the "it touched my code/git/npm!" and I didn't want that. For that reason my suggestion would be to tag this issue as wontfix
and implement prompts as suggested here: https://github.com/lerna/lerna/issues/51#issuecomment-410973914
I agree with the prompt idea, only if there won't be any prompt in the CI
Sorry, but any news on it? It should be very useful.
Any news on --dry-run
in 2020 ?) 😀
If it doesn't progress much it'd be nice to mention workarounds how to run in "dry-run"-ish mode.
Reading this thread and consolidating comments to couple of paragraphs would be nice.
I could open a PR.
From what I can tell, you can accomplish a dry run with --no-git-tag-version
and --no-push
yes?
@joshdcomp yeah, makes sense. I'll open a PR to add a section about this.
@joshdcomp I tried it now and it published my packages.
any updates on this? dry-run would be helpful, to reiterate.
Trying didn't work--no
per https://github.com/lerna/lerna/issues/51#issuecomment-543981027
@JackHowa - Did you try joshdcomp's suggestion https://github.com/lerna/lerna/issues/51#issuecomment-583131358
@metasean sort of. we had already been using --no-git-tag-version --no-push
. but I just left off --yes
to make sure it'd fail in github action
npx lerna publish 0.0.0-$(git rev-parse --short HEAD) --no-git-tag-version --no-push --dist-tag beta
npx lerna publish 0.0.0-$(git rev-parse --short HEAD) --no-git-tag-version --no-push --dist-tag beta --yes
Will be very useful in managing dependencies across multi repo project
Any update in 2021?
Hello, I'd like this too. The commands shared by @JackHowa were very useful, but the hacked dry run doesn't give information about the generated CHANGELOG.md, for example when developing the template.
--dry-run
: everything except change files, create tags, push anything, or publish packages. Wild. 🤷♂️
https://www.youtube.com/watch?v=tYx5mphHAiw
Edit: Not being a jerk, just needed to meme.
--dry-run
ftw! would like to have that too :)
@tamlyn thanks!
I updated your example to use it in my case in GitLab CI (maybe it will save someone's time):
# Build packages using lerna
npx lerna bootstrap
npx lerna version "${RELEASE_TAG}" --no-git-tag-version --no-push --yes
npx lerna run build
# Start local NPM registry
npx verdaccio >> "local_registry.log" &
sleep 10 # probably not needed
# Configure sample user
local username="test123"
local password="test123"
local email="test123@test123.com"
npx npm-cli-login -u "${username}" -p "${password}" -e "${email}" -r "${local_registry_url}"
# Execute publish in dry-run
npx lerna publish from-package \
--registry "http://localhost:4873" \
--no-git-tag-version --no-push --yes \
--loglevel verbose
think this could likely be closed @gigabo as I like and use https://github.com/lerna/lerna/issues/51#issuecomment-705820466
Having a --dry-run
flag would still be very helpful!
Hey,
Seen that nobody really submitted a PR for this so I thought I'd give it a try (#3401). If you think we can do it better, I'm open to any other suggestions, hope I have some time to add them 🤕
These changes seem to solve at least my use case (want to get a preview of the versions to be created in a CI pipeline - no user inputs allowed, and have someone manually approve that they're correct)
Reach out if you find anything 🤓
Any updates on this? I've seen the PR #3401 was declined because it's being worked on, but there hasn't been an update since then.
I'd like to have something to programmatically get the "next versions" of packages being published (and maybe an error if there are none)
+1 for the feature. I've some other files like helm chart that needs the updated version/tag to be added to that file.
+1 for the feature
I run lerna version
on a Gitlab CI job with some config options and log the upcoming versions in a merge request for that MR's changes.
The command below basically tries to mimic a version command without pushing anything to a registry or a repo.
npx lerna version --no-private --yes --exact --conventional-commits --no-git-tag-version --no-push --no-changelog --json --allow-branch ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}
It updates the versions in package.json
files in the packages but since I run this command on a CI job I don't need to do anything about them as the changes will be discarded.
If you are willing to use this command until there is an official one I suggest you to check what does each config flags mean and adjust them according to your needs
The reason that the above command is not the same as --dry-run
is because there is no way to be certain that you've copy/pasted what would be the same thing. --dry-run
should do everything short of publishing to npm/pushing to git remotes, in order to test that you've configured CI correctly. Otherwise you're building the plane as you fly it.
--dry-run
is bog standard in any destructive tool. Perhaps this should be closed with "Won't Fix" if that's the true intent?
Thanks to open-source, just head over to lerna-lite.
--dry-run Displays the git command that would be performed without actually executing it, however please note that it will still create all the changelogs. This could be helpful for troubleshooting and also to see changelog changes without committing them to Git.
Hi,
Really liking
lerna
so far. However I've encountered some unexpected behavior that wound up getting pushed to our public repo and published to npm.I'd like to be able to run
lerna publish
to the point of creating the version commit and tag and stop it there so I can inspect what it did before proceeding.My first thought for an interface for this is:
Where in this case
lerna publish
would see that the head revision is a version tag and skip theprepublish
steps.It might also be nice to have a
lerna revert
that's basically justgit reset --hard HEAD^
after verifying that theHEAD
revision is a version commit.I'd be happy to do the work for this and submit a PR if you're open to the idea. How does it sound? Ideas for a better interface?
Thanks!
Bo