mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-07 00:35:25 -04:00
* feat: add native view/info command * test: add unit tests for native view command * fix(view): support ranges, aliases, and tags * chore: update lockfile and tsconfig * refactor(view): reuse pickPackageFromMeta from npm-resolver - Share version resolution logic with the npm-resolver instead of reimplementing tag/range/version matching in the view command. - Export pickPackageFromMeta and pickVersionByVersionRange from @pnpm/resolving.npm-resolver. - Remove redundant double HTTP fetch (metadata already contains all version data). - Remove duplicate author/repository fields from PackageInRegistry (already inherited from BaseManifest). - Consolidate four changesets into one. - Revert unrelated .gitignore change. - Drop direct semver dependency from deps.inspection.commands. * refactor(view): reuse fetchMetadataFromFromRegistry from npm-resolver Use the npm-resolver's fetchMetadataFromFromRegistry instead of hand-rolled fetch logic. This fixes: - Broken URL encoding for scoped packages (@scope/pkg) - Missing auth header, proxy, SSL, and retry config - Duplicated fetch + error handling code Also pass proper Config options (rawConfig, userAgent, SSL, proxy, retry, timeout) through to createFetchFromRegistry and createGetAuthHeaderByURI so the view command works with private registries and corporate proxies. * test(view): improve test coverage for view command Add tests for: - non-registry spec rejection (git URLs) - no matching version error - version range resolution (^1.0.0) - dist-tag resolution (latest) - nested field selection (dist.shasum) - field selection with --json - text output format (header, dist section, dist-tags) - scoped package lookup (@pnpm.e2e/pkg-with-1-dep) - deps count / deps: none in header - object field rendering as JSON * revert: undo rename of @pnpm/resolving.registry.types The rename from @pnpm/resolving.registry.types to @pnpm/registry.types (and the move from resolving/registry/types/ to registry/types/) is a separate refactoring concern unrelated to the view command. Revert all rename-related changes. Keep the legitimate type additions to PackageInRegistry: maintainers, contributors, and dist.unpackedSize. * revert: restore pnpm-workspace.yaml (remove registry/* glob) * fix(view): handle edge cases in formatBytes and unpackedSize - Use explicit null check for unpackedSize so 0 B is still rendered - Add TB/PB units and clamp index to prevent undefined output --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
@pnpm/npm-resolver
Resolver for npm-hosted packages
Installation
pnpm add @pnpm/npm-resolver
Usage
'use strict'
const createResolveFromNpm = require('@pnpm/npm-resolver').default
const resolveFromNpm = createResolveFromNpm({
store: '.store',
offline: false,
rawConfig: {
registry: 'https://registry.npmjs.org/',
},
})
resolveFromNpm({alias: 'is-positive', bareSpecifier: '1.0.0'}, {
registry: 'https://registry.npmjs.org/',
})
.then(resolveResult => console.log(JSON.stringify(resolveResult, null, 2)))
//> {
// "id": "registry.npmjs.org/is-positive/1.0.0",
// "latest": "3.1.0",
// "package": {
// "name": "is-positive",
// "version": "1.0.0",
// "devDependencies": {
// "ava": "^0.0.4"
// },
// "_hasShrinkwrap": false,
// "directories": {},
// "dist": {
// "shasum": "88009856b64a2f1eb7d8bb0179418424ae0452cb",
// "tarball": "https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz"
// },
// "engines": {
// "node": ">=0.10.0"
// }
// },
// "resolution": {
// "integrity": "sha1-iACYVrZKLx632LsBeUGEJK4EUss=",
// "registry": "https://registry.npmjs.org/",
// "tarball": "https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz"
// },
// "resolvedVia": "npm-registry"
// }
License
MIT