react-native-update-cli 2.15.3 → 2.15.4
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.js +25 -4
- package/lib/app.js +1 -0
- package/lib/bin.js +3 -1
- package/lib/bundle-pack.d.ts +1 -1
- package/lib/bundle-pack.js +8 -7
- package/lib/bundle-runner.js +58 -39
- package/lib/bundle.d.ts +26 -0
- package/lib/bundle.js +18 -6
- package/lib/diff.js +53 -72
- package/lib/locales/en.d.ts +11 -0
- package/lib/locales/en.js +12 -1
- package/lib/locales/zh.d.ts +11 -0
- package/lib/locales/zh.js +12 -1
- package/lib/package.js +3 -1
- package/lib/provider.js +9 -3
- package/lib/types.d.ts +2 -2
- package/lib/utils/app-info-parser/xml-parser/binary.js +4 -3
- package/lib/utils/app-info-parser/zip.d.ts +6 -0
- package/lib/utils/app-info-parser/zip.js +20 -5
- package/lib/utils/check-lockfile.js +5 -1
- package/lib/utils/http-helper.js +20 -23
- package/lib/utils/index.js +48 -20
- package/lib/versions.js +7 -5
- package/package.json +1 -1
- package/src/api.ts +30 -5
- package/src/app.ts +1 -0
- package/src/bin.ts +1 -1
- package/src/bundle-pack.ts +12 -7
- package/src/bundle-runner.ts +66 -43
- package/src/bundle.ts +13 -8
- package/src/diff.ts +83 -110
- package/src/locales/en.ts +13 -0
- package/src/locales/zh.ts +12 -0
- package/src/package.ts +1 -1
- package/src/provider.ts +7 -3
- package/src/types.ts +3 -2
- package/src/utils/app-info-parser/xml-parser/binary.ts +4 -5
- package/src/utils/app-info-parser/zip.ts +22 -5
- package/src/utils/check-lockfile.ts +5 -1
- package/src/utils/http-helper.ts +16 -23
- package/src/utils/index.ts +51 -36
- package/src/versions.ts +5 -5
package/lib/provider.js
CHANGED
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "CLIProviderImpl", {
|
|
|
11
11
|
const _api = require("./api");
|
|
12
12
|
const _app = require("./app");
|
|
13
13
|
const _commandresult = require("./utils/command-result");
|
|
14
|
+
const _i18n = require("./utils/i18n");
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
16
|
if (typeof WeakMap !== "function") return null;
|
|
16
17
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -157,7 +158,9 @@ class CLIProviderImpl {
|
|
|
157
158
|
};
|
|
158
159
|
const uploadHandler = fileType && fileType in uploadHandlerMap ? uploadHandlerMap[fileType] : undefined;
|
|
159
160
|
if (!uploadHandler) {
|
|
160
|
-
throw new Error(
|
|
161
|
+
throw new Error((0, _i18n.t)('unsupportedFileType', {
|
|
162
|
+
fileType
|
|
163
|
+
}));
|
|
161
164
|
}
|
|
162
165
|
await uploadHandler(context);
|
|
163
166
|
}, 'Unknown error during upload', 'File uploaded successfully');
|
|
@@ -213,14 +216,17 @@ class CLIProviderImpl {
|
|
|
213
216
|
async loadSession() {
|
|
214
217
|
await this.ensureInitialized();
|
|
215
218
|
if (!this.session) {
|
|
216
|
-
throw new Error(
|
|
219
|
+
throw new Error((0, _i18n.t)('failedToLoadSession'));
|
|
217
220
|
}
|
|
218
221
|
return this.session;
|
|
219
222
|
}
|
|
220
223
|
async listPackages(appId) {
|
|
221
224
|
return this.runDataCommand(async ()=>{
|
|
225
|
+
if (!appId) {
|
|
226
|
+
throw new Error((0, _i18n.t)('appIdRequired'));
|
|
227
|
+
}
|
|
222
228
|
const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
|
|
223
|
-
return listPackage(appId
|
|
229
|
+
return listPackage(appId);
|
|
224
230
|
}, 'Unknown error listing packages');
|
|
225
231
|
}
|
|
226
232
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface Session {
|
|
|
7
7
|
}
|
|
8
8
|
export type Platform = 'ios' | 'android' | 'harmony';
|
|
9
9
|
export interface Package {
|
|
10
|
-
id:
|
|
10
|
+
id: number;
|
|
11
11
|
name: string;
|
|
12
12
|
version?: string;
|
|
13
13
|
status?: string;
|
|
@@ -18,7 +18,7 @@ export interface Package {
|
|
|
18
18
|
deps?: Record<string, string> | string | null;
|
|
19
19
|
}
|
|
20
20
|
export interface Version {
|
|
21
|
-
id:
|
|
21
|
+
id: number;
|
|
22
22
|
hash: string;
|
|
23
23
|
name: string;
|
|
24
24
|
packages?: Package[];
|
|
@@ -136,7 +136,6 @@ class BinaryXmlParser {
|
|
|
136
136
|
return len;
|
|
137
137
|
}
|
|
138
138
|
readDimension() {
|
|
139
|
-
var _dimension_value;
|
|
140
139
|
this.debug && console.group('readDimension');
|
|
141
140
|
const dimension = {
|
|
142
141
|
value: null,
|
|
@@ -144,7 +143,7 @@ class BinaryXmlParser {
|
|
|
144
143
|
rawUnit: null
|
|
145
144
|
};
|
|
146
145
|
const value = this.readU32();
|
|
147
|
-
const unit =
|
|
146
|
+
const unit = value & 0xff;
|
|
148
147
|
dimension.value = value >> 8;
|
|
149
148
|
dimension.rawUnit = unit;
|
|
150
149
|
switch(unit){
|
|
@@ -463,7 +462,9 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
463
462
|
attr.nodeName = attr.name = this.strings[nameRef];
|
|
464
463
|
if (valueRef > 0) {
|
|
465
464
|
if (attr.name === 'versionName') {
|
|
466
|
-
|
|
465
|
+
// strip UTF-16 null padding only; keep spaces and non-ASCII chars
|
|
466
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: removing NUL padding is the point
|
|
467
|
+
this.strings[valueRef] = this.strings[valueRef].replace(/\u0000/g, '');
|
|
467
468
|
}
|
|
468
469
|
attr.value = this.strings[valueRef];
|
|
469
470
|
}
|
|
@@ -14,5 +14,11 @@ export declare class Zip {
|
|
|
14
14
|
*/
|
|
15
15
|
getEntry(regex: RegExp | string, type?: 'buffer' | 'blob'): Promise<Blob | Buffer<ArrayBufferLike>>;
|
|
16
16
|
getEntryFromHarmonyApp(regex: RegExp): Promise<Buffer | Blob | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Read multiple entries in a single pass over the archive (including
|
|
19
|
+
* nested .hap extraction), instead of one full scan per entry.
|
|
20
|
+
* Returns buffers in the same order as the given regexps.
|
|
21
|
+
*/
|
|
22
|
+
getEntriesFromHarmonyApp(regexps: RegExp[]): Promise<(Buffer | undefined)[]>;
|
|
17
23
|
private readEntries;
|
|
18
24
|
}
|
|
@@ -36,20 +36,31 @@ class Zip {
|
|
|
36
36
|
], type).then((buffers)=>buffers[decoded]);
|
|
37
37
|
}
|
|
38
38
|
async getEntryFromHarmonyApp(regex) {
|
|
39
|
+
return (await this.getEntriesFromHarmonyApp([
|
|
40
|
+
regex
|
|
41
|
+
]))[0];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Read multiple entries in a single pass over the archive (including
|
|
45
|
+
* nested .hap extraction), instead of one full scan per entry.
|
|
46
|
+
* Returns buffers in the same order as the given regexps.
|
|
47
|
+
*/ async getEntriesFromHarmonyApp(regexps) {
|
|
48
|
+
const results = new Array(regexps.length);
|
|
39
49
|
try {
|
|
40
|
-
let originSource;
|
|
41
50
|
if (typeof this.file !== 'string') {
|
|
42
51
|
throw new Error('Param error: [file] must be file path in Node.');
|
|
43
52
|
}
|
|
44
53
|
await (0, _zipentries.enumZipEntries)(this.file, async (entry, zipFile)=>{
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
for(let i = 0; i < regexps.length; i++){
|
|
55
|
+
if (regexps[i].test(entry.fileName)) {
|
|
56
|
+
results[i] = await (0, _zipentries.readEntry)(entry, zipFile);
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
|
-
return originSource;
|
|
50
60
|
} catch (error) {
|
|
51
|
-
console.error('Error in
|
|
61
|
+
console.error('Error in getEntriesFromHarmonyApp:', error);
|
|
52
62
|
}
|
|
63
|
+
return results;
|
|
53
64
|
}
|
|
54
65
|
async readEntries(decoded, type) {
|
|
55
66
|
if (typeof this.file !== 'string') {
|
|
@@ -67,6 +78,10 @@ class Zip {
|
|
|
67
78
|
return pattern === entryName || pattern === lowerEntryName;
|
|
68
79
|
}
|
|
69
80
|
pattern.lastIndex = 0;
|
|
81
|
+
if (pattern.test(entryName)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
pattern.lastIndex = 0;
|
|
70
85
|
return pattern.test(lowerEntryName);
|
|
71
86
|
});
|
|
72
87
|
if (!matched) {
|
|
@@ -23,8 +23,12 @@ const lockFiles = [
|
|
|
23
23
|
'bun.lockb',
|
|
24
24
|
'bun.lock'
|
|
25
25
|
];
|
|
26
|
-
// Function to check if a
|
|
26
|
+
// Function to check if a directory is a monorepo root
|
|
27
|
+
// (package.json workspaces field, or pnpm-workspace.yaml)
|
|
27
28
|
function hasWorkspaces(dir) {
|
|
29
|
+
if (_fs.default.existsSync(_path.default.join(dir, 'pnpm-workspace.yaml'))) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
28
32
|
const pkgPath = _path.default.join(dir, 'package.json');
|
|
29
33
|
if (_fs.default.existsSync(pkgPath)) {
|
|
30
34
|
try {
|
package/lib/utils/http-helper.js
CHANGED
|
@@ -38,30 +38,27 @@ function promiseAny(promises) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const ping = async (url)=>{
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return url;
|
|
50
|
-
}
|
|
51
|
-
// console.log('ping failed', url, status, statusText);
|
|
52
|
-
throw new Error('ping failed');
|
|
53
|
-
}).catch((_e)=>{
|
|
54
|
-
pingFinished = true;
|
|
55
|
-
// console.log('ping error', url, e);
|
|
56
|
-
throw new Error('ping error');
|
|
57
|
-
}),
|
|
58
|
-
new Promise((_, reject)=>setTimeout(()=>{
|
|
59
|
-
reject(new Error('ping timeout'));
|
|
60
|
-
if (!pingFinished) {
|
|
61
|
-
// console.log('ping timeout', url);
|
|
41
|
+
let timer;
|
|
42
|
+
try {
|
|
43
|
+
return await Promise.race([
|
|
44
|
+
(0, _runtime.runtimeFetch)(url, {
|
|
45
|
+
method: 'HEAD'
|
|
46
|
+
}).then(({ status })=>{
|
|
47
|
+
if (status === 200) {
|
|
48
|
+
return url;
|
|
62
49
|
}
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
throw new Error('ping failed');
|
|
51
|
+
}),
|
|
52
|
+
new Promise((_, reject)=>{
|
|
53
|
+
timer = setTimeout(()=>{
|
|
54
|
+
reject(new Error('ping timeout'));
|
|
55
|
+
}, 5000);
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
} finally{
|
|
59
|
+
// clear the timer so it doesn't keep the process alive for 5s
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
65
62
|
};
|
|
66
63
|
const testUrls = async (urls)=>{
|
|
67
64
|
if (!(urls == null ? void 0 : urls.length)) {
|
package/lib/utils/index.js
CHANGED
|
@@ -101,16 +101,23 @@ function translateOptions(options, map) {
|
|
|
101
101
|
}
|
|
102
102
|
return result;
|
|
103
103
|
}
|
|
104
|
+
const ApkBundleFileName = /assets\/index.android.bundle/;
|
|
105
|
+
const ApkUpdateJsonName = /res\/raw\/update.json/;
|
|
104
106
|
async function getApkInfo(fn) {
|
|
105
107
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
106
|
-
|
|
108
|
+
// read both entries in a single scan over the archive
|
|
109
|
+
const entries = await appInfoParser.parser.getEntries([
|
|
110
|
+
ApkBundleFileName,
|
|
111
|
+
ApkUpdateJsonName
|
|
112
|
+
]);
|
|
113
|
+
const bundleFile = entries[String(ApkBundleFileName)];
|
|
107
114
|
if (!bundleFile) {
|
|
108
115
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
109
116
|
packageType: 'apk',
|
|
110
117
|
entryFile: 'index.android.bundle'
|
|
111
118
|
}));
|
|
112
119
|
}
|
|
113
|
-
const updateJsonFile =
|
|
120
|
+
const updateJsonFile = entries[String(ApkUpdateJsonName)];
|
|
114
121
|
let appCredential = {};
|
|
115
122
|
if (updateJsonFile) {
|
|
116
123
|
appCredential = JSON.parse(updateJsonFile.toString()).android;
|
|
@@ -129,7 +136,7 @@ async function getApkInfo(fn) {
|
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
|
-
if (buildTime
|
|
139
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
133
140
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
134
141
|
}
|
|
135
142
|
return {
|
|
@@ -140,19 +147,22 @@ async function getApkInfo(fn) {
|
|
|
140
147
|
}
|
|
141
148
|
async function getAppInfo(fn) {
|
|
142
149
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
143
|
-
|
|
150
|
+
// single scan (and single nested .hap extraction) for all three entries
|
|
151
|
+
const [bundleFile, updateJsonFile, metaJsonFile] = await appInfoParser.parser.getEntriesFromHarmonyApp([
|
|
152
|
+
/rawfile\/bundle.harmony.js/,
|
|
153
|
+
/rawfile\/update.json/,
|
|
154
|
+
/rawfile\/meta.json/
|
|
155
|
+
]);
|
|
144
156
|
if (!bundleFile) {
|
|
145
157
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
146
158
|
packageType: 'app',
|
|
147
159
|
entryFile: 'bundle.harmony.js'
|
|
148
160
|
}));
|
|
149
161
|
}
|
|
150
|
-
const updateJsonFile = await appInfoParser.parser.getEntryFromHarmonyApp(/rawfile\/update.json/);
|
|
151
162
|
let appCredential = {};
|
|
152
163
|
if (updateJsonFile) {
|
|
153
164
|
appCredential = JSON.parse(updateJsonFile.toString()).harmony;
|
|
154
165
|
}
|
|
155
|
-
const metaJsonFile = await appInfoParser.parser.getEntryFromHarmonyApp(/rawfile\/meta.json/);
|
|
156
166
|
let metaData = {};
|
|
157
167
|
if (metaJsonFile) {
|
|
158
168
|
metaData = JSON.parse(metaJsonFile.toString());
|
|
@@ -162,7 +172,7 @@ async function getAppInfo(fn) {
|
|
|
162
172
|
if (pushy_build_time) {
|
|
163
173
|
buildTime = Number(pushy_build_time);
|
|
164
174
|
}
|
|
165
|
-
if (buildTime
|
|
175
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
166
176
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
167
177
|
}
|
|
168
178
|
return {
|
|
@@ -171,30 +181,39 @@ async function getAppInfo(fn) {
|
|
|
171
181
|
...appCredential
|
|
172
182
|
};
|
|
173
183
|
}
|
|
184
|
+
const IpaBundleFileName = /payload\/.+?\.app\/main.jsbundle/;
|
|
185
|
+
const IpaUpdateJsonName = /payload\/.+?\.app\/assets\/update.json/;
|
|
186
|
+
const IpaBuildTimeName = /payload\/.+?\.app\/pushy_build_time.txt/;
|
|
187
|
+
// Not in root bundle when use `use_frameworks`
|
|
188
|
+
const IpaBuildTimeFrameworkName = /payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/;
|
|
174
189
|
async function getIpaInfo(fn) {
|
|
190
|
+
var _entries_String;
|
|
175
191
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
176
|
-
|
|
192
|
+
// read all four entries in a single scan over the archive
|
|
193
|
+
const entries = await appInfoParser.parser.getEntries([
|
|
194
|
+
IpaBundleFileName,
|
|
195
|
+
IpaUpdateJsonName,
|
|
196
|
+
IpaBuildTimeName,
|
|
197
|
+
IpaBuildTimeFrameworkName
|
|
198
|
+
]);
|
|
199
|
+
const bundleFile = entries[String(IpaBundleFileName)];
|
|
177
200
|
if (!bundleFile) {
|
|
178
201
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
179
202
|
packageType: 'ipa',
|
|
180
203
|
entryFile: 'main.jsbundle'
|
|
181
204
|
}));
|
|
182
205
|
}
|
|
183
|
-
const updateJsonFile =
|
|
206
|
+
const updateJsonFile = entries[String(IpaUpdateJsonName)];
|
|
184
207
|
let appCredential = {};
|
|
185
208
|
if (updateJsonFile) {
|
|
186
209
|
appCredential = JSON.parse(updateJsonFile.toString()).ios;
|
|
187
210
|
}
|
|
188
211
|
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
|
189
|
-
|
|
190
|
-
if (!buildTimeTxtBuffer) {
|
|
191
|
-
// Not in root bundle when use `use_frameworks`
|
|
192
|
-
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
|
|
193
|
-
}
|
|
212
|
+
const buildTimeTxtBuffer = (_entries_String = entries[String(IpaBuildTimeName)]) != null ? _entries_String : entries[String(IpaBuildTimeFrameworkName)];
|
|
194
213
|
if (!buildTimeTxtBuffer) {
|
|
195
214
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
196
215
|
}
|
|
197
|
-
const buildTime = buildTimeTxtBuffer.toString().
|
|
216
|
+
const buildTime = buildTimeTxtBuffer.toString().trim();
|
|
198
217
|
return {
|
|
199
218
|
versionName,
|
|
200
219
|
buildTime,
|
|
@@ -216,7 +235,7 @@ async function getAabInfo(fn) {
|
|
|
216
235
|
});
|
|
217
236
|
const manifestElement = object.element;
|
|
218
237
|
if (manifestElement.name !== 'manifest') {
|
|
219
|
-
throw new Error(
|
|
238
|
+
throw new Error((0, _i18n.t)('invalidManifest'));
|
|
220
239
|
}
|
|
221
240
|
let versionName = '';
|
|
222
241
|
for (const attr of manifestElement.attribute){
|
|
@@ -270,7 +289,7 @@ async function getAabInfo(fn) {
|
|
|
270
289
|
}
|
|
271
290
|
}
|
|
272
291
|
}
|
|
273
|
-
if (buildTime === 0) {
|
|
292
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
274
293
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
275
294
|
}
|
|
276
295
|
return {
|
|
@@ -295,13 +314,20 @@ async function readZipEntry(fn, entryName) {
|
|
|
295
314
|
found = true;
|
|
296
315
|
zipfile.openReadStream(entry, (streamError, readStream)=>{
|
|
297
316
|
if (streamError || !readStream) {
|
|
317
|
+
zipfile.close();
|
|
298
318
|
reject(streamError != null ? streamError : new Error('Failed to read zip entry'));
|
|
299
319
|
return;
|
|
300
320
|
}
|
|
301
321
|
const chunks = [];
|
|
302
322
|
readStream.on('data', (chunk)=>chunks.push(chunk));
|
|
303
|
-
readStream.on('end', ()=>
|
|
304
|
-
|
|
323
|
+
readStream.on('end', ()=>{
|
|
324
|
+
zipfile.close();
|
|
325
|
+
resolve(Buffer.concat(chunks));
|
|
326
|
+
});
|
|
327
|
+
readStream.on('error', (error)=>{
|
|
328
|
+
zipfile.close();
|
|
329
|
+
reject(error);
|
|
330
|
+
});
|
|
305
331
|
});
|
|
306
332
|
} else {
|
|
307
333
|
zipfile.readEntry();
|
|
@@ -348,7 +374,9 @@ async function resolveResource(fn, resourceId, root) {
|
|
|
348
374
|
}
|
|
349
375
|
}
|
|
350
376
|
} catch (e) {
|
|
351
|
-
console.warn(
|
|
377
|
+
console.warn((0, _i18n.t)('failedToResolveResource', {
|
|
378
|
+
error: e
|
|
379
|
+
}));
|
|
352
380
|
}
|
|
353
381
|
return null;
|
|
354
382
|
}
|
package/lib/versions.js
CHANGED
|
@@ -106,7 +106,9 @@ function toNumericIds(ids) {
|
|
|
106
106
|
return ids.map((id)=>{
|
|
107
107
|
const numericId = Number(id);
|
|
108
108
|
if (!Number.isInteger(numericId) || numericId <= 0) {
|
|
109
|
-
throw new Error(
|
|
109
|
+
throw new Error((0, _i18n.t)('invalidId', {
|
|
110
|
+
id
|
|
111
|
+
}));
|
|
110
112
|
}
|
|
111
113
|
return numericId;
|
|
112
114
|
});
|
|
@@ -422,7 +424,7 @@ const versionCommands = {
|
|
|
422
424
|
if (nonInteractive) {
|
|
423
425
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
424
426
|
}
|
|
425
|
-
versionId = (await chooseVersion(String(appId))).id;
|
|
427
|
+
versionId = String((await chooseVersion(String(appId))).id);
|
|
426
428
|
}
|
|
427
429
|
if (versionId === 'null') {
|
|
428
430
|
versionId = null;
|
|
@@ -493,7 +495,7 @@ const versionCommands = {
|
|
|
493
495
|
if (nonInteractive) {
|
|
494
496
|
throw new Error((0, _i18n.t)('packageIdRequired'));
|
|
495
497
|
}
|
|
496
|
-
pkgId = (await (0, _package.choosePackage)(String(appId))).id;
|
|
498
|
+
pkgId = String((await (0, _package.choosePackage)(String(appId))).id);
|
|
497
499
|
}
|
|
498
500
|
if (!pkgId) {
|
|
499
501
|
throw new Error((0, _i18n.t)('packageIdRequired'));
|
|
@@ -541,7 +543,7 @@ const versionCommands = {
|
|
|
541
543
|
if (nonInteractive) {
|
|
542
544
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
543
545
|
}
|
|
544
|
-
versionId = (await chooseVersion(String(appId))).id;
|
|
546
|
+
versionId = String((await chooseVersion(String(appId))).id);
|
|
545
547
|
}
|
|
546
548
|
const updateParams = {};
|
|
547
549
|
if (options.name) updateParams.name = options.name;
|
|
@@ -565,7 +567,7 @@ const versionCommands = {
|
|
|
565
567
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
566
568
|
}
|
|
567
569
|
versionIds = [
|
|
568
|
-
(await chooseVersion(String(appId))).id
|
|
570
|
+
String((await chooseVersion(String(appId))).id)
|
|
569
571
|
];
|
|
570
572
|
}
|
|
571
573
|
try {
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -140,9 +140,13 @@ async function query(url: string, options: RuntimeRequestInit) {
|
|
|
140
140
|
try {
|
|
141
141
|
json = JSON.parse(text);
|
|
142
142
|
} catch (_e) {
|
|
143
|
-
if (resp.status === 200
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
if (resp.status === 200) {
|
|
144
|
+
// a proxy/gateway likely replaced the response; surface it instead of
|
|
145
|
+
// returning undefined and crashing callers on destructuring
|
|
146
|
+
throw createRequestError(
|
|
147
|
+
`API returned 200 with non-JSON body (${text.length} bytes)`,
|
|
148
|
+
fullUrl,
|
|
149
|
+
resp.status,
|
|
146
150
|
);
|
|
147
151
|
}
|
|
148
152
|
}
|
|
@@ -282,6 +286,27 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
282
286
|
}
|
|
283
287
|
|
|
284
288
|
export const getAllPackages = async (appId: string) => {
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
// the server caps limit at 100, so page through with offset
|
|
290
|
+
const limit = 100;
|
|
291
|
+
let offset = 0;
|
|
292
|
+
let allPackages: Package[] | undefined | null;
|
|
293
|
+
while (true) {
|
|
294
|
+
const { data, count } = await get(
|
|
295
|
+
`/app/${appId}/package/list?offset=${offset}&limit=${limit}`,
|
|
296
|
+
);
|
|
297
|
+
const packages = data as Package[] | undefined | null;
|
|
298
|
+
if (allPackages === undefined || allPackages === null) {
|
|
299
|
+
allPackages = packages;
|
|
300
|
+
} else if (packages) {
|
|
301
|
+
allPackages.push(...packages);
|
|
302
|
+
}
|
|
303
|
+
if (!packages || packages.length === 0) {
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
offset += packages.length;
|
|
307
|
+
if (offset >= Number(count || 0)) {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return allPackages;
|
|
287
312
|
};
|
package/src/app.ts
CHANGED
package/src/bin.ts
CHANGED
|
@@ -78,7 +78,7 @@ async function run() {
|
|
|
78
78
|
const handler = commandHandlers[argv.command];
|
|
79
79
|
await handler(argv);
|
|
80
80
|
} else {
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error(t('unknownCommand', { command: argv.command }));
|
|
82
82
|
}
|
|
83
83
|
} catch (err: any) {
|
|
84
84
|
if (err.status === 401) {
|
package/src/bundle-pack.ts
CHANGED
|
@@ -4,15 +4,20 @@ import { ZipFile as YazlZipFile } from 'yazl';
|
|
|
4
4
|
import { t } from './utils/i18n';
|
|
5
5
|
import { zipOptionsForPayloadFile } from './utils/zip-options';
|
|
6
6
|
|
|
7
|
-
const ignorePackingFileNames = [
|
|
8
|
-
'.',
|
|
9
|
-
'..',
|
|
10
|
-
'index.bundlejs.map',
|
|
11
|
-
'bundle.harmony.js.map',
|
|
12
|
-
];
|
|
13
7
|
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
|
14
8
|
|
|
15
|
-
export async function packBundle(
|
|
9
|
+
export async function packBundle(
|
|
10
|
+
dir: string,
|
|
11
|
+
output: string,
|
|
12
|
+
bundleName?: string,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
const ignorePackingFileNames = [
|
|
15
|
+
'index.bundlejs.map',
|
|
16
|
+
'bundle.harmony.js.map',
|
|
17
|
+
];
|
|
18
|
+
if (bundleName) {
|
|
19
|
+
ignorePackingFileNames.push(`${bundleName}.map`);
|
|
20
|
+
}
|
|
16
21
|
console.log(t('packing'));
|
|
17
22
|
fs.ensureDirSync(path.dirname(output));
|
|
18
23
|
await new Promise<void>((resolve, reject) => {
|