react-native-update-cli 2.29.1 → 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 +26 -44
- 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 +25 -27
- package/lib/bundle-runner.js +55 -54
- package/lib/bundle.js +18 -26
- package/lib/diff.js +32 -91
- 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 +20 -60
- package/lib/package.d.ts +6 -1
- package/lib/package.js +50 -70
- 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 +87 -192
- 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 -26
- package/lib/utils/app-info-parser/resource-finder.js +41 -183
- 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 +5 -0
- package/lib/utils/fs-helpers.js +19 -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 +93 -156
- 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/zip-entries.d.ts +23 -0
- package/lib/utils/zip-entries.js +125 -102
- package/lib/utils/zip-options.js +29 -56
- package/lib/utils/zip-range.js +25 -65
- package/lib/versions.d.ts +5 -0
- package/lib/versions.js +86 -153
- package/package.json +1 -3
- 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 -31
package/lib/package.js
CHANGED
|
@@ -4,7 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.packageCommands = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.toNumericIds = toNumericIds;
|
|
8
|
+
exports.deleteByIds = deleteByIds;
|
|
8
9
|
exports.listPackage = listPackage;
|
|
9
10
|
exports.choosePackage = choosePackage;
|
|
10
11
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -23,12 +24,8 @@ const i18n_1 = require("./utils/i18n");
|
|
|
23
24
|
const options_1 = require("./utils/options");
|
|
24
25
|
const zip_range_1 = require("./utils/zip-range");
|
|
25
26
|
// the AAB parser drags in protobufjs; load it only for the aab commands
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
return new AabParser(source);
|
|
29
|
-
}
|
|
30
|
-
function normalizeUploadBuildTime(value) {
|
|
31
|
-
return String(value);
|
|
27
|
+
function loadExtractApk() {
|
|
28
|
+
return require('./utils/app-info-parser/aab').extractApk;
|
|
32
29
|
}
|
|
33
30
|
function ensureFileByExt(filePath, extension, usageKey) {
|
|
34
31
|
if (!filePath?.endsWith(extension)) {
|
|
@@ -36,19 +33,6 @@ function ensureFileByExt(filePath, extension, usageKey) {
|
|
|
36
33
|
}
|
|
37
34
|
return filePath;
|
|
38
35
|
}
|
|
39
|
-
function parseBooleanOption(value) {
|
|
40
|
-
return value === true || value === 'true';
|
|
41
|
-
}
|
|
42
|
-
function parseCsvOption(value) {
|
|
43
|
-
if (typeof value !== 'string') {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const parsed = value
|
|
47
|
-
.split(',')
|
|
48
|
-
.map((item) => item.trim())
|
|
49
|
-
.filter(Boolean);
|
|
50
|
-
return parsed.length > 0 ? parsed : null;
|
|
51
|
-
}
|
|
52
36
|
function toNumericIds(ids) {
|
|
53
37
|
return ids.map((id) => {
|
|
54
38
|
const numericId = Number(id);
|
|
@@ -58,6 +42,42 @@ function toNumericIds(ids) {
|
|
|
58
42
|
return numericId;
|
|
59
43
|
});
|
|
60
44
|
}
|
|
45
|
+
const deleteMessages = {
|
|
46
|
+
version: {
|
|
47
|
+
one: 'deleteVersionSuccess',
|
|
48
|
+
many: 'deleteVersionsSuccess',
|
|
49
|
+
error: 'deleteVersionError',
|
|
50
|
+
},
|
|
51
|
+
package: {
|
|
52
|
+
one: 'deletePackageSuccess',
|
|
53
|
+
many: 'deletePackagesSuccess',
|
|
54
|
+
error: 'deletePackageError',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Delete versions or packages of an app: one id through
|
|
59
|
+
* `DELETE /app/:appId/<kind>/:id`, several in one `DELETE /app/:appId/<kind>`.
|
|
60
|
+
*/
|
|
61
|
+
async function deleteByIds(appId, kind, ids) {
|
|
62
|
+
const messages = deleteMessages[kind];
|
|
63
|
+
try {
|
|
64
|
+
if (ids.length === 1) {
|
|
65
|
+
const [id] = ids;
|
|
66
|
+
await (0, api_1.doDelete)(`/app/${appId}/${kind}/${id}`);
|
|
67
|
+
console.log((0, i18n_1.t)(messages.one, { [`${kind}Id`]: id }));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
await (0, api_1.doDelete)(`/app/${appId}/${kind}`, {
|
|
71
|
+
[`${kind}Ids`]: toNumericIds(ids),
|
|
72
|
+
});
|
|
73
|
+
console.log((0, i18n_1.t)(messages.many, { count: ids.length, [`${kind}Ids`]: ids.join(', ') }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
78
|
+
throw new Error((0, i18n_1.t)(messages.error, { [`${kind}Id`]: ids.join(', '), error: message }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
61
81
|
function getVersionBinding(version) {
|
|
62
82
|
if (!version || typeof version !== 'object') {
|
|
63
83
|
return undefined;
|
|
@@ -96,7 +116,7 @@ async function uploadNativePackage(filePath, options, config) {
|
|
|
96
116
|
const slimPackagePath = path_1.default.join(tempRoot, `package${config.extension}`);
|
|
97
117
|
try {
|
|
98
118
|
await (0, native_package_1.createSlimNativePackage)(filePath, slimPackagePath, config.platform);
|
|
99
|
-
const { hash } = await (0, api_1.uploadFile)(slimPackagePath,
|
|
119
|
+
const { hash } = await (0, api_1.uploadFile)(slimPackagePath, appId);
|
|
100
120
|
// where the bundle sits inside the uploaded (slim) archive, so a later
|
|
101
121
|
// `bundle` that falls back to this package as hermes base fetches only
|
|
102
122
|
// the bundle with one HTTP Range request. Harmony .app nests a second
|
|
@@ -110,14 +130,10 @@ async function uploadNativePackage(filePath, options, config) {
|
|
|
110
130
|
// already hashed the bundle, so pass that hash instead of hashing twice
|
|
111
131
|
await (0, hermes_base_1.cachePut)(bundleFile, undefined, bundleHash).catch(() => { });
|
|
112
132
|
}
|
|
113
|
-
const normalizedBuildTime = config.normalizeBuildTime
|
|
114
|
-
? config.normalizeBuildTime(buildTime)
|
|
115
|
-
: buildTime;
|
|
116
|
-
const uploadBuildTime = normalizeUploadBuildTime(normalizedBuildTime);
|
|
117
133
|
const { id } = await (0, api_1.post)(`/app/${appId}/package/create`, {
|
|
118
134
|
name: versionName,
|
|
119
135
|
hash,
|
|
120
|
-
buildTime:
|
|
136
|
+
buildTime: String(buildTime),
|
|
121
137
|
// Content identity of the embedded JS bundle; the server matches it
|
|
122
138
|
// against the client-reported bundleHash to decide pdiff applicability.
|
|
123
139
|
// Old servers strip unknown fields, so this is forward-compatible.
|
|
@@ -134,7 +150,7 @@ async function uploadNativePackage(filePath, options, config) {
|
|
|
134
150
|
console.log((0, i18n_1.t)(config.successKey, {
|
|
135
151
|
id,
|
|
136
152
|
version: versionName,
|
|
137
|
-
buildTime:
|
|
153
|
+
buildTime: String(buildTime),
|
|
138
154
|
}));
|
|
139
155
|
}
|
|
140
156
|
finally {
|
|
@@ -222,11 +238,10 @@ exports.packageCommands = {
|
|
|
222
238
|
// the shared tmpdir and against concurrent uploads of same-named AABs
|
|
223
239
|
const tempRoot = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'rnu-aab-upload-'));
|
|
224
240
|
const output = path_1.default.join(tempRoot, 'universal.apk');
|
|
225
|
-
const includeAllSplits =
|
|
226
|
-
const splits =
|
|
227
|
-
const parser = createAabParser(source);
|
|
241
|
+
const includeAllSplits = (0, options_1.getBooleanOption)(options, 'includeAllSplits');
|
|
242
|
+
const splits = (0, options_1.getStringListOption)(options, 'splits');
|
|
228
243
|
try {
|
|
229
|
-
await
|
|
244
|
+
await loadExtractApk()(source, output, {
|
|
230
245
|
includeAllSplits,
|
|
231
246
|
splits,
|
|
232
247
|
});
|
|
@@ -248,7 +263,6 @@ exports.packageCommands = {
|
|
|
248
263
|
appKeyMismatchKey: 'appKeyMismatchApp',
|
|
249
264
|
successKey: 'appUploadSuccess',
|
|
250
265
|
getInfo: (filePath) => (0, utils_1.getAppInfo)(filePath),
|
|
251
|
-
normalizeBuildTime: (buildTime) => String(buildTime),
|
|
252
266
|
});
|
|
253
267
|
},
|
|
254
268
|
parseApp: async ({ args }) => {
|
|
@@ -283,10 +297,9 @@ exports.packageCommands = {
|
|
|
283
297
|
const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
|
|
284
298
|
const output = options.output ||
|
|
285
299
|
path_1.default.join(path_1.default.dirname(source), `${path_1.default.basename(source, path_1.default.extname(source))}.apk`);
|
|
286
|
-
const includeAllSplits =
|
|
287
|
-
const splits =
|
|
288
|
-
|
|
289
|
-
await parser.extractApk(output, {
|
|
300
|
+
const includeAllSplits = (0, options_1.getBooleanOption)(options, 'includeAllSplits');
|
|
301
|
+
const splits = (0, options_1.getStringListOption)(options, 'splits');
|
|
302
|
+
await loadExtractApk()(source, output, {
|
|
290
303
|
includeAllSplits,
|
|
291
304
|
splits,
|
|
292
305
|
});
|
|
@@ -317,39 +330,6 @@ exports.packageCommands = {
|
|
|
317
330
|
return String(selectedPackage.id);
|
|
318
331
|
});
|
|
319
332
|
}
|
|
320
|
-
|
|
321
|
-
// const confirmDelete = await question(
|
|
322
|
-
// t('confirmDeletePackage', { packageId }),
|
|
323
|
-
// );
|
|
324
|
-
// if (
|
|
325
|
-
// confirmDelete.toLowerCase() !== 'y' &&
|
|
326
|
-
// confirmDelete.toLowerCase() !== 'yes'
|
|
327
|
-
// ) {
|
|
328
|
-
// console.log(t('cancelled'));
|
|
329
|
-
// return;
|
|
330
|
-
// }
|
|
331
|
-
try {
|
|
332
|
-
if (packageIds.length === 1) {
|
|
333
|
-
const [packageId] = packageIds;
|
|
334
|
-
await (0, api_1.doDelete)(`/app/${appId}/package/${packageId}`);
|
|
335
|
-
console.log((0, i18n_1.t)('deletePackageSuccess', { packageId }));
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
await (0, api_1.doDelete)(`/app/${appId}/package`, {
|
|
339
|
-
packageIds: toNumericIds(packageIds),
|
|
340
|
-
});
|
|
341
|
-
console.log((0, i18n_1.t)('deletePackagesSuccess', {
|
|
342
|
-
count: packageIds.length,
|
|
343
|
-
packageIds: packageIds.join(', '),
|
|
344
|
-
}));
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
catch (error) {
|
|
348
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
349
|
-
throw new Error((0, i18n_1.t)('deletePackageError', {
|
|
350
|
-
packageId: packageIds.join(', '),
|
|
351
|
-
error: message,
|
|
352
|
-
}));
|
|
353
|
-
}
|
|
333
|
+
await deleteByIds(appId, 'package', packageIds);
|
|
354
334
|
},
|
|
355
335
|
};
|
package/lib/provider.js
CHANGED
|
@@ -60,12 +60,10 @@ class CLIProviderImpl {
|
|
|
60
60
|
await this.sessionInitPromise;
|
|
61
61
|
}
|
|
62
62
|
runMessageCommand(task, fallbackError, successMessage, requireSession = true) {
|
|
63
|
-
return
|
|
64
|
-
if (requireSession) {
|
|
65
|
-
await this.ensureInitialized();
|
|
66
|
-
}
|
|
63
|
+
return this.runDataCommand(async () => {
|
|
67
64
|
await task();
|
|
68
|
-
|
|
65
|
+
return { message: successMessage };
|
|
66
|
+
}, fallbackError, requireSession);
|
|
69
67
|
}
|
|
70
68
|
runDataCommand(task, fallbackError, requireSession = true) {
|
|
71
69
|
return (0, command_result_1.runAsCommandResult)(async () => {
|
package/lib/symbolicate.js
CHANGED
|
@@ -42,21 +42,6 @@ function symbolicateStack(stack, consumer) {
|
|
|
42
42
|
});
|
|
43
43
|
return { text, mapped };
|
|
44
44
|
}
|
|
45
|
-
async function findVersionByHash(appId, hash) {
|
|
46
|
-
const limit = 100;
|
|
47
|
-
// The list is newest-first; crashes are usually about recent versions.
|
|
48
|
-
for (let offset = 0; offset < 100 * limit; offset += limit) {
|
|
49
|
-
const page = await (0, versions_1.fetchVersions)(appId, offset, limit);
|
|
50
|
-
const found = page.find((version) => version.hash === hash);
|
|
51
|
-
if (found) {
|
|
52
|
-
return found;
|
|
53
|
-
}
|
|
54
|
-
if (page.length < limit) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
45
|
async function readStack(source) {
|
|
61
46
|
if (!source || source === '-') {
|
|
62
47
|
// No file and an interactive terminal: nothing is piped in, so waiting on
|
|
@@ -89,7 +74,7 @@ exports.symbolicateCommands = {
|
|
|
89
74
|
.appId;
|
|
90
75
|
let versionId = versionIdOption;
|
|
91
76
|
if (!versionId) {
|
|
92
|
-
const version = await
|
|
77
|
+
const version = await (0, versions_1.findVersion)(appId, (item) => item.hash === hash);
|
|
93
78
|
if (!version) {
|
|
94
79
|
throw new Error((0, i18n_1.t)('symbolicateVersionNotFound', { hash }));
|
|
95
80
|
}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.addGitIgnore = addGitIgnore;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
// import path from 'path';
|
|
9
8
|
const constants_1 = require("./constants");
|
|
10
9
|
const i18n_1 = require("./i18n");
|
|
11
10
|
function addGitIgnore() {
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
|
|
9
|
-
* 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
|
|
10
|
-
*/
|
|
11
|
-
parse(): Promise<Record<string, any>>;
|
|
12
|
-
/**
|
|
13
|
-
* Parse manifest
|
|
14
|
-
* @param {Buffer} buffer // manifest file's buffer
|
|
15
|
-
*/
|
|
16
|
-
private _parseManifest;
|
|
17
|
-
/**
|
|
18
|
-
* Parse resourceMap
|
|
19
|
-
* @param {Buffer} buffer // resourceMap file's buffer
|
|
20
|
-
*/
|
|
21
|
-
private _parseResourceMap;
|
|
22
|
-
}
|
|
1
|
+
/** Build a universal APK from an .aab with bundletool (or npx node-bundletool). */
|
|
2
|
+
export declare function extractApk(aabPath: string, outputPath: string, { includeAllSplits, splits, }: {
|
|
3
|
+
includeAllSplits?: boolean;
|
|
4
|
+
splits?: string[] | null;
|
|
5
|
+
}): Promise<void>;
|
|
@@ -3,217 +3,112 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.extractApk = extractApk;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const yauzl_1 = require("yauzl");
|
|
12
11
|
const fs_helpers_1 = require("../fs-helpers");
|
|
13
12
|
const i18n_1 = require("../i18n");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
const zip_entries_1 = require("../zip-entries");
|
|
14
|
+
/** Build a universal APK from an .aab with bundletool (or npx node-bundletool). */
|
|
15
|
+
async function extractApk(aabPath, outputPath, { includeAllSplits, splits, }) {
|
|
16
|
+
const bundlePath = path_1.default.resolve(aabPath);
|
|
17
|
+
const normalizedSplits = Array.isArray(splits)
|
|
18
|
+
? splits.map((item) => item.trim()).filter(Boolean)
|
|
19
|
+
: [];
|
|
20
|
+
const modules = includeAllSplits
|
|
21
|
+
? null
|
|
22
|
+
: Array.from(new Set(['base', ...normalizedSplits]));
|
|
23
|
+
const modulesArgs = modules ? [`--modules=${modules.join(',')}`] : [];
|
|
24
|
+
const runCommand = (command, args, options = {}) => new Promise((resolve, reject) => {
|
|
25
|
+
const inheritStdio = options.stdio === 'inherit';
|
|
26
|
+
const child = (0, child_process_1.spawn)(command, args, {
|
|
27
|
+
stdio: inheritStdio ? 'inherit' : ['ignore', 'pipe', 'pipe'],
|
|
28
|
+
env: options.env,
|
|
29
|
+
});
|
|
30
|
+
let stderr = '';
|
|
31
|
+
if (!inheritStdio) {
|
|
32
|
+
child.stderr?.on('data', (chunk) => {
|
|
33
|
+
stderr += chunk.toString();
|
|
32
34
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
}
|
|
36
|
+
child.on('error', reject);
|
|
37
|
+
child.on('close', (code) => {
|
|
38
|
+
if (code === 0) {
|
|
39
|
+
resolve();
|
|
40
|
+
return;
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
child.on('close', (code) => {
|
|
41
|
-
if (code === 0) {
|
|
42
|
-
resolve();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
46
|
-
});
|
|
42
|
+
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
47
43
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
await runCommand('npx', [
|
|
54
|
-
'--no-install',
|
|
55
|
-
'node-bundletool',
|
|
56
|
-
'--version',
|
|
57
|
-
]);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
44
|
+
});
|
|
45
|
+
// Create a temp file for the .apks output
|
|
46
|
+
const tempDir = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'bundletool-'));
|
|
47
|
+
const tempApksPath = path_1.default.join(tempDir, 'output.apks');
|
|
48
|
+
const needsNpxDownload = async () => {
|
|
64
49
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// User might need keystore to sign it properly but for simple extraction we stick to default debug key if possible or unsigned?
|
|
68
|
-
// actually bundletool build-apks signs with debug key by default if no keystore provided.
|
|
69
|
-
try {
|
|
70
|
-
await runCommand('bundletool', [
|
|
71
|
-
'build-apks',
|
|
72
|
-
'--mode=universal',
|
|
73
|
-
`--bundle=${this.file}`,
|
|
74
|
-
`--output=${tempApksPath}`,
|
|
75
|
-
'--overwrite',
|
|
76
|
-
...modulesArgs,
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
// Only fall back when bundletool itself is missing from PATH (spawn
|
|
81
|
-
// ENOENT). Any other failure (corrupt AAB, Java issues, bad args,
|
|
82
|
-
// non-zero exit) must surface as-is instead of being masked by an
|
|
83
|
-
// online npx install.
|
|
84
|
-
if (e?.code !== 'ENOENT') {
|
|
85
|
-
throw e;
|
|
86
|
-
}
|
|
87
|
-
// Fallback to npx node-bundletool if bundletool is not in PATH
|
|
88
|
-
// We use -y to avoid interactive prompt for installation
|
|
89
|
-
if (await needsNpxDownload()) {
|
|
90
|
-
console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
|
|
91
|
-
}
|
|
92
|
-
await runCommand('npx', [
|
|
93
|
-
'-y',
|
|
94
|
-
'node-bundletool',
|
|
95
|
-
'build-apks',
|
|
96
|
-
'--mode=universal',
|
|
97
|
-
`--bundle=${this.file}`,
|
|
98
|
-
`--output=${tempApksPath}`,
|
|
99
|
-
'--overwrite',
|
|
100
|
-
...modulesArgs,
|
|
101
|
-
], {
|
|
102
|
-
stdio: 'inherit',
|
|
103
|
-
env: {
|
|
104
|
-
...process.env,
|
|
105
|
-
npm_config_progress: 'true',
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
// 2. Extract universal.apk from the .apks (zip) file
|
|
110
|
-
await new Promise((resolve, reject) => {
|
|
111
|
-
(0, yauzl_1.open)(tempApksPath, { lazyEntries: true }, (err, zipfile) => {
|
|
112
|
-
if (err || !zipfile) {
|
|
113
|
-
reject(err || new Error((0, i18n_1.t)('aabOpenApksFailed')));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
let found = false;
|
|
117
|
-
zipfile.readEntry();
|
|
118
|
-
zipfile.on('entry', (entry) => {
|
|
119
|
-
if (entry.fileName === 'universal.apk') {
|
|
120
|
-
found = true;
|
|
121
|
-
zipfile.openReadStream(entry, (err, readStream) => {
|
|
122
|
-
if (err || !readStream) {
|
|
123
|
-
reject(err || new Error((0, i18n_1.t)('aabReadUniversalApkFailed')));
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const writeStream = fs_1.default.createWriteStream(outputPath);
|
|
127
|
-
readStream.pipe(writeStream);
|
|
128
|
-
writeStream.on('close', () => {
|
|
129
|
-
zipfile.close();
|
|
130
|
-
resolve();
|
|
131
|
-
});
|
|
132
|
-
readStream.on('error', reject);
|
|
133
|
-
writeStream.on('error', reject);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
zipfile.readEntry();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
zipfile.on('end', () => {
|
|
141
|
-
if (!found)
|
|
142
|
-
reject(new Error((0, i18n_1.t)('aabUniversalApkNotFound')));
|
|
143
|
-
});
|
|
144
|
-
zipfile.on('error', reject);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
50
|
+
await runCommand('npx', ['--no-install', 'node-bundletool', '--version']);
|
|
51
|
+
return false;
|
|
147
52
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (await (0, fs_helpers_1.pathExists)(tempDir)) {
|
|
151
|
-
await (0, fs_helpers_1.remove)(tempDir);
|
|
152
|
-
}
|
|
53
|
+
catch {
|
|
54
|
+
return true;
|
|
153
55
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const manifestPath = 'base/manifest/AndroidManifest.xml';
|
|
161
|
-
const ResourceName = /^base\/resources\.arsc$/;
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
// 1. Build APKS (universal mode)
|
|
59
|
+
// We assume bundletool is in the path.
|
|
60
|
+
// User might need keystore to sign it properly but for simple extraction we stick to default debug key if possible or unsigned?
|
|
61
|
+
// actually bundletool build-apks signs with debug key by default if no keystore provided.
|
|
162
62
|
try {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
63
|
+
await runCommand('bundletool', [
|
|
64
|
+
'build-apks',
|
|
65
|
+
'--mode=universal',
|
|
66
|
+
`--bundle=${bundlePath}`,
|
|
67
|
+
`--output=${tempApksPath}`,
|
|
68
|
+
'--overwrite',
|
|
69
|
+
...modulesArgs,
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
// Only fall back when bundletool itself is missing from PATH (spawn
|
|
74
|
+
// ENOENT). Any other failure (corrupt AAB, Java issues, bad args,
|
|
75
|
+
// non-zero exit) must surface as-is instead of being masked by an
|
|
76
|
+
// online npx install.
|
|
77
|
+
if (e?.code !== 'ENOENT') {
|
|
78
|
+
throw e;
|
|
174
79
|
}
|
|
175
|
-
|
|
176
|
-
|
|
80
|
+
// Fallback to npx node-bundletool if bundletool is not in PATH
|
|
81
|
+
// We use -y to avoid interactive prompt for installation
|
|
82
|
+
if (await needsNpxDownload()) {
|
|
83
|
+
console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
|
|
177
84
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
'application.service',
|
|
194
|
-
'application.receiver',
|
|
195
|
-
'application.provider',
|
|
196
|
-
'permission-group',
|
|
197
|
-
],
|
|
85
|
+
await runCommand('npx', [
|
|
86
|
+
'-y',
|
|
87
|
+
'node-bundletool',
|
|
88
|
+
'build-apks',
|
|
89
|
+
'--mode=universal',
|
|
90
|
+
`--bundle=${bundlePath}`,
|
|
91
|
+
`--output=${tempApksPath}`,
|
|
92
|
+
'--overwrite',
|
|
93
|
+
...modulesArgs,
|
|
94
|
+
], {
|
|
95
|
+
stdio: 'inherit',
|
|
96
|
+
env: {
|
|
97
|
+
...process.env,
|
|
98
|
+
npm_config_progress: 'true',
|
|
99
|
+
},
|
|
198
100
|
});
|
|
199
|
-
return parser.parse();
|
|
200
101
|
}
|
|
201
|
-
|
|
202
|
-
|
|
102
|
+
// 2. Extract universal.apk from the .apks (zip) file
|
|
103
|
+
const found = await (0, zip_entries_1.extractFirstEntry)(tempApksPath, (name) => name === 'universal.apk', outputPath);
|
|
104
|
+
if (!found) {
|
|
105
|
+
throw new Error((0, i18n_1.t)('aabUniversalApkNotFound'));
|
|
203
106
|
}
|
|
204
107
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
_parseResourceMap(buffer) {
|
|
210
|
-
try {
|
|
211
|
-
return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
|
|
212
|
-
}
|
|
213
|
-
catch (e) {
|
|
214
|
-
throw new Error((0, i18n_1.t)('aabParseResourcesError', { error: e?.message ?? e }));
|
|
108
|
+
finally {
|
|
109
|
+
// Cleanup
|
|
110
|
+
if (await (0, fs_helpers_1.pathExists)(tempDir)) {
|
|
111
|
+
await (0, fs_helpers_1.remove)(tempDir);
|
|
215
112
|
}
|
|
216
113
|
}
|
|
217
114
|
}
|
|
218
|
-
exports.AabParser = AabParser;
|
|
219
|
-
const escapeRegExp = (value) => value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private _parseManifest;
|
|
9
|
-
/**
|
|
10
|
-
* Parse resourceMap
|
|
11
|
-
* @param {Buffer} buffer // resourceMap file's buffer
|
|
12
|
-
*/
|
|
13
|
-
private _parseResourceMap;
|
|
1
|
+
export interface ApkManifestInfo {
|
|
2
|
+
versionName?: unknown;
|
|
3
|
+
/** `<application>`'s `<meta-data>` entries, resource references resolved */
|
|
4
|
+
metaData: Array<{
|
|
5
|
+
name?: unknown;
|
|
6
|
+
value?: unknown;
|
|
7
|
+
}>;
|
|
14
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The fields of a binary AndroidManifest.xml the CLI reads, with
|
|
11
|
+
* `@<resource>` references resolved through resources.arsc when given.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseApkManifest(manifest: Buffer, resources?: Buffer): ApkManifestInfo;
|