react-native-update-cli 2.2.1 → 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 CHANGED
@@ -183,9 +183,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
183
183
  } else if (cli.taro) {
184
184
  bundleCommand = 'build';
185
185
  }
186
- reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, platform === 'harmony' ? 'bundle.harmony.js' : bundleName));
186
+ reactNativeBundleArgs.push(cliPath, bundleCommand);
187
187
  if (platform !== 'harmony') {
188
- reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
188
+ reactNativeBundleArgs.push('--platform', platform, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName), '--reset-cache');
189
189
  }
190
190
  if (cli.taro) {
191
191
  reactNativeBundleArgs.push('--type', 'rn');
@@ -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
- const files = await _fsextra.readdir(harmonyRawPath);
260
- for (const file of files){
261
- if (file !== 'update.json' && file !== 'meta.json') {
262
- const sourcePath = _path.default.join(harmonyRawPath, file);
263
- const destPath = _path.default.join(outputFolder, file);
264
- const stat = await _fsextra.stat(sourcePath);
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
- await _fsextra.copy(sourcePath, destPath);
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
- await _fsextra.copy(sourcePath, destPath);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/bundle.ts CHANGED
@@ -163,20 +163,18 @@ async function runReactNativeBundleCommand({
163
163
  bundleCommand = 'build';
164
164
  }
165
165
 
166
- reactNativeBundleArgs.push(
167
- cliPath,
168
- bundleCommand,
169
- '--assets-dest',
170
- outputFolder,
171
- '--bundle-output',
172
- path.join(
173
- outputFolder,
174
- platform === 'harmony' ? 'bundle.harmony.js' : bundleName,
175
- ),
176
- );
166
+ reactNativeBundleArgs.push(cliPath, bundleCommand);
177
167
 
178
168
  if (platform !== 'harmony') {
179
- reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
169
+ reactNativeBundleArgs.push(
170
+ '--platform',
171
+ platform,
172
+ '--assets-dest',
173
+ outputFolder,
174
+ '--bundle-output',
175
+ path.join(outputFolder, bundleName),
176
+ '--reset-cache',
177
+ );
180
178
  }
181
179
 
182
180
  if (cli.taro) {
@@ -272,20 +270,47 @@ async function copyHarmonyBundle(outputFolder: string) {
272
270
  await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
273
271
  await fs.ensureDir(outputFolder);
274
272
 
275
- const files = await fs.readdir(harmonyRawPath);
276
- for (const file of files) {
277
- if (file !== 'update.json' && file !== 'meta.json') {
278
- const sourcePath = path.join(harmonyRawPath, file);
279
- const destPath = path.join(outputFolder, file);
280
- 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);
281
292
 
282
293
  if (stat.isFile()) {
283
- 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);
284
306
  } else if (stat.isDirectory()) {
285
- await fs.copy(sourcePath, destPath);
307
+ // Recursively process subdirectories
308
+ await copyFilesRecursively(srcDir, destDir, itemRelativePath);
286
309
  }
287
310
  }
288
311
  }
312
+
313
+ await copyFilesRecursively(harmonyRawPath, outputFolder);
289
314
  } catch (error: any) {
290
315
  console.error(t('copyHarmonyBundleError', { error }));
291
316
  throw new Error(t('copyFileFailed', { error: error.message }));