feat: add silky cli tools

This commit is contained in:
2025-04-27 22:16:09 +08:00
parent 75d181ef43
commit 6867de838e
42 changed files with 3867 additions and 251 deletions

View File

@@ -0,0 +1,36 @@
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')
.action(async (options) => {
const { id, type } = 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 });
}
});
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);