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
@@ -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 {
@@ -15,3 +15,14 @@
15
15
  * original file untouched.
16
16
  */
17
17
  export declare function slimSourceMap(content: string, projectRoot: string): string | null;
18
+ /**
19
+ * Build the bytes actually archived with a version: the slimmed map (when it
20
+ * is a plain map we understand), gzipped. Source maps are JSON and compress
21
+ * about 5x, which is the difference between a multi-megabyte upload on every
22
+ * publish and a small one. Readers detect the gzip magic bytes rather than
23
+ * trusting a file name, so plain maps archived by older CLI versions keep
24
+ * working unchanged.
25
+ */
26
+ export declare function packSourceMap(content: string, projectRoot: string): Buffer;
27
+ /** Decode an archived source map: gzip when the magic bytes say so. */
28
+ export declare function unpackSourceMap(data: Buffer): string;
@@ -4,7 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.slimSourceMap = slimSourceMap;
7
+ exports.packSourceMap = packSourceMap;
8
+ exports.unpackSourceMap = unpackSourceMap;
7
9
  const path_1 = __importDefault(require("path"));
10
+ const zlib_1 = __importDefault(require("zlib"));
8
11
  /**
9
12
  * Shrink a source map before archiving it with a version, without losing the
10
13
  * ability to locate any frame:
@@ -68,3 +71,22 @@ function relativizeSource(source, rootPrefix) {
68
71
  function isDependencySource(source) {
69
72
  return (source.startsWith('node_modules/') || source.includes('/node_modules/'));
70
73
  }
74
+ /**
75
+ * Build the bytes actually archived with a version: the slimmed map (when it
76
+ * is a plain map we understand), gzipped. Source maps are JSON and compress
77
+ * about 5x, which is the difference between a multi-megabyte upload on every
78
+ * publish and a small one. Readers detect the gzip magic bytes rather than
79
+ * trusting a file name, so plain maps archived by older CLI versions keep
80
+ * working unchanged.
81
+ */
82
+ function packSourceMap(content, projectRoot) {
83
+ const slimmed = slimSourceMap(content, projectRoot);
84
+ return zlib_1.default.gzipSync(Buffer.from(slimmed ?? content, 'utf8'));
85
+ }
86
+ /** Decode an archived source map: gzip when the magic bytes say so. */
87
+ function unpackSourceMap(data) {
88
+ if (data.length >= 2 && data[0] === 0x1f && data[1] === 0x8b) {
89
+ return zlib_1.default.gunzipSync(data).toString('utf8');
90
+ }
91
+ return data.toString('utf8');
92
+ }
@@ -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
@@ -385,19 +385,17 @@ exports.versionCommands = {
385
385
  if (!sourcemapPath) {
386
386
  console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapMissingWarning')));
387
387
  }
388
- // Archive a slimmed copy: relative paths, no dependency sourcesContent
389
- // (see slimSourceMap). Frames keep symbolicating everywhere; only inline
390
- // snippets of node_modules code are dropped, and the map shrinks by the
391
- // bulk of its bytes. If the file is not a plain map, upload it untouched.
388
+ // Archive a slimmed, gzipped copy (see packSourceMap): relative paths, no
389
+ // dependency sourcesContent, ~5x smaller on the wire. Frames keep
390
+ // symbolicating everywhere; only inline snippets of node_modules code are
391
+ // dropped. The temp file keeps the .map extension because /upload routes
392
+ // by extension; readers detect gzip by magic bytes.
392
393
  let uploadSourcemapPath = sourcemapPath;
393
- let slimTempDir;
394
+ let packTempDir;
394
395
  if (sourcemapPath) {
395
- const slimmed = (0, slim_sourcemap_1.slimSourceMap)(fs_1.default.readFileSync(sourcemapPath, 'utf8'), process.cwd());
396
- if (slimmed !== null) {
397
- slimTempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-sourcemap-'));
398
- uploadSourcemapPath = path_1.default.join(slimTempDir, path_1.default.basename(sourcemapPath));
399
- fs_1.default.writeFileSync(uploadSourcemapPath, slimmed);
400
- }
396
+ packTempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'rnu-sourcemap-'));
397
+ uploadSourcemapPath = path_1.default.join(packTempDir, path_1.default.basename(sourcemapPath));
398
+ fs_1.default.writeFileSync(uploadSourcemapPath, (0, slim_sourcemap_1.packSourceMap)(fs_1.default.readFileSync(sourcemapPath, 'utf8'), process.cwd()));
401
399
  }
402
400
  // Hashing/caching the bundle and asking git for the commit are independent
403
401
  // of the upload, so they overlap with it instead of running afterwards.
@@ -417,10 +415,13 @@ exports.versionCommands = {
417
415
  return undefined;
418
416
  })
419
417
  : Promise.resolve(undefined),
420
- ]);
421
- if (slimTempDir) {
422
- fs_1.default.rmSync(slimTempDir, { recursive: true, force: true });
423
- }
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
+ });
424
425
  const sourceMapKey = sourceMapUpload?.hash;
425
426
  if (sourcemapPath && !sourceMapKey) {
426
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.1",
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);