@@ -6,6 +6,7 @@ import fs from 'fs-extra'
66import klaw from 'klaw'
77import path from 'pathe'
88import set from 'set-value'
9+ import YAML from 'yaml'
910import { assetsDir } from '../../constants'
1011import { resolveCommandConfig } from '../../core/config'
1112import { GitClient } from '../../core/git'
@@ -14,6 +15,7 @@ import { escapeStringRegexp, isIgnorableFsError, isMatch, toWorkspaceGitignorePa
1415import { evaluateWriteIntent , flushPendingOverwrites , scheduleOverwrite } from './overwrite'
1516import { setPkgJson } from './pkg-json'
1617import { getAssetTargets } from './targets'
18+ import { mergeWorkspaceManifest , normalizeWorkspaceManifest } from './workspace'
1719
1820export { setPkgJson }
1921
@@ -110,6 +112,32 @@ export async function upgradeMonorepo(opts: CliOpts) {
110112 continue
111113 }
112114
115+ if ( relPath === 'pnpm-workspace.yaml' ) {
116+ const sourceManifest = normalizeWorkspaceManifest (
117+ YAML . parse ( await fs . readFile ( file . path , 'utf8' ) ) ,
118+ )
119+ const exists = await fs . pathExists ( targetPath )
120+ const targetManifest = exists
121+ ? normalizeWorkspaceManifest ( YAML . parse ( await fs . readFile ( targetPath , 'utf8' ) ) )
122+ : normalizeWorkspaceManifest ( { } )
123+ const mergedManifest = exists
124+ ? mergeWorkspaceManifest ( sourceManifest , targetManifest )
125+ : sourceManifest
126+ const data = YAML . stringify ( mergedManifest )
127+ const intent = await evaluateWriteIntent ( targetPath , { skipOverwrite, source : data } )
128+ const action = async ( ) => {
129+ await fs . outputFile ( targetPath , data , 'utf8' )
130+ logger . success ( targetPath )
131+ }
132+ await scheduleOverwrite ( intent , {
133+ relPath,
134+ targetPath,
135+ action,
136+ pending : pendingOverwrites ,
137+ } )
138+ continue
139+ }
140+
113141 if ( relPath === '.changeset/config.json' && repoName ) {
114142 const changesetJson = await fs . readJson ( file . path )
115143 set ( changesetJson , 'changelog.1.repo' , repoName )
0 commit comments