@pnpm/npm-resolver
Advanced tools
Comparing version 12.1.8 to 13.0.0
@@ -5,2 +5,3 @@ import PnpmError from '@pnpm/error'; | ||
import { PackageMeta, PackageMetaCache } from './pickPackage'; | ||
import parsePref, { RegistryPackageSpec } from './parsePref'; | ||
import { RegistryResponseError } from './fetch'; | ||
@@ -14,3 +15,3 @@ export declare class NoMatchingVersionError extends PnpmError { | ||
} | ||
export { PackageMeta, PackageMetaCache, RegistryResponseError, }; | ||
export { parsePref, PackageMeta, PackageMetaCache, RegistryPackageSpec, RegistryResponseError, }; | ||
export interface ResolverFactoryOptions { | ||
@@ -17,0 +18,0 @@ cacheDir: string; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RegistryResponseError = exports.NoMatchingVersionError = void 0; | ||
exports.RegistryResponseError = exports.parsePref = exports.NoMatchingVersionError = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -41,2 +41,3 @@ const error_1 = __importDefault(require("@pnpm/error")); | ||
const parsePref_1 = __importDefault(require("./parsePref")); | ||
exports.parsePref = parsePref_1.default; | ||
const fetch_1 = __importStar(require("./fetch")); | ||
@@ -48,5 +49,4 @@ Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return fetch_1.RegistryResponseError; } }); | ||
constructor(opts) { | ||
var _a; | ||
const dep = opts.wantedDependency.alias | ||
? `${opts.wantedDependency.alias}@${(_a = opts.wantedDependency.pref) !== null && _a !== void 0 ? _a : ''}` | ||
? `${opts.wantedDependency.alias}@${opts.wantedDependency.pref ?? ''}` | ||
: opts.wantedDependency.pref; | ||
@@ -64,3 +64,2 @@ super('NO_MATCHING_VERSION', `No matching version found for ${dep}`); | ||
function createResolver(fetchFromRegistry, getCredentials, opts) { | ||
var _a, _b; | ||
if (typeof opts.cacheDir !== 'string') { // eslint-disable-line | ||
@@ -70,4 +69,4 @@ throw new TypeError('`opts.cacheDir` is required and needs to be a string'); | ||
const fetchOpts = { | ||
retry: (_a = opts.retry) !== null && _a !== void 0 ? _a : {}, | ||
timeout: (_b = opts.timeout) !== null && _b !== void 0 ? _b : 60000, | ||
retry: opts.retry ?? {}, | ||
timeout: opts.timeout ?? 60000, | ||
}; | ||
@@ -97,5 +96,4 @@ const fetch = (0, p_memoize_1.default)(fetch_1.default.bind(null, fetchFromRegistry, fetchOpts), { | ||
async function resolveNpm(ctx, wantedDependency, opts) { | ||
var _a, _b, _c; | ||
const defaultTag = (_a = opts.defaultTag) !== null && _a !== void 0 ? _a : 'latest'; | ||
if ((_b = wantedDependency.pref) === null || _b === void 0 ? void 0 : _b.startsWith('workspace:')) { | ||
const defaultTag = opts.defaultTag ?? 'latest'; | ||
if (wantedDependency.pref?.startsWith('workspace:')) { | ||
if (wantedDependency.pref.startsWith('workspace:.')) | ||
@@ -126,3 +124,3 @@ return null; | ||
dryRun: opts.dryRun === true, | ||
preferredVersionSelectors: (_c = opts.preferredVersions) === null || _c === void 0 ? void 0 : _c[spec.name], | ||
preferredVersionSelectors: opts.preferredVersions?.[spec.name], | ||
registry: opts.registry, | ||
@@ -157,3 +155,3 @@ }); | ||
} | ||
if (((workspacePackages === null || workspacePackages === void 0 ? void 0 : workspacePackages[pickedPackage.name]) != null) && opts.projectDir) { | ||
if (((workspacePackages?.[pickedPackage.name]) != null) && opts.projectDir) { | ||
if (workspacePackages[pickedPackage.name][pickedPackage.version]) { | ||
@@ -197,4 +195,3 @@ return { | ||
function tryResolveFromWorkspace(wantedDependency, opts) { | ||
var _a, _b; | ||
if (!((_a = wantedDependency.pref) === null || _a === void 0 ? void 0 : _a.startsWith('workspace:'))) { | ||
if (!wantedDependency.pref?.startsWith('workspace:')) { | ||
return null; | ||
@@ -218,3 +215,3 @@ } | ||
if (resolvedFromLocal == null) { | ||
throw new error_1.default('NO_MATCHING_VERSION_INSIDE_WORKSPACE', `In ${path_1.default.relative(process.cwd(), opts.projectDir)}: No matching version found for ${(_b = wantedDependency.alias) !== null && _b !== void 0 ? _b : ''}@${pref} inside the workspace`); | ||
throw new error_1.default('NO_MATCHING_VERSION_INSIDE_WORKSPACE', `In ${path_1.default.relative(process.cwd(), opts.projectDir)}: No matching version found for ${wantedDependency.alias ?? ''}@${pref} inside the workspace`); | ||
} | ||
@@ -221,0 +218,0 @@ return resolvedFromLocal; |
@@ -25,3 +25,2 @@ "use strict"; | ||
exports.default = async (ctx, spec, opts) => { | ||
var _a; | ||
opts = opts || {}; | ||
@@ -61,6 +60,6 @@ validatePackageName(spec.name); | ||
if (spec.type === 'version') { | ||
metaCachedInStore = metaCachedInStore !== null && metaCachedInStore !== void 0 ? metaCachedInStore : await limit(async () => loadMeta(pkgMirror)); | ||
metaCachedInStore = metaCachedInStore ?? await limit(async () => loadMeta(pkgMirror)); | ||
// use the cached meta only if it has the required package version | ||
// otherwise it is probably out of date | ||
if (((_a = metaCachedInStore === null || metaCachedInStore === void 0 ? void 0 : metaCachedInStore.versions) === null || _a === void 0 ? void 0 : _a[spec.fetchSpec]) != null) { | ||
if ((metaCachedInStore?.versions?.[spec.fetchSpec]) != null) { | ||
return { | ||
@@ -94,2 +93,3 @@ meta: metaCachedInStore, | ||
catch (err) { // eslint-disable-line | ||
err.spec = spec; | ||
const meta = await loadMeta(pkgMirror); // TODO: add test for this usecase | ||
@@ -96,0 +96,0 @@ if (meta == null) |
@@ -41,3 +41,3 @@ "use strict"; | ||
const latest = meta['dist-tags'].latest; | ||
const preferredVerSelsArr = Object.entries(preferredVerSels !== null && preferredVerSels !== void 0 ? preferredVerSels : {}); | ||
const preferredVerSelsArr = Object.entries(preferredVerSels ?? {}); | ||
if (preferredVerSelsArr.length > 0) { | ||
@@ -86,3 +86,3 @@ const preferredVersions = []; | ||
} | ||
versions = versions !== null && versions !== void 0 ? versions : Object.keys(meta.versions); | ||
versions = versions ?? Object.keys(meta.versions); | ||
const maxVersion = semver_1.default.maxSatisfying(versions, versionRange, true); | ||
@@ -89,0 +89,0 @@ // if the selected version is deprecated, try to find a non-deprecated one that satisfies the range |
{ | ||
"name": "@pnpm/npm-resolver", | ||
"version": "12.1.8", | ||
"version": "13.0.0", | ||
"description": "Resolver for npm-hosted packages", | ||
@@ -12,7 +12,7 @@ "main": "lib/index.js", | ||
"engines": { | ||
"node": ">=12.17" | ||
"node": ">=14.19" | ||
}, | ||
"repository": "https://github.com/pnpm/pnpm/blob/main/packages/npm-resolver", | ||
"keywords": [ | ||
"pnpm6", | ||
"pnpm7", | ||
"pnpm", | ||
@@ -31,9 +31,9 @@ "resolver", | ||
"dependencies": { | ||
"@pnpm/core-loggers": "6.1.4", | ||
"@pnpm/error": "2.1.0", | ||
"@pnpm/fetching-types": "2.2.1", | ||
"@pnpm/graceful-fs": "1.0.0", | ||
"@pnpm/resolve-workspace-range": "2.1.0", | ||
"@pnpm/resolver-base": "8.1.6", | ||
"@pnpm/types": "7.10.0", | ||
"@pnpm/core-loggers": "7.0.0", | ||
"@pnpm/error": "3.0.0", | ||
"@pnpm/fetching-types": "3.0.0", | ||
"@pnpm/graceful-fs": "2.0.0", | ||
"@pnpm/resolve-workspace-range": "3.0.0", | ||
"@pnpm/resolver-base": "9.0.0", | ||
"@pnpm/types": "8.0.0", | ||
"@zkochan/retry": "^0.2.0", | ||
@@ -54,6 +54,6 @@ "encode-registry": "^3.0.0", | ||
"devDependencies": { | ||
"@pnpm/fetch": "4.2.5", | ||
"@pnpm/fetch": "5.0.0", | ||
"@pnpm/logger": "^4.0.0", | ||
"@pnpm/npm-resolver": "12.1.8", | ||
"@pnpm/test-fixtures": "0.0.5", | ||
"@pnpm/npm-resolver": "13.0.0", | ||
"@pnpm/test-fixtures": "0.0.6", | ||
"@types/lru-cache": "^5.1.0", | ||
@@ -68,2 +68,5 @@ "@types/normalize-path": "^3.0.0", | ||
"funding": "https://opencollective.com/pnpm", | ||
"exports": { | ||
".": "./lib/index.js" | ||
}, | ||
"scripts": { | ||
@@ -70,0 +73,0 @@ "lint": "eslint src/**/*.ts test/**/*.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58653
794
+ Added@pnpm/constants@6.0.0(transitive)
+ Added@pnpm/core-loggers@7.0.0(transitive)
+ Added@pnpm/error@3.0.0(transitive)
+ Added@pnpm/fetching-types@3.0.0(transitive)
+ Added@pnpm/graceful-fs@2.0.0(transitive)
+ Added@pnpm/resolve-workspace-range@3.0.0(transitive)
+ Added@pnpm/resolver-base@9.0.0(transitive)
+ Added@pnpm/types@8.0.0(transitive)
- Removed@pnpm/constants@5.0.0(transitive)
- Removed@pnpm/core-loggers@6.1.4(transitive)
- Removed@pnpm/error@2.1.0(transitive)
- Removed@pnpm/fetching-types@2.2.1(transitive)
- Removed@pnpm/graceful-fs@1.0.0(transitive)
- Removed@pnpm/resolve-workspace-range@2.1.0(transitive)
- Removed@pnpm/resolver-base@8.1.6(transitive)
- Removed@pnpm/types@7.10.0(transitive)
Updated@pnpm/core-loggers@7.0.0
Updated@pnpm/error@3.0.0
Updated@pnpm/fetching-types@3.0.0
Updated@pnpm/graceful-fs@2.0.0
Updated@pnpm/resolver-base@9.0.0
Updated@pnpm/types@8.0.0