react-native-update 10.35.0 → 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.
- package/harmony/pushy/hvigor-plugin.ts +41 -0
- package/harmony/pushy/oh-package-lock.json5 +5 -5
- package/harmony/pushy/oh-package.json5 +10 -10
- package/harmony/pushy/src/main/ets/DownloadTask.ts +16 -21
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +9 -6
- package/harmony/pushy/src/main/ets/UpdateContext.ts +3 -10
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
"lockfileVersion": 3,
|
|
7
7
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
8
8
|
"specifiers": {
|
|
9
|
-
"@rnoh/react-native-openharmony
|
|
9
|
+
"@rnoh/react-native-openharmony@^0.72.96": "@rnoh/react-native-openharmony@0.72.96"
|
|
10
10
|
},
|
|
11
11
|
"packages": {
|
|
12
|
-
"@rnoh/react-native-openharmony@0.72.
|
|
12
|
+
"@rnoh/react-native-openharmony@0.72.96": {
|
|
13
13
|
"name": "",
|
|
14
|
-
"version": "0.72.
|
|
15
|
-
"integrity": "sha512-
|
|
16
|
-
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.
|
|
14
|
+
"version": "0.72.96",
|
|
15
|
+
"integrity": "sha512-gBbm8LLyqi5UE7qHWdZYeQnjyncfEpCczKZUP/9M2U1Z7exR0Kya8PMKMwr1ta5ujy7w/hZVC2LomEV4QvBeqA==",
|
|
16
|
+
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.96.har",
|
|
17
17
|
"registryType": "ohpm"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
license: 'MIT',
|
|
3
|
+
types: '',
|
|
4
|
+
devDependencies: {},
|
|
5
|
+
name: 'pushy',
|
|
6
|
+
description: '',
|
|
7
|
+
main: 'index.ets',
|
|
8
|
+
version: '10.35.1',
|
|
9
|
+
dependencies: {
|
|
10
|
+
'@rnoh/react-native-openharmony': '^0.72.96',
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
modelVersion: '5.0.0',
|
|
13
13
|
}
|
|
@@ -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
|
|
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 === '..')
|
|
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
|
-
|
|
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 === '..')
|
|
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
|
|
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
|
|
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 === '..')
|
|
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('.'))
|
|
439
|
+
if (file.startsWith('.')) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
447
442
|
|
|
448
443
|
const filePath = `${params.unzipDirectory}/${file}`;
|
|
449
444
|
const stat = await fileIo.stat(filePath);
|
|
@@ -23,14 +23,17 @@ export class PushyFileJSBundleProvider extends JSBundleProvider {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async getBundle(): Promise<FileJSBundle> {
|
|
26
|
+
if (!this.path) {
|
|
27
|
+
throw new JSBundleProviderError({
|
|
28
|
+
whatHappened: 'No pushy bundle found. using default bundle',
|
|
29
|
+
howCanItBeFixed: ['']
|
|
30
|
+
})
|
|
31
|
+
}
|
|
26
32
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
filePath: this.path
|
|
31
|
-
}
|
|
33
|
+
await fs.access(this.path, fs.OpenMode.READ_ONLY);
|
|
34
|
+
return {
|
|
35
|
+
filePath: this.path
|
|
32
36
|
}
|
|
33
|
-
throw new Error('Update bundle not found');
|
|
34
37
|
} catch (error) {
|
|
35
38
|
throw new JSBundleProviderError({
|
|
36
39
|
whatHappened: `Couldn't load JSBundle from ${this.path}`,
|
|
@@ -189,18 +189,11 @@ export class UpdateContext {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
public
|
|
193
|
-
context: common.UIAbilityContext,
|
|
194
|
-
defaultAssetsUrl?: string,
|
|
195
|
-
) {
|
|
196
|
-
return new UpdateContext(context).getBundleUrl(defaultAssetsUrl);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
public getBundleUrl(defaultAssetsUrl?: string) {
|
|
192
|
+
public getBundleUrl() {
|
|
200
193
|
UpdateContext.isUsingBundleUrl = true;
|
|
201
194
|
const currentVersion = this.getCurrentVersion();
|
|
202
195
|
if (!currentVersion) {
|
|
203
|
-
return
|
|
196
|
+
return '';
|
|
204
197
|
}
|
|
205
198
|
if (!this.isFirstTime()) {
|
|
206
199
|
if (!this.preferences.getSync('firstTimeOk', true)) {
|
|
@@ -222,7 +215,7 @@ export class UpdateContext {
|
|
|
222
215
|
version = this.rollBack();
|
|
223
216
|
}
|
|
224
217
|
}
|
|
225
|
-
return
|
|
218
|
+
return '';
|
|
226
219
|
}
|
|
227
220
|
|
|
228
221
|
getPackageVersion(): string {
|