Skip to content

Commit e71f691

Browse files
Fix UI prompt for new publicly scoped packages (#677)
1 parent 3770647 commit e71f691

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ To publish [scoped packages](https://docs.npmjs.com/misc/scope#publishing-public
243243
}
244244
```
245245

246+
If publishing a scoped package for the first time, `np` will prompt you to ask if you want to publish it publicly.
247+
246248
### Private Org-scoped packages
247249

248250
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`:

source/npm/handle-npm-error.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const handleNpmError = (error, task, message, executor) => {
2525
);
2626
}
2727

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

source/ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ module.exports = async (options, pkg) => {
284284
...options,
285285
version: answers.version || answers.customVersion || options.version,
286286
tag: answers.tag || answers.customTag || options.tag,
287+
publishScoped: answers.publishScoped,
287288
confirm: true,
288289
repoUrl,
289290
releaseNotes

0 commit comments

Comments
 (0)