react-native-update-cli 1.46.2 → 2.0.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/README.md +578 -1
- package/README.zh-CN.md +576 -0
- package/cli.json +18 -0
- package/lib/api.js +5 -5
- package/lib/app.js +1 -1
- package/lib/bundle.js +30 -28
- package/lib/exports.js +65 -0
- package/lib/index.js +100 -9
- package/lib/module-manager.js +125 -0
- package/lib/modules/app-module.js +223 -0
- package/lib/modules/bundle-module.js +188 -0
- package/lib/modules/index.js +42 -0
- package/lib/modules/package-module.js +16 -0
- package/lib/modules/user-module.js +402 -0
- package/lib/modules/version-module.js +16 -0
- package/lib/package.js +16 -6
- package/lib/provider.js +340 -0
- package/lib/user.js +3 -3
- package/lib/utils/app-info-parser/apk.js +1 -1
- package/lib/utils/app-info-parser/ipa.js +2 -2
- package/lib/utils/app-info-parser/resource-finder.js +35 -35
- package/lib/utils/app-info-parser/xml-parser/manifest.js +2 -2
- package/lib/utils/app-info-parser/zip.js +3 -6
- package/lib/utils/check-plugin.js +1 -1
- package/lib/utils/git.js +1 -1
- package/lib/utils/i18n.js +3 -1
- package/lib/utils/index.js +4 -4
- package/lib/utils/latest-version/cli.js +3 -3
- package/lib/utils/latest-version/index.js +4 -4
- package/lib/versions.js +2 -2
- package/package.json +4 -4
- package/src/api.ts +7 -7
- package/src/app.ts +2 -2
- package/src/bundle.ts +44 -32
- package/src/exports.ts +30 -0
- package/src/index.ts +118 -16
- package/src/module-manager.ts +149 -0
- package/src/modules/app-module.ts +205 -0
- package/src/modules/bundle-module.ts +202 -0
- package/src/modules/index.ts +19 -0
- package/src/modules/package-module.ts +11 -0
- package/src/modules/user-module.ts +406 -0
- package/src/modules/version-module.ts +8 -0
- package/src/package.ts +29 -16
- package/src/provider.ts +341 -0
- package/src/types.ts +125 -0
- package/src/user.ts +4 -3
- package/src/utils/app-info-parser/apk.js +62 -52
- package/src/utils/app-info-parser/app.js +5 -5
- package/src/utils/app-info-parser/ipa.js +69 -57
- package/src/utils/app-info-parser/resource-finder.js +50 -54
- package/src/utils/app-info-parser/utils.js +59 -54
- package/src/utils/app-info-parser/xml-parser/binary.js +366 -354
- package/src/utils/app-info-parser/xml-parser/manifest.js +145 -137
- package/src/utils/app-info-parser/zip.js +1 -1
- package/src/utils/check-plugin.ts +4 -2
- package/src/utils/dep-versions.ts +13 -6
- package/src/utils/git.ts +1 -1
- package/src/utils/i18n.ts +3 -1
- package/src/utils/index.ts +8 -10
- package/src/utils/latest-version/cli.ts +4 -4
- package/src/utils/latest-version/index.ts +17 -17
- package/src/utils/plugin-config.ts +3 -3
- 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
|
|
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
|
|
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.
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
const
|
|
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
|
-
|
|
16
|
-
|
|
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
|
|
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
|
-
|
|
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();
|
|
@@ -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();
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "appModule", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return appModule;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _app = require("../app");
|
|
12
|
+
const appModule = {
|
|
13
|
+
name: 'app',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
commands: [],
|
|
16
|
+
workflows: [
|
|
17
|
+
{
|
|
18
|
+
name: 'setup-app',
|
|
19
|
+
description: 'Setup a new app with initial configuration',
|
|
20
|
+
steps: [
|
|
21
|
+
{
|
|
22
|
+
name: 'create',
|
|
23
|
+
description: 'Create the app',
|
|
24
|
+
execute: async (context)=>{
|
|
25
|
+
console.log('Creating app in workflow');
|
|
26
|
+
const { name, downloadUrl, platform } = context.options;
|
|
27
|
+
await _app.appCommands.createApp({
|
|
28
|
+
options: {
|
|
29
|
+
name: name || '',
|
|
30
|
+
downloadUrl: downloadUrl || '',
|
|
31
|
+
platform: platform || ''
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
appCreated: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'select',
|
|
41
|
+
description: 'Select the created app',
|
|
42
|
+
execute: async (context, previousResult)=>{
|
|
43
|
+
console.log('Selecting app in workflow');
|
|
44
|
+
const { platform } = context.options;
|
|
45
|
+
await _app.appCommands.selectApp({
|
|
46
|
+
args: [],
|
|
47
|
+
options: {
|
|
48
|
+
platform: platform || ''
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
...previousResult,
|
|
53
|
+
appSelected: true
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'manage-apps',
|
|
61
|
+
description: 'Manage multiple apps',
|
|
62
|
+
steps: [
|
|
63
|
+
{
|
|
64
|
+
name: 'list-apps',
|
|
65
|
+
description: 'List all apps',
|
|
66
|
+
execute: async (context)=>{
|
|
67
|
+
console.log('Listing all apps');
|
|
68
|
+
const { platform } = context.options;
|
|
69
|
+
await _app.appCommands.apps({
|
|
70
|
+
options: {
|
|
71
|
+
platform: platform || ''
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
appsListed: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'select-target-app',
|
|
81
|
+
description: 'Select target app for operations',
|
|
82
|
+
execute: async (context, previousResult)=>{
|
|
83
|
+
console.log('Selecting target app');
|
|
84
|
+
const { platform } = context.options;
|
|
85
|
+
await _app.appCommands.selectApp({
|
|
86
|
+
args: [],
|
|
87
|
+
options: {
|
|
88
|
+
platform: platform || ''
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
...previousResult,
|
|
93
|
+
targetAppSelected: true
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'multi-platform-app-management',
|
|
101
|
+
description: 'Multi-platform app unified management workflow',
|
|
102
|
+
steps: [
|
|
103
|
+
{
|
|
104
|
+
name: 'scan-platforms',
|
|
105
|
+
description: 'Scan apps on all platforms',
|
|
106
|
+
execute: async (context)=>{
|
|
107
|
+
console.log('🔍 Scanning apps on all platforms...');
|
|
108
|
+
const platforms = [
|
|
109
|
+
'ios',
|
|
110
|
+
'android',
|
|
111
|
+
'harmony'
|
|
112
|
+
];
|
|
113
|
+
const appsData = {};
|
|
114
|
+
for (const platform of platforms){
|
|
115
|
+
console.log(` Scanning ${platform} platform...`);
|
|
116
|
+
// Simulate getting app list
|
|
117
|
+
await new Promise((resolve)=>setTimeout(resolve, 500));
|
|
118
|
+
const appCount = Math.floor(Math.random() * 5) + 1;
|
|
119
|
+
const apps = Array.from({
|
|
120
|
+
length: appCount
|
|
121
|
+
}, (_, i)=>({
|
|
122
|
+
id: `${platform}_app_${i + 1}`,
|
|
123
|
+
name: `App ${i + 1}`,
|
|
124
|
+
platform,
|
|
125
|
+
version: `1.${i}.0`,
|
|
126
|
+
status: Math.random() > 0.2 ? 'active' : 'inactive'
|
|
127
|
+
}));
|
|
128
|
+
appsData[platform] = apps;
|
|
129
|
+
console.log(` ✅ Found ${appCount} apps`);
|
|
130
|
+
}
|
|
131
|
+
console.log('✅ Platform scanning completed');
|
|
132
|
+
return {
|
|
133
|
+
platforms,
|
|
134
|
+
appsData,
|
|
135
|
+
scanned: true
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'analyze-apps',
|
|
141
|
+
description: 'Analyze app status',
|
|
142
|
+
execute: async (context, previousResult)=>{
|
|
143
|
+
console.log('📊 Analyzing app status...');
|
|
144
|
+
const { appsData } = previousResult;
|
|
145
|
+
const analysis = {
|
|
146
|
+
totalApps: 0,
|
|
147
|
+
activeApps: 0,
|
|
148
|
+
inactiveApps: 0,
|
|
149
|
+
platformDistribution: {},
|
|
150
|
+
issues: []
|
|
151
|
+
};
|
|
152
|
+
for (const [platform, apps] of Object.entries(appsData)){
|
|
153
|
+
const platformApps = apps;
|
|
154
|
+
analysis.totalApps += platformApps.length;
|
|
155
|
+
analysis.platformDistribution[platform] = platformApps.length;
|
|
156
|
+
for (const app of platformApps){
|
|
157
|
+
if (app.status === 'active') {
|
|
158
|
+
analysis.activeApps++;
|
|
159
|
+
} else {
|
|
160
|
+
analysis.inactiveApps++;
|
|
161
|
+
analysis.issues.push(`${platform}/${app.name}: App is inactive`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
console.log('📈 Analysis results:');
|
|
166
|
+
console.log(` Total apps: ${analysis.totalApps}`);
|
|
167
|
+
console.log(` Active apps: ${analysis.activeApps}`);
|
|
168
|
+
console.log(` Inactive apps: ${analysis.inactiveApps}`);
|
|
169
|
+
if (analysis.issues.length > 0) {
|
|
170
|
+
console.log('⚠️ Issues found:');
|
|
171
|
+
analysis.issues.forEach((issue)=>console.log(` - ${issue}`));
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...previousResult,
|
|
175
|
+
analysis
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'optimize-apps',
|
|
181
|
+
description: 'Optimize app configuration',
|
|
182
|
+
execute: async (context, previousResult)=>{
|
|
183
|
+
console.log('⚡ Optimizing app configuration...');
|
|
184
|
+
const { analysis } = previousResult;
|
|
185
|
+
const optimizations = [];
|
|
186
|
+
if (analysis.inactiveApps > 0) {
|
|
187
|
+
console.log(' Handling inactive apps...');
|
|
188
|
+
optimizations.push('Reactivate inactive apps');
|
|
189
|
+
}
|
|
190
|
+
if (analysis.totalApps > 10) {
|
|
191
|
+
console.log(' Many apps detected, suggest grouping...');
|
|
192
|
+
optimizations.push('Create app groups');
|
|
193
|
+
}
|
|
194
|
+
// Simulate optimization process
|
|
195
|
+
for (const optimization of optimizations){
|
|
196
|
+
console.log(` Executing: ${optimization}...`);
|
|
197
|
+
await new Promise((resolve)=>setTimeout(resolve, 800));
|
|
198
|
+
console.log(` ✅ ${optimization} completed`);
|
|
199
|
+
}
|
|
200
|
+
console.log('✅ App optimization completed');
|
|
201
|
+
return {
|
|
202
|
+
...previousResult,
|
|
203
|
+
optimizations,
|
|
204
|
+
optimized: true
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
options: {
|
|
210
|
+
includeInactive: {
|
|
211
|
+
hasValue: false,
|
|
212
|
+
default: true,
|
|
213
|
+
description: 'Include inactive apps'
|
|
214
|
+
},
|
|
215
|
+
autoOptimize: {
|
|
216
|
+
hasValue: false,
|
|
217
|
+
default: true,
|
|
218
|
+
description: 'Auto optimize configuration'
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
};
|