react-native-update-cli 1.30.3 → 1.31.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/cli.json +3 -1
- package/lib/api.js +177 -186
- package/lib/app.js +136 -114
- package/lib/bundle.js +535 -559
- package/lib/index.js +46 -49
- package/lib/package.js +132 -136
- package/lib/user.js +43 -41
- package/lib/utils/app-info-parser/apk.js +72 -71
- package/lib/utils/app-info-parser/index.js +28 -30
- package/lib/utils/app-info-parser/ipa.js +72 -80
- package/lib/utils/app-info-parser/resource-finder.js +286 -421
- package/lib/utils/app-info-parser/utils.js +106 -120
- package/lib/utils/app-info-parser/xml-parser/binary.js +539 -637
- package/lib/utils/app-info-parser/xml-parser/manifest.js +193 -215
- package/lib/utils/app-info-parser/zip.js +40 -40
- package/lib/utils/index.js +156 -149
- package/lib/versions.js +226 -178
- package/package.json +10 -9
- package/src/api.js +6 -3
- package/src/bundle.js +11 -10
- package/src/utils/index.js +4 -2
- package/src/versions.js +80 -16
- package/src/.DS_Store +0 -0
- package/src/utils/.DS_Store +0 -0
package/lib/app.js
CHANGED
|
@@ -1,128 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
checkPlatform: function() {
|
|
13
|
+
return checkPlatform;
|
|
14
|
+
},
|
|
15
|
+
chooseApp: function() {
|
|
16
|
+
return chooseApp;
|
|
17
|
+
},
|
|
18
|
+
commands: function() {
|
|
19
|
+
return commands;
|
|
20
|
+
},
|
|
21
|
+
getSelectedApp: function() {
|
|
22
|
+
return getSelectedApp;
|
|
23
|
+
},
|
|
24
|
+
listApp: function() {
|
|
25
|
+
return listApp;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _utils = require("./utils");
|
|
29
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
30
|
+
const _ttytable = /*#__PURE__*/ _interop_require_default(require("tty-table"));
|
|
31
|
+
const _api = require("./api");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
26
37
|
const validPlatforms = {
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
ios: 1,
|
|
39
|
+
android: 1
|
|
29
40
|
};
|
|
30
|
-
|
|
31
41
|
function checkPlatform(platform) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
if (!validPlatforms[platform]) {
|
|
43
|
+
throw new Error(`无法识别的平台 '${platform}'`);
|
|
44
|
+
}
|
|
45
|
+
return platform;
|
|
36
46
|
}
|
|
37
|
-
|
|
38
47
|
function getSelectedApp(platform) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return updateInfo[platform];
|
|
48
|
+
checkPlatform(platform);
|
|
49
|
+
if (!_fs.default.existsSync('update.json')) {
|
|
50
|
+
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
|
51
|
+
}
|
|
52
|
+
const updateInfo = JSON.parse(_fs.default.readFileSync('update.json', 'utf8'));
|
|
53
|
+
if (!updateInfo[platform]) {
|
|
54
|
+
throw new Error(`App not selected. run 'pushy selectApp --platform ${platform}' first!`);
|
|
55
|
+
}
|
|
56
|
+
return updateInfo[platform];
|
|
49
57
|
}
|
|
50
|
-
|
|
51
58
|
async function listApp(platform) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
const { data } = await (0, _api.get)('/app/list');
|
|
60
|
+
const list = platform ? data.filter((v)=>v.platform === platform) : data;
|
|
61
|
+
const header = [
|
|
62
|
+
{
|
|
63
|
+
value: '应用 id'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: '应用名称'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: '平台'
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const rows = [];
|
|
73
|
+
for (const app of list){
|
|
74
|
+
rows.push([
|
|
75
|
+
app.id,
|
|
76
|
+
app.name,
|
|
77
|
+
app.platform
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
console.log((0, _ttytable.default)(header, rows).render());
|
|
81
|
+
if (platform) {
|
|
82
|
+
console.log(`\共 ${list.length} ${platform} 个应用`);
|
|
83
|
+
} else {
|
|
84
|
+
console.log(`\共 ${list.length} 个应用`);
|
|
85
|
+
}
|
|
86
|
+
return list;
|
|
69
87
|
}
|
|
70
|
-
|
|
71
88
|
async function chooseApp(platform) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
const list = await listApp(platform);
|
|
90
|
+
while(true){
|
|
91
|
+
const id = await (0, _utils.question)('输入应用 id:');
|
|
92
|
+
const app = list.find((v)=>v.id === (id | 0));
|
|
93
|
+
if (app) {
|
|
94
|
+
return app;
|
|
95
|
+
}
|
|
79
96
|
}
|
|
80
|
-
}
|
|
81
97
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
const commands = {
|
|
99
|
+
createApp: async function({ options }) {
|
|
100
|
+
const name = options.name || await (0, _utils.question)('应用名称:');
|
|
101
|
+
const { downloadUrl } = options;
|
|
102
|
+
const platform = checkPlatform(options.platform || await (0, _utils.question)('平台(ios/android):'));
|
|
103
|
+
const { id } = await (0, _api.post)('/app/create', {
|
|
104
|
+
name,
|
|
105
|
+
platform
|
|
106
|
+
});
|
|
107
|
+
console.log(`已成功创建应用(id: ${id})`);
|
|
108
|
+
await this.selectApp({
|
|
109
|
+
args: [
|
|
110
|
+
id
|
|
111
|
+
],
|
|
112
|
+
options: {
|
|
113
|
+
platform,
|
|
114
|
+
downloadUrl
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
deleteApp: async function({ args, options }) {
|
|
119
|
+
const { platform } = options;
|
|
120
|
+
const id = args[0] || chooseApp(platform);
|
|
121
|
+
if (!id) {
|
|
122
|
+
console.log('已取消');
|
|
123
|
+
}
|
|
124
|
+
await (0, _api.doDelete)(`/app/${id}`);
|
|
125
|
+
console.log('操作成功');
|
|
126
|
+
},
|
|
127
|
+
apps: async function({ options }) {
|
|
128
|
+
const { platform } = options;
|
|
129
|
+
listApp(platform);
|
|
130
|
+
},
|
|
131
|
+
selectApp: async function({ args, options }) {
|
|
132
|
+
const platform = checkPlatform(options.platform || await (0, _utils.question)('平台(ios/android):'));
|
|
133
|
+
const id = args[0] ? parseInt(args[0]) : (await chooseApp(platform)).id;
|
|
134
|
+
let updateInfo = {};
|
|
135
|
+
if (_fs.default.existsSync('update.json')) {
|
|
136
|
+
try {
|
|
137
|
+
updateInfo = JSON.parse(_fs.default.readFileSync('update.json', 'utf8'));
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.error('Failed to parse file `update.json`. Try to remove it manually.');
|
|
140
|
+
throw e;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const { appKey } = await (0, _api.get)(`/app/${id}`);
|
|
144
|
+
updateInfo[platform] = {
|
|
145
|
+
appId: id,
|
|
146
|
+
appKey
|
|
147
|
+
};
|
|
148
|
+
_fs.default.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
100
149
|
}
|
|
101
|
-
|
|
102
|
-
console.log('操作成功');
|
|
103
|
-
},
|
|
104
|
-
apps: async function ({ options }) {
|
|
105
|
-
const { platform } = options;
|
|
106
|
-
listApp(platform);
|
|
107
|
-
},
|
|
108
|
-
selectApp: async function ({ args, options }) {
|
|
109
|
-
const platform = checkPlatform(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
110
|
-
const id = args[0] ? parseInt(args[0]) : (await chooseApp(platform)).id;
|
|
111
|
-
|
|
112
|
-
let updateInfo = {};
|
|
113
|
-
if (_fs2.default.existsSync('update.json')) {
|
|
114
|
-
try {
|
|
115
|
-
updateInfo = JSON.parse(_fs2.default.readFileSync('update.json', 'utf8'));
|
|
116
|
-
} catch (e) {
|
|
117
|
-
console.error('Failed to parse file `update.json`. Try to remove it manually.');
|
|
118
|
-
throw e;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const { appKey } = await (0, _api.get)(`/app/${id}`);
|
|
122
|
-
updateInfo[platform] = {
|
|
123
|
-
appId: id,
|
|
124
|
-
appKey
|
|
125
|
-
};
|
|
126
|
-
_fs2.default.writeFileSync('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
127
|
-
}
|
|
128
|
-
};
|
|
150
|
+
};
|