react-native-update-cli 1.46.2 → 2.0.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.
Files changed (68) hide show
  1. package/README.md +603 -1
  2. package/README.zh-CN.md +601 -0
  3. package/cli.json +39 -3
  4. package/lib/api.js +5 -5
  5. package/lib/app.js +1 -1
  6. package/lib/bundle.js +30 -28
  7. package/lib/exports.js +65 -0
  8. package/lib/index.js +100 -9
  9. package/lib/locales/en.js +2 -1
  10. package/lib/locales/zh.js +2 -1
  11. package/lib/module-manager.js +125 -0
  12. package/lib/modules/app-module.js +223 -0
  13. package/lib/modules/bundle-module.js +188 -0
  14. package/lib/modules/index.js +42 -0
  15. package/lib/modules/package-module.js +16 -0
  16. package/lib/modules/user-module.js +402 -0
  17. package/lib/modules/version-module.js +16 -0
  18. package/lib/package.js +40 -9
  19. package/lib/provider.js +341 -0
  20. package/lib/user.js +3 -3
  21. package/lib/utils/app-info-parser/apk.js +1 -1
  22. package/lib/utils/app-info-parser/ipa.js +2 -2
  23. package/lib/utils/app-info-parser/resource-finder.js +35 -35
  24. package/lib/utils/app-info-parser/xml-parser/manifest.js +2 -2
  25. package/lib/utils/app-info-parser/zip.js +3 -6
  26. package/lib/utils/check-plugin.js +1 -1
  27. package/lib/utils/git.js +1 -1
  28. package/lib/utils/i18n.js +3 -1
  29. package/lib/utils/index.js +4 -4
  30. package/lib/utils/latest-version/cli.js +3 -3
  31. package/lib/utils/latest-version/index.js +4 -4
  32. package/lib/versions.js +2 -2
  33. package/package.json +4 -4
  34. package/src/api.ts +7 -7
  35. package/src/app.ts +2 -2
  36. package/src/bundle.ts +44 -32
  37. package/src/exports.ts +30 -0
  38. package/src/index.ts +118 -16
  39. package/src/locales/en.ts +1 -0
  40. package/src/locales/zh.ts +1 -0
  41. package/src/module-manager.ts +149 -0
  42. package/src/modules/app-module.ts +205 -0
  43. package/src/modules/bundle-module.ts +202 -0
  44. package/src/modules/index.ts +19 -0
  45. package/src/modules/package-module.ts +11 -0
  46. package/src/modules/user-module.ts +406 -0
  47. package/src/modules/version-module.ts +8 -0
  48. package/src/package.ts +59 -25
  49. package/src/provider.ts +341 -0
  50. package/src/types.ts +126 -0
  51. package/src/user.ts +4 -3
  52. package/src/utils/app-info-parser/apk.js +62 -52
  53. package/src/utils/app-info-parser/app.js +5 -5
  54. package/src/utils/app-info-parser/ipa.js +69 -57
  55. package/src/utils/app-info-parser/resource-finder.js +50 -54
  56. package/src/utils/app-info-parser/utils.js +59 -54
  57. package/src/utils/app-info-parser/xml-parser/binary.js +366 -354
  58. package/src/utils/app-info-parser/xml-parser/manifest.js +145 -137
  59. package/src/utils/app-info-parser/zip.js +1 -1
  60. package/src/utils/check-plugin.ts +4 -2
  61. package/src/utils/dep-versions.ts +13 -6
  62. package/src/utils/git.ts +1 -1
  63. package/src/utils/i18n.ts +3 -1
  64. package/src/utils/index.ts +8 -10
  65. package/src/utils/latest-version/cli.ts +4 -4
  66. package/src/utils/latest-version/index.ts +17 -17
  67. package/src/utils/plugin-config.ts +3 -3
  68. package/src/versions.ts +3 -3
package/lib/bundle.js CHANGED
@@ -19,20 +19,20 @@ _export(exports, {
19
19
  return readEntry;
20
20
  }
21
21
  });
22
+ const _child_process = require("child_process");
22
23
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
23
- const _utils = require("./utils");
24
+ const _compareversions = require("compare-versions");
24
25
  const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
25
- const _yazl = require("yazl");
26
26
  const _yauzl = require("yauzl");
