mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-26 18:09:06 -04:00
Library packages had `prepublishOnly: pn compile`, which expands to `tsgo --build && pn lint --fix`. During `pn release` that runs eslint against ~150 packages for no benefit — the code has already been linted in CI and the release flow's upfront compile has already built dist/. Switch lib prepublishOnly to a bare `tsgo --build` so the safety-net compile stays but the per-package eslint cost is gone.
@pnpm/agent.client
Client library for the pnpm agent server. Reads the local store state, sends it to the server, and writes the received files into the content-addressable store.
How it works
- Reads integrity hashes from the local store index (
index.db). - Sends
POST /v1/installto the pnpm agent server with the project's dependencies and the store integrities. - Parses the NDJSON streaming response —
D-lines (missing file digests) are dispatched to worker downloads against/v1/files,I-lines are buffered as raw store-index entries, and the finalL-line yields the resolved lockfile and stats. - File download workers write each received file directly to the local CAFS (
files/{hash[:2]}/{hash[2:]}). - Writes store index entries for all new packages in a single SQLite transaction.
- Returns the resolved lockfile for use with pnpm's headless install (linking phase).
Usage
This package is used internally by pnpm when the agent config option is set. It is not intended to be called directly, but can be used programmatically:
import { fetchFromPnpmRegistry } from '@pnpm/agent.client'
import { StoreIndex } from '@pnpm/store.index'
const storeIndex = new StoreIndex('/path/to/store')
const { lockfile, stats } = await fetchFromPnpmRegistry({
registryUrl: 'http://localhost:4000',
storeDir: '/path/to/store',
storeIndex,
dependencies: { react: '^19.0.0' },
devDependencies: { typescript: '^5.0.0' },
})
console.log(`Resolved ${stats.totalPackages} packages`)
console.log(`${stats.alreadyInStore} cached, ${stats.filesToDownload} files downloaded`)
// lockfile is ready for headless install
Configuration
Add to pnpm-workspace.yaml to enable automatically during pnpm install:
agent: http://localhost:4000