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.3 in package.json and implement recursive file copying with special handling for assets in bundle.ts
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update-cli",
|
"name": "react-native-update-cli",
|
||||||
"version": "2.2.2",
|
"version": "2.2.3",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -270,20 +270,47 @@ async function copyHarmonyBundle(outputFolder: string) {
|
|||||||
await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
|
await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
|
||||||
await fs.ensureDir(outputFolder);
|
await fs.ensureDir(outputFolder);
|
||||||
|
|
||||||
const files = await fs.readdir(harmonyRawPath);
|
// Recursively copy files with special handling for assets directory
|
||||||
for (const file of files) {
|
async function copyFilesRecursively(
|
||||||
if (file !== 'update.json' && file !== 'meta.json') {
|
srcDir: string,
|
||||||
const sourcePath = path.join(harmonyRawPath, file);
|
destDir: string,
|
||||||
const destPath = path.join(outputFolder, file);
|
relativePath = '',
|
||||||
const stat = await fs.stat(sourcePath);
|
) {
|
||||||
|
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()) {
|
if (stat.isFile()) {
|
||||||
await fs.copy(sourcePath, destPath);
|
// 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()) {
|
} else if (stat.isDirectory()) {
|
||||||
await fs.copy(sourcePath, destPath);
|
// Recursively process subdirectories
|
||||||
|
await copyFilesRecursively(srcDir, destDir, itemRelativePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await copyFilesRecursively(harmonyRawPath, outputFolder);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(t('copyHarmonyBundleError', { error }));
|
console.error(t('copyHarmonyBundleError', { error }));
|
||||||
throw new Error(t('copyFileFailed', { error: error.message }));
|
throw new Error(t('copyFileFailed', { error: error.message }));
|
||||||
|
|||||||
Reference in New Issue
Block a user