27
+ const _yazl = require("yazl");
27
28
  const _app = require("./app");
28
- const _child_process = require("child_process");
29
- const _compareversions = require("compare-versions");
29
+ const _utils = require("./utils");
30
30
  const _os = /*#__PURE__*/ _interop_require_default(require("os"));
31
+ const _addgitignore = require("./utils/add-gitignore");
32
+ const _checklockfile = require("./utils/check-lockfile");
33
+ const _constants = require("./utils/constants");
31
34
  const _depversions = require("./utils/dep-versions");
32
35
  const _i18n = require("./utils/i18n");
33
- const _constants = require("./utils/constants");
34
- const _checklockfile = require("./utils/check-lockfile");
35
- const _addgitignore = require("./utils/add-gitignore");
36
36
  const _versions = require("./versions");
37
37
  function _interop_require_default(obj) {
38
38
  return obj && obj.__esModule ? obj : {
@@ -496,7 +496,7 @@ async function pack(dir, output) {
496
496
  addDirectory(dir, '');
497
497
  zipfile.outputStream.on('error', (err)=>reject(err));
498
498
  zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
499
- resolve();
499
+ resolve(void 0);
500
500
  });
501
501
  zipfile.end();
502
502
  });
@@ -508,17 +508,14 @@ function readEntry(entry, zipFile) {
508
508
  const buffers = [];
509
509
  return new Promise((resolve, reject)=>{
510
510
  zipFile.openReadStream(entry, (err, stream)=>{
511
- stream.pipe({
512
- write (chunk) {
513
- buffers.push(chunk);
514
- },
515
- end () {
516
- resolve(Buffer.concat(buffers));
517
- },
518
- prependListener () {},
519
- on () {},
520
- once () {},
521
- emit () {}
511
+ stream.on('data', (chunk)=>{
512
+ buffers.push(chunk);
513
+ });
514
+ stream.on('end', ()=>{
515
+ resolve(Buffer.concat(buffers));
516
+ });
517
+ stream.on('error', (err)=>{
518
+ reject(err);
522
519
  });
523
520
  });
524
521
  });
@@ -553,7 +550,7 @@ async function diffFromPPK(origin, next, output) {
553
550
  throw err;
554
551
  });
555
552
  zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
556
- resolve();
553
+ resolve(void 0);
557
554
  });
558
555
  });
559
556
  const addedEntry = {};
@@ -616,7 +613,7 @@ async function diffFromPPK(origin, next, output) {
616
613
  zipfile.addReadStream(readStream, entry.fileName);
617
614
  readStream.on('end', ()=>{
618
615
  //console.log('add finished');
619
- resolve();
616
+ resolve(void 0);
620
617
  });
621
618
  });
622
619
  });
@@ -670,7 +667,7 @@ async function diffFromPackage(origin, next, output, originBundleName, transform
670
667
  throw err;
671
668
  });
672
669
  zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
673
- resolve();
670
+ resolve(void 0);
674
671
  });
675
672
  });
676
673
  await enumZipEntries(next, (entry, nextZipfile)=>{
@@ -710,7 +707,7 @@ async function diffFromPackage(origin, next, output, originBundleName, transform
710
707
  zipfile.addReadStream(readStream, entry.fileName);
711
708
  readStream.on('end', ()=>{
712
709
  //console.log('add finished');
713
- resolve();
710
+ resolve(void 0);
714
711
  });
715
712
  });
716
713
  });
@@ -744,7 +741,7 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
744
741
  if (err) return rej(err);
745
742
  const writeStream = _fsextra.createWriteStream(tempZipPath);
746
743
  readStream.pipe(writeStream);
747
- writeStream.on('finish', res);
744
+ writeStream.on('finish', ()=>res(void 0));
748
745
  writeStream.on('error', rej);
749
746
  });
750
747
  });
@@ -822,11 +819,11 @@ const bundleCommands = {
822
819
  outputFolder: intermediaDir,
823
820
  platform,
824
821
  sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
825
- disableHermes,
822
+ disableHermes: !!disableHermes,
826
823
  cli: {
827
- taro,
828
- expo,
829
- rncli
824
+ taro: !!taro,
825
+ expo: !!expo,
826
+ rncli: !!rncli
830
827
  }
831
828
  });
832
829
  await pack(_path.default.resolve(intermediaDir), realOutput);
