react-native-update-cli 2.24.1 → 2.25.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/README.md +11 -4
- package/README.zh-CN.md +11 -4
- package/cli.json +7 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +63 -18
- package/lib/app.js +25 -3
- package/lib/bin.js +39 -45
- package/lib/bundle-runner.d.ts +27 -0
- package/lib/bundle-runner.js +240 -21
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +19 -6
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +5 -14
- package/lib/locales/en.js +5 -14
- package/lib/locales/zh.d.ts +5 -13
- package/lib/locales/zh.js +5 -13
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +11 -3
- package/lib/types.d.ts +1 -0
- package/lib/user.js +6 -0
- package/lib/utils/add-gitignore.js +7 -1
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +78 -26
- package/lib/utils/git.js +9 -6
- package/lib/utils/hermes-base.js +2 -1
- package/lib/utils/i18n.d.ts +5 -0
- package/lib/utils/i18n.js +14 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +9 -4
- package/lib/utils/latest-version/index.js +8 -0
- package/lib/utils/runtime.d.ts +21 -0
- package/lib/utils/runtime.js +138 -5
- package/lib/utils/slim-sourcemap.d.ts +11 -0
- package/lib/utils/slim-sourcemap.js +22 -0
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +16 -15
- package/package.json +4 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -17
- package/src/api.ts +0 -470
- package/src/app.ts +0 -241
- package/src/auto-update.ts +0 -647
- package/src/bin-cresc.ts +0 -8
- package/src/bin.ts +0 -115
- package/src/bundle-pack.ts +0 -61
- package/src/bundle-runner.ts +0 -1430
- package/src/bundle.ts +0 -371
- package/src/cache.ts +0 -20
- package/src/diff.ts +0 -1010
- package/src/exports.ts +0 -17
- package/src/index.ts +0 -1
- package/src/install.ts +0 -50
- package/src/locales/en.ts +0 -257
- package/src/locales/zh.ts +0 -234
- package/src/native-package.ts +0 -338
- package/src/package.ts +0 -482
- package/src/provider.ts +0 -294
- package/src/symbolicate.ts +0 -159
- package/src/types.ts +0 -150
- package/src/user.ts +0 -39
- package/src/utils/add-gitignore.ts +0 -35
- package/src/utils/app-info-parser/aab.ts +0 -241
- package/src/utils/app-info-parser/apk.ts +0 -92
- package/src/utils/app-info-parser/app.ts +0 -7
- package/src/utils/app-info-parser/index.ts +0 -54
- package/src/utils/app-info-parser/ipa.ts +0 -109
- package/src/utils/app-info-parser/resource-finder.ts +0 -508
- package/src/utils/app-info-parser/utils.ts +0 -161
- package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
- package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
- package/src/utils/app-info-parser/zip.ts +0 -108
- package/src/utils/check-lockfile.ts +0 -93
- package/src/utils/check-plugin.ts +0 -38
- package/src/utils/command-result.ts +0 -24
- package/src/utils/constants.ts +0 -25
- package/src/utils/dep-versions.ts +0 -83
- package/src/utils/git.ts +0 -71
- package/src/utils/hbcTransform.ts +0 -649
- package/src/utils/hermes-base.ts +0 -1137
- package/src/utils/http-helper.ts +0 -152
- package/src/utils/i18n.ts +0 -39
- package/src/utils/index.ts +0 -698
- package/src/utils/latest-version/index.ts +0 -573
- package/src/utils/options.ts +0 -78
- package/src/utils/plugin-config.ts +0 -32
- package/src/utils/runtime.ts +0 -187
- package/src/utils/slim-sourcemap.ts +0 -83
- package/src/utils/zip-entries.ts +0 -209
- package/src/utils/zip-options.ts +0 -178
- package/src/utils/zip-range.ts +0 -727
- package/src/utils/zip-raw-writer.ts +0 -247
- package/src/versions.ts +0 -894
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ const publishResult = await provider.publish({
|
|
|
85
85
|
- `hdiffFromApp`: Generate hdiff from APP files
|
|
86
86
|
- `hdiffFromIpa`: Generate hdiff from IPA files
|
|
87
87
|
|
|
88
|
-
Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk) and is composed with the packager map — `--sourcemap` is on by default since 2.23 (`--sourcemap
|
|
88
|
+
Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk) and is composed with the packager map — `--sourcemap` is on by default since 2.23 (`--no-sourcemap` opts out). When `bundle` publishes, that final map is uploaded and archived with the version (`sourceMapKey`), so `pushy symbolicate` can map crash stacks — including Hermes `address at` frames — back to source later. `pushy publish <ppk> --sourcemap <file.map>` archives a map for a ppk built elsewhere; publishing without a map prints a warning.
|
|
89
89
|
|
|
90
90
|
Hermes delta mode (`-base-bytecode`): by default (`--hermesBase auto`) `bundle` compiles against the previous HBC of the same app, which keeps Hermes string IDs stable and makes hot-update patches 5–30× smaller. The base comes from the server (`GET /app/:id/hermesBase`), verified by sha256 and kept in a local cache (`.pushy/cache/<sha256>`, 500 MB / 20 files, `PUSHY_CACHE_DIR` / `--cacheMaxMb` to tune, `pushy cache [clean]` to inspect or clear). `--hermesBase none` disables it; `--hermesBase <file.hbc|.ppk|.apk|.ipa>` uses a local artifact (for example the store build). `--verifyHermesBase` (default on) additionally compiles without the base (concurrently with the base compile) and compares both disassemblies; on any mismatch or failure the CLI silently falls back to the plain compile, so the feature can never block a release. Only hermesc builds that include the upstream delta-mode fix are used (classic `react-native/sdks/hermesc`, or `hermes-compiler` ≥ 250829098). If a base compile fails, the full hermesc output is written to `hermes-base-error.log` next to the intermediate directory. `--resetCache false` skips Metro's `--reset-cache` and reuses its transform cache, which makes repeated bundles much faster.
|
|
91
91
|
|
|
@@ -131,20 +131,23 @@ Hermes delta mode (`-base-bytecode`): by default (`--hermesBase auto`) `bundle`
|
|
|
131
131
|
interface CLIProvider {
|
|
132
132
|
bundle(options: BundleOptions): Promise<CommandResult>;
|
|
133
133
|
publish(options: PublishOptions): Promise<CommandResult>;
|
|
134
|
+
symbolicate(options: SymbolicateOptions): Promise<CommandResult>;
|
|
134
135
|
upload(options: UploadOptions): Promise<CommandResult>;
|
|
135
136
|
|
|
137
|
+
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
138
|
+
listApps(platform?: Platform): Promise<CommandResult>;
|
|
136
139
|
getSelectedApp(
|
|
137
140
|
platform?: Platform,
|
|
141
|
+
config?: string,
|
|
138
142
|
): Promise<{ appId: string; platform: Platform }>;
|
|
139
|
-
listApps(platform?: Platform): Promise<CommandResult>;
|
|
140
|
-
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
141
143
|
|
|
142
144
|
listVersions(appId: string): Promise<CommandResult>;
|
|
143
145
|
updateVersion(
|
|
144
146
|
appId: string,
|
|
145
147
|
versionId: string,
|
|
146
|
-
updates:
|
|
148
|
+
updates: UpdateVersionOptions,
|
|
147
149
|
): Promise<CommandResult>;
|
|
150
|
+
listPackages(appId: string): Promise<CommandResult>;
|
|
148
151
|
|
|
149
152
|
getPlatform(platform?: Platform): Promise<Platform>;
|
|
150
153
|
loadSession(): Promise<Session>;
|
|
@@ -158,8 +161,12 @@ interface CLIProvider {
|
|
|
158
161
|
```bash
|
|
159
162
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
160
163
|
export NO_INTERACTIVE=true
|
|
164
|
+
export RNU_LANG=en # CLI language (default: zh for pushy, en for cresc)
|
|
165
|
+
export RNU_DEBUG=1 # print stack traces for errors
|
|
161
166
|
```
|
|
162
167
|
|
|
168
|
+
`HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` (upper or lower case) are honored by every request: the API, package and bundle uploads, source map and Hermes base downloads, and the registry version check.
|
|
169
|
+
|
|
163
170
|
## Sentry Sourcemaps
|
|
164
171
|
|
|
165
172
|
When `ios/sentry.properties` or `android/sentry.properties` exists, `bundle` uploads sourcemaps for OTA packages. The default matching path is Sentry Debug IDs; the CLI no longer infers release/dist from the native package.
|
package/README.zh-CN.md
CHANGED
|
@@ -76,7 +76,7 @@ const publishResult = await provider.publish({
|
|
|
76
76
|
- `hdiffFromApp`: 基于 APP 文件生成 hdiff
|
|
77
77
|
- `hdiffFromIpa`: 基于 IPA 文件生成 hdiff
|
|
78
78
|
|
|
79
|
-
Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk),并与 packager map 合成——自 2.23 起 `--sourcemap` 默认开启(`--sourcemap
|
|
79
|
+
Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk),并与 packager map 合成——自 2.23 起 `--sourcemap` 默认开启(`--no-sourcemap` 关闭)。`bundle` 发布时会把这份最终 map 上传并随版本归档(`sourceMapKey`),之后用 `pushy symbolicate` 即可把崩溃堆栈(含 Hermes 的 `address at` 帧)还原到源码。别处打好的 ppk 可用 `pushy publish <ppk> --sourcemap <file.map>` 归档;不带 map 发布会打印警告。
|
|
80
80
|
|
|
81
81
|
Hermes delta 模式(`-base-bytecode`):默认 `--hermesBase auto`,`bundle` 会以同一应用上一版的 HBC 为 base 编译,让 Hermes 字符串 ID 跨版本稳定,热更 patch 可缩小 5~30 倍。base 由服务端(`GET /app/:id/hermesBase`)给出、按 sha256 校验并存入本地缓存(`.pushy/cache/<sha256>`,默认 500 MB / 20 个,可用 `PUSHY_CACHE_DIR` / `--cacheMaxMb` 调整,`pushy cache [clean]` 查看或清空)。`--hermesBase none` 关闭;`--hermesBase <file.hbc|.ppk|.apk|.ipa>` 指定本地文件(比如商店包)作 base。`--verifyHermesBase`(默认开)会并行再做一次普通编译并比对两份反汇编;任何不一致或失败都静默回退到普通编译,不会阻塞发版。只有包含上游 delta 模式修复的 hermesc 才会启用(经典 `react-native/sdks/hermesc`,或 `hermes-compiler` ≥ 250829098)。base 编译失败时,完整的 hermesc 输出会写到中间目录旁边的 `hermes-base-error.log`。`--resetCache false` 可跳过 Metro 的 `--reset-cache`,复用其转换缓存,重复打包会快很多。
|
|
82
82
|
|
|
@@ -122,20 +122,23 @@ Hermes delta 模式(`-base-bytecode`):默认 `--hermesBase auto`,`bundle
|
|
|
122
122
|
interface CLIProvider {
|
|
123
123
|
bundle(options: BundleOptions): Promise<CommandResult>;
|
|
124
124
|
publish(options: PublishOptions): Promise<CommandResult>;
|
|
125
|
+
symbolicate(options: SymbolicateOptions): Promise<CommandResult>;
|
|
125
126
|
upload(options: UploadOptions): Promise<CommandResult>;
|
|
126
127
|
|
|
128
|
+
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
129
|
+
listApps(platform?: Platform): Promise<CommandResult>;
|
|
127
130
|
getSelectedApp(
|
|
128
131
|
platform?: Platform,
|
|
132
|
+
config?: string,
|
|
129
133
|
): Promise<{ appId: string; platform: Platform }>;
|
|
130
|
-
listApps(platform?: Platform): Promise<CommandResult>;
|
|
131
|
-
createApp(name: string, platform: Platform): Promise<CommandResult>;
|
|
132
134
|
|
|
133
135
|
listVersions(appId: string): Promise<CommandResult>;
|
|
134
136
|
updateVersion(
|
|
135
137
|
appId: string,
|
|
136
138
|
versionId: string,
|
|
137
|
-
updates:
|
|
139
|
+
updates: UpdateVersionOptions,
|
|
138
140
|
): Promise<CommandResult>;
|
|
141
|
+
listPackages(appId: string): Promise<CommandResult>;
|
|
139
142
|
|
|
140
143
|
getPlatform(platform?: Platform): Promise<Platform>;
|
|
141
144
|
loadSession(): Promise<Session>;
|
|
@@ -149,8 +152,12 @@ interface CLIProvider {
|
|
|
149
152
|
```bash
|
|
150
153
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
151
154
|
export NO_INTERACTIVE=true
|
|
155
|
+
export RNU_LANG=en # 界面语言(默认:pushy 为 zh,cresc 为 en)
|
|
156
|
+
export RNU_DEBUG=1 # 出错时打印完整堆栈
|
|
152
157
|
```
|
|
153
158
|
|
|
159
|
+
所有请求都遵循 `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY`(大小写均可):API 调用、原生包与热更包上传、source map 与 Hermes base 下载、registry 版本检查。
|
|
160
|
+
|
|
154
161
|
## Sentry Sourcemap
|
|
155
162
|
|
|
156
163
|
当项目存在 `ios/sentry.properties` 或 `android/sentry.properties` 时,`bundle` 会为 OTA 包上传 sourcemap。默认使用 Sentry Debug ID 匹配,不再根据原生包推导 release/dist。
|
package/cli.json
CHANGED
package/lib/api.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare const replaceSession: (newSession: {
|
|
|
9
9
|
export declare const loadSession: () => Promise<void>;
|
|
10
10
|
export declare const saveSession: () => void;
|
|
11
11
|
export declare const closeSession: () => void;
|
|
12
|
+
/** Remove credentials, query signatures and fragments before logging a URL. */
|
|
13
|
+
export declare function redactRequestUrl(requestUrl: string): string;
|
|
12
14
|
export declare const get: (api: string) => Promise<any>;
|
|
13
15
|
export declare const post: (api: string, body?: Record<string, any>) => Promise<any>;
|
|
14
16
|
export declare const put: (api: string, body?: Record<string, any>) => Promise<any>;
|
package/lib/api.js
CHANGED
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
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.redactRequestUrl = redactRequestUrl;
|
|
7
8
|
exports.uploadTimeoutMs = uploadTimeoutMs;
|
|
8
9
|
exports.isTransientUploadError = isTransientUploadError;
|
|
9
10
|
exports.uploadFile = uploadFile;
|
|
10
11
|
exports.getHermesBase = getHermesBase;
|
|
11
12
|
const filesize_parser_1 = __importDefault(require("filesize-parser"));
|
|
12
13
|
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
15
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
16
16
|
const constants_1 = require("./utils/constants");
|
|
@@ -81,13 +81,29 @@ const closeSession = () => {
|
|
|
81
81
|
session = undefined;
|
|
82
82
|
};
|
|
83
83
|
exports.closeSession = closeSession;
|
|
84
|
+
/** Remove credentials, query signatures and fragments before logging a URL. */
|
|
85
|
+
function redactRequestUrl(requestUrl) {
|
|
86
|
+
try {
|
|
87
|
+
const parsed = new URL(requestUrl);
|
|
88
|
+
return `${parsed.protocol}//${parsed.host}${parsed.pathname}${parsed.search ? '?<redacted>' : ''}`;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
const secretStart = requestUrl.search(/[?#]/);
|
|
92
|
+
return secretStart < 0
|
|
93
|
+
? requestUrl
|
|
94
|
+
: `${requestUrl.slice(0, secretStart)}?<redacted>`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
84
97
|
function createRequestError(error, requestUrl, status) {
|
|
85
98
|
const message = typeof error === 'string'
|
|
86
99
|
? error
|
|
87
100
|
: error instanceof Error
|
|
88
101
|
? error.message
|
|
89
102
|
: String(error);
|
|
90
|
-
const
|
|
103
|
+
const cause = error instanceof Error || (typeof error === 'object' && error !== null)
|
|
104
|
+
? error
|
|
105
|
+
: undefined;
|
|
106
|
+
const requestError = new Error(`${message}\nURL: ${redactRequestUrl(requestUrl)}`, cause === undefined ? undefined : { cause });
|
|
91
107
|
requestError.status = status;
|
|
92
108
|
return requestError;
|
|
93
109
|
}
|
|
@@ -105,12 +121,24 @@ const PROXY_ERROR_PATTERNS = [
|
|
|
105
121
|
'ENETUNREACH',
|
|
106
122
|
];
|
|
107
123
|
function isProxyRelatedError(error) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
const seen = new Set();
|
|
125
|
+
const parts = [];
|
|
126
|
+
let current = error;
|
|
127
|
+
while (current !== undefined && current !== null && !seen.has(current)) {
|
|
128
|
+
seen.add(current);
|
|
129
|
+
if (current instanceof Error) {
|
|
130
|
+
const code = current.code;
|
|
131
|
+
parts.push(`${current.name} ${code ?? ''} ${current.message}`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
parts.push(String(current));
|
|
135
|
+
}
|
|
136
|
+
current =
|
|
137
|
+
typeof current === 'object'
|
|
138
|
+
? current.cause
|
|
139
|
+
: undefined;
|
|
140
|
+
}
|
|
141
|
+
const lower = parts.join('\n').toLowerCase();
|
|
114
142
|
return PROXY_ERROR_PATTERNS.some((p) => lower.includes(p.toLowerCase()));
|
|
115
143
|
}
|
|
116
144
|
async function query(url, options) {
|
|
@@ -123,7 +151,7 @@ async function query(url, options) {
|
|
|
123
151
|
catch (error) {
|
|
124
152
|
const baseError = createRequestError(error, fullUrl);
|
|
125
153
|
if (isProxyRelatedError(error)) {
|
|
126
|
-
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}
|
|
154
|
+
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`, { cause: baseError });
|
|
127
155
|
}
|
|
128
156
|
throw baseError;
|
|
129
157
|
}
|
|
@@ -217,11 +245,22 @@ function isTransientUploadError(error) {
|
|
|
217
245
|
return TRANSIENT_UPLOAD_ERROR_CODES.some((c) => text.includes(c));
|
|
218
246
|
}
|
|
219
247
|
class UploadTimeoutError extends Error {
|
|
248
|
+
code = 'ETIMEDOUT';
|
|
220
249
|
constructor(timeoutMs) {
|
|
221
250
|
super(`Upload timed out after ${Math.round(timeoutMs / 1000)}s`);
|
|
222
251
|
this.name = 'UploadTimeoutError';
|
|
223
252
|
}
|
|
224
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* node-fetch is only needed for the streaming multipart / PUT upload below
|
|
256
|
+
* (the built-in fetch cannot stream a form-data body). Loading it eagerly
|
|
257
|
+
* pulled whatwg-url → punycode into every command, which Node ≥ 21 greets
|
|
258
|
+
* with a DEP0040 deprecation warning on stderr; so it is loaded on first use.
|
|
259
|
+
*/
|
|
260
|
+
function loadNodeFetch() {
|
|
261
|
+
const mod = require('node-fetch');
|
|
262
|
+
return (mod.default ?? mod);
|
|
263
|
+
}
|
|
225
264
|
/**
|
|
226
265
|
* Send the file with a size-scaled deadline and one retry on a transient
|
|
227
266
|
* network error. `buildRequest` is invoked per attempt with a fresh file
|
|
@@ -229,6 +268,9 @@ class UploadTimeoutError extends Error {
|
|
|
229
268
|
*/
|
|
230
269
|
async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
231
270
|
const timeoutMs = uploadTimeoutMs(fileSize);
|
|
271
|
+
const nodeFetch = loadNodeFetch();
|
|
272
|
+
// HTTP(S)_PROXY / NO_PROXY, like every other request of the CLI
|
|
273
|
+
const agent = (0, runtime_1.proxyAgentFor)(realUrl);
|
|
232
274
|
for (let attempt = 0;; attempt++) {
|
|
233
275
|
const controller = new AbortController();
|
|
234
276
|
let timedOut = false;
|
|
@@ -241,8 +283,9 @@ async function sendUpload(fn, realUrl, fileSize, bar, buildRequest) {
|
|
|
241
283
|
bar.tick(data.length);
|
|
242
284
|
});
|
|
243
285
|
try {
|
|
244
|
-
return await (
|
|
286
|
+
return await nodeFetch(realUrl, {
|
|
245
287
|
...buildRequest(fileStream),
|
|
288
|
+
agent,
|
|
246
289
|
signal: controller.signal,
|
|
247
290
|
});
|
|
248
291
|
}
|
|
@@ -276,7 +319,9 @@ async function uploadFile(fn, key, appId) {
|
|
|
276
319
|
if (global.USE_ACC_OSS) {
|
|
277
320
|
realUrl = backupUrl;
|
|
278
321
|
}
|
|
279
|
-
else {
|
|
322
|
+
else if (!(0, runtime_1.resolveProxy)(url)) {
|
|
323
|
+
// a direct TCP probe says nothing about the path through a proxy (and
|
|
324
|
+
// usually cannot connect at all): the primary url stays in that case
|
|
280
325
|
const latency = await (0, runtime_1.measureTcpLatency)(url, {
|
|
281
326
|
attempts: 4,
|
|
282
327
|
timeout: 1000,
|
|
@@ -304,11 +349,11 @@ async function uploadFile(fn, key, appId) {
|
|
|
304
349
|
total: fileSize,
|
|
305
350
|
});
|
|
306
351
|
const rethrowUploadError = (error) => {
|
|
352
|
+
const baseError = createRequestError(error, realUrl);
|
|
307
353
|
if (isProxyRelatedError(error)) {
|
|
308
|
-
|
|
309
|
-
throw new Error(`${rawMessage}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`);
|
|
354
|
+
throw new Error(`${baseError.message}\n\n${(0, i18n_1.t)('proxyNetworkError')}\n${(0, i18n_1.t)('proxyNetworkErrorTips')}`, { cause: baseError });
|
|
310
355
|
}
|
|
311
|
-
throw
|
|
356
|
+
throw baseError;
|
|
312
357
|
};
|
|
313
358
|
// 自托管节点的 s3 直传:服务端下发预签名 PUT,字节直达用户的对象存储
|
|
314
359
|
if (resp.method === 'PUT') {
|
|
@@ -343,10 +388,10 @@ async function uploadFile(fn, key, appId) {
|
|
|
343
388
|
if (key) {
|
|
344
389
|
form.append('key', key);
|
|
345
390
|
}
|
|
346
|
-
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
|
|
391
|
+
// With every part's length known node-fetch sends Content-Length instead
|
|
392
|
+
// of a chunked body: what object stores expect, and the only framing
|
|
393
|
+
// that survives http-proxy-agent's rewrite of the buffered request head.
|
|
394
|
+
form.append('file', fileStream, { knownLength: fileSize });
|
|
350
395
|
return { method: 'POST', body: form };
|
|
351
396
|
});
|
|
352
397
|
}
|
package/lib/app.js
CHANGED
|
@@ -36,6 +36,14 @@ function assertPlatform(platform) {
|
|
|
36
36
|
}
|
|
37
37
|
return platform;
|
|
38
38
|
}
|
|
39
|
+
/** Parse a complete positive integer ID without parseInt-style truncation. */
|
|
40
|
+
function parsePositiveIntegerId(value) {
|
|
41
|
+
const id = Number(value);
|
|
42
|
+
if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(id)) {
|
|
43
|
+
throw new Error((0, i18n_1.t)('invalidId', { id: value }));
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
39
47
|
/** Read the selected app for a platform from the requested config file. */
|
|
40
48
|
async function getSelectedApp(platform, configPath) {
|
|
41
49
|
assertPlatform(platform);
|
|
@@ -79,6 +87,7 @@ async function assertAppPlatform(appId, platform) {
|
|
|
79
87
|
if (app.platform && app.platform !== platform) {
|
|
80
88
|
throw new Error((0, i18n_1.t)('appPlatformMismatch', { appId, appPlatform: app.platform, platform }));
|
|
81
89
|
}
|
|
90
|
+
return app;
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
84
93
|
* Resolve the app an operation targets: an explicit `--appId` wins, otherwise
|
|
@@ -123,6 +132,10 @@ async function listApp(platform = '') {
|
|
|
123
132
|
}
|
|
124
133
|
/** Prompt until the user chooses an app belonging to the target platform. */
|
|
125
134
|
async function chooseApp(platform) {
|
|
135
|
+
// Fail before a network request or table output when no prompt is possible.
|
|
136
|
+
if ((0, utils_1.isNonInteractive)()) {
|
|
137
|
+
throw new Error((0, i18n_1.t)('appIdRequired'));
|
|
138
|
+
}
|
|
126
139
|
const list = await listApp(platform);
|
|
127
140
|
while (true) {
|
|
128
141
|
const id = await (0, utils_1.question)((0, i18n_1.t)('enterAppIdQuestion'));
|
|
@@ -136,8 +149,16 @@ async function chooseApp(platform) {
|
|
|
136
149
|
async function selectApp({ args, options, }) {
|
|
137
150
|
const platform = await getPlatform(options.platform);
|
|
138
151
|
const id = args[0]
|
|
139
|
-
?
|
|
152
|
+
? parsePositiveIntegerId(args[0])
|
|
140
153
|
: (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
|
+
const app = await assertAppPlatform(String(id), platform);
|
|
158
|
+
if (typeof app.appKey !== 'string' || !app.appKey) {
|
|
159
|
+
throw new Error((0, i18n_1.t)('appKeyMissing', { appId: id }));
|
|
160
|
+
}
|
|
161
|
+
const appKey = app.appKey;
|
|
141
162
|
const configPath = options.config || constants_1.updateJson;
|
|
142
163
|
let updateInfo = {};
|
|
143
164
|
try {
|
|
@@ -149,7 +170,6 @@ async function selectApp({ args, options, }) {
|
|
|
149
170
|
throw e;
|
|
150
171
|
}
|
|
151
172
|
}
|
|
152
|
-
const { appKey } = await (0, api_1.get)(`/app/${id}`);
|
|
153
173
|
updateInfo[platform] = {
|
|
154
174
|
appId: id,
|
|
155
175
|
appKey,
|
|
@@ -174,7 +194,9 @@ function getAppCommands() {
|
|
|
174
194
|
/** Delete the specified app, or prompt for one when no ID is supplied. */
|
|
175
195
|
deleteApp: async ({ args, options, }) => {
|
|
176
196
|
const { platform } = options;
|
|
177
|
-
const id = args[0]
|
|
197
|
+
const id = args[0]
|
|
198
|
+
? parsePositiveIntegerId(args[0])
|
|
199
|
+
: (await chooseApp(platform)).id;
|
|
178
200
|
if (!id) {
|
|
179
201
|
console.log((0, i18n_1.t)('cancelled'));
|
|
180
202
|
return;
|
package/lib/bin.js
CHANGED
|
@@ -2,17 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const api_1 = require("./api");
|
|
5
|
-
const
|
|
6
|
-
const bundle_1 = require("./bundle");
|
|
7
|
-
const cache_1 = require("./cache");
|
|
8
|
-
const diff_1 = require("./diff");
|
|
9
|
-
const install_1 = require("./install");
|
|
10
|
-
const package_1 = require("./package");
|
|
11
|
-
const symbolicate_1 = require("./symbolicate");
|
|
12
|
-
const user_1 = require("./user");
|
|
5
|
+
const commands_1 = require("./commands");
|
|
13
6
|
const utils_1 = require("./utils");
|
|
14
7
|
const i18n_1 = require("./utils/i18n");
|
|
15
|
-
const versions_1 = require("./versions");
|
|
16
8
|
function isTruthyEnv(value) {
|
|
17
9
|
return value === '1' || value?.toLowerCase() === 'true';
|
|
18
10
|
}
|
|
@@ -20,7 +12,7 @@ function printUsage(exitCode = 1) {
|
|
|
20
12
|
console.log('React Native Update CLI');
|
|
21
13
|
console.log('');
|
|
22
14
|
console.log('Commands:');
|
|
23
|
-
for (const name of
|
|
15
|
+
for (const name of commands_1.commandNames) {
|
|
24
16
|
console.log(` ${name}`);
|
|
25
17
|
}
|
|
26
18
|
console.log('');
|
|
@@ -31,20 +23,25 @@ function printUsage(exitCode = 1) {
|
|
|
31
23
|
console.log('Visit `https://github.com/reactnativecn/react-native-update` for document.');
|
|
32
24
|
process.exit(exitCode);
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
26
|
+
/**
|
|
27
|
+
* Errors reaching the top level are almost always about the user's input,
|
|
28
|
+
* project or network: print their message. The stack trace, which only helps
|
|
29
|
+
* when the CLI itself is at fault, is printed on request (RNU_DEBUG=1).
|
|
30
|
+
*/
|
|
31
|
+
function reportError(err) {
|
|
32
|
+
if (isTruthyEnv(process.env.RNU_DEBUG)) {
|
|
33
|
+
console.error(err instanceof Error ? err.stack : err);
|
|
34
|
+
// fetch failures wrap the real reason (ECONNREFUSED, TLS, ...) as `cause`
|
|
35
|
+
for (let cause = err?.cause; cause; cause = cause?.cause) {
|
|
36
|
+
console.error('Caused by:', cause);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
41
|
+
console.error((0, i18n_1.t)('errorStackHint'));
|
|
42
|
+
}
|
|
46
43
|
async function run() {
|
|
47
|
-
const versionOnly =
|
|
44
|
+
const versionOnly = ['-v', '--version', 'version'].includes(process.argv[2] ?? '');
|
|
48
45
|
// The registry check for newer versions runs alongside the command (from a
|
|
49
46
|
// 1-day cache when possible) and only ever delays `-v`/`version` itself; its
|
|
50
47
|
// hint is printed once the command is done, or at exit for commands that
|
|
@@ -60,39 +57,36 @@ async function run() {
|
|
|
60
57
|
versionCheck.startAutoUpdate();
|
|
61
58
|
}
|
|
62
59
|
});
|
|
63
|
-
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
64
|
-
global.NO_INTERACTIVE =
|
|
65
|
-
Boolean(argv.options['no-interactive']) ||
|
|
66
|
-
isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
67
|
-
global.USE_ACC_OSS =
|
|
68
|
-
Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
69
60
|
try {
|
|
61
|
+
// inside the try: an unknown command or option is reported like any other
|
|
62
|
+
// error instead of crashing with an unhandled rejection
|
|
63
|
+
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
64
|
+
global.NO_INTERACTIVE =
|
|
65
|
+
Boolean(argv.options['no-interactive']) ||
|
|
66
|
+
isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
67
|
+
global.USE_ACC_OSS =
|
|
68
|
+
Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
70
69
|
await (0, api_1.loadSession)();
|
|
71
|
-
if (argv.command === 'help') {
|
|
72
|
-
printUsage(0);
|
|
73
|
-
}
|
|
74
|
-
else if (argv.command === 'list') {
|
|
70
|
+
if (argv.command === 'help' || argv.command === 'list') {
|
|
75
71
|
printUsage(0);
|
|
76
72
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await handler(argv);
|
|
80
|
-
// a check still in flight (cold cache) gets a short grace period; the
|
|
81
|
-
// registry request itself is unref'd, so exiting never waits on it
|
|
82
|
-
await versionCheck.settle(500);
|
|
83
|
-
versionCheck.printHints();
|
|
84
|
-
versionCheck.startAutoUpdate();
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
73
|
+
const handler = (0, commands_1.loadCommandHandler)(argv.command);
|
|
74
|
+
if (!handler) {
|
|
87
75
|
throw new Error((0, i18n_1.t)('unknownCommand', { command: argv.command }));
|
|
88
76
|
}
|
|
77
|
+
await handler(argv);
|
|
78
|
+
// a check still in flight (cold cache) gets a short grace period; the
|
|
79
|
+
// registry request itself is unref'd, so exiting never waits on it
|
|
80
|
+
await versionCheck.settle(500);
|
|
81
|
+
versionCheck.printHints();
|
|
82
|
+
versionCheck.startAutoUpdate();
|
|
89
83
|
}
|
|
90
84
|
catch (err) {
|
|
91
|
-
if (err
|
|
85
|
+
if (err?.status === 401) {
|
|
92
86
|
console.log((0, i18n_1.t)('loginFirst'));
|
|
93
87
|
process.exit(1);
|
|
94
88
|
}
|
|
95
|
-
|
|
89
|
+
reportError(err);
|
|
96
90
|
process.exit(1);
|
|
97
91
|
}
|
|
98
92
|
}
|
package/lib/bundle-runner.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export interface HermesBaseSelectionResult {
|
|
|
43
43
|
/** hermesc could not be resolved; the compile phase will report it */
|
|
44
44
|
commandUnavailable?: boolean;
|
|
45
45
|
}
|
|
46
|
+
interface GradleConfig {
|
|
47
|
+
crunchPngs?: boolean;
|
|
48
|
+
enableHermes?: boolean;
|
|
49
|
+
}
|
|
46
50
|
type ResolvedExpoCli = {
|
|
47
51
|
cliPath: string;
|
|
48
52
|
usingExpo: boolean;
|
|
@@ -76,6 +80,29 @@ type SentryUploadMode = {
|
|
|
76
80
|
export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
|
|
77
81
|
export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
|
|
78
82
|
export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, hermesBase, resetCache, cli, isSentry, }: RunBundleCommandOptions): Promise<HermesCompileResult | null>;
|
|
83
|
+
/**
|
|
84
|
+
* Validate the intermediate directory before it is emptied and return the
|
|
85
|
+
* canonical path that was validated. The caller must use this returned path:
|
|
86
|
+
* validating one spelling and deleting through another re-opens symlink
|
|
87
|
+
* redirection.
|
|
88
|
+
*/
|
|
89
|
+
export declare function assertSafeToEmpty(dir: string, cwd?: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the app runs Hermes, i.e. whether the bundle must be compiled to
|
|
92
|
+
* bytecode. A JS bundle shipped to a Hermes app still runs, but starts slower
|
|
93
|
+
* and cannot use the Hermes base delta, so false negatives are what this
|
|
94
|
+
* guards against.
|
|
95
|
+
*
|
|
96
|
+
* Android: `hermesEnabled` in gradle.properties wins; then the legacy
|
|
97
|
+
* `project.ext.react.enableHermes` of build.gradle; with neither, the React
|
|
98
|
+
* Native gradle plugin (0.71+) defaults to Hermes and older versions to JSC.
|
|
99
|
+
* iOS: an installed `Pods/hermes-engine`; when `pod install` has not run on
|
|
100
|
+
* this machine (CI), Expo's `Podfile.properties.json` or the pod listed in
|
|
101
|
+
* `Podfile.lock` tell the same.
|
|
102
|
+
*/
|
|
103
|
+
export declare function detectHermesEnabled(platform: string, forceHermes: boolean | undefined, gradleConfig: GradleConfig, projectRoot?: string): Promise<boolean>;
|
|
104
|
+
/** Hermes on iOS: explicit configuration first, installed artifacts second. */
|
|
105
|
+
export declare function detectIosHermes(projectRoot: string): boolean;
|
|
79
106
|
export declare function resolveHermesCommand(projectRoot?: string): string;
|
|
80
107
|
/**
|
|
81
108
|
* hermesc argument policy. `-output-source-map` is always passed: hermesc then
|