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

Fixes #724

Merged
merged 3 commits into from
Dec 9, 2023
Merged

Fixes #724

merged 3 commits into from
Dec 9, 2023

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Dec 9, 2023

This PR is best reviewed commit-by-commit

1. fix broken revert code after publish failure

it didn't work because of a missing await and .pkg

2. make boolean logic easier to understand

because pkg.publishConfig will often be undefined, canBePublishedPublicly would short circuit to undefined, but undefined means true in inquirer's when option.
change this by always returning an explicit true or false.
this should not bring any changes.
also put isScoped(pkg.name) into the bool for consistency.

3 fix yarn npm publish for scoped packages

this will make yarn berry yarn npm publish behave like npm publish:
npm publish on an already public scoped package will publish it gladly
however for yarn npm publish, even if the scoped package is already published publicly
we need to specify the --access public argument, or it will fail with 402 (Payment Required)
here I add a check (currently only for yarn berry) for whether the published version of the package is public,
and if so, set publishScoped to true (and don't ask for it)

after publish failure
because pkg.publishConfig will often be `undefined`, canBePublishedPublicly would short circuit to `undefined`, but `undefined` means `true` in inquirer `when`...
change this by always returning an explicit true or false
this should not bring any changes.
also put isScoped(pkg.name) into the bool for consistency
this will make yarn berry `yarn npm publish` behave like `npm publish`:
`npm publish` on an already public scoped package will publish it gladly
however for `yarn npm publish`, even if the scoped package is already published publicly
we need to specify the `--access public` argument, or it will fail with 402 (Payment Required)
here I add a check (currently only for yarn berry) for whether the published version of the package is public,
and if so, set publishScoped to true (and don't ask for it)
@sindresorhus sindresorhus merged commit 6c2c930 into sindresorhus:main Dec 9, 2023
1 check passed
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.

2 participants