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.
Files changed (98) hide show
  1. package/README.md +12 -5
  2. package/README.zh-CN.md +12 -5
  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 +45 -1
  9. package/lib/bundle-runner.js +303 -34
  10. package/lib/bundle.d.ts +1 -1
  11. package/lib/bundle.js +23 -7
  12. package/lib/commands.d.ts +6 -0
  13. package/lib/commands.js +65 -0
  14. package/lib/locales/en.d.ts +7 -14
  15. package/lib/locales/en.js +10 -17
  16. package/lib/locales/zh.d.ts +7 -13
  17. package/lib/locales/zh.js +10 -16
  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/hbcTransform.d.ts +15 -0
  29. package/lib/utils/hbcTransform.js +22 -0
  30. package/lib/utils/hermes-base.d.ts +61 -6
  31. package/lib/utils/hermes-base.js +328 -46
  32. package/lib/utils/hermes-literals.d.ts +51 -0
  33. package/lib/utils/hermes-literals.js +210 -0
  34. package/lib/utils/i18n.d.ts +5 -0
  35. package/lib/utils/i18n.js +14 -1
  36. package/lib/utils/index.d.ts +2 -1
  37. package/lib/utils/index.js +9 -4
  38. package/lib/utils/latest-version/index.js +8 -0
  39. package/lib/utils/runtime.d.ts +21 -0
  40. package/lib/utils/runtime.js +138 -5
  41. package/lib/utils/zip-range.js +3 -2
  42. package/lib/versions.js +14 -4
  43. package/package.json +6 -3
  44. package/lib/index.d.ts +0 -1
  45. package/lib/index.js +0 -17
  46. package/src/api.ts +0 -470
  47. package/src/app.ts +0 -241
  48. package/src/auto-update.ts +0 -647
  49. package/src/bin-cresc.ts +0 -8
  50. package/src/bin.ts +0 -115
  51. package/src/bundle-pack.ts +0 -61
  52. package/src/bundle-runner.ts +0 -1430
  53. package/src/bundle.ts +0 -371
  54. package/src/cache.ts +0 -20
  55. package/src/diff.ts +0 -1010
  56. package/src/exports.ts +0 -17
  57. package/src/index.ts +0 -1
  58. package/src/install.ts +0 -50
  59. package/src/locales/en.ts +0 -257
  60. package/src/locales/zh.ts +0 -234
  61. package/src/native-package.ts +0 -338
  62. package/src/package.ts +0 -482
  63. package/src/provider.ts +0 -294
  64. package/src/symbolicate.ts +0 -164
  65. package/src/types.ts +0 -150
  66. package/src/user.ts +0 -39
  67. package/src/utils/add-gitignore.ts +0 -35
  68. package/src/utils/app-info-parser/aab.ts +0 -241
  69. package/src/utils/app-info-parser/apk.ts +0 -92
  70. package/src/utils/app-info-parser/app.ts +0 -7
  71. package/src/utils/app-info-parser/index.ts +0 -54
  72. package/src/utils/app-info-parser/ipa.ts +0 -109
  73. package/src/utils/app-info-parser/resource-finder.ts +0 -508
  74. package/src/utils/app-info-parser/utils.ts +0 -161
  75. package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
  76. package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
  77. package/src/utils/app-info-parser/zip.ts +0 -108
  78. package/src/utils/check-lockfile.ts +0 -93
  79. package/src/utils/check-plugin.ts +0 -38
  80. package/src/utils/command-result.ts +0 -24
  81. package/src/utils/constants.ts +0 -25
  82. package/src/utils/dep-versions.ts +0 -83
  83. package/src/utils/git.ts +0 -71
  84. package/src/utils/hbcTransform.ts +0 -649
  85. package/src/utils/hermes-base.ts +0 -1137
  86. package/src/utils/http-helper.ts +0 -152
  87. package/src/utils/i18n.ts +0 -39
  88. package/src/utils/index.ts +0 -698
  89. package/src/utils/latest-version/index.ts +0 -573
  90. package/src/utils/options.ts +0 -78
  91. package/src/utils/plugin-config.ts +0 -32
  92. package/src/utils/runtime.ts +0 -187
  93. package/src/utils/slim-sourcemap.ts +0 -105
  94. package/src/utils/zip-entries.ts +0 -209
  95. package/src/utils/zip-options.ts +0 -178
  96. package/src/utils/zip-range.ts +0 -727
  97. package/src/utils/zip-raw-writer.ts +0 -247
  98. package/src/versions.ts +0 -892
