react-native-update-cli 2.24.2 → 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 (93) 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 +7 -2
  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/zip-range.js +3 -2
  37. package/lib/versions.js +7 -4
  38. package/package.json +4 -2
  39. package/lib/index.d.ts +0 -1
  40. package/lib/index.js +0 -17
  41. package/src/api.ts +0 -470
  42. package/src/app.ts +0 -241
  43. package/src/auto-update.ts +0 -647
  44. package/src/bin-cresc.ts +0 -8
  45. package/src/bin.ts +0 -115
  46. package/src/bundle-pack.ts +0 -61
  47. package/src/bundle-runner.ts +0 -1430
  48. package/src/bundle.ts +0 -371
  49. package/src/cache.ts +0 -20
  50. package/src/diff.ts +0 -1010
  51. package/src/exports.ts +0 -17
  52. package/src/index.ts +0 -1
  53. package/src/install.ts +0 -50
  54. package/src/locales/en.ts +0 -257
  55. package/src/locales/zh.ts +0 -234
  56. package/src/native-package.ts +0 -338
  57. package/src/package.ts +0 -482
  58. package/src/provider.ts +0 -294
  59. package/src/symbolicate.ts +0 -164
  60. package/src/types.ts +0 -150
  61. package/src/user.ts +0 -39
  62. package/src/utils/add-gitignore.ts +0 -35
  63. package/src/utils/app-info-parser/aab.ts +0 -241
  64. package/src/utils/app-info-parser/apk.ts +0 -92
  65. package/src/utils/app-info-parser/app.ts +0 -7
  66. package/src/utils/app-info-parser/index.ts +0 -54
  67. package/src/utils/app-info-parser/ipa.ts +0 -109
  68. package/src/utils/app-info-parser/resource-finder.ts +0 -508
  69. package/src/utils/app-info-parser/utils.ts +0 -161
  70. package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
  71. package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
  72. package/src/utils/app-info-parser/zip.ts +0 -108
  73. package/src/utils/check-lockfile.ts +0 -93
  74. package/src/utils/check-plugin.ts +0 -38
  75. package/src/utils/command-result.ts +0 -24
  76. package/src/utils/constants.ts +0 -25
  77. package/src/utils/dep-versions.ts +0 -83
  78. package/src/utils/git.ts +0 -71
  79. package/src/utils/hbcTransform.ts +0 -649
  80. package/src/utils/hermes-base.ts +0 -1137
  81. package/src/utils/http-helper.ts +0 -152
  82. package/src/utils/i18n.ts +0 -39
  83. package/src/utils/index.ts +0 -698
  84. package/src/utils/latest-version/index.ts +0 -573
  85. package/src/utils/options.ts +0 -78
  86. package/src/utils/plugin-config.ts +0 -32
  87. package/src/utils/runtime.ts +0 -187
  88. package/src/utils/slim-sourcemap.ts +0 -105
  89. package/src/utils/zip-entries.ts +0 -209
  90. package/src/utils/zip-options.ts +0 -178
  91. package/src/utils/zip-range.ts +0 -727
  92. package/src/utils/zip-raw-writer.ts +0 -247
  93. package/src/versions.ts +0 -892
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isBunRuntime = void 0;
7
7
  exports.runtimeFetch = runtimeFetch;
8
+ exports.resolveProxy = resolveProxy;
9
+ exports.webFetch = webFetch;
10
+ exports.proxyAgentFor = proxyAgentFor;
8
11
  exports.measureTcpLatency = measureTcpLatency;
9
12
  exports.detectPackageManager = detectPackageManager;
10
13
  exports.getInstallCommand = getInstallCommand;
@@ -14,15 +17,145 @@ exports.spawnJavaScriptSync = spawnJavaScriptSync;
14
17
  const child_process_1 = require("child_process");
15
18
  const fs_1 = __importDefault(require("fs"));
16
19
  const net_1 = require("net");
17
- const node_fetch_1 = __importDefault(require("node-fetch"));
18
20
  const path_1 = __importDefault(require("path"));
19
21
  exports.isBunRuntime = typeof process.versions.bun ===
20
22
  'string';
