react-native-update-cli 2.10.0 → 2.10.2
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 +47 -497
- package/README.zh-CN.md +52 -500
- package/cli.json +2 -16
- package/lib/api.js +1 -1
- package/lib/app.d.ts +7 -6
- package/lib/app.js +23 -22
- package/lib/exports.d.ts +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +14 -62
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/module-manager.d.ts +1 -5
- package/lib/module-manager.js +2 -30
- package/lib/modules/app-module.js +1 -249
- package/lib/modules/bundle-module.js +1 -173
- package/lib/modules/package-module.js +1 -2
- package/lib/modules/user-module.js +1 -399
- package/lib/modules/version-module.js +1 -2
- package/lib/package.d.ts +1 -2
- package/lib/package.js +6 -6
- package/lib/provider.d.ts +1 -4
- package/lib/provider.js +2 -21
- package/lib/types.d.ts +0 -20
- package/lib/user.d.ts +1 -1
- package/lib/user.js +1 -1
- package/lib/utils/app-info-parser/aab.js +1 -1
- package/lib/utils/app-info-parser/resource-finder.js +5 -5
- package/lib/utils/app-info-parser/utils.js +3 -2
- package/lib/utils/check-lockfile.js +1 -1
- package/lib/utils/dep-versions.js +2 -2
- package/lib/utils/http-helper.js +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/versions.d.ts +1 -0
- package/lib/versions.js +19 -14
- package/package.json +1 -1
- package/src/api.ts +1 -1
- package/src/app.ts +39 -40
- package/src/exports.ts +0 -2
- package/src/index.ts +16 -81
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/module-manager.ts +1 -41
- package/src/modules/app-module.ts +1 -271
- package/src/modules/bundle-module.ts +1 -206
- package/src/modules/package-module.ts +0 -3
- package/src/modules/user-module.ts +1 -459
- package/src/modules/version-module.ts +0 -1
- package/src/package.ts +5 -7
- package/src/provider.ts +4 -25
- package/src/types.ts +0 -32
- package/src/user.ts +1 -1
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/app-info-parser/resource-finder.ts +5 -5
- package/src/utils/app-info-parser/utils.ts +2 -2
- package/src/utils/check-lockfile.ts +1 -1
- package/src/utils/dep-versions.ts +2 -2
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +1 -1
- package/src/versions.ts +24 -14
- package/lib/workflow-runner.d.ts +0 -2
- package/lib/workflow-runner.js +0 -25
- package/src/workflow-runner.ts +0 -24
package/lib/app.js
CHANGED
|
@@ -119,8 +119,27 @@ async function chooseApp(platform) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
async function selectApp({ args, options }) {
|
|
123
|
+
const platform = await getPlatform(options.platform);
|
|
124
|
+
const id = args[0] ? Number.parseInt(args[0], 10) : (await chooseApp(platform)).id;
|
|
125
|
+
let updateInfo = {};
|
|
126
|
+
try {
|
|
127
|
+
updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (e.code !== 'ENOENT') {
|
|
130
|
+
console.error((0, _i18n.t)('failedToParseUpdateJson'));
|
|
131
|
+
throw e;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const { appKey } = await (0, _api.get)(`/app/${id}`);
|
|
135
|
+
updateInfo[platform] = {
|
|
136
|
+
appId: id,
|
|
137
|
+
appKey
|
|
138
|
+
};
|
|
139
|
+
await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
140
|
+
}
|
|
122
141
|
const appCommands = {
|
|
123
|
-
createApp: async
|
|
142
|
+
createApp: async ({ options })=>{
|
|
124
143
|
const name = options.name || await (0, _utils.question)((0, _i18n.t)('appNameQuestion'));
|
|
125
144
|
const { downloadUrl } = options;
|
|
126
145
|
const platform = await getPlatform(options.platform);
|
|
@@ -132,9 +151,9 @@ const appCommands = {
|
|
|
132
151
|
console.log((0, _i18n.t)('createAppSuccess', {
|
|
133
152
|
id
|
|
134
153
|
}));
|
|
135
|
-
await
|
|
154
|
+
await selectApp({
|
|
136
155
|
args: [
|
|
137
|
-
id
|
|
156
|
+
String(id)
|
|
138
157
|
],
|
|
139
158
|
options: {
|
|
140
159
|
platform
|
|
@@ -154,23 +173,5 @@ const appCommands = {
|
|
|
154
173
|
const { platform = '' } = options;
|
|
155
174
|
await listApp(platform);
|
|
156
175
|
},
|
|
157
|
-
selectApp
|
|
158
|
-
const platform = await getPlatform(options.platform);
|
|
159
|
-
const id = args[0] ? Number.parseInt(args[0]) : (await chooseApp(platform)).id;
|
|
160
|
-
let updateInfo = {};
|
|
161
|
-
try {
|
|
162
|
-
updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
|
|
163
|
-
} catch (e) {
|
|
164
|
-
if (e.code !== 'ENOENT') {
|
|
165
|
-
console.error((0, _i18n.t)('failedToParseUpdateJson'));
|
|
166
|
-
throw e;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const { appKey } = await (0, _api.get)(`/app/${id}`);
|
|
170
|
-
updateInfo[platform] = {
|
|
171
|
-
appId: id,
|
|
172
|
-
appKey
|
|
173
|
-
};
|
|
174
|
-
await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
175
|
-
}
|
|
176
|
+
selectApp
|
|
176
177
|
};
|
package/lib/exports.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export { packageModule } from './modules/package-module';
|
|
|
9
9
|
export { userModule } from './modules/user-module';
|
|
10
10
|
export { versionModule } from './modules/version-module';
|
|
11
11
|
export { CLIProviderImpl } from './provider';
|
|
12
|
-
export type { BundleOptions, CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult,
|
|
12
|
+
export type { BundleOptions, CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult, Package, Platform, PublishOptions, Session, UploadOptions, Version, } from './types';
|
|
13
13
|
export { question, saveToLocal } from './utils';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
export { moduleManager } from './module-manager';
|
|
3
3
|
export { CLIProviderImpl } from './provider';
|
|
4
|
-
export type { CLIModule, CLIProvider, CommandDefinition,
|
|
5
|
-
export { moduleManager };
|
|
4
|
+
export type { CLIModule, CLIProvider, CommandDefinition, } from './types';
|
package/lib/index.js
CHANGED
|
@@ -22,52 +22,29 @@ const _app = require("./app");
|
|
|
22
22
|
const _bundle = require("./bundle");
|
|
23
23
|
const _diff = require("./diff");
|
|
24
24
|
const _install = require("./install");
|
|
25
|
-
const _modulemanager = require("./module-manager");
|
|
26
|
-
const _modules = require("./modules");
|
|
27
25
|
const _package = require("./package");
|
|
28
26
|
const _user = require("./user");
|
|
29
27
|
const _utils = require("./utils");
|
|
30
28
|
const _i18n = require("./utils/i18n");
|
|
31
29
|
const _versions = require("./versions");
|
|
30
|
+
const _modulemanager = require("./module-manager");
|
|
32
31
|
const _provider = require("./provider");
|
|
33
|
-
function
|
|
34
|
-
for (const module of _modules.builtinModules){
|
|
35
|
-
try {
|
|
36
|
-
_modulemanager.moduleManager.registerModule(module);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error(`Failed to register module ${module.name}:`, error);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function printUsage() {
|
|
32
|
+
function printUsage(exitCode = 1) {
|
|
43
33
|
console.log('React Native Update CLI');
|
|
44
34
|
console.log('');
|
|
45
|
-
console.log('
|
|
46
|
-
for (const name of Object.keys(
|
|
47
|
-
console.log(` ${name}
|
|
48
|
-
}
|
|
49
|
-
console.log('');
|
|
50
|
-
console.log('Modular commands:');
|
|
51
|
-
const commands = _modulemanager.moduleManager.listCommands();
|
|
52
|
-
for (const command of commands){
|
|
53
|
-
console.log(` ${command.name}: ${command.description || 'No description'}`);
|
|
54
|
-
}
|
|
55
|
-
console.log('');
|
|
56
|
-
console.log('Available workflows:');
|
|
57
|
-
const workflows = _modulemanager.moduleManager.listWorkflows();
|
|
58
|
-
for (const workflow of workflows){
|
|
59
|
-
console.log(` ${workflow.name}: ${workflow.description || 'No description'}`);
|
|
35
|
+
console.log('Commands:');
|
|
36
|
+
for (const name of Object.keys(commandHandlers)){
|
|
37
|
+
console.log(` ${name}`);
|
|
60
38
|
}
|
|
61
39
|
console.log('');
|
|
62
40
|
console.log('Special commands:');
|
|
63
|
-
console.log(' list: List all available commands
|
|
64
|
-
console.log(' workflow <name>: Execute a specific workflow');
|
|
41
|
+
console.log(' list: List all available commands');
|
|
65
42
|
console.log(' help: Show this help message');
|
|
66
43
|
console.log('');
|
|
67
44
|
console.log('Visit `https://github.com/reactnativecn/react-native-update` for document.');
|
|
68
|
-
process.exit(
|
|
45
|
+
process.exit(exitCode);
|
|
69
46
|
}
|
|
70
|
-
const
|
|
47
|
+
const commandHandlers = {
|
|
71
48
|
..._user.userCommands,
|
|
72
49
|
..._bundle.bundleCommands,
|
|
73
50
|
..._diff.diffCommands,
|
|
@@ -82,45 +59,20 @@ async function run() {
|
|
|
82
59
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
83
60
|
process.exit();
|
|
84
61
|
}
|
|
85
|
-
// Register builtin modules for modular functionality
|
|
86
|
-
registerBuiltinModules();
|
|
87
62
|
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
88
63
|
global.NO_INTERACTIVE = argv.options['no-interactive'];
|
|
89
64
|
global.USE_ACC_OSS = argv.options.acc;
|
|
90
|
-
const context = {
|
|
91
|
-
args: argv.args || [],
|
|
92
|
-
options: argv.options || {}
|
|
93
|
-
};
|
|
94
65
|
try {
|
|
95
66
|
await (0, _api.loadSession)();
|
|
96
|
-
context.session = require('./api').getSession();
|
|
97
|
-
// Handle special modular commands first
|
|
98
67
|
if (argv.command === 'help') {
|
|
99
|
-
printUsage();
|
|
68
|
+
printUsage(0);
|
|
100
69
|
} else if (argv.command === 'list') {
|
|
101
|
-
|
|
102
|
-
} else if (argv.command
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
console.error('Workflow name is required');
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
const result = await _modulemanager.moduleManager.executeWorkflow(workflowName, context);
|
|
109
|
-
if (!result.success) {
|
|
110
|
-
console.error('Workflow execution failed:', result.error);
|
|
111
|
-
process.exit(1);
|
|
112
|
-
}
|
|
113
|
-
console.log('Workflow completed successfully:', result.data);
|
|
114
|
-
} else if (legacyCommands[argv.command]) {
|
|
115
|
-
const legacyHandler = legacyCommands[argv.command];
|
|
116
|
-
await legacyHandler(argv);
|
|
70
|
+
printUsage(0);
|
|
71
|
+
} else if (commandHandlers[argv.command]) {
|
|
72
|
+
const handler = commandHandlers[argv.command];
|
|
73
|
+
await handler(argv);
|
|
117
74
|
} else {
|
|
118
|
-
|
|
119
|
-
if (!result.success) {
|
|
120
|
-
console.error('Command execution failed:', result.error);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
console.log('Command completed successfully:', result.data);
|
|
75
|
+
throw new Error(`Unknown command: ${argv.command}`);
|
|
124
76
|
}
|
|
125
77
|
} catch (err) {
|
|
126
78
|
if (err.status === 401) {
|
package/lib/locales/en.d.ts
CHANGED
package/lib/locales/en.js
CHANGED
|
@@ -82,6 +82,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
82
82
|
operationSuccess: 'Operation successful',
|
|
83
83
|
packageIdRequired: 'Please provide packageId or packageVersion parameter',
|
|
84
84
|
packageUploadSuccess: 'Successfully uploaded new hot update package (id: {{id}})',
|
|
85
|
+
depsChangeWarningTitle: 'Dependency changes detected',
|
|
85
86
|
depsChangeSummary: 'Dependency changes: added {{added}}, removed {{removed}}, changed {{changed}}.',
|
|
86
87
|
depsChangeTargetPackage: 'Target native package: {{packageName}} (id: {{packageId}})',
|
|
87
88
|
depsChangeDependencyHeader: 'Dependency',
|
package/lib/locales/zh.d.ts
CHANGED
package/lib/locales/zh.js
CHANGED
|
@@ -82,6 +82,7 @@ const _default = {
|
|
|
82
82
|
operationSuccess: '操作成功',
|
|
83
83
|
packageIdRequired: '请提供 packageId 或 packageVersion 参数',
|
|
84
84
|
packageUploadSuccess: '已成功上传新热更包(id: {{id}})',
|
|
85
|
+
depsChangeWarningTitle: '检测到依赖变化',
|
|
85
86
|
depsChangeSummary: '依赖变化:新增 {{added}} 项,移除 {{removed}} 项,版本变更 {{changed}} 项。',
|
|
86
87
|
depsChangeTargetPackage: '目标原生包:{{packageName}} (id: {{packageId}})',
|
|
87
88
|
depsChangeDependencyHeader: '依赖',
|
package/lib/module-manager.d.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import type { CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult
|
|
1
|
+
import type { CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult } from './types';
|
|
2
2
|
export declare class ModuleManager {
|
|
3
3
|
private modules;
|
|
4
4
|
private provider;
|
|
5
5
|
private commands;
|
|
6
|
-
private workflows;
|
|
7
6
|
constructor();
|
|
8
7
|
registerModule(module: CLIModule): void;
|
|
9
8
|
unregisterModule(moduleName: string): void;
|
|
10
9
|
registerCommand(command: CommandDefinition): void;
|
|
11
|
-
registerWorkflow(workflow: CustomWorkflow): void;
|
|
12
10
|
executeCommand(commandName: string, context: CommandContext): Promise<CommandResult>;
|
|
13
|
-
executeWorkflow(workflowName: string, context: CommandContext): Promise<CommandResult>;
|
|
14
11
|
getProvider(): CLIProvider;
|
|
15
12
|
listCommands(): CommandDefinition[];
|
|
16
|
-
listWorkflows(): CustomWorkflow[];
|
|
17
13
|
listModules(): CLIModule[];
|
|
18
14
|
listAll(): void;
|
|
19
15
|
}
|
package/lib/module-manager.js
CHANGED
|
@@ -28,11 +28,6 @@ class ModuleManager {
|
|
|
28
28
|
this.registerCommand(command);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
if (module.workflows) {
|
|
32
|
-
for (const workflow of module.workflows){
|
|
33
|
-
this.registerWorkflow(workflow);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
31
|
if (module.init) {
|
|
37
32
|
module.init(this.provider);
|
|
38
33
|
}
|
|
@@ -47,11 +42,6 @@ class ModuleManager {
|
|
|
47
42
|
this.commands.delete(command.name);
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
|
-
if (module.workflows) {
|
|
51
|
-
for (const workflow of module.workflows){
|
|
52
|
-
this.workflows.delete(workflow.name);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
45
|
if (module.cleanup) {
|
|
56
46
|
module.cleanup();
|
|
57
47
|
}
|
|
@@ -64,13 +54,6 @@ class ModuleManager {
|
|
|
64
54
|
}
|
|
65
55
|
this.commands.set(command.name, command);
|
|
66
56
|
}
|
|
67
|
-
registerWorkflow(workflow) {
|
|
68
|
-
if (this.workflows.has(workflow.name)) {
|
|
69
|
-
throw new Error(`Workflow '${workflow.name}' is already registered`);
|
|
70
|
-
}
|
|
71
|
-
this.workflows.set(workflow.name, workflow);
|
|
72
|
-
this.provider.registerWorkflow(workflow);
|
|
73
|
-
}
|
|
74
57
|
async executeCommand(commandName, context) {
|
|
75
58
|
const command = this.commands.get(commandName);
|
|
76
59
|
if (!command) {
|
|
@@ -78,18 +61,12 @@ class ModuleManager {
|
|
|
78
61
|
}
|
|
79
62
|
return await command.handler(context);
|
|
80
63
|
}
|
|
81
|
-
async executeWorkflow(workflowName, context) {
|
|
82
|
-
return await this.provider.executeWorkflow(workflowName, context);
|
|
83
|
-
}
|
|
84
64
|
getProvider() {
|
|
85
65
|
return this.provider;
|
|
86
66
|
}
|
|
87
67
|
listCommands() {
|
|
88
68
|
return Array.from(this.commands.values());
|
|
89
69
|
}
|
|
90
|
-
listWorkflows() {
|
|
91
|
-
return Array.from(this.workflows.values());
|
|
92
|
-
}
|
|
93
70
|
listModules() {
|
|
94
71
|
return Array.from(this.modules.values());
|
|
95
72
|
}
|
|
@@ -98,20 +75,15 @@ class ModuleManager {
|
|
|
98
75
|
for (const command of this.commands.values()){
|
|
99
76
|
console.log(` ${command.name}: ${command.description || 'No description'}`);
|
|
100
77
|
}
|
|
101
|
-
console.log('\n=== Registered Workflows ===');
|
|
102
|
-
for (const workflow of this.workflows.values()){
|
|
103
|
-
console.log(` ${workflow.name}: ${workflow.description || 'No description'}`);
|
|
104
|
-
}
|
|
105
78
|
console.log('\n=== Registered Modules ===');
|
|
106
79
|
for (const module of this.modules.values()){
|
|
107
|
-
var _module_commands
|
|
108
|
-
console.log(` ${module.name} (v${module.version}): ${((_module_commands = module.commands) == null ? void 0 : _module_commands.length) || 0} commands
|
|
80
|
+
var _module_commands;
|
|
81
|
+
console.log(` ${module.name} (v${module.version}): ${((_module_commands = module.commands) == null ? void 0 : _module_commands.length) || 0} commands`);
|
|
109
82
|
}
|
|
110
83
|
}
|
|
111
84
|
constructor(){
|
|
112
85
|
this.modules = new Map();
|
|
113
86
|
this.commands = new Map();
|
|
114
|
-
this.workflows = new Map();
|
|
115
87
|
this.provider = new _provider.CLIProviderImpl();
|
|
116
88
|
}
|
|
117
89
|
}
|
|
@@ -8,256 +8,8 @@ Object.defineProperty(exports, "appModule", {
|
|
|
8
8
|
return appModule;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _app = require("../app");
|
|
12
|
-
const _options = require("../utils/options");
|
|
13
|
-
const allPlatforms = [
|
|
14
|
-
'ios',
|
|
15
|
-
'android',
|
|
16
|
-
'harmony'
|
|
17
|
-
];
|
|
18
|
-
const emptyAppsData = {
|
|
19
|
-
ios: [],
|
|
20
|
-
android: [],
|
|
21
|
-
harmony: []
|
|
22
|
-
};
|
|
23
|
-
function isPlatform(value) {
|
|
24
|
-
return value === 'ios' || value === 'android' || value === 'harmony';
|
|
25
|
-
}
|
|
26
|
-
function normalizePlatformOption(value) {
|
|
27
|
-
return isPlatform(value) ? value : '';
|
|
28
|
-
}
|
|
29
11
|
const appModule = {
|
|
30
12
|
name: 'app',
|
|
31
13
|
version: '1.0.0',
|
|
32
|
-
commands: []
|
|
33
|
-
workflows: [
|
|
34
|
-
{
|
|
35
|
-
name: 'setup-app',
|
|
36
|
-
description: 'Setup a new app with initial configuration',
|
|
37
|
-
steps: [
|
|
38
|
-
{
|
|
39
|
-
name: 'create',
|
|
40
|
-
description: 'Create the app',
|
|
41
|
-
execute: async (context)=>{
|
|
42
|
-
console.log('Creating app in workflow');
|
|
43
|
-
const name = (0, _options.getStringOption)(context.options, 'name');
|
|
44
|
-
const downloadUrl = (0, _options.getStringOption)(context.options, 'downloadUrl');
|
|
45
|
-
const platform = normalizePlatformOption(context.options.platform);
|
|
46
|
-
await _app.appCommands.createApp({
|
|
47
|
-
options: {
|
|
48
|
-
name,
|
|
49
|
-
downloadUrl,
|
|
50
|
-
platform
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
appCreated: true
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'select',
|
|
60
|
-
description: 'Select the created app',
|
|
61
|
-
execute: async (context, previousResult)=>{
|
|
62
|
-
console.log('Selecting app in workflow');
|
|
63
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
64
|
-
const platform = normalizePlatformOption(context.options.platform);
|
|
65
|
-
await _app.appCommands.selectApp({
|
|
66
|
-
args: [],
|
|
67
|
-
options: {
|
|
68
|
-
platform
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
...state,
|
|
73
|
-
appSelected: true
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'manage-apps',
|
|
81
|
-
description: 'Manage multiple apps',
|
|
82
|
-
steps: [
|
|
83
|
-
{
|
|
84
|
-
name: 'list-apps',
|
|
85
|
-
description: 'List all apps',
|
|
86
|
-
execute: async (context)=>{
|
|
87
|
-
console.log('Listing all apps');
|
|
88
|
-
const platform = normalizePlatformOption(context.options.platform);
|
|
89
|
-
await _app.appCommands.apps({
|
|
90
|
-
options: {
|
|
91
|
-
platform
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
return {
|
|
95
|
-
appsListed: true
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'select-target-app',
|
|
101
|
-
description: 'Select target app for operations',
|
|
102
|
-
execute: async (context, previousResult)=>{
|
|
103
|
-
console.log('Selecting target app');
|
|
104
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
105
|
-
const platform = normalizePlatformOption(context.options.platform);
|
|
106
|
-
await _app.appCommands.selectApp({
|
|
107
|
-
args: [],
|
|
108
|
-
options: {
|
|
109
|
-
platform
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return {
|
|
113
|
-
...state,
|
|
114
|
-
targetAppSelected: true
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: 'multi-platform-app-management',
|
|
122
|
-
description: 'Multi-platform app unified management workflow',
|
|
123
|
-
steps: [
|
|
124
|
-
{
|
|
125
|
-
name: 'scan-platforms',
|
|
126
|
-
description: 'Scan apps on all platforms',
|
|
127
|
-
execute: async (context)=>{
|
|
128
|
-
console.log('🔍 Scanning apps on all platforms...');
|
|
129
|
-
const appsData = {
|
|
130
|
-
ios: [],
|
|
131
|
-
android: [],
|
|
132
|
-
harmony: []
|
|
133
|
-
};
|
|
134
|
-
for (const platform of allPlatforms){
|
|
135
|
-
console.log(` Scanning ${platform} platform...`);
|
|
136
|
-
try {
|
|
137
|
-
const rawApps = await (0, _app.listApp)(platform);
|
|
138
|
-
const apps = rawApps.map((app, index)=>{
|
|
139
|
-
var _app_id, _app_name, _app_platform, _app_version;
|
|
140
|
-
return {
|
|
141
|
-
id: String((_app_id = app.id) != null ? _app_id : `${platform}-app-${index + 1}`),
|
|
142
|
-
name: (_app_name = app.name) != null ? _app_name : `App ${index + 1}`,
|
|
143
|
-
platform: (_app_platform = app.platform) != null ? _app_platform : platform,
|
|
144
|
-
version: typeof app.version === 'string' ? (_app_version = app.version) != null ? _app_version : 'unknown' : 'unknown',
|
|
145
|
-
status: app.status === 'inactive' ? 'inactive' : 'active'
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
appsData[platform] = apps;
|
|
149
|
-
console.log(` ✅ Found ${apps.length} apps`);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
appsData[platform] = [];
|
|
152
|
-
console.warn(` ⚠️ Failed to scan ${platform}:`, error);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
console.log('✅ Platform scanning completed');
|
|
156
|
-
return {
|
|
157
|
-
platforms: allPlatforms,
|
|
158
|
-
appsData,
|
|
159
|
-
scanned: true
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
name: 'analyze-apps',
|
|
165
|
-
description: 'Analyze app status',
|
|
166
|
-
execute: async (context, previousResult)=>{
|
|
167
|
-
var _state_appsData;
|
|
168
|
-
console.log('📊 Analyzing app status...');
|
|
169
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
170
|
-
const appsData = (_state_appsData = state.appsData) != null ? _state_appsData : emptyAppsData;
|
|
171
|
-
const analysis = {
|
|
172
|
-
totalApps: 0,
|
|
173
|
-
activeApps: 0,
|
|
174
|
-
inactiveApps: 0,
|
|
175
|
-
platformDistribution: {
|
|
176
|
-
ios: 0,
|
|
177
|
-
android: 0,
|
|
178
|
-
harmony: 0
|
|
179
|
-
},
|
|
180
|
-
issues: []
|
|
181
|
-
};
|
|
182
|
-
for (const platform of allPlatforms){
|
|
183
|
-
var _appsData_platform;
|
|
184
|
-
const platformApps = (_appsData_platform = appsData[platform]) != null ? _appsData_platform : [];
|
|
185
|
-
analysis.totalApps += platformApps.length;
|
|
186
|
-
analysis.platformDistribution[platform] = platformApps.length;
|
|
187
|
-
for (const app of platformApps){
|
|
188
|
-
if (app.status === 'active') {
|
|
189
|
-
analysis.activeApps++;
|
|
190
|
-
} else {
|
|
191
|
-
analysis.inactiveApps++;
|
|
192
|
-
analysis.issues.push(`${platform}/${app.name}: App is inactive`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
console.log('📈 Analysis results:');
|
|
197
|
-
console.log(` Total apps: ${analysis.totalApps}`);
|
|
198
|
-
console.log(` Active apps: ${analysis.activeApps}`);
|
|
199
|
-
console.log(` Inactive apps: ${analysis.inactiveApps}`);
|
|
200
|
-
if (analysis.issues.length > 0) {
|
|
201
|
-
console.log('⚠️ Issues found:');
|
|
202
|
-
for (const issue of analysis.issues){
|
|
203
|
-
console.log(` - ${issue}`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
...state,
|
|
208
|
-
analysis
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: 'optimize-apps',
|
|
214
|
-
description: 'Optimize app configuration',
|
|
215
|
-
execute: async (context, previousResult)=>{
|
|
216
|
-
console.log('⚡ Optimizing app configuration...');
|
|
217
|
-
const state = (0, _options.toObjectState)(previousResult, {});
|
|
218
|
-
const analysis = state.analysis;
|
|
219
|
-
if (!analysis) {
|
|
220
|
-
console.log(' No analysis data, skip optimization');
|
|
221
|
-
return {
|
|
222
|
-
...state,
|
|
223
|
-
optimizations: [],
|
|
224
|
-
optimized: false
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
const optimizations = [];
|
|
228
|
-
if (analysis.inactiveApps > 0) {
|
|
229
|
-
console.log(' Handling inactive apps...');
|
|
230
|
-
optimizations.push('Reactivate inactive apps');
|
|
231
|
-
}
|
|
232
|
-
if (analysis.totalApps > 10) {
|
|
233
|
-
console.log(' Many apps detected, suggest grouping...');
|
|
234
|
-
optimizations.push('Create app groups');
|
|
235
|
-
}
|
|
236
|
-
for (const optimization of optimizations){
|
|
237
|
-
console.log(` Executing: ${optimization}...`);
|
|
238
|
-
console.log(` ✅ ${optimization} completed`);
|
|
239
|
-
}
|
|
240
|
-
console.log('✅ App optimization completed');
|
|
241
|
-
return {
|
|
242
|
-
...state,
|
|
243
|
-
optimizations,
|
|
244
|
-
optimized: true
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
],
|
|
249
|
-
options: {
|
|
250
|
-
includeInactive: {
|
|
251
|
-
hasValue: false,
|
|
252
|
-
default: true,
|
|
253
|
-
description: 'Include inactive apps'
|
|
254
|
-
},
|
|
255
|
-
autoOptimize: {
|
|
256
|
-
hasValue: false,
|
|
257
|
-
default: true,
|
|
258
|
-
description: 'Auto optimize configuration'
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
]
|
|
14
|
+
commands: []
|
|
263
15
|
};
|