diff --git a/.changeset/pink-parks-begin.md b/.changeset/pink-parks-begin.md new file mode 100644 index 0000000000..3548017678 --- /dev/null +++ b/.changeset/pink-parks-begin.md @@ -0,0 +1,6 @@ +--- +"@pnpm/plugin-commands-deploy": patch +"pnpm": patch +--- + +Remove the `injectWorkspacePackages` setting from the lockfile on the `deploy` command [#10294](https://github.com/pnpm/pnpm/pull/10294). diff --git a/releasing/plugin-commands-deploy/src/createDeployFiles.ts b/releasing/plugin-commands-deploy/src/createDeployFiles.ts index d340269330..135e91ce95 100644 --- a/releasing/plugin-commands-deploy/src/createDeployFiles.ts +++ b/releasing/plugin-commands-deploy/src/createDeployFiles.ts @@ -123,6 +123,10 @@ export function createDeployFiles ({ overrides: undefined, // the effects of the overrides should already be part of the package snapshots packageExtensionsChecksum: undefined, // the effects of the package extensions should already be part of the package snapshots pnpmfileChecksum: undefined, // the effects of the pnpmfile should already be part of the package snapshots + settings: { + ...lockfile.settings, + injectWorkspacePackages: undefined, // the effects of injecting workspace packages should already be part of the lockfile + }, importers: { ['.' as ProjectId]: targetSnapshot, }, diff --git a/releasing/plugin-commands-deploy/src/deploy.ts b/releasing/plugin-commands-deploy/src/deploy.ts index 3e1b31da30..eb754cc0c6 100644 --- a/releasing/plugin-commands-deploy/src/deploy.ts +++ b/releasing/plugin-commands-deploy/src/deploy.ts @@ -265,6 +265,7 @@ async function deployFromSharedLockfile ( modulesDir: undefined, confirmModulesPurge: false, frozenLockfile: true, + injectWorkspacePackages: undefined, // the effects of injecting workspace packages should already be part of the package snapshots overrides: undefined, // the effects of the overrides should already be part of the package snapshots hooks: { ...opts.hooks, diff --git a/releasing/plugin-commands-deploy/test/deploy.test.ts b/releasing/plugin-commands-deploy/test/deploy.test.ts index 63cf70701a..5e1f0b81d3 100644 --- a/releasing/plugin-commands-deploy/test/deploy.test.ts +++ b/releasing/plugin-commands-deploy/test/deploy.test.ts @@ -5,6 +5,7 @@ import { preparePackages } from '@pnpm/prepare' import { filterPackagesFromDir } from '@pnpm/workspace.filter-packages-from-dir' import { jest } from '@jest/globals' import { DEFAULT_OPTS } from './utils/index.js' +import { install } from '@pnpm/plugin-commands-installation' const original = await import('@pnpm/logger') const warn = jest.fn() @@ -498,3 +499,51 @@ test('deploy works when workspace packages use catalog protocol', async () => { // Make sure the is-positive cataloged dependency was actually installed. expect(fs.existsSync('deploy/node_modules/.pnpm/project-3@file+project-3/node_modules/is-positive')).toBeTruthy() }) + +test('deploy does not preserve the inject workspace packages settings in the lockfile', async () => { + preparePackages([ + { + location: '.', + package: { + name: 'root', + version: '1.0.0', + private: true, + }, + }, + { + name: 'project', + version: '1.0.0', + }, + ]) + + const { allProjects, selectedProjectsGraph } = await filterPackagesFromDir(process.cwd(), [{ namePattern: 'project' }]) + + await install.handler({ + ...DEFAULT_OPTS, + allProjects, + dir: process.cwd(), + dev: true, + production: true, + lockfileOnly: true, + sharedWorkspaceLockfile: true, + lockfileDir: process.cwd(), + workspaceDir: process.cwd(), + }) + + await deploy.handler({ + ...DEFAULT_OPTS, + allProjects, + dir: process.cwd(), + dev: false, + production: true, + recursive: true, + selectedProjectsGraph, + sharedWorkspaceLockfile: true, + lockfileDir: process.cwd(), + workspaceDir: process.cwd(), + }, ['dist']) + + const project = assertProject(path.resolve('dist')) + const lockfile = project.readLockfile() + expect(lockfile.settings).not.toHaveProperty('injectWorkspacePackages') +})