mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-10-28 21:33:10 +08:00
Update version to 2.2.4 in package.json and enhance argument handling in runReactNativeBundleCommand for improved functionality.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"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)",
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -163,18 +163,20 @@ async function runReactNativeBundleCommand({
|
|||||||
bundleCommand = 'build';
|
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') {
|
if (platform !== 'harmony') {
|
||||||
reactNativeBundleArgs.push(
|
reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
|
||||||
'--platform',
|
|
||||||
platform,
|
|
||||||
'--assets-dest',
|
|
||||||
outputFolder,
|
|
||||||
'--bundle-output',
|
|
||||||
path.join(outputFolder, bundleName),
|
|
||||||
'--reset-cache',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli.taro) {
|
if (cli.taro) {
|
||||||
@@ -240,8 +242,6 @@ async function runReactNativeBundleCommand({
|
|||||||
fs.existsSync('ios/Pods/hermes-engine')
|
fs.existsSync('ios/Pods/hermes-engine')
|
||||||
) {
|
) {
|
||||||
hermesEnabled = true;
|
hermesEnabled = true;
|
||||||
} else if (platform === 'harmony') {
|
|
||||||
await copyHarmonyBundle(outputFolder);
|
|
||||||
}
|
}
|
||||||
if (hermesEnabled) {
|
if (hermesEnabled) {
|
||||||
await compileHermesByteCode(
|
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() {
|
function getHermesOSBin() {
|
||||||
if (os.platform() === 'win32') return 'win64-bin';
|
if (os.platform() === 'win32') return 'win64-bin';
|
||||||
if (os.platform() === 'darwin') return 'osx-bin';
|
if (os.platform() === 'darwin') return 'osx-bin';
|
||||||
|
|||||||
Reference in New Issue
Block a user