fix(deploy): ensure that the deploy target is generated in the same directory (#6859)

close #6858

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
await-ovo
2023-07-29 23:44:55 +08:00
committed by GitHub
parent 692197df3e
commit 78d43a8627
4 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/plugin-commands-installation": patch
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---
Always set `dedupe-peer-dependents` to `false`, when running installation during deploy [#6858](https://github.com/pnpm/pnpm/issues/6858).

View File

@@ -250,6 +250,7 @@ export type InstallCommandOptions = Pick<Config,
| 'bail'
| 'bin'
| 'cliOptions'
| 'dedupePeerDependents'
| 'deployAllFiles'
| 'depth'
| 'dev'

View File

@@ -79,6 +79,11 @@ export async function handler (
await install.handler({
...opts,
confirmModulesPurge: false,
// Deploy doesn't work with dedupePeerDependents=true currently as for deploy
// we need to select a single project for install, while dedupePeerDependents
// doesn't work with filters right now.
// Related issue: https://github.com/pnpm/pnpm/issues/6858
dedupePeerDependents: false,
depth: Infinity,
hooks: {
...opts.hooks,

View File

@@ -74,3 +74,52 @@ 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 ignores the value of dedupePeerDependents', 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, // This is ignored by deploy
}, ['deploy'])
const project = assertProject(path.resolve('deploy'))
await project.has('is-positive')
expect(fs.existsSync('sub-dir/deploy')).toBe(false)
})