react-native-update-cli 1.5.0 → 1.7.1
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 +4 -0
- package/lib/api.js +3 -9
- package/lib/app.js +11 -15
- package/lib/bundle.js +3 -7
- package/lib/index.js +2 -6
- package/lib/package.js +13 -13
- package/lib/user.js +2 -2
- package/lib/versions.js +41 -27
- package/package.json +1 -1
- package/src/api.js +3 -13
- package/src/app.js +13 -17
- package/src/bundle.js +3 -7
- package/src/index.js +13 -14
- package/src/package.js +13 -13
- package/src/user.js +2 -2
- package/src/versions.js +78 -41
- package/LICENSE +0 -29
package/cli.json
CHANGED
package/lib/api.js
CHANGED
|
@@ -16,10 +16,6 @@ var _utils = require('./utils');
|
|
|
16
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Created by tdzl2003 on 2/13/16.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
19
|
const fetch = require('node-fetch');
|
|
24
20
|
const defaultEndpoint = 'http://u.reactnative.cn/api';
|
|
25
21
|
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
@@ -151,10 +147,10 @@ async function uploadFile(fn, key) {
|
|
|
151
147
|
|
|
152
148
|
const fileSize = fs.statSync(fn).size;
|
|
153
149
|
if (maxSize && fileSize > (0, _filesizeParser2.default)(maxSize)) {
|
|
154
|
-
throw new Error(`此文件大小${(fileSize / 1048576).toFixed(1)}m, 超出当前额度${maxSize}
|
|
150
|
+
throw new Error(`此文件大小${(fileSize / 1048576).toFixed(1)}m, 超出当前额度${maxSize}。您可以考虑升级付费业务以提升此额度。详情请访问: ${_utils.pricingPageUrl}`);
|
|
155
151
|
}
|
|
156
152
|
|
|
157
|
-
const bar = new _progress2.default('
|
|
153
|
+
const bar = new _progress2.default(' 上传中 [:bar] :percent :etas', {
|
|
158
154
|
complete: '=',
|
|
159
155
|
incomplete: ' ',
|
|
160
156
|
total: fileSize
|
|
@@ -182,9 +178,7 @@ async function uploadFile(fn, key) {
|
|
|
182
178
|
if (resp.statusCode > 299) {
|
|
183
179
|
return reject(Object.assign(new Error(body), { status: resp.statusCode }));
|
|
184
180
|
}
|
|
185
|
-
resolve(
|
|
186
|
-
JSON.parse(body) : // aliyun oss
|
|
187
|
-
{ hash: formData.key });
|
|
181
|
+
resolve({ hash: formData.key });
|
|
188
182
|
});
|
|
189
183
|
});
|
|
190
184
|
return info;
|
package/lib/app.js
CHANGED
|
@@ -17,10 +17,6 @@ var _fs2 = _interopRequireDefault(_fs);
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Created by tdzl2003 on 2/13/16.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
20
|
const Table = require('tty-table');
|
|
25
21
|
|
|
26
22
|
const { post, get, doDelete } = require('./api');
|
|
@@ -32,7 +28,7 @@ const validPlatforms = {
|
|
|
32
28
|
|
|
33
29
|
function checkPlatform(platform) {
|
|
34
30
|
if (!validPlatforms[platform]) {
|
|
35
|
-
throw new Error(
|
|
31
|
+
throw new Error(`无法识别的平台 '${platform}'`);
|
|
36
32
|
}
|
|
37
33
|
return platform;
|
|
38
34
|
}
|
|
@@ -54,7 +50,7 @@ async function listApp(platform) {
|
|
|
54
50
|
const { data } = await get('/app/list');
|
|
55
51
|
const list = platform ? data.filter(v => v.platform === platform) : data;
|
|
56
52
|
|
|
57
|
-
const header = [{ value: '
|
|
53
|
+
const header = [{ value: '应用 id' }, { value: '应用名称' }, { value: '平台' }];
|
|
58
54
|
const rows = [];
|
|
59
55
|
for (const app of list) {
|
|
60
56
|
rows.push([app.id, app.name, app.platform]);
|
|
@@ -63,9 +59,9 @@ async function listApp(platform) {
|
|
|
63
59
|
console.log(Table(header, rows).render());
|
|
64
60
|
|
|
65
61
|
if (platform) {
|
|
66
|
-
console.log(
|
|
62
|
+
console.log(`\共 ${list.length} ${platform} 个应用`);
|
|
67
63
|
} else {
|
|
68
|
-
console.log(
|
|
64
|
+
console.log(`\共 ${list.length} 个应用`);
|
|
69
65
|
}
|
|
70
66
|
return list;
|
|
71
67
|
}
|
|
@@ -74,7 +70,7 @@ async function chooseApp(platform) {
|
|
|
74
70
|
const list = await listApp(platform);
|
|
75
71
|
|
|
76
72
|
while (true) {
|
|
77
|
-
const id = await (0, _utils.question)('
|
|
73
|
+
const id = await (0, _utils.question)('输入应用 id:');
|
|
78
74
|
const app = list.find(v => v.id === (id | 0));
|
|
79
75
|
if (app) {
|
|
80
76
|
return app;
|
|
@@ -84,11 +80,11 @@ async function chooseApp(platform) {
|
|
|
84
80
|
|
|
85
81
|
const commands = exports.commands = {
|
|
86
82
|
createApp: async function ({ options }) {
|
|
87
|
-
const name = options.name || (await (0, _utils.question)('
|
|
83
|
+
const name = options.name || (await (0, _utils.question)('应用名称:'));
|
|
88
84
|
const { downloadUrl } = options;
|
|
89
|
-
const platform = checkPlatform(options.platform || (await (0, _utils.question)('
|
|
85
|
+
const platform = checkPlatform(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
90
86
|
const { id } = await post('/app/create', { name, platform });
|
|
91
|
-
console.log(
|
|
87
|
+
console.log(`已成功创建应用(id: ${id})`);
|
|
92
88
|
await this.selectApp({
|
|
93
89
|
args: [id],
|
|
94
90
|
options: { platform, downloadUrl }
|
|
@@ -98,17 +94,17 @@ const commands = exports.commands = {
|
|
|
98
94
|
const { platform } = options;
|
|
99
95
|
const id = args[0] || chooseApp(platform);
|
|
100
96
|
if (!id) {
|
|
101
|
-
console.log('
|
|
97
|
+
console.log('已取消');
|
|
102
98
|
}
|
|
103
99
|
await doDelete(`/app/${id}`);
|
|
104
|
-
console.log('
|
|
100
|
+
console.log('操作成功');
|
|
105
101
|
},
|
|
106
102
|
apps: async function ({ options }) {
|
|
107
103
|
const { platform } = options;
|
|
108
104
|
listApp(platform);
|
|
109
105
|
},
|
|
110
106
|
selectApp: async function ({ args, options }) {
|
|
111
|
-
const platform = checkPlatform(options.platform || (await (0, _utils.question)('
|
|
107
|
+
const platform = checkPlatform(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
112
108
|
const id = args[0] || (await chooseApp(platform)).id;
|
|
113
109
|
|
|
114
110
|
let updateInfo = {};
|
package/lib/bundle.js
CHANGED
|
@@ -21,10 +21,6 @@ var _app = require('./app');
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Created by tdzl2003 on 2/22/16.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
24
|
const path = require('path');
|
|
29
25
|
|
|
30
26
|
const { spawn, spawnSync } = require('child_process');
|
|
@@ -167,7 +163,7 @@ async function pack(dir, output) {
|
|
|
167
163
|
});
|
|
168
164
|
zipfile.end();
|
|
169
165
|
});
|
|
170
|
-
console.log('
|
|
166
|
+
console.log('ppk热更包已生成并保存到: ' + output);
|
|
171
167
|
}
|
|
172
168
|
|
|
173
169
|
function readEntire(entry, zipFile) {
|
|
@@ -457,7 +453,7 @@ function diffArgsCheck(args, options, diffFn) {
|
|
|
457
453
|
|
|
458
454
|
const commands = exports.commands = {
|
|
459
455
|
bundle: async function ({ options }) {
|
|
460
|
-
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('
|
|
456
|
+
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
461
457
|
|
|
462
458
|
let {
|
|
463
459
|
bundleName,
|
|
@@ -487,7 +483,7 @@ const commands = exports.commands = {
|
|
|
487
483
|
|
|
488
484
|
await pack(path.resolve(intermediaDir), realOutput);
|
|
489
485
|
|
|
490
|
-
const v = await (0, _utils.question)('
|
|
486
|
+
const v = await (0, _utils.question)('是否现在上传此热更包?(Y/N)');
|
|
491
487
|
if (v.toLowerCase() === 'y') {
|
|
492
488
|
await this.publish({
|
|
493
489
|
args: [realOutput],
|
package/lib/index.js
CHANGED
|
@@ -5,10 +5,6 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
|
|
5
5
|
|
|
6
6
|
var _index = require('./utils/index.js');
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Created by tdzl2003 on 2/13/16.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
8
|
const { loadSession } = require('./api');
|
|
13
9
|
const updateNotifier = require('update-notifier');
|
|
14
10
|
|
|
@@ -41,12 +37,12 @@ function run() {
|
|
|
41
37
|
|
|
42
38
|
loadSession().then(() => commands[argv.command](argv)).catch(err => {
|
|
43
39
|
if (err.status === 401) {
|
|
44
|
-
console.log('
|
|
40
|
+
console.log('尚未登录。\n请在项目目录中运行`pushy login`命令来登录');
|
|
45
41
|
return;
|
|
46
42
|
}
|
|
47
43
|
console.error(err.stack);
|
|
48
44
|
process.exit(-1);
|
|
49
45
|
});
|
|
50
|
-
}
|
|
46
|
+
}
|
|
51
47
|
|
|
52
48
|
run();
|
package/lib/package.js
CHANGED
|
@@ -37,7 +37,7 @@ async function listPackage(appId) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
console.log(Table(header, rows).render());
|
|
40
|
-
console.log(`\
|
|
40
|
+
console.log(`\n共 ${data.length} 个包`);
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ async function choosePackage(appId) {
|
|
|
45
45
|
const list = await listPackage(appId);
|
|
46
46
|
|
|
47
47
|
while (true) {
|
|
48
|
-
const id = await (0, _utils.question)('
|
|
48
|
+
const id = await (0, _utils.question)('输入原生包 id:');
|
|
49
49
|
const app = list.find(v => v.id === (id | 0));
|
|
50
50
|
if (app) {
|
|
51
51
|
return app;
|
|
@@ -57,7 +57,7 @@ const commands = exports.commands = {
|
|
|
57
57
|
uploadIpa: async function ({ args }) {
|
|
58
58
|
const fn = args[0];
|
|
59
59
|
if (!fn || !fn.endsWith('.ipa')) {
|
|
60
|
-
throw new Error('
|
|
60
|
+
throw new Error('使用方法: pushy uploadIpa ipa后缀文件');
|
|
61
61
|
}
|
|
62
62
|
const {
|
|
63
63
|
versionName,
|
|
@@ -68,11 +68,11 @@ const commands = exports.commands = {
|
|
|
68
68
|
const { appId, appKey } = await (0, _app.getSelectedApp)('ios');
|
|
69
69
|
|
|
70
70
|
if (appIdInPkg && appIdInPkg !== appId) {
|
|
71
|
-
throw new Error(`appId不匹配!当前ipa
|
|
71
|
+
throw new Error(`appId不匹配!当前ipa: ${appIdInPkg}, 当前update.json: ${appId}`);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
75
|
-
throw new Error(`appKey不匹配!当前ipa
|
|
75
|
+
throw new Error(`appKey不匹配!当前ipa: ${appKeyInPkg}, 当前update.json: ${appKey}`);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const { hash } = await uploadFile(fn);
|
|
@@ -83,12 +83,12 @@ const commands = exports.commands = {
|
|
|
83
83
|
buildTime
|
|
84
84
|
});
|
|
85
85
|
(0, _utils.saveToLocal)(fn, `${appId}/package/${id}.ipa`);
|
|
86
|
-
console.log(
|
|
86
|
+
console.log(`已成功上传ipa原生包(id: ${id})`);
|
|
87
87
|
},
|
|
88
88
|
uploadApk: async function ({ args }) {
|
|
89
89
|
const fn = args[0];
|
|
90
90
|
if (!fn || !fn.endsWith('.apk')) {
|
|
91
|
-
throw new Error('
|
|
91
|
+
throw new Error('使用方法: pushy uploadApk apk后缀文件');
|
|
92
92
|
}
|
|
93
93
|
const {
|
|
94
94
|
versionName,
|
|
@@ -99,11 +99,11 @@ const commands = exports.commands = {
|
|
|
99
99
|
const { appId, appKey } = await (0, _app.getSelectedApp)('android');
|
|
100
100
|
|
|
101
101
|
if (appIdInPkg && appIdInPkg !== appId) {
|
|
102
|
-
throw new Error(`appId不匹配!当前apk
|
|
102
|
+
throw new Error(`appId不匹配!当前apk: ${appIdInPkg}, 当前update.json: ${appId}`);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
106
|
-
throw new Error(`appKey不匹配!当前apk
|
|
106
|
+
throw new Error(`appKey不匹配!当前apk: ${appKeyInPkg}, 当前update.json: ${appKey}`);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
const { hash } = await uploadFile(fn);
|
|
@@ -114,24 +114,24 @@ const commands = exports.commands = {
|
|
|
114
114
|
buildTime
|
|
115
115
|
});
|
|
116
116
|
(0, _utils.saveToLocal)(fn, `${appId}/package/${id}.apk`);
|
|
117
|
-
console.log(
|
|
117
|
+
console.log(`已成功上传apk原生包(id: ${id})`);
|
|
118
118
|
},
|
|
119
119
|
parseIpa: async function ({ args }) {
|
|
120
120
|
const fn = args[0];
|
|
121
121
|
if (!fn || !fn.endsWith('.ipa')) {
|
|
122
|
-
throw new Error('
|
|
122
|
+
throw new Error('使用方法: pushy parseIpa ipa后缀文件');
|
|
123
123
|
}
|
|
124
124
|
console.log((await (0, _utils.getIpaInfo)(fn)));
|
|
125
125
|
},
|
|
126
126
|
parseApk: async function ({ args }) {
|
|
127
127
|
const fn = args[0];
|
|
128
128
|
if (!fn || !fn.endsWith('.apk')) {
|
|
129
|
-
throw new Error('
|
|
129
|
+
throw new Error('使用方法: pushy parseApk apk后缀文件');
|
|
130
130
|
}
|
|
131
131
|
console.log((await (0, _utils.getApkInfo)(fn)));
|
|
132
132
|
},
|
|
133
133
|
packages: async function ({ options }) {
|
|
134
|
-
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('
|
|
134
|
+
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
135
135
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
136
136
|
await listPackage(appId);
|
|
137
137
|
}
|
package/lib/user.js
CHANGED
|
@@ -28,11 +28,11 @@ exports.commands = {
|
|
|
28
28
|
});
|
|
29
29
|
replaceSession({ token });
|
|
30
30
|
await saveSession();
|
|
31
|
-
console.log(
|
|
31
|
+
console.log(`欢迎使用 pushy 热更新服务, ${info.name}.`);
|
|
32
32
|
},
|
|
33
33
|
logout: async function () {
|
|
34
34
|
await closeSession();
|
|
35
|
-
console.log('
|
|
35
|
+
console.log('已退出登录');
|
|
36
36
|
},
|
|
37
37
|
me: async function () {
|
|
38
38
|
const me = await get('/user/me');
|
package/lib/versions.js
CHANGED
|
@@ -11,16 +11,7 @@ var _app = require('./app');
|
|
|
11
11
|
|
|
12
12
|
var _package = require('./package');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* Created by tdzl2003 on 4/2/16.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
get,
|
|
20
|
-
post,
|
|
21
|
-
put,
|
|
22
|
-
uploadFile
|
|
23
|
-
} = require('./api');
|
|
14
|
+
const { get, post, put, uploadFile } = require('./api');
|
|
24
15
|
|
|
25
16
|
|
|
26
17
|
async function showVersion(appId, offset) {
|
|
@@ -49,11 +40,14 @@ async function listVersions(appId) {
|
|
|
49
40
|
const cmd = await (0, _utils.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
|
|
50
41
|
switch (cmd.toLowerCase()) {
|
|
51
42
|
case 'u':
|
|
52
|
-
offset = Math.max(0, offset - 10);
|
|
43
|
+
offset = Math.max(0, offset - 10);
|
|
44
|
+
break;
|
|
53
45
|
case 'd':
|
|
54
|
-
offset += 10;
|
|
46
|
+
offset += 10;
|
|
47
|
+
break;
|
|
55
48
|
case 'b':
|
|
56
|
-
offset = 0;
|
|
49
|
+
offset = 0;
|
|
50
|
+
break;
|
|
57
51
|
case 'q':
|
|
58
52
|
return;
|
|
59
53
|
}
|
|
@@ -67,11 +61,14 @@ async function chooseVersion(appId) {
|
|
|
67
61
|
const cmd = await (0, _utils.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
|
|
68
62
|
switch (cmd.toLowerCase()) {
|
|
69
63
|
case 'U':
|
|
70
|
-
offset = Math.max(0, offset - 10);
|
|
64
|
+
offset = Math.max(0, offset - 10);
|
|
65
|
+
break;
|
|
71
66
|
case 'D':
|
|
72
|
-
offset += 10;
|
|
67
|
+
offset += 10;
|
|
68
|
+
break;
|
|
73
69
|
case 'B':
|
|
74
|
-
offset = 0;
|
|
70
|
+
offset = 0;
|
|
71
|
+
break;
|
|
75
72
|
default:
|
|
76
73
|
{
|
|
77
74
|
const v = data.find(v => v.id === (cmd | 0));
|
|
@@ -89,42 +86,59 @@ const commands = exports.commands = {
|
|
|
89
86
|
const { name, description, metaInfo } = options;
|
|
90
87
|
|
|
91
88
|
if (!fn || !fn.endsWith('.ppk')) {
|
|
92
|
-
throw new Error('
|
|
89
|
+
throw new Error('使用方法: pushy publish ppk后缀文件 --platform ios|android');
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('
|
|
92
|
+
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
96
93
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
97
94
|
|
|
98
95
|
const { hash } = await uploadFile(fn);
|
|
99
96
|
|
|
100
97
|
const { id } = await post(`/app/${appId}/version/create`, {
|
|
101
|
-
name: name || (await (0, _utils.question)('
|
|
98
|
+
name: name || (await (0, _utils.question)('输入版本名称: ')) || '(未命名)',
|
|
102
99
|
hash,
|
|
103
|
-
description: description || (await (0, _utils.question)('
|
|
104
|
-
metaInfo: metaInfo || (await (0, _utils.question)('
|
|
100
|
+
description: description || (await (0, _utils.question)('输入版本描述:')),
|
|
101
|
+
metaInfo: metaInfo || (await (0, _utils.question)('输入自定义的 meta info:'))
|
|
105
102
|
});
|
|
106
103
|
// TODO local diff
|
|
107
104
|
(0, _utils.saveToLocal)(fn, `${appId}/ppk/${id}.ppk`);
|
|
108
|
-
console.log(
|
|
105
|
+
console.log(`已成功上传新热更包(id: ${id})`);
|
|
109
106
|
|
|
110
|
-
const v = await (0, _utils.question)('
|
|
107
|
+
const v = await (0, _utils.question)('是否现在将此热更应用到原生包上?(Y/N)');
|
|
111
108
|
if (v.toLowerCase() === 'y') {
|
|
112
109
|
await this.update({ args: [], options: { versionId: id, platform } });
|
|
113
110
|
}
|
|
114
111
|
},
|
|
115
112
|
versions: async function ({ options }) {
|
|
116
|
-
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('
|
|
113
|
+
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
117
114
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
118
115
|
await listVersions(appId);
|
|
119
116
|
},
|
|
120
117
|
update: async function ({ args, options }) {
|
|
121
|
-
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('
|
|
118
|
+
const platform = (0, _app.checkPlatform)(options.platform || (await (0, _utils.question)('平台(ios/android):')));
|
|
122
119
|
const { appId } = await (0, _app.getSelectedApp)(platform);
|
|
123
120
|
const versionId = options.versionId || (await chooseVersion(appId)).id;
|
|
124
|
-
|
|
121
|
+
let pkgId = options.packageId;
|
|
122
|
+
if (!pkgId) {
|
|
123
|
+
let pkgVersion = options.packageVersion;
|
|
124
|
+
if (pkgVersion) {
|
|
125
|
+
pkgVersion = pkgVersion.trim();
|
|
126
|
+
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
|
|
127
|
+
const pkg = data.find(d => d.name === pkgVersion);
|
|
128
|
+
if (pkg) {
|
|
129
|
+
pkgId = pkg.id;
|
|
130
|
+
} else {
|
|
131
|
+
throw new Error(`未查询到匹配原生版本:${pkgVersion}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!pkgId) {
|
|
137
|
+
throw new Error('请提供 packageId 或 packageVersion 参数');
|
|
138
|
+
}
|
|
125
139
|
await put(`/app/${appId}/package/${pkgId}`, {
|
|
126
140
|
versionId
|
|
127
141
|
});
|
|
128
|
-
console.log('
|
|
142
|
+
console.log('操作成功');
|
|
129
143
|
}
|
|
130
144
|
};
|
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by tdzl2003 on 2/13/16.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
const fetch = require('node-fetch');
|
|
6
2
|
const defaultEndpoint = 'http://u.reactnative.cn/api';
|
|
7
3
|
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
@@ -140,11 +136,11 @@ async function uploadFile(fn, key) {
|
|
|
140
136
|
throw new Error(
|
|
141
137
|
`此文件大小${(fileSize / 1048576).toFixed(
|
|
142
138
|
1,
|
|
143
|
-
)}m, 超出当前额度${maxSize}
|
|
139
|
+
)}m, 超出当前额度${maxSize}。您可以考虑升级付费业务以提升此额度。详情请访问: ${pricingPageUrl}`,
|
|
144
140
|
);
|
|
145
141
|
}
|
|
146
142
|
|
|
147
|
-
const bar = new ProgressBar('
|
|
143
|
+
const bar = new ProgressBar(' 上传中 [:bar] :percent :etas', {
|
|
148
144
|
complete: '=',
|
|
149
145
|
incomplete: ' ',
|
|
150
146
|
total: fileSize,
|
|
@@ -177,13 +173,7 @@ async function uploadFile(fn, key) {
|
|
|
177
173
|
Object.assign(new Error(body), { status: resp.statusCode }),
|
|
178
174
|
);
|
|
179
175
|
}
|
|
180
|
-
resolve(
|
|
181
|
-
body
|
|
182
|
-
? // qiniu
|
|
183
|
-
JSON.parse(body)
|
|
184
|
-
: // aliyun oss
|
|
185
|
-
{ hash: formData.key },
|
|
186
|
-
);
|
|
176
|
+
resolve({ hash: formData.key });
|
|
187
177
|
},
|
|
188
178
|
);
|
|
189
179
|
});
|
package/src/app.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by tdzl2003 on 2/13/16.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import { question } from './utils';
|
|
6
2
|
import fs from 'fs';
|
|
7
3
|
const Table = require('tty-table');
|
|
@@ -15,7 +11,7 @@ const validPlatforms = {
|
|
|
15
11
|
|
|
16
12
|
export function checkPlatform(platform) {
|
|
17
13
|
if (!validPlatforms[platform]) {
|
|
18
|
-
throw new Error(
|
|
14
|
+
throw new Error(`无法识别的平台 '${platform}'`);
|
|
19
15
|
}
|
|
20
16
|
return platform;
|
|
21
17
|
}
|
|
@@ -42,9 +38,9 @@ export async function listApp(platform) {
|
|
|
42
38
|
const list = platform ? data.filter((v) => v.platform === platform) : data;
|
|
43
39
|
|
|
44
40
|
const header = [
|
|
45
|
-
{ value: '
|
|
46
|
-
{ value: '
|
|
47
|
-
{ value: '
|
|
41
|
+
{ value: '应用 id' },
|
|
42
|
+
{ value: '应用名称' },
|
|
43
|
+
{ value: '平台' },
|
|
48
44
|
];
|
|
49
45
|
const rows = [];
|
|
50
46
|
for (const app of list) {
|
|
@@ -54,9 +50,9 @@ export async function listApp(platform) {
|
|
|
54
50
|
console.log(Table(header, rows).render());
|
|
55
51
|
|
|
56
52
|
if (platform) {
|
|
57
|
-
console.log(
|
|
53
|
+
console.log(`\共 ${list.length} ${platform} 个应用`);
|
|
58
54
|
} else {
|
|
59
|
-
console.log(
|
|
55
|
+
console.log(`\共 ${list.length} 个应用`);
|
|
60
56
|
}
|
|
61
57
|
return list;
|
|
62
58
|
}
|
|
@@ -65,7 +61,7 @@ export async function chooseApp(platform) {
|
|
|
65
61
|
const list = await listApp(platform);
|
|
66
62
|
|
|
67
63
|
while (true) {
|
|
68
|
-
const id = await question('
|
|
64
|
+
const id = await question('输入应用 id:');
|
|
69
65
|
const app = list.find((v) => v.id === (id | 0));
|
|
70
66
|
if (app) {
|
|
71
67
|
return app;
|
|
@@ -75,13 +71,13 @@ export async function chooseApp(platform) {
|
|
|
75
71
|
|
|
76
72
|
export const commands = {
|
|
77
73
|
createApp: async function ({ options }) {
|
|
78
|
-
const name = options.name || (await question('
|
|
74
|
+
const name = options.name || (await question('应用名称:'));
|
|
79
75
|
const { downloadUrl } = options;
|
|
80
76
|
const platform = checkPlatform(
|
|
81
|
-
options.platform || (await question('
|
|
77
|
+
options.platform || (await question('平台(ios/android):')),
|
|
82
78
|
);
|
|
83
79
|
const { id } = await post('/app/create', { name, platform });
|
|
84
|
-
console.log(
|
|
80
|
+
console.log(`已成功创建应用(id: ${id})`);
|
|
85
81
|
await this.selectApp({
|
|
86
82
|
args: [id],
|
|
87
83
|
options: { platform, downloadUrl },
|
|
@@ -91,10 +87,10 @@ export const commands = {
|
|
|
91
87
|
const { platform } = options;
|
|
92
88
|
const id = args[0] || chooseApp(platform);
|
|
93
89
|
if (!id) {
|
|
94
|
-
console.log('
|
|
90
|
+
console.log('已取消');
|
|
95
91
|
}
|
|
96
92
|
await doDelete(`/app/${id}`);
|
|
97
|
-
console.log('
|
|
93
|
+
console.log('操作成功');
|
|
98
94
|
},
|
|
99
95
|
apps: async function ({ options }) {
|
|
100
96
|
const { platform } = options;
|
|
@@ -102,7 +98,7 @@ export const commands = {
|
|
|
102
98
|
},
|
|
103
99
|
selectApp: async function ({ args, options }) {
|
|
104
100
|
const platform = checkPlatform(
|
|
105
|
-
options.platform || (await question('
|
|
101
|
+
options.platform || (await question('平台(ios/android):')),
|
|
106
102
|
);
|
|
107
103
|
const id = args[0] || (await chooseApp(platform)).id;
|
|
108
104
|
|
package/src/bundle.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by tdzl2003 on 2/22/16.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
const path = require('path');
|
|
6
2
|
import { getRNVersion, translateOptions } from './utils';
|
|
7
3
|
import * as fs from 'fs-extra';
|
|
@@ -197,7 +193,7 @@ async function pack(dir, output) {
|
|
|
197
193
|
});
|
|
198
194
|
zipfile.end();
|
|
199
195
|
});
|
|
200
|
-
console.log('
|
|
196
|
+
console.log('ppk热更包已生成并保存到: ' + output);
|
|
201
197
|
}
|
|
202
198
|
|
|
203
199
|
function readEntire(entry, zipFile) {
|
|
@@ -515,7 +511,7 @@ function diffArgsCheck(args, options, diffFn) {
|
|
|
515
511
|
export const commands = {
|
|
516
512
|
bundle: async function ({ options }) {
|
|
517
513
|
const platform = checkPlatform(
|
|
518
|
-
options.platform || (await question('
|
|
514
|
+
options.platform || (await question('平台(ios/android):')),
|
|
519
515
|
);
|
|
520
516
|
|
|
521
517
|
let {
|
|
@@ -553,7 +549,7 @@ export const commands = {
|
|
|
553
549
|
|
|
554
550
|
await pack(path.resolve(intermediaDir), realOutput);
|
|
555
551
|
|
|
556
|
-
const v = await question('
|
|
552
|
+
const v = await question('是否现在上传此热更包?(Y/N)');
|
|
557
553
|
if (v.toLowerCase() === 'y') {
|
|
558
554
|
await this.publish({
|
|
559
555
|
args: [realOutput],
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Created by tdzl2003 on 2/13/16.
|
|
4
|
-
*/
|
|
5
2
|
|
|
6
|
-
const {loadSession} = require('./api');
|
|
3
|
+
const { loadSession } = require('./api');
|
|
7
4
|
const updateNotifier = require('update-notifier');
|
|
8
5
|
import { printVersionCommand } from './utils/index.js';
|
|
9
6
|
const pkg = require('../package.json');
|
|
10
7
|
|
|
11
|
-
updateNotifier({pkg}).notify({isGlobal: true});
|
|
8
|
+
updateNotifier({ pkg }).notify({ isGlobal: true });
|
|
12
9
|
|
|
13
|
-
function printUsage({args}) {
|
|
10
|
+
function printUsage({ args }) {
|
|
14
11
|
// const commandName = args[0];
|
|
15
12
|
// TODO: print usage of commandName, or print global usage.
|
|
16
13
|
|
|
17
|
-
console.log('Usage is under development now.')
|
|
18
|
-
console.log(
|
|
14
|
+
console.log('Usage is under development now.');
|
|
15
|
+
console.log(
|
|
16
|
+
'Visit `https://github.com/reactnativecn/react-native-pushy` for early document.',
|
|
17
|
+
);
|
|
19
18
|
process.exit(1);
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -33,21 +32,21 @@ function run() {
|
|
|
33
32
|
printVersionCommand();
|
|
34
33
|
process.exit();
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
|
|
37
36
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
38
37
|
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
39
38
|
global.USE_ACC_OSS = argv.options['acc'];
|
|
40
39
|
|
|
41
40
|
loadSession()
|
|
42
|
-
.then(()=>commands[argv.command](argv))
|
|
43
|
-
.catch(err=>{
|
|
41
|
+
.then(() => commands[argv.command](argv))
|
|
42
|
+
.catch((err) => {
|
|
44
43
|
if (err.status === 401) {
|
|
45
|
-
console.log('
|
|
44
|
+
console.log('尚未登录。\n请在项目目录中运行`pushy login`命令来登录');
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
console.error(err.stack);
|
|
49
48
|
process.exit(-1);
|
|
50
49
|
});
|
|
51
|
-
}
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
run();
|
|
52
|
+
run();
|
package/src/package.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function listPackage(appId) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
console.log(Table(header, rows).render());
|
|
33
|
-
console.log(`\
|
|
33
|
+
console.log(`\n共 ${data.length} 个包`);
|
|
34
34
|
return data;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -38,7 +38,7 @@ export async function choosePackage(appId) {
|
|
|
38
38
|
const list = await listPackage(appId);
|
|
39
39
|
|
|
40
40
|
while (true) {
|
|
41
|
-
const id = await question('
|
|
41
|
+
const id = await question('输入原生包 id:');
|
|
42
42
|
const app = list.find((v) => v.id === (id | 0));
|
|
43
43
|
if (app) {
|
|
44
44
|
return app;
|
|
@@ -50,7 +50,7 @@ export const commands = {
|
|
|
50
50
|
uploadIpa: async function ({ args }) {
|
|
51
51
|
const fn = args[0];
|
|
52
52
|
if (!fn || !fn.endsWith('.ipa')) {
|
|
53
|
-
throw new Error('
|
|
53
|
+
throw new Error('使用方法: pushy uploadIpa ipa后缀文件');
|
|
54
54
|
}
|
|
55
55
|
const {
|
|
56
56
|
versionName,
|
|
@@ -62,13 +62,13 @@ export const commands = {
|
|
|
62
62
|
|
|
63
63
|
if (appIdInPkg && appIdInPkg !== appId) {
|
|
64
64
|
throw new Error(
|
|
65
|
-
`appId不匹配!当前ipa
|
|
65
|
+
`appId不匹配!当前ipa: ${appIdInPkg}, 当前update.json: ${appId}`,
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
70
70
|
throw new Error(
|
|
71
|
-
`appKey不匹配!当前ipa
|
|
71
|
+
`appKey不匹配!当前ipa: ${appKeyInPkg}, 当前update.json: ${appKey}`,
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -80,12 +80,12 @@ export const commands = {
|
|
|
80
80
|
buildTime,
|
|
81
81
|
});
|
|
82
82
|
saveToLocal(fn, `${appId}/package/${id}.ipa`);
|
|
83
|
-
console.log(
|
|
83
|
+
console.log(`已成功上传ipa原生包(id: ${id})`);
|
|
84
84
|
},
|
|
85
85
|
uploadApk: async function ({ args }) {
|
|
86
86
|
const fn = args[0];
|
|
87
87
|
if (!fn || !fn.endsWith('.apk')) {
|
|
88
|
-
throw new Error('
|
|
88
|
+
throw new Error('使用方法: pushy uploadApk apk后缀文件');
|
|
89
89
|
}
|
|
90
90
|
const {
|
|
91
91
|
versionName,
|
|
@@ -97,13 +97,13 @@ export const commands = {
|
|
|
97
97
|
|
|
98
98
|
if (appIdInPkg && appIdInPkg !== appId) {
|
|
99
99
|
throw new Error(
|
|
100
|
-
`appId不匹配!当前apk
|
|
100
|
+
`appId不匹配!当前apk: ${appIdInPkg}, 当前update.json: ${appId}`,
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (appKeyInPkg && appKeyInPkg !== appKey) {
|
|
105
105
|
throw new Error(
|
|
106
|
-
`appKey不匹配!当前apk
|
|
106
|
+
`appKey不匹配!当前apk: ${appKeyInPkg}, 当前update.json: ${appKey}`,
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -115,25 +115,25 @@ export const commands = {
|
|
|
115
115
|
buildTime,
|
|
116
116
|
});
|
|
117
117
|
saveToLocal(fn, `${appId}/package/${id}.apk`);
|
|
118
|
-
console.log(
|
|
118
|
+
console.log(`已成功上传apk原生包(id: ${id})`);
|
|
119
119
|
},
|
|
120
120
|
parseIpa: async function ({ args }) {
|
|
121
121
|
const fn = args[0];
|
|
122
122
|
if (!fn || !fn.endsWith('.ipa')) {
|
|
123
|
-
throw new Error('
|
|
123
|
+
throw new Error('使用方法: pushy parseIpa ipa后缀文件');
|
|
124
124
|
}
|
|
125
125
|
console.log(await getIpaInfo(fn));
|
|
126
126
|
},
|
|
127
127
|
parseApk: async function ({ args }) {
|
|
128
128
|
const fn = args[0];
|
|
129
129
|
if (!fn || !fn.endsWith('.apk')) {
|
|
130
|
-
throw new Error('
|
|
130
|
+
throw new Error('使用方法: pushy parseApk apk后缀文件');
|
|
131
131
|
}
|
|
132
132
|
console.log(await getApkInfo(fn));
|
|
133
133
|
},
|
|
134
134
|
packages: async function ({ options }) {
|
|
135
135
|
const platform = checkPlatform(
|
|
136
|
-
options.platform || (await question('
|
|
136
|
+
options.platform || (await question('平台(ios/android):')),
|
|
137
137
|
);
|
|
138
138
|
const { appId } = await getSelectedApp(platform);
|
|
139
139
|
await listPackage(appId);
|
package/src/user.js
CHANGED
|
@@ -26,11 +26,11 @@ exports.commands = {
|
|
|
26
26
|
});
|
|
27
27
|
replaceSession({token});
|
|
28
28
|
await saveSession();
|
|
29
|
-
console.log(
|
|
29
|
+
console.log(`欢迎使用 pushy 热更新服务, ${info.name}.`);
|
|
30
30
|
},
|
|
31
31
|
logout: async function (){
|
|
32
32
|
await closeSession();
|
|
33
|
-
console.log('
|
|
33
|
+
console.log('已退出登录');
|
|
34
34
|
},
|
|
35
35
|
me: async function (){
|
|
36
36
|
const me = await get('/user/me');
|
package/src/versions.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Created by tdzl2003 on 4/2/16.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
get,
|
|
7
|
-
post,
|
|
8
|
-
put,
|
|
9
|
-
uploadFile,
|
|
10
|
-
} = require('./api');
|
|
1
|
+
const { get, post, put, uploadFile } = require('./api');
|
|
11
2
|
import { question, saveToLocal } from './utils';
|
|
12
3
|
|
|
13
4
|
import { checkPlatform, getSelectedApp } from './app';
|
|
@@ -17,17 +8,24 @@ async function showVersion(appId, offset) {
|
|
|
17
8
|
const { data, count } = await get(`/app/${appId}/version/list`);
|
|
18
9
|
console.log(`Offset ${offset}`);
|
|
19
10
|
for (const version of data) {
|
|
20
|
-
let packageInfo = version.packages
|
|
11
|
+
let packageInfo = version.packages
|
|
12
|
+
.slice(0, 3)
|
|
13
|
+
.map((v) => v.name)
|
|
14
|
+
.join(', ');
|
|
21
15
|
const count = version.packages.length;
|
|
22
16
|
if (count > 3) {
|
|
23
|
-
packageInfo += `...and ${count-3} more`;
|
|
17
|
+
packageInfo += `...and ${count - 3} more`;
|
|
24
18
|
}
|
|
25
19
|
if (count === 0) {
|
|
26
20
|
packageInfo = `(no package)`;
|
|
27
21
|
} else {
|
|
28
22
|
packageInfo = `[${packageInfo}]`;
|
|
29
23
|
}
|
|
30
|
-
console.log(
|
|
24
|
+
console.log(
|
|
25
|
+
`${version.id}) ${version.hash.slice(0, 8)} ${
|
|
26
|
+
version.name
|
|
27
|
+
} ${packageInfo}`,
|
|
28
|
+
);
|
|
31
29
|
}
|
|
32
30
|
return data;
|
|
33
31
|
}
|
|
@@ -38,10 +36,17 @@ async function listVersions(appId) {
|
|
|
38
36
|
await showVersion(appId, offset);
|
|
39
37
|
const cmd = await question('page Up/page Down/Begin/Quit(U/D/B/Q)');
|
|
40
38
|
switch (cmd.toLowerCase()) {
|
|
41
|
-
case 'u':
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
case '
|
|
39
|
+
case 'u':
|
|
40
|
+
offset = Math.max(0, offset - 10);
|
|
41
|
+
break;
|
|
42
|
+
case 'd':
|
|
43
|
+
offset += 10;
|
|
44
|
+
break;
|
|
45
|
+
case 'b':
|
|
46
|
+
offset = 0;
|
|
47
|
+
break;
|
|
48
|
+
case 'q':
|
|
49
|
+
return;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -50,14 +55,21 @@ async function chooseVersion(appId) {
|
|
|
50
55
|
let offset = 0;
|
|
51
56
|
while (true) {
|
|
52
57
|
const data = await showVersion(appId, offset);
|
|
53
|
-
const cmd = await question(
|
|
58
|
+
const cmd = await question(
|
|
59
|
+
'Enter versionId or page Up/page Down/Begin(U/D/B)',
|
|
60
|
+
);
|
|
54
61
|
switch (cmd.toLowerCase()) {
|
|
55
|
-
case 'U':
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
case 'U':
|
|
63
|
+
offset = Math.max(0, offset - 10);
|
|
64
|
+
break;
|
|
65
|
+
case 'D':
|
|
66
|
+
offset += 10;
|
|
67
|
+
break;
|
|
68
|
+
case 'B':
|
|
69
|
+
offset = 0;
|
|
70
|
+
break;
|
|
71
|
+
default: {
|
|
72
|
+
const v = data.find((v) => v.id === (cmd | 0));
|
|
61
73
|
if (v) {
|
|
62
74
|
return v;
|
|
63
75
|
}
|
|
@@ -67,47 +79,72 @@ async function chooseVersion(appId) {
|
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
export const commands = {
|
|
70
|
-
publish: async function({args, options}) {
|
|
82
|
+
publish: async function ({ args, options }) {
|
|
71
83
|
const fn = args[0];
|
|
72
|
-
const {name, description, metaInfo } = options;
|
|
84
|
+
const { name, description, metaInfo } = options;
|
|
73
85
|
|
|
74
86
|
if (!fn || !fn.endsWith('.ppk')) {
|
|
75
|
-
throw new Error(
|
|
87
|
+
throw new Error(
|
|
88
|
+
'使用方法: pushy publish ppk后缀文件 --platform ios|android',
|
|
89
|
+
);
|
|
76
90
|
}
|
|
77
91
|
|
|
78
|
-
const platform = checkPlatform(
|
|
92
|
+
const platform = checkPlatform(
|
|
93
|
+
options.platform || (await question('平台(ios/android):')),
|
|
94
|
+
);
|
|
79
95
|
const { appId } = await getSelectedApp(platform);
|
|
80
96
|
|
|
81
97
|
const { hash } = await uploadFile(fn);
|
|
82
98
|
|
|
83
99
|
const { id } = await post(`/app/${appId}/version/create`, {
|
|
84
|
-
name: name || await question('
|
|
100
|
+
name: name || (await question('输入版本名称: ')) || '(未命名)',
|
|
85
101
|
hash,
|
|
86
|
-
description: description || await question('
|
|
87
|
-
metaInfo: metaInfo || await question('
|
|
102
|
+
description: description || (await question('输入版本描述:')),
|
|
103
|
+
metaInfo: metaInfo || (await question('输入自定义的 meta info:')),
|
|
88
104
|
});
|
|
89
105
|
// TODO local diff
|
|
90
106
|
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
|
|
91
|
-
console.log(
|
|
107
|
+
console.log(`已成功上传新热更包(id: ${id})`);
|
|
92
108
|
|
|
93
|
-
const v = await question('
|
|
109
|
+
const v = await question('是否现在将此热更应用到原生包上?(Y/N)');
|
|
94
110
|
if (v.toLowerCase() === 'y') {
|
|
95
|
-
await this.update({args:[], options:{versionId: id, platform}});
|
|
111
|
+
await this.update({ args: [], options: { versionId: id, platform } });
|
|
96
112
|
}
|
|
97
113
|
},
|
|
98
|
-
versions: async function({options}) {
|
|
99
|
-
const platform = checkPlatform(
|
|
114
|
+
versions: async function ({ options }) {
|
|
115
|
+
const platform = checkPlatform(
|
|
116
|
+
options.platform || (await question('平台(ios/android):')),
|
|
117
|
+
);
|
|
100
118
|
const { appId } = await getSelectedApp(platform);
|
|
101
119
|
await listVersions(appId);
|
|
102
120
|
},
|
|
103
|
-
update: async function({args, options}) {
|
|
104
|
-
const platform = checkPlatform(
|
|
121
|
+
update: async function ({ args, options }) {
|
|
122
|
+
const platform = checkPlatform(
|
|
123
|
+
options.platform || (await question('平台(ios/android):')),
|
|
124
|
+
);
|
|
105
125
|
const { appId } = await getSelectedApp(platform);
|
|
106
126
|
const versionId = options.versionId || (await chooseVersion(appId)).id;
|
|
107
|
-
|
|
127
|
+
let pkgId = options.packageId;
|
|
128
|
+
if (!pkgId) {
|
|
129
|
+
let pkgVersion = options.packageVersion;
|
|
130
|
+
if (pkgVersion) {
|
|
131
|
+
pkgVersion = pkgVersion.trim();
|
|
132
|
+
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
|
|
133
|
+
const pkg = data.find((d) => d.name === pkgVersion);
|
|
134
|
+
if (pkg) {
|
|
135
|
+
pkgId = pkg.id;
|
|
136
|
+
} else {
|
|
137
|
+
throw new Error(`未查询到匹配原生版本:${pkgVersion}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!pkgId) {
|
|
143
|
+
throw new Error('请提供 packageId 或 packageVersion 参数');
|
|
144
|
+
}
|
|
108
145
|
await put(`/app/${appId}/package/${pkgId}`, {
|
|
109
146
|
versionId,
|
|
110
147
|
});
|
|
111
|
-
console.log('
|
|
112
|
-
}
|
|
148
|
+
console.log('操作成功');
|
|
149
|
+
},
|
|
113
150
|
};
|
package/LICENSE
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020, reactnativecn
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|