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.
Files changed (95) hide show
  1. package/README.md +11 -4
  2. package/README.zh-CN.md +11 -4
  3. package/cli.json +7 -1
  4. package/lib/api.d.ts +2 -0
  5. package/lib/api.js +63 -18
  6. package/lib/app.js +25 -3
  7. package/lib/bin.js +39 -45
  8. package/lib/bundle-runner.d.ts +27 -0
  9. package/lib/bundle-runner.js +240 -21
  10. package/lib/bundle.d.ts +1 -1
  11. package/lib/bundle.js +19 -6
  12. package/lib/commands.d.ts +6 -0
  13. package/lib/commands.js +65 -0
  14. package/lib/locales/en.d.ts +5 -14
  15. package/lib/locales/en.js +5 -14
  16. package/lib/locales/zh.d.ts +5 -13
  17. package/lib/locales/zh.js +5 -13
  18. package/lib/package.js +4 -0
  19. package/lib/provider.d.ts +1 -1
  20. package/lib/provider.js +3 -1
  21. package/lib/symbolicate.js +11 -3
  22. package/lib/types.d.ts +1 -0
  23. package/lib/user.js +6 -0
  24. package/lib/utils/add-gitignore.js +7 -1
  25. package/lib/utils/dep-versions.d.ts +7 -0
  26. package/lib/utils/dep-versions.js +78 -26
  27. package/lib/utils/git.js +9 -6
  28. package/lib/utils/hermes-base.js +2 -1
  29. package/lib/utils/i18n.d.ts +5 -0
  30. package/lib/utils/i18n.js +14 -1
  31. package/lib/utils/index.d.ts +2 -1
  32. package/lib/utils/index.js +9 -4
  33. package/lib/utils/latest-version/index.js +8 -0
  34. package/lib/utils/runtime.d.ts +21 -0
  35. package/lib/utils/runtime.js +138 -5
  36. package/lib/utils/slim-sourcemap.d.ts +11 -0
  37. package/lib/utils/slim-sourcemap.js +22 -0
  38. package/lib/utils/zip-range.js +3 -2
  39. package/lib/versions.js +16 -15
  40. package/package.json +4 -2
  41. package/lib/index.d.ts +0 -1
  42. package/lib/index.js +0 -17
  43. package/src/api.ts +0 -470
  44. package/src/app.ts +0 -241
  45. package/src/auto-update.ts +0 -647
  46. package/src/bin-cresc.ts +0 -8
  47. package/src/bin.ts +0 -115
  48. package/src/bundle-pack.ts +0 -61
  49. package/src/bundle-runner.ts +0 -1430
  50. package/src/bundle.ts +0 -371
  51. package/src/cache.ts +0 -20
  52. package/src/diff.ts +0 -1010
  53. package/src/exports.ts +0 -17
  54. package/src/index.ts +0 -1
  55. package/src/install.ts +0 -50
  56. package/src/locales/en.ts +0 -257
  57. package/src/locales/zh.ts +0 -234
  58. package/src/native-package.ts +0 -338
  59. package/src/package.ts +0 -482
  60. package/src/provider.ts +0 -294
  61. package/src/symbolicate.ts +0 -159
  62. package/src/types.ts +0 -150
  63. package/src/user.ts +0 -39
  64. package/src/utils/add-gitignore.ts +0 -35
  65. package/src/utils/app-info-parser/aab.ts +0 -241
  66. package/src/utils/app-info-parser/apk.ts +0 -92
  67. package/src/utils/app-info-parser/app.ts +0 -7
  68. package/src/utils/app-info-parser/index.ts +0 -54
  69. package/src/utils/app-info-parser/ipa.ts +0 -109
  70. package/src/utils/app-info-parser/resource-finder.ts +0 -508
  71. package/src/utils/app-info-parser/utils.ts +0 -161
  72. package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
  73. package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
  74. package/src/utils/app-info-parser/zip.ts +0 -108
  75. package/src/utils/check-lockfile.ts +0 -93
  76. package/src/utils/check-plugin.ts +0 -38
  77. package/src/utils/command-result.ts +0 -24
  78. package/src/utils/constants.ts +0 -25
  79. package/src/utils/dep-versions.ts +0 -83
  80. package/src/utils/git.ts +0 -71
  81. package/src/utils/hbcTransform.ts +0 -649
  82. package/src/utils/hermes-base.ts +0 -1137
  83. package/src/utils/http-helper.ts +0 -152
  84. package/src/utils/i18n.ts +0 -39
  85. package/src/utils/index.ts +0 -698
  86. package/src/utils/latest-version/index.ts +0 -573
  87. package/src/utils/options.ts +0 -78
  88. package/src/utils/plugin-config.ts +0 -32
  89. package/src/utils/runtime.ts +0 -187
  90. package/src/utils/slim-sourcemap.ts +0 -83
  91. package/src/utils/zip-entries.ts +0 -209
  92. package/src/utils/zip-options.ts +0 -178
  93. package/src/utils/zip-range.ts +0 -727
  94. package/src/utils/zip-raw-writer.ts +0 -247
  95. package/src/versions.ts +0 -894