21
23
  function runtimeFetch(url, options) {
22
- const fetchImpl = typeof globalThis.fetch === 'function'
23
- ? globalThis.fetch.bind(globalThis)
24
- : node_fetch_1.default;
25
- return fetchImpl(url, options);
24
+ return webFetch(url, options);
25
+ }
26
+ // ---------------------------------------------------------------------------
27
+ // proxies
28
+ //
29
+ // Node's built-in fetch ignores HTTP(S)_PROXY, so behind a corporate proxy or
30
+ // a VPN every request of the CLI used to fail with a connection error. Every
31
+ // network path (API, uploads, source map / Hermes base downloads, the registry
32
+ // version check) resolves its proxy here, with the conventions curl, npm and
33
+ // undici share: HTTPS_PROXY for https targets (falling back to HTTP_PROXY),
34
+ // HTTP_PROXY for http targets, NO_PROXY to exempt hosts.
35
+ // ---------------------------------------------------------------------------
36
+ function firstEnv(env, ...names) {
37
+ for (const name of names) {
38
+ const value = env[name]?.trim();
39
+ if (value)
40
+ return value;
41
+ }
42
+ return undefined;
43
+ }
44
+ /**
45
+ * NO_PROXY: comma/space separated hosts; `*` exempts everything; a leading
46
+ * `.` (or `*.`) matches sub-domains, a plain host matches itself and its
47
+ * sub-domains, `host:port` only that port.
48
+ */
49
+ function matchesNoProxy(target, noProxy) {
50
+ if (!noProxy)
51
+ return false;
52
+ const host = target.hostname.toLowerCase();
53
+ const port = target.port || (target.protocol === 'https:' ? '443' : '80');
54
+ for (const raw of noProxy.split(/[\s,]+/)) {
55
+ let entry = raw.trim().toLowerCase();
56
+ if (!entry)
57
+ continue;
58
+ if (entry === '*')
59
+ return true;
60
+ let entryPort;
61
+ const withPort = /^([^:]+):(\d+)$/.exec(entry);
62
+ if (withPort) {
63
+ entry = withPort[1];
64
+ entryPort = withPort[2];
65
+ }
66
+ if (entryPort && entryPort !== port)
67
+ continue;
68
+ if (entry.startsWith('*.'))
69
+ entry = entry.slice(1);
70
+ if (entry.startsWith('.'))
71
+ entry = entry.slice(1);
72
+ if (host === entry || host.endsWith(`.${entry}`))
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+ /**
78
+ * The proxy url for `targetUrl` from the environment, or undefined for a
79
+ * direct connection (no proxy configured, NO_PROXY exempts the host, or the
80
+ * proxy is not an http(s) url).
81
+ */
82
+ function resolveProxy(targetUrl, env = process.env) {
83
+ let target;
84
+ try {
85
+ target = new URL(targetUrl);
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ if (target.protocol !== 'http:' && target.protocol !== 'https:') {
91
+ return undefined;
92
+ }
93
+ const proxy = target.protocol === 'https:'
94
+ ? firstEnv(env, 'HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy')
95
+ : firstEnv(env, 'HTTP_PROXY', 'http_proxy');
96
+ if (!proxy || matchesNoProxy(target, firstEnv(env, 'NO_PROXY', 'no_proxy'))) {
97
+ return undefined;
98
+ }
99
+ try {
100
+ const parsed = new URL(proxy);
101
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
102
+ return undefined;
103
+ }
104
+ }
105
+ catch {
106
+ return undefined;
107
+ }
108
+ return proxy;
109
+ }
110
+ const proxyDispatchers = new Map();
111
+ /**
112
+ * fetch with the WHATWG Response, through the environment's proxy when one
113
+ * applies to `url`. The proxy path goes through undici's own fetch (Node's
114
+ * built-in one cannot take a dispatcher), loaded only then.
115
+ */
116
+ function webFetch(url, init = {}) {
117
+ const proxy = resolveProxy(url);
118
+ if (proxy) {
119
+ const undici = require('undici');
120
+ let dispatcher = proxyDispatchers.get(proxy);
121
+ if (!dispatcher) {
122
+ dispatcher = new undici.ProxyAgent(proxy);
123
+ proxyDispatchers.set(proxy, dispatcher);
124
+ }
125
+ return undici.fetch(url, {
126
+ ...init,
127
+ dispatcher,
128
+ });
129
+ }
130
+ if (typeof globalThis.fetch === 'function') {
131
+ return globalThis.fetch(url, init);
132
+ }
133
+ // Node < 18 only. Loaded on demand so the built-in fetch path never pays
134
+ // for node-fetch (nor for the punycode deprecation warning it triggers on
135
+ // Node ≥ 21).
136
+ const mod = require('node-fetch');
137
+ const nodeFetch = (mod.default ?? mod);
138
+ return nodeFetch(url, init);
139
+ }
140
+ const proxyAgents = new Map();
141
+ /**
142
+ * An http.Agent routing `targetUrl` through its proxy, for the core
143
+ * http/https APIs and node-fetch (the streaming uploads); undefined when the
144
+ * connection is direct. Always a CONNECT tunnel (also for http targets, like
145
+ * undici's ProxyAgent above): the absolute-form alternative rewrites the
146
+ * request head after it was buffered, which garbles a streaming body.
147
+ */
148
+ function proxyAgentFor(targetUrl) {
149
+ const proxy = resolveProxy(targetUrl);
150
+ if (!proxy)
151
+ return undefined;
152
+ let agent = proxyAgents.get(proxy);
153
+ if (!agent) {
154
+ const { HttpsProxyAgent } = require('https-proxy-agent');
155
+ agent = new HttpsProxyAgent(proxy);
156
+ proxyAgents.set(proxy, agent);
157
+ }
158
+ return agent;
26
159
  }
27
160
  function resolveTcpTarget(input) {
28
161
  try {
@@ -25,6 +25,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
25
25
  const stream_1 = require("stream");
26
26
  const yauzl_1 = require("yauzl");
27
27
  const zlib_1 = require("zlib");
28
+ const runtime_1 = require("./runtime");
28
29
  const zip_entries_1 = require("./zip-entries");
29
30
  exports.ZIP_STORED = 0;
30
31
  exports.ZIP_DEFLATED = 8;
@@ -206,7 +207,7 @@ async function fetchRange(url, start, end, options) {
206
207
  headers['If-Range'] = options.ifRange;
207
208
  let response;
208
209
  try {
209
- response = await fetch(url, {
210
+ response = await (0, runtime_1.webFetch)(url, {
210
211
  headers,
211
212
  signal: AbortSignal.timeout(options.timeoutMs),
212
213
  });
@@ -497,7 +498,7 @@ async function openRemoteZip(url, options = {}) {
497
498
  const timeoutMs = timeoutFor(TAIL_BYTES, options);
498
499
  let response;
499
500
  try {
500
- response = await fetch(url, {
501
+ response = await (0, runtime_1.webFetch)(url, {
501
502
  headers: { Range: `bytes=-${TAIL_BYTES}`, 'Accept-Encoding': 'identity' },
502
503
  signal: AbortSignal.timeout(timeoutMs),
503
504
  });
package/lib/versions.js CHANGED
@@ -415,10 +415,13 @@ exports.versionCommands = {
415
415
  return undefined;
416
416
  })
417
417
  : Promise.resolve(undefined),
418
- ]);
419
- if (packTempDir) {
420
- fs_1.default.rmSync(packTempDir, { recursive: true, force: true });
421
- }
418
+ ]).finally(() => {
419
+ // the packed copy only exists for the upload; a failed ppk upload must
420
+ // not leave it behind in the OS temp dir
421
+ if (packTempDir) {
422
+ fs_1.default.rmSync(packTempDir, { recursive: true, force: true });
423
+ }
424
+ });
422
425
  const sourceMapKey = sourceMapUpload?.hash;
423
426
  if (sourcemapPath && !sourceMapKey) {
424
427
  console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapUploadFailedWarning', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.24.2",
3
+ "version": "2.25.0",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "lib/exports.js",
6
6
  "types": "lib/exports.d.ts",
@@ -27,7 +27,6 @@
27
27
  },
28
28
  "files": [
29
29
  "lib",
30
- "src",
31
30
  "proto",
32
31
  "cli.json"
33
32
  ],
@@ -39,6 +38,7 @@
39
38
  "lint": "bun run typecheck && biome check .",
40
39
  "lint:fix": "bun run typecheck && biome check --write .",
41
40
  "test": "bun test",
41
+ "smoke": "node scripts/smoke-lib.js",
42
42
  "test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
43
43
  "benchmark:diff-stream": "bun scripts/benchmark-diff-stream.ts"
44
44
  },
@@ -71,6 +71,7 @@
71
71
  "fs-extra": "^11.4.0",
72
72
  "global-dirs": "^4.0.0",
73
73
  "gradle-to-js": "^2.0.1",
74
+ "https-proxy-agent": "^7.0.6",
74
75
  "i18next": "^26.4.0",
75
76
  "node-fetch": "^2.6.1",
76
77
  "plist": "^5.0.0",
@@ -81,6 +82,7 @@
81
82
  "registry-auth-token": "^5.1.1",
82
83
  "source-map": "0.6.1",
83
84
  "tty-table": "5.0",
85
+ "undici": "^6.28.0",
84
86
  "yauzl": "^3.4.0",
85
87
  "yazl": "3.3.1"
86
88
  },
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './exports';
package/lib/index.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./exports"), exports);