"feat: 升级本地应用管理依赖,新增应用删除功能及强制覆盖下载选项"
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AssistantApp } from '@/module/assistant/index.ts';
|
||||
import { program, Command, assistantConfig } from '@/program.ts';
|
||||
import { AppDownload } from '@/services/app/index.ts';
|
||||
|
||||
const appManagerCommand = new Command('app-manager').alias('am').description('Manage Assistant Apps 管理本地的应用模块');
|
||||
program.addCommand(appManagerCommand);
|
||||
@@ -38,18 +39,20 @@ appManagerCommand
|
||||
manager.start(appKey);
|
||||
console.log('Start App:', appKey);
|
||||
});
|
||||
|
||||
const stop = async (appKey: string) => {
|
||||
const manager = new AssistantApp(assistantConfig);
|
||||
try {
|
||||
await manager.loadConfig();
|
||||
await manager.stop(appKey);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
appManagerCommand
|
||||
.command('stop')
|
||||
.argument('<app-key-name>', '应用的 key 名称')
|
||||
.action(async (appKey: string) => {
|
||||
const manager = new AssistantApp(assistantConfig);
|
||||
try {
|
||||
await manager.loadConfig();
|
||||
await manager.stop(appKey);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
await stop(appKey);
|
||||
console.log('Stop App:', appKey);
|
||||
});
|
||||
|
||||
@@ -67,6 +70,22 @@ appManagerCommand
|
||||
console.log('Restart App:', appKey);
|
||||
});
|
||||
|
||||
appManagerCommand
|
||||
.command('delete')
|
||||
.alias('del')
|
||||
.argument('<app-key-name>', '应用的 key 名称, apps 中的 文件名')
|
||||
.action(async (id) => {
|
||||
const app = new AppDownload(assistantConfig);
|
||||
if (id) {
|
||||
if (id.includes('/')) {
|
||||
const [_user, appName] = id.split('/');
|
||||
id = appName;
|
||||
await stop(id);
|
||||
}
|
||||
await app.deleteApp({ id, type: 'app' });
|
||||
}
|
||||
});
|
||||
|
||||
const pageListCommand = new Command('page-list')
|
||||
.alias('pl')
|
||||
.option('-a, --all', '列出前端页面的所有信息')
|
||||
|
||||
@@ -9,14 +9,16 @@ const downloadCommand = new Command('download')
|
||||
.option('-i, --id <id>', '应用名称')
|
||||
.option('-t, --type <type>', '应用类型', 'web')
|
||||
.option('-r, --registry <registry>', '应用源 https://kevisual.cn')
|
||||
.option('-f --force', '强制覆盖')
|
||||
.option('-y --yes', '覆盖的时候不提示')
|
||||
.action(async (options) => {
|
||||
const { id, type } = options;
|
||||
const { id, type, force, yes } = options;
|
||||
assistantConfig.checkMounted();
|
||||
const registry = options.registry || assistantConfig.getRegistry();
|
||||
// console.log('registry', registry);
|
||||
const app = new AppDownload(assistantConfig);
|
||||
if (id) {
|
||||
await app.downloadApp({ id, type, registry });
|
||||
await app.downloadApp({ id, type, registry, force, yes });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user