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,116 @@
import { TasksCommand } from '@kevisual/task-command/mod.ts';
export const silkyCommand = new TasksCommand();
export const enum TaskKey {
ev = 1,
pm2,
deno,
bun,
silkyInit,
appCenter,
appTalkshowAdmin,
appTalkshow,
}
export const init = {
description: '安装依赖',
key: TaskKey.ev,
command: 'npm install -g @kevisual/cli --registry=https://registry.npmmirror.com',
type: 'npm-install',
before: 'ev -v',
beforeCheck: '.',
tags: ['env', 'must-env'],
};
silkyCommand.addTask(init);
const init1 = {
description: '安装 pm2',
type: 'npm-install',
key: TaskKey.pm2,
command: 'npm install -g pm2 --registry=https://registry.npmmirror.com',
before: 'pm2 -v',
beforeCheck: '.',
tags: ['env', 'must-env'],
};
silkyCommand.addTask(init1);
const init2 = {
description: '安装 deno',
command: 'npm install -g deno --registry=https://registry.npmmirror.com',
key: TaskKey.deno,
type: 'npm-install',
before: 'deno -v',
beforeCheck: 'deno',
tags: ['env'],
};
silkyCommand.addTask(init2);
const init3 = {
description: '安装 bun',
type: 'npm-install',
key: TaskKey.bun,
command: 'npm install -g bun --registry=https://registry.npmmirror.com',
before: 'bun -v',
beforeCheck: '.',
tags: ['env'],
};
silkyCommand.addTask(init3);
// ===========================
// 安装talkshow的程序到本地
const talkInit = {
description: '初始化一个助手客户端,生成配置文件。',
key: TaskKey.silkyInit,
command: 'silky init',
};
silkyCommand.addTask(talkInit);
const task1 = {
description: '下载前端应用 root/center 应用',
key: TaskKey.appCenter,
command: 'asst app download -i root/center',
tags: ['app', 'root'],
};
silkyCommand.addTask(task1);
const task2 = {
description: '下载前端应用 root/talkshow-admin 应用',
key: TaskKey.appTalkshowAdmin,
command: 'asst app download -i root/talkshow-admin',
tags: ['app', 'talkshow'],
};
silkyCommand.addTask(task2);
const task3 = {
description: '安装后端应用 root/talkshow-code-center 应用',
key: TaskKey.appTalkshow,
command: 'asst app download -i root/talkshow-code-center -t app',
tags: ['app', 'talkshow'],
};
silkyCommand.addTask(task3);
// ===========================
const testTask = {
description: '测试',
command: 'npm i -g nodemon --registry=https://registry.npmmirror.com',
type: 'npm-install',
before: 'nodemon -v',
beforeCheck: '.',
key: 'test-task',
};
silkyCommand.addTask(testTask);
const runTask1 = async () => {
const tasksCommand = new TasksCommand();
tasksCommand.addTask(init2);
const res = tasksCommand.runTask(init2.description);
console.log(res);
};
// runTask1();
const runTestTask = async () => {
const tasksCommand = new TasksCommand();
tasksCommand.addTask(testTask);
const res = tasksCommand.runTask(testTask);
console.log(res);
return res;
};
// runTestTask();