Skip to content

Commit c633af5

Browse files
committed
Update version to 2.2.3 in package.json and implement recursive file copying with special handling for assets in bundle.ts
1 parent 78159f3 commit c633af5

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {

src/bundle.ts

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/^assets[\\/]/, '');
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

Comments
 (0)