@@ -270,20 +270,47 @@ async function copyHarmonyBundle(outputFolder: string) {
270270 await fs . copy ( 'update.json' , path . join ( harmonyRawPath , 'update.json' ) ) ;
271271 await fs . ensureDir ( outputFolder ) ;
272272
273- const files = await fs . readdir ( harmonyRawPath ) ;
274- for ( const file of files ) {
275- if ( file !== 'update.json' && file !== 'meta.json' ) {
276- const sourcePath = path . join ( harmonyRawPath , file ) ;
277- const destPath = path . join ( outputFolder , file ) ;
278- const stat = await fs . stat ( sourcePath ) ;
273+ // Recursively copy files with special handling for assets directory
274+ async function copyFilesRecursively (
275+ srcDir : string ,
276+ destDir : string ,
277+ relativePath = '' ,
278+ ) {
279+ const fullSrcPath = path . join ( srcDir , relativePath ) ;
280+ const items = await fs . readdir ( fullSrcPath ) ;
281+
282+ for ( const item of items ) {
283+ const itemRelativePath = path . join ( relativePath , item ) ;
284+ const itemSrcPath = path . join ( srcDir , itemRelativePath ) ;
285+
286+ // Skip update.json and meta.json at root level
287+ if ( ! relativePath && ( item === 'update.json' || item === 'meta.json' ) ) {
288+ continue ;
289+ }
290+
291+ const stat = await fs . stat ( itemSrcPath ) ;
279292
280293 if ( stat . isFile ( ) ) {
281- await fs . copy ( sourcePath , destPath ) ;
294+ // Special handling: remove 'assets/' prefix to move files up one level
295+ let itemDestPath = itemRelativePath ;
296+ if (
297+ itemDestPath . startsWith ( 'assets/' ) ||
298+ itemDestPath . startsWith ( 'assets\\' )
299+ ) {
300+ itemDestPath = itemDestPath . replace ( / ^ a s s e t s [ \\ / ] / , '' ) ;
301+ }
302+
303+ const fullDestPath = path . join ( destDir , itemDestPath ) ;
304+ await fs . ensureDir ( path . dirname ( fullDestPath ) ) ;
305+ await fs . copy ( itemSrcPath , fullDestPath ) ;
282306 } else if ( stat . isDirectory ( ) ) {
283- await fs . copy ( sourcePath , destPath ) ;
307+ // Recursively process subdirectories
308+ await copyFilesRecursively ( srcDir , destDir , itemRelativePath ) ;
284309 }
285310 }
286311 }
312+
313+ await copyFilesRecursively ( harmonyRawPath , outputFolder ) ;
287314 } catch ( error : any ) {
288315 console . error ( t ( 'copyHarmonyBundleError' , { error } ) ) ;
289316 throw new Error ( t ( 'copyFileFailed' , { error : error . message } ) ) ;
0 commit comments