fix(deploy): don't modify the lockfile and fail in CI (#5074)

close #5071
This commit is contained in:
Zoltan Kochan
2022-07-21 18:15:28 +03:00
committed by GitHub
parent e3f4d131cc
commit 0569f10227
8 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---
`pnpm deploy` should not modify the lockfile [#5071](https://github.com/pnpm/pnpm/issues/5071)

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---
`pnpm deploy` should not fail in CI [#5071](https://github.com/pnpm/pnpm/issues/5071)

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": minor
"@pnpm/plugin-commands-installation": minor
---
When `saveLockfile` is set to `false`, no changes to `pnpm-lock.yaml` are written to the filesystem.

View File

@@ -25,6 +25,7 @@ export interface StrictInstallOptions {
extraBinPaths: string[]
hoistingLimits?: HoistingLimits
useLockfile: boolean
saveLockfile: boolean
useGitBranchLockfile: boolean
mergeGitBranchLockfiles: boolean
linkWorkspacePackagesDepth: number
@@ -173,6 +174,7 @@ const defaults = async (opts: InstallOptions) => {
process.getuid() !== 0,
update: false,
useLockfile: true,
saveLockfile: true,
useGitBranchLockfile: false,
mergeGitBranchLockfiles: false,
userAgent: `${packageManager.name}/${packageManager.version} npm/? node/${process.version} ${process.platform} ${process.arch}`,

View File

@@ -1030,7 +1030,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
const projectsWithTargetDirs = extendProjectsWithTargetDirs(projects, newLockfile, ctx)
await Promise.all([
opts.useLockfile
opts.useLockfile && opts.saveLockfile
? writeLockfiles({
currentLockfile: result.currentLockfile,
currentLockfileDir: ctx.virtualStoreDir,

View File

@@ -83,8 +83,14 @@ export async function handler (
},
frozenLockfile: false,
preferFrozenLockfile: false,
saveLockfile: false,
virtualStoreDir: path.join(deployDir, 'node_modules/.pnpm'),
modulesDir: path.relative(deployedDir, path.join(deployDir, 'node_modules')),
rawLocalConfig: {
...opts.rawLocalConfig,
// This is a workaround to prevent frozen install in CI envs.
'frozen-lockfile': false,
},
})
}

View File

@@ -52,6 +52,8 @@ test('deploy', async () => {
production: true,
recursive: true,
selectedProjectsGraph,
sharedWorkspaceLockfile: true,
lockfileDir: process.cwd(),
workspaceDir: process.cwd(),
}, ['deploy'])
@@ -62,4 +64,5 @@ test('deploy', async () => {
await project.hasNot('is-negative')
expect(fs.existsSync('deploy/index.js')).toBeTruthy()
expect(fs.existsSync('deploy/test.js')).toBeFalsy()
expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy() // no changes to the lockfile are written
})

View File

@@ -288,6 +288,7 @@ export type InstallCommandOptions = Pick<Config,
pruneDirectDependencies?: boolean
pruneStore?: boolean
recursive?: boolean
saveLockfile?: boolean
workspace?: boolean
} & Partial<Pick<Config, 'modulesCacheMaxAge' | 'pnpmHomeDir' | 'preferWorkspacePackages'>>