@pnpm/npm-resolver
Advanced tools
Comparing version 13.1.11 to 14.0.0
@@ -1,1 +0,1 @@ | ||
export default function createPkgId(registry: string, pkgName: string, pkgVersion: string): string; | ||
export declare function createPkgId(registry: string, pkgName: string, pkgVersion: string): string; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPkgId = void 0; | ||
const encode_registry_1 = __importDefault(require("encode-registry")); | ||
@@ -12,3 +13,3 @@ function createPkgId(registry, pkgName, pkgVersion) { | ||
} | ||
exports.default = createPkgId; | ||
exports.createPkgId = createPkgId; | ||
//# sourceMappingURL=createNpmPkgId.js.map |
@@ -8,5 +8,5 @@ import { FetchError, FetchErrorRequest, FetchErrorResponse } from '@pnpm/error'; | ||
} | ||
export default function fromRegistry(fetch: FetchFromRegistry, fetchOpts: { | ||
export declare function fromRegistry(fetch: FetchFromRegistry, fetchOpts: { | ||
retry: RetryTimeoutOptions; | ||
timeout: number; | ||
}, pkgName: string, registry: string, authHeaderValue?: string): Promise<PackageMeta>; |
@@ -29,6 +29,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RegistryResponseError = void 0; | ||
exports.fromRegistry = exports.RegistryResponseError = void 0; | ||
const url_1 = __importDefault(require("url")); | ||
const core_loggers_1 = require("@pnpm/core-loggers"); | ||
const error_1 = __importStar(require("@pnpm/error")); | ||
const error_1 = require("@pnpm/error"); | ||
const retry = __importStar(require("@zkochan/retry")); | ||
@@ -66,3 +66,3 @@ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string | ||
catch (error) { // eslint-disable-line | ||
reject(new error_1.default('META_FETCH_FAIL', `GET ${uri}: ${error.message}`, { attempts: attempt })); | ||
reject(new error_1.PnpmError('META_FETCH_FAIL', `GET ${uri}: ${error.message}`, { attempts: attempt })); | ||
return; | ||
@@ -84,3 +84,3 @@ } | ||
catch (error) { // eslint-disable-line | ||
const timeout = op.retry(new error_1.default('BROKEN_METADATA_JSON', error.message)); | ||
const timeout = op.retry(new error_1.PnpmError('BROKEN_METADATA_JSON', error.message)); | ||
if (timeout === false) { | ||
@@ -101,3 +101,3 @@ reject(op.mainError()); | ||
} | ||
exports.default = fromRegistry; | ||
exports.fromRegistry = fromRegistry; | ||
function toUri(pkgName, registry) { | ||
@@ -104,0 +104,0 @@ let encodedName; |
@@ -1,6 +0,6 @@ | ||
import PnpmError from '@pnpm/error'; | ||
import { PnpmError } from '@pnpm/error'; | ||
import { FetchFromRegistry, GetCredentials, RetryTimeoutOptions } from '@pnpm/fetching-types'; | ||
import { PreferredVersions, ResolveResult, WantedDependency, WorkspacePackages } from '@pnpm/resolver-base'; | ||
import { PackageMeta, PackageMetaCache } from './pickPackage'; | ||
import parsePref, { RegistryPackageSpec } from './parsePref'; | ||
import { parsePref, RegistryPackageSpec } from './parsePref'; | ||
import { RegistryResponseError } from './fetch'; | ||
@@ -24,3 +24,3 @@ export declare class NoMatchingVersionError extends PnpmError { | ||
} | ||
export default function createResolver(fetchFromRegistry: FetchFromRegistry, getCredentials: GetCredentials, opts: ResolverFactoryOptions): (wantedDependency: WantedDependency, opts: ResolveFromNpmOptions) => Promise<ResolveResult | null>; | ||
export declare function createNpmResolver(fetchFromRegistry: FetchFromRegistry, getCredentials: GetCredentials, opts: ResolverFactoryOptions): (wantedDependency: WantedDependency, opts: ResolveFromNpmOptions) => Promise<ResolveResult | null>; | ||
export declare type ResolveFromNpmOptions = { | ||
@@ -27,0 +27,0 @@ alwaysTryWorkspacePackages?: boolean; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -29,6 +6,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RegistryResponseError = exports.parsePref = exports.NoMatchingVersionError = void 0; | ||
exports.createNpmResolver = exports.RegistryResponseError = exports.parsePref = exports.NoMatchingVersionError = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
const error_1 = __importDefault(require("@pnpm/error")); | ||
const resolve_workspace_range_1 = __importDefault(require("@pnpm/resolve-workspace-range")); | ||
const error_1 = require("@pnpm/error"); | ||
const resolve_workspace_range_1 = require("@pnpm/resolve-workspace-range"); | ||
const lru_cache_1 = __importDefault(require("lru-cache")); | ||
@@ -40,10 +17,10 @@ const normalize_path_1 = __importDefault(require("normalize-path")); | ||
const ssri_1 = __importDefault(require("ssri")); | ||
const pickPackage_1 = __importDefault(require("./pickPackage")); | ||
const parsePref_1 = __importDefault(require("./parsePref")); | ||
exports.parsePref = parsePref_1.default; | ||
const fetch_1 = __importStar(require("./fetch")); | ||
const pickPackage_1 = require("./pickPackage"); | ||
const parsePref_1 = require("./parsePref"); | ||
Object.defineProperty(exports, "parsePref", { enumerable: true, get: function () { return parsePref_1.parsePref; } }); | ||
const fetch_1 = require("./fetch"); | ||
Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return fetch_1.RegistryResponseError; } }); | ||
const createNpmPkgId_1 = __importDefault(require("./createNpmPkgId")); | ||
const workspacePrefToNpm_1 = __importDefault(require("./workspacePrefToNpm")); | ||
class NoMatchingVersionError extends error_1.default { | ||
const createNpmPkgId_1 = require("./createNpmPkgId"); | ||
const workspacePrefToNpm_1 = require("./workspacePrefToNpm"); | ||
class NoMatchingVersionError extends error_1.PnpmError { | ||
constructor(opts) { | ||
@@ -64,3 +41,3 @@ const dep = opts.wantedDependency.alias | ||
const FULL_FILTERED_META_DIR = 'metadata-v1.1'; | ||
function createResolver(fetchFromRegistry, getCredentials, opts) { | ||
function createNpmResolver(fetchFromRegistry, getCredentials, opts) { | ||
if (typeof opts.cacheDir !== 'string') { | ||
@@ -73,3 +50,3 @@ throw new TypeError('`opts.cacheDir` is required and needs to be a string'); | ||
}; | ||
const fetch = (0, p_memoize_1.default)(fetch_1.default.bind(null, fetchFromRegistry, fetchOpts), { | ||
const fetch = (0, p_memoize_1.default)(fetch_1.fromRegistry.bind(null, fetchFromRegistry, fetchOpts), { | ||
cacheKey: (...args) => JSON.stringify(args), | ||
@@ -85,3 +62,3 @@ maxAge: 1000 * 20, // 20 seconds | ||
getAuthHeaderValueByURI, | ||
pickPackage: pickPackage_1.default.bind(null, { | ||
pickPackage: pickPackage_1.pickPackage.bind(null, { | ||
fetch, | ||
@@ -97,3 +74,3 @@ filterMetadata: opts.filterMetadata, | ||
} | ||
exports.default = createResolver; | ||
exports.createNpmResolver = createNpmResolver; | ||
async function resolveNpm(ctx, wantedDependency, opts) { | ||
@@ -117,3 +94,3 @@ const defaultTag = opts.defaultTag ?? 'latest'; | ||
const spec = wantedDependency.pref | ||
? (0, parsePref_1.default)(wantedDependency.pref, wantedDependency.alias, defaultTag, opts.registry) | ||
? (0, parsePref_1.parsePref)(wantedDependency.pref, wantedDependency.alias, defaultTag, opts.registry) | ||
: defaultTagForAlias(wantedDependency.alias, defaultTag); | ||
@@ -183,3 +160,3 @@ if (spec == null) | ||
} | ||
const id = (0, createNpmPkgId_1.default)(pickedPackage.dist.tarball, pickedPackage.name, pickedPackage.version); | ||
const id = (0, createNpmPkgId_1.createPkgId)(pickedPackage.dist.tarball, pickedPackage.name, pickedPackage.version); | ||
const resolution = { | ||
@@ -204,4 +181,4 @@ integrity: getIntegrity(pickedPackage.dist), | ||
} | ||
const pref = (0, workspacePrefToNpm_1.default)(wantedDependency.pref); | ||
const spec = (0, parsePref_1.default)(pref, wantedDependency.alias, opts.defaultTag, opts.registry); | ||
const pref = (0, workspacePrefToNpm_1.workspacePrefToNpm)(wantedDependency.pref); | ||
const spec = (0, parsePref_1.parsePref)(pref, wantedDependency.alias, opts.defaultTag, opts.registry); | ||
if (spec == null) | ||
@@ -221,3 +198,3 @@ throw new Error(`Invalid workspace: spec (${wantedDependency.pref})`); | ||
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 ${wantedDependency.alias ?? ''}@${pref} inside the workspace`); | ||
throw new error_1.PnpmError('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`); | ||
} | ||
@@ -242,3 +219,3 @@ return resolvedFromLocal; | ||
case 'range': | ||
return (0, resolve_workspace_range_1.default)(spec.fetchSpec, localVersions); | ||
return (0, resolve_workspace_range_1.resolveWorkspaceRange)(spec.fetchSpec, localVersions); | ||
default: | ||
@@ -293,3 +270,3 @@ return null; | ||
if (!integrity) { | ||
throw new error_1.default('INVALID_TARBALL_INTEGRITY', `Tarball "${dist.tarball}" has invalid shasum specified in its metadata: ${dist.shasum}`); | ||
throw new error_1.PnpmError('INVALID_TARBALL_INTEGRITY', `Tarball "${dist.tarball}" has invalid shasum specified in its metadata: ${dist.shasum}`); | ||
} | ||
@@ -296,0 +273,0 @@ return integrity.toString(); |
@@ -7,2 +7,2 @@ export interface RegistryPackageSpec { | ||
} | ||
export default function parsePref(pref: string, alias: string | undefined, defaultTag: string, registry: string): RegistryPackageSpec | null; | ||
export declare function parsePref(pref: string, alias: string | undefined, defaultTag: string, registry: string): RegistryPackageSpec | null; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parsePref = void 0; | ||
const parse_npm_tarball_url_1 = __importDefault(require("parse-npm-tarball-url")); | ||
@@ -46,3 +47,3 @@ const version_selector_type_1 = __importDefault(require("version-selector-type")); | ||
} | ||
exports.default = parsePref; | ||
exports.parsePref = parsePref; | ||
//# sourceMappingURL=parsePref.js.map |
@@ -31,3 +31,3 @@ import { VersionSelectors } from '@pnpm/resolver-base'; | ||
} | ||
declare const _default: (ctx: { | ||
export declare function pickPackage(ctx: { | ||
fetch: (pkgName: string, registry: string, authHeaderValue?: string) => Promise<PackageMeta>; | ||
@@ -37,9 +37,8 @@ metaDir: string; | ||
cacheDir: string; | ||
offline?: boolean | undefined; | ||
preferOffline?: boolean | undefined; | ||
filterMetadata?: boolean | undefined; | ||
}, spec: RegistryPackageSpec, opts: PickPackageOptions) => Promise<{ | ||
offline?: boolean; | ||
preferOffline?: boolean; | ||
filterMetadata?: boolean; | ||
}, spec: RegistryPackageSpec, opts: PickPackageOptions): Promise<{ | ||
meta: PackageMeta; | ||
pickedPackage: PackageInRegistry | null; | ||
}>; | ||
export default _default; |
@@ -6,7 +6,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pickPackage = void 0; | ||
const crypto_1 = __importDefault(require("crypto")); | ||
const fs_1 = require("fs"); | ||
const path_1 = __importDefault(require("path")); | ||
const error_1 = __importDefault(require("@pnpm/error")); | ||
const logger_1 = __importDefault(require("@pnpm/logger")); | ||
const error_1 = require("@pnpm/error"); | ||
const logger_1 = require("@pnpm/logger"); | ||
const graceful_fs_1 = __importDefault(require("@pnpm/graceful-fs")); | ||
@@ -19,3 +20,3 @@ const encode_registry_1 = __importDefault(require("encode-registry")); | ||
const rename_overwrite_1 = __importDefault(require("rename-overwrite")); | ||
const toRaw_1 = __importDefault(require("./toRaw")); | ||
const toRaw_1 = require("./toRaw"); | ||
const pickPackageFromMeta_1 = require("./pickPackageFromMeta"); | ||
@@ -33,3 +34,3 @@ /** | ||
} | ||
exports.default = async (ctx, spec, opts) => { | ||
async function pickPackage(ctx, spec, opts) { | ||
opts = opts || {}; | ||
@@ -59,3 +60,3 @@ const _pickPackageFromMeta = opts.publishedBy | ||
}; | ||
throw new error_1.default('NO_OFFLINE_META', `Failed to resolve ${(0, toRaw_1.default)(spec)} in package mirror ${pkgMirror}`); | ||
throw new error_1.PnpmError('NO_OFFLINE_META', `Failed to resolve ${(0, toRaw_1.toRaw)(spec)} in package mirror ${pkgMirror}`); | ||
} | ||
@@ -124,4 +125,4 @@ if (metaCachedInStore != null) { | ||
throw err; | ||
logger_1.default.error(err, err); | ||
logger_1.default.debug({ message: `Using cached meta from ${pkgMirror}` }); | ||
logger_1.logger.error(err, err); | ||
logger_1.logger.debug({ message: `Using cached meta from ${pkgMirror}` }); | ||
return { | ||
@@ -132,3 +133,4 @@ meta, | ||
} | ||
}; | ||
} | ||
exports.pickPackage = pickPackage; | ||
function clearMeta(pkg) { | ||
@@ -193,5 +195,5 @@ const versions = {}; | ||
if (pkgName.includes('/') && pkgName[0] !== '@') { | ||
throw new error_1.default('INVALID_PACKAGE_NAME', `Package name ${pkgName} is invalid, it should have a @scope`); | ||
throw new error_1.PnpmError('INVALID_PACKAGE_NAME', `Package name ${pkgName} is invalid, it should have a @scope`); | ||
} | ||
} | ||
//# sourceMappingURL=pickPackage.js.map |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.pickVersionByVersionRange = exports.pickLowestVersionByVersionRange = exports.pickPackageFromMeta = void 0; | ||
const error_1 = __importDefault(require("@pnpm/error")); | ||
const error_1 = require("@pnpm/error"); | ||
const semver_1 = __importDefault(require("semver")); | ||
@@ -38,3 +38,3 @@ function pickPackageFromMeta(pickVersionByVersionRangeFn, spec, preferredVersionSelectors, meta, publishedBy) { | ||
catch (err) { // eslint-disable-line | ||
throw new error_1.default('MALFORMED_METADATA', `Received malformed metadata for "${spec.name}"`, { hint: 'This might mean that the package was unpublished from the registry' }); | ||
throw new error_1.PnpmError('MALFORMED_METADATA', `Received malformed metadata for "${spec.name}"`, { hint: 'This might mean that the package was unpublished from the registry' }); | ||
} | ||
@@ -41,0 +41,0 @@ } |
import { RegistryPackageSpec } from './parsePref'; | ||
export default function toRaw(spec: RegistryPackageSpec): string; | ||
export declare function toRaw(spec: RegistryPackageSpec): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toRaw = void 0; | ||
function toRaw(spec) { | ||
return `${spec.name}@${spec.fetchSpec}`; | ||
} | ||
exports.default = toRaw; | ||
exports.toRaw = toRaw; | ||
//# sourceMappingURL=toRaw.js.map |
@@ -1,1 +0,1 @@ | ||
export default function workspacePrefToNpm(workspacePref: string): string; | ||
export declare function workspacePrefToNpm(workspacePref: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.workspacePrefToNpm = void 0; | ||
function workspacePrefToNpm(workspacePref) { | ||
@@ -17,3 +18,3 @@ const prefParts = /^workspace:([^._/][^@]*@)?(.*)$/.exec(workspacePref); | ||
} | ||
exports.default = workspacePrefToNpm; | ||
exports.workspacePrefToNpm = workspacePrefToNpm; | ||
//# sourceMappingURL=workspacePrefToNpm.js.map |
{ | ||
"name": "@pnpm/npm-resolver", | ||
"version": "13.1.11", | ||
"version": "14.0.0", | ||
"description": "Resolver for npm-hosted packages", | ||
@@ -27,10 +27,10 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"@pnpm/logger": "^4.0.0" | ||
"@pnpm/logger": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@pnpm/core-loggers": "7.1.0", | ||
"@pnpm/error": "3.1.0", | ||
"@pnpm/core-loggers": "8.0.0", | ||
"@pnpm/error": "4.0.0", | ||
"@pnpm/fetching-types": "3.0.0", | ||
"@pnpm/graceful-fs": "2.0.0", | ||
"@pnpm/resolve-workspace-range": "3.0.0", | ||
"@pnpm/resolve-workspace-range": "4.0.0", | ||
"@pnpm/resolver-base": "9.1.2", | ||
@@ -49,3 +49,3 @@ "@pnpm/types": "8.7.0", | ||
"rename-overwrite": "^4.0.2", | ||
"semver": "^7.3.7", | ||
"semver": "^7.3.8", | ||
"ssri": "^9.0.1", | ||
@@ -55,5 +55,5 @@ "version-selector-type": "^3.0.0" | ||
"devDependencies": { | ||
"@pnpm/fetch": "5.0.10", | ||
"@pnpm/npm-resolver": "13.1.11", | ||
"@pnpm/test-fixtures": "0.0.23", | ||
"@pnpm/fetch": "6.0.0", | ||
"@pnpm/npm-resolver": "14.0.0", | ||
"@pnpm/test-fixtures": "0.0.24", | ||
"@types/normalize-path": "^3.0.0", | ||
@@ -60,0 +60,0 @@ "@types/ramda": "0.28.15", |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65202
867
+ Added@pnpm/core-loggers@8.0.0(transitive)
+ Added@pnpm/error@4.0.0(transitive)
+ Added@pnpm/logger@5.2.0(transitive)
+ Added@pnpm/resolve-workspace-range@4.0.0(transitive)
+ Addedbole@5.0.17(transitive)
- Removed@pnpm/core-loggers@7.1.0(transitive)
- Removed@pnpm/error@3.1.0(transitive)
- Removed@pnpm/logger@4.0.0(transitive)
- Removed@pnpm/resolve-workspace-range@3.0.0(transitive)
- Removedbole@4.0.1(transitive)
Updated@pnpm/core-loggers@8.0.0
Updated@pnpm/error@4.0.0
Updatedsemver@^7.3.8