@@ -891,6 +888,11 @@ const bundleCommands = {
891
888
  await diffFromPackage(origin, next, realOutput, 'assets/index.android.bundle');
892
889
  console.log(`${realOutput} generated.`);
893
890
  },
891
+ async diffFromApp ({ args, options }) {
892
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromApp');
893
+ await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
894
+ console.log(`${realOutput} generated.`);
895
+ },
894
896
  async hdiffFromApp ({ args, options }) {
895
897
  const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromApp');
896
898
  await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
package/lib/exports.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ CLIProviderImpl: function() {
13
+ return _provider.CLIProviderImpl;
14
+ },
15
+ appModule: function() {
16
+ return _appmodule.appModule;
17
+ },
18
+ builtinModules: function() {
19
+ return _modules.builtinModules;
20
+ },
21
+ bundleModule: function() {
22
+ return _bundlemodule.bundleModule;
23
+ },
24
+ getPlatform: function() {
25
+ return _app.getPlatform;
26
+ },
27
+ getSelectedApp: function() {
28
+ return _app.getSelectedApp;
29
+ },
30
+ getSession: function() {
31
+ return _api.getSession;
32
+ },
33
+ loadSession: function() {
34
+ return _api.loadSession;
35
+ },
36
+ moduleManager: function() {
37
+ return _modulemanager.moduleManager;
38
+ },
39
+ packageModule: function() {
40
+ return _packagemodule.packageModule;
41
+ },
42
+ question: function() {
43
+ return _utils.question;
44
+ },
45
+ saveToLocal: function() {
46
+ return _utils.saveToLocal;
47
+ },
48
+ userModule: function() {
49
+ return _usermodule.userModule;
50
+ },
51
+ versionModule: function() {
52
+ return _versionmodule.versionModule;
53
+ }
54
+ });
55
+ const _modulemanager = require("./module-manager");
56
+ const _provider = require("./provider");
57
+ const _modules = require("./modules");
58
+ const _bundlemodule = require("./modules/bundle-module");
59
+ const _versionmodule = require("./modules/version-module");
60
+ const _appmodule = require("./modules/app-module");
61
+ const _usermodule = require("./modules/user-module");
62
+ const _packagemodule = require("./modules/package-module");
63
+ const _api = require("./api");
64
+ const _app = require("./app");
65
+ const _utils = require("./utils");
package/lib/index.js CHANGED
@@ -3,21 +3,76 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ function _export(target, all) {
7
+ for(var name in all)Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ CLIProviderImpl: function() {
14
+ return _provider.CLIProviderImpl;
15
+ },
16
+ moduleManager: function() {
17
+ return _modulemanager.moduleManager;
18
+ }
19
+ });
6
20
  const _api = require("./api");
21
+ const _app = require("./app");
22
+ const _bundle = require("./bundle");
23
+ const _modulemanager = require("./module-manager");
24
+ const _modules = require("./modules");
25
+ const _package = require("./package");
26
+ const _user = require("./user");
7
27
  const _utils = require("./utils");
8
28
  const _i18n = require("./utils/i18n");
9
- const _bundle = require("./bundle");
10
29
  const _versions = require("./versions");
11
- const _user = require("./user");
12
- const _app = require("./app");
13
- const _package = require("./package");
30
+ const _provider = require("./provider");
31
+ function registerBuiltinModules() {
32
+ for (const module of _modules.builtinModules){
33
+ try {
34
+ _modulemanager.moduleManager.registerModule(module);
35
+ } catch (error) {
36
+ console.error(`Failed to register module ${module.name}:`, error);
37
+ }
38
+ }
39
+ }
14
40
  function printUsage() {
15
- // const commandName = args[0];
16
- // TODO: print usage of commandName, or print global usage.
41
+ console.log('React Native Update CLI');
42
+ console.log('');
43
+ console.log('Traditional commands:');
44
+ const legacyCommands = {
45
+ ..._user.userCommands,
46
+ ..._bundle.bundleCommands,
47
+ ..._app.appCommands,
48
+ ..._package.packageCommands,
49
+ ..._versions.versionCommands
50
+ };
51
+ for (const [name, handler] of Object.entries(legacyCommands)){
52
+ console.log(` ${name}: Legacy command`);
53
+ }
54
+ console.log('');
55
+ console.log('Modular commands:');
56
+ const commands = _modulemanager.moduleManager.getRegisteredCommands();
57
+ for (const command of commands){
58
+ console.log(` ${command.name}: ${command.description || 'No description'}`);
59
+ }
60
+ console.log('');
61
+ console.log('Available workflows:');
62
+ const workflows = _modulemanager.moduleManager.getRegisteredWorkflows();
63
+ for (const workflow of workflows){
64
+ console.log(` ${workflow.name}: ${workflow.description || 'No description'}`);
65
+ }
66
+ console.log('');
67
+ console.log('Special commands:');
68
+ console.log(' list: List all available commands and workflows');
69
+ console.log(' workflow <name>: Execute a specific workflow');
70
+ console.log(' help: Show this help message');
71
+ console.log('');
17
72
  console.log('Visit `https://github.com/reactnativecn/react-native-update` for document.');
18
73
  process.exit(1);
19
74
  }
