From 08feef90a5fd4f3d787cc98d8fef394bb13ec2ad Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 14 Apr 2026 21:47:29 +0200 Subject: [PATCH] refactor: always send projects array to agent, remove legacy single-project fields --- agent/client/src/fetchFromPnpmRegistry.ts | 12 +++++++----- agent/server/src/createRegistryServer.ts | 13 +++++++++++-- installing/deps-installer/src/install/index.ts | 15 ++++++++++----- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/agent/client/src/fetchFromPnpmRegistry.ts b/agent/client/src/fetchFromPnpmRegistry.ts index 0be210ab9a..7d915d1e5b 100644 --- a/agent/client/src/fetchFromPnpmRegistry.ts +++ b/agent/client/src/fetchFromPnpmRegistry.ts @@ -63,12 +63,14 @@ export async function fetchFromPnpmRegistry ( ): Promise { const storeIntegrities = readStoreIntegrities(opts.storeIndex) + const projects = opts.projects ?? [{ + dir: '.', + dependencies: opts.dependencies, + devDependencies: opts.devDependencies, + }] + const requestBody = JSON.stringify({ - projects: opts.projects ?? [{ - dir: '.', - dependencies: opts.dependencies, - devDependencies: opts.devDependencies, - }], + projects, overrides: opts.overrides, nodeVersion: opts.nodeVersion ?? process.version.slice(1), os: process.platform, diff --git a/agent/server/src/createRegistryServer.ts b/agent/server/src/createRegistryServer.ts index 83d3f67038..b88ab48277 100644 --- a/agent/server/src/createRegistryServer.ts +++ b/agent/server/src/createRegistryServer.ts @@ -133,7 +133,11 @@ interface InstallRequestProject { } interface InstallRequest { - projects: InstallRequestProject[] + /** Single project (legacy) */ + dependencies?: Record + devDependencies?: Record + /** Multiple projects (workspace) */ + projects?: InstallRequestProject[] overrides?: Record peerDependencyRules?: Record nodeVersion?: string @@ -193,7 +197,12 @@ async function handleInstall ( const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pnpm-agent-')) try { - const { projects } = request + // Build project list — support both single-project and workspace + const projects = request.projects ?? [{ + dir: '.', + dependencies: request.dependencies, + devDependencies: request.devDependencies, + }] // Create package.json for each project await Promise.all(projects.map(async (project) => { diff --git a/installing/deps-installer/src/install/index.ts b/installing/deps-installer/src/install/index.ts index cada35c045..c27aef498b 100644 --- a/installing/deps-installer/src/install/index.ts +++ b/installing/deps-installer/src/install/index.ts @@ -1883,16 +1883,21 @@ async function installFromPnpmRegistry ( // Open the store index to read integrities and write new entries const storeIndex = new StoreIndex(opts.storeDir) - const projectsList = (allInstallProjects ?? [{ rootDir, manifest }]).map(p => ({ - dir: path.relative(lockfileDir, p.rootDir) || '.', - dependencies: p.manifest.dependencies, - devDependencies: p.manifest.devDependencies, - })) + // Build projects list for workspace support + const projectsList = allInstallProjects && allInstallProjects.length > 1 + ? allInstallProjects.map(p => ({ + dir: path.relative(lockfileDir, p.rootDir) || '.', + dependencies: p.manifest.dependencies, + devDependencies: p.manifest.devDependencies, + })) + : undefined const { lockfile, stats, fileDownloads, indexEntries } = await fetchFromPnpmRegistry({ registryUrl: opts.agent!, storeDir: opts.storeDir, storeIndex, + dependencies: projectsList ? undefined : manifest.dependencies, + devDependencies: projectsList ? undefined : manifest.devDependencies, projects: projectsList, overrides: opts.overrides, minimumReleaseAge: opts.minimumReleaseAge,