diff --git a/.changeset/heavy-dolls-itch.md b/.changeset/heavy-dolls-itch.md new file mode 100644 index 0000000000..4ab913f722 --- /dev/null +++ b/.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). diff --git a/.changeset/neat-zoos-glow.md b/.changeset/neat-zoos-glow.md new file mode 100644 index 0000000000..91223cdc9e --- /dev/null +++ b/.changeset/neat-zoos-glow.md @@ -0,0 +1,6 @@ +--- +"@pnpm/get-context": minor +"@pnpm/core": minor +--- + +New option added: confirmModulesPurge. diff --git a/pkg-manager/core/src/install/extendInstallOptions.ts b/pkg-manager/core/src/install/extendInstallOptions.ts index 7948b6233c..26d960da83 100644 --- a/pkg-manager/core/src/install/extendInstallOptions.ts +++ b/pkg-manager/core/src/install/extendInstallOptions.ts @@ -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, diff --git a/pkg-manager/core/test/breakingChanges.ts b/pkg-manager/core/test/breakingChanges.ts index 620b9adb1f..7758ab7a45 100644 --- a/pkg-manager/core/test/breakingChanges.ts +++ b/pkg-manager/core/test/breakingChanges.ts @@ -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, }) }) diff --git a/pkg-manager/core/test/install/only.ts b/pkg-manager/core/test/install/only.ts index 73c19ff24b..9077db15e5 100644 --- a/pkg-manager/core/test/install/only.ts +++ b/pkg-manager/core/test/install/only.ts @@ -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, diff --git a/pkg-manager/core/test/lockfile.ts b/pkg-manager/core/test/lockfile.ts index 89a75f27b4..ccff3bfcfd 100644 --- a/pkg-manager/core/test/lockfile.ts +++ b/pkg-manager/core/test/lockfile.ts @@ -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) diff --git a/pkg-manager/get-context/src/index.ts b/pkg-manager/get-context/src/index.ts index cc0822ddb4..dcc737cfae 100644 --- a/pkg-manager/get-context/src/index.ts +++ b/pkg-manager/get-context/src/index.ts @@ -72,6 +72,7 @@ interface HookOptions { export interface GetContextOptions { allProjects: Array + 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, diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index 04c9d1b051..d9f51f4923 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -305,6 +305,7 @@ export type InstallCommandOptions = Pick> export async function handler ( diff --git a/releasing/plugin-commands-deploy/src/deploy.ts b/releasing/plugin-commands-deploy/src/deploy.ts index 1e0755a3eb..d813be2962 100644 --- a/releasing/plugin-commands-deploy/src/deploy.ts +++ b/releasing/plugin-commands-deploy/src/deploy.ts @@ -78,6 +78,7 @@ export async function handler ( await copyProject(deployedDir, deployDir, { includeOnlyPackageFiles }) await install.handler({ ...opts, + confirmModulesPurge: false, depth: Infinity, hooks: { ...opts.hooks,