Skip to content

Commit

Permalink
test: add test for pnpm deploy when using catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
gluxon committed Jul 12, 2024
1 parent 57e875e commit b93a1f2
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
50 changes: 50 additions & 0 deletions releasing/plugin-commands-deploy/test/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

// Regresion 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-postive cataloged dependency was actually installed.
expect(fs.existsSync('deploy/node_modules/.pnpm/project-3@file+project-3/node_modules/is-positive')).toBeTruthy()
})
33 changes: 33 additions & 0 deletions releasing/plugin-commands-deploy/test/deployCatalogHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { deployCatalogHook } from '../src/deployCatalogHook'

test('deployCatalogHook()', () => {
const catalogs = {
default: {
a: '^1.0.0',
b: '^2.0.0',
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',
},
})
})

0 comments on commit b93a1f2

Please sign in to comment.