"feat: 增加助手应用配置管理功能与服务器守护进程支持"
This commit is contained in:
@@ -4,6 +4,7 @@ import { checkFileExists, AssistantConfig } from '@/module/assistant/index.ts';
|
||||
import { chalk } from '@/module/chalk.ts';
|
||||
export type AssistantInitOptions = {
|
||||
path?: string;
|
||||
init?: boolean;
|
||||
};
|
||||
/**
|
||||
* 助手初始化类
|
||||
@@ -14,6 +15,7 @@ export class AssistantInit extends AssistantConfig {
|
||||
const configDir = opts?.path || process.cwd();
|
||||
super({
|
||||
configDir,
|
||||
init: opts?.init ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,21 +32,30 @@ export class AssistantInit extends AssistantConfig {
|
||||
}
|
||||
}
|
||||
checkConfigPath() {
|
||||
const assistantPath = path.join(this.configDir, 'assistant-config.json');
|
||||
const assistantPath = path.join(this.configDir, 'assistant-app', 'assistant-config.json');
|
||||
return checkFileExists(assistantPath);
|
||||
}
|
||||
createAssistantConfig() {
|
||||
const assistantPath = this.configPath?.configPath;
|
||||
// 创建助手配置文件 assistant-config.json
|
||||
if (!checkFileExists(assistantPath, true)) {
|
||||
this.setConfig({
|
||||
description: '助手配置文件',
|
||||
});
|
||||
console.log(chalk.green('助手配置文件创建成功'));
|
||||
console.log(chalk.green('助手配置文件assistant-config.json创建成功'));
|
||||
}
|
||||
const env = this.configPath?.envConfigPath;
|
||||
// 创建助手环境配置文件 env
|
||||
if (!checkFileExists(env, true)) {
|
||||
fs.writeFileSync(env, '# 环境配置文件\n');
|
||||
console.log(chalk.green('助手环境配置文件创建成功'));
|
||||
console.log(chalk.green('助手环境配置.env文件创建成功'));
|
||||
}
|
||||
|
||||
const appsConfig = this.configPath?.appsConfigPath;
|
||||
// 创建助手应用配置文件 apps
|
||||
if (!checkFileExists(appsConfig, true)) {
|
||||
fs.writeFileSync(appsConfig, JSON.stringify({ description: 'apps manager.', list: [] }));
|
||||
console.log(chalk.green('助手应用配置文件apps.json创建成功'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user