Skip to content

Commit

Permalink
fix(deploy): always purge modules directory (#6511)
Browse files Browse the repository at this point in the history
close #6510
  • Loading branch information
zkochan committed May 7, 2023
1 parent 9d4d967 commit 1ffedcb
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/heavy-dolls-itch.md
@@ -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).
6 changes: 6 additions & 0 deletions .changeset/neat-zoos-glow.md
@@ -0,0 +1,6 @@
---
"@pnpm/get-context": minor
"@pnpm/core": minor
---

New option added: confirmModulesPurge.
2 changes: 2 additions & 0 deletions pkg-manager/core/src/install/extendInstallOptions.ts
Expand Up @@ -123,6 +123,7 @@ export interface StrictInstallOptions {
dedupePeerDependents: boolean
extendNodePath: boolean
excludeLinksFromLockfile: boolean
confirmModulesPurge: boolean
}

export type InstallOptions =
Expand All @@ -139,6 +140,7 @@ const defaults = async (opts: InstallOptions) => {
allowNonAppliedPatches: false,
autoInstallPeers: true,
childConcurrency: 5,
confirmModulesPurge: !opts.force,
depth: 0,
enablePnp: false,
engineStrict: false,
Expand Down
4 changes: 2 additions & 2 deletions pkg-manager/core/test/breakingChanges.ts
Expand Up @@ -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,
})
})

Expand Down Expand Up @@ -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,
})
})

Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/core/test/install/only.ts
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/core/test/lockfile.ts
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions pkg-manager/get-context/src/index.ts
Expand Up @@ -72,6 +72,7 @@ interface HookOptions {

export interface GetContextOptions {
allProjects: Array<ProjectOptions & HookOptions>
confirmModulesPurge?: boolean
force: boolean
forceNewModules?: boolean
forceSharedLockfile: boolean
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -408,6 +409,7 @@ export async function getContextForSingleImporter (
force: boolean
forceNewModules?: boolean
forceSharedLockfile: boolean
confirmModulesPurge?: boolean
extraBinPaths: string[]
extendNodePath?: boolean
lockfileDir: string
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pkg-manager/plugin-commands-installation/src/install.ts
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions releasing/plugin-commands-deploy/src/deploy.ts
Expand Up @@ -78,6 +78,7 @@ export async function handler (
await copyProject(deployedDir, deployDir, { includeOnlyPackageFiles })
await install.handler({
...opts,
confirmModulesPurge: false,
depth: Infinity,
hooks: {
...opts.hooks,
Expand Down

0 comments on commit 1ffedcb

Please sign in to comment.