@@ -13,6 +13,7 @@ import {
1313import { REGISTRY_ADDRESS , startRegistry } from './registry.ts'
1414import { detect , AGENTS , getCommand , serializeCommand } from '@antfu/ni'
1515import actionsCore from '@actions/core'
16+ import YAML from 'yaml'
1617
1718const isGitHubActions = ! ! process . env . GITHUB_ACTIONS
1819
@@ -601,15 +602,46 @@ export async function applyPackageOverrides(
601602 // ...pkg.devDependencies,
602603 // ...overrides, // overrides must be present in devDependencies or dependencies otherwise they may not work
603604 // }
604- pkg . pnpm ||= { }
605- pkg . pnpm . overrides = {
606- ...pkg . pnpm . overrides ,
607- ...overrides ,
608- }
609- pkg . pnpm . peerDependencyRules ||= { }
610- pkg . pnpm . peerDependencyRules . allowedVersions = {
611- ...pkg . pnpm . peerDependencyRules . allowedVersions ,
612- ...overrides ,
605+ const workspacePath = path . join ( dir , 'pnpm-workspace.yaml' )
606+ if ( fs . existsSync ( workspacePath ) ) {
607+ const data = YAML . parse ( fs . readFileSync ( workspacePath , 'utf-8' ) )
608+ if ( data . overrides ) {
609+ data . overrides = {
610+ ...data . overrides ,
611+ ...overrides ,
612+ }
613+ } else {
614+ pkg . pnpm ||= { }
615+ pkg . pnpm . overrides = {
616+ ...pkg . pnpm . overrides ,
617+ ...overrides ,
618+ }
619+ }
620+ if ( data . peerDependencyRules ?. allowedVersions ) {
621+ data . peerDependencyRules . allowedVersions = {
622+ ...data . peerDependencyRules . allowedVersions ,
623+ ...overrides ,
624+ }
625+ } else {
626+ pkg . pnpm ||= { }
627+ pkg . pnpm . peerDependencyRules ||= { }
628+ pkg . pnpm . peerDependencyRules . allowedVersions = {
629+ ...pkg . pnpm . peerDependencyRules . allowedVersions ,
630+ ...overrides ,
631+ }
632+ }
633+ fs . writeFileSync ( workspacePath , YAML . stringify ( data ) )
634+ } else {
635+ pkg . pnpm ||= { }
636+ pkg . pnpm . overrides = {
637+ ...pkg . pnpm . overrides ,
638+ ...overrides ,
639+ }
640+ pkg . pnpm . peerDependencyRules ||= { }
641+ pkg . pnpm . peerDependencyRules . allowedVersions = {
642+ ...pkg . pnpm . peerDependencyRules . allowedVersions ,
643+ ...overrides ,
644+ }
613645 }
614646 } else if ( pm === 'yarn' ) {
615647 pkg . resolutions = {
0 commit comments