react-native-update 10.35.1 → 10.35.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.
@@ -0,0 +1,41 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ export function reactNativeUpdatePlugin() {
5
+ return {
6
+ pluginId: 'reactNativeUpdatePlugin',
7
+ apply(node) {
8
+ node.registerTask({
9
+ name: 'reactNativeUpdatePlugin',
10
+ run: () => {
11
+ const cwd = process.cwd();
12
+ const metaFilePath = path.resolve(
13
+ cwd,
14
+ 'entry/src/main/resources/rawfile/meta.json',
15
+ );
16
+ fs.mkdirSync(path.dirname(metaFilePath), { recursive: true });
17
+
18
+ const moduleJsonPath = path.resolve(cwd, 'AppScope/app.json5');
19
+ let versionName = '';
20
+ if (fs.existsSync(moduleJsonPath)) {
21
+ const content = fs.readFileSync(moduleJsonPath, 'utf-8');
22
+ const match = content.match(
23
+ /(?:"versionName"|versionName):\s*["']([^"']+)["']/,
24
+ );
25
+ versionName = match?.[1] || '';
26
+ }
27
+
28
+ const metaContent = {
29
+ pushy_build_time: new Date().toISOString(),
30
+ versionName,
31
+ };
32
+
33
+ fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
34
+ console.log(`Build time written to ${metaFilePath}`);
35
+ },
36
+ dependencies: [],
37
+ postDependencies: ['default@BuildJS'],
38
+ });
39
+ },
40
+ };
41
+ }
@@ -1,10 +1,8 @@
1
1
  import http from '@ohos.net.http';
2
2
  import fileIo from '@ohos.file.fs';
3
- import util from '@ohos.util';
4
3
  import common from '@ohos.app.ability.common';
5
- import { BusinessError } from '@kit.BasicServicesKit';
6
4
  import { buffer } from '@kit.ArkTS';
7
- import zip from '@ohos.zlib';
5
+ import { zlib, BusinessError } from '@kit.BasicServicesKit';
8
6
  import { EventHub } from './EventHub';
9
7
  import { DownloadTaskParams } from './DownloadTaskParams';
10
8
  import Pushy from 'librnupdate.so';
@@ -37,7 +35,9 @@ export class DownloadTask {
37
35
  if (stat.isDirectory()) {
38
36
  const files = await fileIo.listFile(path);
39
37
  for (const file of files) {
40
- if (file === '.' || file === '..') continue;
38
+ if (file === '.' || file === '..') {
39
+ continue;
40
+ }
41
41
  await this.removeDirectory(`${path}/${file}`);
42
42
  }
43
43
  await fileIo.rmdir(path);
@@ -180,12 +180,7 @@ export class DownloadTask {
180
180
  await this.removeDirectory(params.unzipDirectory);
181
181
  await fileIo.mkdir(params.unzipDirectory);
182
182
 
183
- try {
184
- await zip.decompressFile(params.targetFile, params.unzipDirectory);
185
- } catch (error) {
186
- console.error('Unzip failed:', error);
187
- throw error;
188
- }
183
+ await zlib.decompressFile(params.targetFile, params.unzipDirectory);
189
184
  }
190
185
 
191
186
  private async processUnzippedFiles(directory: string): Promise<ZipFile> {
@@ -193,7 +188,9 @@ export class DownloadTask {
193
188
  try {
194
189
  const files = await fileIo.listFile(directory);
195
190
  for (const file of files) {
196
- if (file === '.' || file === '..') continue;
191
+ if (file === '.' || file === '..') {
192
+ continue;
193
+ }
197
194
 
198
195
  const filePath = `${directory}/${file}`;
199
196
  const stat = await fileIo.stat(filePath);
@@ -230,7 +227,7 @@ export class DownloadTask {
230
227
  let foundDiff = false;
231
228
  let foundBundlePatch = false;
232
229
  const copyList: Map<string, Array<any>> = new Map();
233
- await zip.decompressFile(params.targetFile, params.unzipDirectory);
230
+ await zlib.decompressFile(params.targetFile, params.unzipDirectory);
234
231
  const zipFile = await this.processUnzippedFiles(params.unzipDirectory);
235
232
  for (const entry of zipFile.entries) {
236
233
  const fn = entry.filename;
@@ -295,10 +292,6 @@ export class DownloadTask {
295
292
  throw error;
296
293
  }
297
294
  }
298
-
299
- if (fn !== '.DS_Store') {
300
- await zip.decompressFile(fn, params.unzipDirectory);
301
- }
302
295
  }
303
296
 
304
297
  if (!foundDiff) {
@@ -318,7 +311,7 @@ export class DownloadTask {
318
311
  let foundDiff = false;
319
312
  let foundBundlePatch = false;
320
313
  const copyList: Map<string, Array<any>> = new Map();
321
- await zip.decompressFile(params.targetFile, params.unzipDirectory);
314
+ await zlib.decompressFile(params.targetFile, params.unzipDirectory);
322
315
  const zipFile = await this.processUnzippedFiles(params.unzipDirectory);
323
316
  for (const entry of zipFile.entries) {
324
317
  const fn = entry.filename;
@@ -389,8 +382,6 @@ export class DownloadTask {
389
382
  }
390
383
  }
391
384
  }
392
-
393
- await zip.decompressFile(entry.filename, params.unzipDirectory);
394
385
  }
395
386
 
396
387
  if (!foundDiff) {
@@ -410,7 +401,9 @@ export class DownloadTask {
410
401
 
411
402
  const files = await fileIo.listFile(bundlePath);
412
403
  for (const file of files) {
413
- if (file === '.' || file === '..') continue;
404
+ if (file === '.' || file === '..') {
405
+ continue;
406
+ }
414
407
 
415
408
  const targets = copyList.get(file);
416
409
  if (targets) {
@@ -443,7 +436,9 @@ export class DownloadTask {
443
436
  try {
444
437
  const files = await fileIo.listFile(params.unzipDirectory);
445
438
  for (const file of files) {
446
- if (file.startsWith('.')) continue;
439
+ if (file.startsWith('.')) {
440
+ continue;
441
+ }
447
442
 
448
443
  const filePath = `${params.unzipDirectory}/${file}`;
449
444
  const stat = await fileIo.stat(filePath);
@@ -26,14 +26,13 @@ export class PushyFileJSBundleProvider extends JSBundleProvider {
26
26
  if (!this.path) {
27
27
  throw new JSBundleProviderError({
28
28
  whatHappened: 'No pushy bundle found. using default bundle',
29
+ howCanItBeFixed: ['']
29
30
  })
30
31
  }
31
32
  try {
32
- const status = await fs.access(this.path, fs.OpenMode.READ_ONLY);
33
- if (status) {
34
- return {
35
- filePath: this.path
36
- }
33
+ await fs.access(this.path, fs.OpenMode.READ_ONLY);
34
+ return {
35
+ filePath: this.path
37
36
  }
38
37
  } catch (error) {
39
38
  throw new JSBundleProviderError({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.35.1",
3
+ "version": "10.35.2",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {