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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use yarn publish
for Yarn
#220
Conversation
This chunk https://github.com/ErisDS/np/blob/dbef1d544c7a8f3ccd0e97c43a4c47df0fa58aec/index.js#L16-L24 splits stdout and stderr on newlines and then merges them in one observable that buffers them until it's finished.
|
index.js
Outdated
return 'Private package: not publishing to Yarn.'; | ||
} | ||
}, | ||
task: () => exec('yarn', ['publish', '--new-version', input]).catch(err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to support the tag
option, like done here: https://github.com/ErisDS/np/blob/dbef1d544c7a8f3ccd0e97c43a4c47df0fa58aec/lib/publish.js#L10-L12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it doesn't really make sense to run --new-version
here, as we already call yarn version --new-version
earlier: https://github.com/ErisDS/np/blob/dbef1d544c7a8f3ccd0e97c43a4c47df0fa58aec/index.js#L96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn publish
wants you to provide an argument for a new version to publish or you'll be prompted for it, so I think this is the only way to avoid the prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @gpoole explained, this isn't unnecessary duplication, it's required by yarn. I don't like it either.
I have added the --tag
argument back as requested.
I don't use Yarn, so I can't be of much help, but if you can find a way to reliably reproduce the issue, we can figure out exactly what caused it. Maybe someone could help debug this. // @NeekSandhu @jescalan @gpoole @jesstelford |
I'm a little baby so I might be missing something, but what issue(s) are we having with using stock npm publish that yarn attempts to solve? I don't use yarn myself, but unless yarn fixes something that npm really can't or has performance edge, adding more moving parts might just make things sophisticated (IMO). If you can add npm debug log or CLI output that'd be nice. Thanks. |
馃憢 I really don't mind whether or not yarn support gets added - it might not be a good idea whilst the yarn publish tool is so young - I was just trying to fix For me 2.16.1 works for private packages only - we're using this on all of our internal tools. 2.17+ all have the problem listed in #216 etc where it says "[Current version number] published 馃帀" Therefore we're pinned to 2.16.1. Meanwhile, I don't seem to be able to get np to work at all for public packages - i.e. where an npm publish is involved - what-so-ever. I always get an ENEEDAUTH error, even though I am logged in & running Our team uses yarn for dep management and script running now - so Here's an example: This is the package I'm working on: https://github.com/TryGhost/eslint-plugin-ghost/tree/ce1a8c44538d401758429eec1f28d6d03b014d20 I have yarn installed using the bash installer: https://yarnpkg.com/en/docs/install#alternatives-tab If there's any other information I can provide let me know. There seems to be 2 or 3 different problems here, and which ever one try to solve I bash my head against one of the others 馃槥 |
I'd recommend you to try the latest release of I cloned your repo named it I guess the verdict is, that this (^) issue is out of |
@NeekSandhu I've been using @ErisDS very strange issue with not being able to publish since it works outside of |
@gpoole Can you check if publish happens if you do Maybe try both ways, first np installed globally and then also as a local dev dependency. |
Oh yep, good point @NeekSandhu, I'm now getting the same issue running it as a script. Looks like @ErisDS I tested with your branch and it seems like it should work but for some reason I get |
@gpoole For me, this PR just hangs on the |
I meant packages with private:true set in the package.json, which in 2.16.1, results in a prerequisite login check, but the actual publish step isn't needed or run. I think you figured that out though. If there's something I can do to help track down the weirdnesses let me know - think all the questions so far have answered themselves or I have answered them. |
- Fixed linting errors (indent) - Added --tag support back for yarn publish
I've updated this PR to pass the linter (whoops) and add back the tag option. I'm running some more tests to ensure it works. Does anyone have any recommendations for good ways to test & debug the code without actually publishing stuff to npm? |
OK I found my dumb mistake that prevented this working. I've also verified that:
I also tested a few other scenarios e.g. setting |
@ErisDS Happy to see you got it sorted out in the end 馃憣馃槂 Sorry I couldn't be of more help. |
I just have a test repo and test npm package I use: https://github.com/sindresorhus/sindre-playground |
New |
|
||
return exec('yarn', args).catch(err => { | ||
throw new Error(err); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this. Why do you catch the error, rewrap it in an error, and throw it again?
Just FYI, this completely breaks publishing for people that have two-factor authentication enabled. |
Ah I just noticed this but it looks like |
I also have problems with np using
Given that |
@oligot if you still want to use npm, then you can use |
But then, it will use npm instead of yarn to install the dependencies, which is not what I want (yarn to install deps, npm to publish the package). |
I know that the project's philosophy is not to add spurious options. I found that I've never used a custom registry, so I'm not seeing what you're seeing. I'd suggest a bug report with full reproduction case would be the best place to start trying to come to a resolution? |
I understand that adding an extra option is not the best solution. Ok, I'll try to do a bug report with full reproduction case. |
There is now an open PR on yarn to only check the status code when publishing a package: yarnpkg/yarn#5398 |
We just merged it, will be part of the next release 馃憤 |
Just tested with the new release of yarn (1.6.0) and it works now 馃帀 |
refs #216, #203, etc
I've genuinely been pulling my hair out with np for the last 3 days. I've done my absolute best to try to contribute a fix because I love this tool, but I'm utterly lost 馃槶
I've tried to fix the npm publish, but I just don't understand how exec/execa/observable are all related.
Instead I've tried to add yarn publish support, but although the publish happens, the flow of control never returns back to listr it seems, so it sits and hangs forever, and never gets as far as pushing the tags. I am at a loss for how to debug.
This PR includes that attempt.
Can someone who understands listr, execa, etc etc take a look and see if they can find an easy fix?
I'd also love to know as well:
publish.js
achieve?execa
is used directly, although everywhere else it isexeca.stdout
If someone can point me at some related reading that would make this make sense I'd be grateful!