Yarn: Publish without version prompt

Created on 29 Mar 2017  ·  25Comments  ·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
minor feature

What is the current behavior?
yarn publish is prompting for a new version number

What is the expected behavior?
For a release and deployment bash script, I bump the new version internally and would like to pass on the new version to yarn with an argument like yarn publish --version new.version.number

And better, yarn publish auto, would parse the new version number in package.json. Sometimes I bump it there too.

Please mention your node.js, yarn and operating system version.
Think that's irrelevant?

triaged

Most helpful comment

hmm, tried that and am hitting the next stumbling block. with --new-version i see this error

yarn publish v0.22.0
info Current version: 1.25.7
error New version is the same as the current version.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

let me explain my use case. i am running this bash script to deploy new releases:
https://github.com/binarykitchen/videomail-client/blob/develop/bin/release.sh

there you can see that i am tagging new releases with git flow, doing stuff on gulp, bumping the version, doing a final commit before pushing and publishing that to npm. in other words, the version bump already has been done and i don't want yarn to bump it.

honestly i think yarn shouldn't do this local check and not print the New version is the same as the current version. error. leave it to npm to respond with an error when the version already exist.

All 25 comments

You should be able to run yarn publish --new-version x.y.z to fix the version from the command line. Unfortunately, it seems impossible to just skip the version bump at all. Maybe the current behaviour should be moved inside a -i,--interactive flag ... wdyt, @bestander?

Yeah, we should allow publishing without bump.
Maybe an argument --no-version-bump would be the easiest way to do it without breaking current API.
Send a PR!

but i am confused, code says there is already an argument for version, see
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/version.js#L70

That one is yarn version command.

@bestander well, the code for the yarn publish command is using it, see https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/publish.js#L138

So what happens when you pass version via --version?

ah, i think we can do yarn publish --new-version x.y.z ... will try tonight

hmm, tried that and am hitting the next stumbling block. with --new-version i see this error

yarn publish v0.22.0
info Current version: 1.25.7
error New version is the same as the current version.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

let me explain my use case. i am running this bash script to deploy new releases:
https://github.com/binarykitchen/videomail-client/blob/develop/bin/release.sh

there you can see that i am tagging new releases with git flow, doing stuff on gulp, bumping the version, doing a final commit before pushing and publishing that to npm. in other words, the version bump already has been done and i don't want yarn to bump it.

honestly i think yarn shouldn't do this local check and not print the New version is the same as the current version. error. leave it to npm to respond with an error when the version already exist.

@bestander @arcanis if you think that's a separate issue, happy to raise another one

Go ahead, a PR will be appreciated

On Sat, 8 Apr 2017 at 02:24, Michael Heuberger notifications@github.com
wrote:

@bestander https://github.com/bestander @arcanis
https://github.com/arcanis if you think that's a separate issue, happy
to raise another one


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yarnpkg/yarn/issues/3011#issuecomment-292685420, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACBdWIgyC3S26pih2d_Mo4mwCCUZVU45ks5rtuHkgaJpZM4Msop0
.

fixed

@bestander is this still not out?

It is in branch 0.24
screen shot 2017-05-11 at 10 59 55 am

We just keep it as RC till tomorrow but you can install it anyway.

@bestander now gave this a try and something does not look right. it gets stuck when publishing.

~/c/videomail-client ❯❯❯ yarn publish --new-version 1.27.6 --verbose                           ⏎ release/1.27.6 ✭
yarn publish v0.24.4
verbose 0.188 Checking for configuration file "/home/michael-heuberger/code/videomail-client/.npmrc".
verbose 0.188 Checking for configuration file "/home/michael-heuberger/.npmrc".
verbose 0.189 Found configuration file "/home/michael-heuberger/.npmrc".
verbose 0.191 Checking for configuration file "/home/michael-heuberger/.nvm/versions/node/v7.7.2/.npmrc".
verbose 0.191 Checking for configuration file "/home/michael-heuberger/code/videomail-client/.npmrc".
verbose 0.191 Checking for configuration file "/home/michael-heuberger/code/.npmrc".
verbose 0.191 Checking for configuration file "/home/michael-heuberger/.npmrc".
verbose 0.191 Found configuration file "/home/michael-heuberger/.npmrc".
verbose 0.192 Checking for configuration file "/home/.npmrc".
verbose 0.194 Checking for configuration file "/home/michael-heuberger/code/videomail-client/.yarnrc".
verbose 0.195 Checking for configuration file "/home/michael-heuberger/.yarnrc".
verbose 0.195 Found configuration file "/home/michael-heuberger/.yarnrc".
verbose 0.195 Checking for configuration file "/home/michael-heuberger/.nvm/versions/node/v7.7.2/.yarnrc".
verbose 0.195 Checking for configuration file "/home/michael-heuberger/code/videomail-client/.yarnrc".
verbose 0.195 Checking for configuration file "/home/michael-heuberger/code/.yarnrc".
verbose 0.196 Checking for configuration file "/home/michael-heuberger/.yarnrc".
verbose 0.196 Found configuration file "/home/michael-heuberger/.yarnrc".
verbose 0.196 Checking for configuration file "/home/.yarnrc".
verbose 0.198 current time: 2017-05-13T01:02:34.626Z
[1/4] Bumping version...
info Current version: 1.27.6
[2/4] Logging in...
[3/4] Publishing... <--- here it stucks and does nothing for minutes, not even a timeout

hello??

@bestander cc

Thanks for reporting, @binarykitchen.
If it gets stuck then probably it tries to prompt for authentication.
Please open a new issue

@bestander why not reopen it? it's the same original issue - happy to examine and to submit another PR here

Thanks @binarykitchen, looking forward to get a fix

hmmm, i figured out that

stream.pipe(new ConcatStream(resolve))
  .on('error', reject);

in publish.js is the problem. when I added a data listener while debugging, publishing suddenly worked.

like that

stream.pipe(new ConcatStream(resolve))
  .on('data', console.log)  
  .on('error', reject);

probably the stream needs a data sink to make this actually work?

@bestander have an idea what that is?

@binarykitchen, thanks for reporting more.
There may be lots of reasons for streams to get stuck, e.g. https://github.com/ludios/why-are-my-node-streams-hanging.
Maybe adding a data handler affects scheduling a bit and your publish does not get stuck anymore but it seems like we might be handling streams piping wrong here.

Do you have a repo where this issue can be reproduced 100%?

yeah, good idea with data handler but i am afraid, i have switched back to npm5 and do not have the time right now :(

@BYK, you said you have an idea where the bug is coming from.

@binarykitchen, thanks for reporting anyway, hope we can win you back soon. :)

Was this page helpful?
0 / 5 - 0 ratings