react-native-update-cli 2.29.2 → 2.29.4

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.
@@ -16,6 +16,6 @@ export interface SlimPackageOptions {
16
16
  }
17
17
  /**
18
18
  * Repack a native package with only the bundle and resources required by
19
- * package-origin diffs. Entry names and nested Harmony HAP structure are kept.
19
+ * package-origin diffs, plus the server-only entries. Entry names and nested Harmony HAP structure are kept.
20
20
  */
21
21
  export declare function createSlimNativePackage(source: string, output: string, platform: Platform, options?: SlimPackageOptions): Promise<void>;
@@ -8,7 +8,10 @@ exports.createSlimNativePackage = createSlimNativePackage;
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const path_1 = __importDefault(require("path"));
11
+ const stream_1 = require("stream");
12
+ const util_1 = require("util");
11
13
  const yauzl_1 = require("yauzl");
14
+ const zlib_1 = __importDefault(require("zlib"));
12
15
  const fs_helpers_1 = require("./utils/fs-helpers");
13
16
  const zip_entries_1 = require("./utils/zip-entries");
14
17
  const zip_raw_writer_1 = require("./utils/zip-raw-writer");
@@ -55,6 +58,15 @@ const nativePackageRules = {
55
58
  function resolveNativePackageEntry(platform, entryName) {
56
59
  return nativePackageRules[platform].resolveEntry(entryName);
57
60
  }
61
+ /**
62
+ * Entries kept for the server only: it maps resource names to their (shortened)
63
+ * paths through resources.arsc when building a package diff. They are never a
64
+ * diff origin, so they stay out of resolveNativePackageEntry.
65
+ */
66
+ const serverOnlyEntries = {
67
+ android: 'resources.arsc',
68
+ };
69
+ const deflateRaw = (0, util_1.promisify)(zlib_1.default.deflateRaw);
58
70
  /**
59
71
  * Copies each entry's stored bytes, CRC and sizes verbatim (yauzl hands out
60
72
  * the raw file data with `decodeFileData: false`), so slimming a package is
@@ -71,6 +83,21 @@ class RawCopySink {
71
83
  });
72
84
  await this.writer.addRawEntry(entry, readStream);
73
85
  }
86
+ async copyEntryDeflated(sourceZip, entry) {
87
+ if (entry.compressionMethod !== 0) {
88
+ return this.copyEntry(sourceZip, entry);
89
+ }
90
+ const deflated = await deflateRaw(await (0, zip_entries_1.readEntry)(entry, sourceZip), {
91
+ level: zlib_1.default.constants.Z_BEST_COMPRESSION,
92
+ });
93
+ await this.writer.addRawEntry({
94
+ ...entry,
95
+ compressionMethod: 8,
96
+ compressedSize: deflated.length,
97
+ // deflate strength bits of a stored entry mean nothing
98
+ generalPurposeBitFlag: 0,
99
+ }, stream_1.Readable.from([deflated]));
100
+ }
74
101
  addFile(filePath, fileName, like) {
75
102
  // a nested slim archive is a zip of deflated entries: storing it as-is
76
103
  // loses nothing and skips another pass over its bytes
@@ -89,13 +116,19 @@ class RepackSink {
89
116
  constructor(output) {
90
117
  this.output = (0, zip_entries_1.createOutputZip)(output);
91
118
  }
92
- async copyEntry(sourceZip, entry) {
119
+ copyEntry(sourceZip, entry) {
120
+ return this.add(sourceZip, entry, entry.compressionMethod !== 0);
121
+ }
122
+ copyEntryDeflated(sourceZip, entry) {
123
+ return this.add(sourceZip, entry, true);
124
+ }
125
+ async add(sourceZip, entry, compress) {
93
126
  const readStream = await (0, zip_entries_1.openEntryStream)(entry, sourceZip);
94
127
  await new Promise((resolve, reject) => {
95
128
  readStream.once('error', reject);
96
129
  readStream.once('end', () => resolve());
97
130
  this.output.zipfile.addReadStream(readStream, entry.fileName, {
98
- compress: entry.compressionMethod !== 0,
131
+ compress,
99
132
  mtime: entry.getLastModDate(),
100
133
  });
101
134
  });
@@ -189,6 +222,10 @@ async function filterNativePackageArchive(source, output, platform, options) {
189
222
  includedBundles += 1;
190
223
  }
191
224
  }
225
+ else if (entry.fileName === serverOnlyEntries[platform]) {
226
+ await sink.copyEntryDeflated(sourceZip, entry);
227
+ includedEntries += 1;
228
+ }
192
229
  sourceZip.readEntry();
193
230
  }
194
231
  catch (error) {
@@ -210,7 +247,7 @@ async function filterNativePackageArchive(source, output, platform, options) {
210
247
  }
211
248
  /**
212
249
  * Repack a native package with only the bundle and resources required by
213
- * package-origin diffs. Entry names and nested Harmony HAP structure are kept.
250
+ * package-origin diffs, plus the server-only entries. Entry names and nested Harmony HAP structure are kept.
214
251
  */
215
252
  async function createSlimNativePackage(source, output, platform, options = {}) {
216
253
  const result = await filterNativePackageArchive(source, output, platform, options);
package/lib/package.js CHANGED
@@ -23,6 +23,11 @@ const hermes_base_1 = require("./utils/hermes-base");
23
23
  const i18n_1 = require("./utils/i18n");
24
24
  const options_1 = require("./utils/options");
25
25
  const zip_range_1 = require("./utils/zip-range");
26
+ // parse* output is JSON so the bundleHash (content fingerprint) can be piped
27
+ // into jq; the raw bundle bytes are dropped — a Buffer preview is just noise.
28
+ function printPackageInfo({ bundleFile: _bundleFile, ...info }) {
29
+ console.log(JSON.stringify(info, null, 2));
30
+ }
26
31
  // the AAB parser drags in protobufjs; load it only for the aab commands
27
32
  function loadExtractApk() {
28
33
  return require('./utils/app-info-parser/aab').extractApk;
@@ -270,28 +275,28 @@ exports.packageCommands = {
270
275
  if (!fn?.endsWith('.app')) {
271
276
  throw new Error((0, i18n_1.t)('usageParseApp'));
272
277
  }
273
- console.log(await (0, utils_1.getAppInfo)(fn));
278
+ printPackageInfo(await (0, utils_1.getAppInfo)(fn));
274
279
  },
275
280
  parseIpa: async ({ args }) => {
276
281
  const fn = args[0];
277
282
  if (!fn?.endsWith('.ipa')) {
278
283
  throw new Error((0, i18n_1.t)('usageParseIpa'));
279
284
  }
280
- console.log(await (0, utils_1.getIpaInfo)(fn));
285
+ printPackageInfo(await (0, utils_1.getIpaInfo)(fn));
281
286
  },
282
287
  parseApk: async ({ args }) => {
283
288
  const fn = args[0];
284
289
  if (!fn?.endsWith('.apk')) {
285
290
  throw new Error((0, i18n_1.t)('usageParseApk'));
286
291
  }
287
- console.log(await (0, utils_1.getApkInfo)(fn));
292
+ printPackageInfo(await (0, utils_1.getApkInfo)(fn));
288
293
  },
289
294
  parseAab: async ({ args }) => {
290
295
  const fn = args[0];
291
296
  if (!fn?.endsWith('.aab')) {
292
297
  throw new Error((0, i18n_1.t)('usageParseAab'));
293
298
  }
294
- console.log(await (0, utils_1.getAabInfo)(fn));
299
+ printPackageInfo(await (0, utils_1.getAabInfo)(fn));
295
300
  },
296
301
  extractApk: async ({ args, options, }) => {
297
302
  const source = ensureFileByExt(args[0], '.aab', 'usageExtractApk');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.29.2",
3
+ "version": "2.29.4",
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",
@@ -59,7 +59,7 @@
59
59
  "bugs": {
60
60
  "url": "https://github.com/reactnativecn/react-native-update-cli/issues"
61
61
  },
62
- "homepage": "https://github.com/reactnativecn/react-native-update-cli",
62
+ "homepage": "https://cresc.dev/docs/cli",
63
63
  "dependencies": {
64
64
  "bplist-parser": "^0.3.2",
65
65
  "chalk": "4",