react-native-update-cli 2.11.0 → 2.13.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 (51) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/cli.json +6 -0
  4. package/lib/api.js +10 -12
  5. package/lib/app.d.ts +1 -1
  6. package/lib/app.js +1 -1
  7. package/lib/bin.js +5 -2
  8. package/lib/bundle-runner.js +22 -12
  9. package/lib/install.js +3 -4
  10. package/lib/locales/en.d.ts +1 -0
  11. package/lib/locales/en.js +1 -0
  12. package/lib/locales/zh.d.ts +1 -0
  13. package/lib/locales/zh.js +1 -0
  14. package/lib/package.d.ts +3 -0
  15. package/lib/package.js +6 -2
  16. package/lib/provider.d.ts +2 -2
  17. package/lib/provider.js +23 -22
  18. package/lib/types.d.ts +17 -4
  19. package/lib/utils/app-info-parser/zip.d.ts +3 -3
  20. package/lib/utils/app-info-parser/zip.js +33 -19
  21. package/lib/utils/git.d.ts +2 -1
  22. package/lib/utils/git.js +82 -40
  23. package/lib/utils/http-helper.js +8 -8
  24. package/lib/utils/index.d.ts +1 -0
  25. package/lib/utils/index.js +9 -1
  26. package/lib/utils/runtime.d.ts +28 -0
  27. package/lib/utils/runtime.js +183 -0
  28. package/lib/utils/zip-entries.js +1 -2
  29. package/lib/versions.d.ts +6 -3
  30. package/lib/versions.js +80 -23
  31. package/package.json +1 -7
  32. package/src/api.ts +23 -15
  33. package/src/app.ts +1 -1
  34. package/src/bin.ts +9 -2
  35. package/src/bundle-runner.ts +91 -50
  36. package/src/install.ts +3 -1
  37. package/src/locales/en.ts +1 -0
  38. package/src/locales/zh.ts +1 -0
  39. package/src/package.ts +11 -2
  40. package/src/provider.ts +47 -40
  41. package/src/types.ts +18 -4
  42. package/src/utils/app-info-parser/zip.ts +41 -24
  43. package/src/utils/git.ts +52 -31
  44. package/src/utils/http-helper.ts +8 -3
  45. package/src/utils/index.ts +8 -1
  46. package/src/utils/runtime.ts +187 -0
  47. package/src/utils/zip-entries.ts +2 -4
  48. package/src/versions.ts +105 -32
  49. package/lib/utils/latest-version/cli.d.ts +0 -1
  50. package/lib/utils/latest-version/cli.js +0 -308
  51. package/src/utils/latest-version/cli.ts +0 -445
