From d7543ffde30b60ed05eb5f7177baa8d08c131a44 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 27 Nov 2023 19:21:19 +0800 Subject: [PATCH] Improvements and fixes (#721) --- readme.md | 4 +++- source/index.js | 6 +++--- source/release-task-helper.js | 2 +- source/ui.js | 4 ++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 3455b0cb..e9ae7eff 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,7 @@ ### Why not - Monorepos are not supported. -- Yarn >= 2 is not supported. +- Yarn >= 2 and pnpm are not supported. - Custom registries are not supported ([but could be with your help](https://github.com/sindresorhus/np/issues/420)). - CI is [not an ideal environment](https://github.com/sindresorhus/np/issues/619#issuecomment-994493179) for `np`. It's meant to be used locally as an interactive tool. @@ -254,6 +254,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. +**Note:** When publishing a scoped package, the first ever version you publish has to be done interactively using `np`. If not, you cannot use `np` to publish future versions of the package. + ### 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`: diff --git a/source/index.js b/source/index.js index c4aa6c30..93a9407d 100644 --- a/source/index.js +++ b/source/index.js @@ -12,7 +12,7 @@ import logSymbols from 'log-symbols'; import prerequisiteTasks from './prerequisite-tasks.js'; import gitTasks from './git-tasks.js'; import publish, {getPackagePublishArguments} from './npm/publish.js'; -import enable2fa from './npm/enable-2fa.js'; +import enable2fa, {getEnable2faArgs} from './npm/enable-2fa.js'; import releaseTaskHelper from './release-task-helper.js'; import * as util from './util.js'; import * as git from './git-util.js'; @@ -227,9 +227,9 @@ const np = async (input = 'patch', options, {pkg, rootDir}) => { }, ...shouldEnable2FA ? [{ title: 'Enabling two-factor authentication', - skip() { + async skip() { if (options.preview) { - const args = enable2fa.getEnable2faArgs(pkg.name, options); + const args = await getEnable2faArgs(pkg.name, options); return `[Preview] Command not executed: npm ${args.join(' ')}.`; } }, diff --git a/source/release-task-helper.js b/source/release-task-helper.js index 51f62058..ebaf2269 100644 --- a/source/release-task-helper.js +++ b/source/release-task-helper.js @@ -6,7 +6,7 @@ import Version from './version.js'; const releaseTaskHelper = async (options, pkg) => { const newVersion = options.releaseDraftOnly ? new Version(pkg.version) - : new Version(pkg.version).setFrom(options.version, {prereleasePrefix: await getPreReleasePrefix(options)}); + : new Version(pkg.version).setFrom(options.version.toString(), {prereleasePrefix: await getPreReleasePrefix(options)}); const tag = await getTagVersionPrefix(options) + newVersion.toString(); diff --git a/source/ui.js b/source/ui.js index 44931301..66e7984a 100644 --- a/source/ui.js +++ b/source/ui.js @@ -198,6 +198,10 @@ const ui = async (options, {pkg, rootDir}) => { } if (options.availability.isUnknown) { + if (!isScoped(pkg.name)) { + throw new Error('Unknown availability, but package is not scoped. This shouldn\'t happen'); + } + const answers = await inquirer.prompt({ confirm: { type: 'confirm',