react-native-update-cli 2.2.2 → 2.3.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.
package/cli.json CHANGED
@@ -213,7 +213,7 @@
213
213
  "rncli": {
214
214
  "default": false
215
215
  },
216
- "disableHermes": {
216
+ "hermes": {
217
217
  "default": false
218
218
  },
219
219
  "name": {
@@ -299,15 +299,6 @@
299
299
  }
300
300
  }
301
301
  },
302
- "hdiffFromPPK": {
303
- "description": "Create hdiff patch from a Prepare package(.ppk)",
304
- "options": {
305
- "output": {
306
- "default": "${tempDir}/output/hdiff-${time}.ppk-patch",
307
- "hasValue": true
308
- }
309
- }
310
- },
311
302
  "hdiffFromApp": {
312
303
  "description": "Create hdiff patch from a Harmony package(.app)",
313
304
  "options": {
@@ -343,6 +334,10 @@
343
334
  "hasValue": true
344
335
  }
345
336
  }
337
+ },
338
+ "install": {
339
+ "description": "Install optional dependencies to the CLI",
340
+ "options": {}
346
341
  }
347
342
  },
348
343
  "globalOptions": {
package/lib/bundle.js CHANGED
@@ -91,7 +91,7 @@ try {
91
91
  try {
92
92
  hdiff = require('node-hdiffpatch').diff;
93
93
  } catch (e) {}
94
- async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, disableHermes, cli }) {
94
+ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli }) {
95
95
  let gradleConfig = {};
96
96
  if (platform === 'android') {
97
97
  gradleConfig = await checkGradleConfig();
@@ -183,9 +183,16 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
183
183
  } else if (cli.taro) {
184
184
  bundleCommand = 'build';
185
185
  }
186
- reactNativeBundleArgs.push(cliPath, bundleCommand);
186
+ if (platform === 'harmony') {
187
+ bundleName = 'bundle.harmony.js';
188
+ if (forceHermes === undefined) {
189
+ // enable hermes by default for harmony
190
+ forceHermes = true;
191
+ }
192
+ }
193
+ reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName));
187
194
  if (platform !== 'harmony') {
188
- reactNativeBundleArgs.push('--platform', platform, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName), '--reset-cache');
195
+ reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
189
196
  }
190
197
  if (cli.taro) {
191
198
  reactNativeBundleArgs.push('--type', 'rn');
@@ -214,9 +221,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
214
221
  })));
215
222
  } else {
216
223
  let hermesEnabled = false;
217
- if (disableHermes) {
218
- hermesEnabled = false;
219
- console.log((0, _i18n.t)('hermesDisabled'));
224
+ if (forceHermes) {
225
+ hermesEnabled = true;
226
+ console.log((0, _i18n.t)('forceHermes'));
220
227
  } else if (platform === 'android') {
221
228
  const gradlePropeties = await new Promise((resolve)=>{
222
229
  properties.parse('./android/gradle.properties', {
@@ -233,8 +240,6 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
233
240
  if (typeof hermesEnabled !== 'boolean') hermesEnabled = gradleConfig.enableHermes;
234
241
  } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
235
242
  hermesEnabled = true;
236
- } else if (platform === 'harmony') {
237
- await copyHarmonyBundle(outputFolder);
238
243
  }
239
244
  if (hermesEnabled) {
240
245
  await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
@@ -244,40 +249,6 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
244
249
  });
245
250
  });
246
251
  }
247
- async function copyHarmonyBundle(outputFolder) {
248
- const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
249
- try {
250
- await _fsextra.ensureDir(harmonyRawPath);
251
- try {
252
- await _fsextra.access(harmonyRawPath, _fsextra.constants.W_OK);
253
- } catch (error) {
254
- await _fsextra.chmod(harmonyRawPath, 0o755);
255
- }
256
- await _fsextra.remove(_path.default.join(harmonyRawPath, 'update.json'));
257
- await _fsextra.copy('update.json', _path.default.join(harmonyRawPath, 'update.json'));
258
- await _fsextra.ensureDir(outputFolder);
259
- const files = await _fsextra.readdir(harmonyRawPath);
260
- for (const file of files){
261
- if (file !== 'update.json' && file !== 'meta.json') {
262
- const sourcePath = _path.default.join(harmonyRawPath, file);
263
- const destPath = _path.default.join(outputFolder, file);
264
- const stat = await _fsextra.stat(sourcePath);
265
- if (stat.isFile()) {
266
- await _fsextra.copy(sourcePath, destPath);
267
- } else if (stat.isDirectory()) {
268
- await _fsextra.copy(sourcePath, destPath);
269
- }
270
- }
271
- }
272
- } catch (error) {
273
- console.error((0, _i18n.t)('copyHarmonyBundleError', {
274
- error
275
- }));
276
- throw new Error((0, _i18n.t)('copyFileFailed', {
277
- error: error.message
278
- }));
279
- }
280
- }
281
252
  function getHermesOSBin() {
282
253
  if (_os.default.platform() === 'win32') return 'win64-bin';
283
254
  if (_os.default.platform() === 'darwin') return 'osx-bin';
@@ -430,7 +401,8 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
430
401
  const ignorePackingFileNames = [
431
402
  '.',
432
403
  '..',
433
- 'index.bundlejs.map'
404
+ 'index.bundlejs.map',
405
+ 'bundle.harmony.js.map'
434
406
  ];
435
407
  const ignorePackingExtensions = [
436
408
  'DS_Store',
@@ -502,14 +474,14 @@ async function diffFromPPK(origin, next, output) {
502
474
  if (!/\/$/.test(entry.fileName)) {
503
475
  // isFile
504
476
  originMap[entry.crc32] = entry.fileName;
505
- if (entry.fileName === 'index.bundlejs' || entry.fileName === 'bundle.harmony.js') {
477
+ if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
506
478
  // This is source.
507
479
  return readEntry(entry, zipFile).then((v)=>originSource = v);
508
480
  }
509
481
  }
510
482
  });
511
483
  if (!originSource) {
512
- throw new Error('Bundle file not found! Please use default bundle file name and path.');
484
+ throw new Error((0, _i18n.t)('bundleFileNotFound'));
513
485
  }
514
486
  const copies = {};
515
487
  const copiesv2 = {};
@@ -542,18 +514,11 @@ async function diffFromPPK(origin, next, output) {
542
514
  if (!originEntries[entry.fileName]) {
543
515
  addEntry(entry.fileName);
544
516
  }
545
- } else if (entry.fileName === 'index.bundlejs') {
517
+ } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
546
518
  //console.log('Found bundle');
547
519
  return readEntry(entry, nextZipfile).then((newSource)=>{
548
520
  //console.log('Begin diff');
549
- zipfile.addBuffer(diff(originSource, newSource), 'index.bundlejs.patch');
550
- //console.log('End diff');
551
- });
552
- } else if (entry.fileName === 'bundle.harmony.js') {
553
- //console.log('Found bundle');
554
- return readEntry(entry, nextZipfile).then((newSource)=>{
555
- //console.log('Begin diff');
556
- zipfile.addBuffer(diff(originSource, newSource), 'bundle.harmony.js.patch');
521
+ zipfile.addBuffer(diff(originSource, newSource), `${entry.fileName}.patch`);
557
522
  //console.log('End diff');
558
523
  });
559
524
  } else {
@@ -629,7 +594,7 @@ async function diffFromPackage(origin, next, output, originBundleName, transform
629
594
  }
630
595
  });
