react-native-update-cli 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle.js +23 -8
- package/package.json +1 -1
- package/src/bundle.ts +35 -8
package/lib/bundle.js
CHANGED
|
@@ -256,19 +256,34 @@ async function copyHarmonyBundle(outputFolder) {
|
|
|
256
256
|
await _fsextra.remove(_path.default.join(harmonyRawPath, 'update.json'));
|
|
257
257
|
await _fsextra.copy('update.json', _path.default.join(harmonyRawPath, 'update.json'));
|
|
258
258
|
await _fsextra.ensureDir(outputFolder);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
259
|
+
// Recursively copy files with special handling for assets directory
|
|
260
|
+
async function copyFilesRecursively(srcDir, destDir, relativePath = '') {
|
|
261
|
+
const fullSrcPath = _path.default.join(srcDir, relativePath);
|
|
262
|
+
const items = await _fsextra.readdir(fullSrcPath);
|
|
263
|
+
for (const item of items){
|
|
264
|
+
const itemRelativePath = _path.default.join(relativePath, item);
|
|
265
|
+
const itemSrcPath = _path.default.join(srcDir, itemRelativePath);
|
|
266
|
+
// Skip update.json and meta.json at root level
|
|
267
|
+
if (!relativePath && (item === 'update.json' || item === 'meta.json')) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
const stat = await _fsextra.stat(itemSrcPath);
|
|
265
271
|
if (stat.isFile()) {
|
|
266
|
-
|
|
272
|
+
// Special handling: remove 'assets/' prefix to move files up one level
|
|
273
|
+
let itemDestPath = itemRelativePath;
|
|
274
|
+
if (itemDestPath.startsWith('assets/') || itemDestPath.startsWith('assets\\')) {
|
|
275
|
+
itemDestPath = itemDestPath.replace(/^assets[\\/]/, '');
|
|
276
|
+
}
|
|
277
|
+
const fullDestPath = _path.default.join(destDir, itemDestPath);
|
|
278
|
+
await _fsextra.ensureDir(_path.default.dirname(fullDestPath));
|
|
279
|
+
await _fsextra.copy(itemSrcPath, fullDestPath);
|
|
267
280
|
} else if (stat.isDirectory()) {
|
|
268
|
-
|
|
281
|
+
// Recursively process subdirectories
|
|
282
|
+
await copyFilesRecursively(srcDir, destDir, itemRelativePath);
|
|
269
283
|
}
|
|
270
284
|
}
|
|
271
285
|
}
|
|
286
|
+
await copyFilesRecursively(harmonyRawPath, outputFolder);
|
|
272
287
|
} catch (error) {
|
|
273
288
|
console.error((0, _i18n.t)('copyHarmonyBundleError', {
|
|
274
289
|
error
|
package/package.json
CHANGED
package/src/bundle.ts
CHANGED
|
@@ -270,20 +270,47 @@ async function copyHarmonyBundle(outputFolder: string) {
|
|
|
270
270
|
await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
|
|
271
271
|
await fs.ensureDir(outputFolder);
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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);
|
|
279
292
|
|
|
280
293
|
if (stat.isFile()) {
|
|
281
|
-
|
|
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);
|
|
282
306
|
} else if (stat.isDirectory()) {
|
|
283
|
-
|
|
307
|
+
// Recursively process subdirectories
|
|
308
|
+
await copyFilesRecursively(srcDir, destDir, itemRelativePath);
|
|
284
309
|
}
|
|
285
310
|
}
|
|
286
311
|
}
|
|
312
|
+
|
|
313
|
+
await copyFilesRecursively(harmonyRawPath, outputFolder);
|
|
287
314
|
} catch (error: any) {
|
|
288
315
|
console.error(t('copyHarmonyBundleError', { error }));
|
|
289
316
|
throw new Error(t('copyFileFailed', { error: error.message }));
|