@@ -9,7 +9,7 @@ import ts from 'typescript';
99import glob from 'tiny-glob/sync.js' ;
1010import chokidar from 'chokidar' ;
1111import { fileURLToPath } from 'node:url' ;
12- import { clone_repo , migrate_meta_json } from './utils.ts' ;
12+ import { clone_repo , invoke , migrate_meta_json } from './utils.ts' ;
1313import { get_types , read_d_ts_file , read_types } from './types.ts' ;
1414import type { Modules } from '@sveltejs/site-kit/markdown' ;
1515import { generate_crosslinks } from './crosslinks.ts' ;
@@ -24,6 +24,7 @@ interface Package {
2424 docs : string ;
2525 types : string | null ;
2626 process_modules ?: ( modules : Modules , pkg : Package ) => Promise < Modules > ;
27+ post_clone ?: ( dir : string ) => Promise < void > ;
2728}
2829
2930const get_trigger = ( pkg : Package ) => pkg . trigger ?? pkg . name ;
@@ -79,6 +80,26 @@ const get_downstream_repo = (name: string) => {
7980 return `${ owner } /${ downstream } ` ;
8081} ;
8182
83+ function patch_node_modules (
84+ cloned_dir : string ,
85+ pkg_subdir : string ,
86+ npm_name : string ,
87+ onlyDirs ?: string [ ]
88+ ) {
89+ const source = path . join ( cloned_dir , pkg_subdir ) ;
90+ const target = path . join ( dirname , '../../node_modules' , npm_name ) ;
91+ if ( onlyDirs ) {
92+ for ( const dir of onlyDirs ) {
93+ const t = path . join ( target , dir ) ;
94+ fs . rmSync ( t , { recursive : true , force : true } ) ;
95+ fs . cpSync ( path . join ( source , dir ) , t , { recursive : true } ) ;
96+ }
97+ } else {
98+ fs . rmSync ( target , { force : true } ) ;
99+ fs . symlinkSync ( source , target ) ;
100+ }
101+ }
102+
82103const packages : Package [ ] = [
83104 {
84105 name : 'svelte' ,
@@ -87,6 +108,9 @@ const packages: Package[] = [
87108 pkg : 'packages/svelte' ,
88109 docs : 'documentation/docs' ,
89110 types : 'types' ,
111+ post_clone : async ( dir ) => {
112+ patch_node_modules ( dir , 'packages/svelte' , 'svelte' , [ 'types' ] ) ;
113+ } ,
90114 process_modules : async ( modules : Modules ) => {
91115 // Remove $$_attributes from ActionReturn
92116 const module_with_ActionReturn = modules . find ( ( m ) =>
@@ -111,6 +135,9 @@ const packages: Package[] = [
111135 pkg : 'packages/kit' ,
112136 docs : 'documentation/docs' ,
113137 types : 'types' ,
138+ post_clone : async ( dir ) => {
139+ patch_node_modules ( dir , 'packages/kit' , '@sveltejs/kit' , [ 'types' ] ) ;
140+ } ,
114141 process_modules : async ( modules , pkg ) => {
115142 const kit_base = `${ REPOS } /${ pkg . name } /${ pkg . pkg } /` ;
116143
@@ -170,7 +197,14 @@ const packages: Package[] = [
170197 branch : branches [ 'cli' ] ?. branch ?? 'main' ,
171198 pkg : 'packages/sv' ,
172199 docs : 'documentation/docs' ,
173- types : null
200+ types : null ,
201+ post_clone : async ( dir ) => {
202+ await invoke ( 'npx' , [ 'pnpm@10' , 'install' ] , { cwd : dir } ) ;
203+ await invoke ( 'npx' , [ 'pnpm@10' , 'build' ] , { cwd : dir } ) ;
204+
205+ patch_node_modules ( dir , 'packages/sv' , 'sv' ) ;
206+ patch_node_modules ( dir , 'packages/sv-utils' , '@sveltejs/sv-utils' ) ;
207+ }
174208 } ,
175209 {
176210 name : 'ai' ,
@@ -213,6 +247,9 @@ if (parsed.values.pull) {
213247
214248 for ( const pkg of filtered ) {
215249 await clone_repo ( `https://github.com/${ pkg . repo } .git` , pkg . name , pkg . branch , REPOS ) ;
250+ if ( pkg . post_clone ) {
251+ await pkg . post_clone ( `${ REPOS } /${ pkg . name } ` ) ;
252+ }
216253 }
217254}
218255
0 commit comments