@@ -32,12 +32,13 @@ const ignorePackages = [
3232 '@angular/bazel' ,
3333] ;
3434
35- const { writeFileSync} = require ( 'fs' ) ;
35+ const { readFileSync , writeFileSync} = require ( 'fs' ) ;
3636const { join} = require ( 'path' ) ;
3737
3838const [ tag ] = process . argv . slice ( 2 ) ;
3939const projectDir = join ( __dirname , '../../' ) ;
4040const packageJsonPath = join ( projectDir , 'package.json' ) ;
41+ const pnpmWorkspacePath = join ( projectDir , 'pnpm-workspace.yaml' ) ;
4142const packageJson = require ( packageJsonPath ) ;
4243const packageSuffix = tag ? ` (${ tag } )` : '' ;
4344
@@ -65,15 +66,17 @@ const packagesToUpdate = packagesToConsider.reduce((result, name) => {
6566console . log ( 'Setting up snapshot builds for:\n' ) ;
6667console . log ( ` ${ packagesToUpdate . map ( p => `${ p . name } ${ packageSuffix } ` ) . join ( '\n ' ) } \n` ) ;
6768
69+ const overrideLines = [ ] ;
70+
6871// Setup the snapshot version for each Angular package specified in the "package.json" file.
6972packagesToUpdate . forEach ( ( { name, repoName} ) => {
70- const buildsUrl = `github:angular/ ${ repoName } ${ tag ? `#${ tag } ` : '' } ` ;
73+ const buildsUrl = `github:${ repoName } ${ tag ? `#${ tag } ` : '' } ` ;
7174
72- // Add overrides for each package in the format "**/{PACKAGE}" so that all
73- // nested versions of that specific Angular package will have the same version.
74- packageJson . pnpm . overrides [ `**/ ${ name } ` ] = buildsUrl ;
75+ // Add overrides for each package so that all nested versions of that
76+ // specific Angular package will have the same version.
77+ overrideLines . push ( ` ' ${ name } ': ' ${ buildsUrl } '` ) ;
7578
76- // Since the resolutions only cover the version of all nested installs, we also need
79+ // Since the overrides only cover the version of all nested installs, we also need
7780 // to explicitly set the version for the package listed in the project "package.json".
7881 if ( packageJson . devDependencies && packageJson . devDependencies [ name ] ) {
7982 packageJson . devDependencies [ name ] = buildsUrl ;
@@ -83,6 +86,17 @@ packagesToUpdate.forEach(({name, repoName}) => {
8386} ) ;
8487
8588// Write changes to the "packageJson", so that we can install the new versions afterwards.
86- writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) ) ;
89+ writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) + '\n' ) ;
90+
91+ // Add the overrides and allow exotic subdependencies in "pnpm-workspace.yaml".
92+ let pnpmWorkspace = readFileSync ( pnpmWorkspacePath , 'utf8' ) ;
93+ if ( ! pnpmWorkspace . includes ( '\noverrides:\n' ) ) {
94+ throw new Error ( 'Could not find "overrides:" section in pnpm-workspace.yaml' ) ;
95+ }
96+ pnpmWorkspace = pnpmWorkspace . replace (
97+ '\noverrides:\n' ,
98+ `\nblockExoticSubdeps: false\noverrides:\n${ overrideLines . join ( '\n' ) } \n` ,
99+ ) ;
100+ writeFileSync ( pnpmWorkspacePath , pnpmWorkspace ) ;
87101
88- console . log ( 'Successfully added the "resolutions " to the "package.json ".' ) ;
102+ console . log ( 'Successfully added the "overrides " to the "pnpm-workspace.yaml ".' ) ;
0 commit comments