Skip to content

Commit

Permalink
Fix UI prompt for new publicly scoped packages (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell authored Mar 20, 2023
1 parent 3770647 commit e71f691
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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

0 comments on commit e71f691

Please sign in to comment.