react-native-update-cli 2.9.3 → 2.9.5
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/api.js +23 -9
- package/lib/app.d.ts +5 -1
- package/lib/app.js +23 -13
- package/lib/bundle-pack.js +2 -1
- package/lib/diff.js +98 -17
- package/lib/module-manager.js +0 -3
- package/lib/package.js +7 -3
- package/lib/utils/http-helper.js +1 -1
- package/lib/utils/zip-entries.d.ts +1 -0
- package/lib/utils/zip-entries.js +61 -0
- package/lib/utils/zip-options.d.ts +9 -0
- package/lib/utils/zip-options.js +272 -0
- package/lib/versions.js +12 -12
- package/package.json +1 -1
- package/src/api.ts +32 -9
- package/src/app.ts +24 -11
- package/src/bundle-pack.ts +6 -1
- package/src/diff.ts +209 -15
- package/src/module-manager.ts +0 -4
- package/src/package.ts +5 -4
- package/src/utils/http-helper.ts +1 -1
- package/src/utils/zip-entries.ts +69 -0
- package/src/utils/zip-options.ts +173 -0
- package/src/versions.ts +12 -12
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
ZIP_ENTRY_SNIFF_BYTES: function() {
|
|
13
|
+
return ZIP_ENTRY_SNIFF_BYTES;
|
|
14
|
+
},
|
|
15
|
+
zipOptionsForManifestEntry: function() {
|
|
16
|
+
return zipOptionsForManifestEntry;
|
|
17
|
+
},
|
|
18
|
+
zipOptionsForPatchEntry: function() {
|
|
19
|
+
return zipOptionsForPatchEntry;
|
|
20
|
+
},
|
|
21
|
+
zipOptionsForPayloadEntry: function() {
|
|
22
|
+
return zipOptionsForPayloadEntry;
|
|
23
|
+
},
|
|
24
|
+
zipOptionsForPayloadFile: function() {
|
|
25
|
+
return zipOptionsForPayloadFile;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
29
|
+
const _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
36
|
+
if (typeof WeakMap !== "function") return null;
|
|
37
|
+
var cacheBabelInterop = new WeakMap();
|
|
38
|
+
var cacheNodeInterop = new WeakMap();
|
|
39
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
40
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
41
|
+
})(nodeInterop);
|
|
42
|
+
}
|
|
43
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
44
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
45
|
+
return obj;
|
|
46
|
+
}
|
|
47
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
48
|
+
return {
|
|
49
|
+
default: obj
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
53
|
+
if (cache && cache.has(obj)) {
|
|
54
|
+
return cache.get(obj);
|
|
55
|
+
}
|
|
56
|
+
var newObj = {
|
|
57
|
+
__proto__: null
|
|
58
|
+
};
|
|
59
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
|
+
for(var key in obj){
|
|
61
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
62
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
63
|
+
if (desc && (desc.get || desc.set)) {
|
|
64
|
+
Object.defineProperty(newObj, key, desc);
|
|
65
|
+
} else {
|
|
66
|
+
newObj[key] = obj[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
newObj.default = obj;
|
|
71
|
+
if (cache) {
|
|
72
|
+
cache.set(obj, newObj);
|
|
73
|
+
}
|
|
74
|
+
return newObj;
|
|
75
|
+
}
|
|
76
|
+
const ZIP_ENTRY_SNIFF_BYTES = 64;
|
|
77
|
+
const alreadyCompressedExtensions = new Set([
|
|
78
|
+
'.7z',
|
|
79
|
+
'.aab',
|
|
80
|
+
'.apk',
|
|
81
|
+
'.br',
|
|
82
|
+
'.bz2',
|
|
83
|
+
'.gif',
|
|
84
|
+
'.gz',
|
|
85
|
+
'.heic',
|
|
86
|
+
'.jpeg',
|
|
87
|
+
'.jpg',
|
|
88
|
+
'.lzma',
|
|
89
|
+
'.mp3',
|
|
90
|
+
'.mp4',
|
|
91
|
+
'.ogg',
|
|
92
|
+
'.png',
|
|
93
|
+
'.webm',
|
|
94
|
+
'.webp',
|
|
95
|
+
'.woff',
|
|
96
|
+
'.woff2',
|
|
97
|
+
'.xz',
|
|
98
|
+
'.zip',
|
|
99
|
+
'.zst'
|
|
100
|
+
]);
|
|
101
|
+
const HERMES_MAGIC = Buffer.from([
|
|
102
|
+
0xc6,
|
|
103
|
+
0x1f,
|
|
104
|
+
0xbc,
|
|
105
|
+
0x03,
|
|
106
|
+
0xc1,
|
|
107
|
+
0x03,
|
|
108
|
+
0x19,
|
|
109
|
+
0x1f
|
|
110
|
+
]);
|
|
111
|
+
const HERMES_DELTA_MAGIC = Buffer.from([
|
|
112
|
+
0x39,
|
|
113
|
+
0xe0,
|
|
114
|
+
0x43,
|
|
115
|
+
0xfc,
|
|
116
|
+
0x3e,
|
|
117
|
+
0xfc,
|
|
118
|
+
0xe6,
|
|
119
|
+
0xe0
|
|
120
|
+
]);
|
|
121
|
+
function startsWith(bytes, signature) {
|
|
122
|
+
return bytes.length >= signature.length && bytes.subarray(0, signature.length).equals(signature);
|
|
123
|
+
}
|
|
124
|
+
function hasHermesBytecodeMagic(bytes) {
|
|
125
|
+
return startsWith(bytes, HERMES_MAGIC) || startsWith(bytes, HERMES_DELTA_MAGIC);
|
|
126
|
+
}
|
|
127
|
+
function hasAlreadyCompressedMagic(bytes) {
|
|
128
|
+
if (bytes.length < 2) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (startsWith(bytes, Buffer.from([
|
|
132
|
+
0x89,
|
|
133
|
+
0x50,
|
|
134
|
+
0x4e,
|
|
135
|
+
0x47
|
|
136
|
+
]))) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (startsWith(bytes, Buffer.from([
|
|
140
|
+
0xff,
|
|
141
|
+
0xd8,
|
|
142
|
+
0xff
|
|
143
|
+
]))) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (startsWith(bytes, Buffer.from('GIF87a', 'ascii')) || startsWith(bytes, Buffer.from('GIF89a', 'ascii'))) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (bytes.length >= 12 && bytes.subarray(0, 4).equals(Buffer.from('RIFF', 'ascii')) && bytes.subarray(8, 12).equals(Buffer.from('WEBP', 'ascii'))) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (startsWith(bytes, Buffer.from([
|
|
153
|
+
0x50,
|
|
154
|
+
0x4b,
|
|
155
|
+
0x03,
|
|
156
|
+
0x04
|
|
157
|
+
])) || startsWith(bytes, Buffer.from([
|
|
158
|
+
0x50,
|
|
159
|
+
0x4b,
|
|
160
|
+
0x05,
|
|
161
|
+
0x06
|
|
162
|
+
])) || startsWith(bytes, Buffer.from([
|
|
163
|
+
0x50,
|
|
164
|
+
0x4b,
|
|
165
|
+
0x07,
|
|
166
|
+
0x08
|
|
167
|
+
]))) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
if (startsWith(bytes, Buffer.from([
|
|
171
|
+
0x1f,
|
|
172
|
+
0x8b
|
|
173
|
+
]))) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (startsWith(bytes, Buffer.from('BZh', 'ascii'))) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
if (startsWith(bytes, Buffer.from([
|
|
180
|
+
0xfd,
|
|
181
|
+
0x37,
|
|
182
|
+
0x7a,
|
|
183
|
+
0x58,
|
|
184
|
+
0x5a,
|
|
185
|
+
0x00
|
|
186
|
+
]))) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
if (startsWith(bytes, Buffer.from([
|
|
190
|
+
0x37,
|
|
191
|
+
0x7a,
|
|
192
|
+
0xbc,
|
|
193
|
+
0xaf,
|
|
194
|
+
0x27,
|
|
195
|
+
0x1c
|
|
196
|
+
]))) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (startsWith(bytes, Buffer.from([
|
|
200
|
+
0x28,
|
|
201
|
+
0xb5,
|
|
202
|
+
0x2f,
|
|
203
|
+
0xfd
|
|
204
|
+
]))) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (bytes.length >= 12 && bytes.subarray(4, 8).equals(Buffer.from('ftyp'))) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
if (startsWith(bytes, Buffer.from('OggS', 'ascii'))) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
if (startsWith(bytes, Buffer.from('ID3', 'ascii'))) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (bytes[0] === 0xff && bytes.length >= 2 && (bytes[1] & 0xe0) === 0xe0) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (startsWith(bytes, Buffer.from('wOFF', 'ascii')) || startsWith(bytes, Buffer.from('wOF2', 'ascii'))) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
function readFilePrefix(filePath) {
|
|
225
|
+
const buffer = Buffer.alloc(ZIP_ENTRY_SNIFF_BYTES);
|
|
226
|
+
const fd = _fs.openSync(filePath, 'r');
|
|
227
|
+
try {
|
|
228
|
+
const bytesRead = _fs.readSync(fd, buffer, 0, buffer.length, 0);
|
|
229
|
+
return buffer.subarray(0, bytesRead);
|
|
230
|
+
} finally{
|
|
231
|
+
_fs.closeSync(fd);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function zipOptionsForPatchEntry() {
|
|
235
|
+
return {
|
|
236
|
+
compress: false
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function zipOptionsForManifestEntry() {
|
|
240
|
+
return {
|
|
241
|
+
compress: false
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function zipOptionsForPayloadEntry(fileName, prefix) {
|
|
245
|
+
if (prefix && prefix.length > 0) {
|
|
246
|
+
if (hasHermesBytecodeMagic(prefix)) {
|
|
247
|
+
// Hermes bytecode is binary, but still benefits significantly from zip deflate.
|
|
248
|
+
return {
|
|
249
|
+
compress: true,
|
|
250
|
+
compressionLevel: 9
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (hasAlreadyCompressedMagic(prefix)) {
|
|
254
|
+
return {
|
|
255
|
+
compress: false
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const extension = _path.default.extname(fileName).toLowerCase();
|
|
260
|
+
if (alreadyCompressedExtensions.has(extension)) {
|
|
261
|
+
return {
|
|
262
|
+
compress: false
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
compress: true,
|
|
267
|
+
compressionLevel: 9
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function zipOptionsForPayloadFile(filePath, entryName = filePath) {
|
|
271
|
+
return zipOptionsForPayloadEntry(entryName, readFilePrefix(filePath));
|
|
272
|
+
}
|
package/lib/versions.js
CHANGED
|
@@ -361,12 +361,12 @@ const versionCommands = {
|
|
|
361
361
|
versions: async ({ options })=>{
|
|
362
362
|
const platform = await (0, _app.getPlatform)(options.platform);
|
|
363
363
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
364
|
-
await listVersions(appId);
|
|
364
|
+
await listVersions(String(appId));
|
|
365
365
|
},
|
|
366
366
|
update: async ({ options })=>{
|
|
367
367
|
const platform = await (0, _app.getPlatform)(options.platform);
|
|
368
368
|
const appId = options.appId || (await (0, _app.getSelectedApp)(platform)).appId;
|
|
369
|
-
let versionId = options.versionId || (await chooseVersion(appId)).id;
|
|
369
|
+
let versionId = options.versionId || (await chooseVersion(String(appId))).id;
|
|
370
370
|
if (versionId === 'null') {
|
|
371
371
|
versionId = undefined;
|
|
372
372
|
}
|
|
@@ -386,7 +386,7 @@ const versionCommands = {
|
|
|
386
386
|
throw new Error((0, _i18n.t)('rolloutRangeError'));
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
const allPkgs = await (0, _api.getAllPackages)(appId);
|
|
389
|
+
const allPkgs = await (0, _api.getAllPackages)(String(appId));
|
|
390
390
|
if (!allPkgs) {
|
|
391
391
|
throw new Error((0, _i18n.t)('noPackagesFound', {
|
|
392
392
|
appId
|
|
@@ -431,7 +431,7 @@ const versionCommands = {
|
|
|
431
431
|
}
|
|
432
432
|
} else {
|
|
433
433
|
if (!pkgId) {
|
|
434
|
-
pkgId = (await (0, _package.choosePackage)(appId)).id;
|
|
434
|
+
pkgId = (await (0, _package.choosePackage)(String(appId))).id;
|
|
435
435
|
}
|
|
436
436
|
if (!pkgId) {
|
|
437
437
|
throw new Error((0, _i18n.t)('packageIdRequired'));
|
|
@@ -448,14 +448,14 @@ const versionCommands = {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
await printDepsChangesForPublish({
|
|
451
|
-
appId,
|
|
452
|
-
versionId,
|
|
451
|
+
appId: String(appId),
|
|
452
|
+
versionId: String(versionId),
|
|
453
453
|
pkgs: pkgsToBind,
|
|
454
454
|
providedVersionDeps: options.versionDeps
|
|
455
455
|
});
|
|
456
456
|
await bindVersionToPackages({
|
|
457
|
-
appId,
|
|
458
|
-
versionId,
|
|
457
|
+
appId: String(appId),
|
|
458
|
+
versionId: String(versionId),
|
|
459
459
|
pkgs: pkgsToBind,
|
|
460
460
|
rollout,
|
|
461
461
|
dryRun: options.dryRun
|
|
@@ -464,12 +464,12 @@ const versionCommands = {
|
|
|
464
464
|
updateVersionInfo: async ({ options })=>{
|
|
465
465
|
const platform = await (0, _app.getPlatform)(options.platform);
|
|
466
466
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
467
|
-
const versionId = options.versionId || (await chooseVersion(appId)).id;
|
|
467
|
+
const versionId = options.versionId || (await chooseVersion(String(appId))).id;
|
|
468
468
|
const updateParams = {};
|
|
469
469
|
if (options.name) updateParams.name = options.name;
|
|
470
470
|
if (options.description) updateParams.description = options.description;
|
|
471
471
|
if (options.metaInfo) updateParams.metaInfo = options.metaInfo;
|
|
472
|
-
await (0, _api.put)(`/app/${appId}/version/${versionId}`, updateParams);
|
|
472
|
+
await (0, _api.put)(`/app/${String(appId)}/version/${versionId}`, updateParams);
|
|
473
473
|
console.log((0, _i18n.t)('operationSuccess'));
|
|
474
474
|
},
|
|
475
475
|
deleteVersion: async ({ options })=>{
|
|
@@ -480,10 +480,10 @@ const versionCommands = {
|
|
|
480
480
|
}
|
|
481
481
|
let versionId = options.versionId;
|
|
482
482
|
if (!versionId) {
|
|
483
|
-
versionId = (await chooseVersion(appId)).id;
|
|
483
|
+
versionId = (await chooseVersion(String(appId))).id;
|
|
484
484
|
}
|
|
485
485
|
try {
|
|
486
|
-
await (0, _api.doDelete)(`/app/${appId}/version/${versionId}`);
|
|
486
|
+
await (0, _api.doDelete)(`/app/${String(appId)}/version/${versionId}`);
|
|
487
487
|
console.log((0, _i18n.t)('deleteVersionSuccess', {
|
|
488
488
|
versionId
|
|
489
489
|
}));
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -75,10 +75,25 @@ export const closeSession = () => {
|
|
|
75
75
|
session = undefined;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
function createRequestError(error: unknown, requestUrl: string) {
|
|
79
|
+
const message =
|
|
80
|
+
typeof error === 'string'
|
|
81
|
+
? error
|
|
82
|
+
: error instanceof Error
|
|
83
|
+
? error.message
|
|
84
|
+
: String(error);
|
|
85
|
+
return new Error(`${message}\nURL: ${requestUrl}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
async function query(url: string, options: fetch.RequestInit) {
|
|
79
89
|
const baseUrl = await getBaseUrl;
|
|
80
90
|
const fullUrl = `${baseUrl}${url}`;
|
|
81
|
-
|
|
91
|
+
let resp: fetch.Response;
|
|
92
|
+
try {
|
|
93
|
+
resp = await fetch(fullUrl, options);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
throw createRequestError(error, fullUrl);
|
|
96
|
+
}
|
|
82
97
|
const text = await resp.text();
|
|
83
98
|
let json: any;
|
|
84
99
|
try {
|
|
@@ -86,11 +101,11 @@ async function query(url: string, options: fetch.RequestInit) {
|
|
|
86
101
|
} catch (e) {}
|
|
87
102
|
|
|
88
103
|
if (resp.status !== 200) {
|
|
89
|
-
const message = json?.message || resp.statusText
|
|
104
|
+
const message = json?.message || resp.statusText || `HTTP ${resp.status}`;
|
|
90
105
|
if (resp.status === 401) {
|
|
91
|
-
throw
|
|
106
|
+
throw createRequestError(t('loginExpired'), fullUrl);
|
|
92
107
|
}
|
|
93
|
-
throw
|
|
108
|
+
throw createRequestError(message, fullUrl);
|
|
94
109
|
}
|
|
95
110
|
return json;
|
|
96
111
|
}
|
|
@@ -195,13 +210,21 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
195
210
|
// contentType: 'application/octet-stream',
|
|
196
211
|
// });
|
|
197
212
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
213
|
+
let res: fetch.Response;
|
|
214
|
+
try {
|
|
215
|
+
res = await fetch(realUrl, {
|
|
216
|
+
method: 'POST',
|
|
217
|
+
body: form,
|
|
218
|
+
});
|
|
219
|
+
} catch (error) {
|
|
220
|
+
throw createRequestError(error, realUrl);
|
|
221
|
+
}
|
|
202
222
|
|
|
203
223
|
if (res.status > 299) {
|
|
204
|
-
throw
|
|
224
|
+
throw createRequestError(
|
|
225
|
+
`${res.status}: ${res.statusText || 'Upload failed'}`,
|
|
226
|
+
realUrl,
|
|
227
|
+
);
|
|
205
228
|
}
|
|
206
229
|
|
|
207
230
|
// const body = await response.json();
|
package/src/app.ts
CHANGED
|
@@ -27,17 +27,30 @@ export function assertPlatform(platform: string): Platform {
|
|
|
27
27
|
return platform as Platform;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function getSelectedApp(
|
|
30
|
+
export async function getSelectedApp(
|
|
31
|
+
platform: Platform,
|
|
32
|
+
): Promise<{ appId: string; appKey: string; platform: Platform }> {
|
|
31
33
|
assertPlatform(platform);
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
|
|
36
|
+
{};
|
|
37
|
+
try {
|
|
38
|
+
updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
|
|
39
|
+
} catch (e: any) {
|
|
40
|
+
if (e.code === 'ENOENT') {
|
|
41
|
+
throw new Error(t('appNotSelected', { platform }));
|
|
42
|
+
}
|
|
43
|
+
throw e;
|
|
35
44
|
}
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
45
|
+
const info = updateInfo[platform];
|
|
46
|
+
if (!info) {
|
|
38
47
|
throw new Error(t('appNotSelected', { platform }));
|
|
39
48
|
}
|
|
40
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
appId: String(info.appId),
|
|
51
|
+
appKey: info.appKey,
|
|
52
|
+
platform,
|
|
53
|
+
};
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
export async function listApp(platform: Platform | '' = '') {
|
|
@@ -125,10 +138,10 @@ export const appCommands = {
|
|
|
125
138
|
let updateInfo: Partial<
|
|
126
139
|
Record<Platform, { appId: number; appKey: string }>
|
|
127
140
|
> = {};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
try {
|
|
142
|
+
updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
|
|
143
|
+
} catch (e: any) {
|
|
144
|
+
if (e.code !== 'ENOENT') {
|
|
132
145
|
console.error(t('failedToParseUpdateJson'));
|
|
133
146
|
throw e;
|
|
134
147
|
}
|
|
@@ -138,7 +151,7 @@ export const appCommands = {
|
|
|
138
151
|
appId: id,
|
|
139
152
|
appKey,
|
|
140
153
|
};
|
|
141
|
-
fs.
|
|
154
|
+
await fs.promises.writeFile(
|
|
142
155
|
'update.json',
|
|
143
156
|
JSON.stringify(updateInfo, null, 4),
|
|
144
157
|
'utf8',
|
package/src/bundle-pack.ts
CHANGED
|
@@ -2,6 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import * as fs from 'fs-extra';
|
|
3
3
|
import { ZipFile as YazlZipFile } from 'yazl';
|
|
4
4
|
import { t } from './utils/i18n';
|
|
5
|
+
import { zipOptionsForPayloadFile } from './utils/zip-options';
|
|
5
6
|
|
|
6
7
|
const ignorePackingFileNames = [
|
|
7
8
|
'.',
|
|
@@ -32,7 +33,11 @@ export async function packBundle(dir: string, output: string): Promise<void> {
|
|
|
32
33
|
const fullPath = path.join(root, name);
|
|
33
34
|
const stat = fs.statSync(fullPath);
|
|
34
35
|
if (stat.isFile()) {
|
|
35
|
-
zipfile.addFile(
|
|
36
|
+
zipfile.addFile(
|
|
37
|
+
fullPath,
|
|
38
|
+
rel + name,
|
|
39
|
+
zipOptionsForPayloadFile(fullPath, rel + name),
|
|
40
|
+
);
|
|
36
41
|
} else if (stat.isDirectory()) {
|
|
37
42
|
addDirectory(fullPath, `${rel}${name}/`);
|
|
38
43
|
}
|