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
|
@@ -1,251 +1,114 @@
|
|
|
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
|
-
exports.
|
|
6
|
+
exports.extractApk = extractApk;
|
|
40
7
|
const child_process_1 = require("child_process");
|
|
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
|
-
const
|
|
11
|
+
const fs_helpers_1 = require("../fs-helpers");
|
|
45
12
|
const i18n_1 = require("../i18n");
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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();
|
|
64
34
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
35
|
+
}
|
|
36
|
+
child.on('error', reject);
|
|
37
|
+
child.on('close', (code) => {
|
|
38
|
+
if (code === 0) {
|
|
39
|
+
resolve();
|
|
40
|
+
return;
|
|
70
41
|
}
|
|
71
|
-
|
|
72
|
-
child.on('close', (code) => {
|
|
73
|
-
if (code === 0) {
|
|
74
|
-
resolve();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
78
|
-
});
|
|
42
|
+
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
79
43
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await runCommand('npx', [
|
|
86
|
-
'--no-install',
|
|
87
|
-
'node-bundletool',
|
|
88
|
-
'--version',
|
|
89
|
-
]);
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
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 () => {
|
|
96
49
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// User might need keystore to sign it properly but for simple extraction we stick to default debug key if possible or unsigned?
|
|
100
|
-
// actually bundletool build-apks signs with debug key by default if no keystore provided.
|
|
101
|
-
try {
|
|
102
|
-
await runCommand('bundletool', [
|
|
103
|
-
'build-apks',
|
|
104
|
-
'--mode=universal',
|
|
105
|
-
`--bundle=${this.file}`,
|
|
106
|
-
`--output=${tempApksPath}`,
|
|
107
|
-
'--overwrite',
|
|
108
|
-
...modulesArgs,
|
|
109
|
-
]);
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
// Only fall back when bundletool itself is missing from PATH (spawn
|
|
113
|
-
// ENOENT). Any other failure (corrupt AAB, Java issues, bad args,
|
|
114
|
-
// non-zero exit) must surface as-is instead of being masked by an
|
|
115
|
-
// online npx install.
|
|
116
|
-
if (e?.code !== 'ENOENT') {
|
|
117
|
-
throw e;
|
|
118
|
-
}
|
|
119
|
-
// Fallback to npx node-bundletool if bundletool is not in PATH
|
|
120
|
-
// We use -y to avoid interactive prompt for installation
|
|
121
|
-
if (await needsNpxDownload()) {
|
|
122
|
-
console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
|
|
123
|
-
}
|
|
124
|
-
await runCommand('npx', [
|
|
125
|
-
'-y',
|
|
126
|
-
'node-bundletool',
|
|
127
|
-
'build-apks',
|
|
128
|
-
'--mode=universal',
|
|
129
|
-
`--bundle=${this.file}`,
|
|
130
|
-
`--output=${tempApksPath}`,
|
|
131
|
-
'--overwrite',
|
|
132
|
-
...modulesArgs,
|
|
133
|
-
], {
|
|
134
|
-
stdio: 'inherit',
|
|
135
|
-
env: {
|
|
136
|
-
...process.env,
|
|
137
|
-
npm_config_progress: 'true',
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
// 2. Extract universal.apk from the .apks (zip) file
|
|
142
|
-
await new Promise((resolve, reject) => {
|
|
143
|
-
(0, yauzl_1.open)(tempApksPath, { lazyEntries: true }, (err, zipfile) => {
|
|
144
|
-
if (err || !zipfile) {
|
|
145
|
-
reject(err || new Error((0, i18n_1.t)('aabOpenApksFailed')));
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
let found = false;
|
|
149
|
-
zipfile.readEntry();
|
|
150
|
-
zipfile.on('entry', (entry) => {
|
|
151
|
-
if (entry.fileName === 'universal.apk') {
|
|
152
|
-
found = true;
|
|
153
|
-
zipfile.openReadStream(entry, (err, readStream) => {
|
|
154
|
-
if (err || !readStream) {
|
|
155
|
-
reject(err || new Error((0, i18n_1.t)('aabReadUniversalApkFailed')));
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const writeStream = fs.createWriteStream(outputPath);
|
|
159
|
-
readStream.pipe(writeStream);
|
|
160
|
-
writeStream.on('close', () => {
|
|
161
|
-
zipfile.close();
|
|
162
|
-
resolve();
|
|
163
|
-
});
|
|
164
|
-
readStream.on('error', reject);
|
|
165
|
-
writeStream.on('error', reject);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
zipfile.readEntry();
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
zipfile.on('end', () => {
|
|
173
|
-
if (!found)
|
|
174
|
-
reject(new Error((0, i18n_1.t)('aabUniversalApkNotFound')));
|
|
175
|
-
});
|
|
176
|
-
zipfile.on('error', reject);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
50
|
+
await runCommand('npx', ['--no-install', 'node-bundletool', '--version']);
|
|
51
|
+
return false;
|
|
179
52
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (await fs.pathExists(tempDir)) {
|
|
183
|
-
await fs.remove(tempDir);
|
|
184
|
-
}
|
|
53
|
+
catch {
|
|
54
|
+
return true;
|
|
185
55
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const manifestPath = 'base/manifest/AndroidManifest.xml';
|
|
193
|
-
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.
|
|
194
62
|
try {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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;
|
|
206
79
|
}
|
|
207
|
-
|
|
208
|
-
|
|
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'));
|
|
209
84
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
'application.service',
|
|
226
|
-
'application.receiver',
|
|
227
|
-
'application.provider',
|
|
228
|
-
'permission-group',
|
|
229
|
-
],
|
|
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
|
+
},
|
|
230
100
|
});
|
|
231
|
-
return parser.parse();
|
|
232
101
|
}
|
|
233
|
-
|
|
234
|
-
|
|
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'));
|
|
235
106
|
}
|
|
236
107
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
_parseResourceMap(buffer) {
|
|
242
|
-
try {
|
|
243
|
-
return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
|
|
244
|
-
}
|
|
245
|
-
catch (e) {
|
|
246
|
-
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);
|
|
247
112
|
}
|
|
248
113
|
}
|
|
249
114
|
}
|
|
250
|
-
exports.AabParser = AabParser;
|
|
251
|
-
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;
|
|
@@ -1,90 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseApkManifest = parseApkManifest;
|
|
4
4
|
const resource_finder_1 = require("./resource-finder");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
this.getEntries([ManifestName, ResourceName])
|
|
16
|
-
.then((buffers) => {
|
|
17
|
-
const manifestBuffer = buffers[manifestKey];
|
|
18
|
-
if (!manifestBuffer) {
|
|
19
|
-
throw new Error("AndroidManifest.xml can't be found.");
|
|
20
|
-
}
|
|
21
|
-
let apkInfo;
|
|
22
|
-
let resourceMap;
|
|
23
|
-
apkInfo = this._parseManifest(manifestBuffer);
|
|
24
|
-
if (!buffers[resourceKey]) {
|
|
25
|
-
resolve(apkInfo);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
resourceMap = this._parseResourceMap(buffers[resourceKey]);
|
|
29
|
-
apkInfo = (0, utils_1.mapInfoResource)(apkInfo, resourceMap);
|
|
30
|
-
const iconPath = (0, utils_1.findApkIconPath)(apkInfo);
|
|
31
|
-
if (iconPath) {
|
|
32
|
-
this.getEntry(iconPath)
|
|
33
|
-
.then((iconBuffer) => {
|
|
34
|
-
apkInfo.icon = Buffer.isBuffer(iconBuffer)
|
|
35
|
-
? (0, utils_1.getBase64FromBuffer)(iconBuffer)
|
|
36
|
-
: null;
|
|
37
|
-
resolve(apkInfo);
|
|
38
|
-
})
|
|
39
|
-
.catch((e) => {
|
|
40
|
-
apkInfo.icon = null;
|
|
41
|
-
resolve(apkInfo);
|
|
42
|
-
console.warn('[Warning] failed to parse icon: ', e);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
apkInfo.icon = null;
|
|
47
|
-
resolve(apkInfo);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
.catch((e) => {
|
|
52
|
-
reject(e);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
5
|
+
const binary_1 = require("./xml-parser/binary");
|
|
6
|
+
/**
|
|
7
|
+
* The fields of a binary AndroidManifest.xml the CLI reads, with
|
|
8
|
+
* `@<resource>` references resolved through resources.arsc when given.
|
|
9
|
+
*/
|
|
10
|
+
function parseApkManifest(manifest, resources) {
|
|
11
|
+
let root;
|
|
12
|
+
try {
|
|
13
|
+
root = (0, binary_1.parseBinaryXml)(manifest);
|
|
55
14
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* @param {Buffer} buffer // manifest file's buffer
|
|
59
|
-
*/
|
|
60
|
-
_parseManifest(buffer) {
|
|
61
|
-
try {
|
|
62
|
-
const parser = new manifest_1.ManifestParser(buffer, {
|
|
63
|
-
ignore: [
|
|
64
|
-
'application.activity',
|
|
65
|
-
'application.service',
|
|
66
|
-
'application.receiver',
|
|
67
|
-
'application.provider',
|
|
68
|
-
'permission-group',
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
return parser.parse();
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
throw new Error(`Parse AndroidManifest.xml error: ${e.message || e}`);
|
|
75
|
-
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
throw new Error(`Parse AndroidManifest.xml error: ${e.message || e}`);
|
|
76
17
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* @param {Buffer} buffer // resourceMap file's buffer
|
|
80
|
-
*/
|
|
81
|
-
_parseResourceMap(buffer) {
|
|
18
|
+
let resourceMap = {};
|
|
19
|
+
if (resources) {
|
|
82
20
|
try {
|
|
83
|
-
|
|
21
|
+
resourceMap = new resource_finder_1.ResourceFinder().processResourceTable(resources);
|
|
84
22
|
}
|
|
85
23
|
catch (e) {
|
|
86
24
|
throw new Error(`Parser resources.arsc error: ${e}`);
|
|
87
25
|
}
|
|
88
26
|
}
|
|
27
|
+
const resolve = (value) => typeof value === 'string' && value.startsWith('resourceId:')
|
|
28
|
+
? resourceMap[`@${value.replace('resourceId:0x', '').toUpperCase()}`]
|
|
29
|
+
: value;
|
|
30
|
+
const application = root.children.find((el) => el.name === 'application');
|
|
31
|
+
return {
|
|
32
|
+
versionName: resolve(root.attributes.versionName),
|
|
33
|
+
metaData: (application?.children ?? [])
|
|
34
|
+
.filter((el) => el.name === 'meta-data')
|
|
35
|
+
.map(({ attributes }) => ({
|
|
36
|
+
name: resolve(attributes.name),
|
|
37
|
+
value: resolve(attributes.value),
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
89
40
|
}
|
|
90
|
-
exports.ApkParser = ApkParser;
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
parse(): Promise<any>;
|
|
4
|
-
/**
|
|
5
|
-
* Parse plist
|
|
6
|
-
* @param {Buffer} buffer // plist file's buffer
|
|
7
|
-
*/
|
|
8
|
-
private _parsePlist;
|
|
9
|
-
/**
|
|
10
|
-
* parse provision
|
|
11
|
-
* @param {Buffer} buffer // provision file's buffer
|
|
12
|
-
*/
|
|
13
|
-
private _parseProvision;
|
|
14
|
-
}
|
|
1
|
+
/** Parse an Info.plist in XML or binary form. */
|
|
2
|
+
export declare function parsePlist(buffer: Buffer): Promise<Record<string, any>>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parsePlist = parsePlist;
|
|
4
4
|
const parseBplist = require('bplist-parser').parseBuffer;
|
|
5
|
-
const cgbiToPng = require('cgbi-to-png');
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
|
-
const zip_1 = require("./zip");
|
|
8
|
-
const PlistName = /payload\/[^/]+?.app\/info.plist$/i;
|
|
9
|
-
const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/;
|
|
10
5
|
let parsePlistPromise;
|
|
11
6
|
function loadParsePlist() {
|
|
12
7
|
if (!parsePlistPromise) {
|
|
@@ -27,70 +22,14 @@ function loadParsePlist() {
|
|
|
27
22
|
}
|
|
28
23
|
return parsePlistPromise;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
throw new Error("Info.plist can't be found.");
|
|
36
|
-
}
|
|
37
|
-
const plistInfo = this._parsePlist(buffers[PlistName], parsePlist);
|
|
38
|
-
const provisionInfo = this._parseProvision(buffers[ProvisionName], parsePlist);
|
|
39
|
-
plistInfo.mobileProvision = provisionInfo;
|
|
40
|
-
const iconRegex = new RegExp((0, utils_1.findIpaIconPath)(plistInfo).toLowerCase());
|
|
41
|
-
const iconBuffer = await this.getEntry(iconRegex);
|
|
42
|
-
try {
|
|
43
|
-
plistInfo.icon = iconBuffer
|
|
44
|
-
? (0, utils_1.getBase64FromBuffer)(cgbiToPng.revert(iconBuffer))
|
|
45
|
-
: null;
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
if ((0, utils_1.isBrowser)()) {
|
|
49
|
-
plistInfo.icon = iconBuffer
|
|
50
|
-
? (0, utils_1.getBase64FromBuffer)(window.btoa(String.fromCharCode(...iconBuffer)))
|
|
51
|
-
: null;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
plistInfo.icon = null;
|
|
55
|
-
console.warn('[Warning] failed to parse icon: ', err);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return plistInfo;
|
|
25
|
+
/** Parse an Info.plist in XML or binary form. */
|
|
26
|
+
async function parsePlist(buffer) {
|
|
27
|
+
const bufferType = buffer[0];
|
|
28
|
+
if (bufferType === 60 || bufferType === 239) {
|
|
29
|
+
return (await loadParsePlist())(buffer.toString());
|
|
59
30
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* @param {Buffer} buffer // plist file's buffer
|
|
63
|
-
*/
|
|
64
|
-
_parsePlist(buffer, parsePlist) {
|
|
65
|
-
let result;
|
|
66
|
-
const bufferType = buffer[0];
|
|
67
|
-
if (bufferType === 60 || bufferType === 239) {
|
|
68
|
-
result = parsePlist(buffer.toString());
|
|
69
|
-
}
|
|
70
|
-
else if (bufferType === 98) {
|
|
71
|
-
result = parseBplist(buffer)[0];
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
throw new Error('Unknown plist buffer type.');
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* parse provision
|
|
80
|
-
* @param {Buffer} buffer // provision file's buffer
|
|
81
|
-
*/
|
|
82
|
-
_parseProvision(buffer, parsePlist) {
|
|
83
|
-
let info = {};
|
|
84
|
-
if (buffer) {
|
|
85
|
-
let content = buffer.toString('utf-8');
|
|
86
|
-
const firstIndex = content.indexOf('<?xml');
|
|
87
|
-
const endIndex = content.indexOf('</plist>');
|
|
88
|
-
content = content.slice(firstIndex, endIndex + 8);
|
|
89
|
-
if (content) {
|
|
90
|
-
info = parsePlist(content);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return info;
|
|
31
|
+
if (bufferType === 98) {
|
|
32
|
+
return parseBplist(buffer)[0];
|
|
94
33
|
}
|
|
34
|
+
throw new Error('Unknown plist buffer type.');
|
|
95
35
|
}
|
|
96
|
-
exports.IpaParser = IpaParser;
|
|
@@ -5,45 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class ResourceFinder {
|
|
7
7
|
private valueStringPool;
|
|
8
|
-
private typeStringPool;
|
|
9
|
-
private keyStringPool;
|
|
10
8
|
private packageId;
|
|
11
9
|
private responseMap;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Same to C# BinaryReader.readBytes
|
|
15
|
-
*
|
|
16
|
-
* @param bb ByteBuffer
|
|
17
|
-
* @param len length
|
|
18
|
-
* @returns {Buffer}
|
|
19
|
-
*/
|
|
20
|
-
static readBytes(bb: any, len: number): any;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {ByteBuffer} bb
|
|
24
|
-
* @return {Map<String, Set<String>>}
|
|
25
|
-
*/
|
|
10
|
+
/** Map of `@<RESOURCE ID>` to the values of that resource. */
|
|
26
11
|
processResourceTable(resourceBuffer: Buffer): Record<string, any[]>;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {ByteBuffer} bb
|
|
30
|
-
*/
|
|
31
12
|
private processPackage;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {ByteBuffer} bb
|
|
35
|
-
*/
|
|
36
13
|
private processType;
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {ByteBuffer} bb
|
|
40
|
-
* @return {Array}
|
|
41
|
-
*/
|
|
42
14
|
private processStringPool;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {ByteBuffer} bb
|
|
46
|
-
*/
|
|
47
|
-
private processTypeSpec;
|
|
48
15
|
private putIntoMap;
|
|
49
16
|
}
|