631
596
  if (!originSource) {
632
- throw new Error('Bundle file not found! Please use default bundle file name and path.');
597
+ throw new Error((0, _i18n.t)('bundleFileNotFound'));
633
598
  }
634
599
  const copies = {};
635
600
  const copiesv2 = {};
@@ -646,18 +611,11 @@ async function diffFromPackage(origin, next, output, originBundleName, transform
646
611
  if (/\/$/.test(entry.fileName)) {
647
612
  // Directory
648
613
  zipfile.addEmptyDirectory(entry.fileName);
649
- } else if (entry.fileName === 'index.bundlejs') {
614
+ } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
650
615
  //console.log('Found bundle');
651
616
  return readEntry(entry, nextZipfile).then((newSource)=>{
652
617
  //console.log('Begin diff');
653
- zipfile.addBuffer(diff(originSource, newSource), 'index.bundlejs.patch');
654
- //console.log('End diff');
655
- });
656
- } else if (entry.fileName === 'bundle.harmony.js') {
657
- //console.log('Found bundle');
658
- return readEntry(entry, nextZipfile).then((newSource)=>{
659
- //console.log('Begin diff');
660
- zipfile.addBuffer(diff(originSource, newSource), 'bundle.harmony.js.patch');
618
+ zipfile.addBuffer(diff(originSource, newSource), `${entry.fileName}.patch`);
661
619
  //console.log('End diff');
662
620
  });
663
621
  } else {
@@ -747,20 +705,25 @@ function diffArgsCheck(args, options, diffFn) {
747
705
  }
748
706
  if (diffFn.startsWith('hdiff')) {
749
707
  if (!hdiff) {
750
- console.error(`This function needs "node-hdiffpatch".
751
- Please run "npm i node-hdiffpatch" to install`);
708
+ console.error((0, _i18n.t)('nodeHdiffpatchRequired', {
709
+ scriptName: _constants.scriptName
710
+ }));
752
711
  process.exit(1);
753
712
  }
754
713
  diff = hdiff;
755
714
  } else {
756
715
  if (!bsdiff) {
757
- console.error(`This function needs "node-bsdiff".
758
- Please run "npm i node-bsdiff" to install`);
716
+ console.error((0, _i18n.t)('nodeBsdiffRequired', {
717
+ scriptName: _constants.scriptName
718
+ }));
759
719
  process.exit(1);
760
720
  }
761
721
  diff = bsdiff;
762
722
  }
763
- const { output } = options;
723
+ const { output } = (0, _utils.translateOptions)({
724
+ ...options,
725
+ tempDir: _constants.tempDir
726
+ });
764
727
  return {
765
728
  origin,
766
729
  next,
@@ -770,7 +733,7 @@ function diffArgsCheck(args, options, diffFn) {
770
733
  const bundleCommands = {
771
734
  bundle: async ({ options })=>{
772
735
  const platform = await (0, _app.getPlatform)(options.platform);
773
- const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli, disableHermes, name, description, metaInfo, packageId, packageVersion, minPackageVersion, maxPackageVersion, packageVersionRange, rollout, dryRun } = (0, _utils.translateOptions)({
736
+ const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli, hermes, name, description, metaInfo, packageId, packageVersion, minPackageVersion, maxPackageVersion, packageVersionRange, rollout, dryRun } = (0, _utils.translateOptions)({
774
737
  ...options,
775
738
  tempDir: _constants.tempDir,
776
739
  platform
@@ -793,7 +756,7 @@ const bundleCommands = {
793
756
  outputFolder: intermediaDir,
794
757
  platform,
795
758
  sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
796
- disableHermes: !!disableHermes,
759
+ forceHermes: hermes,
797
760
  cli: {
798
761
  taro: !!taro,
799
762
  expo: !!expo,
@@ -845,32 +808,44 @@ const bundleCommands = {
845
808
  async diff ({ args, options }) {
846
809
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
847
810
  await diffFromPPK(origin, next, realOutput);
848
- console.log(`${realOutput} generated.`);
811
+ console.log((0, _i18n.t)('diffPackageGenerated', {
812
+ output: realOutput
813
+ }));
849
814
  },
850
815
  async hdiff ({ args, options }) {
851
816
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
852
817
  await diffFromPPK(origin, next, realOutput);
853
- console.log(`${realOutput} generated.`);
818
+ console.log((0, _i18n.t)('diffPackageGenerated', {
819
+ output: realOutput
820
+ }));
854
821
  },
855
822
  async diffFromApk ({ args, options }) {
856
823
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromApk');
857
824
  await diffFromPackage(origin, next, realOutput, 'assets/index.android.bundle');
858
- console.log(`${realOutput} generated.`);
825
+ console.log((0, _i18n.t)('diffPackageGenerated', {
826
+ output: realOutput
827
+ }));
859
828
  },
860
829
  async hdiffFromApk ({ args, options }) {
861
830
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromApk');
862
831
  await diffFromPackage(origin, next, realOutput, 'assets/index.android.bundle');
863
- console.log(`${realOutput} generated.`);
832
+ console.log((0, _i18n.t)('diffPackageGenerated', {
833
+ output: realOutput
834
+ }));
864
835
  },
865
836
  async diffFromApp ({ args, options }) {
866
837
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromApp');
867
838
  await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
868
- console.log(`${realOutput} generated.`);
839
+ console.log((0, _i18n.t)('diffPackageGenerated', {
840
+ output: realOutput
841
+ }));
869
842
  },
870
843
  async hdiffFromApp ({ args, options }) {
871
844
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromApp');
872
845
  await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
873
- console.log(`${realOutput} generated.`);
846
+ console.log((0, _i18n.t)('diffPackageGenerated', {
847
+ output: realOutput
848
+ }));
874
849
  },
875
850
  async diffFromIpa ({ args, options }) {
876
851
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromIpa');
@@ -878,7 +853,9 @@ const bundleCommands = {
878
853
  const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
879
854
  return m == null ? void 0 : m[1];
880
855
  });
881
- console.log(`${realOutput} generated.`);
856
+ console.log((0, _i18n.t)('diffPackageGenerated', {
857
+ output: realOutput
858
+ }));
882
859
  },
883
860
  async hdiffFromIpa ({ args, options }) {
884
861
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromIpa');
@@ -886,6 +863,8 @@ const bundleCommands = {
886
863
  const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
887
864
  return m == null ? void 0 : m[1];
888
865
  });
889
- console.log(`${realOutput} generated.`);
866
+ console.log((0, _i18n.t)('diffPackageGenerated', {
867
+ output: realOutput
868
+ }));
890
869
  }
891
870
  };
package/lib/index.js CHANGED
@@ -20,6 +20,7 @@ _export(exports, {
20
20
  const _api = require("./api");
21
21
  const _app = require("./app");
22
22
  const _bundle = require("./bundle");
23
+ const _install = require("./install");
23
24
  const _modulemanager = require("./module-manager");
24
25
  const _modules = require("./modules");
25
26
  const _package = require("./package");
@@ -46,7 +47,8 @@ function printUsage() {
46
47
  ..._bundle.bundleCommands,
47
48
  ..._app.appCommands,
48
49
  ..._package.packageCommands,
49
- ..._versions.versionCommands
50
+ ..._versions.versionCommands,
51
+ ..._install.installCommands
50
52
  };
51
53
  for (const [name, handler] of Object.entries(legacyCommands)){
52
54
  console.log(` ${name}: Legacy command`);
@@ -78,6 +80,7 @@ const legacyCommands = {
78
80
  ..._app.appCommands,
79
81
  ..._package.packageCommands,
80
82
  ..._versions.versionCommands,
83
+ ..._install.installCommands,
81
84
  help: printUsage
82
85
  };
83
86
  async function run() {
package/lib/install.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "installCommands", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return installCommands;
9
+ }
10
+ });
11
+ const _child_process = require("child_process");
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ const installCommands = {
19
+ install: async ({ args })=>{
20
+ if (args.length === 0) {
21
+ return;
22
+ }
23
+ const cliDir = _path.default.resolve(__dirname, '..');
24
+ (0, _child_process.spawnSync)('npm', [
25
+ 'install',
26
+ ...args
27
+ ], {
28
+ cwd: cliDir,
29
+ stdio: 'inherit',
30
+ shell: true
31
+ });
32
+ }
33
+ };
package/lib/locales/en.js CHANGED
@@ -44,7 +44,7 @@ const _default = {
44
44
  failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
45
45
  fileGenerated: '{{- file}} generated.',
46
46
  fileSizeExceeded: 'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
47
- hermesDisabled: 'Hermes disabled',
47
+ forceHermes: 'Forcing Hermes enabled for this build',
48
48
  hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
49
49
  ipaUploadSuccess: 'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
50
50
  keyStrings: 'Key strings:',
@@ -118,5 +118,9 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
118
118
  confirmDeletePackage: 'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
119
119
  deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
120
120
  deletePackageError: 'Failed to delete native package {{packageId}}: {{error}}',
121
- usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]'
121
+ usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
122
+ bundleFileNotFound: 'Bundle file not found! Please use default bundle file name and path.',
123
+ diffPackageGenerated: '{{- output}} generated.',
124
+ nodeBsdiffRequired: 'This function needs "node-bsdiff". Please run "{{scriptName}} install node-bsdiff" to install',
125
+ nodeHdiffpatchRequired: 'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install'
122
126
  };
package/lib/locales/zh.js CHANGED
@@ -44,7 +44,7 @@ const _default = {
44
44
  failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
45
45
  fileGenerated: '已生成 {{- file}}',
46
46
  fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
47
- hermesDisabled: 'Hermes 已禁用',
47
+ forceHermes: '强制启用 Hermes 编译',
48
48
  hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
49
49
  ipaUploadSuccess: '已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
50
50
  keyStrings: '键字符串:',
@@ -117,5 +117,9 @@ const _default = {
117
117
  confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
118
118
  deletePackageSuccess: '原生包 {{packageId}} 删除成功',
119
119
  deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
120
- usageDeletePackage: '使用方法: pushy deletePackage [packageId] --appId [appId]'
120
+ usageDeletePackage: '使用方法: pushy deletePackage [packageId] --appId [appId]',
121
+ bundleFileNotFound: '未找到 bundle 文件!请使用默认的 bundle 文件名和路径。',
122
+ diffPackageGenerated: '{{- output}} 已生成。',
123
+ nodeBsdiffRequired: '此功能需要 "node-bsdiff"。请运行 "{{scriptName}} install node-bsdiff" 来安装',
124
+ nodeHdiffpatchRequired: '此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装'
121
125
  };
@@ -46,7 +46,7 @@ const bundleModule = {
46
46
  description: 'Build current version',
47
47
  execute: async (context, previousResult)=>{
48
48
  console.log('🏗️ Building current version...');
49
- const { platform, dev = false, sourcemap = false, bundleName = 'index.bundlejs', entryFile = 'index.js', intermediaDir, taro = false, expo = false, rncli = false, disableHermes = false, output } = context.options;
49
+ const { platform, dev = false, sourcemap = false, bundleName = 'index.bundlejs', entryFile = 'index.js', intermediaDir, taro = false, expo = false, rncli = false, hermes = false, output } = context.options;
50
50
  console.log(`Building ${platform} platform...`);
51
51
  console.log(` Entry file: ${entryFile}`);
52
52
  console.log(` Bundle name: ${bundleName}`);
@@ -62,7 +62,7 @@ const bundleModule = {
62
62
  taro,
63
63
  expo,
64
64
  rncli,
65
- disableHermes,
65
+ hermes,
66
66
  intermediaDir: '${tempDir}/intermedia/${platform}',
67
67
  output: '${tempDir}/output/${platform}.${time}.ppk'
68
68
  };
@@ -156,10 +156,10 @@ const bundleModule = {
156
156
  default: false,
157
157
  description: 'Use React Native CLI'
158
158
  },
159
- disableHermes: {
159
+ hermes: {
160
160
  hasValue: false,
161
161
  default: false,
162
- description: 'Disable Hermes'
162
+ description: 'Force enable Hermes'
163
163
  },
164
164
  name: {
165
165
  hasValue: true,
package/lib/provider.js CHANGED
@@ -72,7 +72,7 @@ class CLIProviderImpl {
72
72
  taro: options.taro || false,
73
73
  expo: options.expo || false,
74
74
  rncli: options.rncli || false,
75
- disableHermes: options.disableHermes || false
75
+ hermes: options.hermes || false
76
76
  }
77
77
  };
78
78
  const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
@@ -18,9 +18,18 @@ _export(exports, {
18
18
  defaultEndpoints: function() {
19
19
  return defaultEndpoints;
20
20
  },
21
+ isPPKBundleFileName: function() {
22
+ return isPPKBundleFileName;
23
+ },
24
+ ppkBundleFileNames: function() {
25
+ return ppkBundleFileNames;
26
+ },
21
27
  pricingPageUrl: function() {
22
28
  return pricingPageUrl;
23
29
  },
30
+ scriptName: function() {
31
+ return scriptName;
32
+ },
24
33
  tempDir: function() {
25
34
  return tempDir;
26
35
  },
@@ -36,6 +45,11 @@ function _interop_require_default(obj) {
36
45
  }
37
46
  const scriptName = _path.default.basename(process.argv[1]);
38
47
  const IS_CRESC = scriptName === 'cresc';
48
+ const ppkBundleFileNames = [
49
+ 'index.bundlejs',
50
+ 'bundle.harmony.js'
51
+ ];
52
+ const isPPKBundleFileName = (fileName)=>ppkBundleFileNames.includes(fileName);
39
53
  const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
40
54
  const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
41
55
  const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/bundle.ts CHANGED
@@ -16,7 +16,7 @@ import os from 'os';
16
16
  const properties = require('properties');
17
17
  import { addGitIgnore } from './utils/add-gitignore';
18
18
  import { checkLockFiles } from './utils/check-lockfile';
19
- import { tempDir } from './utils/constants';
19
+ import { isPPKBundleFileName, scriptName, tempDir } from './utils/constants';
20
20
  import { depVersions } from './utils/dep-versions';
21
21
  import { t } from './utils/i18n';
22
22
  import { versionCommands } from './versions';
@@ -42,7 +42,7 @@ async function runReactNativeBundleCommand({
42
42
  platform,
43
43
  sourcemapOutput,
44
44
  config,
45
- disableHermes,
45
+ forceHermes,
46
46
  cli,
47
47
  }: {
48
48
  bundleName: string;
@@ -52,7 +52,7 @@ async function runReactNativeBundleCommand({
52
52
  platform: string;
53
53
  sourcemapOutput: string;
54
54
  config?: string;
55
- disableHermes?: boolean;
55
+ forceHermes?: boolean;
56
56
  cli: {
57
57
  taro?: boolean;
58
58
  expo?: boolean;
@@ -163,18 +163,25 @@ async function runReactNativeBundleCommand({
163
163
  bundleCommand = 'build';
164
164
  }
165
165
 
166
- reactNativeBundleArgs.push(cliPath, bundleCommand);
166
+ if (platform === 'harmony') {
167
+ bundleName = 'bundle.harmony.js';
168
+ if (forceHermes === undefined) {
169
+ // enable hermes by default for harmony
170
+ forceHermes = true;
171
+ }
172
+ }
173
+
174
+ reactNativeBundleArgs.push(
175
+ cliPath,
176
+ bundleCommand,
177
+ '--assets-dest',
178
+ outputFolder,
179
+ '--bundle-output',
180
+ path.join(outputFolder, bundleName),
181
+ );
167
182
 
168
183
  if (platform !== 'harmony') {
169
- reactNativeBundleArgs.push(
170
- '--platform',
171
- platform,
172
- '--assets-dest',
173
- outputFolder,
174
- '--bundle-output',
175
- path.join(outputFolder, bundleName),
176
- '--reset-cache',
177
- );
184
+ reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
178
185
  }
179
186
 
180
187
  if (cli.taro) {
@@ -211,9 +218,9 @@ async function runReactNativeBundleCommand({
211
218
  } else {
212
219
  let hermesEnabled: boolean | undefined = false;
213
220
 
214
- if (disableHermes) {
215
- hermesEnabled = false;
216
- console.log(t('hermesDisabled'));
221
+ if (forceHermes) {
222
+ hermesEnabled = true;
223
+ console.log(t('forceHermes'));
217
224
  } else if (platform === 'android') {
218
225
  const gradlePropeties = await new Promise<{
219
226
  hermesEnabled?: boolean;
@@ -240,8 +247,6 @@ async function runReactNativeBundleCommand({
240
247
  fs.existsSync('ios/Pods/hermes-engine')
241
248
  ) {
242
249
  hermesEnabled = true;
243
- } else if (platform === 'harmony') {
244
- await copyHarmonyBundle(outputFolder);
245
250
  }
246
251
  if (hermesEnabled) {
247
252
  await compileHermesByteCode(
@@ -257,39 +262,6 @@ async function runReactNativeBundleCommand({
257
262
  });
258
263
  }
259
264
 
260
- async function copyHarmonyBundle(outputFolder: string) {
261
- const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
262
- try {
263
- await fs.ensureDir(harmonyRawPath);
264
- try {
265
- await fs.access(harmonyRawPath, fs.constants.W_OK);
266
- } catch (error) {
267
- await fs.chmod(harmonyRawPath, 0o755);
268
- }
269
- await fs.remove(path.join(harmonyRawPath, 'update.json'));
270
- await fs.copy('update.json', path.join(harmonyRawPath, 'update.json'));
271
- await fs.ensureDir(outputFolder);
272
-
273
- const files = await fs.readdir(harmonyRawPath);
274
- for (const file of files) {
275
- if (file !== 'update.json' && file !== 'meta.json') {
276
- const sourcePath = path.join(harmonyRawPath, file);
277
- const destPath = path.join(outputFolder, file);
278
- const stat = await fs.stat(sourcePath);
279
-
280
- if (stat.isFile()) {
281
- await fs.copy(sourcePath, destPath);
282
- } else if (stat.isDirectory()) {
283
- await fs.copy(sourcePath, destPath);
284
- }
285
- }
286
- }
287
- } catch (error: any) {
288
- console.error(t('copyHarmonyBundleError', { error }));
289
- throw new Error(t('copyFileFailed', { error: error.message }));
290
- }
291
- }
292
-
293
265
  function getHermesOSBin() {
294
266
  if (os.platform() === 'win32') return 'win64-bin';
295
267
  if (os.platform() === 'darwin') return 'osx-bin';
@@ -478,7 +450,12 @@ async function uploadSourcemapForSentry(
478
450
  }
479
451
  }
480
452
 
481
- const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
453
+ const ignorePackingFileNames = [
454
+ '.',
455
+ '..',
456
+ 'index.bundlejs.map',
457
+ 'bundle.harmony.js.map',
458
+ ];
482
459
  const ignorePackingExtensions = ['DS_Store', 'txt.map'];
483
460
  async function pack(dir: string, output: string) {
484
461
  console.log(t('packing'));
@@ -560,10 +537,7 @@ async function diffFromPPK(origin: string, next: string, output: string) {
560
537
  // isFile
561
538
  originMap[entry.crc32] = entry.fileName;
562
539
 
563
- if (
564
- entry.fileName === 'index.bundlejs' ||
565
- entry.fileName === 'bundle.harmony.js'
566
- ) {
540
+ if (isPPKBundleFileName(entry.fileName)) {
567
541
  // This is source.
568
542
  return readEntry(entry, zipFile).then((v) => (originSource = v));
569
543
  }
@@ -571,9 +545,7 @@ async function diffFromPPK(origin: string, next: string, output: string) {
571
545
  });
572
546
 
573
547
  if (!originSource) {
574
- throw new Error(
575
- 'Bundle file not found! Please use default bundle file name and path.',
576
- );
548
+ throw new Error(t('bundleFileNotFound'));
577
549
  }
578
550
 
579
551
  const copies = {};
@@ -614,23 +586,13 @@ async function diffFromPPK(origin: string, next: string, output: string) {
614
586
  if (!originEntries[entry.fileName]) {
615
587
  addEntry(entry.fileName);
616
588
  }
617
- } else if (entry.fileName === 'index.bundlejs') {
589
+ } else if (isPPKBundleFileName(entry.fileName)) {
618
590
  //console.log('Found bundle');
619
591
  return readEntry(entry, nextZipfile).then((newSource) => {
620
592
  //console.log('Begin diff');
621
593
  zipfile.addBuffer(
622
594
  diff(originSource, newSource),
623
- 'index.bundlejs.patch',
624
- );
625
- //console.log('End diff');
626
- });
627
- } else if (entry.fileName === 'bundle.harmony.js') {
628
- //console.log('Found bundle');
629
- return readEntry(entry, nextZipfile).then((newSource) => {
630
- //console.log('Begin diff');
631
- zipfile.addBuffer(
632
- diff(originSource, newSource),
633
- 'bundle.harmony.js.patch',
595
+ `${entry.fileName}.patch`,
634
596
  );
635
597
  //console.log('End diff');
636
598
  });
@@ -723,9 +685,7 @@ async function diffFromPackage(
723
685
  });
724
686
 
725
687
  if (!originSource) {
726
- throw new Error(
727
- 'Bundle file not found! Please use default bundle file name and path.',
728
- );
688
+ throw new Error(t('bundleFileNotFound'));
729
689
  }
730
690
 
731
691
  const copies = {};
@@ -746,23 +706,13 @@ async function diffFromPackage(
746
706
  if (/\/$/.test(entry.fileName)) {
747
707
  // Directory
748
708
  zipfile.addEmptyDirectory(entry.fileName);
749
- } else if (entry.fileName === 'index.bundlejs') {
709
+ } else if (isPPKBundleFileName(entry.fileName)) {
750
710
  //console.log('Found bundle');
751
711
  return readEntry(entry, nextZipfile).then((newSource) => {
752
712
  //console.log('Begin diff');
753
713
  zipfile.addBuffer(
754
714
  diff(originSource, newSource),
755
- 'index.bundlejs.patch',
756
- );
757
- //console.log('End diff');
758
- });
759
- } else if (entry.fileName === 'bundle.harmony.js') {
760
- //console.log('Found bundle');
761
- return readEntry(entry, nextZipfile).then((newSource) => {
762
- //console.log('Begin diff');
763
- zipfile.addBuffer(
764
- diff(originSource, newSource),
765
- 'bundle.harmony.js.patch',
715
+ `${entry.fileName}.patch`,
766
716
  );
767
717
  //console.log('End diff');
768
718
  });
@@ -879,24 +829,21 @@ function diffArgsCheck(args: string[], options: any, diffFn: string) {
879
829
 
880
830
  if (diffFn.startsWith('hdiff')) {
881
831
  if (!hdiff) {
882
- console.error(
883
- `This function needs "node-hdiffpatch".
884
- Please run "npm i node-hdiffpatch" to install`,
885
- );
832
+ console.error(t('nodeHdiffpatchRequired', { scriptName }));
886
833
  process.exit(1);
887
834
  }
888
835
  diff = hdiff;
889
836
  } else {
890
837
  if (!bsdiff) {
891
- console.error(
892
- `This function needs "node-bsdiff".
893
- Please run "npm i node-bsdiff" to install`,
894
- );
838
+ console.error(t('nodeBsdiffRequired', { scriptName }));
895
839
  process.exit(1);
896
840
  }
897
841
  diff = bsdiff;
898
842
  }
899
- const { output } = options;
843
+ const { output } = translateOptions({
844
+ ...options,
845
+ tempDir,
846
+ });
900
847
 
901
848
  return {
902
849
  origin,
@@ -919,7 +866,7 @@ export const bundleCommands = {
919
866
  taro,
920
867
  expo,
921
868
  rncli,
922
- disableHermes,
869
+ hermes,
923
870
  name,
924
871
  description,
925
872
  metaInfo,
@@ -960,7 +907,7 @@ export const bundleCommands = {
960
907
  outputFolder: intermediaDir,
961
908
  platform,
962
909
  sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
963
- disableHermes: !!disableHermes,
910
+ forceHermes: hermes as unknown as boolean,
964
911
  cli: {
965
912
  taro: !!taro,
966
913
  expo: !!expo,
@@ -1027,14 +974,14 @@ export const bundleCommands = {
1027
974
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
1028
975
 
1029
976
  await diffFromPPK(origin, next, realOutput);
1030
- console.log(`${realOutput} generated.`);
977
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1031
978
  },
1032
979
 
1033
980
  async hdiff({ args, options }) {
1034
981
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
1035
982
 
1036
983
  await diffFromPPK(origin, next, realOutput);
1037
- console.log(`${realOutput} generated.`);
984
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1038
985
  },
1039
986
 
1040
987
  async diffFromApk({ args, options }) {
@@ -1050,7 +997,7 @@ export const bundleCommands = {
1050
997
  realOutput,
1051
998
  'assets/index.android.bundle',
1052
999
  );
1053
- console.log(`${realOutput} generated.`);
1000
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1054
1001
  },
1055
1002
 
1056
1003
  async hdiffFromApk({ args, options }) {
@@ -1066,7 +1013,7 @@ export const bundleCommands = {
1066
1013
  realOutput,
1067
1014
  'assets/index.android.bundle',
1068
1015
  );
1069
- console.log(`${realOutput} generated.`);
1016
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1070
1017
  },
1071
1018
 
1072
1019
  async diffFromApp({ args, options }) {
@@ -1081,7 +1028,7 @@ export const bundleCommands = {
1081
1028
  realOutput,
1082
1029
  'resources/rawfile/bundle.harmony.js',
1083
1030
  );
1084
- console.log(`${realOutput} generated.`);
1031
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1085
1032
  },
1086
1033
 
1087
1034
  async hdiffFromApp({ args, options }) {
@@ -1096,7 +1043,7 @@ export const bundleCommands = {
1096
1043
  realOutput,
1097
1044
  'resources/rawfile/bundle.harmony.js',
1098
1045
  );
1099
- console.log(`${realOutput} generated.`);
1046
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1100
1047
  },
1101
1048
 
1102
1049
  async diffFromIpa({ args, options }) {
@@ -1111,7 +1058,7 @@ export const bundleCommands = {
1111
1058
  return m?.[1];
1112
1059
  });
1113
1060
 
1114
- console.log(`${realOutput} generated.`);
1061
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1115
1062
  },
1116
1063
 
1117
1064
  async hdiffFromIpa({ args, options }) {
@@ -1126,6 +1073,6 @@ export const bundleCommands = {
1126
1073
  return m?.[1];
1127
1074
  });
1128
1075
 
1129
- console.log(`${realOutput} generated.`);
1076
+ console.log(t('diffPackageGenerated', { output: realOutput }));
1130
1077
  },
1131
1078
  };
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import { loadSession } from './api';
4
4
  import { appCommands } from './app';
5
5
  import { bundleCommands } from './bundle';
6
+ import { installCommands } from './install';
6
7
  import { moduleManager } from './module-manager';
7
8
  import { builtinModules } from './modules';
8
9
  import { packageCommands } from './package';
@@ -26,15 +27,16 @@ function printUsage() {
26
27
  console.log('React Native Update CLI');
27
28
  console.log('');
28
29
  console.log('Traditional commands:');
29
-
30
+
30
31
  const legacyCommands = {
31
32
  ...userCommands,
32
33
  ...bundleCommands,
33
34
  ...appCommands,
34
35
  ...packageCommands,
35
36
  ...versionCommands,
37
+ ...installCommands,
36
38
  };
37
-
39
+
38
40
  for (const [name, handler] of Object.entries(legacyCommands)) {
39
41
  console.log(` ${name}: Legacy command`);
40
42
  }
@@ -62,7 +64,7 @@ function printUsage() {
62
64
  console.log(' list: List all available commands and workflows');
63
65
  console.log(' workflow <name>: Execute a specific workflow');
64
66
  console.log(' help: Show this help message');
65
-
67
+
66
68
  console.log('');
67
69
  console.log(
68
70
  'Visit `https://github.com/reactnativecn/react-native-update` for document.',
@@ -76,6 +78,7 @@ const legacyCommands = {
76
78
  ...appCommands,
77
79
  ...packageCommands,
78
80
  ...versionCommands,
81
+ ...installCommands,
79
82
  help: printUsage,
80
83
  };
81
84
 
@@ -118,7 +121,7 @@ async function run() {
118
121
  process.exit(1);
119
122
  }
120
123
  console.log('Workflow completed successfully:', result.data);
121
- }
124
+ }
122
125
  // Try legacy commands first for backward compatibility
123
126
  else if (legacyCommands[argv.command]) {
124
127
  await legacyCommands[argv.command](argv);
package/src/install.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { spawnSync } from 'child_process';
2
+ import path from 'path';
3
+ import type { CommandContext } from './types';
4
+
5
+ export const installCommands = {
6
+ install: async ({ args }: CommandContext) => {
7
+ if (args.length === 0) {
8
+ return;
9
+ }
10
+
11
+ const cliDir = path.resolve(__dirname, '..');
12
+
13
+ spawnSync('npm', ['install', ...args], {
14
+ cwd: cliDir,
15
+ stdio: 'inherit',
16
+ shell: true,
17
+ });
18
+ },
19
+ };
package/src/locales/en.ts CHANGED
@@ -49,7 +49,7 @@ export default {
49
49
  fileGenerated: '{{- file}} generated.',
50
50
  fileSizeExceeded:
51
51
  'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
52
- hermesDisabled: 'Hermes disabled',
52
+ forceHermes: 'Forcing Hermes enabled for this build',
53
53
  hermesEnabledCompiling: 'Hermes enabled, now compiling to hermes bytecode:\n',
54
54
  ipaUploadSuccess:
55
55
  'Successfully uploaded IPA native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
@@ -137,4 +137,11 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
137
137
  deletePackageError:
138
138
  'Failed to delete native package {{packageId}}: {{error}}',
139
139
  usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
140
+ bundleFileNotFound:
141
+ 'Bundle file not found! Please use default bundle file name and path.',
142
+ diffPackageGenerated: '{{- output}} generated.',
143
+ nodeBsdiffRequired:
144
+ 'This function needs "node-bsdiff". Please run "{{scriptName}} install node-bsdiff" to install',
145
+ nodeHdiffpatchRequired:
146
+ 'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
140
147
  };
package/src/locales/zh.ts CHANGED
@@ -47,7 +47,7 @@ export default {
47
47
  fileGenerated: '已生成 {{- file}}',
48
48
  fileSizeExceeded:
49
49
  '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
50
- hermesDisabled: 'Hermes 已禁用',
50
+ forceHermes: '强制启用 Hermes 编译',
51
51
  hermesEnabledCompiling: 'Hermes 已启用,正在编译为 hermes 字节码:\n',
52
52
  ipaUploadSuccess:
53
53
  '已成功上传ipa原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
@@ -129,4 +129,10 @@ export default {
129
129
  deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
130
130
  usageDeletePackage:
131
131
  '使用方法: pushy deletePackage [packageId] --appId [appId]',
132
+ bundleFileNotFound: '未找到 bundle 文件!请使用默认的 bundle 文件名和路径。',
133
+ diffPackageGenerated: '{{- output}} 已生成。',
134
+ nodeBsdiffRequired:
135
+ '此功能需要 "node-bsdiff"。请运行 "{{scriptName}} install node-bsdiff" 来安装',
136
+ nodeHdiffpatchRequired:
137
+ '此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
132
138
  };
@@ -53,7 +53,7 @@ export const bundleModule: CLIModule = {
53
53
  taro = false,
54
54
  expo = false,
55
55
  rncli = false,
56
- disableHermes = false,
56
+ hermes = false,
57
57
  output,
58
58
  } = context.options;
59
59
 
@@ -73,7 +73,7 @@ export const bundleModule: CLIModule = {
73
73
  taro,
74
74
  expo,
75
75
  rncli,
76
- disableHermes,
76
+ hermes,
77
77
  intermediaDir: '${tempDir}/intermedia/${platform}',
78
78
  output: '${tempDir}/output/${platform}.${time}.ppk',
79
79
  };
@@ -170,10 +170,10 @@ export const bundleModule: CLIModule = {
170
170
  default: false,
171
171
  description: 'Use React Native CLI',
172
172
  },
173
- disableHermes: {
173
+ hermes: {
174
174
  hasValue: false,
175
175
  default: false,
176
- description: 'Disable Hermes',
176
+ description: 'Force enable Hermes',
177
177
  },
178
178
  name: {
179
179
  hasValue: true,
package/src/provider.ts CHANGED
@@ -42,7 +42,7 @@ export class CLIProviderImpl implements CLIProvider {
42
42
  taro: options.taro || false,
43
43
  expo: options.expo || false,
44
44
  rncli: options.rncli || false,
45
- disableHermes: options.disableHermes || false,
45
+ hermes: options.hermes || false,
46
46
  },
47
47
  };
48
48
 
package/src/types.ts CHANGED
@@ -65,7 +65,7 @@ export interface BundleOptions {
65
65
  taro?: boolean;
66
66
  expo?: boolean;
67
67
  rncli?: boolean;
68
- disableHermes?: boolean;
68
+ hermes?: boolean;
69
69
  }
70
70
 
71
71
  export interface PublishOptions {
@@ -1,8 +1,12 @@
1
1
  import path from 'path';
2
2
 
3
- const scriptName = path.basename(process.argv[1]) as 'cresc' | 'pushy';
3
+ export const scriptName = path.basename(process.argv[1]) as 'cresc' | 'pushy';
4
4
  export const IS_CRESC = scriptName === 'cresc';
5
5
 
6
+ export const ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
7
+ export const isPPKBundleFileName = (fileName: string) =>
8
+ ppkBundleFileNames.includes(fileName);
9
+
6
10
  export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
7
11
  export const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
8
12
  export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';