39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { program, Command, assistantConfig } from '@/program.ts';
|
|
import { AppDownload } from '@/services/app/index.ts';
|
|
|
|
const appManagerCommand = new Command('app').description('本地的应用模块的安装和下载, 分为 app 和 web 两种类型');
|
|
program.addCommand(appManagerCommand);
|
|
|
|
const downloadCommand = new Command('download')
|
|
.description('下载应用')
|
|
.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, 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, force, yes });
|
|
}
|
|
});
|
|
|
|
appManagerCommand.addCommand(downloadCommand);
|
|
|
|
const deleteCommand = new Command('delete')
|
|
.description('删除应用')
|
|
.option('-i, --id <id>', '应用名称')
|
|
.option('-t, --type <type>', '应用类型', 'web')
|
|
.action(async (options) => {
|
|
const { id, type } = options;
|
|
const app = new AppDownload(assistantConfig);
|
|
if (id) {
|
|
await app.deleteApp({ id, type });
|
|
}
|
|
});
|
|
appManagerCommand.addCommand(deleteCommand);
|