react-native-update-cli 2.18.0 → 2.20.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 +143 -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 +190 -240
- 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/native-package.d.ts +17 -0
- package/lib/native-package.js +232 -0
- package/lib/package.js +180 -225
- 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 +47 -3
- package/src/diff.ts +12 -20
- package/src/native-package.ts +248 -0
- package/src/package.ts +29 -19
- package/src/user.ts +1 -1
- package/src/versions.ts +1 -1
package/lib/api.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const get: (api: string) => Promise<any>;
|
|
|
12
12
|
export declare const post: (api: string, body?: Record<string, any>) => Promise<any>;
|
|
13
13
|
export declare const put: (api: string, body?: Record<string, any>) => Promise<any>;
|
|
14
14
|
export declare const doDelete: (api: string, body?: Record<string, any>) => Promise<any>;
|
|
15
|
-
export declare function uploadFile(fn: string, key?: string): Promise<{
|
|
15
|
+
export declare function uploadFile(fn: string, key?: string, appId?: string | number): Promise<{
|
|
16
16
|
hash: any;
|
|
17
17
|
}>;
|
|
18
18
|
export declare const getAllPackages: (appId: string) => Promise<Package[] | null | undefined>;
|
package/lib/api.js
CHANGED
|
@@ -1,119 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return get;
|
|
20
|
-
},
|
|
21
|
-
get getAllPackages () {
|
|
22
|
-
return getAllPackages;
|
|
23
|
-
},
|
|
24
|
-
get getApiToken () {
|
|
25
|
-
return getApiToken;
|
|
26
|
-
},
|
|
27
|
-
get getSession () {
|
|
28
|
-
return getSession;
|
|
29
|
-
},
|
|
30
|
-
get loadSession () {
|
|
31
|
-
return loadSession;
|
|
32
|
-
},
|
|
33
|
-
get post () {
|
|
34
|
-
return post;
|
|
35
|
-
},
|
|
36
|
-
get put () {
|
|
37
|
-
return put;
|
|
38
|
-
},
|
|
39
|
-
get replaceSession () {
|
|
40
|
-
return replaceSession;
|
|
41
|
-
},
|
|
42
|
-
get saveSession () {
|
|
43
|
-
return saveSession;
|
|
44
|
-
},
|
|
45
|
-
get setApiToken () {
|
|
46
|
-
return setApiToken;
|
|
47
|
-
},
|
|
48
|
-
get uploadFile () {
|
|
49
|
-
return uploadFile;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const _filesizeparser = /*#__PURE__*/ _interop_require_default(require("filesize-parser"));
|
|
53
|
-
const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
|
|
54
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
55
|
-
const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
|
|
56
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
57
|
-
const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
|
|
58
|
-
const _httphelper = require("./utils/http-helper");
|
|
59
|
-
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
60
|
-
const _constants = require("./utils/constants");
|
|
61
|
-
const _i18n = require("./utils/i18n");
|
|
62
|
-
const _runtime = require("./utils/runtime");
|
|
63
|
-
function _interop_require_default(obj) {
|
|
64
|
-
return obj && obj.__esModule ? obj : {
|
|
65
|
-
default: obj
|
|
66
|
-
};
|
|
67
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAllPackages = exports.doDelete = exports.put = exports.post = exports.get = exports.closeSession = exports.saveSession = exports.loadSession = exports.replaceSession = exports.setApiToken = exports.getApiToken = exports.getSession = void 0;
|
|
7
|
+
exports.uploadFile = uploadFile;
|
|
8
|
+
const filesize_parser_1 = __importDefault(require("filesize-parser"));
|
|
9
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const progress_1 = __importDefault(require("progress"));
|
|
14
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
15
|
+
const constants_1 = require("./utils/constants");
|
|
16
|
+
const http_helper_1 = require("./utils/http-helper");
|
|
17
|
+
const i18n_1 = require("./utils/i18n");
|
|
18
|
+
const runtime_1 = require("./utils/runtime");
|
|
68
19
|
let session;
|
|
69
20
|
let savedSession;
|
|
70
21
|
let apiToken;
|
|
71
|
-
const userAgent = `react-native-update-cli/${
|
|
72
|
-
const getSession = ()=>session;
|
|
73
|
-
|
|
74
|
-
const
|
|
22
|
+
const userAgent = `react-native-update-cli/${package_json_1.default.version}`;
|
|
23
|
+
const getSession = () => session;
|
|
24
|
+
exports.getSession = getSession;
|
|
25
|
+
const getApiToken = () => apiToken;
|
|
26
|
+
exports.getApiToken = getApiToken;
|
|
27
|
+
const setApiToken = (token) => {
|
|
75
28
|
apiToken = token;
|
|
76
29
|
};
|
|
77
|
-
|
|
30
|
+
exports.setApiToken = setApiToken;
|
|
31
|
+
const loadApiTokenFromEnv = () => {
|
|
78
32
|
// Use CRESC_API_TOKEN for cresc, PUSHY_API_TOKEN for pushy
|
|
79
|
-
const envToken =
|
|
33
|
+
const envToken = constants_1.IS_CRESC
|
|
34
|
+
? process.env.CRESC_API_TOKEN
|
|
35
|
+
: process.env.PUSHY_API_TOKEN;
|
|
80
36
|
if (envToken) {
|
|
81
37
|
apiToken = envToken;
|
|
82
38
|
}
|
|
83
39
|
};
|
|
84
|
-
const replaceSession = (newSession)=>{
|
|
40
|
+
const replaceSession = (newSession) => {
|
|
85
41
|
session = newSession;
|
|
86
42
|
};
|
|
87
|
-
|
|
43
|
+
exports.replaceSession = replaceSession;
|
|
44
|
+
const loadSession = async () => {
|
|
88
45
|
loadApiTokenFromEnv();
|
|
89
|
-
if (
|
|
46
|
+
if (fs_1.default.existsSync(constants_1.credentialFile)) {
|
|
90
47
|
try {
|
|
91
|
-
replaceSession(JSON.parse(
|
|
48
|
+
(0, exports.replaceSession)(JSON.parse(fs_1.default.readFileSync(constants_1.credentialFile, 'utf8')));
|
|
92
49
|
savedSession = session;
|
|
93
|
-
}
|
|
94
|
-
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.error(`Failed to parse file ${constants_1.credentialFile}. Try to remove it manually.`);
|
|
95
53
|
throw e;
|
|
96
54
|
}
|
|
97
55
|
}
|
|
98
56
|
};
|
|
99
|
-
|
|
57
|
+
exports.loadSession = loadSession;
|
|
58
|
+
const saveSession = () => {
|
|
100
59
|
// Only save on change.
|
|
101
60
|
if (session !== savedSession) {
|
|
102
61
|
const current = session;
|
|
103
62
|
const data = JSON.stringify(current, null, 4);
|
|
104
|
-
|
|
63
|
+
fs_1.default.writeFileSync(constants_1.credentialFile, data, 'utf8');
|
|
105
64
|
savedSession = current;
|
|
106
65
|
}
|
|
107
66
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
exports.saveSession = saveSession;
|
|
68
|
+
const closeSession = () => {
|
|
69
|
+
if (fs_1.default.existsSync(constants_1.credentialFile)) {
|
|
70
|
+
fs_1.default.unlinkSync(constants_1.credentialFile);
|
|
111
71
|
savedSession = undefined;
|
|
112
72
|
}
|
|
113
73
|
session = undefined;
|
|
114
74
|
};
|
|
75
|
+
exports.closeSession = closeSession;
|
|
115
76
|
function createRequestError(error, requestUrl, status) {
|
|
116
|
-
const message = typeof error === 'string'
|
|
77
|
+
const message = typeof error === 'string'
|
|
78
|
+
? error
|
|
79
|
+
: error instanceof Error
|
|
80
|
+
? error.message
|
|
81
|
+
: String(error);
|
|
117
82
|
const requestError = new Error(`${message}\nURL: ${requestUrl}`);
|
|
118
83
|
requestError.status = status;
|
|
119
84
|
return requestError;
|
|
@@ -129,23 +94,28 @@ const PROXY_ERROR_PATTERNS = [
|
|
|
129
94
|
'proxy',
|
|
130
95
|
'ETIMEDOUT',
|
|
131
96
|
'EHOSTUNREACH',
|
|
132
|
-
'ENETUNREACH'
|
|
97
|
+
'ENETUNREACH',
|
|
133
98
|
];
|
|
134
99
|
function isProxyRelatedError(error) {
|
|
135
|
-
const msg = error instanceof Error
|
|
100
|
+
const msg = error instanceof Error
|
|
101
|
+
? error.message
|
|
102
|
+
: typeof error === 'string'
|
|
103
|
+
? error
|
|
104
|
+
: '';
|
|
136
105
|
const lower = msg.toLowerCase();
|
|
137
|
-
return PROXY_ERROR_PATTERNS.some((p)=>lower.includes(p.toLowerCase()));
|
|
106
|
+
return PROXY_ERROR_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
|
|
138
107
|
}
|
|
139
108
|
async function query(url, options) {
|
|
140
|
-
const baseUrl = await
|
|
109
|
+
const baseUrl = await http_helper_1.getBaseUrl;
|
|
141
110
|
const fullUrl = `${baseUrl}${url}`;
|
|
142
111
|
let resp;
|
|
143
112
|
try {
|
|
144
|
-
resp = await (0,
|
|
145
|
-
}
|
|
113
|
+
resp = await (0, runtime_1.runtimeFetch)(fullUrl, options);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
146
116
|
const baseError = createRequestError(error, fullUrl);
|
|
147
117
|
if (isProxyRelatedError(error)) {
|
|
148
|
-
throw new Error(`${baseError.message}\n\n${(0,
|
|
118
|
+
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`);
|
|
149
119
|
}
|
|
150
120
|
throw baseError;
|
|
151
121
|
}
|
|
@@ -153,7 +123,8 @@ async function query(url, options) {
|
|
|
153
123
|
let json;
|
|
154
124
|
try {
|
|
155
125
|
json = JSON.parse(text);
|
|
156
|
-
}
|
|
126
|
+
}
|
|
127
|
+
catch (_e) {
|
|
157
128
|
if (resp.status === 200) {
|
|
158
129
|
// a proxy/gateway likely replaced the response; surface it instead of
|
|
159
130
|
// returning undefined and crashing callers on destructuring
|
|
@@ -161,91 +132,128 @@ async function query(url, options) {
|
|
|
161
132
|
}
|
|
162
133
|
}
|
|
163
134
|
if (resp.status !== 200) {
|
|
164
|
-
const message =
|
|
135
|
+
const message = json?.message || resp.statusText || `HTTP ${resp.status}`;
|
|
165
136
|
if (resp.status === 401) {
|
|
166
|
-
throw createRequestError((0,
|
|
137
|
+
throw createRequestError((0, i18n_1.t)('loginExpired'), fullUrl, resp.status);
|
|
167
138
|
}
|
|
168
139
|
throw createRequestError(message, fullUrl, resp.status);
|
|
169
140
|
}
|
|
170
141
|
return json;
|
|
171
142
|
}
|
|
172
143
|
function queryWithoutBody(method) {
|
|
173
|
-
return (api)=>{
|
|
144
|
+
return (api) => {
|
|
174
145
|
const headers = {
|
|
175
|
-
'User-Agent': userAgent
|
|
146
|
+
'User-Agent': userAgent,
|
|
176
147
|
};
|
|
177
148
|
if (apiToken) {
|
|
178
149
|
headers['x-api-token'] = apiToken;
|
|
179
|
-
}
|
|
150
|
+
}
|
|
151
|
+
else if (session?.token) {
|
|
180
152
|
headers['X-AccessToken'] = session.token;
|
|
181
153
|
}
|
|
182
154
|
return query(api, {
|
|
183
155
|
method,
|
|
184
|
-
headers
|
|
156
|
+
headers,
|
|
185
157
|
});
|
|
186
158
|
};
|
|
187
159
|
}
|
|
188
160
|
function queryWithBody(method) {
|
|
189
|
-
return (api, body)=>{
|
|
161
|
+
return (api, body) => {
|
|
190
162
|
const headers = {
|
|
191
163
|
'User-Agent': userAgent,
|
|
192
|
-
'Content-Type': 'application/json'
|
|
164
|
+
'Content-Type': 'application/json',
|
|
193
165
|
};
|
|
194
166
|
if (apiToken) {
|
|
195
167
|
headers['x-api-token'] = apiToken;
|
|
196
|
-
}
|
|
168
|
+
}
|
|
169
|
+
else if (session?.token) {
|
|
197
170
|
headers['X-AccessToken'] = session.token;
|
|
198
171
|
}
|
|
199
172
|
return query(api, {
|
|
200
173
|
method,
|
|
201
174
|
headers,
|
|
202
|
-
body: JSON.stringify(body)
|
|
175
|
+
body: JSON.stringify(body),
|
|
203
176
|
});
|
|
204
177
|
};
|
|
205
178
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
async function uploadFile(fn, key) {
|
|
211
|
-
|
|
212
|
-
|
|
179
|
+
exports.get = queryWithoutBody('GET');
|
|
180
|
+
exports.post = queryWithBody('POST');
|
|
181
|
+
exports.put = queryWithBody('PUT');
|
|
182
|
+
exports.doDelete = queryWithBody('DELETE');
|
|
183
|
+
async function uploadFile(fn, key, appId) {
|
|
184
|
+
// appId 用于服务端路由:绑定了自托管节点(rnu-node)的应用,
|
|
185
|
+
// 上传指令会指向节点或其对象存储
|
|
186
|
+
const resp = await (0, exports.post)('/upload', {
|
|
187
|
+
ext: path_1.default.extname(fn),
|
|
188
|
+
...(appId ? { appId: Number(appId) } : {}),
|
|
213
189
|
});
|
|
190
|
+
const { url, backupUrl, formData, maxSize } = resp;
|
|
214
191
|
let realUrl = url;
|
|
215
192
|
if (backupUrl) {
|
|
216
193
|
if (global.USE_ACC_OSS) {
|
|
217
194
|
realUrl = backupUrl;
|
|
218
|
-
}
|
|
219
|
-
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const latency = await (0, runtime_1.measureTcpLatency)(url, {
|
|
220
198
|
attempts: 4,
|
|
221
|
-
timeout: 1000
|
|
199
|
+
timeout: 1000,
|
|
222
200
|
});
|
|
223
201
|
if (!Number.isFinite(latency) || latency > 150) {
|
|
224
202
|
realUrl = backupUrl;
|
|
225
203
|
}
|
|
226
204
|
}
|
|
227
|
-
|
|
205
|
+
// console.log({realUrl});
|
|
228
206
|
}
|
|
229
|
-
const fileSize =
|
|
230
|
-
if (maxSize && fileSize > (0,
|
|
207
|
+
const fileSize = fs_1.default.statSync(fn).size;
|
|
208
|
+
if (maxSize && fileSize > (0, filesize_parser_1.default)(maxSize)) {
|
|
231
209
|
const readableFileSize = `${(fileSize / 1048576).toFixed(1)}m`;
|
|
232
|
-
throw new Error((0,
|
|
210
|
+
throw new Error((0, i18n_1.t)('fileSizeExceeded', {
|
|
233
211
|
fileSize: readableFileSize,
|
|
234
212
|
maxSize,
|
|
235
|
-
pricingPageUrl:
|
|
213
|
+
pricingPageUrl: constants_1.pricingPageUrl,
|
|
236
214
|
}));
|
|
237
215
|
}
|
|
238
|
-
const bar = new
|
|
216
|
+
const bar = new progress_1.default(' Uploading [:bar] :percent :etas', {
|
|
239
217
|
complete: '=',
|
|
240
218
|
incomplete: ' ',
|
|
241
|
-
total: fileSize
|
|
219
|
+
total: fileSize,
|
|
242
220
|
});
|
|
243
|
-
|
|
244
|
-
|
|
221
|
+
// 自托管节点的 s3 直传:服务端下发预签名 PUT,字节直达用户的对象存储
|
|
222
|
+
if (resp.method === 'PUT') {
|
|
223
|
+
const fileStream = fs_1.default.createReadStream(fn);
|
|
224
|
+
fileStream.on('data', (data) => {
|
|
225
|
+
bar.tick(data.length);
|
|
226
|
+
});
|
|
227
|
+
let putRes;
|
|
228
|
+
try {
|
|
229
|
+
putRes = await (0, node_fetch_1.default)(realUrl, {
|
|
230
|
+
method: 'PUT',
|
|
231
|
+
body: fileStream,
|
|
232
|
+
// 预签名 PUT 不接受 chunked 传输,必须显式声明长度
|
|
233
|
+
headers: {
|
|
234
|
+
'content-length': String(fileSize),
|
|
235
|
+
...(resp.headers || {}),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (isProxyRelatedError(error)) {
|
|
241
|
+
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
242
|
+
throw new Error(`${rawMessage}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`);
|
|
243
|
+
}
|
|
244
|
+
throw createRequestError(error, realUrl);
|
|
245
|
+
}
|
|
246
|
+
if (putRes.status > 299) {
|
|
247
|
+
throw createRequestError(`${putRes.status}: ${putRes.statusText || 'Upload failed'}`, realUrl);
|
|
248
|
+
}
|
|
249
|
+
return { hash: resp.key };
|
|
250
|
+
}
|
|
251
|
+
const form = new form_data_1.default();
|
|
252
|
+
for (const [k, v] of Object.entries(formData)) {
|
|
245
253
|
form.append(k, v);
|
|
246
254
|
}
|
|
247
|
-
const fileStream =
|
|
248
|
-
fileStream.on('data', (data)=>{
|
|
255
|
+
const fileStream = fs_1.default.createReadStream(fn);
|
|
256
|
+
fileStream.on('data', (data) => {
|
|
249
257
|
bar.tick(data.length);
|
|
250
258
|
});
|
|
251
259
|
if (key) {
|
|
@@ -257,14 +265,15 @@ async function uploadFile(fn, key) {
|
|
|
257
265
|
// });
|
|
258
266
|
let res;
|
|
259
267
|
try {
|
|
260
|
-
res = await (0,
|
|
268
|
+
res = await (0, node_fetch_1.default)(realUrl, {
|
|
261
269
|
method: 'POST',
|
|
262
|
-
body: form
|
|
270
|
+
body: form,
|
|
263
271
|
});
|
|
264
|
-
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
265
274
|
if (isProxyRelatedError(error)) {
|
|
266
275
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
267
|
-
throw new Error(`${rawMessage}\n\n${(0,
|
|
276
|
+
throw new Error(`${rawMessage}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`);
|
|
268
277
|
}
|
|
269
278
|
throw createRequestError(error, realUrl);
|
|
270
279
|
}
|
|
@@ -272,21 +281,20 @@ async function uploadFile(fn, key) {
|
|
|
272
281
|
throw createRequestError(`${res.status}: ${res.statusText || 'Upload failed'}`, realUrl);
|
|
273
282
|
}
|
|
274
283
|
// const body = await response.json();
|
|
275
|
-
return {
|
|
276
|
-
hash: key || formData.key
|
|
277
|
-
};
|
|
284
|
+
return { hash: key || formData.key };
|
|
278
285
|
}
|
|
279
|
-
const getAllPackages = async (appId)=>{
|
|
286
|
+
const getAllPackages = async (appId) => {
|
|
280
287
|
// the server caps limit at 100, so page through with offset
|
|
281
288
|
const limit = 100;
|
|
282
289
|
let offset = 0;
|
|
283
290
|
let allPackages;
|
|
284
|
-
while(true){
|
|
285
|
-
const { data, count } = await get(`/app/${appId}/package/list?offset=${offset}&limit=${limit}`);
|
|
291
|
+
while (true) {
|
|
292
|
+
const { data, count } = await (0, exports.get)(`/app/${appId}/package/list?offset=${offset}&limit=${limit}`);
|
|
286
293
|
const packages = data;
|
|
287
294
|
if (allPackages === undefined || allPackages === null) {
|
|
288
295
|
allPackages = packages;
|
|
289
|
-
}
|
|
296
|
+
}
|
|
297
|
+
else if (packages) {
|
|
290
298
|
allPackages.push(...packages);
|
|
291
299
|
}
|
|
292
300
|
if (!packages || packages.length === 0) {
|
|
@@ -299,3 +307,4 @@ const getAllPackages = async (appId)=>{
|
|
|
299
307
|
}
|
|
300
308
|
return allPackages;
|
|
301
309
|
};
|
|
310
|
+
exports.getAllPackages = getAllPackages;
|
package/lib/app.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function getAppCommands(): {
|
|
|
24
24
|
options: {
|
|
25
25
|
name: string;
|
|
26
26
|
downloadUrl: string;
|
|
27
|
-
platform?: Platform |
|
|
27
|
+
platform?: Platform | '';
|
|
28
28
|
};
|
|
29
29
|
}) => Promise<void>;
|
|
30
30
|
deleteApp: ({ args, options, }: {
|
|
@@ -35,7 +35,7 @@ export declare function getAppCommands(): {
|
|
|
35
35
|
}) => Promise<void>;
|
|
36
36
|
apps: ({ options }: {
|
|
37
37
|
options: {
|
|
38
|
-
platform?: Platform |
|
|
38
|
+
platform?: Platform | '';
|
|
39
39
|
};
|
|
40
40
|
}) => Promise<AppSummary[]>;
|
|
41
41
|
selectApp: typeof selectApp;
|