react-native-update-cli 2.18.0 → 2.19.0
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.d.ts +1 -1
- package/lib/api.js +140 -134
- package/lib/app.d.ts +2 -2
- package/lib/app.js +60 -107
- package/lib/bin.js +38 -35
- package/lib/bundle-pack.js +57 -77
- package/lib/bundle-runner.js +249 -312
- package/lib/bundle.js +71 -89
- package/lib/diff.js +188 -235
- package/lib/exports.js +14 -37
- package/lib/index.js +16 -17
- package/lib/install.js +24 -37
- package/lib/locales/en.js +3 -11
- package/lib/locales/zh.js +3 -11
- package/lib/package.js +164 -218
- package/lib/provider.js +85 -107
- package/lib/types.js +1 -3
- package/lib/user.d.ts +1 -1
- package/lib/user.js +26 -39
- package/lib/utils/add-gitignore.js +16 -29
- package/lib/utils/app-info-parser/aab.js +133 -157
- package/lib/utils/app-info-parser/apk.js +42 -39
- package/lib/utils/app-info-parser/app.js +5 -11
- package/lib/utils/app-info-parser/index.js +21 -31
- package/lib/utils/app-info-parser/ipa.js +35 -35
- package/lib/utils/app-info-parser/resource-finder.js +84 -71
- package/lib/utils/app-info-parser/utils.js +52 -77
- package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
- package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
- package/lib/utils/app-info-parser/zip.js +43 -51
- package/lib/utils/check-lockfile.js +28 -37
- package/lib/utils/check-plugin.js +16 -32
- package/lib/utils/command-result.js +7 -20
- package/lib/utils/constants.js +23 -63
- package/lib/utils/dep-versions.js +21 -27
- package/lib/utils/git.js +20 -64
- package/lib/utils/hbcTransform.js +133 -246
- package/lib/utils/http-helper.js +33 -44
- package/lib/utils/i18n.js +17 -26
- package/lib/utils/index.js +137 -179
- package/lib/utils/latest-version/index.js +128 -137
- package/lib/utils/options.js +13 -34
- package/lib/utils/plugin-config.js +43 -56
- package/lib/utils/runtime.js +50 -108
- package/lib/utils/zip-entries.js +70 -97
- package/lib/utils/zip-options.js +80 -181
- package/lib/versions.js +231 -265
- package/package.json +19 -21
- package/src/api.ts +44 -3
- package/src/package.ts +1 -1
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
|
@@ -1,117 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
get: function() {
|
|
8
|
-
return AabParser;
|
|
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]; } };
|
|
9
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;
|
|
10
17
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const _resourcefinder = require("./resource-finder");
|
|
18
|
-
const _utils = require("./utils");
|
|
19
|
-
const _manifest = require("./xml-parser/manifest");
|
|
20
|
-
const _zip = require("./zip");
|
|
21
|
-
function _interop_require_default(obj) {
|
|
22
|
-
return obj && obj.__esModule ? obj : {
|
|
23
|
-
default: obj
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
-
if (typeof WeakMap !== "function") return null;
|
|
28
|
-
var cacheBabelInterop = new WeakMap();
|
|
29
|
-
var cacheNodeInterop = new WeakMap();
|
|
30
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
31
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
|
-
})(nodeInterop);
|
|
33
|
-
}
|
|
34
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
35
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
|
-
return obj;
|
|
37
|
-
}
|
|
38
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
|
-
return {
|
|
40
|
-
default: obj
|
|
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;
|
|
41
24
|
};
|
|
42
|
-
|
|
43
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
44
|
-
if (cache && cache.has(obj)) {
|
|
45
|
-
return cache.get(obj);
|
|
46
|
-
}
|
|
47
|
-
var newObj = {
|
|
48
|
-
__proto__: null
|
|
25
|
+
return ownKeys(o);
|
|
49
26
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AabParser = void 0;
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
|
+
const os_1 = __importDefault(require("os"));
|
|
43
|
+
const path_1 = __importDefault(require("path"));
|
|
44
|
+
const yauzl_1 = require("yauzl");
|
|
45
|
+
const i18n_1 = require("../i18n");
|
|
46
|
+
const resource_finder_1 = require("./resource-finder");
|
|
47
|
+
const utils_1 = require("./utils");
|
|
48
|
+
const manifest_1 = require("./xml-parser/manifest");
|
|
49
|
+
const zip_1 = require("./zip");
|
|
50
|
+
class AabParser extends zip_1.Zip {
|
|
51
|
+
async extractApk(outputPath, { includeAllSplits, splits, }) {
|
|
52
|
+
const normalizedSplits = Array.isArray(splits)
|
|
53
|
+
? splits.map((item) => item.trim()).filter(Boolean)
|
|
54
|
+
: [];
|
|
55
|
+
const modules = includeAllSplits
|
|
56
|
+
? null
|
|
57
|
+
: Array.from(new Set(['base', ...normalizedSplits]));
|
|
58
|
+
const modulesArgs = modules ? [`--modules=${modules.join(',')}`] : [];
|
|
59
|
+
const runCommand = (command, args, options = {}) => new Promise((resolve, reject) => {
|
|
60
|
+
const inheritStdio = options.stdio === 'inherit';
|
|
61
|
+
const child = (0, child_process_1.spawn)(command, args, {
|
|
62
|
+
stdio: inheritStdio ? 'inherit' : ['ignore', 'pipe', 'pipe'],
|
|
63
|
+
env: options.env,
|
|
64
|
+
});
|
|
65
|
+
let stderr = '';
|
|
66
|
+
if (!inheritStdio) {
|
|
67
|
+
child.stderr?.on('data', (chunk) => {
|
|
68
|
+
stderr += chunk.toString();
|
|
86
69
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
}
|
|
71
|
+
child.on('error', reject);
|
|
72
|
+
child.on('close', (code) => {
|
|
73
|
+
if (code === 0) {
|
|
74
|
+
resolve();
|
|
75
|
+
return;
|
|
93
76
|
}
|
|
94
|
-
|
|
95
|
-
child.on('close', (code)=>{
|
|
96
|
-
if (code === 0) {
|
|
97
|
-
resolve();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
101
|
-
});
|
|
77
|
+
reject(new Error(stderr.trim() || `Command failed: ${command} (code ${code})`));
|
|
102
78
|
});
|
|
79
|
+
});
|
|
103
80
|
// Create a temp file for the .apks output
|
|
104
|
-
const tempDir = await
|
|
105
|
-
const tempApksPath =
|
|
106
|
-
const needsNpxDownload = async ()=>{
|
|
81
|
+
const tempDir = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'bundletool-'));
|
|
82
|
+
const tempApksPath = path_1.default.join(tempDir, 'output.apks');
|
|
83
|
+
const needsNpxDownload = async () => {
|
|
107
84
|
try {
|
|
108
85
|
await runCommand('npx', [
|
|
109
86
|
'--no-install',
|
|
110
87
|
'node-bundletool',
|
|
111
|
-
'--version'
|
|
88
|
+
'--version',
|
|
112
89
|
]);
|
|
113
90
|
return false;
|
|
114
|
-
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
115
93
|
return true;
|
|
116
94
|
}
|
|
117
95
|
};
|
|
@@ -127,13 +105,14 @@ class AabParser extends _zip.Zip {
|
|
|
127
105
|
`--bundle=${this.file}`,
|
|
128
106
|
`--output=${tempApksPath}`,
|
|
129
107
|
'--overwrite',
|
|
130
|
-
...modulesArgs
|
|
108
|
+
...modulesArgs,
|
|
131
109
|
]);
|
|
132
|
-
}
|
|
110
|
+
}
|
|
111
|
+
catch (_e) {
|
|
133
112
|
// Fallback to npx node-bundletool if bundletool is not in PATH
|
|
134
113
|
// We use -y to avoid interactive prompt for installation
|
|
135
114
|
if (await needsNpxDownload()) {
|
|
136
|
-
console.log((0,
|
|
115
|
+
console.log((0, i18n_1.t)('aabBundletoolDownloadHint'));
|
|
137
116
|
}
|
|
138
117
|
await runCommand('npx', [
|
|
139
118
|
'-y',
|
|
@@ -143,125 +122,122 @@ class AabParser extends _zip.Zip {
|
|
|
143
122
|
`--bundle=${this.file}`,
|
|
144
123
|
`--output=${tempApksPath}`,
|
|
145
124
|
'--overwrite',
|
|
146
|
-
...modulesArgs
|
|
125
|
+
...modulesArgs,
|
|
147
126
|
], {
|
|
148
127
|
stdio: 'inherit',
|
|
149
128
|
env: {
|
|
150
129
|
...process.env,
|
|
151
|
-
npm_config_progress: 'true'
|
|
152
|
-
}
|
|
130
|
+
npm_config_progress: 'true',
|
|
131
|
+
},
|
|
153
132
|
});
|
|
154
133
|
}
|
|
155
134
|
// 2. Extract universal.apk from the .apks (zip) file
|
|
156
|
-
await new Promise((resolve, reject)=>{
|
|
157
|
-
(0,
|
|
158
|
-
lazyEntries: true
|
|
159
|
-
}, (err, zipfile)=>{
|
|
135
|
+
await new Promise((resolve, reject) => {
|
|
136
|
+
(0, yauzl_1.open)(tempApksPath, { lazyEntries: true }, (err, zipfile) => {
|
|
160
137
|
if (err || !zipfile) {
|
|
161
|
-
reject(err || new Error((0,
|
|
138
|
+
reject(err || new Error((0, i18n_1.t)('aabOpenApksFailed')));
|
|
162
139
|
return;
|
|
163
140
|
}
|
|
164
141
|
let found = false;
|
|
165
142
|
zipfile.readEntry();
|
|
166
|
-
zipfile.on('entry', (entry)=>{
|
|
143
|
+
zipfile.on('entry', (entry) => {
|
|
167
144
|
if (entry.fileName === 'universal.apk') {
|
|
168
145
|
found = true;
|
|
169
|
-
zipfile.openReadStream(entry, (err, readStream)=>{
|
|
146
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
170
147
|
if (err || !readStream) {
|
|
171
|
-
reject(err || new Error((0,
|
|
148
|
+
reject(err || new Error((0, i18n_1.t)('aabReadUniversalApkFailed')));
|
|
172
149
|
return;
|
|
173
150
|
}
|
|
174
|
-
const writeStream =
|
|
151
|
+
const writeStream = fs.createWriteStream(outputPath);
|
|
175
152
|
readStream.pipe(writeStream);
|
|
176
|
-
writeStream.on('close', ()=>{
|
|
153
|
+
writeStream.on('close', () => {
|
|
177
154
|
zipfile.close();
|
|
178
155
|
resolve();
|
|
179
156
|
});
|
|
180
157
|
writeStream.on('error', reject);
|
|
181
158
|
});
|
|
182
|
-
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
183
161
|
zipfile.readEntry();
|
|
184
162
|
}
|
|
185
163
|
});
|
|
186
|
-
zipfile.on('end', ()=>{
|
|
187
|
-
if (!found)
|
|
164
|
+
zipfile.on('end', () => {
|
|
165
|
+
if (!found)
|
|
166
|
+
reject(new Error((0, i18n_1.t)('aabUniversalApkNotFound')));
|
|
188
167
|
});
|
|
189
168
|
zipfile.on('error', reject);
|
|
190
169
|
});
|
|
191
170
|
});
|
|
192
|
-
}
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
193
173
|
// Cleanup
|
|
194
|
-
if (await
|
|
195
|
-
await
|
|
174
|
+
if (await fs.pathExists(tempDir)) {
|
|
175
|
+
await fs.remove(tempDir);
|
|
196
176
|
}
|
|
197
177
|
}
|
|
198
178
|
}
|
|
199
179
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
180
|
+
* 解析 AAB 文件信息(类似 APK parser 的 parse 方法)
|
|
181
|
+
* 注意:AAB 中的 AndroidManifest.xml 在 base/manifest/AndroidManifest.xml
|
|
182
|
+
*/
|
|
183
|
+
async parse() {
|
|
203
184
|
const manifestPath = 'base/manifest/AndroidManifest.xml';
|
|
204
185
|
const ResourceName = /^base\/resources\.arsc$/;
|
|
205
186
|
try {
|
|
206
187
|
const manifestBuffer = await this.getEntry(new RegExp(`^${escapeRegExp(manifestPath)}$`));
|
|
207
188
|
if (!manifestBuffer) {
|
|
208
|
-
throw new Error((0,
|
|
189
|
+
throw new Error((0, i18n_1.t)('aabManifestNotFound'));
|
|
209
190
|
}
|
|
210
191
|
let apkInfo = this._parseManifest(manifestBuffer);
|
|
211
192
|
try {
|
|
212
193
|
const resourceBuffer = await this.getEntry(ResourceName);
|
|
213
194
|
if (resourceBuffer) {
|
|
214
195
|
const resourceMap = this._parseResourceMap(resourceBuffer);
|
|
215
|
-
apkInfo = (0,
|
|
196
|
+
apkInfo = (0, utils_1.mapInfoResource)(apkInfo, resourceMap);
|
|
216
197
|
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
console.warn((0,
|
|
220
|
-
error: (_ref = e == null ? void 0 : e.message) != null ? _ref : e
|
|
221
|
-
}));
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
console.warn((0, i18n_1.t)('aabParseResourcesWarning', { error: e?.message ?? e }));
|
|
222
201
|
}
|
|
223
202
|
return apkInfo;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
throw new Error((0,
|
|
227
|
-
error: (_error_message = error.message) != null ? _error_message : error
|
|
228
|
-
}));
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
throw new Error((0, i18n_1.t)('aabParseFailed', { error: error.message ?? error }));
|
|
229
206
|
}
|
|
230
207
|
}
|
|
231
208
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
209
|
+
* Parse manifest
|
|
210
|
+
* @param {Buffer} buffer // manifest file's buffer
|
|
211
|
+
*/
|
|
212
|
+
_parseManifest(buffer) {
|
|
235
213
|
try {
|
|
236
|
-
const parser = new
|
|
214
|
+
const parser = new manifest_1.ManifestParser(buffer, {
|
|
237
215
|
ignore: [
|
|
238
216
|
'application.activity',
|
|
239
217
|
'application.service',
|
|
240
218
|
'application.receiver',
|
|
241
219
|
'application.provider',
|
|
242
|
-
'permission-group'
|
|
243
|
-
]
|
|
220
|
+
'permission-group',
|
|
221
|
+
],
|
|
244
222
|
});
|
|
245
223
|
return parser.parse();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
throw new Error((0,
|
|
249
|
-
error: (_ref = e == null ? void 0 : e.message) != null ? _ref : e
|
|
250
|
-
}));
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
throw new Error((0, i18n_1.t)('aabParseManifestError', { error: e?.message ?? e }));
|
|
251
227
|
}
|
|
252
228
|
}
|
|
253
229
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
230
|
+
* Parse resourceMap
|
|
231
|
+
* @param {Buffer} buffer // resourceMap file's buffer
|
|
232
|
+
*/
|
|
233
|
+
_parseResourceMap(buffer) {
|
|
257
234
|
try {
|
|
258
|
-
return new
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
throw new Error((0,
|
|
262
|
-
error: (_ref = e == null ? void 0 : e.message) != null ? _ref : e
|
|
263
|
-
}));
|
|
235
|
+
return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
throw new Error((0, i18n_1.t)('aabParseResourcesError', { error: e?.message ?? e }));
|
|
264
239
|
}
|
|
265
240
|
}
|
|
266
241
|
}
|
|
267
|
-
|
|
242
|
+
exports.AabParser = AabParser;
|
|
243
|
+
const escapeRegExp = (value) => value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return ApkParser;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _resourcefinder = require("./resource-finder");
|
|
12
|
-
const _utils = require("./utils");
|
|
13
|
-
const _manifest = require("./xml-parser/manifest");
|
|
14
|
-
const _zip = require("./zip");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApkParser = void 0;
|
|
4
|
+
const resource_finder_1 = require("./resource-finder");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const manifest_1 = require("./xml-parser/manifest");
|
|
7
|
+
const zip_1 = require("./zip");
|
|
15
8
|
const ManifestName = /^androidmanifest\.xml$/;
|
|
16
9
|
const ResourceName = /^resources\.arsc$/;
|
|
17
|
-
class ApkParser extends
|
|
10
|
+
class ApkParser extends zip_1.Zip {
|
|
18
11
|
parse() {
|
|
19
12
|
const manifestKey = ManifestName.toString();
|
|
20
13
|
const resourceKey = ResourceName.toString();
|
|
21
|
-
return new Promise((resolve, reject)=>{
|
|
22
|
-
this.getEntries([
|
|
23
|
-
|
|
24
|
-
ResourceName
|
|
25
|
-
]).then((buffers)=>{
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
this.getEntries([ManifestName, ResourceName])
|
|
16
|
+
.then((buffers) => {
|
|
26
17
|
const manifestBuffer = buffers[manifestKey];
|
|
27
18
|
if (!manifestBuffer) {
|
|
28
19
|
throw new Error("AndroidManifest.xml can't be found.");
|
|
@@ -32,56 +23,68 @@ class ApkParser extends _zip.Zip {
|
|
|
32
23
|
apkInfo = this._parseManifest(manifestBuffer);
|
|
33
24
|
if (!buffers[resourceKey]) {
|
|
34
25
|
resolve(apkInfo);
|
|
35
|
-
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
36
28
|
resourceMap = this._parseResourceMap(buffers[resourceKey]);
|
|
37
|
-
apkInfo = (0,
|
|
38
|
-
const iconPath = (0,
|
|
29
|
+
apkInfo = (0, utils_1.mapInfoResource)(apkInfo, resourceMap);
|
|
30
|
+
const iconPath = (0, utils_1.findApkIconPath)(apkInfo);
|
|
39
31
|
if (iconPath) {
|
|
40
|
-
this.getEntry(iconPath)
|
|
41
|
-
|
|
32
|
+
this.getEntry(iconPath)
|
|
33
|
+
.then((iconBuffer) => {
|
|
34
|
+
apkInfo.icon = Buffer.isBuffer(iconBuffer)
|
|
35
|
+
? (0, utils_1.getBase64FromBuffer)(iconBuffer)
|
|
36
|
+
: null;
|
|
42
37
|
resolve(apkInfo);
|
|
43
|
-
})
|
|
38
|
+
})
|
|
39
|
+
.catch((e) => {
|
|
44
40
|
apkInfo.icon = null;
|
|
45
41
|
resolve(apkInfo);
|
|
46
42
|
console.warn('[Warning] failed to parse icon: ', e);
|
|
47
43
|
});
|
|
48
|
-
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
49
46
|
apkInfo.icon = null;
|
|
50
47
|
resolve(apkInfo);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
})
|
|
50
|
+
})
|
|
51
|
+
.catch((e) => {
|
|
54
52
|
reject(e);
|
|
55
53
|
});
|
|
56
54
|
});
|
|
57
55
|
}
|
|
58
56
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
* Parse manifest
|
|
58
|
+
* @param {Buffer} buffer // manifest file's buffer
|
|
59
|
+
*/
|
|
60
|
+
_parseManifest(buffer) {
|
|
62
61
|
try {
|
|
63
|
-
const parser = new
|
|
62
|
+
const parser = new manifest_1.ManifestParser(buffer, {
|
|
64
63
|
ignore: [
|
|
65
64
|
'application.activity',
|
|
66
65
|
'application.service',
|
|
67
66
|
'application.receiver',
|
|
68
67
|
'application.provider',
|
|
69
|
-
'permission-group'
|
|
70
|
-
]
|
|
68
|
+
'permission-group',
|
|
69
|
+
],
|
|
71
70
|
});
|
|
72
71
|
return parser.parse();
|
|
73
|
-
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
74
|
throw new Error(`Parse AndroidManifest.xml error: ${e.message || e}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
* Parse resourceMap
|
|
79
|
+
* @param {Buffer} buffer // resourceMap file's buffer
|
|
80
|
+
*/
|
|
81
|
+
_parseResourceMap(buffer) {
|
|
81
82
|
try {
|
|
82
|
-
return new
|
|
83
|
-
}
|
|
83
|
+
return new resource_finder_1.ResourceFinder().processResourceTable(buffer);
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
84
86
|
throw new Error(`Parser resources.arsc error: ${e}`);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
}
|
|
90
|
+
exports.ApkParser = ApkParser;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return AppParser;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _zip = require("./zip");
|
|
12
|
-
class AppParser extends _zip.Zip {
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppParser = void 0;
|
|
4
|
+
const zip_1 = require("./zip");
|
|
5
|
+
class AppParser extends zip_1.Zip {
|
|
13
6
|
async parse() {
|
|
14
7
|
return {};
|
|
15
8
|
}
|
|
16
9
|
}
|
|
10
|
+
exports.AppParser = AppParser;
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _aab = require("./aab");
|
|
12
|
-
const _apk = require("./apk");
|
|
13
|
-
const _app = require("./app");
|
|
14
|
-
const _ipa = require("./ipa");
|
|
15
|
-
const supportFileTypes = [
|
|
16
|
-
'ipa',
|
|
17
|
-
'apk',
|
|
18
|
-
'app',
|
|
19
|
-
'aab'
|
|
20
|
-
];
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const aab_1 = require("./aab");
|
|
4
|
+
const apk_1 = require("./apk");
|
|
5
|
+
const app_1 = require("./app");
|
|
6
|
+
const ipa_1 = require("./ipa");
|
|
7
|
+
const supportFileTypes = ['ipa', 'apk', 'app', 'aab'];
|
|
21
8
|
class AppInfoParser {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
9
|
+
file;
|
|
10
|
+
parser;
|
|
25
11
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
* parser for parsing .ipa or .apk file
|
|
13
|
+
* @param {String | File} file // file's path in Node, instance of File in Browser
|
|
14
|
+
*/
|
|
15
|
+
constructor(file) {
|
|
29
16
|
if (!file) {
|
|
30
17
|
throw new Error("Param miss: file(file's path in Node, instance of File in browser).");
|
|
31
18
|
}
|
|
@@ -35,22 +22,25 @@ class AppInfoParser {
|
|
|
35
22
|
throw new Error('Unsupported file type, only support .ipa, .apk, .app, or .aab file.');
|
|
36
23
|
}
|
|
37
24
|
this.file = file;
|
|
38
|
-
switch(fileType){
|
|
25
|
+
switch (fileType) {
|
|
39
26
|
case 'ipa':
|
|
40
|
-
this.parser = new
|
|
27
|
+
this.parser = new ipa_1.IpaParser(this.file);
|
|
41
28
|
break;
|
|
42
29
|
case 'apk':
|
|
43
|
-
this.parser = new
|
|
30
|
+
this.parser = new apk_1.ApkParser(this.file);
|
|
44
31
|
break;
|
|
45
32
|
case 'app':
|
|
46
|
-
this.parser = new
|
|
33
|
+
this.parser = new app_1.AppParser(this.file);
|
|
47
34
|
break;
|
|
48
35
|
case 'aab':
|
|
49
|
-
this.parser = new
|
|
36
|
+
this.parser = new aab_1.AabParser(this.file);
|
|
50
37
|
break;
|
|
51
38
|
default:
|
|
52
39
|
throw new Error('Unsupported parser file type.');
|
|
53
40
|
}
|
|
54
41
|
}
|
|
42
|
+
parse() {
|
|
43
|
+
return this.parser.parse();
|
|
44
|
+
}
|
|
55
45
|
}
|
|
56
|
-
|
|
46
|
+
exports.default = AppInfoParser;
|