package/lib/versions.js CHANGED
@@ -12,6 +12,9 @@ _export(exports, {
12
12
  get bindVersionToPackages () {
13
13
  return bindVersionToPackages;
14
14
  },
15
+ get fetchVersions () {
16
+ return fetchVersions;
17
+ },
15
18
  get versionCommands () {
16
19
  return versionCommands;
17
20
  }
@@ -26,6 +29,7 @@ const _utils = require("./utils");
26
29
  const _depversions = require("./utils/dep-versions");
27
30
  const _git = require("./utils/git");
28
31
  const _i18n = require("./utils/i18n");
32
+ const _options = require("./utils/options");
29
33
  function _interop_require_default(obj) {
30
34
  return obj && obj.__esModule ? obj : {
31
35
  default: obj
@@ -207,8 +211,13 @@ async function printDepsChangesForPublish({ appId, versionId, pkgs, providedVers
207
211
  console.log(_chalk.default.yellow((0, _i18n.t)('depsChangeNonBlockingHint')));
208
212
  }
209
213
  }
214
+ const versionPageLimit = 10;
215
+ async function fetchVersions(appId, offset = 0, limit = versionPageLimit) {
216
+ const { data } = await (0, _api.get)(`/app/${appId}/version/list?offset=${offset}&limit=${limit}`);
217
+ return Array.isArray(data) ? data : [];
218
+ }
210
219
  async function showVersion(appId, offset) {
211
- const { data } = await (0, _api.get)(`/app/${appId}/version/list`);
220
+ const data = await fetchVersions(appId, offset, versionPageLimit);
212
221
  console.log((0, _i18n.t)('offset', {
213
222
  offset
214
223
  }));
@@ -220,7 +229,7 @@ async function showVersion(appId, offset) {
220
229
  packageInfo = 'no package';
221
230
  } else {
222
231
  var _version_packages1;
223
- packageInfo = (_version_packages1 = version.packages) == null ? void 0 : _version_packages1.slice(0, 3).map((pkg)=>pkg.name).join(', ');
232
+ packageInfo = ((_version_packages1 = version.packages) != null ? _version_packages1 : []).slice(0, 3).map((pkg)=>pkg.name).join(', ');
224
233
  if (pkgCount > 3) {
225
234
  packageInfo += `...and ${pkgCount - 3} more`;
226
235
  } else {
@@ -231,10 +240,13 @@ async function showVersion(appId, offset) {
231
240
  }
232
241
  return data;
233
242
  }
234
- async function listVersions(appId) {
243
+ async function listVersions(appId, interactive = true) {
235
244
  let offset = 0;
236
245
  while(true){
237
- await showVersion(appId, offset);
246
+ const data = await showVersion(appId, offset);
247
+ if (!interactive) {
248
+ return data;
249
+ }
238
250
  const cmd = await (0, _utils.question)('page Up/page Down/Begin/Quit(U/D/B/Q)');
239
251
  switch(cmd.toLowerCase()){
240
252
  case 'u':
@@ -247,7 +259,9 @@ async function listVersions(appId) {
247
259
  offset = 0;
248
260
  break;
249
261
  case 'q':
250
- return;
262
+ return data;
263
+ case '':
264
+ return data;
251
265
  }
252
266
  }
253
267
  }
@@ -255,6 +269,9 @@ async function chooseVersion(appId) {
255
269
  let offset = 0;
256
270
  while(true){
257
271
  const data = await showVersion(appId, offset);
272
+ if ((0, _utils.isNonInteractive)()) {
273
+ throw new Error((0, _i18n.t)('versionIdRequired'));
274
+ }
258
275
  const cmd = await (0, _utils.question)('Enter versionId or page Up/page Down/Begin(U/D/B)');
259
276
  switch(cmd.toUpperCase()){
260
277
  case 'U':
@@ -314,13 +331,14 @@ const versionCommands = {
314
331
  }
315
332
  const platform = await (0, _app.getPlatform)(options.platform);
316
333
  const { appId } = await (0, _app.getSelectedApp)(platform);
334
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
317
335
  const { hash } = await (0, _api.uploadFile)(fn);
318
- const versionName = name || await (0, _utils.question)((0, _i18n.t)('versionNameQuestion')) || (0, _i18n.t)('unnamed');
336
+ const versionName = name || (nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionNameQuestion'))) || (0, _i18n.t)('unnamed');
319
337
  const { id } = await (0, _api.post)(`/app/${appId}/version/create`, {
320
338
  name: versionName,
321
339
  hash,
322
- description: description || await (0, _utils.question)((0, _i18n.t)('versionDescriptionQuestion')),
323
- metaInfo: metaInfo || await (0, _utils.question)((0, _i18n.t)('versionMetaInfoQuestion')),
340
+ description: description != null ? description : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionDescriptionQuestion')),
341
+ metaInfo: metaInfo != null ? metaInfo : nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionMetaInfoQuestion')),
324
342
  deps: _depversions.depVersions,
325
343
  commit: await (0, _git.getCommitInfo)()
326
344
  });
@@ -344,7 +362,7 @@ const versionCommands = {
344
362
  warnDepsChanges: true
345
363
  }
346
364
  });
347
- } else {
365
+ } else if (!nonInteractive) {
348
366
  const q = await (0, _utils.question)((0, _i18n.t)('updateNativePackageQuestion'));
349
367
  if (q.toLowerCase() === 'y') {
350
368
  await versionCommands.update({
@@ -360,16 +378,33 @@ const versionCommands = {
360
378
  return versionName;
361
379
  },
362
380
  versions: async ({ options })=>{
363
- const platform = await (0, _app.getPlatform)(options.platform);
364
- const { appId } = await (0, _app.getSelectedApp)(platform);
365
- await listVersions(String(appId));
381
+ let appId = options.appId;
382
+ if (!appId) {
383
+ const platform = await (0, _app.getPlatform)(options.platform);
384
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
385
+ }
386
+ const interactive = !((0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)());
387
+ await listVersions(String(appId), interactive);
366
388
  },
367
389
  update: async ({ options })=>{
368
- const platform = await (0, _app.getPlatform)(options.platform);
369
- const appId = options.appId || (await (0, _app.getSelectedApp)(platform)).appId;
370
- let versionId = options.versionId || (await chooseVersion(String(appId))).id;
390
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
391
+ let appId = options.appId;
392
+ let platform = options.platform;
393
+ if (!appId) {
394
+ platform = await (0, _app.getPlatform)(platform);
395
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
396
+ } else if (platform) {
397
+ platform = await (0, _app.getPlatform)(platform);
398
+ }
399
+ let versionId = options.versionId;
400
+ if (!versionId) {
401
+ if (nonInteractive) {
402
+ throw new Error((0, _i18n.t)('versionIdRequired'));
403
+ }
404
+ versionId = (await chooseVersion(String(appId))).id;
405
+ }
371
406
  if (versionId === 'null') {
372
- versionId = undefined;
407
+ versionId = null;
373
408
  }
374
409
  let pkgId = options.packageId;
375
410
  let pkgVersion = options.packageVersion;
@@ -378,7 +413,7 @@ const versionCommands = {
378
413
  let packageVersionRange = options.packageVersionRange;
379
414
  let rollout;
380
415
  if (options.rollout !== undefined) {
381
- rollout = Number.parseInt(options.rollout, 10);
416
+ rollout = Number.parseInt(String(options.rollout), 10);
382
417
  if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
383
418
  throw new Error((0, _i18n.t)('rolloutRangeError'));
384
419
  }
@@ -392,7 +427,7 @@ const versionCommands = {
392
427
  let pkgsToBind = [];
393
428
  if (minPkgVersion) {
394
429
  minPkgVersion = String(minPkgVersion).trim();
395
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.satisfies)(pkg.name, `>=${minPkgVersion}`));
430
+ pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.compare)(pkg.name, minPkgVersion, '>='));
396
431
  if (pkgsToBind.length === 0) {
397
432
  throw new Error((0, _i18n.t)('nativeVersionNotFoundGte', {
398
433
  version: minPkgVersion
@@ -400,7 +435,9 @@ const versionCommands = {
400
435
  }
401
436
  } else if (maxPkgVersion) {
402
437
  maxPkgVersion = String(maxPkgVersion).trim();
403
- pkgsToBind = allPkgs.filter((pkg)=>(0, _compareversions.satisfies)(pkg.name, `<=${maxPkgVersion}`));
438
+ pkgsToBind = allPkgs.filter((pkg)=>{
439
+ return (0, _compareversions.compare)(pkg.name, maxPkgVersion, '<=');
440
+ });
404
441
  if (pkgsToBind.length === 0) {
405
442
  throw new Error((0, _i18n.t)('nativeVersionNotFoundLte', {
406
443
  version: maxPkgVersion
@@ -428,6 +465,9 @@ const versionCommands = {
428
465
  }
429
466
  } else {
430
467
  if (!pkgId) {
468
+ if (nonInteractive) {
469
+ throw new Error((0, _i18n.t)('packageIdRequired'));
470
+ }
431
471
  pkgId = (await (0, _package.choosePackage)(String(appId))).id;
432
472
  }
433
473
  if (!pkgId) {
@@ -444,7 +484,7 @@ const versionCommands = {
444
484
  }));
445
485
  }
446
486
  }
447
- if (options.warnDepsChanges) {
487
+ if (options.warnDepsChanges && versionId) {
448
488
  await printDepsChangesForPublish({
449
489
  appId: String(appId),
450
490
  versionId: String(versionId),
@@ -461,9 +501,22 @@ const versionCommands = {
461
501
  });
462
502
  },
463
503
  updateVersionInfo: async ({ options })=>{
464
- const platform = await (0, _app.getPlatform)(options.platform);
465
- const { appId } = await (0, _app.getSelectedApp)(platform);
466
- const versionId = options.versionId || (await chooseVersion(String(appId))).id;
504
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
505
+ let appId = options.appId;
506
+ let platform = options.platform;
507
+ if (!appId) {
508
+ platform = await (0, _app.getPlatform)(platform);
509
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
510
+ } else if (platform) {
511
+ await (0, _app.getPlatform)(platform);
512
+ }
513
+ let versionId = options.versionId;
514
+ if (!versionId) {
515
+ if (nonInteractive) {
516
+ throw new Error((0, _i18n.t)('versionIdRequired'));
517
+ }
518
+ versionId = (await chooseVersion(String(appId))).id;
519
+ }
467
520
  const updateParams = {};
468
521
  if (options.name) updateParams.name = options.name;
469
522
  if (options.description) updateParams.description = options.description;
@@ -472,6 +525,7 @@ const versionCommands = {
472
525
  console.log((0, _i18n.t)('operationSuccess'));
473
526
  },
474
527
  deleteVersion: async ({ options })=>{
528
+ const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
475
529
  let appId = options.appId;
476
530
  if (!appId) {
477
531
  const platform = await (0, _app.getPlatform)(options.platform);
@@ -479,6 +533,9 @@ const versionCommands = {
479
533
  }
480
534
  let versionId = options.versionId;
481
535
  if (!versionId) {
536
+ if (nonInteractive) {
537
+ throw new Error((0, _i18n.t)('versionIdRequired'));
538
+ }
482
539
  versionId = (await chooseVersion(String(appId))).id;
483
540
  }
484
541
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.11.0",
3
+ "version": "2.13.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",
@@ -59,13 +59,11 @@
59
59
  },
60
60
  "homepage": "https://github.com/reactnativecn/react-native-update-cli",
61
61
  "dependencies": {
62
- "@colors/colors": "^1.6.0",
63
62
  "bplist-parser": "^0.3.2",
64
63
  "bytebuffer": "^5.0.1",
65
64
  "cgbi-to-png": "^1.0.7",
66
65
  "chalk": "4",
67
66
  "cli-arguments": "^0.2.1",
68
- "commander": "^13",
69
67
  "compare-versions": "^6.1.1",
70
68
  "filesize-parser": "^1.5.1",
71
69
  "form-data": "^4.0.5",
@@ -73,8 +71,6 @@
73
71
  "global-dirs": "^4.0.0",
74
72
  "gradle-to-js": "^2.0.1",
75
73
  "i18next": "^26.0.4",
76
- "isomorphic-git": "^1.37.5",
77
- "isomorphic-unzip": "^1.1.5",
78
74
  "node-fetch": "^2.6.1",
79
75
  "plist": "^3.1.0",
80
76
  "progress": "^2.0.3",
@@ -83,7 +79,6 @@
83
79
  "read": "^4.1.0",
84
80
  "registry-auth-token": "^5.1.1",
85
81
  "semver": "^7.7.4",
86
- "tcp-ping": "^0.1.1",
87
82
  "tty-table": "5.0",
88
83
  "yauzl": "^3.3.0",
89
84
  "yazl": "3.3.1"
@@ -105,7 +100,6 @@
105
100
  "@types/node-fetch": "^2.6.13",
106
101
  "@types/progress": "^2.0.7",
107
102
  "@types/semver": "^7.7.1",
108
- "@types/tcp-ping": "^0.1.6",
109
103
  "@types/yauzl": "^2.10.3",
110
104
  "@types/yazl": "^2.4.6",
111
105
  "typescript": "^6.0.2"
package/src/api.ts CHANGED
@@ -4,15 +4,17 @@ 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 tcpp from 'tcp-ping';
8
- import util from 'util';
9
7
  import { getBaseUrl } from 'utils/http-helper';
10
8
  import packageJson from '../package.json';
11
9
  import type { Package, Session } from './types';
12
10
  import { credentialFile, IS_CRESC, pricingPageUrl } from './utils/constants';
13
11
  import { t } from './utils/i18n';
14
-
15
- const tcpPing = util.promisify(tcpp.ping);
12
+ import {
13
+ measureTcpLatency,
14
+ type RuntimeRequestInit,
15
+ type RuntimeResponse,
16
+ runtimeFetch,
17
+ } from './utils/runtime';
16
18
 
17
19
  let session: Session | undefined;
18
20
  let savedSession: Session | undefined;
@@ -75,22 +77,30 @@ export const closeSession = () => {
75
77
  session = undefined;
76
78
  };
77
79
 
78
- function createRequestError(error: unknown, requestUrl: string) {
80
+ function createRequestError(
81
+ error: unknown,
82
+ requestUrl: string,
83
+ status?: number,
84
+ ) {
79
85
  const message =
80
86
  typeof error === 'string'
81
87
  ? error
82
88
  : error instanceof Error
83
89
  ? error.message
84
90
  : String(error);
85
- return new Error(`${message}\nURL: ${requestUrl}`);
91
+ const requestError = new Error(`${message}\nURL: ${requestUrl}`) as Error & {
92
+ status?: number;
93
+ };
94
+ requestError.status = status;
95
+ return requestError;
86
96
  }
87
97
 
88
- async function query(url: string, options: fetch.RequestInit) {
98
+ async function query(url: string, options: RuntimeRequestInit) {
89
99
  const baseUrl = await getBaseUrl;
90
100
  const fullUrl = `${baseUrl}${url}`;
91
- let resp: fetch.Response;
101
+ let resp: RuntimeResponse;
92
102
  try {
93
- resp = await fetch(fullUrl, options);
103
+ resp = await runtimeFetch(fullUrl, options);
94
104
  } catch (error) {
95
105
  throw createRequestError(error, fullUrl);
96
106
  }
@@ -109,9 +119,9 @@ async function query(url: string, options: fetch.RequestInit) {
109
119
  if (resp.status !== 200) {
110
120
  const message = json?.message || resp.statusText || `HTTP ${resp.status}`;
111
121
  if (resp.status === 401) {
112
- throw createRequestError(t('loginExpired'), fullUrl);
122
+ throw createRequestError(t('loginExpired'), fullUrl, resp.status);
113
123
  }
114
- throw createRequestError(message, fullUrl);
124
+ throw createRequestError(message, fullUrl, resp.status);
115
125
  }
116
126
  return json;
117
127
  }
@@ -166,13 +176,11 @@ export async function uploadFile(fn: string, key?: string) {
166
176
  if (global.USE_ACC_OSS) {
167
177
  realUrl = backupUrl;
168
178
  } else {
169
- const pingResult = await tcpPing({
170
- address: url.replace('https://', ''),
179
+ const latency = await measureTcpLatency(url, {
171
180
  attempts: 4,
172
181
  timeout: 1000,
173
182
  });
174
- // console.log({pingResult});
175
- if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
183
+ if (!Number.isFinite(latency) || latency > 150) {
176
184
  realUrl = backupUrl;
177
185
  }
178
186
  }
package/src/app.ts CHANGED
@@ -153,7 +153,7 @@ export function getAppCommands() {
153
153
  },
154
154
  apps: async ({ options }: { options: { platform?: Platform | '' } }) => {
155
155
  const { platform = '' } = options;
156
- await listApp(platform);
156
+ return listApp(platform);
157
157
  },
158
158
  selectApp,
159
159
  };
package/src/bin.ts CHANGED
@@ -19,6 +19,10 @@ interface CliArgv {
19
19
  options: Record<string, any>;
20
20
  }
21
21
 
22
+ function isTruthyEnv(value: string | undefined): boolean {
23
+ return value === '1' || value?.toLowerCase() === 'true';
24
+ }
25
+
22
26
  function printUsage(exitCode = 1) {
23
27
  console.log('React Native Update CLI');
24
28
  console.log('');
@@ -57,8 +61,11 @@ async function run() {
57
61
  }
58
62
 
59
63
  const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
60
- global.NO_INTERACTIVE = argv.options['no-interactive'];
61
- global.USE_ACC_OSS = argv.options.acc;
64
+ global.NO_INTERACTIVE =
65
+ Boolean(argv.options['no-interactive']) ||
66
+ isTruthyEnv(process.env.NO_INTERACTIVE);
67
+ global.USE_ACC_OSS =
68
+ Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
62
69
 
63
70
  try {
64
71
  await loadSession();
@@ -1,9 +1,14 @@
1
- import { spawn, spawnSync } from 'child_process';
1
+ import { spawnSync } from 'child_process';
2
2
  import { satisfies } from 'compare-versions';
3
3
  import * as fs from 'fs-extra';
4
4
  import os from 'os';
5
5
  import path from 'path';
6
6
  import { t } from './utils/i18n';
7
+ import {
8
+ getJavaScriptRuntime,
9
+ spawnJavaScript,
10
+ spawnJavaScriptSync,
11
+ } from './utils/runtime';
7
12
 
8
13
  const g2js = require('gradle-to-js/lib/parser');
9
14
  const properties = require('properties');
@@ -39,6 +44,12 @@ const dependencyFields = [
39
44
  'optionalDependencies',
40
45
  ] as const;
41
46
 
47
+ type SyncProcessResult = {
48
+ status: number | null;
49
+ signal: NodeJS.Signals | null;
50
+ error?: Error;
51
+ };
52
+
42
53
  type ResolvedExpoCli = {
43
54
  cliPath: string;
44
55
  usingExpo: boolean;
@@ -242,9 +253,10 @@ export async function runReactNativeBundleCommand({
242
253
  reactNativeBundleArgs.push('--config', config);
243
254
  }
244
255
 
245
- const reactNativeBundleProcess = spawn('node', reactNativeBundleArgs);
256
+ const jsRuntime = getJavaScriptRuntime();
257
+ const reactNativeBundleProcess = spawnJavaScript(reactNativeBundleArgs);
246
258
  console.log(
247
- `Running bundle command: node ${reactNativeBundleArgs.join(' ')}`,
259
+ `Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`,
248
260
  );
249
261
 
250
262
  await new Promise<void>((resolve, reject) => {
@@ -346,6 +358,24 @@ function dirnameOfPackage(
346
358
  );
347
359
  }
348
360
 
361
+ function assertSuccessfulSyncProcess(
362
+ result: SyncProcessResult,
363
+ command: string,
364
+ ) {
365
+ if (result.error) {
366
+ throw result.error;
367
+ }
368
+ if (result.status !== 0) {
369
+ throw new Error(
370
+ `${command} failed with ${
371
+ result.status === null
372
+ ? `signal ${result.signal}`
373
+ : `exit code ${result.status}`
374
+ }`,
375
+ );
376
+ }
377
+ }
378
+
349
379
  export function resolveHermesCommand(projectRoot = process.cwd()): string {
350
380
  const osBin = getHermesOSBin();
351
381
  if (!osBin) {
@@ -453,9 +483,12 @@ async function compileHermesByteCode(
453
483
  console.log(
454
484
  t('runningHermesc', { command: hermesCommand, args: args.join(' ') }),
455
485
  );
456
- spawnSync(hermesCommand, args, {
457
- stdio: 'ignore',
458
- });
486
+ assertSuccessfulSyncProcess(
487
+ spawnSync(hermesCommand, args, {
488
+ stdio: 'ignore',
489
+ }),
490
+ hermesCommand,
491
+ );
459
492
  if (sourcemapOutput) {
460
493
  const composerPath =
461
494
  'node_modules/react-native/scripts/compose-source-maps.js';
@@ -463,18 +496,20 @@ async function compileHermesByteCode(
463
496
  return;
464
497
  }
465
498
  console.log(t('composingSourceMap'));
466
- spawnSync(
467
- 'node',
468
- [
469
- composerPath,
470
- path.join(outputFolder, `${bundleName}.txt.map`),
471
- path.join(outputFolder, `${bundleName}.map`),
472
- '-o',
473
- sourcemapOutput,
474
- ],
475
- {
476
- stdio: 'ignore',
477
- },
499
+ assertSuccessfulSyncProcess(
500
+ spawnJavaScriptSync(
501
+ [
502
+ composerPath,
503
+ path.join(outputFolder, `${bundleName}.txt.map`),
504
+ path.join(outputFolder, `${bundleName}.map`),
505
+ '-o',
506
+ sourcemapOutput,
507
+ ],
508
+ {
509
+ stdio: 'ignore',
510
+ },
511
+ ),
512
+ composerPath,
478
513
  );
479
514
  }
480
515
  if (shouldCleanSourcemap) {
@@ -505,16 +540,18 @@ export async function copyDebugidForSentry(
505
540
  return;
506
541
  }
507
542
  console.log(t('copyingDebugId'));
508
- spawnSync(
509
- 'node',
510
- [
511
- copyDebugidPath,
512
- path.join(outputFolder, `${bundleName}.txt.map`),
513
- path.join(outputFolder, `${bundleName}.map`),
514
- ],
515
- {
516
- stdio: 'ignore',
517
- },
543
+ assertSuccessfulSyncProcess(
544
+ spawnJavaScriptSync(
545
+ [
546
+ copyDebugidPath,
547
+ path.join(outputFolder, `${bundleName}.txt.map`),
548
+ path.join(outputFolder, `${bundleName}.map`),
549
+ ],
550
+ {
551
+ stdio: 'ignore',
552
+ },
553
+ ),
554
+ copyDebugidPath,
518
555
  );
519
556
  }
520
557
  fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
@@ -544,31 +581,35 @@ export async function uploadSourcemapForSentry(
544
581
  return;
545
582
  }
546
583
 
547
- spawnSync(
548
- 'node',
549
- [sentryCliPath, 'releases', 'set-commits', version, '--auto'],
550
- {
551
- stdio: 'inherit',
552
- },
584
+ assertSuccessfulSyncProcess(
585
+ spawnJavaScriptSync(
586
+ [sentryCliPath, 'releases', 'set-commits', version, '--auto'],
587
+ {
588
+ stdio: 'inherit',
589
+ },
590
+ ),
591
+ sentryCliPath,
553
592
  );
554
593
  console.log(t('sentryReleaseCreated', { version }));
555
594
 
556
595
  console.log(t('uploadingSourcemap'));
557
- spawnSync(
558
- 'node',
559
- [
560
- sentryCliPath,
561
- 'releases',
562
- 'files',
563
- version,
564
- 'upload-sourcemaps',
565
- '--strip-prefix',
566
- path.join(process.cwd(), outputFolder),
567
- path.join(outputFolder, bundleName),
568
- path.join(outputFolder, `${bundleName}.map`),
569
- ],
570
- {
571
- stdio: 'inherit',
572
- },
596
+ assertSuccessfulSyncProcess(
597
+ spawnJavaScriptSync(
598
+ [
599
+ sentryCliPath,
600
+ 'releases',
601
+ 'files',
602
+ version,
603
+ 'upload-sourcemaps',
604
+ '--strip-prefix',
605
+ path.join(process.cwd(), outputFolder),
606
+ path.join(outputFolder, bundleName),
607
+ path.join(outputFolder, `${bundleName}.map`),
608
+ ],
609
+ {
610
+ stdio: 'inherit',
611
+ },
612
+ ),
613
+ sentryCliPath,
573
614
  );
574
615
  }
package/src/install.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { spawnSync } from 'child_process';
2
2
  import path from 'path';
3
3
  import type { CommandContext } from './types';
4
+ import { getInstallCommand } from './utils/runtime';
4
5
 
5
6
  export const installCommands = {
6
7
  install: async ({ args }: CommandContext) => {
@@ -9,8 +10,9 @@ export const installCommands = {
9
10
  }
10
11
 
11
12
  const cliDir = path.resolve(__dirname, '..');
13
+ const installCommand = getInstallCommand(args, cliDir);
12
14
 
13
- spawnSync('npm', ['install', ...args], {
15
+ spawnSync(installCommand.command, installCommand.args, {
14
16
  cwd: cliDir,
15
17
  stdio: 'inherit',
16
18
  shell: true,
package/src/locales/en.ts CHANGED
@@ -156,6 +156,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
156
156
  usageUploadIpa: 'Usage: cresc uploadIpa <ipa file>',
157
157
  versionBind:
158
158
  'Bound hot update {{version}} to native version {{nativeVersion}} (id: {{id}})',
159
+ versionIdRequired: 'Please provide versionId in non-interactive mode.',
159
160
  welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
160
161
  versionNameQuestion: 'Enter OTA update name:',
161
162
  versionDescriptionQuestion: 'Enter OTA update description:',
package/src/locales/zh.ts CHANGED
@@ -145,6 +145,7 @@ export default {
145
145
  usageUploadIpa: '使用方法: pushy uploadIpa ipa后缀文件',
146
146
  versionBind:
147
147
  '已将热更包 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
148
+ versionIdRequired: '非交互模式下请提供 versionId。',
148
149
  welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
149
150
  versionNameQuestion: '输入版本名称:',
150
151
  versionDescriptionQuestion: '输入版本描述:',
package/src/package.ts CHANGED
@@ -18,6 +18,9 @@ import { getCommitInfo } from './utils/git';
18
18
  import { t } from './utils/i18n';
19
19
 
20
20
  type PackageCommandOptions = Record<string, unknown> & {
21
+ appId?: string;
22
+ appKey?: string;
23
+ platform?: Platform;
21
24
  version?: string;
22
25
  includeAllSplits?: boolean | string;
23
26
  splits?: string;
@@ -96,13 +99,19 @@ async function uploadNativePackage(
96
99
  const info = await config.getInfo(filePath);
97
100
  const { versionName: extractedVersionName, buildTime } = info;
98
101
  const { appId: appIdInPkg, appKey: appKeyInPkg } = info;
99
- const { appId, appKey } = await getSelectedApp(config.platform);
102
+ const selectedApp = options.appId
103
+ ? {
104
+ appId: String(options.appId),
105
+ appKey: typeof options.appKey === 'string' ? options.appKey : undefined,
106
+ }
107
+ : await getSelectedApp(config.platform);
108
+ const { appId, appKey } = selectedApp;
100
109
 
101
110
  if (appIdInPkg && String(appIdInPkg) !== appId) {
102
111
  throw new Error(t(config.appIdMismatchKey, { appIdInPkg, appId }));
103
112
  }
104
113
 
105
- if (appKeyInPkg && appKeyInPkg !== appKey) {
114
+ if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
106
115
  throw new Error(t(config.appKeyMismatchKey, { appKeyInPkg, appKey }));
107
116
  }
108
117