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

Always run postversion lifecycle method #7154

Merged
merged 9 commits into from Jul 24, 2019

Conversation

hampustagerud
Copy link
Contributor

@hampustagerud hampustagerud commented Mar 28, 2019

Summary

After battling yarn for a while, trying to get the postversion lifecycle method to run without committing the new version, I found #5358 which indicated that it actually doesn't run when opting out committing the changes. The documentation doesn't indicate that a commit is needed for postversion to run so at least I assumed that I wouldn't need to commit in order for postversion to run. According to the previously mentioned issue there seems to be some people sharing my confusing around this. My use case for wanting postversion to run without committing is that I need to update other files before creating a commit.

Test plan

I tested using the following steps:

  • Edited the scripts section of package.json and added preversion and postversion:

    {
      "scripts": {
        ...otherScripts,
        "preversion": "echo before: $npm_package_version",
        "postversion": "echo after: $npm_package_version"
     }
    }
  • Ran yarn version --no-git-tag-version --new-version 1.17.0 with a fresh install from homebrew, result:

    yarn version v1.15.2
    warning ../package.json: No license field
    info Current version: 1.16.0-0
    $ echo before: $npm_package_version
    before: 1.16.0-0
    info New version: 1.17.0
    ✨  Done in 0.15s.
    
  • Reset package.json version field.

  • Ran yarn build && node ./lib/cli/index.js version --no-git-tag-version --new-version 1.17.0 with the change from this PR, result:

    info Current version: 1.16.0-0
    $ echo before: $npm_package_version
    before: 1.16.0-0
    info New version: 1.17.0
    $ echo after: $npm_package_version
    after: 1.17.0
    ✨  Done in 0.31s.
    

Final notes

I realise that version can be used to achieve this since it also passes $npm_package_version but since there is some confusion (once again referencing #5358, latest post from about a month ago), and the docs doesn't really mention it, making postversion always run would be more consistent with both its name and the docs (in my opinion).

If the current behaviour is desired I'd accept that but right now it is pretty ambiguous so I thought a at least a discussion would be good since #5358 has been open for over a year now 🙂

If accepted this will fix #5358.

@byF
Copy link

byF commented May 3, 2019

i hope someone can take care of this

@buildsize
Copy link

buildsize bot commented May 7, 2019

File name Previous Size New Size Change
yarn-[version].noarch.rpm 1.18 MB 1.18 MB -70 bytes (0%)
yarn-[version].js 4.85 MB 4.85 MB -82 bytes (0%)
yarn-legacy-[version].js 5.05 MB 5.05 MB -112 bytes (0%)
yarn-v[version].tar.gz 1.19 MB 1.18 MB -1.93 KB (0%)
yarn_[version]all.deb 868.55 KB 868.48 KB -78 bytes (0%)

@hampustagerud
Copy link
Contributor Author

@arcanis Mind taking a look at this? 🙂

@thebergamo
Copy link

Any change to have it merged?

@arcanis arcanis merged commit 84e01a9 into yarnpkg:master Jul 24, 2019
@arcanis
Copy link
Member

arcanis commented Jul 24, 2019

Seems acceptable - thanks @hampustagerud! 🙂

VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
* Always run postversion lifecycle method

Runs postversion even if no git commit is made.

* Update CHANGELOG.md

* Improve logic, add tests, update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md
VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
* Always run postversion lifecycle method

Runs postversion even if no git commit is made.

* Update CHANGELOG.md

* Improve logic, add tests, update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running version with --no-git-tag-version skips postversion script hook
4 participants