@@ -42,7 +42,8 @@ const linkDemo = async (demoName: string) => {
4242 const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf8' ) ) ;
4343
4444 // Track changed files
45- let changes = 0 ;
45+ let changes = false ;
46+
4647 const updateDeps = ( deps : { [ key : string ] : string } ) => {
4748 for ( const dep in deps ) {
4849 const matchingPackage = workspacePackages . find ( ( p ) => p . manifest . name === dep ) ;
@@ -55,12 +56,11 @@ const linkDemo = async (demoName: string) => {
5556 }
5657 latestVersion = '^' + latestVersion ;
5758 if ( deps [ dep ] === latestVersion ) {
58- console . log ( `- ${ dep } : '${ deps [ dep ] } ' => '${ latestVersion } ' (no changes)` ) ;
5959 continue ;
6060 }
6161 console . log ( `- ${ dep } : '${ deps [ dep ] } ' => '${ latestVersion } '` ) ;
6262 deps [ dep ] = latestVersion ;
63- changes ++ ;
63+ changes = true ;
6464 }
6565 } ;
6666
@@ -78,6 +78,37 @@ const linkDemo = async (demoName: string) => {
7878
7979 if ( changes ) {
8080 fs . writeFileSync ( packageJsonPath , `${ JSON . stringify ( packageJson , null , 2 ) } \n` , 'utf8' ) ;
81+ } else {
82+ console . log ( '- No changes' ) ;
83+ }
84+
85+ const tsConfigPath = path . join ( demoSrc , 'tsconfig.json' ) ;
86+ if ( fs . existsSync ( tsConfigPath ) ) {
87+ changes = false ;
88+
89+ console . log ( 'Checking tsconfig.json' ) ;
90+ const tsConfig = JSON . parse ( fs . readFileSync ( tsConfigPath , 'utf8' ) ) ;
91+
92+ if ( 'references' in tsConfig ) {
93+ for ( let i = 0 ; i < tsConfig . references . length ; i ++ ) {
94+ const ref = tsConfig . references [ i ] ;
95+ if ( ref . path === 'tsconfig.workspace.json' ) {
96+ console . log ( '- Unlinking tsconfig.workspace.json' ) ;
97+ tsConfig . references . splice ( i ) ;
98+ changes = true ;
99+ }
100+ }
101+ }
102+
103+ if ( tsConfig . references . length === 0 ) {
104+ delete tsConfig . references ;
105+ }
106+
107+ if ( changes ) {
108+ fs . writeFileSync ( tsConfigPath , `${ JSON . stringify ( tsConfig , null , 2 ) } \n` , 'utf8' ) ;
109+ } else {
110+ console . log ( '- No changes' ) ;
111+ }
81112 }
82113} ;
83114
@@ -130,7 +161,7 @@ const main = () => {
130161 console . log ( `- ${ demoName } ` ) ;
131162 try {
132163 // Patchy solution with rm -rf'ing node_modules because pnpm tries to reuse existing linked package
133- execSync ( 'rm -rf node_modules && pnpm --ignore-workspace install' , { cwd : demoSrc , stdio : 'inherit' } ) ;
164+ execSync ( 'rm -rf node_modules && pnpm install' , { cwd : demoSrc , stdio : 'inherit' } ) ;
134165 } catch ( e ) {
135166 console . error ( `Error installing packages: ${ e } ` ) ;
136167 process . exit ( 1 ) ;
0 commit comments