react-native-update-cli 2.18.0 → 2.19.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 (52) hide show
  1. package/lib/api.d.ts +1 -1
  2. package/lib/api.js +140 -134
  3. package/lib/app.d.ts +2 -2
  4. package/lib/app.js +60 -107
  5. package/lib/bin.js +38 -35
  6. package/lib/bundle-pack.js +57 -77
  7. package/lib/bundle-runner.js +249 -312
  8. package/lib/bundle.js +71 -89
  9. package/lib/diff.js +188 -235
  10. package/lib/exports.js +14 -37
  11. package/lib/index.js +16 -17
  12. package/lib/install.js +24 -37
  13. package/lib/locales/en.js +3 -11
  14. package/lib/locales/zh.js +3 -11
  15. package/lib/package.js +164 -218
  16. package/lib/provider.js +85 -107
  17. package/lib/types.js +1 -3
  18. package/lib/user.d.ts +1 -1
  19. package/lib/user.js +26 -39
  20. package/lib/utils/add-gitignore.js +16 -29
  21. package/lib/utils/app-info-parser/aab.js +133 -157
  22. package/lib/utils/app-info-parser/apk.js +42 -39
  23. package/lib/utils/app-info-parser/app.js +5 -11
  24. package/lib/utils/app-info-parser/index.js +21 -31
  25. package/lib/utils/app-info-parser/ipa.js +35 -35
  26. package/lib/utils/app-info-parser/resource-finder.js +84 -71
  27. package/lib/utils/app-info-parser/utils.js +52 -77
  28. package/lib/utils/app-info-parser/xml-parser/binary.js +82 -90
  29. package/lib/utils/app-info-parser/xml-parser/manifest.js +88 -98
  30. package/lib/utils/app-info-parser/zip.js +43 -51
  31. package/lib/utils/check-lockfile.js +28 -37
  32. package/lib/utils/check-plugin.js +16 -32
  33. package/lib/utils/command-result.js +7 -20
  34. package/lib/utils/constants.js +23 -63
  35. package/lib/utils/dep-versions.js +21 -27
  36. package/lib/utils/git.js +20 -64
  37. package/lib/utils/hbcTransform.js +133 -246
  38. package/lib/utils/http-helper.js +33 -44
  39. package/lib/utils/i18n.js +17 -26
  40. package/lib/utils/index.js +137 -179
  41. package/lib/utils/latest-version/index.js +128 -137
  42. package/lib/utils/options.js +13 -34
  43. package/lib/utils/plugin-config.js +43 -56
  44. package/lib/utils/runtime.js +50 -108
  45. package/lib/utils/zip-entries.js +70 -97
  46. package/lib/utils/zip-options.js +80 -181
  47. package/lib/versions.js +231 -265
  48. package/package.json +19 -21
  49. package/src/api.ts +44 -3
  50. package/src/package.ts +1 -1
  51. package/src/user.ts +1 -1
  52. package/src/versions.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.18.0",
3
+ "version": "2.19.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",
@@ -32,7 +32,7 @@
32
32
  "cli.json"
33
33
  ],
34
34
  "scripts": {
35
- "build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js lib/bin-cresc.js",
35
+ "build": "rm -rf lib && tsc -p tsconfig.build.json && chmod +x lib/bin.js lib/bin-cresc.js",
36
36
  "prepublishOnly": "bun run build",
37
37
  "typecheck": "tsc --noEmit",
38
38
  "typecheck:build": "tsc -p tsconfig.build.json",
@@ -62,25 +62,25 @@
62
62
  "bplist-parser": "^0.3.2",
63
63
  "bytebuffer": "^5.0.1",
64
64
  "cgbi-to-png": "^1.0.7",
65
- "chalk": "4",
65
+ "chalk": "5",
66
66
  "cli-arguments": "^0.2.1",
67
67
  "compare-versions": "^6.1.1",
68
68
  "filesize-parser": "^1.5.1",
69
- "form-data": "^4.0.5",
70
- "fs-extra": "^11.3.5",
69
+ "form-data": "^4.0.6",
70
+ "fs-extra": "^11.3.6",
71
71
  "global-dirs": "^4.0.0",
72
72
  "gradle-to-js": "^2.0.1",
73
- "i18next": "^26.0.4",
73
+ "i18next": "^26.3.5",
74
74
  "node-fetch": "^2.6.1",
75
- "plist": "^3.1.0",
75
+ "plist": "^5.0.0",
76
76
  "progress": "^2.0.3",
77
77
  "properties": "^1.2.1",
78
- "protobufjs": "^7.5.4",
78
+ "protobufjs": "^8.7.0",
79
79
  "read": "^4.1.0",
80
80
  "registry-auth-token": "^5.1.1",
81
- "semver": "^7.7.4",
81
+ "semver": "^7.8.5",
82
82
  "tty-table": "5.0",
83
- "yauzl": "^3.3.0",
83
+ "yauzl": "^3.4.0",
84
84
  "yazl": "3.3.1"
85
85
  },
