react-native-update-cli 2.28.3 → 2.29.1

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.
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // Streaming uploads on node:http(s): a multipart form or a raw PUT whose body
3
+ // is read from disk as it is sent, with an exact Content-Length.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.fileContentType = fileContentType;
9
+ exports.multipartRequest = multipartRequest;
10
+ exports.sendUploadRequest = sendUploadRequest;
11
+ const crypto_1 = require("crypto");
12
+ const path_1 = __importDefault(require("path"));
13
+ const stream_1 = require("stream");
14
+ /**
15
+ * The file part's Content-Type for the extensions the CLI uploads, as the
16
+ * form-data package used to pick them (mime-types): object stores keep it as
17
+ * the stored object's type.
18
+ */
19
+ const FILE_CONTENT_TYPES = {
20
+ '.aab': 'application/x-authorware-bin',
21
+ '.apk': 'application/vnd.android.package-archive',
22
+ '.json': 'application/json',
23
+ '.map': 'application/json',
24
+ '.zip': 'application/zip',
25
+ };
26
+ function fileContentType(fileName) {
27
+ return (FILE_CONTENT_TYPES[path_1.default.extname(fileName).toLowerCase()] ??
28
+ 'application/octet-stream');
29
+ }
30
+ /**
31
+ * multipart/form-data with `fields` first and the file last. The file's size
32
+ * is known up front, so the request carries Content-Length instead of a
33
+ * chunked body: what object stores expect, and the only framing that survives
34
+ * a proxy agent's rewrite of the buffered request head.
35
+ */
36
+ function multipartRequest(fields, file) {
37
+ // A 'data' listener (the progress bar) may have set the stream flowing:
38
+ // hold its chunks until the body below reads them.
39
+ file.stream.pause();
40
+ const boundary = `--------------------------${(0, crypto_1.randomBytes)(12).toString('hex')}`;
41
+ let head = '';
42
+ for (const [name, value] of Object.entries(fields)) {
43
+ head += `--${boundary}\r\nContent-Disposition: form-data; name="${name}"\r\n\r\n${value}\r\n`;
44
+ }
45
+ head +=
46
+ `--${boundary}\r\n` +
47
+ `Content-Disposition: form-data; name="file"; filename="${path_1.default.basename(file.name)}"\r\n` +
48
+ `Content-Type: ${fileContentType(file.name)}\r\n\r\n`;
49
+ const headBytes = Buffer.from(head);
50
+ const tailBytes = Buffer.from(`\r\n--${boundary}--\r\n`);
51
+ async function* parts() {
52
+ yield headBytes;
53
+ let sent = 0;
54
+ for await (const chunk of file.stream) {
55
+ sent += chunk.length;
56
+ yield chunk;
57
+ }
58
+ // a file that shrank since its size was taken would leave the request
59
+ // short of its Content-Length, waiting out the whole upload deadline
60
+ if (sent !== file.size) {
61
+ throw new Error(`${file.name} changed during the upload: sent ${sent} of ${file.size} bytes`);
62
+ }
63
+ yield tailBytes;
64
+ }
65
+ return {
66
+ method: 'POST',
67
+ headers: {
68
+ 'content-type': `multipart/form-data;boundary=${boundary}`,
69
+ 'content-length': String(headBytes.length + file.size + tailBytes.length),
70
+ },
71
+ body: stream_1.Readable.from(parts(), { objectMode: false }),
72
+ };
73
+ }
74
+ /**
75
+ * Send `request` and resolve with the response status once its head arrives
76
+ * (the body is drained and dropped). Network errors reject as they are, with
77
+ * their `code` (ECONNRESET, ...); aborting `signal` rejects with an AbortError.
78
+ */
79
+ function sendUploadRequest(url, request, options) {
80
+ const { request: send } = url.startsWith('https:')
81
+ ? require('https')
82
+ : require('http');
83
+ return new Promise((resolve, reject) => {
84
+ const req = send(url, {
85
+ method: request.method,
86
+ headers: {
87
+ accept: '*/*',
88
+ ...(options.userAgent ? { 'user-agent': options.userAgent } : {}),
89
+ ...request.headers,
90
+ },
91
+ agent: options.agent,
92
+ });
93
+ const fail = (error) => {
94
+ request.body.destroy();
95
+ req.destroy(error);
96
+ reject(error);
97
+ };
98
+ const { signal } = options;
99
+ const onAbort = () => {
100
+ fail(Object.assign(new Error('The upload was aborted'), {
101
+ name: 'AbortError',
102
+ code: 'ABORT_ERR',
103
+ }));
104
+ };
105
+ if (signal?.aborted)
106
+ return onAbort();
107
+ signal?.addEventListener('abort', onAbort, { once: true });
108
+ req.on('error', fail);
109
+ request.body.on('error', fail);
110
+ req.on('response', (res) => {
111
+ signal?.removeEventListener('abort', onAbort);
112
+ res.resume();
113
+ resolve({
114
+ status: res.statusCode ?? 0,
115
+ statusText: res.statusMessage ?? '',
116
+ });
117
+ });
118
+ request.body.pipe(req);
119
+ });
120
+ }
@@ -1,37 +1,4 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -40,11 +7,12 @@ exports.readEntry = readEntry;
40
7
  exports.writeEntry = writeEntry;
