diff --git a/.changeset/calm-files-hide.md b/.changeset/calm-files-hide.md new file mode 100644 index 0000000000..8212fa15a2 --- /dev/null +++ b/.changeset/calm-files-hide.md @@ -0,0 +1,7 @@ +--- +"@pnpm/plugin-commands-installation": patch +"@pnpm/plugin-commands-deploy": patch +pnpm: patch +--- + +The `pnpm deploy` command now supports the [`catalog:` protocol](https://pnpm.io/catalogs). diff --git a/pkg-manager/plugin-commands-installation/src/install.ts b/pkg-manager/plugin-commands-installation/src/install.ts index 2b6ccd801e..b19727afea 100644 --- a/pkg-manager/plugin-commands-installation/src/install.ts +++ b/pkg-manager/plugin-commands-installation/src/install.ts @@ -252,6 +252,7 @@ export type InstallCommandOptions = Pick {}, + + misconfiguration: (result) => { + throw result.error + }, + + found: (result) => { + depsBlock[alias] = result.resolution.specifier + }, + }) + } + } + + return pkg +} diff --git a/releasing/plugin-commands-deploy/test/deploy.test.ts b/releasing/plugin-commands-deploy/test/deploy.test.ts index 37adfaa290..1a129a03de 100644 --- a/releasing/plugin-commands-deploy/test/deploy.test.ts +++ b/releasing/plugin-commands-deploy/test/deploy.test.ts @@ -213,3 +213,53 @@ test('deploy with dedupePeerDependents=true ignores the value of dedupePeerDepen project.has('is-positive') expect(fs.existsSync('sub-dir/deploy')).toBe(false) }) + +// Regression test for https://github.com/pnpm/pnpm/issues/8297 (pnpm deploy doesn't replace catalog: protocol) +test('deploy works when workspace packages use catalog protocol', async () => { + preparePackages([ + { + name: 'project-1', + dependencies: { + 'project-2': 'workspace:*', + 'is-positive': 'catalog:', + }, + }, + { + name: 'project-2', + dependencies: { + 'project-3': 'workspace:*', + 'is-positive': 'catalog:', + }, + }, + { + name: 'project-3', + dependencies: { + 'project-3': 'workspace:*', + 'is-positive': 'catalog:', + }, + }, + ]) + + const { allProjects, selectedProjectsGraph } = await filterPackagesFromDir(process.cwd(), [{ namePattern: 'project-1' }]) + + await deploy.handler({ + ...DEFAULT_OPTS, + allProjects, + catalogs: { + default: { + 'is-positive': '1.0.0', + }, + }, + dir: process.cwd(), + dev: false, + production: true, + recursive: true, + selectedProjectsGraph, + sharedWorkspaceLockfile: true, + lockfileDir: process.cwd(), + workspaceDir: process.cwd(), + }, ['deploy']) + + // 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() +}) diff --git a/releasing/plugin-commands-deploy/test/deployCatalogHook.ts b/releasing/plugin-commands-deploy/test/deployCatalogHook.ts new file mode 100644 index 0000000000..828e1e94a4 --- /dev/null +++ b/releasing/plugin-commands-deploy/test/deployCatalogHook.ts @@ -0,0 +1,37 @@ +import { deployCatalogHook } from '../src/deployCatalogHook' + +test('deployCatalogHook()', () => { + const catalogs = { + default: { + a: '^1.0.0', + }, + foo: { + b: '^2.0.0', + }, + bar: { + c: '^3.0.0', + }, + } + + expect(deployCatalogHook(catalogs, { + dependencies: { + a: 'catalog:', + }, + devDependencies: { + b: 'catalog:foo', + }, + optionalDependencies: { + c: 'catalog:bar', + }, + })).toStrictEqual({ + dependencies: { + a: '^1.0.0', + }, + devDependencies: { + b: '^2.0.0', + }, + optionalDependencies: { + c: '^3.0.0', + }, + }) +}) diff --git a/releasing/plugin-commands-deploy/tsconfig.json b/releasing/plugin-commands-deploy/tsconfig.json index 1ffdc5a2fe..3a35dd5f49 100644 --- a/releasing/plugin-commands-deploy/tsconfig.json +++ b/releasing/plugin-commands-deploy/tsconfig.json @@ -15,6 +15,12 @@ { "path": "../../__utils__/prepare" }, + { + "path": "../../catalogs/resolver" + }, + { + "path": "../../catalogs/types" + }, { "path": "../../cli/cli-utils" },