Skip to content

feat: expose a typed package manager resolution API - #923

Closed
Aschenbath wants to merge 1 commit into
nodejs:mainfrom
Aschenbath:feat/public-api-326
Closed

Aschenbath wants to merge 1 commit into
nodejs:mainfrom
Aschenbath:feat/public-api-326

Conversation

@Aschenbath

Copy link
Copy Markdown

Expose corepack/api so callers can validate package-manager specifications and resolve versions without spawning the CLI. The entry point provides getSupportedPackageManagers, parsePackageManagerSpec, and resolvePackageManager, with self-contained TypeScript declarations and documented behavior for tags, ranges, cached releases, custom URLs, environment variables, and errors.

Resolution reuses Corepack's existing engine and does not install or run package managers or update Last Known Good versions. Exact versions are returned without verifying release existence. A separate CommonJS bundle supports both require and ES module named imports.

Validation:

  • New API regression tests cover input validation, hashes, tags, ranges, cache preference/bypass, disabled network access, custom registries/URLs, error propagation, and absence of cache writes.
  • Published-entry tests exercise CommonJS, ES module imports, and TypeScript consumers in both module modes.
  • TypeScript, repository-wide ESLint, build/bundle generation, and git diff --check pass.
  • Actual npm pack --ignore-scripts tarball verified: API bundle and declarations included, no task artifacts; extracted package passes CommonJS, ES module, and TypeScript smoke checks.
  • Full Vitest suite (NOCK_ENV=replay vitest run --maxWorkers=2 --retry=0): 10 test files passed, 193 tests passed, and 1 existing expected failure. A local preload isolates fixture proxy settings while preserving the live npm signing-key check; V8 caches are disabled.

Closes #326.

Provide corepack/api with supported package manager listing, specification parsing, and version resolution without spawning the CLI or installing releases. Document the public contract and ship CommonJS/ESM-compatible exports with self-contained TypeScript declarations.

Closes nodejs#326.
@aduh95

aduh95 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This account has opened more than 10 PRs in the last 24 hours. This looks like bot activity, and will result in a ban if the behavior continues.

@aduh95 aduh95 closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expose/isolate allowed package manager descriptors

2 participants