20
- const commands = {
75
+ const legacyCommands = {
21
76
  ..._user.userCommands,
22
77
  ..._bundle.bundleCommands,
23
78
  ..._app.appCommands,
@@ -30,16 +85,52 @@ async function run() {
30
85
  if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
31
86
  process.exit();
32
87
  }
88
+ // Register builtin modules for modular functionality
89
+ registerBuiltinModules();
33
90
  const argv = require('cli-arguments').parse(require('../cli.json'));
34
91
  global.NO_INTERACTIVE = argv.options['no-interactive'];
35
92
  global.USE_ACC_OSS = argv.options.acc;
36
- (0, _api.loadSession)().then(()=>commands[argv.command](argv)).catch((err)=>{
93
+ const context = {
94
+ args: argv.args || [],
95
+ options: argv.options || {}
96
+ };
97
+ try {
98
+ await (0, _api.loadSession)();
99
+ context.session = require('./api').getSession();
100
+ // Handle special modular commands first
101
+ if (argv.command === 'help') {
102
+ printUsage();
103
+ } else if (argv.command === 'list') {
104
+ _modulemanager.moduleManager.listAll();
105
+ } else if (argv.command === 'workflow') {
106
+ const workflowName = argv.args[0];
107
+ if (!workflowName) {
108
+ console.error('Workflow name is required');
109
+ process.exit(1);
110
+ }
111
+ const result = await _modulemanager.moduleManager.executeWorkflow(workflowName, context);
112
+ if (!result.success) {
113
+ console.error('Workflow execution failed:', result.error);
114
+ process.exit(1);
115
+ }
116
+ console.log('Workflow completed successfully:', result.data);
117
+ } else if (legacyCommands[argv.command]) {
118
+ await legacyCommands[argv.command](argv);
119
+ } else {
120
+ const result = await _modulemanager.moduleManager.executeCommand(argv.command, context);
121
+ if (!result.success) {
122
+ console.error('Command execution failed:', result.error);
123
+ process.exit(1);
124
+ }
125
+ console.log('Command completed successfully:', result.data);
126
+ }
127
+ } catch (err) {
37
128
  if (err.status === 401) {
38
129
  console.log((0, _i18n.t)('loginFirst'));
39
130
  return;
40
131
  }
41
132
  console.error(err.stack);
42
133
  process.exit(-1);
43
- });
134
+ }
44
135
  }
45
136
  run();
package/lib/locales/en.js CHANGED
@@ -113,5 +113,6 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
113
113
  versionMetaInfoQuestion: 'Enter custom meta info:',
114
114
  updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
115
115
  unnamed: '(Unnamed)',
116
- dryRun: 'Below is the dry-run result, no actual operation will be performed:'
116
+ dryRun: 'Below is the dry-run result, no actual operation will be performed:',
117
+ usingCustomVersion: 'Using custom version: {{version}}'
117
118
  };
