From 15c8052459c314ea29186cdf8ca35c182b13a64a Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sat, 25 Oct 2025 10:53:50 +0800 Subject: [PATCH] Update version to 2.2.4 in package.json and enhance argument handling in runReactNativeBundleCommand for improved functionality. --- package.json | 2 +- src/bundle.ts | 84 ++++++++------------------------------------------- 2 files changed, 13 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index ffe2bfc..8998407 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update-cli", - "version": "2.2.3", + "version": "2.2.4", "description": "command line tool for react-native-update (remote updates for react native)", "main": "index.js", "bin": { diff --git a/src/bundle.ts b/src/bundle.ts index d4e60c0..22d6218 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -163,18 +163,20 @@ async function runReactNativeBundleCommand({ bundleCommand = 'build'; } - reactNativeBundleArgs.push(cliPath, bundleCommand); + reactNativeBundleArgs.push( + cliPath, + bundleCommand, + '--assets-dest', + outputFolder, + '--bundle-output', + path.join( + outputFolder, + platform === 'harmony' ? 'harmony.bundle.js' : bundleName, + ), + ); if (platform !== 'harmony') { - reactNativeBundleArgs.push( - '--platform', - platform, - '--assets-dest', - outputFolder, - '--bundle-output', - path.join(outputFolder, bundleName), - '--reset-cache', - ); + reactNativeBundleArgs.push('--platform', platform, '--reset-cache'); } if (cli.taro) { @@ -240,8 +242,6 @@ async function runReactNativeBundleCommand({ fs.existsSync('ios/Pods/hermes-engine') ) { hermesEnabled = true; - } else if (platform === 'harmony') { - await copyHarmonyBundle(outputFolder); } if (hermesEnabled) { await compileHermesByteCode( @@ -257,66 +257,6 @@ async function runReactNativeBundleCommand({ }); } -async function copyHarmonyBundle(outputFolder: string) { - const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile'; - try { - await fs.ensureDir(harmonyRawPath); - try { - await fs.access(harmonyRawPath, fs.constants.W_OK); - } catch (error) { - await fs.chmod(harmonyRawPath, 0o755); - } - await fs.remove(path.join(harmonyRawPath, 'update.json')); - await fs.copy('update.json', path.join(harmonyRawPath, 'update.json')); - await fs.ensureDir(outputFolder); - - // Recursively copy files with special handling for assets directory - async function copyFilesRecursively( - srcDir: string, - destDir: string, - relativePath = '', - ) { - const fullSrcPath = path.join(srcDir, relativePath); - const items = await fs.readdir(fullSrcPath); - - for (const item of items) { - const itemRelativePath = path.join(relativePath, item); - const itemSrcPath = path.join(srcDir, itemRelativePath); - - // Skip update.json and meta.json at root level - if (!relativePath && (item === 'update.json' || item === 'meta.json')) { - continue; - } - - const stat = await fs.stat(itemSrcPath); - - if (stat.isFile()) { - // Special handling: remove 'assets/' prefix to move files up one level - let itemDestPath = itemRelativePath; - if ( - itemDestPath.startsWith('assets/') || - itemDestPath.startsWith('assets\\') - ) { - itemDestPath = itemDestPath.replace(/^assets[\\/]/, ''); - } - - const fullDestPath = path.join(destDir, itemDestPath); - await fs.ensureDir(path.dirname(fullDestPath)); - await fs.copy(itemSrcPath, fullDestPath); - } else if (stat.isDirectory()) { - // Recursively process subdirectories - await copyFilesRecursively(srcDir, destDir, itemRelativePath); - } - } - } - - await copyFilesRecursively(harmonyRawPath, outputFolder); - } catch (error: any) { - console.error(t('copyHarmonyBundleError', { error })); - throw new Error(t('copyFileFailed', { error: error.message })); - } -} - function getHermesOSBin() { if (os.platform() === 'win32') return 'win64-bin'; if (os.platform() === 'darwin') return 'osx-bin';