41
8
  exports.readEntryPrefix = readEntryPrefix;
42
9
  exports.enumZipEntries = enumZipEntries;
43
- const fs = __importStar(require("fs-extra"));
10
+ const fs_1 = __importDefault(require("fs"));
44
11
  const os_1 = __importDefault(require("os"));
45
12
  const path_1 = __importDefault(require("path"));
46
13
  const promises_1 = require("stream/promises");
47
14
  const yauzl_1 = require("yauzl");
15
+ const fs_helpers_1 = require("./fs-helpers");
48
16
  function readEntry(entry, zipFile) {
49
17
  const buffers = [];
50
18
  return new Promise((resolve, reject) => {
@@ -69,7 +37,7 @@ function readEntry(entry, zipFile) {
69
37
  });
70
38
  }
71
39
  function writeEntry(entry, zipFile, outputPath) {
72
- fs.ensureDirSync(path_1.default.dirname(outputPath));
40
+ (0, fs_helpers_1.ensureDirSync)(path_1.default.dirname(outputPath));
73
41
  return new Promise((resolve, reject) => {
74
42
  zipFile.openReadStream(entry, (err, stream) => {
75
43
  if (err) {
@@ -80,7 +48,7 @@ function writeEntry(entry, zipFile, outputPath) {
80
48
  reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
81
49
  return;
82
50
  }
83
- (0, promises_1.pipeline)(stream, fs.createWriteStream(outputPath)).then(resolve, reject);
51
+ (0, promises_1.pipeline)(stream, fs_1.default.createWriteStream(outputPath)).then(resolve, reject);
84
52
  });
85
53
  });
86
54
  }
@@ -166,14 +134,14 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
166
134
  try {
167
135
  if (!entry.fileName.endsWith('/') &&
168
136
  entry.fileName.toLowerCase().endsWith('.hap')) {
169
- const tempDir = await fs.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'nested_zip_'));
137
+ const tempDir = await fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'nested_zip_'));
170
138
  const tempZipPath = path_1.default.join(tempDir, 'temp.zip');
