react-native-update-cli 2.29.1 → 2.29.2
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/account.js +2 -4
- package/lib/api.d.ts +1 -1
- package/lib/api.js +26 -44
- package/lib/app.js +13 -27
- package/lib/auto-update.d.ts +1 -1
- package/lib/auto-update.js +6 -16
- package/lib/bin.js +4 -6
- package/lib/bundle-pack.js +25 -27
- package/lib/bundle-runner.js +55 -54
- package/lib/bundle.js +18 -26
- package/lib/diff.js +32 -91
- package/lib/locales/en.d.ts +0 -10
- package/lib/locales/en.js +0 -10
- package/lib/locales/zh.d.ts +0 -10
- package/lib/locales/zh.js +0 -10
- package/lib/native-package.js +20 -60
- package/lib/package.d.ts +6 -1
- package/lib/package.js +50 -70
- package/lib/provider.js +3 -5
- package/lib/symbolicate.js +1 -16
- package/lib/utils/add-gitignore.js +0 -1
- package/lib/utils/app-info-parser/aab.d.ts +5 -22
- package/lib/utils/app-info-parser/aab.js +87 -192
- package/lib/utils/app-info-parser/apk.d.ts +12 -13
- package/lib/utils/app-info-parser/apk.js +28 -78
- package/lib/utils/app-info-parser/ipa.d.ts +2 -14
- package/lib/utils/app-info-parser/ipa.js +9 -70
- package/lib/utils/app-info-parser/resource-finder.d.ts +1 -26
- package/lib/utils/app-info-parser/resource-finder.js +41 -183
- package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
- package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
- package/lib/utils/app-info-parser/zip.d.ts +6 -24
- package/lib/utils/app-info-parser/zip.js +19 -86
- package/lib/utils/check-plugin.d.ts +7 -5
- package/lib/utils/check-plugin.js +15 -25
- package/lib/utils/dep-versions.d.ts +0 -6
- package/lib/utils/dep-versions.js +2 -27
- package/lib/utils/failure-fingerprint.js +3 -4
- package/lib/utils/fs-helpers.d.ts +5 -0
- package/lib/utils/fs-helpers.js +19 -0
- package/lib/utils/git.d.ts +0 -1
- package/lib/utils/git.js +0 -8
- package/lib/utils/hash.d.ts +3 -0
- package/lib/utils/hash.js +19 -0
- package/lib/utils/hbcTransform.d.ts +9 -2
- package/lib/utils/hbcTransform.js +41 -70
- package/lib/utils/hermes-base.d.ts +1 -5
- package/lib/utils/hermes-base.js +93 -156
- package/lib/utils/hermes-literals.d.ts +5 -3
- package/lib/utils/hermes-literals.js +30 -53
- package/lib/utils/hermes-raw.d.ts +7 -0
- package/lib/utils/hermes-raw.js +26 -9
- package/lib/utils/http-helper.d.ts +0 -1
- package/lib/utils/http-helper.js +0 -20
- package/lib/utils/i18n.js +0 -2
- package/lib/utils/index.d.ts +5 -19
- package/lib/utils/index.js +95 -189
- package/lib/utils/latest-version.d.ts +19 -0
- package/lib/utils/latest-version.js +137 -0
- package/lib/utils/options.d.ts +2 -1
- package/lib/utils/options.js +5 -7
- package/lib/utils/zip-entries.d.ts +23 -0
- package/lib/utils/zip-entries.js +125 -102
- package/lib/utils/zip-options.js +29 -56
- package/lib/utils/zip-range.js +25 -65
- package/lib/versions.d.ts +5 -0
- package/lib/versions.js +86 -153
- package/package.json +1 -3
- package/lib/utils/app-info-parser/app.d.ts +0 -4
- package/lib/utils/app-info-parser/app.js +0 -10
- package/lib/utils/app-info-parser/index.d.ts +0 -16
- package/lib/utils/app-info-parser/index.js +0 -46
- package/lib/utils/app-info-parser/utils.d.ts +0 -31
- package/lib/utils/app-info-parser/utils.js +0 -135
- package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
- package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
- package/lib/utils/latest-version/index.d.ts +0 -149
- package/lib/utils/latest-version/index.js +0 -326
- package/lib/utils/plugin-config.d.ts +0 -9
- package/lib/utils/plugin-config.js +0 -31
package/lib/account.js
CHANGED
|
@@ -8,12 +8,12 @@ exports.accountCacheFile = accountCacheFile;
|
|
|
8
8
|
exports.showCurrentAccount = showCurrentAccount;
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
|
-
const crypto_1 = require("crypto");
|
|
12
11
|
const fs_1 = __importDefault(require("fs"));
|
|
13
12
|
const os_1 = __importDefault(require("os"));
|
|
14
13
|
const path_1 = __importDefault(require("path"));
|
|
15
14
|
const api_1 = require("./api");
|
|
16
15
|
const constants_1 = require("./utils/constants");
|
|
16
|
+
const hash_1 = require("./utils/hash");
|
|
17
17
|
const i18n_1 = require("./utils/i18n");
|
|
18
18
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
19
19
|
function printAccountInfo(account, isCresc = constants_1.IS_CRESC, now = Date.now()) {
|
|
@@ -41,9 +41,7 @@ function printAccountInfo(account, isCresc = constants_1.IS_CRESC, now = Date.no
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
function accountCacheFile(token, apiToken = '') {
|
|
44
|
-
const key = (0,
|
|
45
|
-
.update(JSON.stringify([constants_1.IS_CRESC, process.cwd(), token, apiToken]))
|
|
46
|
-
.digest('hex');
|
|
44
|
+
const key = (0, hash_1.sha256Hex)(JSON.stringify([constants_1.IS_CRESC, process.cwd(), token, apiToken]));
|
|
47
45
|
return path_1.default.join(os_1.default.homedir(), '.cache', 'react-native-update-cli', 'accounts', `${key}.json`);
|
|
48
46
|
}
|
|
49
47
|
function printCachedAccount(entry) {
|
package/lib/api.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function uploadTimeoutMs(fileSize: number): number;
|
|
|
22
22
|
* get here — they are surfaced as-is.
|
|
23
23
|
*/
|
|
24
24
|
export declare function isTransientUploadError(error: unknown): boolean;
|
|
25
|
-
export declare function uploadFile(fn: string,
|
|
25
|
+
export declare function uploadFile(fn: string, appId?: string | number): Promise<{
|
|
26
26
|
hash: any;
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
package/lib/api.js
CHANGED
|
@@ -142,6 +142,14 @@ function isProxyRelatedError(error) {
|
|
|
142
142
|
const lower = parts.join('\n').toLowerCase();
|
|
143
143
|
return PROXY_ERROR_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
|
|
144
144
|
}
|
|
145
|
+
/** A request error for `url`, with the proxy hints when a proxy is the likely cause. */
|
|
146
|
+
function networkError(error, url) {
|
|
147
|
+
const baseError = createRequestError(error, url);
|
|
148
|
+
if (isProxyRelatedError(error)) {
|
|
149
|
+
return new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`, { cause: baseError });
|
|
150
|
+
}
|
|
151
|
+
return baseError;
|
|
152
|
+
}
|
|
145
153
|
async function query(url, options) {
|
|
146
154
|
const baseUrl = await (0, http_helper_1.getBaseUrl)();
|
|
147
155
|
const fullUrl = `${baseUrl}${url}`;
|
|
@@ -150,11 +158,7 @@ async function query(url, options) {
|
|
|
150
158
|
resp = await (0, runtime_1.runtimeFetch)(fullUrl, options);
|
|
151
159
|
}
|
|
152
160
|
catch (error) {
|
|
153
|
-
|
|
154
|
-
if (isProxyRelatedError(error)) {
|
|
155
|
-
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`, { cause: baseError });
|
|
156
|
-
}
|
|
157
|
-
throw baseError;
|
|
161
|
+
throw networkError(error, fullUrl);
|
|
158
162
|
}
|
|
159
163
|
const text = await resp.text();
|
|
160
164
|
let json;
|
|
@@ -177,29 +181,12 @@ async function query(url, options) {
|
|
|
177
181
|
}
|
|
178
182
|
return json;
|
|
179
183
|
}
|
|
180
|
-
function
|
|
181
|
-
return (api) => {
|
|
182
|
-
const headers = {
|
|
183
|
-
'User-Agent': userAgent,
|
|
184
|
-
};
|
|
185
|
-
if (apiToken) {
|
|
186
|
-
headers['x-api-token'] = apiToken;
|
|
187
|
-
}
|
|
188
|
-
else if (session?.token) {
|
|
189
|
-
headers['X-AccessToken'] = session.token;
|
|
190
|
-
}
|
|
191
|
-
return query(api, {
|
|
192
|
-
method,
|
|
193
|
-
headers,
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
function queryWithBody(method) {
|
|
184
|
+
function queryWith(method, withBody) {
|
|
198
185
|
return (api, body) => {
|
|
199
|
-
const headers = {
|
|
200
|
-
|
|
201
|
-
'Content-Type'
|
|
202
|
-
}
|
|
186
|
+
const headers = { 'User-Agent': userAgent };
|
|
187
|
+
if (withBody) {
|
|
188
|
+
headers['Content-Type'] = 'application/json';
|
|
189
|
+
}
|
|
203
190
|
if (apiToken) {
|
|
204
191
|
headers['x-api-token'] = apiToken;
|
|
205
192
|
}
|
|
@@ -209,14 +196,14 @@ function queryWithBody(method) {
|
|
|
209
196
|
return query(api, {
|
|
210
197
|
method,
|
|
211
198
|
headers,
|
|
212
|
-
body: JSON.stringify(body),
|
|
199
|
+
...(withBody ? { body: JSON.stringify(body) } : {}),
|
|
213
200
|
});
|
|
214
201
|
};
|
|
215
202
|
}
|
|
216
|
-
exports.get =
|
|
217
|
-
exports.post =
|
|
218
|
-
exports.put =
|
|
219
|
-
exports.doDelete =
|
|
203
|
+
exports.get = queryWith('GET', false);
|
|
204
|
+
exports.post = queryWith('POST', true);
|
|
205
|
+
exports.put = queryWith('PUT', true);
|
|
206
|
+
exports.doDelete = queryWith('DELETE', true);
|
|
220
207
|
// Upload deadline: generous for a slow link (5 s/MB, i.e. ~200 KB/s, on top
|
|
221
208
|
// of a 30 s base, never below 60 s) but bounded, so a stalled connection cannot
|
|
222
209
|
// hang a CI job forever. The bar keeps ticking while bytes flow; the deadline
|
|
@@ -339,7 +326,7 @@ async function sendChunks(fn, realUrl, fileSize, bar, chunked, postForm) {
|
|
|
339
326
|
throw failure;
|
|
340
327
|
}
|
|
341
328
|
}
|
|
342
|
-
async function uploadFile(fn,
|
|
329
|
+
async function uploadFile(fn, appId) {
|
|
343
330
|
const fileSize = fs_1.default.statSync(fn).size;
|
|
344
331
|
// appId 用于服务端路由:绑定了自托管节点(rnu-node)的应用,
|
|
345
332
|
// 上传指令会指向节点或其对象存储。chunked + size 让支持的服务端(GCS)
|
|
@@ -347,7 +334,8 @@ async function uploadFile(fn, key, appId) {
|
|
|
347
334
|
const resp = await (0, exports.post)('/upload', {
|
|
348
335
|
ext: path_1.default.extname(fn),
|
|
349
336
|
...(appId ? { appId: Number(appId) } : {}),
|
|
350
|
-
|
|
337
|
+
chunked: true,
|
|
338
|
+
size: fileSize,
|
|
351
339
|
});
|
|
352
340
|
const { url, backupUrl, formData, maxSize } = resp;
|
|
353
341
|
let realUrl = url;
|
|
@@ -367,7 +355,6 @@ async function uploadFile(fn, key, appId) {
|
|
|
367
355
|
realUrl = backupUrl;
|
|
368
356
|
}
|
|
369
357
|
}
|
|
370
|
-
// console.log({realUrl});
|
|
371
358
|
}
|
|
372
359
|
if (maxSize && fileSize > (0, filesize_parser_1.default)(maxSize)) {
|
|
373
360
|
const readableFileSize = `${(fileSize / 1048576).toFixed(1)}m`;
|
|
@@ -387,11 +374,7 @@ async function uploadFile(fn, key, appId) {
|
|
|
387
374
|
total: fileSize,
|
|
388
375
|
});
|
|
389
376
|
const rethrowUploadError = (error) => {
|
|
390
|
-
|
|
391
|
-
if (isProxyRelatedError(error)) {
|
|
392
|
-
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`, { cause: baseError });
|
|
393
|
-
}
|
|
394
|
-
throw baseError;
|
|
377
|
+
throw networkError(error, realUrl);
|
|
395
378
|
};
|
|
396
379
|
// 自托管节点的 s3 直传:服务端下发预签名 PUT,字节直达用户的对象存储
|
|
397
380
|
if (resp.method === 'PUT') {
|
|
@@ -420,7 +403,7 @@ async function uploadFile(fn, key, appId) {
|
|
|
420
403
|
size: byteCount,
|
|
421
404
|
stream: fileStream,
|
|
422
405
|
});
|
|
423
|
-
if (resp.chunked
|
|
406
|
+
if (resp.chunked) {
|
|
424
407
|
try {
|
|
425
408
|
await sendChunks(fn, realUrl, fileSize, bar, resp.chunked, postForm);
|
|
426
409
|
}
|
|
@@ -438,7 +421,7 @@ async function uploadFile(fn, key, appId) {
|
|
|
438
421
|
}
|
|
439
422
|
let res;
|
|
440
423
|
try {
|
|
441
|
-
res = await sendUpload(fn, realUrl, fileSize, bar, postForm(
|
|
424
|
+
res = await sendUpload(fn, realUrl, fileSize, bar, postForm(formData, fileSize));
|
|
442
425
|
}
|
|
443
426
|
catch (error) {
|
|
444
427
|
return rethrowUploadError(error);
|
|
@@ -446,8 +429,7 @@ async function uploadFile(fn, key, appId) {
|
|
|
446
429
|
if (res.status > 299) {
|
|
447
430
|
throw createRequestError(`${res.status}: ${res.statusText || 'Upload failed'}`, realUrl);
|
|
448
431
|
}
|
|
449
|
-
|
|
450
|
-
return { hash: key || formData.key };
|
|
432
|
+
return { hash: formData.key };
|
|
451
433
|
}
|
|
452
434
|
/**
|
|
453
435
|
* Ask the server for the Hermes base of (app, HBC version): the earliest
|
package/lib/app.js
CHANGED
|
@@ -44,28 +44,30 @@ function parsePositiveIntegerId(value) {
|
|
|
44
44
|
}
|
|
45
45
|
return id;
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
48
|
-
async function
|
|
49
|
-
assertPlatform(platform);
|
|
50
|
-
const resolvedConfigPath = configPath || constants_1.updateJson;
|
|
47
|
+
/** The parsed config file, or undefined when it does not exist. */
|
|
48
|
+
async function readUpdateInfo(configPath) {
|
|
51
49
|
let raw;
|
|
52
50
|
try {
|
|
53
|
-
raw = await fs_1.default.promises.readFile(
|
|
51
|
+
raw = await fs_1.default.promises.readFile(configPath, 'utf8');
|
|
54
52
|
}
|
|
55
53
|
catch (e) {
|
|
56
54
|
if (e.code === 'ENOENT') {
|
|
57
|
-
|
|
55
|
+
return undefined;
|
|
58
56
|
}
|
|
59
57
|
throw e;
|
|
60
58
|
}
|
|
61
|
-
let updateInfo;
|
|
62
59
|
try {
|
|
63
|
-
|
|
60
|
+
return JSON.parse(raw);
|
|
64
61
|
}
|
|
65
62
|
catch {
|
|
66
|
-
throw new Error((0, i18n_1.t)('failedToParseUpdateJson', { configPath
|
|
63
|
+
throw new Error((0, i18n_1.t)('failedToParseUpdateJson', { configPath }));
|
|
67
64
|
}
|
|
68
|
-
|
|
65
|
+
}
|
|
66
|
+
/** Read the selected app for a platform from the requested config file. */
|
|
67
|
+
async function getSelectedApp(platform, configPath) {
|
|
68
|
+
assertPlatform(platform);
|
|
69
|
+
const updateInfo = await readUpdateInfo(configPath || constants_1.updateJson);
|
|
70
|
+
const info = updateInfo?.[platform];
|
|
69
71
|
if (!info) {
|
|
70
72
|
throw new AppNotSelectedError(platform);
|
|
71
73
|
}
|
|
@@ -151,25 +153,13 @@ async function selectApp({ args, options, }) {
|
|
|
151
153
|
const id = args[0]
|
|
152
154
|
? parsePositiveIntegerId(args[0])
|
|
153
155
|
: (await chooseApp(platform)).id;
|
|
154
|
-
if (!Number.isSafeInteger(id) || id <= 0) {
|
|
155
|
-
throw new Error((0, i18n_1.t)('invalidId', { id: args[0] }));
|
|
156
|
-
}
|
|
157
156
|
const app = await assertAppPlatform(String(id), platform);
|
|
158
157
|
if (typeof app.appKey !== 'string' || !app.appKey) {
|
|
159
158
|
throw new Error((0, i18n_1.t)('appKeyMissing', { appId: id }));
|
|
160
159
|
}
|
|
161
160
|
const appKey = app.appKey;
|
|
162
161
|
const configPath = options.config || constants_1.updateJson;
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
updateInfo = JSON.parse(await fs_1.default.promises.readFile(configPath, 'utf8'));
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
if (e.code !== 'ENOENT') {
|
|
169
|
-
console.error((0, i18n_1.t)('failedToParseUpdateJson', { configPath }));
|
|
170
|
-
throw e;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
162
|
+
const updateInfo = (await readUpdateInfo(configPath)) ?? {};
|
|
173
163
|
updateInfo[platform] = {
|
|
174
164
|
appId: id,
|
|
175
165
|
appKey,
|
|
@@ -197,10 +187,6 @@ function getAppCommands() {
|
|
|
197
187
|
const id = args[0]
|
|
198
188
|
? parsePositiveIntegerId(args[0])
|
|
199
189
|
: (await chooseApp(platform)).id;
|
|
200
|
-
if (!id) {
|
|
201
|
-
console.log((0, i18n_1.t)('cancelled'));
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
190
|
await (0, api_1.doDelete)(`/app/${id}`);
|
|
205
191
|
console.log((0, i18n_1.t)('operationSuccess'));
|
|
206
192
|
},
|
package/lib/auto-update.d.ts
CHANGED
package/lib/auto-update.js
CHANGED
|
@@ -9,8 +9,9 @@ exports.launchAutoUpdate = launchAutoUpdate;
|
|
|
9
9
|
exports.consumeAutoUpdateNotice = consumeAutoUpdateNotice;
|
|
10
10
|
const child_process_1 = require("child_process");
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
|
-
const os_1 = require("os");
|
|
13
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
14
|
+
const options_1 = require("./utils/options");
|
|
14
15
|
const PACKAGE_NAME = 'react-native-update-cli';
|
|
15
16
|
const WORKER_ENV = 'RNU_AUTO_UPDATE_WORKER';
|
|
16
17
|
const CANDIDATE_ENV = 'RNU_AUTO_UPDATE_CANDIDATE';
|
|
@@ -21,17 +22,7 @@ const FAILURE_RETRY_MS = 24 * 60 * 60 * 1000;
|
|
|
21
22
|
const PERMISSION_RETRY_MS = 7 * 24 * 60 * 60 * 1000;
|
|
22
23
|
const OUTPUT_LIMIT = 32 * 1024;
|
|
23
24
|
function cacheDir() {
|
|
24
|
-
|
|
25
|
-
return path_1.default.join(process.env.XDG_CACHE_HOME, PACKAGE_NAME);
|
|
26
|
-
}
|
|
27
|
-
switch (process.platform) {
|
|
28
|
-
case 'darwin':
|
|
29
|
-
return path_1.default.join((0, os_1.homedir)(), 'Library', 'Caches', PACKAGE_NAME);
|
|
30
|
-
case 'win32':
|
|
31
|
-
return path_1.default.join(process.env.LOCALAPPDATA ?? path_1.default.join((0, os_1.homedir)(), 'AppData', 'Local'), PACKAGE_NAME, 'Cache');
|
|
32
|
-
default:
|
|
33
|
-
return path_1.default.join((0, os_1.homedir)(), '.cache', PACKAGE_NAME);
|
|
34
|
-
}
|
|
25
|
+
return (0, fs_helpers_1.userCacheDir)(PACKAGE_NAME);
|
|
35
26
|
}
|
|
36
27
|
function stateFile() {
|
|
37
28
|
return path_1.default.join(cacheDir(), 'auto-update.json');
|
|
@@ -233,11 +224,10 @@ function inferNpmPrefix(packageRoot, npmGlobalDir, npmPrefix) {
|
|
|
233
224
|
}
|
|
234
225
|
function isDisabled(env) {
|
|
235
226
|
const disabled = (value) => value === '0' || value?.toLowerCase() === 'false';
|
|
236
|
-
const enabled = (value) => value === '1' || value?.toLowerCase() === 'true';
|
|
237
227
|
return (disabled(env.RNU_AUTO_UPDATE) ||
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
228
|
+
(0, options_1.isTruthyEnv)(env.RNU_DISABLE_AUTO_UPDATE) ||
|
|
229
|
+
(0, options_1.isTruthyEnv)(env.NO_UPDATE_NOTIFIER) ||
|
|
230
|
+
(0, options_1.isTruthyEnv)(env.CI));
|
|
241
231
|
}
|
|
242
232
|
function shouldRetry(state, target) {
|
|
243
233
|
if (!state || state.targetVersion !== target)
|
package/lib/bin.js
CHANGED
|
@@ -6,9 +6,7 @@ const api_1 = require("./api");
|
|
|
6
6
|
const commands_1 = require("./commands");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const i18n_1 = require("./utils/i18n");
|
|
9
|
-
|
|
10
|
-
return value === '1' || value?.toLowerCase() === 'true';
|
|
11
|
-
}
|
|
9
|
+
const options_1 = require("./utils/options");
|
|
12
10
|
function printUsage(exitCode = 1) {
|
|
13
11
|
console.log('React Native Update CLI');
|
|
14
12
|
console.log('');
|
|
@@ -30,7 +28,7 @@ function printUsage(exitCode = 1) {
|
|
|
30
28
|
* when the CLI itself is at fault, is printed on request (RNU_DEBUG=1).
|
|
31
29
|
*/
|
|
32
30
|
function reportError(err) {
|
|
33
|
-
if (isTruthyEnv(process.env.RNU_DEBUG)) {
|
|
31
|
+
if ((0, options_1.isTruthyEnv)(process.env.RNU_DEBUG)) {
|
|
34
32
|
console.error(err instanceof Error ? err.stack : err);
|
|
35
33
|
// fetch failures wrap the real reason (ECONNREFUSED, TLS, ...) as `cause`
|
|
36
34
|
for (let cause = err?.cause; cause; cause = cause?.cause) {
|
|
@@ -64,9 +62,9 @@ async function run() {
|
|
|
64
62
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
65
63
|
global.NO_INTERACTIVE =
|
|
66
64
|
Boolean(argv.options['no-interactive']) ||
|
|
67
|
-
isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
65
|
+
(0, options_1.isTruthyEnv)(process.env.NO_INTERACTIVE);
|
|
68
66
|
global.USE_ACC_OSS =
|
|
69
|
-
Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
67
|
+
Boolean(argv.options.acc) || (0, options_1.isTruthyEnv)(process.env.USE_ACC_OSS);
|
|
70
68
|
await (0, api_1.loadSession)();
|
|
71
69
|
if (argv.command === 'help' || argv.command === 'list') {
|
|
72
70
|
printUsage(0);
|
package/lib/bundle-pack.js
CHANGED
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.packBundle = packBundle;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const yazl_1 = require("yazl");
|
|
10
|
-
const fs_helpers_1 = require("./utils/fs-helpers");
|
|
11
9
|
const i18n_1 = require("./utils/i18n");
|
|
10
|
+
const zip_entries_1 = require("./utils/zip-entries");
|
|
12
11
|
const zip_options_1 = require("./utils/zip-options");
|
|
13
12
|
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
|
14
13
|
async function packBundle(dir, output, bundleName) {
|
|
@@ -20,35 +19,34 @@ async function packBundle(dir, output, bundleName) {
|
|
|
20
19
|
ignorePackingFileNames.push(`${bundleName}.map`);
|
|
21
20
|
}
|
|
22
21
|
console.log((0, i18n_1.t)('packing'));
|
|
23
|
-
(0,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const { zipfile, writePromise, abort } = (0, zip_entries_1.createOutputZip)(output);
|
|
23
|
+
function addDirectory(root, rel) {
|
|
24
|
+
if (rel) {
|
|
25
|
+
zipfile.addEmptyDirectory(rel);
|
|
26
|
+
}
|
|
27
|
+
for (const name of fs_1.default.readdirSync(root)) {
|
|
28
|
+
if (ignorePackingFileNames.includes(name) ||
|
|
29
|
+
ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const fullPath = path_1.default.join(root, name);
|
|
33
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
34
|
+
if (stat.isFile()) {
|
|
35
|
+
zipfile.addFile(fullPath, rel + name, (0, zip_options_1.zipOptionsForPayloadFile)(fullPath, rel + name));
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (ignorePackingFileNames.includes(name) ||
|
|
33
|
-
ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const fullPath = path_1.default.join(root, name);
|
|
37
|
-
const stat = fs_1.default.statSync(fullPath);
|
|
38
|
-
if (stat.isFile()) {
|
|
39
|
-
zipfile.addFile(fullPath, rel + name, (0, zip_options_1.zipOptionsForPayloadFile)(fullPath, rel + name));
|
|
40
|
-
}
|
|
41
|
-
else if (stat.isDirectory()) {
|
|
42
|
-
addDirectory(fullPath, `${rel}${name}/`);
|
|
43
|
-
}
|
|
37
|
+
else if (stat.isDirectory()) {
|
|
38
|
+
addDirectory(fullPath, `${rel}${name}/`);
|
|
44
39
|
}
|
|
45
40
|
}
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
46
43
|
addDirectory(dir, '');
|
|
47
|
-
zipfile.outputStream.on('error', (err) => reject(err));
|
|
48
|
-
zipfile.outputStream.pipe(fs_1.default.createWriteStream(output)).on('close', () => {
|
|
49
|
-
resolve();
|
|
50
|
-
});
|
|
51
44
|
zipfile.end();
|
|
52
|
-
|
|
45
|
+
await writePromise;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
await abort();
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
53
51
|
console.log((0, i18n_1.t)('fileGenerated', { file: output }));
|
|
54
52
|
}
|
package/lib/bundle-runner.js
CHANGED
|
@@ -35,7 +35,6 @@ const hermes_timeout_1 = require("./utils/hermes-timeout");
|
|
|
35
35
|
const i18n_1 = require("./utils/i18n");
|
|
36
36
|
const runtime_1 = require("./utils/runtime");
|
|
37
37
|
const g2js = require('gradle-to-js/lib/parser');
|
|
38
|
-
const properties = require('properties');
|
|
39
38
|
const dependencyFields = [
|
|
40
39
|
'dependencies',
|
|
41
40
|
'devDependencies',
|
|
@@ -160,15 +159,12 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
if (isSentry) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
else if (platform === 'harmony' &&
|
|
170
|
-
fs_1.default.existsSync('harmony/sentry.properties')) {
|
|
171
|
-
process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
|
|
162
|
+
// optional only on harmony
|
|
163
|
+
const sentryProperties = `${platform}/sentry.properties`;
|
|
164
|
+
if (platform === 'ios' ||
|
|
165
|
+
platform === 'android' ||
|
|
166
|
+
(platform === 'harmony' && fs_1.default.existsSync(sentryProperties))) {
|
|
167
|
+
process.env.SENTRY_PROPERTIES = sentryProperties;
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
let bundleCommand = 'bundle';
|
|
@@ -327,9 +323,8 @@ function assertSafeToEmpty(dir, cwd = process.cwd()) {
|
|
|
327
323
|
[lexicalHome, canonicalHome],
|
|
328
324
|
[lexicalTmp, canonicalTmp],
|
|
329
325
|
]) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
(!relative.startsWith('..') && !path_1.default.isAbsolute(relative))) {
|
|
326
|
+
if (contains(lexicalBase, requested)) {
|
|
327
|
+
const relative = path_1.default.relative(lexicalBase, requested);
|
|
333
328
|
if (!samePath(path_1.default.resolve(canonicalBase, relative), target)) {
|
|
334
329
|
reject(target);
|
|
335
330
|
}
|
|
@@ -357,9 +352,9 @@ async function detectHermesEnabled(platform, forceHermes, gradleConfig, projectR
|
|
|
357
352
|
return true;
|
|
358
353
|
}
|
|
359
354
|
if (platform === 'android') {
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
return
|
|
355
|
+
const hermesEnabled = await readGradleHermesEnabled(path_1.default.join(projectRoot, 'android', 'gradle.properties'));
|
|
356
|
+
if (hermesEnabled !== undefined) {
|
|
357
|
+
return hermesEnabled;
|
|
363
358
|
}
|
|
364
359
|
if (typeof gradleConfig.enableHermes === 'boolean') {
|
|
365
360
|
return gradleConfig.enableHermes;
|
|
@@ -371,20 +366,27 @@ async function detectHermesEnabled(platform, forceHermes, gradleConfig, projectR
|
|
|
371
366
|
}
|
|
372
367
|
return false;
|
|
373
368
|
}
|
|
374
|
-
/**
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
369
|
+
/**
|
|
370
|
+
* `hermesEnabled` from gradle.properties (the last assignment wins, as in
|
|
371
|
+
* Gradle); undefined when the file, the key or a boolean value is missing.
|
|
372
|
+
*/
|
|
373
|
+
async function readGradleHermesEnabled(file) {
|
|
374
|
+
let content;
|
|
375
|
+
try {
|
|
376
|
+
content = await fs_1.default.promises.readFile(file, 'utf8');
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
if (error.code !== 'ENOENT') {
|
|
380
|
+
console.warn(`${file}: ${error.message ?? error}`);
|
|
381
|
+
}
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
let value;
|
|
385
|
+
for (const match of content.matchAll(/^[ \t\f]*hermesEnabled[ \t\f]*[=: \t\f][ \t\f]*(.*?)[ \t\f]*\r?$/gm)) {
|
|
386
|
+
value =
|
|
387
|
+
match[1] === 'true' ? true : match[1] === 'false' ? false : undefined;
|
|
388
|
+
}
|
|
389
|
+
return value;
|
|
388
390
|
}
|
|
389
391
|
/** React Native's gradle plugin (0.71+) enables Hermes unless a property says otherwise */
|
|
390
392
|
function reactNativeDefaultsToHermes(projectRoot) {
|
|
@@ -1004,7 +1006,6 @@ async function selectHermesBase(hermesCommand, request) {
|
|
|
1004
1006
|
try {
|
|
1005
1007
|
const base = await (0, hermes_base_1.resolveHermesBase)({
|
|
1006
1008
|
option: request.option,
|
|
1007
|
-
hermesCommand,
|
|
1008
1009
|
bytecodeVersion,
|
|
1009
1010
|
appId: request.appId,
|
|
1010
1011
|
cacheMaxMb: request.cacheMaxMb,
|
|
@@ -1148,20 +1149,25 @@ function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapP
|
|
|
1148
1149
|
...uploadArgs,
|
|
1149
1150
|
];
|
|
1150
1151
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* What the installed sentry-cli supports, from one `sourcemaps upload --help`
|
|
1154
|
+
* run: the standalone `sourcemaps upload` command (else the legacy
|
|
1155
|
+
* `releases files upload-sourcemaps`), and its `--debug-id-reference` flag.
|
|
1156
|
+
*/
|
|
1157
|
+
function probeSentryCli(sentryCliPath) {
|
|
1158
|
+
const result = (0, runtime_1.spawnJavaScriptSync)([sentryCliPath, 'sourcemaps', 'upload', '--help'], { encoding: 'utf8' });
|
|
1159
|
+
const standalone = !result.error && result.status === 0;
|
|
1160
|
+
return {
|
|
1161
|
+
standalone,
|
|
1162
|
+
debugIdReference: standalone &&
|
|
1163
|
+
typeof result.stdout === 'string' &&
|
|
1164
|
+
result.stdout.includes('--debug-id-reference'),
|
|
1165
|
+
};
|
|
1156
1166
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
return (!result.error &&
|
|
1162
|
-
result.status === 0 &&
|
|
1163
|
-
typeof result.stdout === 'string' &&
|
|
1164
|
-
result.stdout.includes('--debug-id-reference'));
|
|
1167
|
+
/** --sentry-release/--sentry-dist, else SENTRY_RELEASE/SENTRY_DIST */
|
|
1168
|
+
function explicitSentryRelease(options) {
|
|
1169
|
+
return (resolveSentryReleaseFromValues(options.sentryRelease, options.sentryDist) ??
|
|
1170
|
+
resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST));
|
|
1165
1171
|
}
|
|
1166
1172
|
function runSentryCli(args) {
|
|
1167
1173
|
return (0, runtime_1.spawnJavaScriptSync)(args, {
|
|
@@ -1195,12 +1201,10 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
1195
1201
|
console.error((0, i18n_1.t)('sentryCliNotFound'));
|
|
1196
1202
|
return;
|
|
1197
1203
|
}
|
|
1198
|
-
if (!fs_1.default.existsSync(sentryCliPath)) {
|
|
1199
|
-
return;
|
|
1200
|
-
}
|
|
1201
1204
|
const { bundlePath, sourcemapPath } = await prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
|
|
1202
1205
|
const uploadMode = await resolveSentryUploadMode(sourcemapPath, sentryOptions);
|
|
1203
|
-
const
|
|
1206
|
+
const sentryCli = probeSentryCli(sentryCliPath);
|
|
1207
|
+
const useStandaloneSourcemapsCommand = sentryCli.standalone;
|
|
1204
1208
|
if (uploadMode.type === 'release') {
|
|
1205
1209
|
uploadSourcemapsWithRelease({
|
|
1206
1210
|
sentryCliPath,
|
|
@@ -1213,10 +1217,8 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
1213
1217
|
return;
|
|
1214
1218
|
}
|
|
1215
1219
|
console.log((0, i18n_1.t)('uploadingSourcemap'));
|
|
1216
|
-
if (!
|
|
1217
|
-
|
|
1218
|
-
const explicitRelease = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist) ??
|
|
1219
|
-
resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
|
|
1220
|
+
if (!sentryCli.debugIdReference) {
|
|
1221
|
+
const explicitRelease = explicitSentryRelease(sentryOptions);
|
|
1220
1222
|
if (!explicitRelease) {
|
|
1221
1223
|
throw new Error('[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' +
|
|
1222
1224
|
'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.');
|
|
@@ -1242,8 +1244,7 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
1242
1244
|
if (debugIdResult.status === 0 && !debugIdResult.error) {
|
|
1243
1245
|
return;
|
|
1244
1246
|
}
|
|
1245
|
-
const explicitRelease =
|
|
1246
|
-
resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
|
|
1247
|
+
const explicitRelease = explicitSentryRelease(sentryOptions);
|
|
1247
1248
|
if (!explicitRelease) {
|
|
1248
1249
|
assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
|
|
1249
1250
|
return;
|