package/lib/locales/zh.js CHANGED
@@ -112,5 +112,6 @@ const _default = {
112
112
  versionMetaInfoQuestion: '输入自定义的 meta info:',
113
113
  updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
114
114
  unnamed: '(未命名)',
115
- dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:'
115
+ dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
116
+ usingCustomVersion: '使用自定义版本:{{version}}'
116
117
  };
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ ModuleManager: function() {
13
+ return ModuleManager;
14
+ },
15
+ moduleManager: function() {
16
+ return moduleManager;
17
+ }
18
+ });
19
+ const _provider = require("./provider");
20
+ class ModuleManager {
21
+ registerModule(module) {
22
+ if (this.modules.has(module.name)) {
23
+ throw new Error(`Module '${module.name}' is already registered`);
24
+ }
25
+ this.modules.set(module.name, module);
26
+ if (module.commands) {
27
+ for (const command of module.commands){
28
+ this.registerCommand(command);
29
+ }
30
+ }
31
+ if (module.workflows) {
32
+ for (const workflow of module.workflows){
33
+ this.registerWorkflow(workflow);
34
+ }
35
+ }
36
+ if (module.init) {
37
+ module.init(this.provider);
38
+ }
39
+ console.log(`Module '${module.name}' (v${module.version}) registered successfully`);
40
+ }
41
+ unregisterModule(moduleName) {
42
+ const module = this.modules.get(moduleName);
43
+ if (!module) {
44
+ throw new Error(`Module '${moduleName}' is not registered`);
45
+ }
46
+ if (module.commands) {
47
+ for (const command of module.commands){
48
+ this.commands.delete(command.name);
49
+ }
50
+ }
51
+ if (module.workflows) {
52
+ for (const workflow of module.workflows){
53
+ this.workflows.delete(workflow.name);
54
+ }
55
+ }
56
+ if (module.cleanup) {
57
+ module.cleanup();
58
+ }
59
+ this.modules.delete(moduleName);
60
+ console.log(`Module '${moduleName}' unregistered successfully`);
61
+ }
62
+ registerCommand(command) {
63
+ if (this.commands.has(command.name)) {
64
+ throw new Error(`Command '${command.name}' is already registered`);
65
+ }
66
+ this.commands.set(command.name, command);
67
+ }
68
+ registerWorkflow(workflow) {
69
+ if (this.workflows.has(workflow.name)) {
70
+ throw new Error(`Workflow '${workflow.name}' is already registered`);
71
+ }
72
+ this.workflows.set(workflow.name, workflow);
73
+ this.provider.registerWorkflow(workflow);
74
+ }
75
+ getRegisteredCommands() {
76
+ return Array.from(this.commands.values());
77
+ }
78
+ getRegisteredWorkflows() {
79
+ return Array.from(this.workflows.values());
80
+ }
81
+ getRegisteredModules() {
82
+ return Array.from(this.modules.values());
83
+ }
84
+ async executeCommand(commandName, context) {
85
+ const command = this.commands.get(commandName);
86
+ if (!command) {
87
+ throw new Error(`Command '${commandName}' not found`);
88
+ }
89
+ return await command.handler(context);
90
+ }
91
+ async executeWorkflow(workflowName, context) {
92
+ return await this.provider.executeWorkflow(workflowName, context);
93
+ }
94
+ getProvider() {
95
+ return this.provider;
96
+ }
97
+ listCommands() {
98
+ return Array.from(this.commands.values());
99
+ }
100
+ listWorkflows() {
101
+ return Array.from(this.workflows.values());
102
+ }
103
+ listAll() {
104
+ console.log('\n=== Registered Commands ===');
105
+ for (const command of this.commands.values()){
106
+ console.log(` ${command.name}: ${command.description || 'No description'}`);
107
+ }
108
+ console.log('\n=== Registered Workflows ===');
109
+ for (const workflow of this.workflows.values()){
110
+ console.log(` ${workflow.name}: ${workflow.description || 'No description'}`);
111
+ }
112
+ console.log('\n=== Registered Modules ===');
113
+ for (const module of this.modules.values()){
114
+ var _module_commands, _module_workflows;
115
+ console.log(` ${module.name} (v${module.version}): ${((_module_commands = module.commands) == null ? void 0 : _module_commands.length) || 0} commands, ${((_module_workflows = module.workflows) == null ? void 0 : _module_workflows.length) || 0} workflows`);
116
+ }
117
+ }
118
+ constructor(){
119
+ this.modules = new Map();
120
+ this.commands = new Map();
121
+ this.workflows = new Map();
122
+ this.provider = new _provider.CLIProviderImpl();
123
+ }
124
+ }
125
+ const moduleManager = new ModuleManager();