mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 15:48:06 -05:00
fix: deploy with shared-workspace-lockfile=false (#8515)
close #8475 close #8504
This commit is contained in:
7
.changeset/twenty-news-fetch.md
Normal file
7
.changeset/twenty-news-fetch.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
"@pnpm/plugin-commands-deploy": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm deploy` should work in workspace with `shared-workspace-lockfile=false` [#8475](https://github.com/pnpm/pnpm/issues/8475).
|
||||
@@ -342,6 +342,7 @@ export async function recursive (
|
||||
...installOpts,
|
||||
...localConfig,
|
||||
...getOptionsFromRootManifest(rootDir, manifest),
|
||||
...opts.allProjectsGraph[rootDir]?.package,
|
||||
bin: path.join(rootDir, 'node_modules', '.bin'),
|
||||
dir: rootDir,
|
||||
hooks,
|
||||
|
||||
@@ -77,6 +77,75 @@ test('deploy', async () => {
|
||||
expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy() // no changes to the lockfile are written
|
||||
})
|
||||
|
||||
test('deploy in workspace with shared-workspace-lockfile=false', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
files: ['index.js'],
|
||||
dependencies: {
|
||||
'project-2': 'workspace:*',
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
devDependencies: {
|
||||
'project-3': 'workspace:*',
|
||||
'is-negative': '1.0.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
version: '2.0.0',
|
||||
files: ['index.js'],
|
||||
dependencies: {
|
||||
'project-3': 'workspace:*',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'project-3',
|
||||
version: '2.0.0',
|
||||
files: ['index.js'],
|
||||
dependencies: {
|
||||
'project-3': 'workspace:*',
|
||||
'is-odd': '1.0.0',
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
; ['project-1', 'project-2', 'project-3'].forEach(name => {
|
||||
fs.writeFileSync(`${name}/test.js`, '', 'utf8')
|
||||
fs.writeFileSync(`${name}/index.js`, '', 'utf8')
|
||||
})
|
||||
|
||||
const { allProjects, selectedProjectsGraph } = await filterPackagesFromDir(process.cwd(), [{ namePattern: 'project-1' }])
|
||||
|
||||
await deploy.handler({
|
||||
...DEFAULT_OPTS,
|
||||
allProjects,
|
||||
dir: process.cwd(),
|
||||
dev: false,
|
||||
production: true,
|
||||
recursive: true,
|
||||
selectedProjectsGraph,
|
||||
sharedWorkspaceLockfile: false,
|
||||
workspaceDir: process.cwd(),
|
||||
}, ['deploy'])
|
||||
|
||||
const project = assertProject(path.resolve('deploy'))
|
||||
project.has('project-2')
|
||||
project.has('is-positive')
|
||||
project.hasNot('project-3')
|
||||
project.hasNot('is-negative')
|
||||
expect(fs.existsSync('deploy/index.js')).toBeTruthy()
|
||||
expect(fs.existsSync('deploy/test.js')).toBeFalsy()
|
||||
expect(fs.existsSync('deploy/node_modules/.modules.yaml')).toBeTruthy()
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/project-2@file+..+project-2/node_modules/project-2/index.js')).toBeTruthy()
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/project-2@file+..+project-2/node_modules/project-2/test.js')).toBeFalsy()
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/project-3@file+..+project-3/node_modules/project-3/index.js')).toBeTruthy()
|
||||
expect(fs.existsSync('deploy/node_modules/.pnpm/project-3@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 fails when the destination directory exists and is not empty', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user