react-native-update-cli 2.24.2 → 2.26.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 +12 -5
- package/README.zh-CN.md +12 -5
- 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 +45 -1
- package/lib/bundle-runner.js +303 -34
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +23 -7
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +7 -14
- package/lib/locales/en.js +10 -17
- package/lib/locales/zh.d.ts +7 -13
- package/lib/locales/zh.js +10 -16
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +7 -2
- 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/hbcTransform.d.ts +15 -0
- package/lib/utils/hbcTransform.js +22 -0
- package/lib/utils/hermes-base.d.ts +61 -6
- package/lib/utils/hermes-base.js +328 -46
- package/lib/utils/hermes-literals.d.ts +51 -0
- package/lib/utils/hermes-literals.js +210 -0
- 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/zip-range.js +3 -2
- package/lib/versions.js +14 -4
- package/package.json +6 -3
- 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 -164
- 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 -105
- 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 -892
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiteralResolver = void 0;
|
|
4
|
+
exports.readLiteralBuffers = readLiteralBuffers;
|
|
5
|
+
exports.decodeSerializedLiterals = decodeSerializedLiterals;
|
|
6
|
+
exports.renderLiteral = renderLiteral;
|
|
7
|
+
/**
|
|
8
|
+
* Binary literal buffers of an HBC file, for the Hermes base equivalence
|
|
9
|
+
* check (see docs/hermes-base-verification.md §3.2).
|
|
10
|
+
*
|
|
11
|
+
* `NewArrayWithBuffer` / `NewObjectWithBuffer` reference their literals by
|
|
12
|
+
* *byte offset* into the serialized literal buffers. The text dump prints
|
|
13
|
+
* those buffers entry by entry without byte positions, so the offsets in the
|
|
14
|
+
* instructions cannot be mapped to entries from the dump alone — and a delta
|
|
15
|
+
* build may lay the buffers out differently (deduplicated runs, different
|
|
16
|
+
* order) while every instruction still resolves to the same literals. Reading
|
|
17
|
+
* the buffers from the file and decoding at each instruction's offset
|
|
18
|
+
* compares what the instruction actually builds.
|
|
19
|
+
*
|
|
20
|
+
* Serialized literal format (hermes SerializedLiteralGenerator): runs of
|
|
21
|
+
* same-typed values. Tag byte: bits 6..4 = type, bit 7 = "length continues in
|
|
22
|
+
* the next byte", bits 3..0 = low 4 bits of the run length (high 8 bits in
|
|
23
|
+
* the next byte when bit 7 is set). Values follow the tag, fixed width per
|
|
24
|
+
* type: none (null/true/false), 8-byte little-endian double, 4/2/1-byte
|
|
25
|
+
* string id, 4-byte little-endian int32.
|
|
26
|
+
*/
|
|
27
|
+
const promises_1 = require("node:fs/promises");
|
|
28
|
+
const hbcTransform_1 = require("./hbcTransform");
|
|
29
|
+
const HBC_HEADER_SIZE = 128;
|
|
30
|
+
const TAG_TYPE_MASK = 0x70;
|
|
31
|
+
const TAG_LENGTH_CONTINUES = 0x80;
|
|
32
|
+
const TAG_LENGTH_LOW = 0x0f;
|
|
33
|
+
var Tag;
|
|
34
|
+
(function (Tag) {
|
|
35
|
+
Tag[Tag["Null"] = 0] = "Null";
|
|
36
|
+
Tag[Tag["True"] = 16] = "True";
|
|
37
|
+
Tag[Tag["False"] = 32] = "False";
|
|
38
|
+
Tag[Tag["Number"] = 48] = "Number";
|
|
39
|
+
Tag[Tag["LongString"] = 64] = "LongString";
|
|
40
|
+
Tag[Tag["ShortString"] = 80] = "ShortString";
|
|
41
|
+
Tag[Tag["ByteString"] = 96] = "ByteString";
|
|
42
|
+
Tag[Tag["Integer"] = 112] = "Integer";
|
|
43
|
+
})(Tag || (Tag = {}));
|
|
44
|
+
/**
|
|
45
|
+
* Read only the literal buffers of an HBC file (header + three byte ranges,
|
|
46
|
+
* never the whole file). Null for a file whose layout is unknown, including
|
|
47
|
+
* HBC v98 (literalValueBuffer + objShapeTable, not decoded yet): the caller
|
|
48
|
+
* then falls back to comparing the dumped buffers as a whole.
|
|
49
|
+
*/
|
|
50
|
+
async function readLiteralBuffers(file) {
|
|
51
|
+
const handle = await (0, promises_1.open)(file, 'r');
|
|
52
|
+
try {
|
|
53
|
+
const { size } = await handle.stat();
|
|
54
|
+
if (size < HBC_HEADER_SIZE)
|
|
55
|
+
return null;
|
|
56
|
+
const header = Buffer.alloc(HBC_HEADER_SIZE);
|
|
57
|
+
const read = await handle.read(header, 0, HBC_HEADER_SIZE, 0);
|
|
58
|
+
if (read.bytesRead !== HBC_HEADER_SIZE)
|
|
59
|
+
return null;
|
|
60
|
+
const resolved = (0, hbcTransform_1.resolveHbcSections)(header, size);
|
|
61
|
+
if (!resolved)
|
|
62
|
+
return null;
|
|
63
|
+
const range = (name) => resolved.sections.get(name);
|
|
64
|
+
const array = range('arrayBuffer');
|
|
65
|
+
const objectKeys = range('objKeyBuffer');
|
|
66
|
+
const objectValues = range('objValueBuffer');
|
|
67
|
+
if (!array || !objectKeys || !objectValues)
|
|
68
|
+
return null;
|
|
69
|
+
const readRange = async (r) => {
|
|
70
|
+
const buf = Buffer.alloc(r.size);
|
|
71
|
+
if (r.size === 0)
|
|
72
|
+
return buf;
|
|
73
|
+
const { bytesRead } = await handle.read(buf, 0, r.size, r.start);
|
|
74
|
+
return bytesRead === r.size ? buf : null;
|
|
75
|
+
};
|
|
76
|
+
const [a, k, v] = await Promise.all([
|
|
77
|
+
readRange(array),
|
|
78
|
+
readRange(objectKeys),
|
|
79
|
+
readRange(objectValues),
|
|
80
|
+
]);
|
|
81
|
+
if (!a || !k || !v)
|
|
82
|
+
return null;
|
|
83
|
+
return {
|
|
84
|
+
version: resolved.version,
|
|
85
|
+
array: a,
|
|
86
|
+
objectKeys: k,
|
|
87
|
+
objectValues: v,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
await handle.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Decode `count` literal values starting at byte `offset`. Null when the
|
|
96
|
+
* offset or a run reaches outside the buffer or a tag type is unknown; the
|
|
97
|
+
* caller reports that as a difference rather than guessing.
|
|
98
|
+
*/
|
|
99
|
+
function decodeSerializedLiterals(buffer, offset, count) {
|
|
100
|
+
const values = [];
|
|
101
|
+
let pos = offset;
|
|
102
|
+
while (values.length < count) {
|
|
103
|
+
if (pos < 0 || pos >= buffer.length)
|
|
104
|
+
return null;
|
|
105
|
+
const tag = buffer[pos++];
|
|
106
|
+
let length = tag & TAG_LENGTH_LOW;
|
|
107
|
+
if (tag & TAG_LENGTH_CONTINUES) {
|
|
108
|
+
if (pos >= buffer.length)
|
|
109
|
+
return null;
|
|
110
|
+
length = (length << 8) | buffer[pos++];
|
|
111
|
+
}
|
|
112
|
+
const type = tag & TAG_TYPE_MASK;
|
|
113
|
+
for (let i = 0; i < length && values.length < count; i++) {
|
|
114
|
+
switch (type) {
|
|
115
|
+
case Tag.Null:
|
|
116
|
+
values.push({ kind: 'null' });
|
|
117
|
+
break;
|
|
118
|
+
case Tag.True:
|
|
119
|
+
values.push({ kind: 'true' });
|
|
120
|
+
break;
|
|
121
|
+
case Tag.False:
|
|
122
|
+
values.push({ kind: 'false' });
|
|
123
|
+
break;
|
|
124
|
+
case Tag.Number:
|
|
125
|
+
if (pos + 8 > buffer.length)
|
|
126
|
+
return null;
|
|
127
|
+
values.push({ kind: 'number', value: buffer.readDoubleLE(pos) });
|
|
128
|
+
pos += 8;
|
|
129
|
+
break;
|
|
130
|
+
case Tag.LongString:
|
|
131
|
+
if (pos + 4 > buffer.length)
|
|
132
|
+
return null;
|
|
133
|
+
values.push({ kind: 'string', id: buffer.readUInt32LE(pos) });
|
|
134
|
+
pos += 4;
|
|
135
|
+
break;
|
|
136
|
+
case Tag.ShortString:
|
|
137
|
+
if (pos + 2 > buffer.length)
|
|
138
|
+
return null;
|
|
139
|
+
values.push({ kind: 'string', id: buffer.readUInt16LE(pos) });
|
|
140
|
+
pos += 2;
|
|
141
|
+
break;
|
|
142
|
+
case Tag.ByteString:
|
|
143
|
+
if (pos + 1 > buffer.length)
|
|
144
|
+
return null;
|
|
145
|
+
values.push({ kind: 'string', id: buffer[pos] });
|
|
146
|
+
pos += 1;
|
|
147
|
+
break;
|
|
148
|
+
case Tag.Integer:
|
|
149
|
+
if (pos + 4 > buffer.length)
|
|
150
|
+
return null;
|
|
151
|
+
values.push({ kind: 'int', value: buffer.readInt32LE(pos) });
|
|
152
|
+
pos += 4;
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return values;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* One literal as text, string ids resolved through the dump's string table
|
|
163
|
+
* (an unknown id stays visible as `?id`). Doubles keep their exact bits in
|
|
164
|
+
* the text so -0 and 0, or two NaNs, never collide by accident.
|
|
165
|
+
*/
|
|
166
|
+
function renderLiteral(value, strings) {
|
|
167
|
+
switch (value.kind) {
|
|
168
|
+
case 'null':
|
|
169
|
+
case 'true':
|
|
170
|
+
case 'false':
|
|
171
|
+
return value.kind;
|
|
172
|
+
case 'int':
|
|
173
|
+
return `[int ${value.value}]`;
|
|
174
|
+
case 'number': {
|
|
175
|
+
const bits = Buffer.alloc(8);
|
|
176
|
+
bits.writeDoubleLE(value.value);
|
|
177
|
+
return `[double ${Object.is(value.value, -0) ? '-0' : String(value.value)}#${bits.toString('hex')}]`;
|
|
178
|
+
}
|
|
179
|
+
case 'string': {
|
|
180
|
+
const text = strings.get(value.id);
|
|
181
|
+
return `[String ${text === undefined ? `?${value.id}` : JSON.stringify(text)}]`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Decodes the literals an instruction refers to, for one side of a compare.
|
|
187
|
+
* Returns rendered entries, or null when the offset cannot be decoded.
|
|
188
|
+
*/
|
|
189
|
+
class LiteralResolver {
|
|
190
|
+
buffers;
|
|
191
|
+
strings;
|
|
192
|
+
constructor(buffers, strings) {
|
|
193
|
+
this.buffers = buffers;
|
|
194
|
+
this.strings = strings;
|
|
195
|
+
}
|
|
196
|
+
decode(buffer, offset, count) {
|
|
197
|
+
const values = decodeSerializedLiterals(buffer, offset, count);
|
|
198
|
+
return values ? values.map((v) => renderLiteral(v, this.strings)) : null;
|
|
199
|
+
}
|
|
200
|
+
array(offset, count) {
|
|
201
|
+
return this.decode(this.buffers.array, offset, count);
|
|
202
|
+
}
|
|
203
|
+
objectKeys(offset, count) {
|
|
204
|
+
return this.decode(this.buffers.objectKeys, offset, count);
|
|
205
|
+
}
|
|
206
|
+
objectValues(offset, count) {
|
|
207
|
+
return this.decode(this.buffers.objectValues, offset, count);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.LiteralResolver = LiteralResolver;
|
package/lib/utils/i18n.d.ts
CHANGED
|
@@ -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:
|
|
25
|
+
lng: resolveLanguage(),
|
|
13
26
|
// debug: process.env.NODE_ENV !== 'production',
|
|
14
27
|
// debug: true,
|
|
15
28
|
resources: {
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/lib/utils/index.js
CHANGED
|
@@ -39,9 +39,13 @@ function loadTtyTable() {
|
|
|
39
39
|
const mod = require('tty-table');
|
|
40
40
|
return (mod.default ?? mod);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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) {
|
package/lib/utils/runtime.d.ts
CHANGED
|
@@ -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;
|
package/lib/utils/runtime.js
CHANGED
|
@@ -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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 {
|
package/lib/utils/zip-range.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
@@ -358,6 +358,13 @@ async function describePpkBundle(ppkPath, base) {
|
|
|
358
358
|
meta.baseVersionId = base.baseVersionId;
|
|
359
359
|
if (base?.baseHash)
|
|
360
360
|
meta.baseHash = base.baseHash;
|
|
361
|
+
// equivalence-check result: the server tells a rejected base from "no base"
|
|
362
|
+
// only through these; a server without the columns ignores the keys
|
|
363
|
+
if (base?.hermesBaseOutcome)
|
|
364
|
+
meta.hermesBaseOutcome = base.hermesBaseOutcome;
|
|
365
|
+
if (base?.hermesBaseDetail) {
|
|
366
|
+
meta.hermesBaseDetail = (0, hermes_base_1.truncateHermesBaseDetail)(base.hermesBaseDetail);
|
|
367
|
+
}
|
|
361
368
|
return meta;
|
|
362
369
|
}
|
|
363
370
|
/** Exported for tests: the version/create fields derived from a ppk + base. */
|
|
@@ -415,10 +422,13 @@ exports.versionCommands = {
|
|
|
415
422
|
return undefined;
|
|
416
423
|
})
|
|
417
424
|
: Promise.resolve(undefined),
|
|
418
|
-
])
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
]).finally(() => {
|
|
426
|
+
// the packed copy only exists for the upload; a failed ppk upload must
|
|
427
|
+
// not leave it behind in the OS temp dir
|
|
428
|
+
if (packTempDir) {
|
|
429
|
+
fs_1.default.rmSync(packTempDir, { recursive: true, force: true });
|
|
430
|
+
}
|
|
431
|
+
});
|
|
422
432
|
const sourceMapKey = sourceMapUpload?.hash;
|
|
423
433
|
if (sourcemapPath && !sourceMapKey) {
|
|
424
434
|
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.
|
|
3
|
+
"version": "2.26.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,8 +38,10 @@
|
|
|
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
|
-
"benchmark:diff-stream": "bun scripts/benchmark-diff-stream.ts"
|
|
43
|
+
"benchmark:diff-stream": "bun scripts/benchmark-diff-stream.ts",
|
|
44
|
+
"fuzz:hermes-base": "bun scripts/fuzz-hermes-base.ts"
|
|
44
45
|
},
|
|
45
46
|
"repository": {
|
|
46
47
|
"type": "git",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"fs-extra": "^11.4.0",
|
|
72
73
|
"global-dirs": "^4.0.0",
|
|
73
74
|
"gradle-to-js": "^2.0.1",
|
|
75
|
+
"https-proxy-agent": "^7.0.6",
|
|
74
76
|
"i18next": "^26.4.0",
|
|
75
77
|
"node-fetch": "^2.6.1",
|
|
76
78
|
"plist": "^5.0.0",
|
|
@@ -81,6 +83,7 @@
|
|
|
81
83
|
"registry-auth-token": "^5.1.1",
|
|
82
84
|
"source-map": "0.6.1",
|
|
83
85
|
"tty-table": "5.0",
|
|
86
|
+
"undici": "^6.28.0",
|
|
84
87
|
"yauzl": "^3.4.0",
|
|
85
88
|
"yazl": "3.3.1"
|
|
86
89
|
},
|
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);
|