@@ -1675,6 +1675,88 @@ describe('ensureVitePlusBootstrap', () => {
16751675 expect ( pkg . devDependencies . vitest ) . toBe ( VITEST_VERSION ) ;
16761676 } ) ;
16771677
1678+ it ( 'prefers existing catalogs for Vitest ecosystem packages and pins unsupported ones' , ( ) => {
1679+ const appDir = path . join ( tmpDir , 'packages/app' ) ;
1680+ fs . mkdirSync ( appDir , { recursive : true } ) ;
1681+ fs . writeFileSync (
1682+ path . join ( tmpDir , 'package.json' ) ,
1683+ JSON . stringify ( {
1684+ name : 'root' ,
1685+ private : true ,
1686+ devDependencies : { 'vite-plus' : 'catalog:' } ,
1687+ devEngines : {
1688+ packageManager : { name : 'pnpm' , version : '10.33.0' , onFail : 'download' } ,
1689+ } ,
1690+ } ) ,
1691+ ) ;
1692+ fs . writeFileSync (
1693+ path . join ( appDir , 'package.json' ) ,
1694+ JSON . stringify ( {
1695+ name : 'app' ,
1696+ devDependencies : {
1697+ // Reproduce the output from the prior migration: the package was
1698+ // hard-pinned even though the default catalog already owned it.
1699+ '@vitest/coverage-istanbul' : VITEST_VERSION ,
1700+ '@vitest/ui' : 'catalog:test' ,
1701+ '@vitest/web-worker' : '^4.1.0' ,
1702+ } ,
1703+ } ) ,
1704+ ) ;
1705+ fs . writeFileSync (
1706+ path . join ( tmpDir , 'pnpm-workspace.yaml' ) ,
1707+ [
1708+ 'packages:' ,
1709+ ' - packages/*' ,
1710+ 'catalog:' ,
1711+ ' vite-plus: latest' ,
1712+ ' vite: npm:@voidzero-dev/vite-plus-core@latest' ,
1713+ ` vitest: ${ VITEST_VERSION } ` ,
1714+ " '@vitest/coverage-istanbul': 4.1.4" ,
1715+ 'catalogs:' ,
1716+ ' test:' ,
1717+ " '@vitest/ui': 4.1.4" ,
1718+ 'blockExoticSubdeps: false' ,
1719+ 'overrides:' ,
1720+ " vite: 'catalog:'" ,
1721+ " vitest: 'catalog:'" ,
1722+ 'peerDependencyRules:' ,
1723+ ' allowAny: [vite, vitest]' ,
1724+ ' allowedVersions:' ,
1725+ " vite: '*'" ,
1726+ " vitest: '*'" ,
1727+ '' ,
1728+ ] . join ( '\n' ) ,
1729+ ) ;
1730+ const workspaceInfo = {
1731+ ...makeWorkspaceInfo ( tmpDir , PackageManager . pnpm ) ,
1732+ isMonorepo : true ,
1733+ workspacePatterns : [ 'packages/*' ] ,
1734+ packages : [ { name : 'app' , path : 'packages/app' } ] ,
1735+ } ;
1736+
1737+ expect (
1738+ detectVitePlusBootstrapPending ( tmpDir , PackageManager . pnpm , workspaceInfo . packages ) ,
1739+ ) . toBe ( true ) ;
1740+ ensureVitePlusBootstrap ( workspaceInfo ) ;
1741+
1742+ const pkg = readJson ( path . join ( appDir , 'package.json' ) ) as {
1743+ devDependencies : Record < string , string > ;
1744+ } ;
1745+ expect ( pkg . devDependencies [ '@vitest/coverage-istanbul' ] ) . toBe ( 'catalog:' ) ;
1746+ expect ( pkg . devDependencies [ '@vitest/ui' ] ) . toBe ( 'catalog:test' ) ;
1747+ expect ( pkg . devDependencies [ '@vitest/web-worker' ] ) . toBe ( VITEST_VERSION ) ;
1748+
1749+ const workspace = readYamlObject ( path . join ( tmpDir , 'pnpm-workspace.yaml' ) ) as {
1750+ catalog : Record < string , string > ;
1751+ catalogs : Record < string , Record < string , string > > ;
1752+ } ;
1753+ expect ( workspace . catalog [ '@vitest/coverage-istanbul' ] ) . toBe ( VITEST_VERSION ) ;
1754+ expect ( workspace . catalogs . test [ '@vitest/ui' ] ) . toBe ( VITEST_VERSION ) ;
1755+ expect (
1756+ detectVitePlusBootstrapPending ( tmpDir , PackageManager . pnpm , workspaceInfo . packages ) ,
1757+ ) . toBe ( false ) ;
1758+ } ) ;
1759+
16781760 it ( 'does not align deprecated @vitest/coverage-c8 to a nonexistent Vitest 4 version' , ( ) => {
16791761 fs . writeFileSync (
16801762 path . join ( tmpDir , 'package.json' ) ,
0 commit comments