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

Fix UI prompt for new publicly scoped packages #677

Merged
merged 3 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ To publish [scoped packages](https://docs.npmjs.com/misc/scope#publishing-public
}
```

If publishing a scoped package for the first time, `np` will prompt you to ask if you want to publish it publicly.

### Private Org-scoped packages

To publish a [private Org-scoped package](https://docs.npmjs.com/creating-and-publishing-an-org-scoped-package#publishing-a-private-org-scoped-package), you need to set the access level to `restricted`. You can do that by adding the following to your `package.json`:
Expand Down
6 changes: 6 additions & 0 deletions source/npm/handle-npm-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const handleNpmError = (error, task, message, executor) => {
);
}

// Attempting to privately publish a scoped package without the correct npm plan
// https://stackoverflow.com/a/44862841/10292952
if (error.code === 402 || error.stderr.includes('npm ERR! 402 Payment Required')) {
throw new Error('You cannot publish a privately scoped package without a paid plan. Did you mean to publish publicly?');
}

return throwError(error);
};

Expand Down
1 change: 1 addition & 0 deletions source/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ module.exports = async (options, pkg) => {
...options,
version: answers.version || answers.customVersion || options.version,
tag: answers.tag || answers.customTag || options.tag,
publishScoped: answers.publishScoped,
confirm: true,
repoUrl,
releaseNotes
Expand Down