Skip to content

[Feature] lerna --dryrun #51

Open
Open

Description

@gigabo

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:

$ lerna prepublish
... make sure everything's as expected...
$ lerna publish

Where in this case lerna publish would see that the head revision is a version tag and skip the prepublish steps.

It might also be nice to have a lerna revert that's basically just git reset --hard HEAD^ after verifying that the HEAD 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

Activity

  1. sebmck commented on Feb 12, 2016

    @sebmck
    Contributor

    Sounds like you're looking for just lerna updated then?

  2. gigabo commented on Feb 12, 2016

    @gigabo
    ContributorAuthor

    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. :)

  3. jamiebuilds commented on Feb 12, 2016

    @jamiebuilds
    Contributor

    Oh like a --dry-run flag

  4. gigabo commented on Feb 12, 2016

    @gigabo
    ContributorAuthor

    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.

  5. gigabo commented on Feb 12, 2016

    @gigabo
    ContributorAuthor

    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)
  6. hzoo commented on Feb 12, 2016

    @hzoo
    Contributor

    Yeah ok, so you don't publish what you didn't intend?

  7. gigabo commented on Feb 12, 2016

    @gigabo
    ContributorAuthor

    Exactly! If that interface looks okay I'd be happy to set it up and submit a PR.

  8. jamiebuilds commented on Feb 12, 2016

    @jamiebuilds
    Contributor

    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.

  9. gigabo commented on Feb 12, 2016

    @gigabo
    ContributorAuthor

    Sounds good. Thanks @thejameskyle.

  10. changed the title [-]Feature request: lerna prepublish[/-] [+]Feature request: lerna --dryrun[/+] on Feb 13, 2016
  11. chrisui commented on Apr 14, 2016

    @chrisui

    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! :)

  12. jamiebuilds commented on Apr 14, 2016

    @jamiebuilds
    Contributor

    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.

  13. chrisui commented on Apr 14, 2016

    @chrisui

    @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?

  14. changed the title [-]Feature request: lerna --dryrun[/-] [+][Feature] lerna --dryrun[/+] on Nov 16, 2016
  15. 36 remaining items

  16. fsmaia commented on Oct 14, 2022

    @fsmaia

    Having a --dry-run flag would still be very helpful!

  17. meteabduraman commented on Oct 30, 2022

    @meteabduraman

    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 🤓

  18. added this to the Lerna v7 milestone on Nov 29, 2022
  19. ChFlick commented on Apr 5, 2023

    @ChFlick

    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)

  20. sqaisar commented on Apr 27, 2023

    @sqaisar

    +1 for the feature. I've some other files like helm chart that needs the updated version/tag to be added to that file.

  21. next-juanantoniogomez commented on Jan 29, 2024

    @next-juanantoniogomez

    +1 for the feature

  22. sevilyilmaz commented on May 13, 2024

    @sevilyilmaz

    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

  23. cellog commented on May 28, 2024

    @cellog

    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?

  24. SchulteDev commented on Aug 16, 2024

    @SchulteDev

    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.

    lerna-lite --dry-run

  25. zifeiyu666 commented on Sep 13, 2024

    @zifeiyu666

    did lerna now have the support of --dry-run when publish ?

  26. added a commit that references this issue on Nov 15, 2024
  27. ashwinkumar6 commented on Feb 24, 2025

    @ashwinkumar6

    Is the --dry-run feature out yet ?

  28. removed this from the Lerna v7 milestone on Mar 16, 2026
  29. nikzanda commented on Mar 26, 2026

    @nikzanda

    is there any news on this feature?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions