react-native-update-cli 1.39.1 → 1.39.2

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
@@ -196,7 +196,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
196
196
  }, (error, props)=>{
197
197
  if (error) {
198
198
  console.error(error);
199
- resolve(null);
199
+ resolve({});
200
200
  }
201
201
  resolve(props);
202
202
  });
@@ -378,6 +378,14 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
378
378
  });
379
379
  }
380
380
  }
381
+ const ignorePackingFileNames = [
382
+ '.',
383
+ '..',
384
+ 'index.bundlejs.map'
385
+ ];
386
+ const ignorePackingExtensions = [
387
+ 'DS_Store'
388
+ ];
381
389
  async function pack(dir, output) {
382
390
  console.log('Packing');
383
391
  _fsextra.ensureDirSync(_nodepath.default.dirname(output));
@@ -389,7 +397,7 @@ async function pack(dir, output) {
389
397
  }
390
398
  const childs = _fsextra.readdirSync(root);
391
399
  for (const name of childs){
392
- if (name === '.' || name === '..' || name === 'index.bundlejs.map' || name === 'index.bundlejs.txt.map') {
400
+ if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some((ext)=>name.endsWith(`.${ext}`))) {
393
401
  continue;
394
402
  }
395
403
  const fullPath = _nodepath.default.join(root, name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.39.1",
3
+ "version": "1.39.2",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -22,16 +22,20 @@ try {
22
22
  hdiff = require('node-hdiffpatch').diff;
23
23
  } catch (e) {}
24
24
 
25
+
25
26
  async function runReactNativeBundleCommand(
26
- bundleName,
27
- development,
28
- entryFile,
29
- outputFolder,
30
- platform,
31
- sourcemapOutput,
32
- config,
27
+ bundleName: string,
28
+ development: string,
29
+ entryFile: string,
30
+ outputFolder: string,
31
+ platform: string,
32
+ sourcemapOutput: string,
33
+ config: string,
33
34
  ) {
34
- let gradleConfig = {};
35
+ let gradleConfig: {
36
+ crunchPngs?: boolean;
37
+ enableHermes?: boolean;
38
+ } = {};
35
39
  if (platform === 'android') {
36
40
  gradleConfig = await checkGradleConfig();
37
41
  if (gradleConfig.crunchPngs !== false) {
@@ -41,7 +45,7 @@ async function runReactNativeBundleCommand(
41
45
  }
42
46
  }
43
47
 
44
- const reactNativeBundleArgs = [];
48
+ const reactNativeBundleArgs: string[] = [];
45
49
 
46
50
  const envArgs = process.env.PUSHY_ENV_ARGS;
47
51
 
@@ -158,17 +162,17 @@ async function runReactNativeBundleCommand(
158
162
  ),
159
163
  );
160
164
  } else {
161
- let hermesEnabled = false;
165
+ let hermesEnabled: boolean | undefined = false;
162
166
 
163
167
  if (platform === 'android') {
164
- const gradlePropeties = await new Promise((resolve) => {
168
+ const gradlePropeties = await new Promise<{ hermesEnabled?: boolean }>((resolve) => {
165
169
  properties.parse(
166
170
  './android/gradle.properties',
167
171
  { path: true },
168
- (error, props) => {
172
+ (error: any, props: { hermesEnabled?: boolean }) => {
169
173
  if (error) {
170
174
  console.error(error);
171
- resolve(null);
175
+ resolve({});
172
176
  }
173
177
 
174
178
  resolve(props);
@@ -201,7 +205,7 @@ async function runReactNativeBundleCommand(
201
205
  });
202
206
  }
203
207
 
204
- async function copyHarmonyBundle(outputFolder) {
208
+ async function copyHarmonyBundle(outputFolder: string) {
205
209
  const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
206
210
  try {
207
211
  await fs.ensureDir(harmonyRawPath);
@@ -215,7 +219,7 @@ async function copyHarmonyBundle(outputFolder) {
215
219
 
216
220
  await fs.ensureDir(outputFolder);
217
221
  await fs.copy(harmonyRawPath, outputFolder);
218
- } catch (error) {
222
+ } catch (error: any) {
219
223
  console.error('copyHarmonyBundle 错误:', error);
220
224
  throw new Error(`复制文件失败: ${error.message}`);
221
225
  }
@@ -253,10 +257,10 @@ async function checkGradleConfig() {
253
257
  }
254
258
 
255
259
  async function compileHermesByteCode(
256
- bundleName,
257
- outputFolder,
258
- sourcemapOutput,
259
- shouldCleanSourcemap,
260
+ bundleName: string,
261
+ outputFolder: string,
262
+ sourcemapOutput: string,
263
+ shouldCleanSourcemap: boolean,
260
264
  ) {
261
265
  console.log('Hermes enabled, now compiling to hermes bytecode:\n');
262
266
  // >= rn 0.69
@@ -318,7 +322,7 @@ async function compileHermesByteCode(
318
322
  }
319
323
  }
320
324
 
321
- async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
325
+ async function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string) {
322
326
  if (sourcemapOutput) {
323
327
  let copyDebugidPath;
324
328
  try {
@@ -355,10 +359,10 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
355
359
  }
356
360
 
357
361
  async function uploadSourcemapForSentry(
358
- bundleName,
359
- outputFolder,
360
- sourcemapOutput,
361
- version,
362
+ bundleName: string,
363
+ outputFolder: string,
364
+ sourcemapOutput: string,
365
+ version: string,
362
366
  ) {
363
367
  if (sourcemapOutput) {
364
368
  let sentryCliPath;
@@ -405,19 +409,21 @@ async function uploadSourcemapForSentry(
405
409
  }
406
410
  }
407
411
 
408
- async function pack(dir, output) {
412
+ const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
413
+ const ignorePackingExtensions = ['DS_Store'];
414
+ async function pack(dir: string, output: string) {
409
415
  console.log('Packing');
410
416
  fs.ensureDirSync(path.dirname(output));
411
- await new Promise((resolve, reject) => {
417
+ await new Promise<void>((resolve, reject) => {
412
418
  const zipfile = new ZipFile();
413
419
 
414
- function addDirectory(root, rel) {
420
+ function addDirectory(root: string, rel: string) {
415
421
  if (rel) {
416
422
  zipfile.addEmptyDirectory(rel);
417
423
  }
418
424
  const childs = fs.readdirSync(root);
419
425
  for (const name of childs) {
420
- if (name === '.' || name === '..' || name === 'index.bundlejs.map' || name === 'index.bundlejs.txt.map') {
426
+ if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some(ext => name.endsWith(`.${ext}`))) {
421
427
  continue;
422
428
  }
423
429
  const fullPath = path.join(root, name);
@@ -434,7 +440,7 @@ async function pack(dir, output) {
434
440
 
435
441
  addDirectory(dir, '');
436
442
 
437
- zipfile.outputStream.on('error', (err) => reject(err));
443
+ zipfile.outputStream.on('error', (err: any) => reject(err));
438
444
  zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
439
445
  resolve();
440
446
  });
@@ -443,12 +449,12 @@ async function pack(dir, output) {
443
449
  console.log(`ppk热更包已生成并保存到: ${output}`);
444
450
  }
445
451
 
446
- export function readEntire(entry, zipFile) {
447
- const buffers = [];
452
+ export function readEntire(entry: string, zipFile: ZipFile) {
453
+ const buffers: Buffer[] = [];
448
454
  return new Promise((resolve, reject) => {
449
- zipFile.openReadStream(entry, (err, stream) => {
455
+ zipFile.openReadStream(entry, (err: any, stream: any) => {
450
456
  stream.pipe({
451
- write(chunk) {
457
+ write(chunk: Buffer) {
452
458
  buffers.push(chunk);
453
459
  },
454
460
  end() {
@@ -463,12 +469,12 @@ export function readEntire(entry, zipFile) {
463
469
  });
464
470
  }
465
471
 
466
- function basename(fn) {
472
+ function basename(fn: string) {
467
473
  const m = /^(.+\/)[^\/]+\/?$/.exec(fn);
468
474
  return m?.[1];
469
475
  }
470
476
 
471
- async function diffFromPPK(origin, next, output) {
477
+ async function diffFromPPK(origin: string, next: string, output: string) {
472
478
  fs.ensureDirSync(path.dirname(output));
473
479
 
474
480
  const originEntries = {};
@@ -513,7 +519,7 @@ async function diffFromPPK(origin, next, output) {
513
519
 
514
520
  const addedEntry = {};
515
521
 
516
- function addEntry(fn) {
522
+ function addEntry(fn: string) {
517
523
  //console.log(fn);
518
524
  if (!fn || addedEntry[fn]) {
519
525
  return;
@@ -610,11 +616,11 @@ async function diffFromPPK(origin, next, output) {
610
616
  }
611
617
 
612
618
  async function diffFromPackage(
613
- origin,
614
- next,
615
- output,
616
- originBundleName,
617
- transformPackagePath = (v) => v,
619
+ origin: string,
620
+ next: string,
621
+ output: string,
622
+ originBundleName: string,
623
+ transformPackagePath = (v: string) => v,
618
624
  ) {
619
625
  fs.ensureDirSync(path.dirname(output));
620
626
 
@@ -623,7 +629,7 @@ async function diffFromPackage(
623
629
 
624
630
  let originSource;
625
631
 
626
- await enumZipEntries(origin, (entry, zipFile) => {
632
+ await enumZipEntries(origin, (entry: any, zipFile: any) => {
627
633
  if (!/\/$/.test(entry.fileName)) {
628
634
  const fn = transformPackagePath(entry.fileName);
629
635
  if (!fn) {
@@ -717,9 +723,9 @@ async function diffFromPackage(
717
723
  await writePromise;
718
724
  }
719
725
 
720
- export async function enumZipEntries(zipFn, callback, nestedPath = '') {
726
+ export async function enumZipEntries(zipFn: string, callback: (entry: any, zipFile: any) => void, nestedPath = '') {
721
727
  return new Promise((resolve, reject) => {
722
- openZipFile(zipFn, { lazyEntries: true }, async (err, zipfile) => {
728
+ openZipFile(zipFn, { lazyEntries: true }, async (err: any, zipfile: ZipFile) => {
723
729
  if (err) {
724
730
  return reject(err);
725
731
  }