86
86
  "overrides": {
@@ -90,23 +90,21 @@
90
90
  "node": ">= 18.17.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@biomejs/biome": "^2.4.12",
94
- "@swc/cli": "^0.8.1",
95
- "@swc/core": "^1.15.41",
96
- "@types/bun": "^1.3.12",
93
+ "@babel/parser": "^8.0.0",
94
+ "@biomejs/biome": "^2.5.3",
95
+ "@types/bun": "^1.3.14",
97
96
  "@types/filesize-parser": "^1.5.3",
98
97
  "@types/fs-extra": "^11.0.4",
99
- "@types/node": "^25.6.0",
98
+ "@types/node": "^26.1.1",
100
99
  "@types/node-fetch": "^2.6.13",
101
100
  "@types/progress": "^2.0.7",
102
101
  "@types/semver": "^7.7.1",
103
- "@types/yauzl": "^2.10.3",
104
- "@types/yazl": "^2.4.6",
105
- "node-hdiffpatch": "^2.0.3",
106
- "typescript": "^6.0.2"
102
+ "@types/yauzl": "^3.4.0",
103
+ "@types/yazl": "^3.3.1",
104
+ "node-hdiffpatch": "^2.2.1",
105
+ "typescript": "^7.0.2"
107
106
  },
108
107
  "trustedDependencies": [
109
- "@biomejs/biome",
110
- "@swc/core"
108
+ "@biomejs/biome"
111
109
  ]
112
110
  }
package/src/api.ts CHANGED
@@ -4,10 +4,10 @@ import fs from 'fs';
4
4
  import fetch from 'node-fetch';
5
5
  import path from 'path';
6
6
  import ProgressBar from 'progress';
7
- import { getBaseUrl } from 'utils/http-helper';
8
7
  import packageJson from '../package.json';
9
8
  import type { Package, Session } from './types';
10
9
  import { credentialFile, IS_CRESC, pricingPageUrl } from './utils/constants';
10
+ import { getBaseUrl } from './utils/http-helper';
11
11
  import { t } from './utils/i18n';
12
12
  import {
13
13
  measureTcpLatency,
@@ -202,10 +202,18 @@ export const post = queryWithBody('POST');
202
202
  export const put = queryWithBody('PUT');
203
203
  export const doDelete = queryWithBody('DELETE');
204
204
 
205
- export async function uploadFile(fn: string, key?: string) {
206
- const { url, backupUrl, formData, maxSize } = await post('/upload', {
205
+ export async function uploadFile(
206
+ fn: string,
207
+ key?: string,
208
+ appId?: string | number,
209
+ ) {
210
+ // appId 用于服务端路由:绑定了自托管节点(rnu-node)的应用,
211
+ // 上传指令会指向节点或其对象存储
212
+ const resp = await post('/upload', {
207
213
  ext: path.extname(fn),
214
+ ...(appId ? { appId: Number(appId) } : {}),
208
215
  });
216
+ const { url, backupUrl, formData, maxSize } = resp;
209
217
  let realUrl = url;
210
218
  if (backupUrl) {
211
219
  if (global.USE_ACC_OSS) {
@@ -240,6 +248,39 @@ export async function uploadFile(fn: string, key?: string) {
240
248
  total: fileSize,
241
249
  });
242
250
 
251
+ // 自托管节点的 s3 直传:服务端下发预签名 PUT,字节直达用户的对象存储
252
+ if (resp.method === 'PUT') {
253
+ const fileStream = fs.createReadStream(fn);
254
+ fileStream.on('data', (data) => {
255
+ bar.tick(data.length);
256
+ });
257
+ let putRes: fetch.Response;
258
+ try {
259
+ putRes = await fetch(realUrl, {
260
+ method: 'PUT',
261
+ body: fileStream,
262
+ // 预签名 PUT 不接受 chunked 传输,必须显式声明长度
263
+ headers: { 'content-length': String(fileSize), ...(resp.headers || {}) },
264
+ });
265
+ } catch (error) {
266
+ if (isProxyRelatedError(error)) {
267
+ const rawMessage =
268
+ error instanceof Error ? error.message : String(error);
269
+ throw new Error(
270
+ `${rawMessage}\n\n${t('proxyNetworkError')}\n${t('proxyNetworkErrorTips')}`,
271
+ );
272
+ }
273
+ throw createRequestError(error, realUrl);
274
+ }
275
+ if (putRes.status > 299) {
276
+ throw createRequestError(
277
+ `${putRes.status}: ${putRes.statusText || 'Upload failed'}`,
278
+ realUrl,
279
+ );
280
+ }
281
+ return { hash: resp.key };
282
+ }
283
+
243
284
  const form = new FormData();
244
285
 
245
286
  for (const [k, v] of Object.entries(formData)) {
package/src/package.ts CHANGED
@@ -141,7 +141,7 @@ async function uploadNativePackage(
141
141
  console.log(t('usingCustomVersion', { version: versionName }));
142
142
  }
143
143
 
144
- const { hash } = await uploadFile(filePath);
144
+ const { hash } = await uploadFile(filePath, undefined, appId);
145
145
  const normalizedBuildTime = config.normalizeBuildTime
146
146
  ? config.normalizeBuildTime(buildTime)
147
147
  : buildTime;
package/src/user.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto';
2
- import type { CommandContext } from 'types';
3
2
  import { closeSession, get, post, replaceSession, saveSession } from './api';
3
+ import type { CommandContext } from './types';
4
4
  import { question } from './utils';
5
5
  import { t } from './utils/i18n';
6
6
 
package/src/versions.ts CHANGED
@@ -475,7 +475,7 @@ export const versionCommands = {
475
475
  const nonInteractive =
476
476
  getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
477
477
 
478
- const { hash } = await uploadFile(fn);
478
+ const { hash } = await uploadFile(fn, undefined, appId);
479
479
 
480
480
  const versionName =
481
481
  name ||