diff --git a/.changeset/moody-bobcats-yell.md b/.changeset/moody-bobcats-yell.md new file mode 100644 index 00000000000..c205f71e1b4 --- /dev/null +++ b/.changeset/moody-bobcats-yell.md @@ -0,0 +1,8 @@ +--- +"@pnpm/plugin-commands-installation": patch +"@pnpm/plugin-commands-deploy": patch +"@pnpm/types": patch +"pnpm": patch +--- + +Ensure that the deploy target is generated in the same directory [#6858](https://github.com/pnpm/pnpm/issues/6858) diff --git a/packages/types/src/project.ts b/packages/types/src/project.ts index a10e172a80f..8e72604d7ec 100644 --- a/packages/types/src/project.ts +++ b/packages/types/src/project.ts @@ -4,6 +4,7 @@ export interface Project { dir: string manifest: ProjectManifest writeProjectManifest: (manifest: ProjectManifest, force?: boolean | undefined) => Promise + modulesDir?: string } export type ProjectsGraph = Record diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index d9f51f4923e..e9d0e871872 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -250,6 +250,7 @@ export type InstallCommandOptions = Pick { + allProjectsGraph[prefix].package.modulesDir = path.relative(allProjectsGraph[prefix].package.dir, absoluteModulesDir) + }) + } +} diff --git a/releasing/plugin-commands-deploy/test/deploy.test.ts b/releasing/plugin-commands-deploy/test/deploy.test.ts index 61bb6b5f5d9..0da0e3b700b 100644 --- a/releasing/plugin-commands-deploy/test/deploy.test.ts +++ b/releasing/plugin-commands-deploy/test/deploy.test.ts @@ -74,3 +74,54 @@ test('deploy', async () => { expect(fs.existsSync('deploy/node_modules/.pnpm/file+project-3/node_modules/project-3/test.js')).toBeFalsy() expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy() // no changes to the lockfile are written }) + +test('deploy with dedupePeerDependents true', async () => { + preparePackages([ + { + name: 'project-1', + version: '1.0.0', + dependencies: { + 'is-positive': '1.0.0', + }, + }, + { + location: './sub-dir/project-2', + package: { + name: 'project-2', + version: '2.0.0', + dependencies: { + 'is-odd': '1.0.0', + }, + }, + }, + { + name: 'project-3', + version: '2.0.0', + dependencies: { + 'is-number': '1.0.0', + }, + }, + ]) + + const { allProjects, selectedProjectsGraph, allProjectsGraph } = await readProjects(process.cwd(), [{ namePattern: 'project-1' }]) + + await deploy.handler({ + ...DEFAULT_OPTS, + allProjects, + allProjectsGraph, + dir: process.cwd(), + dev: false, + production: true, + recursive: true, + selectedProjectsGraph, + sharedWorkspaceLockfile: true, + lockfileDir: process.cwd(), + workspaceDir: process.cwd(), + dedupePeerDependents: true, + }, ['deploy']) + const project = assertProject(path.resolve('deploy')) + await project.has('is-positive') + await project.has('is-odd') + await project.has('is-number') + expect(fs.existsSync('sub-dir/deploy')).toBe(false) +})