diff --git a/src/lib/queryVersions.ts b/src/lib/queryVersions.ts index 1368a462..d1fff4b9 100644 --- a/src/lib/queryVersions.ts +++ b/src/lib/queryVersions.ts @@ -9,6 +9,7 @@ import { VersionResult } from '../types/VersionResult' import { VersionSpec } from '../types/VersionSpec' import getPackageManager from './getPackageManager' import keyValueBy from './keyValueBy' +import programError from './programError' import { createNpmAlias, isGithubUrl, isPre, parseNpmAlias } from './version-util' const supportedVersionTargets = ['latest', 'newest', 'greatest', 'minor', 'patch'] @@ -71,12 +72,12 @@ async function queryVersions(packageMap: Index, options: Options = if (!getPackageVersion) { const packageManagerSupportedVersionTargets = supportedVersionTargets.filter(t => t in packageManager) - return Promise.reject( - new Error( - `Unsupported target "${target}" for ${packageManagerName}. Supported version targets are: ` + - packageManagerSupportedVersionTargets.join(', ') + - (!isGithubDependency ? ' and custom distribution tags, following "@" (example: @next)' : ''), - ), + programError( + options, + chalk.red(`\nUnsupported target "${target}" using ${packageManagerName}`) + + `\nSupported version targets are: ` + + packageManagerSupportedVersionTargets.join(', ') + + (!isGithubDependency ? ', and tags (e.g. @next)' : ''), ) } diff --git a/src/package-managers/pnpm.ts b/src/package-managers/pnpm.ts index 7f568872..7cda51dc 100644 --- a/src/package-managers/pnpm.ts +++ b/src/package-managers/pnpm.ts @@ -36,6 +36,7 @@ export { greatest, latest, minor, + patch, newest, packageAuthorChanged, } from './npm' diff --git a/src/types/PackageManager.ts b/src/types/PackageManager.ts index 9694667d..82590d23 100644 --- a/src/types/PackageManager.ts +++ b/src/types/PackageManager.ts @@ -4,14 +4,14 @@ import { Options } from './Options' import { Version } from './Version' import { VersionSpec } from './VersionSpec' -/** The package manager API that ncu uses to fetch versions and meta information for packages. Includes npm and yarn, and others can be added if needed. */ +/** The package manager API that ncu uses to fetch versions and meta information for packages. Includes npm and yarn, and others can be added as needed. */ export interface PackageManager { defaultPrefix?: (options: Options) => Promise list?: (options: Options) => Promise> latest: GetVersion - major?: GetVersion minor?: GetVersion newest?: GetVersion + patch?: GetVersion greatest?: GetVersion packageAuthorChanged?: ( packageName: string,