fix(deploy): always purge modules directory (#6511)

close #6510
This commit is contained in:
Zoltan Kochan
2023-05-07 12:51:56 +03:00
committed by GitHub
parent 9d4d967df8
commit 1ffedcb8d7
9 changed files with 24 additions and 6 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-deploy": patch
"pnpm": patch
---
The deploy command should not ask for confirmation to purge the `node_modules` directory [#6510](https://github.com/pnpm/pnpm/issues/6510).

View File

@@ -0,0 +1,6 @@
---
"@pnpm/get-context": minor
"@pnpm/core": minor
---
New option added: confirmModulesPurge.

View File

@@ -123,6 +123,7 @@ export interface StrictInstallOptions {
dedupePeerDependents: boolean
extendNodePath: boolean
excludeLinksFromLockfile: boolean
confirmModulesPurge: boolean
}
export type InstallOptions =
@@ -139,6 +140,7 @@ const defaults = async (opts: InstallOptions) => {
allowNonAppliedPatches: false,
autoInstallPeers: true,
childConcurrency: 5,
confirmModulesPurge: !opts.force,
depth: 0,
enablePnp: false,
engineStrict: false,

View File

@@ -67,7 +67,7 @@ test('do not fail on non-compatible node_modules when forced with a named instal
await install({}, {
...opts,
force: true, // Don't ask for prompt
confirmModulesPurge: false,
})
})
@@ -96,7 +96,7 @@ test('do not fail on non-compatible store when forced during named installation'
await install({}, {
...opts,
force: true, // Don't ask for prompt
confirmModulesPurge: false,
})
})

View File

@@ -137,7 +137,7 @@ test('fail if installing different types of dependencies in a project that uses
await project.hasNot('once')
const newOpts = await testDefaults({
force: true, // Don't ask for prompt
confirmModulesPurge: false,
include: {
dependencies: true,
devDependencies: true,

View File

@@ -1063,7 +1063,7 @@ test('lockfile is not getting broken if the used registry changes', async () =>
rootDir: process.cwd(),
}, {
...newOpts,
force: true, // Don't ask for prompt
confirmModulesPurge: false,
})
await addDependenciesToPackage(manifest, ['is-negative@1'], newOpts)

View File

@@ -72,6 +72,7 @@ interface HookOptions {
export interface GetContextOptions {
allProjects: Array<ProjectOptions & HookOptions>
confirmModulesPurge?: boolean
force: boolean
forceNewModules?: boolean
forceSharedLockfile: boolean
@@ -116,7 +117,7 @@ export async function getContext (
registries: opts.registries,
storeDir: opts.storeDir,
virtualStoreDir,
confirmModulesPurge: !opts.force && !isCI,
confirmModulesPurge: opts.confirmModulesPurge && !isCI,
forceHoistPattern: opts.forceHoistPattern,
hoistPattern: opts.hoistPattern,
@@ -408,6 +409,7 @@ export async function getContextForSingleImporter (
force: boolean
forceNewModules?: boolean
forceSharedLockfile: boolean
confirmModulesPurge?: boolean
extraBinPaths: string[]
extendNodePath?: boolean
lockfileDir: string
@@ -472,7 +474,7 @@ export async function getContextForSingleImporter (
registries: opts.registries,
storeDir: opts.storeDir,
virtualStoreDir,
confirmModulesPurge: !opts.force && !isCI,
confirmModulesPurge: opts.confirmModulesPurge && !isCI,
forceHoistPattern: opts.forceHoistPattern,
hoistPattern: opts.hoistPattern,

View File

@@ -305,6 +305,7 @@ export type InstallCommandOptions = Pick<Config,
saveLockfile?: boolean
workspace?: boolean
includeOnlyPackageFiles?: boolean
confirmModulesPurge?: boolean
} & Partial<Pick<Config, 'modulesCacheMaxAge' | 'pnpmHomeDir' | 'preferWorkspacePackages'>>
export async function handler (

View File

@@ -78,6 +78,7 @@ export async function handler (
await copyProject(deployedDir, deployDir, { includeOnlyPackageFiles })
await install.handler({
...opts,
confirmModulesPurge: false,
depth: Infinity,
hooks: {
...opts.hooks,