Files
envision-cli/assistant/tasks/silkyai-cli/src/command/check/init-env.ts
2025-04-27 22:16:09 +08:00

69 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { program, Command } from '@/program.ts';
import { TaskKey, silkyCommand } from '@/mdoules/talkshow.ts';
const description = `初始化运行环境,安装
1. @kevisual/cli
2. pm2
可选安装:
deno
bun
`;
const isDev = process.env.NODE_ENV === 'development';
const testEnv = new Command('init-env')
.description(description)
.option('-a --all')
.action((options) => {
let tag = options.all ? 'env' : 'must-env';
silkyCommand.isDebug = isDev ?? false;
const envTask = silkyCommand.getTasksArrayByTag(tag);
for (const value of envTask) {
try {
const res = silkyCommand.runTask(value);
if (res.code === 200) {
console.log('执行结果:', res.code, res.message);
} else {
console.log('执行结果错误:', res.task?.description, res.message);
}
} catch (error) {
console.log('error', error);
continue;
}
}
});
program.addCommand(testEnv);
const appDownloadDesc = `下载安装talkshow的应用模块
1. root/talkshow-admin
2. root/talkshow-code-center
3. root/center
`;
const appDownloadTask = new Command('init-talkshow')
.description(appDownloadDesc)
.option('-a --all', '下载所有应用模块或者只下载talkshow相关的')
.action((options) => {
//
let tag = options.all ? 'app' : 'talkshow';
const appTask = silkyCommand.getTasksArrayByTag(tag);
silkyCommand.isDebug = true;
for (const value of appTask) {
try {
const res = silkyCommand.runTask(value);
if (res.code === 200) {
console.log('执行结果:', res.task?.description, res.code);
} else {
console.log('执行结果错误:', res.task?.description, res.message);
}
} catch (error) {
console.log('error', error);
continue;
}
}
});
program.addCommand(appDownloadTask);