@@ -78,6 +78,42 @@ class CopyTemplateDirService extends Effect.Service<CopyTemplateDirService>()(
7878 yield * fs . writeFileString ( destPackageJsonPath , JSON . stringify ( packageJson , null , 2 ) ) ;
7979 } ) ;
8080
81+ const updateTsconfigJsonWorkspaceDeps = ( tsconfigJsonPath : string , destTsconfigJsonPath : string ) =>
82+ Effect . gen ( function * ( ) {
83+ // read the tsconfig.json
84+ const tsconfigJson = yield * fs . readFileString ( tsconfigJsonPath ) . pipe ( Effect . map ( JSON . parse ) ) ;
85+
86+ // remove the paths for the hypergraph workspace deps
87+ tsconfigJson . compilerOptions . paths = Object . fromEntries (
88+ Object . entries ( tsconfigJson . compilerOptions . paths ) . filter (
89+ ( [ key ] ) => ! key . startsWith ( '@graphprotocol/hypergraph' ) ,
90+ ) ,
91+ ) ;
92+
93+ // remove hypergraph paths from the include array
94+ if ( tsconfigJson . include && Array . isArray ( tsconfigJson . include ) ) {
95+ tsconfigJson . include = tsconfigJson . include . filter (
96+ ( path : string ) => ! path . startsWith ( '../../packages/hypergraph' ) ,
97+ ) ;
98+ }
99+
100+ yield * fs . writeFileString ( destTsconfigJsonPath , JSON . stringify ( tsconfigJson , null , 2 ) ) ;
101+ } ) ;
102+
103+ const updateViteConfigAliases = ( viteConfigPath : string , destViteConfigPath : string ) =>
104+ Effect . gen ( function * ( ) {
105+ // read the vite.config.ts
106+ const viteConfig = yield * fs . readFileString ( viteConfigPath ) ;
107+
108+ // Remove the hypergraph aliases from the Vite config using line-based filtering
109+ const updatedViteConfig = viteConfig
110+ . split ( '\n' )
111+ . filter ( ( line ) => ! line . match ( / [ ' " ] @ g r a p h p r o t o c o l \/ h y p e r g r a p h ( - r e a c t ) ? [ ^ ' " ] * [ ' " ] \s * : / ) )
112+ . join ( '\n' ) ;
113+
114+ yield * fs . writeFileString ( destViteConfigPath , updatedViteConfig ) ;
115+ } ) ;
116+
81117 const copy = ( src : string , dest : string , replaced : Record < string , string > ) : Effect . Effect < void , PlatformError > =>
82118 Effect . gen ( function * ( ) {
83119 yield * fs . makeDirectory ( dest , { recursive : true } ) ;
@@ -97,6 +133,14 @@ class CopyTemplateDirService extends Effect.Service<CopyTemplateDirService>()(
97133 yield * updatePackageJsonWorkspaceDeps ( srcPath , destPath , replaced ) ;
98134 continue ;
99135 }
136+ if ( entry . name === 'tsconfig.app.json' || entry . name === 'tsconfig.json' ) {
137+ yield * updateTsconfigJsonWorkspaceDeps ( srcPath , destPath ) ;
138+ continue ;
139+ }
140+ if ( entry . name === 'vite.config.ts' ) {
141+ yield * updateViteConfigAliases ( srcPath , destPath ) ;
142+ continue ;
143+ }
100144 yield * fs . copyFile ( srcPath , destPath ) ;
101145 }
102146 }
0 commit comments