package/lib/locales/zh.js CHANGED
@@ -34,24 +34,18 @@ exports.default = {
34
34
  bundlingWithRN: '正在使用 react-native {{version}} 打包',
35
35
  cancelled: '已取消',
36
36
  composingSourceMap: '正在生成 source map',
37
- copyFileFailed: '复制文件失败:{{error}}',
38
- copyHarmonyBundleError: '复制 Harmony bundle 错误:{{error}}',
39
37
  copyingDebugId: '正在复制 debugid',
40
38
  createAppSuccess: '已成功创建应用(id: {{id}})',
41
39
  deleteFile: '删除 {{- file}}',
42
- deletingFile: '删除 {{- file}}',
43
40
  enterAppIdQuestion: '输入应用 id:',
44
41
  enterNativePackageId: '输入原生包 id:',
45
- errorInHarmonyApp: '获取 Harmony 应用入口时出错:{{error}}',
46
42
  expiredStatus: '(已过期)',
47
- failedToParseIcon: '[警告] 解析图标失败:{{error}}',
48
43
  failedToParseUpdateJson: '无法解析文件 `{{- configPath}}`。请手动删除它。',
49
44
  fileGenerated: '已生成 {{- file}}',
50
45
  fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
51
46
  forceHermes: '强制启用 Hermes 编译',
52
47
  hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
53
48
  ipaUploadSuccess: '已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
54
- keyStrings: '键字符串:',
55
49
  latestVersionTag: '(最新:{{version}})',
56
50
  lockBestPractice: `
57
51
  关于 lock 文件的最佳实践:
@@ -94,15 +88,9 @@ exports.default = {
94
88
  packing: '正在打包',
95
89
  pausedStatus: '(已暂停)',
96
90
  platform: '平台',
97
- platformPrompt: '平台(ios/android/harmony):',
98
91
  platformQuestion: '平台(ios/android/harmony):',
99
- platformRequired: '必须指定平台。',
100
92
  pluginDetectionError: '检测 {{name}} 插件时出错:{{error}}',
101
93
  pluginDetected: '检测到 {{name}} 插件',
102
- ppkPackageGenerated: 'ppk 热更包已生成并保存到: {{- output}}',
103
- processingError: '处理文件时出错:{{error}}',
104
- processingPackage: '正在处理包 {{count}}...',
105
- processingStringPool: '正在处理字符串池...',
106
94
  sourceMapNotFound: '找不到 source map:{{path}}',
107
95
  sourceMapMissingWarning: '本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
108
96
  sourceMapArchived: 'source map 已随版本 {{id}} 归档',
@@ -122,7 +110,6 @@ exports.default = {
122
110
  sentryReleaseCreated: '已为版本 {{version}} 创建 Sentry release',
123
111
  totalApps: '共 {{count}} 个 {{platform}} 应用',
124
112
  totalPackages: '共 {{count}} 个包',
125
- typeStrings: '类型字符串:',
126
113
  unsupportedPlatform: '无法识别的平台 `{{platform}}`',
127
114
  uploadBundlePrompt: '是否现在上传此热更包?(Y/N)',
128
115
  uploadingSourcemap: '正在上传 sourcemap',
@@ -187,4 +174,9 @@ exports.default = {
187
174
  hermesBaseVerifyFailed: 'Hermes base:字节码与普通编译不等价,放弃 base 重新编译',
188
175
  cacheCleaned: '已清理 {{count}} 个缓存 bundle',
189
176
  cacheStats: 'bundle 缓存:{{- dir}} — {{files}} 个文件,{{mb}} MB',
177
+ loginCredentialsRequired: '需要提供邮箱和密码。用法:{{scriptName}} login <邮箱> <密码>',
178
+ bundleUnexpectedArgs: 'bundle 不接受位置参数,收到:{{- args}}。布尔选项不带值,关闭请使用 --no-<选项>(例如 --no-sourcemap)。',
179
+ unsafeIntermediateDir: '拒绝清空中间目录 {{- dir}}:该路径指向受保护目录或包含符号链接。请用 --intermediaDir 指定一个专用的构建目录。',
180
+ appKeyMissing: '应用 {{appId}} 未返回有效的 appKey。',
181
+ errorStackHint: '(设置 RNU_DEBUG=1 可打印完整堆栈)',
190
182
  };
package/lib/package.js CHANGED
@@ -206,6 +206,10 @@ async function listPackage(appId, packages) {
206
206
  return allPkgs;
207
207
  }
208
208
  async function choosePackage(appId, packages) {
209
+ // Fail before fetching or rendering the package list when no prompt exists.
210
+ if ((0, utils_1.isNonInteractive)()) {
211
+ throw new Error((0, i18n_1.t)('packageIdRequired'));
212
+ }
209
213
  const list = await listPackage(appId, packages);
210
214
  const packageMap = new Map(list?.map((v) => [v.id.toString(), v]));
211
215
  while (true) {
package/lib/provider.d.ts CHANGED
@@ -20,5 +20,5 @@ export declare class CLIProviderImpl implements CLIProvider {
20
20
  updateVersion(appId: string, versionId: string, updates: UpdateVersionOptions): Promise<CommandResult>;
21
21
  getPlatform(platform?: Platform): Promise<Platform>;
22
22
  loadSession(): Promise<Session>;
23
- listPackages(appId?: string): Promise<CommandResult>;
23
+ listPackages(appId: string): Promise<CommandResult>;
24
24
  }
package/lib/provider.js CHANGED
@@ -84,13 +84,15 @@ class CLIProviderImpl {
84
84
  entryFile: options.entryFile || 'index.js',
85
85
  output: options.output || DEFAULT_BUNDLE_OUTPUT,
86
86
  'no-interactive': true,
87
- sourcemap: options.sourcemap || false,
87
+ // on by default like the CLI: archived with the version for symbolicate
88
+ sourcemap: options.sourcemap ?? true,
88
89
  taro: options.taro || false,
89
90
  expo: options.expo || false,
90
91
  rncli: options.rncli || false,
91
92
  hermes: options.hermes || false,
92
93
  hermesBase: options.hermesBase || 'auto',
93
94
  verifyHermesBase: options.verifyHermesBase ?? true,
95
+ resetCache: options.resetCache ?? true,
94
96
  sentryRelease: options.sentryRelease,
95
97
  sentryDist: options.sentryDist,
96
98
  appId: options.appId,
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.symbolicateCommands = void 0;
7
7
  exports.symbolicateStack = symbolicateStack;
8
8
  const fs_1 = __importDefault(require("fs"));
9
- const node_fetch_1 = __importDefault(require("node-fetch"));
10
9
  const source_map_1 = require("source-map");
11
10
  const api_1 = require("./api");
12
11
  const app_1 = require("./app");
13
12
  const i18n_1 = require("./utils/i18n");
13
+ const runtime_1 = require("./utils/runtime");
14
+ const slim_sourcemap_1 = require("./utils/slim-sourcemap");
14
15
  const versions_1 = require("./versions");
15
16
  // A frame location inside a shipped bundle: `<bundle>:<line>:<column>`. Covers
16
17
  // `index.bundlejs`, `index.android.bundle`, `main.jsbundle`, `bundle.harmony.js`
@@ -58,6 +59,11 @@ async function findVersionByHash(appId, hash) {
58
59
  }
59
60
  async function readStack(source) {
60
61
  if (!source || source === '-') {
62
+ // No file and an interactive terminal: nothing is piped in, so waiting on
63
+ // stdin would just hang. `-` is an explicit request for stdin either way.
64
+ if (!source && process.stdin.isTTY) {
65
+ throw new Error((0, i18n_1.t)('symbolicateUsage'));
66
+ }
61
67
  return new Promise((resolve, reject) => {
62
68
  const chunks = [];
63
69
  process.stdin.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
@@ -93,11 +99,13 @@ exports.symbolicateCommands = {
93
99
  if (!located?.url) {
94
100
  throw new Error((0, i18n_1.t)('symbolicateNoSourceMap', { id: versionId }));
95
101
  }
96
- const response = await (0, node_fetch_1.default)(located.url);
102
+ const response = await (0, runtime_1.webFetch)(located.url);
97
103
  if (!response.ok) {
98
104
  throw new Error(`Failed to download source map: HTTP ${response.status}`);
99
105
  }
100
- const rawMap = JSON.parse(await response.text());
106
+ // Maps archived by recent CLI versions are gzipped; older ones are plain
107
+ // JSON, and unpackSourceMap accepts both.
108
+ const rawMap = JSON.parse((0, slim_sourcemap_1.unpackSourceMap)(Buffer.from(await response.arrayBuffer())));
101
109
  const consumer = new source_map_1.SourceMapConsumer(rawMap);
102
110
  const stack = await readStack(args[0]);
103
111
  const { text, mapped } = symbolicateStack(stack, consumer);
package/lib/types.d.ts CHANGED
@@ -123,6 +123,7 @@ export interface CLIProvider {
123
123
  }>;
124
124
  listVersions: (appId: string) => Promise<CommandResult>;
125
125
  updateVersion: (appId: string, versionId: string, updates: UpdateVersionOptions) => Promise<CommandResult>;
126
+ listPackages: (appId: string) => Promise<CommandResult>;
126
127
  getPlatform: (platform?: Platform) => Promise<Platform>;
127
128
  loadSession: () => Promise<Session>;
128
129
  }
package/lib/user.js CHANGED
@@ -8,6 +8,7 @@ const crypto_1 = __importDefault(require("crypto"));
8
8
  const api_1 = require("./api");
9
9
  const utils_1 = require("./utils");
10
10
  const add_gitignore_1 = require("./utils/add-gitignore");
11
+ const constants_1 = require("./utils/constants");
11
12
  const i18n_1 = require("./utils/i18n");
12
13
  function md5(str) {
13
14
  return crypto_1.default.createHash('md5').update(str).digest('hex');
@@ -16,6 +17,11 @@ exports.userCommands = {
16
17
  login: async ({ args }) => {
17
18
  const email = args[0] || (await (0, utils_1.question)('email:'));
18
19
  const pwd = args[1] || (await (0, utils_1.question)('password:', true));
20
+ if (!email || !pwd) {
21
+ // without a terminal `question` answers '': fail here instead of
22
+ // sending empty credentials to the server
23
+ throw new Error((0, i18n_1.t)('loginCredentialsRequired', { scriptName: constants_1.scriptName }));
24
+ }
19
25
  const { token, info } = await (0, api_1.post)('/user/login', {
20
26
  email,
21
27
  pwd: md5(pwd),
@@ -16,8 +16,14 @@ function addGitIgnore() {
16
16
  }
17
17
  const gitignoreContent = fs_1.default.readFileSync(gitignorePath, 'utf-8');
18
18
  const gitignoreLines = gitignoreContent.split('\n');
19
+ // `.pushy`, `/.pushy` and `.pushy/` all ignore the same directory; a
20
+ // trailing slash only matches directories, so it counts for tempDir alone
21
+ const covers = (entry, line) => {
22
+ const pattern = line.trim().replace(/^\//, '');
23
+ return pattern === entry || (entry === constants_1.tempDir && pattern === `${entry}/`);
24
+ };
19
25
  for (const line of gitignoreLines) {
20
- const index = shouldIgnore.indexOf(line.trim());
26
+ const index = shouldIgnore.findIndex((entry) => covers(entry, line));
21
27
  if (index !== -1) {
22
28
  shouldIgnore.splice(index, 1);
23
29
  }
@@ -1,5 +1,12 @@
1
1
  /** Installed versions of the cwd project's dependencies, keys sorted. */
2
2
  export declare function getDepVersions(): Record<string, string>;
3
+ /**
4
+ * Installed version of one direct (dev)dependency of the cwd project, or
5
+ * undefined when the project does not declare it or it is not installed.
6
+ * Two file reads instead of one per dependency: the version banner printed
7
+ * before every command must not scale with the size of the project.
8
+ */
9
+ export declare function getDepVersion(name: string, cwd?: string): string | undefined;
3
10
  /**
4
11
  * Same data as `getDepVersions()` but as a lazily populated object, for the
5
12
  * remaining property-access call sites (`depVersions['react-native']`).
@@ -1,37 +1,70 @@
1
1
  "use strict";
2
- // Installed versions of every dependency/devDependency of the project in cwd.
3
- // Resolving them means reading one package.json per dependency, so this is
4
- // done lazily (on first use) and memoized rather than at import time, which
5
- // used to cost every command ~3-30 ms before it even parsed its arguments.
2
+ // Installed versions of the dependencies/devDependencies of the project in
3
+ // cwd. Resolving them means reading one package.json per dependency, so the
4
+ // full map is built lazily (on first use) and memoized rather than at import
5
+ // time, and the version banner printed by every command asks for the single
6
+ // dependency it needs (`getDepVersion`) instead of the whole map.
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
6
10
  Object.defineProperty(exports, "__esModule", { value: true });
7
11
  exports.depVersions = void 0;
8
12
  exports.getDepVersions = getDepVersions;
13
+ exports.getDepVersion = getDepVersion;
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const path_1 = __importDefault(require("path"));
16
+ let cachedCwd;
9
17
  let cached;
10
- function readDepVersions() {
11
- let currentPackage = null;
18
+ function readProjectPackageJson(cwd) {
12
19
  try {
13
- currentPackage = require(`${process.cwd()}/package.json`);
20
+ return JSON.parse(fs_1.default.readFileSync(path_1.default.join(cwd, 'package.json'), 'utf8'));
14
21
  }
15
- catch (_e) {
16
- // console.warn('No package.json file were found');
22
+ catch {
23
+ // no package.json (or not JSON): the project simply declares nothing
24
+ return null;
17
25
  }
26
+ }
27
+ /** direct dependency names (dependencies + devDependencies), deduplicated */
28
+ function directDependencyNames(pkg) {
29
+ return [
30
+ ...new Set([
31
+ ...Object.keys(pkg.dependencies ?? {}),
32
+ ...Object.keys(pkg.devDependencies ?? {}),
33
+ ]),
34
+ ];
35
+ }
36
+ /**
37
+ * Version of the installed copy of `dep`: the nearest
38
+ * `node_modules/<dep>/package.json` from `cwd` upwards, read directly. Not
39
+ * `require.resolve`: a package whose `exports` map omits package.json makes
40
+ * it throw, and bun caches its answer per specifier, ignoring `paths`.
41
+ */
42
+ function readInstalledVersion(dep, cwd) {
43
+ let dir = path_1.default.resolve(cwd);
44
+ for (;;) {
45
+ try {
46
+ const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, 'node_modules', dep, 'package.json'), 'utf8'));
47
+ return typeof pkg.version === 'string' ? pkg.version : undefined;
48
+ }
49
+ catch {
50
+ // not installed at this level
51
+ }
52
+ const parent = path_1.default.dirname(dir);
53
+ if (parent === dir) {
54
+ return undefined;
55
+ }
56
+ dir = parent;
57
+ }
58
+ }
59
+ function readDepVersions(cwd) {
18
60
  const versions = {};
19
- if (currentPackage) {
20
- const depKeys = currentPackage.dependencies
21
- ? Object.keys(currentPackage.dependencies)
22
- : [];
23
- const devDepKeys = currentPackage.devDependencies
24
- ? Object.keys(currentPackage.devDependencies)
25
- : [];
26
- const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
27
- for (const dep of dedupedDeps) {
28
- try {
29
- const packageJsonPath = require.resolve(`${dep}/package.json`, {
30
- paths: [process.cwd()],
31
- });
32
- versions[dep] = require(packageJsonPath).version;
61
+ const pkg = readProjectPackageJson(cwd);
62
+ if (pkg) {
63
+ for (const dep of directDependencyNames(pkg)) {
64
+ const version = readInstalledVersion(dep, cwd);
65
+ if (version) {
66
+ versions[dep] = version;
33
67
  }
34
- catch (_e) { }
35
68
  }
36
69
  }
37
70
  // sorted keys: the object is sent to the server as-is and diffed
@@ -44,11 +77,30 @@ function readDepVersions() {
44
77
  }
45
78
  /** Installed versions of the cwd project's dependencies, keys sorted. */
46
79
  function getDepVersions() {
47
- if (!cached) {
48
- cached = readDepVersions();
80
+ const cwd = path_1.default.resolve(process.cwd());
81
+ if (!cached || cachedCwd !== cwd) {
82
+ cached = readDepVersions(cwd);
83
+ cachedCwd = cwd;
49
84
  }
50
85
  return cached;
51
86
  }
87
+ /**
88
+ * Installed version of one direct (dev)dependency of the cwd project, or
89
+ * undefined when the project does not declare it or it is not installed.
90
+ * Two file reads instead of one per dependency: the version banner printed
91
+ * before every command must not scale with the size of the project.
92
+ */
93
+ function getDepVersion(name, cwd = process.cwd()) {
94
+ const resolvedCwd = path_1.default.resolve(cwd);
95
+ if (cached && cachedCwd === resolvedCwd) {
96
+ return cached[name];
97
+ }
98
+ const pkg = readProjectPackageJson(resolvedCwd);
99
+ if (!pkg || !directDependencyNames(pkg).includes(name)) {
100
+ return undefined;
101
+ }
102
+ return readInstalledVersion(name, resolvedCwd);
103
+ }
52
104
  /**
53
105
  * Same data as `getDepVersions()` but as a lazily populated object, for the
54
106
  * remaining property-access call sites (`depVersions['react-native']`).
package/lib/utils/git.js CHANGED
@@ -35,16 +35,19 @@ async function getRemoteOrigin(cwd) {
35
35
  async function getCommitInfo() {
36
36
  try {
37
37
  const gitRoot = await gitOutput(['rev-parse', '--show-toplevel']);
38
- const [hash, message, author, timestamp, origin] = await Promise.all([
39
- gitOutput(['rev-parse', 'HEAD'], gitRoot),
40
- gitOutput(['log', '-1', '--format=%B'], gitRoot),
41
- gitOutput(['log', '-1', '--format=%an'], gitRoot),
42
- gitOutput(['log', '-1', '--format=%ct'], gitRoot),
38
+ // one `git log` for every commit field (NUL-separated, the multi-line
39
+ // message last) instead of one git process per field
40
+ const [log, origin] = await Promise.all([
41
+ gitOutput(['log', '-1', '--format=%H%x00%an%x00%ct%x00%B'], gitRoot),
43
42
  getRemoteOrigin(gitRoot),
44
43
  ]);
44
+ const [hash, author, timestamp, ...message] = log.split('\0');
45
+ if (!hash) {
46
+ return;
47
+ }
45
48
  return {
46
49
  hash,
47
- message,
50
+ message: message.join('\0'),
48
51
  author,
49
52
  timestamp,
50
53
  origin,
@@ -80,6 +80,7 @@ const promises_1 = require("stream/promises");
80
80
  const constants_1 = require("./constants");
81
81
  const hbcTransform_1 = require("./hbcTransform");
82
82
  const i18n_1 = require("./i18n");
83
+ const runtime_1 = require("./runtime");
83
84
  const zip_entries_1 = require("./zip-entries");
84
85
  const zip_range_1 = require("./zip-range");
85
86
  /**
@@ -492,7 +493,7 @@ async function downloadToFile(url, destination) {
492
493
  const headersTimer = setTimeout(() => controller.abort(new Error('timeout waiting for response')), FETCH_HEADERS_TIMEOUT_MS);
493
494
  let response;
494
495
  try {
495
- response = await fetch(url, { signal: controller.signal });
496
+ response = await (0, runtime_1.webFetch)(url, { signal: controller.signal });
496
497
  }
497
498
  finally {
498
499
  clearTimeout(headersTimer);
@@ -1,5 +1,10 @@
1
1
  import en from '../locales/en';
2
2
  import zh from '../locales/zh';
3
+ /**
4
+ * UI language: `RNU_LANG=en|zh` (a locale such as `zh_CN` counts by its
5
+ * prefix) overrides the brand default, Chinese for pushy and English for cresc.
6
+ */
7
+ export declare function resolveLanguage(env?: NodeJS.ProcessEnv, isCresc?: boolean): 'en' | 'zh';
3
8
  declare module 'i18next' {
4
9
  interface CustomTypeOptions {
5
10
  defaultNS: 'en';
package/lib/utils/i18n.js CHANGED
@@ -3,13 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveLanguage = resolveLanguage;
6
7
  exports.t = t;
7
8
  const i18next_1 = __importDefault(require("i18next"));
8
9
  const en_1 = __importDefault(require("../locales/en"));
9
10
  const zh_1 = __importDefault(require("../locales/zh"));
10
11
  const constants_1 = require("./constants");
12
+ /**
13
+ * UI language: `RNU_LANG=en|zh` (a locale such as `zh_CN` counts by its
14
+ * prefix) overrides the brand default, Chinese for pushy and English for cresc.
15
+ */
16
+ function resolveLanguage(env = process.env, isCresc = constants_1.IS_CRESC) {
17
+ const override = env.RNU_LANG?.trim().toLowerCase();
18
+ if (override?.startsWith('zh'))
19
+ return 'zh';
20
+ if (override?.startsWith('en'))
21
+ return 'en';
22
+ return isCresc ? 'en' : 'zh';
23
+ }
11
24
  i18next_1.default.init({
12
- lng: constants_1.IS_CRESC ? 'en' : 'zh',
25
+ lng: resolveLanguage(),
13
26
  // debug: process.env.NODE_ENV !== 'production',
14
27
  // debug: true,
15
28
  resources: {
@@ -4,7 +4,8 @@ import { checkPlugins } from './check-plugin';
4
4
  * a CJS module can hand back a namespace object, so unwrap `default`.
5
5
  */
6
6
  export declare function loadTtyTable(): typeof import('tty-table');
7
- export declare function isNonInteractive(): boolean;
7
+ /** True when prompts cannot or must not be shown. */
8
+ export declare function isNonInteractive(env?: NodeJS.ProcessEnv, stdinIsTTY?: boolean | undefined, globalFlag?: boolean | undefined): boolean;
8
9
  export declare function question(query: string, password?: boolean): Promise<string>;
9
10
  export declare function translateOptions<T extends Record<string, unknown>>(options: T, map?: Record<string, string>): T & Record<string, unknown>;
10
11
  export declare const ApkBundleFileName: RegExp;
@@ -39,9 +39,13 @@ function loadTtyTable() {
39
39
  const mod = require('tty-table');
40
40
  return (mod.default ?? mod);
41
41
  }
42
- function isNonInteractive() {
43
- const envValue = process.env.NO_INTERACTIVE?.toLowerCase();
44
- return (global.NO_INTERACTIVE === true || envValue === 'true' || envValue === '1');
42
+ /** True when prompts cannot or must not be shown. */
43
+ function isNonInteractive(env = process.env, stdinIsTTY = process.stdin.isTTY, globalFlag = global.NO_INTERACTIVE) {
44
+ const envValue = env.NO_INTERACTIVE?.toLowerCase();
45
+ return (globalFlag === true ||
46
+ envValue === 'true' ||
47
+ envValue === '1' ||
48
+ stdinIsTTY !== true);
45
49
  }
46
50
  async function question(query, password) {
47
51
  if (isNonInteractive()) {
@@ -450,7 +454,8 @@ function latestTag(version) {
450
454
  * newer once the command is done — the command itself is never delayed by it.
451
455
  */
452
456
  async function printVersionCommand({ wait = true, } = {}) {
453
- const rnuVersion = (0, dep_versions_1.getDepVersions)()['react-native-update'];
457
+ // one dependency, not the whole map: this runs before every command
458
+ const rnuVersion = (0, dep_versions_1.getDepVersion)('react-native-update');
454
459
  let latest;
455
460
  const check = getLatestVersions(!wait).then((versions) => {
456
461
  latest = versions;
@@ -12,6 +12,7 @@ const path_1 = require("path");
12
12
  const registry_auth_token_1 = __importDefault(require("registry-auth-token"));
13
13
  const registry_url_1 = __importDefault(require("registry-auth-token/registry-url"));
14
14
  const url_1 = require("url");
15
+ const runtime_1 = require("../runtime");
15
16
  exports.ONE_DAY = 1000 * 60 * 60 * 24; // eslint-disable-line @typescript-eslint/naming-convention
16
17
  const isPackageJson = (obj) => {
17
18
  return (obj.dependencies !== undefined ||
@@ -43,6 +44,13 @@ const downloadMetadata = (pkgName, options) => {
43
44
  if (options?.requestOptions) {
44
45
  requestOptions = { ...requestOptions, ...options.requestOptions };
45
46
  }
47
+ if (requestOptions.agent === undefined) {
48
+ // HTTP(S)_PROXY / NO_PROXY, like every other request of the CLI
49
+ const agent = (0, runtime_1.proxyAgentFor)(pkgUrl.toString());
50
+ if (agent) {
51
+ requestOptions = { ...requestOptions, agent };
52
+ }
53
+ }
46
54
  const { get } = require(pkgUrl.protocol === 'https:' ? 'https' : 'http');
47
55
  const request = get(requestOptions, (res) => {
48
56
  if (res.statusCode === 200) {
@@ -1,4 +1,5 @@
1
1
  import { type ChildProcessWithoutNullStreams, type SpawnOptionsWithoutStdio, type SpawnSyncOptions } from 'child_process';
2
+ import type { Agent as HttpAgent } from 'http';
2
3
  export type RuntimeRequestInit = {
3
4
  method?: string;
4
5
  headers?: Record<string, string>;
@@ -14,6 +15,26 @@ export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
14
15
  export type JavaScriptRuntime = 'bun' | 'node';
15
16
  export declare const isBunRuntime: boolean;
16
17
  export declare function runtimeFetch(url: string, options?: RuntimeRequestInit): Promise<RuntimeResponse>;
18
+ /**
19
+ * The proxy url for `targetUrl` from the environment, or undefined for a
20
+ * direct connection (no proxy configured, NO_PROXY exempts the host, or the
21
+ * proxy is not an http(s) url).
22
+ */
23
+ export declare function resolveProxy(targetUrl: string, env?: NodeJS.ProcessEnv): string | undefined;
24
+ /**
25
+ * fetch with the WHATWG Response, through the environment's proxy when one
26
+ * applies to `url`. The proxy path goes through undici's own fetch (Node's
27
+ * built-in one cannot take a dispatcher), loaded only then.
28
+ */
29
+ export declare function webFetch(url: string, init?: RequestInit): Promise<Response>;
30
+ /**
31
+ * An http.Agent routing `targetUrl` through its proxy, for the core
32
+ * http/https APIs and node-fetch (the streaming uploads); undefined when the
33
+ * connection is direct. Always a CONNECT tunnel (also for http targets, like
34
+ * undici's ProxyAgent above): the absolute-form alternative rewrites the
35
+ * request head after it was buffered, which garbles a streaming body.
36
+ */
37
+ export declare function proxyAgentFor(targetUrl: string): HttpAgent | undefined;
17
38
  export declare function measureTcpLatency(input: string, { attempts, timeout, }?: {
18
39
  attempts?: number;
19
40
  timeout?: number;