react-native-update-cli 1.46.1 → 2.0.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/README.md +578 -1
- package/README.zh-CN.md +576 -0
- package/cli.json +18 -0
- package/lib/api.js +5 -5
- package/lib/app.js +1 -1
- package/lib/bundle.js +43 -29
- package/lib/exports.js +65 -0
- package/lib/index.js +100 -9
- package/lib/module-manager.js +125 -0
- package/lib/modules/app-module.js +223 -0
- package/lib/modules/bundle-module.js +188 -0
- package/lib/modules/index.js +42 -0
- package/lib/modules/package-module.js +16 -0
- package/lib/modules/user-module.js +402 -0
- package/lib/modules/version-module.js +16 -0
- package/lib/package.js +16 -6
- package/lib/provider.js +340 -0
- package/lib/user.js +3 -3
- package/lib/utils/app-info-parser/apk.js +1 -1
- package/lib/utils/app-info-parser/ipa.js +2 -2
- package/lib/utils/app-info-parser/resource-finder.js +35 -35
- package/lib/utils/app-info-parser/xml-parser/manifest.js +2 -2
- package/lib/utils/app-info-parser/zip.js +3 -6
- package/lib/utils/check-plugin.js +1 -1
- package/lib/utils/git.js +1 -1
- package/lib/utils/i18n.js +3 -1
- package/lib/utils/index.js +4 -4
- package/lib/utils/latest-version/cli.js +3 -3
- package/lib/utils/latest-version/index.js +4 -4
- package/lib/versions.js +2 -2
- package/package.json +4 -4
- package/src/api.ts +7 -7
- package/src/app.ts +2 -2
- package/src/bundle.ts +57 -32
- package/src/exports.ts +30 -0
- package/src/index.ts +118 -16
- package/src/module-manager.ts +149 -0
- package/src/modules/app-module.ts +205 -0
- package/src/modules/bundle-module.ts +202 -0
- package/src/modules/index.ts +19 -0
- package/src/modules/package-module.ts +11 -0
- package/src/modules/user-module.ts +406 -0
- package/src/modules/version-module.ts +8 -0
- package/src/package.ts +29 -16
- package/src/provider.ts +341 -0
- package/src/types.ts +125 -0
- package/src/user.ts +4 -3
- package/src/utils/app-info-parser/apk.js +62 -52
- package/src/utils/app-info-parser/app.js +5 -5
- package/src/utils/app-info-parser/ipa.js +69 -57
- package/src/utils/app-info-parser/resource-finder.js +50 -54
- package/src/utils/app-info-parser/utils.js +59 -54
- package/src/utils/app-info-parser/xml-parser/binary.js +366 -354
- package/src/utils/app-info-parser/xml-parser/manifest.js +145 -137
- package/src/utils/app-info-parser/zip.js +1 -1
- package/src/utils/check-plugin.ts +4 -2
- package/src/utils/dep-versions.ts +13 -6
- package/src/utils/git.ts +1 -1
- package/src/utils/i18n.ts +3 -1
- package/src/utils/index.ts +8 -10
- package/src/utils/latest-version/cli.ts +4 -4
- package/src/utils/latest-version/index.ts +17 -17
- package/src/utils/plugin-config.ts +3 -3
- package/src/versions.ts +3 -3
package/lib/provider.js
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "CLIProviderImpl", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return CLIProviderImpl;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _api = require("./api");
|
|
12
|
+
const _app = require("./app");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
+
if (typeof WeakMap !== "function") return null;
|
|
15
|
+
var cacheBabelInterop = new WeakMap();
|
|
16
|
+
var cacheNodeInterop = new WeakMap();
|
|
17
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
18
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
+
})(nodeInterop);
|
|
20
|
+
}
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
+
return {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
+
if (cache && cache.has(obj)) {
|
|
32
|
+
return cache.get(obj);
|
|
33
|
+
}
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
37
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
+
if (desc && (desc.get || desc.set)) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
newObj.default = obj;
|
|
49
|
+
if (cache) {
|
|
50
|
+
cache.set(obj, newObj);
|
|
51
|
+
}
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
class CLIProviderImpl {
|
|
55
|
+
async init() {
|
|
56
|
+
try {
|
|
57
|
+
await (0, _api.loadSession)();
|
|
58
|
+
this.session = (0, _api.getSession)();
|
|
59
|
+
} catch (error) {}
|
|
60
|
+
}
|
|
61
|
+
async bundle(options) {
|
|
62
|
+
try {
|
|
63
|
+
const context = {
|
|
64
|
+
args: [],
|
|
65
|
+
options: {
|
|
66
|
+
dev: options.dev || false,
|
|
67
|
+
platform: options.platform,
|
|
68
|
+
bundleName: options.bundleName || 'index.bundlejs',
|
|
69
|
+
entryFile: options.entryFile || 'index.js',
|
|
70
|
+
output: options.output || '${tempDir}/output/${platform}.${time}.ppk',
|
|
71
|
+
sourcemap: options.sourcemap || false,
|
|
72
|
+
taro: options.taro || false,
|
|
73
|
+
expo: options.expo || false,
|
|
74
|
+
rncli: options.rncli || false,
|
|
75
|
+
disableHermes: options.disableHermes || false
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
|
|
79
|
+
await bundleCommands.bundle(context);
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
data: {
|
|
83
|
+
message: 'Bundle created successfully'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
error: error instanceof Error ? error.message : 'Unknown error during bundling'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async publish(options) {
|
|
94
|
+
try {
|
|
95
|
+
const context = {
|
|
96
|
+
args: [],
|
|
97
|
+
options: {
|
|
98
|
+
name: options.name,
|
|
99
|
+
description: options.description,
|
|
100
|
+
metaInfo: options.metaInfo,
|
|
101
|
+
packageId: options.packageId,
|
|
102
|
+
packageVersion: options.packageVersion,
|
|
103
|
+
minPackageVersion: options.minPackageVersion,
|
|
104
|
+
maxPackageVersion: options.maxPackageVersion,
|
|
105
|
+
packageVersionRange: options.packageVersionRange,
|
|
106
|
+
rollout: options.rollout,
|
|
107
|
+
dryRun: options.dryRun || false
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
111
|
+
await versionCommands.publish(context);
|
|
112
|
+
return {
|
|
113
|
+
success: true,
|
|
114
|
+
data: {
|
|
115
|
+
message: 'Version published successfully'
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: error instanceof Error ? error.message : 'Unknown error during publishing'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async upload(options) {
|
|
126
|
+
try {
|
|
127
|
+
var _filePath_split_pop;
|
|
128
|
+
const platform = await this.getPlatform(options.platform);
|
|
129
|
+
const { appId } = await this.getSelectedApp(platform);
|
|
130
|
+
const filePath = options.filePath;
|
|
131
|
+
const fileType = (_filePath_split_pop = filePath.split('.').pop()) == null ? void 0 : _filePath_split_pop.toLowerCase();
|
|
132
|
+
const context = {
|
|
133
|
+
args: [
|
|
134
|
+
filePath
|
|
135
|
+
],
|
|
136
|
+
options: {
|
|
137
|
+
platform,
|
|
138
|
+
appId
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const { packageCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
|
|
142
|
+
switch(fileType){
|
|
143
|
+
case 'ipa':
|
|
144
|
+
await packageCommands.uploadIpa(context);
|
|
145
|
+
break;
|
|
146
|
+
case 'apk':
|
|
147
|
+
await packageCommands.uploadApk(context);
|
|
148
|
+
break;
|
|
149
|
+
case 'app':
|
|
150
|
+
await packageCommands.uploadApp(context);
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
throw new Error(`Unsupported file type: ${fileType}`);
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
data: {
|
|
158
|
+
message: 'File uploaded successfully'
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return {
|
|
163
|
+
success: false,
|
|
164
|
+
error: error instanceof Error ? error.message : 'Unknown error during upload'
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async getSelectedApp(platform) {
|
|
169
|
+
const resolvedPlatform = await this.getPlatform(platform);
|
|
170
|
+
return (0, _app.getSelectedApp)(resolvedPlatform);
|
|
171
|
+
}
|
|
172
|
+
async listApps(platform) {
|
|
173
|
+
try {
|
|
174
|
+
const resolvedPlatform = await this.getPlatform(platform);
|
|
175
|
+
const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
|
|
176
|
+
await appCommands.apps({
|
|
177
|
+
options: {
|
|
178
|
+
platform: resolvedPlatform
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
data: {
|
|
184
|
+
message: 'Apps listed successfully'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
} catch (error) {
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
error: error instanceof Error ? error.message : 'Unknown error listing apps'
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async createApp(name, platform) {
|
|
195
|
+
try {
|
|
196
|
+
const { appCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./app")));
|
|
197
|
+
await appCommands.createApp({
|
|
198
|
+
options: {
|
|
199
|
+
name,
|
|
200
|
+
platform,
|
|
201
|
+
downloadUrl: ''
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
success: true,
|
|
206
|
+
data: {
|
|
207
|
+
message: 'App created successfully'
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
return {
|
|
212
|
+
success: false,
|
|
213
|
+
error: error instanceof Error ? error.message : 'Unknown error creating app'
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async listVersions(appId) {
|
|
218
|
+
try {
|
|
219
|
+
const context = {
|
|
220
|
+
args: [],
|
|
221
|
+
options: {
|
|
222
|
+
appId
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
226
|
+
await versionCommands.versions(context);
|
|
227
|
+
return {
|
|
228
|
+
success: true,
|
|
229
|
+
data: {
|
|
230
|
+
message: 'Versions listed successfully'
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
} catch (error) {
|
|
234
|
+
return {
|
|
235
|
+
success: false,
|
|
236
|
+
error: error instanceof Error ? error.message : 'Unknown error listing versions'
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async updateVersion(appId, versionId, updates) {
|
|
241
|
+
try {
|
|
242
|
+
const context = {
|
|
243
|
+
args: [
|
|
244
|
+
versionId
|
|
245
|
+
],
|
|
246
|
+
options: {
|
|
247
|
+
appId,
|
|
248
|
+
...updates
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const { versionCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./versions")));
|
|
252
|
+
await versionCommands.update(context);
|
|
253
|
+
return {
|
|
254
|
+
success: true,
|
|
255
|
+
data: {
|
|
256
|
+
message: 'Version updated successfully'
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
} catch (error) {
|
|
260
|
+
return {
|
|
261
|
+
success: false,
|
|
262
|
+
error: error instanceof Error ? error.message : 'Unknown error updating version'
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async getPlatform(platform) {
|
|
267
|
+
return (0, _app.getPlatform)(platform);
|
|
268
|
+
}
|
|
269
|
+
async loadSession() {
|
|
270
|
+
await (0, _api.loadSession)();
|
|
271
|
+
this.session = (0, _api.getSession)();
|
|
272
|
+
if (!this.session) {
|
|
273
|
+
throw new Error('Failed to load session');
|
|
274
|
+
}
|
|
275
|
+
return this.session;
|
|
276
|
+
}
|
|
277
|
+
registerWorkflow(workflow) {
|
|
278
|
+
this.workflows.set(workflow.name, workflow);
|
|
279
|
+
}
|
|
280
|
+
async executeWorkflow(workflowName, context) {
|
|
281
|
+
const workflow = this.workflows.get(workflowName);
|
|
282
|
+
if (!workflow) {
|
|
283
|
+
return {
|
|
284
|
+
success: false,
|
|
285
|
+
error: `Workflow '${workflowName}' not found`
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
let previousResult = null;
|
|
290
|
+
for (const step of workflow.steps){
|
|
291
|
+
if (step.condition && !step.condition(context)) {
|
|
292
|
+
console.log(`Skipping step '${step.name}' due to condition`);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
console.log(`Executing step '${step.name}'`);
|
|
296
|
+
previousResult = await step.execute(context, previousResult);
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
success: true,
|
|
300
|
+
data: {
|
|
301
|
+
message: `Workflow '${workflowName}' completed successfully`,
|
|
302
|
+
result: previousResult
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
} catch (error) {
|
|
306
|
+
return {
|
|
307
|
+
success: false,
|
|
308
|
+
error: error instanceof Error ? error.message : `Workflow '${workflowName}' failed`
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
getRegisteredWorkflows() {
|
|
313
|
+
return Array.from(this.workflows.keys());
|
|
314
|
+
}
|
|
315
|
+
async listPackages(appId) {
|
|
316
|
+
try {
|
|
317
|
+
const context = {
|
|
318
|
+
args: [],
|
|
319
|
+
options: appId ? {
|
|
320
|
+
appId
|
|
321
|
+
} : {}
|
|
322
|
+
};
|
|
323
|
+
const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
|
|
324
|
+
const result = await listPackage(appId || '');
|
|
325
|
+
return {
|
|
326
|
+
success: true,
|
|
327
|
+
data: result
|
|
328
|
+
};
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return {
|
|
331
|
+
success: false,
|
|
332
|
+
error: error instanceof Error ? error.message : 'Unknown error listing packages'
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
constructor(){
|
|
337
|
+
this.workflows = new Map();
|
|
338
|
+
this.init();
|
|
339
|
+
}
|
|
340
|
+
}
|
package/lib/user.js
CHANGED
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "userCommands", {
|
|
|
8
8
|
return userCommands;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _utils = require("./utils");
|
|
12
|
-
const _api = require("./api");
|
|
13
11
|
const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
12
|
+
const _api = require("./api");
|
|
13
|
+
const _utils = require("./utils");
|
|
14
14
|
const _i18n = require("./utils/i18n");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -36,7 +36,7 @@ const userCommands = {
|
|
|
36
36
|
name: info.name
|
|
37
37
|
}));
|
|
38
38
|
},
|
|
39
|
-
logout: async ()=>{
|
|
39
|
+
logout: async (context)=>{
|
|
40
40
|
await (0, _api.closeSession)();
|
|
41
41
|
console.log((0, _i18n.t)('loggedOut'));
|
|
42
42
|
},
|
|
@@ -13,7 +13,7 @@ class ApkParser extends Zip {
|
|
|
13
13
|
ResourceName
|
|
14
14
|
]).then((buffers)=>{
|
|
15
15
|
if (!buffers[ManifestName]) {
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error("AndroidManifest.xml can't be found.");
|
|
17
17
|
}
|
|
18
18
|
let apkInfo = this._parseManifest(buffers[ManifestName]);
|
|
19
19
|
let resourceMap;
|
|
@@ -4,7 +4,7 @@ const parseBplist = require('bplist-parser').parseBuffer;
|
|
|
4
4
|
const cgbiToPng = require('cgbi-to-png');
|
|
5
5
|
const Zip = require('./zip');
|
|
6
6
|
const { findIpaIconPath, getBase64FromBuffer, isBrowser } = require('./utils');
|
|
7
|
-
const PlistName =
|
|
7
|
+
const PlistName = /payload\/[^\/]+?.app\/info.plist$/i;
|
|
8
8
|
const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/;
|
|
9
9
|
class IpaParser extends Zip {
|
|
10
10
|
parse() {
|
|
@@ -14,7 +14,7 @@ class IpaParser extends Zip {
|
|
|
14
14
|
ProvisionName
|
|
15
15
|
]).then((buffers)=>{
|
|
16
16
|
if (!buffers[PlistName]) {
|
|
17
|
-
throw new Error(
|
|
17
|
+
throw new Error("Info.plist can't be found.");
|
|
18
18
|
}
|
|
19
19
|
const plistInfo = this._parsePlist(buffers[PlistName]);
|
|
20
20
|
// parse mobile provision
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Decode binary file `resources.arsc` from a .apk file to a JavaScript Object.
|
|
5
5
|
*/ "use strict";
|
|
6
|
-
var ByteBuffer = require(
|
|
6
|
+
var ByteBuffer = require('bytebuffer');
|
|
7
7
|
var DEBUG = false;
|
|
8
8
|
var RES_STRING_POOL_TYPE = 0x0001;
|
|
9
9
|
var RES_TABLE_TYPE = 0x0002;
|
|
@@ -30,12 +30,12 @@ function ResourceFinder() {
|
|
|
30
30
|
* @param bb ByteBuffer
|
|
31
31
|
* @param len length
|
|
32
32
|
* @returns {Buffer}
|
|
33
|
-
*/ ResourceFinder.readBytes =
|
|
33
|
+
*/ ResourceFinder.readBytes = (bb, len)=>{
|
|
34
34
|
var uint8Array = new Uint8Array(len);
|
|
35
35
|
for(var i = 0; i < len; i++){
|
|
36
36
|
uint8Array[i] = bb.readUint8();
|
|
37
37
|
}
|
|
38
|
-
return ByteBuffer.wrap(uint8Array,
|
|
38
|
+
return ByteBuffer.wrap(uint8Array, 'binary', true);
|
|
39
39
|
};
|
|
40
40
|
//
|
|
41
41
|
/**
|
|
@@ -43,14 +43,14 @@ function ResourceFinder() {
|
|
|
43
43
|
* @param {ByteBuffer} bb
|
|
44
44
|
* @return {Map<String, Set<String>>}
|
|
45
45
|
*/ ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
|
|
46
|
-
const bb = ByteBuffer.wrap(resourceBuffer,
|
|
46
|
+
const bb = ByteBuffer.wrap(resourceBuffer, 'binary', true);
|
|
47
47
|
// Resource table structure
|
|
48
48
|
var type = bb.readShort(), headerSize = bb.readShort(), size = bb.readInt(), packageCount = bb.readInt(), buffer, bb2;
|
|
49
49
|
if (type != RES_TABLE_TYPE) {
|
|
50
|
-
throw new Error(
|
|
50
|
+
throw new Error('No RES_TABLE_TYPE found!');
|
|
51
51
|
}
|
|
52
52
|
if (size != bb.limit) {
|
|
53
|
-
throw new Error(
|
|
53
|
+
throw new Error('The buffer size not matches to the resource table size.');
|
|
54
54
|
}
|
|
55
55
|
bb.offset = headerSize;
|
|
56
56
|
var realStringPoolCount = 0, realPackageCount = 0;
|
|
@@ -69,12 +69,12 @@ function ResourceFinder() {
|
|
|
69
69
|
if (realStringPoolCount == 0) {
|
|
70
70
|
// Only the first string pool is processed.
|
|
71
71
|
if (DEBUG) {
|
|
72
|
-
console.log(
|
|
72
|
+
console.log('Processing the string pool ...');
|
|
73
73
|
}
|
|
74
74
|
buffer = new ByteBuffer(s);
|
|
75
75
|
bb.offset = pos;
|
|
76
76
|
bb.prependTo(buffer);
|
|
77
|
-
bb2 = ByteBuffer.wrap(buffer,
|
|
77
|
+
bb2 = ByteBuffer.wrap(buffer, 'binary', true);
|
|
78
78
|
bb2.LE();
|
|
79
79
|
this.valueStringPool = this.processStringPool(bb2);
|
|
80
80
|
}
|
|
@@ -82,26 +82,26 @@ function ResourceFinder() {
|
|
|
82
82
|
} else if (t == RES_TABLE_PACKAGE_TYPE) {
|
|
83
83
|
// Process the package
|
|
84
84
|
if (DEBUG) {
|
|
85
|
-
console.log(
|
|
85
|
+
console.log('Processing the package ' + realPackageCount + ' ...');
|
|
86
86
|
}
|
|
87
87
|
buffer = new ByteBuffer(s);
|
|
88
88
|
bb.offset = pos;
|
|
89
89
|
bb.prependTo(buffer);
|
|
90
|
-
bb2 = ByteBuffer.wrap(buffer,
|
|
90
|
+
bb2 = ByteBuffer.wrap(buffer, 'binary', true);
|
|
91
91
|
bb2.LE();
|
|
92
92
|
this.processPackage(bb2);
|
|
93
93
|
realPackageCount++;
|
|
94
94
|
} else {
|
|
95
|
-
throw new Error(
|
|
95
|
+
throw new Error('Unsupported type');
|
|
96
96
|
}
|
|
97
97
|
bb.offset = pos + s;
|
|
98
98
|
if (!bb.remaining()) break;
|
|
99
99
|
}
|
|
100
100
|
if (realStringPoolCount != 1) {
|
|
101
|
-
throw new Error(
|
|
101
|
+
throw new Error('More than 1 string pool found!');
|
|
102
102
|
}
|
|
103
103
|
if (realPackageCount != packageCount) {
|
|
104
|
-
throw new Error(
|
|
104
|
+
throw new Error('Real package count not equals the declared count.');
|
|
105
105
|
}
|
|
106
106
|
return this.responseMap;
|
|
107
107
|
};
|
|
@@ -117,10 +117,10 @@ function ResourceFinder() {
|
|
|
117
117
|
}
|
|
118
118
|
var typeStrings = bb.readInt(), lastPublicType = bb.readInt(), keyStrings = bb.readInt(), lastPublicKey = bb.readInt();
|
|
119
119
|
if (typeStrings != headerSize) {
|
|
120
|
-
throw new Error(
|
|
120
|
+
throw new Error('TypeStrings must immediately following the package structure header.');
|
|
121
121
|
}
|
|
122
122
|
if (DEBUG) {
|
|
123
|
-
console.log(
|
|
123
|
+
console.log('Type strings:');
|
|
124
124
|
}
|
|
125
125
|
var lastPosition = bb.offset;
|
|
126
126
|
bb.offset = typeStrings;
|
|
@@ -129,7 +129,7 @@ function ResourceFinder() {
|
|
|
129
129
|
this.typeStringPool = this.processStringPool(bbTypeStrings);
|
|
130
130
|
// Key strings
|
|
131
131
|
if (DEBUG) {
|
|
132
|
-
console.log(
|
|
132
|
+
console.log('Key strings:');
|
|
133
133
|
}
|
|
134
134
|
bb.offset = keyStrings;
|
|
135
135
|
var key_type = bb.readShort(), key_headerSize = bb.readShort(), key_size = bb.readInt();
|
|
@@ -182,7 +182,7 @@ function ResourceFinder() {
|
|
|
182
182
|
// Skip the config data
|
|
183
183
|
bb.offset = headerSize;
|
|
184
184
|
if (headerSize + entryCount * 4 != entriesStart) {
|
|
185
|
-
throw new Error(
|
|
185
|
+
throw new Error('HeaderSize, entryCount and entriesStart are not valid.');
|
|
186
186
|
}
|
|
187
187
|
// Start to get entry indices
|
|
188
188
|
var entryIndices = new Array(entryCount);
|
|
@@ -213,9 +213,9 @@ function ResourceFinder() {
|
|
|
213
213
|
var keyStr = this.keyStringPool[entry_key];
|
|
214
214
|
var data = null;
|
|
215
215
|
if (DEBUG) {
|
|
216
|
-
console.log(
|
|
216
|
+
console.log('Entry 0x' + idStr + ', key: ' + keyStr + ', simple value type: ');
|
|
217
217
|
}
|
|
218
|
-
var key = parseInt(idStr, 16);
|
|
218
|
+
var key = Number.parseInt(idStr, 16);
|
|
219
219
|
var entryArr = this.entryMap[key];
|
|
220
220
|
if (entryArr == null) {
|
|
221
221
|
entryArr = [];
|
|
@@ -225,18 +225,18 @@ function ResourceFinder() {
|
|
|
225
225
|
if (value_dataType == TYPE_STRING) {
|
|
226
226
|
data = this.valueStringPool[value_data];
|
|
227
227
|
if (DEBUG) {
|
|
228
|
-
console.log(
|
|
228
|
+
console.log(', data: ' + this.valueStringPool[value_data] + '');
|
|
229
229
|
}
|
|
230
230
|
} else if (value_dataType == TYPE_REFERENCE) {
|
|
231
231
|
var hexIndex = Number(value_data).toString(16);
|
|
232
232
|
refKeys[idStr] = value_data;
|
|
233
233
|
} else {
|
|
234
|
-
data =
|
|
234
|
+
data = '' + value_data;
|
|
235
235
|
if (DEBUG) {
|
|
236
|
-
console.log(
|
|
236
|
+
console.log(', data: ' + value_data + '');
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
this.putIntoMap(
|
|
239
|
+
this.putIntoMap('@' + idStr, data);
|
|
240
240
|
} else {
|
|
241
241
|
// Complex case
|
|
242
242
|
var entry_parent = bb.readInt();
|
|
@@ -249,15 +249,15 @@ function ResourceFinder() {
|
|
|
249
249
|
value_data = bb.readInt();
|
|
250
250
|
}
|
|
251
251
|
if (DEBUG) {
|
|
252
|
-
console.log(
|
|
252
|
+
console.log('Entry 0x' + Number(resource_id).toString(16) + ', key: ' + this.keyStringPool[entry_key] + ', complex value, not printed.');
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
for(var refK in refKeys){
|
|
257
|
-
var values = this.responseMap[
|
|
257
|
+
var values = this.responseMap['@' + Number(refKeys[refK]).toString(16).toUpperCase()];
|
|
258
258
|
if (values != null && Object.keys(values).length < 1000) {
|
|
259
259
|
for(var value in values){
|
|
260
|
-
this.putIntoMap(
|
|
260
|
+
this.putIntoMap('@' + refK, values[value]);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -266,7 +266,7 @@ function ResourceFinder() {
|
|
|
266
266
|
*
|
|
267
267
|
* @param {ByteBuffer} bb
|
|
268
268
|
* @return {Array}
|
|
269
|
-
*/ ResourceFinder.prototype.processStringPool =
|
|
269
|
+
*/ ResourceFinder.prototype.processStringPool = (bb)=>{
|
|
270
270
|
// String pool structure
|
|
271
271
|
//
|
|
272
272
|
var type = bb.readShort(), headerSize = bb.readShort(), size = bb.readInt(), stringCount = bb.readInt(), styleCount = bb.readInt(), flags = bb.readInt(), stringsStart = bb.readInt(), stylesStart = bb.readInt(), u16len, buffer;
|
|
@@ -279,7 +279,7 @@ function ResourceFinder() {
|
|
|
279
279
|
for(var i = 0; i < stringCount; ++i){
|
|
280
280
|
var pos = stringsStart + offsets[i];
|
|
281
281
|
bb.offset = pos;
|
|
282
|
-
strings[i] =
|
|
282
|
+
strings[i] = '';
|
|
283
283
|
if (isUTF_8) {
|
|
284
284
|
u16len = bb.readUint8();
|
|
285
285
|
if ((u16len & 0x80) != 0) {
|
|
@@ -292,15 +292,15 @@ function ResourceFinder() {
|
|
|
292
292
|
if (u8len > 0) {
|
|
293
293
|
buffer = ResourceFinder.readBytes(bb, u8len);
|
|
294
294
|
try {
|
|
295
|
-
strings[i] = ByteBuffer.wrap(buffer,
|
|
295
|
+
strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
|
|
296
296
|
} catch (e) {
|
|
297
297
|
if (DEBUG) {
|
|
298
298
|
console.error(e);
|
|
299
|
-
console.log(
|
|
299
|
+
console.log('Error when turning buffer to utf-8 string.');
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
} else {
|
|
303
|
-
strings[i] =
|
|
303
|
+
strings[i] = '';
|
|
304
304
|
}
|
|
305
305
|
} else {
|
|
306
306
|
u16len = bb.readUint16();
|
|
@@ -312,17 +312,17 @@ function ResourceFinder() {
|
|
|
312
312
|
var len = u16len * 2;
|
|
313
313
|
buffer = ResourceFinder.readBytes(bb, len);
|
|
314
314
|
try {
|
|
315
|
-
strings[i] = ByteBuffer.wrap(buffer,
|
|
315
|
+
strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
|
|
316
316
|
} catch (e) {
|
|
317
317
|
if (DEBUG) {
|
|
318
318
|
console.error(e);
|
|
319
|
-
console.log(
|
|
319
|
+
console.log('Error when turning buffer to utf-8 string.');
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
if (DEBUG) {
|
|
325
|
-
console.log(
|
|
325
|
+
console.log('Parsed value: {0}', strings[i]);
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
return strings;
|
|
@@ -333,7 +333,7 @@ function ResourceFinder() {
|
|
|
333
333
|
*/ ResourceFinder.prototype.processTypeSpec = function(bb) {
|
|
334
334
|
var type = bb.readShort(), headerSize = bb.readShort(), size = bb.readInt(), id = bb.readByte(), res0 = bb.readByte(), res1 = bb.readShort(), entryCount = bb.readInt();
|
|
335
335
|
if (DEBUG) {
|
|
336
|
-
console.log(
|
|
336
|
+
console.log('Processing type spec ' + this.typeStringPool[id - 1] + '...');
|
|
337
337
|
}
|
|
338
338
|
var flags = new Array(entryCount);
|
|
339
339
|
for(var i = 0; i < entryCount; ++i){
|
|
@@ -6,7 +6,7 @@ const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
|
|
|
6
6
|
class ManifestParser {
|
|
7
7
|
collapseAttributes(element) {
|
|
8
8
|
const collapsed = Object.create(null);
|
|
9
|
-
for (
|
|
9
|
+
for (const attr of Array.from(element.attributes)){
|
|
10
10
|
collapsed[attr.name] = attr.typedValue.value;
|
|
11
11
|
}
|
|
12
12
|
return collapsed;
|
|
@@ -123,7 +123,7 @@ class ManifestParser {
|
|
|
123
123
|
return app;
|
|
124
124
|
}
|
|
125
125
|
isLauncherActivity(activity) {
|
|
126
|
-
return activity.intentFilters.some(
|
|
126
|
+
return activity.intentFilters.some((filter)=>{
|
|
127
127
|
const hasMain = filter.actions.some((action)=>action.name === INTENT_MAIN);
|
|
128
128
|
if (!hasMain) {
|
|
129
129
|
return false;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
const _bundle = require("../../bundle");
|
|
6
2
|
const Unzip = require('isomorphic-unzip');
|
|
7
3
|
const { isBrowser, decodeNullUnicode } = require('./utils');
|
|
4
|
+
const { enumZipEntries, readEntry } = require('../../bundle');
|
|
8
5
|
class Zip {
|
|
9
6
|
/**
|
|
10
7
|
* get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
|
|
@@ -40,9 +37,9 @@ class Zip {
|
|
|
40
37
|
async getEntryFromHarmonyApp(regex) {
|
|
41
38
|
try {
|
|
42
39
|
let originSource;
|
|
43
|
-
await
|
|
40
|
+
await enumZipEntries(this.file, (entry, zipFile)=>{
|
|
44
41
|
if (regex.test(entry.fileName)) {
|
|
45
|
-
return
|
|
42
|
+
return readEntry(entry, zipFile).then((v)=>originSource = v);
|
|
46
43
|
}
|
|
47
44
|
});
|
|
48
45
|
return originSource;
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "checkPlugins", {
|
|
|
8
8
|
return checkPlugins;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _pluginconfig = require("./plugin-config");
|
|
12
11
|
const _i18n = require("./i18n");
|
|
12
|
+
const _pluginconfig = require("./plugin-config");
|
|
13
13
|
async function checkPlugins() {
|
|
14
14
|
const params = {
|
|
15
15
|
sentry: false,
|