@@ -1,247 +0,0 @@
1
- // A minimal zip writer that copies entries *as stored* — their compressed
2
- // bytes, CRC, sizes and timestamps straight from the source archive's central
3
- // directory — so repacking a subset of an apk / ipa / hap costs disk I/O, not
4
- // a second deflate of every asset (yazl can only add uncompressed data and
5
- // re-deflates it). Plain zip only: no zip64, no data descriptors, no extra
6
- // fields; callers must check `fitsRawZip` before choosing this writer.
7
- import fs from 'fs-extra';
8
- import type { Readable } from 'stream';
9
- import type { Entry } from 'yauzl';
10
-
11
- const LOCAL_HEADER_SIGNATURE = 0x04034b50;
12
- const CENTRAL_HEADER_SIGNATURE = 0x02014b50;
13
- const EOCD_SIGNATURE = 0x06054b50;
14
- const VERSION_NEEDED_DEFAULT = 20;
15
- /** "made by" for entries this writer creates itself: unix, spec 2.0 */
16
- const VERSION_MADE_BY_UNIX = (3 << 8) | 20;
17
- const FLAG_UTF8_NAMES = 0x800;
18
- const FLAG_DATA_DESCRIPTOR = 0x8;
19
- /** general-purpose bits carried over from a copied entry: encryption, deflate strength */
20
- const FLAG_KEEP_MASK = 0x0007;
21
- const MAX_UINT32 = 0xffffffff;
22
- const MAX_UINT16 = 0xffff;
23
- /** external attributes of a plain `-rw-r--r--` file */
24
- const UNIX_REGULAR_FILE_ATTRIBUTES = 0o100644 << 16;
25
-
26
- export interface RawZipEntry {
27
- fileName: string;
28
- compressionMethod: number;
29
- crc32: number;
30
- compressedSize: number;
31
- uncompressedSize: number;
32
- lastModFileTime: number;
33
- lastModFileDate: number;
34
- generalPurposeBitFlag?: number;
35
- versionMadeBy?: number;
36
- versionNeededToExtract?: number;
37
- internalFileAttributes?: number;
38
- externalFileAttributes?: number;
39
- }
40
-
41
- /**
42
- * Whether an archive of `sourceSize` bytes with `entryCount` entries can be
43
- * (partially) copied without zip64 structures: an output that only keeps a
44
- * subset of the entries is never larger than its source.
45
- */
46
- export function fitsRawZip(sourceSize: number, entryCount: number): boolean {
47
- return sourceSize < MAX_UINT32 && entryCount < MAX_UINT16;
48
- }
49
-
50
- let crcTable: Int32Array | undefined;
51
- function getCrcTable(): Int32Array {
52
- if (!crcTable) {
53
- crcTable = new Int32Array(256);
54
- for (let n = 0; n < 256; n++) {
55
- let c = n;
56
- for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
57
- crcTable[n] = c;
58
- }
59
- }
60
- return crcTable;
61
- }
62
-
63
- /** CRC-32 (IEEE) continued from `seed` (the running value, not inverted) */
64
- export function crc32Update(seed: number, chunk: Buffer): number {
65
- const table = getCrcTable();
66
- let crc = ~seed;
67
- for (let i = 0; i < chunk.length; i++) {
68
- crc = table[(crc ^ chunk[i]) & 0xff] ^ (crc >>> 8);
69
- }
70
- return ~crc >>> 0;
71
- }
72
-
73
- export class RawZipWriter {
74
- private readonly out: fs.WriteStream;
75
- private readonly central: Buffer[] = [];
76
- private offset = 0;
77
- private count = 0;
78
- private failure: Error | null = null;
79
- private readonly closed: Promise<void>;
80
-
81
- constructor(readonly output: string) {
82
- this.out = fs.createWriteStream(output);
83
- this.closed = new Promise<void>((resolve, reject) => {
84
- this.out.once('close', resolve);
85
- this.out.once('error', (error) => {
86
- this.failure = error;
87
- reject(error);
88
- });
89
- });
90
- // surfaced by the next write / end(), never as an unhandled rejection
91
- this.closed.catch(() => {});
92
- }
93
-
94
- /** Copy one entry with its file data exactly as stored in the source. */
95
- async addRawEntry(meta: RawZipEntry, data: Readable): Promise<void> {
96
- if (
97
- meta.compressedSize > MAX_UINT32 ||
98
- meta.uncompressedSize > MAX_UINT32 ||
99
- this.offset > MAX_UINT32 ||
100
- this.count >= MAX_UINT16
101
- ) {
102
- throw new Error(`zip64 required for ${meta.fileName}`);
103
- }
104
- const name = Buffer.from(meta.fileName, 'utf8');
105
- if (name.length > MAX_UINT16) {
106
- throw new Error(`file name too long: ${meta.fileName}`);
107
- }
108
- const flags =
109
- ((meta.generalPurposeBitFlag ?? 0) &
110
- FLAG_KEEP_MASK &
111
- ~FLAG_DATA_DESCRIPTOR) |
112
- FLAG_UTF8_NAMES;
113
- const versionNeeded = Math.max(
114
- VERSION_NEEDED_DEFAULT,
115
- meta.versionNeededToExtract ?? 0,
116
- );
117
- const localOffset = this.offset;
118
-
119
- const local = Buffer.alloc(30 + name.length);
120
- local.writeUInt32LE(LOCAL_HEADER_SIGNATURE, 0);
121
- local.writeUInt16LE(versionNeeded, 4);
122
- local.writeUInt16LE(flags, 6);
123
- local.writeUInt16LE(meta.compressionMethod, 8);
124
- local.writeUInt16LE(meta.lastModFileTime, 10);
125
- local.writeUInt16LE(meta.lastModFileDate, 12);
126
- local.writeUInt32LE(meta.crc32 >>> 0, 14);
127
- local.writeUInt32LE(meta.compressedSize, 18);
128
- local.writeUInt32LE(meta.uncompressedSize, 22);
129
- local.writeUInt16LE(name.length, 26);
130
- local.writeUInt16LE(0, 28);
131
- name.copy(local, 30);
132
- await this.write(local);
133
-
134
- let copied = 0;
135
- for await (const chunk of data as AsyncIterable<Buffer>) {
136
- copied += chunk.length;
137
- await this.write(chunk);
138
- }
139
- if (copied !== meta.compressedSize) {
140
- throw new Error(
141
- `${meta.fileName}: read ${copied} bytes, expected ${meta.compressedSize}`,
142
- );
143
- }
144
-
145
- const header = Buffer.alloc(46 + name.length);
146
- header.writeUInt32LE(CENTRAL_HEADER_SIGNATURE, 0);
147
- header.writeUInt16LE(meta.versionMadeBy ?? VERSION_MADE_BY_UNIX, 4);
148
- header.writeUInt16LE(versionNeeded, 6);
149
- header.writeUInt16LE(flags, 8);
150
- header.writeUInt16LE(meta.compressionMethod, 10);
151
- header.writeUInt16LE(meta.lastModFileTime, 12);
152
- header.writeUInt16LE(meta.lastModFileDate, 14);
153
- header.writeUInt32LE(meta.crc32 >>> 0, 16);
154
- header.writeUInt32LE(meta.compressedSize, 20);
155
- header.writeUInt32LE(meta.uncompressedSize, 24);
156
- header.writeUInt16LE(name.length, 28);
157
- header.writeUInt16LE(0, 30); // extra
158
- header.writeUInt16LE(0, 32); // comment
159
- header.writeUInt16LE(0, 34); // disk number start
160
- header.writeUInt16LE(meta.internalFileAttributes ?? 0, 36);
161
- header.writeUInt32LE(
162
- (meta.externalFileAttributes ?? UNIX_REGULAR_FILE_ATTRIBUTES) >>> 0,
163
- 38,
164
- );
165
- header.writeUInt32LE(localOffset, 42);
166
- name.copy(header, 46);
167
- this.central.push(header);
168
- this.count += 1;
169
- }
170
-
171
- /**
172
- * Add a local file uncompressed (its CRC is computed in a first pass).
173
- * `like` lends its timestamp and attributes, e.g. the archive entry this
174
- * file replaces.
175
- */
176
- async addStoredFile(
177
- filePath: string,
178
- fileName: string,
179
- like?: Pick<
180
- Entry,
181
- | 'lastModFileTime'
182
- | 'lastModFileDate'
183
- | 'externalFileAttributes'
184
- | 'versionMadeBy'
185
- >,
186
- ): Promise<void> {
187
- let crc = 0;
188
- let size = 0;
189
- for await (const chunk of fs.createReadStream(
190
- filePath,
191
- ) as AsyncIterable<Buffer>) {
192
- crc = crc32Update(crc, chunk);
193
- size += chunk.length;
194
- }
195
- await this.addRawEntry(
196
- {
197
- fileName,
198
- compressionMethod: 0,
199
- crc32: crc,
200
- compressedSize: size,
201
- uncompressedSize: size,
202
- lastModFileTime: like?.lastModFileTime ?? 0,
203
- lastModFileDate: like?.lastModFileDate ?? 0x21, // 1980-01-01
204
- externalFileAttributes: like?.externalFileAttributes,
205
- versionMadeBy: like?.versionMadeBy,
206
- },
207
- fs.createReadStream(filePath),
208
- );
209
- }
210
-
211
- /** Write the central directory and close the file. */
212
- async end(): Promise<void> {
213
- const cdOffset = this.offset;
214
- for (const header of this.central) await this.write(header);
215
- const cdSize = this.offset - cdOffset;
216
- if (cdOffset > MAX_UINT32 || cdSize > MAX_UINT32) {
217
- throw new Error('zip64 required for the central directory');
218
- }
219
- const eocd = Buffer.alloc(22);
220
- eocd.writeUInt32LE(EOCD_SIGNATURE, 0);
221
- eocd.writeUInt16LE(0, 4);
222
- eocd.writeUInt16LE(0, 6);
223
- eocd.writeUInt16LE(this.count, 8);
224
- eocd.writeUInt16LE(this.count, 10);
225
- eocd.writeUInt32LE(cdSize, 12);
226
- eocd.writeUInt32LE(cdOffset, 16);
227
- eocd.writeUInt16LE(0, 20);
228
- await this.write(eocd);
229
- this.out.end();
230
- await this.closed;
231
- }
232
-
233
- /** Stop writing and remove the partial output. */
234
- async abort(): Promise<void> {
235
- this.out.destroy();
236
- await this.closed.catch(() => {});
237
- await fs.remove(this.output).catch(() => {});
238
- }
239
-
240
- private write(chunk: Buffer): Promise<void> {
241
- if (this.failure) return Promise.reject(this.failure);
242
- this.offset += chunk.length;
243
- return new Promise((resolve, reject) => {
244
- this.out.write(chunk, (error) => (error ? reject(error) : resolve()));
245
- });
246
- }
247
- }