Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/clever-guests-heal.md
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions .changeset/clever-guests-heal2.md
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions .changeset/wise-guests-turn.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions packages/core/src/install/extendInstallOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface StrictInstallOptions {
extraBinPaths: string[]
hoistingLimits?: HoistingLimits
useLockfile: boolean
saveLockfile: boolean
useGitBranchLockfile: boolean
mergeGitBranchLockfiles: boolean
linkWorkspacePackagesDepth: number
Expand Down Expand Up @@ -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}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,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,
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-commands-deploy/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
}

Expand Down
3 changes: 3 additions & 0 deletions packages/plugin-commands-deploy/test/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ test('deploy', async () => {
production: true,
recursive: true,
selectedProjectsGraph,
sharedWorkspaceLockfile: true,
lockfileDir: process.cwd(),
workspaceDir: process.cwd(),
}, ['deploy'])

Expand All @@ -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
})
1 change: 1 addition & 0 deletions packages/plugin-commands-installation/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'>>

Expand Down