react-native-update-cli 2.29.0 → 2.29.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/account.js +2 -4
- package/lib/api.d.ts +1 -1
- package/lib/api.js +35 -73
- package/lib/app.js +13 -27
- package/lib/auto-update.d.ts +1 -1
- package/lib/auto-update.js +6 -16
- package/lib/bin.js +4 -6
- package/lib/bundle-pack.js +26 -60
- package/lib/bundle-runner.js +89 -119
- package/lib/bundle.js +18 -26
- package/lib/diff.js +43 -133
- package/lib/locales/en.d.ts +0 -10
- package/lib/locales/en.js +0 -10
- package/lib/locales/zh.d.ts +0 -10
- package/lib/locales/zh.js +0 -10
- package/lib/native-package.js +27 -99
- package/lib/package.d.ts +6 -1
- package/lib/package.js +56 -108
- package/lib/provider.js +3 -5
- package/lib/symbolicate.js +1 -16
- package/lib/utils/add-gitignore.js +0 -1
- package/lib/utils/app-info-parser/aab.d.ts +5 -22
- package/lib/utils/app-info-parser/aab.js +89 -226
- package/lib/utils/app-info-parser/apk.d.ts +12 -13
- package/lib/utils/app-info-parser/apk.js +28 -78
- package/lib/utils/app-info-parser/ipa.d.ts +2 -14
- package/lib/utils/app-info-parser/ipa.js +9 -70
- package/lib/utils/app-info-parser/resource-finder.d.ts +1 -34
- package/lib/utils/app-info-parser/resource-finder.js +95 -234
- package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
- package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
- package/lib/utils/app-info-parser/zip.d.ts +6 -24
- package/lib/utils/app-info-parser/zip.js +19 -86
- package/lib/utils/check-plugin.d.ts +7 -5
- package/lib/utils/check-plugin.js +15 -25
- package/lib/utils/dep-versions.d.ts +0 -6
- package/lib/utils/dep-versions.js +2 -27
- package/lib/utils/failure-fingerprint.js +3 -4
- package/lib/utils/fs-helpers.d.ts +18 -0
- package/lib/utils/fs-helpers.js +84 -0
- package/lib/utils/git.d.ts +0 -1
- package/lib/utils/git.js +0 -8
- package/lib/utils/hash.d.ts +3 -0
- package/lib/utils/hash.js +19 -0
- package/lib/utils/hbcTransform.d.ts +9 -2
- package/lib/utils/hbcTransform.js +41 -70
- package/lib/utils/hermes-base.d.ts +1 -5
- package/lib/utils/hermes-base.js +136 -196
- package/lib/utils/hermes-literals.d.ts +5 -3
- package/lib/utils/hermes-literals.js +30 -53
- package/lib/utils/hermes-raw.d.ts +7 -0
- package/lib/utils/hermes-raw.js +26 -9
- package/lib/utils/http-helper.d.ts +0 -1
- package/lib/utils/http-helper.js +0 -20
- package/lib/utils/i18n.js +0 -2
- package/lib/utils/index.d.ts +5 -19
- package/lib/utils/index.js +95 -189
- package/lib/utils/latest-version.d.ts +19 -0
- package/lib/utils/latest-version.js +137 -0
- package/lib/utils/options.d.ts +2 -1
- package/lib/utils/options.js +5 -7
- package/lib/utils/runtime.d.ts +1 -1
- package/lib/utils/runtime.js +2 -10
- package/lib/utils/upload-request.d.ts +33 -0
- package/lib/utils/upload-request.js +120 -0
- package/lib/utils/zip-entries.d.ts +23 -0
- package/lib/utils/zip-entries.js +130 -139
- package/lib/utils/zip-options.js +29 -56
- package/lib/utils/zip-range.js +29 -69
- package/lib/utils/zip-raw-writer.js +6 -5
- package/lib/versions.d.ts +5 -0
- package/lib/versions.js +86 -153
- package/package.json +1 -9
- package/lib/utils/app-info-parser/app.d.ts +0 -4
- package/lib/utils/app-info-parser/app.js +0 -10
- package/lib/utils/app-info-parser/index.d.ts +0 -16
- package/lib/utils/app-info-parser/index.js +0 -46
- package/lib/utils/app-info-parser/utils.d.ts +0 -31
- package/lib/utils/app-info-parser/utils.js +0 -135
- package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
- package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
- package/lib/utils/latest-version/index.d.ts +0 -149
- package/lib/utils/latest-version/index.js +0 -326
- package/lib/utils/plugin-config.d.ts +0 -9
- package/lib/utils/plugin-config.js +0 -61
package/lib/diff.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -39,15 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
6
|
exports.diffCommands = exports.readEntry = exports.enumZipEntries = void 0;
|
|
40
7
|
exports.zipEntryContentKey = zipEntryContentKey;
|
|
41
8
|
exports.zipEntriesHaveSameContent = zipEntriesHaveSameContent;
|
|
42
|
-
const
|
|
43
|
-
const fs = __importStar(require("fs-extra"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
44
10
|
const global_dirs_1 = require("global-dirs");
|
|
45
11
|
const os_1 = __importDefault(require("os"));
|
|
46
12
|
const path_1 = __importDefault(require("path"));
|
|
47
|
-
const yazl_1 = require("yazl");
|
|
48
13
|
const native_package_1 = require("./native-package");
|
|
49
14
|
const utils_1 = require("./utils");
|
|
50
15
|
const constants_1 = require("./utils/constants");
|
|
16
|
+
const hash_1 = require("./utils/hash");
|
|
51
17
|
const hbcTransform_1 = require("./utils/hbcTransform");
|
|
52
18
|
const i18n_1 = require("./utils/i18n");
|
|
53
19
|
const zip_entries_1 = require("./utils/zip-entries");
|
|
@@ -83,43 +49,12 @@ function basename(fn) {
|
|
|
83
49
|
const m = /^(.+\/)[^/]+\/?$/.exec(fn);
|
|
84
50
|
return m?.[1];
|
|
85
51
|
}
|
|
86
|
-
function createOutputZip(output) {
|
|
87
|
-
fs.ensureDirSync(path_1.default.dirname(output));
|
|
88
|
-
const zipfile = new yazl_1.ZipFile();
|
|
89
|
-
const writeStream = fs.createWriteStream(output);
|
|
90
|
-
const writePromise = new Promise((resolve, reject) => {
|
|
91
|
-
zipfile.outputStream.on('error', reject);
|
|
92
|
-
// without this, a full disk / read-only target left the promise pending
|
|
93
|
-
writeStream.on('error', reject);
|
|
94
|
-
zipfile.outputStream.pipe(writeStream).on('close', () => {
|
|
95
|
-
resolve(void 0);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
// 失败时释放输出 fd 并删掉半成品,避免残留一个截断的 patch 包
|
|
99
|
-
const abort = async () => {
|
|
100
|
-
writePromise.catch(() => { });
|
|
101
|
-
zipfile.outputStream.unpipe(writeStream);
|
|
102
|
-
// yazl 的 outputStream 类型声明缺 destroy,运行时是 PassThrough
|
|
103
|
-
zipfile.outputStream.destroy();
|
|
104
|
-
if (!writeStream.closed) {
|
|
105
|
-
// 等 fd 真正关闭再删文件,避免 Windows 上删除被占用文件失败
|
|
106
|
-
await new Promise((resolve) => {
|
|
107
|
-
writeStream.once('close', () => resolve());
|
|
108
|
-
if (!writeStream.destroyed) {
|
|
109
|
-
writeStream.destroy();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
await fs.rm(output, { force: true });
|
|
114
|
-
};
|
|
115
|
-
return { zipfile, writePromise, abort };
|
|
116
|
-
}
|
|
117
52
|
/**
|
|
118
53
|
* 打开输出包,执行 build 填充条目并返回 manifest,最后写入 __diff.json
|
|
119
54
|
* 收尾。build 或收尾任何一步失败都会关闭输出流、删除半成品并重新抛出。
|
|
120
55
|
*/
|
|
121
56
|
async function writeDiffZip(output, build) {
|
|
122
|
-
const { zipfile, writePromise, abort } = createOutputZip(output);
|
|
57
|
+
const { zipfile, writePromise, abort } = (0, zip_entries_1.createOutputZip)(output);
|
|
123
58
|
try {
|
|
124
59
|
const manifest = await build(zipfile);
|
|
125
60
|
await finishDiffZip(zipfile, writePromise, manifest);
|
|
@@ -141,32 +76,25 @@ function reportDiffPhase(options, metric) {
|
|
|
141
76
|
}
|
|
142
77
|
}
|
|
143
78
|
const bundleSourceSize = (source) => source.kind === 'buffer' ? source.data.length : source.size;
|
|
144
|
-
const bundleSourceBuffer = async (source) => source.kind === 'buffer' ? source.data :
|
|
79
|
+
const bundleSourceBuffer = async (source) => source.kind === 'buffer' ? source.data : fs_1.default.promises.readFile(source.path);
|
|
145
80
|
async function bundleSourceFile(source, outputPath) {
|
|
146
81
|
if (source.kind === 'file') {
|
|
147
82
|
return source.path;
|
|
148
83
|
}
|
|
149
|
-
await
|
|
84
|
+
await fs_1.default.promises.writeFile(outputPath, source.data);
|
|
150
85
|
return outputPath;
|
|
151
86
|
}
|
|
152
|
-
async function hashFile(filePath) {
|
|
153
|
-
const hash = (0, node_crypto_1.createHash)('sha256');
|
|
154
|
-
for await (const chunk of fs.createReadStream(filePath)) {
|
|
155
|
-
hash.update(chunk);
|
|
156
|
-
}
|
|
157
|
-
return hash.digest('hex');
|
|
158
|
-
}
|
|
159
87
|
async function filesEqual(leftPath, rightPath) {
|
|
160
88
|
const [leftStat, rightStat] = await Promise.all([
|
|
161
|
-
|
|
162
|
-
|
|
89
|
+
fs_1.default.promises.stat(leftPath),
|
|
90
|
+
fs_1.default.promises.stat(rightPath),
|
|
163
91
|
]);
|
|
164
92
|
if (leftStat.size !== rightStat.size) {
|
|
165
93
|
return false;
|
|
166
94
|
}
|
|
167
95
|
const [leftHash, rightHash] = await Promise.all([
|
|
168
|
-
|
|
169
|
-
|
|
96
|
+
(0, hash_1.sha256File)(leftPath),
|
|
97
|
+
(0, hash_1.sha256File)(rightPath),
|
|
170
98
|
]);
|
|
171
99
|
return leftHash === rightHash;
|
|
172
100
|
}
|
|
@@ -182,7 +110,7 @@ async function buildStreamBundlePatch(originSource, newSource, options, workRoot
|
|
|
182
110
|
if (!diffStreamFn || !patchStreamFn) {
|
|
183
111
|
throw new Error('stream diff requires diffStream/patchStream from node-hdiffpatch');
|
|
184
112
|
}
|
|
185
|
-
const tempRoot =
|
|
113
|
+
const tempRoot = fs_1.default.mkdtempSync(path_1.default.join(workRoot, 'stream-'));
|
|
186
114
|
const inputBytes = bundleSourceSize(originSource) + bundleSourceSize(newSource);
|
|
187
115
|
const extractionDurationMs = (originSource.kind === 'file' ? originSource.materializeDurationMs : 0) +
|
|
188
116
|
(newSource.kind === 'file' ? newSource.materializeDurationMs : 0);
|
|
@@ -206,12 +134,13 @@ async function buildStreamBundlePatch(originSource, newSource, options, workRoot
|
|
|
206
134
|
const rawPatchFile = path_1.default.join(tempRoot, 'patch-raw.bin');
|
|
207
135
|
await diffStreamFn(rawOldFile, rawNewFile, rawPatchFile);
|
|
208
136
|
let patchFile = rawPatchFile;
|
|
209
|
-
let patchBytes = (await
|
|
137
|
+
let patchBytes = (await fs_1.default.promises.stat(rawPatchFile)).size;
|
|
210
138
|
let chosenPair = null;
|
|
211
139
|
if (pair) {
|
|
212
140
|
const transformedPatchFile = path_1.default.join(tempRoot, 'patch-transformed.bin');
|
|
213
141
|
await diffStreamFn(transformedOldFile, transformedNewFile, transformedPatchFile);
|
|
214
|
-
const transformedPatchBytes = (await
|
|
142
|
+
const transformedPatchBytes = (await fs_1.default.promises.stat(transformedPatchFile))
|
|
143
|
+
.size;
|
|
215
144
|
const metaOverhead = Buffer.byteLength(JSON.stringify(pair.meta));
|
|
216
145
|
if (transformedPatchBytes + metaOverhead < patchBytes) {
|
|
217
146
|
patchFile = transformedPatchFile;
|
|
@@ -263,16 +192,32 @@ async function buildStreamBundlePatch(originSource, newSource, options, workRoot
|
|
|
263
192
|
...(chosenPair ? { hbcTransform: chosenPair.meta } : {}),
|
|
264
193
|
};
|
|
265
194
|
}
|
|
195
|
+
/** origin 与 new 中较大者达到流式阈值时走流式 diff */
|
|
196
|
+
function exceedsStreamThreshold(options, originSource, newSize) {
|
|
197
|
+
return (!!options.streamThresholdBytes &&
|
|
198
|
+
!!originSource &&
|
|
199
|
+
Math.max(bundleSourceSize(originSource), newSize) >=
|
|
200
|
+
options.streamThresholdBytes);
|
|
201
|
+
}
|
|
202
|
+
/** 把 zip 条目落盘到 workRoot 下的临时目录,作为文件型 BundleSource */
|
|
203
|
+
async function materializeEntry(entry, zipFile, workRoot, prefix) {
|
|
204
|
+
const filePath = path_1.default.join(fs_1.default.mkdtempSync(path_1.default.join(workRoot, prefix)), 'bundle.bin');
|
|
205
|
+
const startedAt = performance.now();
|
|
206
|
+
await (0, zip_entries_1.writeEntry)(entry, zipFile, filePath);
|
|
207
|
+
return {
|
|
208
|
+
kind: 'file',
|
|
209
|
+
path: filePath,
|
|
210
|
+
size: entry.uncompressedSize,
|
|
211
|
+
materializeDurationMs: performance.now() - startedAt,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
266
214
|
/**
|
|
267
215
|
* 生成 bundle patch:默认现状路径;开启 hbcTransform 时对 Hermes bundle
|
|
268
216
|
* 做双候选择优(baseline vs 变换域 + 元数据开销),且变换候选必须通过
|
|
269
217
|
* 本地 round-trip 还原自检才会被采用——收益永不为负,未知格式天然安全。
|
|
270
218
|
*/
|
|
271
219
|
async function buildBundlePatch(diffFn, originSource, newSource, options, workRoot) {
|
|
272
|
-
if (options
|
|
273
|
-
originSource &&
|
|
274
|
-
Math.max(bundleSourceSize(originSource), bundleSourceSize(newSource)) >=
|
|
275
|
-
options.streamThresholdBytes) {
|
|
220
|
+
if (exceedsStreamThreshold(options, originSource, bundleSourceSize(newSource))) {
|
|
276
221
|
return buildStreamBundlePatch(originSource, newSource, options, workRoot);
|
|
277
222
|
}
|
|
278
223
|
const [originBuffer, newBuffer] = await Promise.all([
|
|
@@ -316,26 +261,9 @@ async function buildBundlePatch(diffFn, originSource, newSource, options, workRo
|
|
|
316
261
|
}
|
|
317
262
|
}
|
|
318
263
|
async function addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource, bundleOptions, hbcTransformMetas, workRoot) {
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
bundleOptions.streamThresholdBytes;
|
|
323
|
-
let newSource;
|
|
324
|
-
if (shouldStream) {
|
|
325
|
-
const nextRoot = fs.mkdtempSync(path_1.default.join(workRoot, 'next-'));
|
|
326
|
-
const nextPath = path_1.default.join(nextRoot, 'bundle.bin');
|
|
327
|
-
const startedAt = performance.now();
|
|
328
|
-
await (0, zip_entries_1.writeEntry)(entry, nextZipfile, nextPath);
|
|
329
|
-
newSource = {
|
|
330
|
-
kind: 'file',
|
|
331
|
-
path: nextPath,
|
|
332
|
-
size: entry.uncompressedSize,
|
|
333
|
-
materializeDurationMs: performance.now() - startedAt,
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
newSource = { kind: 'buffer', data: await (0, zip_entries_1.readEntry)(entry, nextZipfile) };
|
|
338
|
-
}
|
|
264
|
+
const newSource = exceedsStreamThreshold(bundleOptions, originSource, entry.uncompressedSize)
|
|
265
|
+
? await materializeEntry(entry, nextZipfile, workRoot, 'next-')
|
|
266
|
+
: { kind: 'buffer', data: await (0, zip_entries_1.readEntry)(entry, nextZipfile) };
|
|
339
267
|
const { patch, hbcTransform } = await buildBundlePatch(diffFn, originSource, newSource, bundleOptions, workRoot);
|
|
340
268
|
const patchEntryName = `${entry.fileName}.patch`;
|
|
341
269
|
if (hbcTransform) {
|
|
@@ -352,33 +280,15 @@ async function readOriginBundleSource(entry, zipFile, bundleOptions, workRoot) {
|
|
|
352
280
|
if (!bundleOptions.streamThresholdBytes) {
|
|
353
281
|
return { kind: 'buffer', data: await (0, zip_entries_1.readEntry)(entry, zipFile) };
|
|
354
282
|
}
|
|
355
|
-
|
|
356
|
-
const originPath = path_1.default.join(originRoot, 'bundle.bin');
|
|
357
|
-
const startedAt = performance.now();
|
|
358
|
-
await (0, zip_entries_1.writeEntry)(entry, zipFile, originPath);
|
|
359
|
-
return {
|
|
360
|
-
kind: 'file',
|
|
361
|
-
path: originPath,
|
|
362
|
-
size: entry.uncompressedSize,
|
|
363
|
-
materializeDurationMs: performance.now() - startedAt,
|
|
364
|
-
};
|
|
283
|
+
return materializeEntry(entry, zipFile, workRoot, 'origin-');
|
|
365
284
|
}
|
|
366
285
|
async function addFileFromZipEntry(zipfile, entry, nextZipfile) {
|
|
367
286
|
const entryPrefix = await (0, zip_entries_1.readEntryPrefix)(entry, nextZipfile, zip_options_1.ZIP_ENTRY_SNIFF_BYTES);
|
|
287
|
+
const readStream = await (0, zip_entries_1.openEntryStream)(entry, nextZipfile);
|
|
368
288
|
await new Promise((resolve, reject) => {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
if (!readStream) {
|
|
374
|
-
return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
375
|
-
}
|
|
376
|
-
zipfile.addReadStream(readStream, entry.fileName, (0, zip_options_1.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
|
|
377
|
-
readStream.on('error', reject);
|
|
378
|
-
readStream.on('end', () => {
|
|
379
|
-
resolve(void 0);
|
|
380
|
-
});
|
|
381
|
-
});
|
|
289
|
+
zipfile.addReadStream(readStream, entry.fileName, (0, zip_options_1.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
|
|
290
|
+
readStream.on('error', reject);
|
|
291
|
+
readStream.on('end', () => resolve());
|
|
382
292
|
});
|
|
383
293
|
}
|
|
384
294
|
function finishDiffZip(zipfile, writePromise, manifest) {
|
|
@@ -642,7 +552,7 @@ function diffArgsCheck(args, options, diffFnName) {
|
|
|
642
552
|
const createDiffCommand = ({ diffFnName, target }) => async ({ args, options }) => {
|
|
643
553
|
const { origin, next, realOutput, diffFn } = diffArgsCheck(args, options, diffFnName);
|
|
644
554
|
const bundleOptions = resolveBundleDiffOptions(options);
|
|
645
|
-
const workRoot =
|
|
555
|
+
const workRoot = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-bundle-diff-'));
|
|
646
556
|
try {
|
|
647
557
|
if (target.kind === 'ppk') {
|
|
648
558
|
await diffFromPPK(origin, next, realOutput, diffFn, bundleOptions, workRoot);
|
|
@@ -652,7 +562,7 @@ const createDiffCommand = ({ diffFnName, target }) => async ({ args, options })
|
|
|
652
562
|
}
|
|
653
563
|
}
|
|
654
564
|
finally {
|
|
655
|
-
|
|
565
|
+
fs_1.default.rmSync(workRoot, { recursive: true, force: true });
|
|
656
566
|
}
|
|
657
567
|
console.log((0, i18n_1.t)('diffPackageGenerated', { output: realOutput }));
|
|
658
568
|
};
|
package/lib/locales/en.d.ts
CHANGED
|
@@ -3,18 +3,10 @@ declare const _default: {
|
|
|
3
3
|
accountUnknown: string;
|
|
4
4
|
accountNoExpiry: string;
|
|
5
5
|
accountRenewalWarning: string;
|
|
6
|
-
accountLookupFailed: string;
|
|
7
6
|
addedToGitignore: string;
|
|
8
7
|
androidCrunchPngsWarning: string;
|
|
9
|
-
aabOpenApksFailed: string;
|
|
10
|
-
aabReadUniversalApkFailed: string;
|
|
11
8
|
aabUniversalApkNotFound: string;
|
|
12
9
|
aabBundletoolDownloadHint: string;
|
|
13
|
-
aabManifestNotFound: string;
|
|
14
|
-
aabParseResourcesWarning: string;
|
|
15
|
-
aabParseFailed: string;
|
|
16
|
-
aabParseManifestError: string;
|
|
17
|
-
aabParseResourcesError: string;
|
|
18
10
|
appId: string;
|
|
19
11
|
appIdMismatchApk: string;
|
|
20
12
|
appIdMismatchApp: string;
|
|
@@ -86,7 +78,6 @@ declare const _default: {
|
|
|
86
78
|
pausedStatus: string;
|
|
87
79
|
platform: string;
|
|
88
80
|
platformQuestion: string;
|
|
89
|
-
pluginDetectionError: string;
|
|
90
81
|
pluginDetected: string;
|
|
91
82
|
publishUsage: string;
|
|
92
83
|
sourceMapNotFound: string;
|
|
@@ -130,7 +121,6 @@ declare const _default: {
|
|
|
130
121
|
unnamed: string;
|
|
131
122
|
dryRun: string;
|
|
132
123
|
usingCustomVersion: string;
|
|
133
|
-
confirmDeletePackage: string;
|
|
134
124
|
deletePackageSuccess: string;
|
|
135
125
|
deletePackagesSuccess: string;
|
|
136
126
|
deletePackageError: string;
|
package/lib/locales/en.js
CHANGED
|
@@ -5,18 +5,10 @@ exports.default = {
|
|
|
5
5
|
accountUnknown: 'Unknown',
|
|
6
6
|
accountNoExpiry: 'No expiry specified',
|
|
7
7
|
accountRenewalWarning: '[Notice] Your Pushy paid plan expires in {{days}} days. Renew soon to avoid service disruption: {{url}}',
|
|
8
|
-
accountLookupFailed: '[Warning] Unable to retrieve account information. Continuing with the command.',
|
|
9
8
|
addedToGitignore: 'Added {{line}} to .gitignore',
|
|
10
9
|
androidCrunchPngsWarning: 'The crunchPngs option of android seems not disabled (Please ignore this warning if already disabled), which may cause abnormal consumption of mobile network traffic. Please refer to https://cresc.dev/docs/getting-started#disable-crunchpngs-on-android \n',
|
|
11
|
-
aabOpenApksFailed: 'Failed to open generated .apks file',
|
|
12
|
-
aabReadUniversalApkFailed: 'Failed to read universal.apk',
|
|
13
10
|
aabUniversalApkNotFound: 'universal.apk not found in generated .apks',
|
|
14
11
|
aabBundletoolDownloadHint: 'bundletool not found. Downloading node-bundletool via npx (first run may take a while).',
|
|
15
|
-
aabManifestNotFound: "AndroidManifest.xml can't be found in AAB base/manifest/",
|
|
16
|
-
aabParseResourcesWarning: '[Warning] Failed to parse resources.arsc: {{error}}',
|
|
17
|
-
aabParseFailed: 'Failed to parse AAB: {{error}}',
|
|
18
|
-
aabParseManifestError: 'Parse AndroidManifest.xml error: {{error}}',
|
|
19
|
-
aabParseResourcesError: 'Parser resources.arsc error: {{error}}',
|
|
20
12
|
appId: 'App ID',
|
|
21
13
|
appIdMismatchApk: 'App ID mismatch! Current APK: {{appIdInPkg}}, current {{- source}}: {{appId}}',
|
|
22
14
|
appIdMismatchApp: 'App ID mismatch! Current APP: {{appIdInPkg}}, current {{- source}}: {{appId}}',
|
|
@@ -94,7 +86,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
94
86
|
pausedStatus: '(Paused)',
|
|
95
87
|
platform: 'Platform',
|
|
96
88
|
platformQuestion: 'Platform(ios/android/harmony):',
|
|
97
|
-
pluginDetectionError: 'error while detecting {{name}} plugin: {{error}}',
|
|
98
89
|
pluginDetected: 'detected {{name}} plugin',
|
|
99
90
|
publishUsage: 'Usage: pushy publish <ppk file> --platform ios|android|harmony',
|
|
100
91
|
sourceMapNotFound: 'Source map not found: {{path}}',
|
|
@@ -138,7 +129,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
138
129
|
unnamed: '(Unnamed)',
|
|
139
130
|
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
|
|
140
131
|
usingCustomVersion: 'Using custom version: {{version}}',
|
|
141
|
-
confirmDeletePackage: 'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
|
|
142
132
|
deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
|
|
143
133
|
deletePackagesSuccess: 'Deleted {{count}} native packages: {{packageIds}}',
|
|
144
134
|
deletePackageError: 'Failed to delete native package {{packageId}}: {{error}}',
|
package/lib/locales/zh.d.ts
CHANGED
|
@@ -3,18 +3,10 @@ declare const _default: {
|
|
|
3
3
|
accountUnknown: string;
|
|
4
4
|
accountNoExpiry: string;
|
|
5
5
|
accountRenewalWarning: string;
|
|
6
|
-
accountLookupFailed: string;
|
|
7
6
|
addedToGitignore: string;
|
|
8
7
|
androidCrunchPngsWarning: string;
|
|
9
|
-
aabOpenApksFailed: string;
|
|
10
|
-
aabReadUniversalApkFailed: string;
|
|
11
8
|
aabUniversalApkNotFound: string;
|
|
12
9
|
aabBundletoolDownloadHint: string;
|
|
13
|
-
aabManifestNotFound: string;
|
|
14
|
-
aabParseResourcesWarning: string;
|
|
15
|
-
aabParseFailed: string;
|
|
16
|
-
aabParseManifestError: string;
|
|
17
|
-
aabParseResourcesError: string;
|
|
18
10
|
appId: string;
|
|
19
11
|
appIdMismatchApk: string;
|
|
20
12
|
appIdMismatchApp: string;
|
|
@@ -86,7 +78,6 @@ declare const _default: {
|
|
|
86
78
|
pausedStatus: string;
|
|
87
79
|
platform: string;
|
|
88
80
|
platformQuestion: string;
|
|
89
|
-
pluginDetectionError: string;
|
|
90
81
|
pluginDetected: string;
|
|
91
82
|
sourceMapNotFound: string;
|
|
92
83
|
sourceMapMissingWarning: string;
|
|
@@ -130,7 +121,6 @@ declare const _default: {
|
|
|
130
121
|
unnamed: string;
|
|
131
122
|
dryRun: string;
|
|
132
123
|
usingCustomVersion: string;
|
|
133
|
-
confirmDeletePackage: string;
|
|
134
124
|
deletePackageSuccess: string;
|
|
135
125
|
deletePackagesSuccess: string;
|
|
136
126
|
deletePackageError: string;
|
package/lib/locales/zh.js
CHANGED
|
@@ -5,18 +5,10 @@ exports.default = {
|
|
|
5
5
|
accountUnknown: '未知',
|
|
6
6
|
accountNoExpiry: '未设置有效期',
|
|
7
7
|
accountRenewalWarning: '[注意] 您的 Pushy 付费套餐将在 {{days}} 天内到期,请及时续费,以免影响服务:{{url}}',
|
|
8
|
-
accountLookupFailed: '[警告] 暂时无法获取账号信息,将继续执行命令。',
|
|
9
8
|
addedToGitignore: '已将 {{line}} 添加到 .gitignore',
|
|
10
9
|
androidCrunchPngsWarning: 'android 的 crunchPngs 选项似乎尚未禁用(如已禁用则请忽略此提示),这可能导致热更包体积异常增大,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n',
|
|
11
|
-
aabOpenApksFailed: '无法打开生成的 .apks 文件',
|
|
12
|
-
aabReadUniversalApkFailed: '无法读取 universal.apk',
|
|
13
10
|
aabUniversalApkNotFound: '在生成的 .apks 中未找到 universal.apk',
|
|
14
11
|
aabBundletoolDownloadHint: '未找到 bundletool,正在通过 npx 下载 node-bundletool(首次下载可能需要一些时间)。',
|
|
15
|
-
aabManifestNotFound: '在 AAB 的 base/manifest/ 中找不到 AndroidManifest.xml',
|
|
16
|
-
aabParseResourcesWarning: '[警告] 解析 resources.arsc 失败:{{error}}',
|
|
17
|
-
aabParseFailed: '解析 AAB 失败:{{error}}',
|
|
18
|
-
aabParseManifestError: '解析 AndroidManifest.xml 出错:{{error}}',
|
|
19
|
-
aabParseResourcesError: '解析 resources.arsc 出错:{{error}}',
|
|
20
12
|
appId: '应用 id',
|
|
21
13
|
appIdMismatchApk: 'appId不匹配!当前apk: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
|
|
22
14
|
appIdMismatchApp: 'appId不匹配!当前app: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
|
|
@@ -94,7 +86,6 @@ exports.default = {
|
|
|
94
86
|
pausedStatus: '(已暂停)',
|
|
95
87
|
platform: '平台',
|
|
96
88
|
platformQuestion: '平台(ios/android/harmony):',
|
|
97
|
-
pluginDetectionError: '检测 {{name}} 插件时出错:{{error}}',
|
|
98
89
|
pluginDetected: '检测到 {{name}} 插件',
|
|
99
90
|
sourceMapNotFound: '找不到 source map:{{path}}',
|
|
100
91
|
sourceMapMissingWarning: '本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
|
|
@@ -138,7 +129,6 @@ exports.default = {
|
|
|
138
129
|
unnamed: '(未命名)',
|
|
139
130
|
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
|
|
140
131
|
usingCustomVersion: '使用自定义版本:{{version}}',
|
|
141
|
-
confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
|
|
142
132
|
deletePackageSuccess: '原生包 {{packageId}} 删除成功',
|
|
143
133
|
deletePackagesSuccess: '已删除 {{count}} 个原生包:{{packageIds}}',
|
|
144
134
|
deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
|
package/lib/native-package.js
CHANGED
|
@@ -1,48 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
6
|
exports.resolveNativePackageEntry = resolveNativePackageEntry;
|
|
40
7
|
exports.createSlimNativePackage = createSlimNativePackage;
|
|
41
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
42
9
|
const os_1 = __importDefault(require("os"));
|
|
43
10
|
const path_1 = __importDefault(require("path"));
|
|
44
11
|
const yauzl_1 = require("yauzl");
|
|
45
|
-
const
|
|
12
|
+
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
13
|
+
const zip_entries_1 = require("./utils/zip-entries");
|
|
46
14
|
const zip_raw_writer_1 = require("./utils/zip-raw-writer");
|
|
47
15
|
const nativePackageRules = {
|
|
48
16
|
android: {
|
|
@@ -97,16 +65,11 @@ class RawCopySink {
|
|
|
97
65
|
constructor(output) {
|
|
98
66
|
this.writer = new zip_raw_writer_1.RawZipWriter(output);
|
|
99
67
|
}
|
|
100
|
-
copyEntry(sourceZip, entry) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (error || !readStream) {
|
|
104
|
-
reject(error ?? new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.writer.addRawEntry(entry, readStream).then(resolve, reject);
|
|
108
|
-
});
|
|
68
|
+
async copyEntry(sourceZip, entry) {
|
|
69
|
+
const readStream = await (0, zip_entries_1.openEntryStream)(entry, sourceZip, {
|
|
70
|
+
decodeFileData: false,
|
|
109
71
|
});
|
|
72
|
+
await this.writer.addRawEntry(entry, readStream);
|
|
110
73
|
}
|
|
111
74
|
addFile(filePath, fileName, like) {
|
|
112
75
|
// a nested slim archive is a zip of deflated entries: storing it as-is
|
|
@@ -123,48 +86,32 @@ class RawCopySink {
|
|
|
123
86
|
/** Re-deflates every kept entry through yazl; only for sources that need zip64. */
|
|
124
87
|
class RepackSink {
|
|
125
88
|
output;
|
|
126
|
-
outputZip = new yazl_1.ZipFile();
|
|
127
|
-
writePromise;
|
|
128
89
|
constructor(output) {
|
|
129
|
-
this.output = output;
|
|
130
|
-
this.writePromise = new Promise((resolve, reject) => {
|
|
131
|
-
this.outputZip.outputStream.once('error', reject);
|
|
132
|
-
this.outputZip.outputStream
|
|
133
|
-
.pipe(fs.createWriteStream(output))
|
|
134
|
-
.once('error', reject)
|
|
135
|
-
.once('close', () => resolve());
|
|
136
|
-
});
|
|
90
|
+
this.output = (0, zip_entries_1.createOutputZip)(output);
|
|
137
91
|
}
|
|
138
|
-
copyEntry(sourceZip, entry) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
readStream.once('end', () => resolve());
|
|
147
|
-
this.outputZip.addReadStream(readStream, entry.fileName, {
|
|
148
|
-
compress: entry.compressionMethod !== 0,
|
|
149
|
-
mtime: entry.getLastModDate(),
|
|
150
|
-
});
|
|
92
|
+
async copyEntry(sourceZip, entry) {
|
|
93
|
+
const readStream = await (0, zip_entries_1.openEntryStream)(entry, sourceZip);
|
|
94
|
+
await new Promise((resolve, reject) => {
|
|
95
|
+
readStream.once('error', reject);
|
|
96
|
+
readStream.once('end', () => resolve());
|
|
97
|
+
this.output.zipfile.addReadStream(readStream, entry.fileName, {
|
|
98
|
+
compress: entry.compressionMethod !== 0,
|
|
99
|
+
mtime: entry.getLastModDate(),
|
|
151
100
|
});
|
|
152
101
|
});
|
|
153
102
|
}
|
|
154
103
|
async addFile(filePath, fileName, like) {
|
|
155
|
-
this.
|
|
104
|
+
this.output.zipfile.addFile(filePath, fileName, {
|
|
156
105
|
compress: like.compressionMethod !== 0,
|
|
157
106
|
mtime: like.getLastModDate(),
|
|
158
107
|
});
|
|
159
108
|
}
|
|
160
109
|
async end() {
|
|
161
|
-
this.
|
|
162
|
-
await this.writePromise;
|
|
110
|
+
this.output.zipfile.end();
|
|
111
|
+
await this.output.writePromise;
|
|
163
112
|
}
|
|
164
|
-
|
|
165
|
-
this.
|
|
166
|
-
await this.writePromise.catch(() => { });
|
|
167
|
-
await fs.remove(this.output).catch(() => { });
|
|
113
|
+
abort() {
|
|
114
|
+
return this.output.abort();
|
|
168
115
|
}
|
|
169
116
|
}
|
|
170
117
|
function openZip(source) {
|
|
@@ -178,33 +125,14 @@ function openZip(source) {
|
|
|
178
125
|
});
|
|
179
126
|
});
|
|
180
127
|
}
|
|
181
|
-
function extractEntryToFile(sourceZip, entry, outputPath) {
|
|
182
|
-
return new Promise((resolve, reject) => {
|
|
183
|
-
sourceZip.openReadStream(entry, (error, readStream) => {
|
|
184
|
-
if (error) {
|
|
185
|
-
reject(error);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (!readStream) {
|
|
189
|
-
reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
const writeStream = fs.createWriteStream(outputPath);
|
|
193
|
-
readStream.once('error', reject);
|
|
194
|
-
writeStream.once('error', reject);
|
|
195
|
-
writeStream.once('close', () => resolve());
|
|
196
|
-
readStream.pipe(writeStream);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
128
|
async function filterNativePackageArchive(source, output, platform, options) {
|
|
201
|
-
await
|
|
202
|
-
const scratchDir = await
|
|
129
|
+
await (0, fs_helpers_1.ensureDir)(path_1.default.dirname(output));
|
|
130
|
+
const scratchDir = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-native-package-entry-'));
|
|
203
131
|
const sourceZip = await openZip(source);
|
|
204
132
|
// a subset of the source never outgrows it, so the source's own size and
|
|
205
133
|
// entry count decide whether plain (non-zip64) headers are enough
|
|
206
134
|
const rawCopy = !options.repack &&
|
|
207
|
-
(0, zip_raw_writer_1.fitsRawZip)((await
|
|
135
|
+
(0, zip_raw_writer_1.fitsRawZip)((await fs_1.default.promises.stat(source)).size, sourceZip.entryCount);
|
|
208
136
|
const sink = rawCopy
|
|
209
137
|
? new RawCopySink(output)
|
|
210
138
|
: new RepackSink(output);
|
|
@@ -243,7 +171,7 @@ async function filterNativePackageArchive(source, output, platform, options) {
|
|
|
243
171
|
const index = nestedArchiveIndex++;
|
|
244
172
|
const nestedSource = path_1.default.join(scratchDir, `${index}.source.hap`);
|
|
245
173
|
const nestedOutput = path_1.default.join(scratchDir, `${index}.slim.hap`);
|
|
246
|
-
await
|
|
174
|
+
await (0, zip_entries_1.writeEntry)(entry, sourceZip, nestedSource);
|
|
247
175
|
const nestedResult = await filterNativePackageArchive(nestedSource, nestedOutput, platform, options);
|
|
248
176
|
if (nestedResult.entries > 0) {
|
|
249
177
|
await sink.addFile(nestedOutput, entry.fileName, entry);
|
|
@@ -277,7 +205,7 @@ async function filterNativePackageArchive(source, output, platform, options) {
|
|
|
277
205
|
throw error;
|
|
278
206
|
}
|
|
279
207
|
finally {
|
|
280
|
-
await
|
|
208
|
+
await (0, fs_helpers_1.remove)(scratchDir);
|
|
281
209
|
}
|
|
282
210
|
}
|
|
283
211
|
/**
|
|
@@ -287,7 +215,7 @@ async function filterNativePackageArchive(source, output, platform, options) {
|
|
|
287
215
|
async function createSlimNativePackage(source, output, platform, options = {}) {
|
|
288
216
|
const result = await filterNativePackageArchive(source, output, platform, options);
|
|
289
217
|
if (result.bundles === 0) {
|
|
290
|
-
await
|
|
218
|
+
await (0, fs_helpers_1.remove)(output);
|
|
291
219
|
throw new Error(`Bundle entry not found in native package: ${source}`);
|
|
292
220
|
}
|
|
293
221
|
}
|
package/lib/package.d.ts
CHANGED
|
@@ -12,7 +12,12 @@ type PackageCommandOptions = Record<string, unknown> & {
|
|
|
12
12
|
splits?: string;
|
|
13
13
|
output?: string;
|
|
14
14
|
};
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function toNumericIds(ids: string[]): number[];
|
|
16
|
+
/**
|
|
17
|
+
* Delete versions or packages of an app: one id through
|
|
18
|
+
* `DELETE /app/:appId/<kind>/:id`, several in one `DELETE /app/:appId/<kind>`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function deleteByIds(appId: string | number, kind: 'version' | 'package', ids: string[]): Promise<void>;
|
|
16
21
|
/**
|
|
17
22
|
* Print the app's native packages. Pass `packages` when the caller already
|
|
18
23
|
* fetched them (every page of the list), to skip fetching them again.
|