171
139
  try {
172
140
  await new Promise((res, rej) => {
173
141
  zipfile.openReadStream(entry, async (err, readStream) => {
174
142
  if (err)
175
143
  return rej(err);
176
- const writeStream = fs.createWriteStream(tempZipPath);
144
+ const writeStream = fs_1.default.createWriteStream(tempZipPath);
177
145
  readStream.on('error', rej);
178
146
  readStream.pipe(writeStream);
179
147
  writeStream.on('finish', () => res(void 0));
@@ -183,7 +151,7 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
183
151
  await enumZipEntries(tempZipPath, callback, `${fullPath}/`);
184
152
  }
185
153
  finally {
186
- await fs.remove(tempDir);
154
+ await (0, fs_helpers_1.remove)(tempDir);
187
155
  }
188
156
  }
189
157
  const result = callback(entry, zipfile, fullPath);
@@ -23,7 +23,7 @@ exports.readRemoteZipEntry = readRemoteZipEntry;
23
23
  // `openRemoteZip` read just the bundle of a remote archive through HTTP Range
24
24
  // requests instead of downloading the whole ppk / apk / ipa. Every helper
25
25
  // throws on anything unexpected; callers fall back to a full download.
26
- const fs_extra_1 = __importDefault(require("fs-extra"));
26
+ const fs_1 = __importDefault(require("fs"));
27
27
  const stream_1 = require("stream");
28
28
  const yauzl_1 = require("yauzl");
29
29
  const zlib_1 = require("zlib");
@@ -75,15 +75,15 @@ async function readZipEntryWithLocation(zipPath, matches) {
75
75
  }
76
76
  async function locationOfEntry(zipPath, entry) {
77
77
  const header = Buffer.alloc(LOCAL_HEADER_SIZE);
78
- const fd = await fs_extra_1.default.open(zipPath, 'r');
78
+ const handle = await fs_1.default.promises.open(zipPath, 'r');
79
79
  try {
80
- const { bytesRead } = await fs_extra_1.default.read(fd, header, 0, LOCAL_HEADER_SIZE, entry.relativeOffsetOfLocalHeader);
80
+ const { bytesRead } = await handle.read(header, 0, LOCAL_HEADER_SIZE, entry.relativeOffsetOfLocalHeader);
81
81
  if (bytesRead !== LOCAL_HEADER_SIZE) {
82
82
  throw new Error('truncated local file header');
83
83
  }
84
84
  }
85
85
  finally {
86
- await fs_extra_1.default.close(fd);
86
+ await handle.close();
87
87
  }
88
88
  if (header.readUInt32LE(0) !== LOCAL_HEADER_SIGNATURE) {
89
89
  throw new Error('invalid local file header signature');
@@ -12,7 +12,8 @@ exports.crc32Update = crc32Update;
12
12
  // a second deflate of every asset (yazl can only add uncompressed data and
13
13
  // re-deflates it). Plain zip only: no zip64, no data descriptors, no extra
14
14
  // fields; callers must check `fitsRawZip` before choosing this writer.
15
- const fs_extra_1 = __importDefault(require("fs-extra"));
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const fs_helpers_1 = require("./fs-helpers");
16
17
  const LOCAL_HEADER_SIGNATURE = 0x04034b50;
17
18
  const CENTRAL_HEADER_SIGNATURE = 0x02014b50;
18
19
  const EOCD_SIGNATURE = 0x06054b50;
@@ -67,7 +68,7 @@ class RawZipWriter {
67
68
  closed;
68
69
  constructor(output) {
69
70
  this.output = output;
70
- this.out = fs_extra_1.default.createWriteStream(output);
71
+ this.out = fs_1.default.createWriteStream(output);
71
72
  this.closed = new Promise((resolve, reject) => {
72
73
  this.out.once('close', resolve);
73
74
  this.out.once('error', (error) => {
@@ -148,7 +149,7 @@ class RawZipWriter {
148
149
  async addStoredFile(filePath, fileName, like) {
149
150
  let crc = 0;
150
151
  let size = 0;
151
- for await (const chunk of fs_extra_1.default.createReadStream(filePath)) {
152
+ for await (const chunk of fs_1.default.createReadStream(filePath)) {
152
153
  crc = crc32Update(crc, chunk);
153
154
  size += chunk.length;
154
155
  }
@@ -162,7 +163,7 @@ class RawZipWriter {
162
163
  lastModFileDate: like?.lastModFileDate ?? 0x21, // 1980-01-01
163
164
  externalFileAttributes: like?.externalFileAttributes,
164
165
  versionMadeBy: like?.versionMadeBy,
165
- }, fs_extra_1.default.createReadStream(filePath));
166
+ }, fs_1.default.createReadStream(filePath));
166
167
  }
167
168
  /** Write the central directory and close the file. */
168
169
  async end() {
@@ -190,7 +191,7 @@ class RawZipWriter {
190
191
  async abort() {
191
192
  this.out.destroy();
192
193
  await this.closed.catch(() => { });
193
- await fs_extra_1.default.remove(this.output).catch(() => { });
194
+ await (0, fs_helpers_1.remove)(this.output).catch(() => { });
194
195
  }
195
196
  write(chunk) {
196
197
  if (this.failure)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.28.3",
3
+ "version": "2.29.1",
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",
@@ -62,19 +62,15 @@
62
62
  "homepage": "https://github.com/reactnativecn/react-native-update-cli",
63
63
  "dependencies": {
64
64
  "bplist-parser": "^0.3.2",
65
- "bytebuffer": "^5.0.1",
66
65
  "cgbi-to-png": "^1.0.7",
67
66
  "chalk": "4",
68
67
  "cli-arguments": "^0.2.1",
69
68
  "compare-versions": "^6.1.1",
70
69
  "filesize-parser": "^1.5.2",
71
- "form-data": "^4.0.6",
72
- "fs-extra": "^11.4.0",
73
70
  "global-dirs": "^4.0.0",
74
71
  "gradle-to-js": "^2.0.1",
75
72
  "https-proxy-agent": "^7.0.6",
76
73
  "i18next": "^26.4.0",
77
- "node-fetch": "^2.6.1",
78
74
  "plist": "^5.0.0",
79
75
  "progress": "^2.0.3",
80
76
  "properties": "^1.2.1",
@@ -98,9 +94,7 @@
98
94
  "@biomejs/biome": "^2.5.10",
99
95
  "@types/bun": "^1.4.0",
100
96
  "@types/filesize-parser": "^1.5.3",
101
- "@types/fs-extra": "^11.0.4",
102
97
  "@types/node": "^26.3.0",
103
- "@types/node-fetch": "^2.6.13",
104
98
  "@types/progress": "^2.0.7",
105
99
  "@types/yauzl": "^3.4.0",
106
100
  "@types/yazl": "^3.3.1",