feat: 助手配置与服务命令扩展及依赖更新
This commit is contained in:
@@ -20,7 +20,7 @@ export const initConfig = (configRootPath: string) => {
|
||||
const pageConfigPath = path.join(configDir, 'assistant-page-config.json');
|
||||
const pageDir = createDir(path.join(configDir, 'page'));
|
||||
const appsDir = createDir(path.join(configDir, 'apps'));
|
||||
const appsConfigPath = path.join(appsDir, 'assistant-apps-config.json');
|
||||
const appsConfigPath = path.join(configDir, 'assistant-apps-config.json');
|
||||
const appPidPath = path.join(configDir, 'assistant-app.pid');
|
||||
const envConfigPath = path.join(configDir, '.env');
|
||||
return {
|
||||
@@ -82,17 +82,34 @@ type AssistantConfigOptions = {
|
||||
};
|
||||
export class AssistantConfig {
|
||||
config: AssistantConfigData;
|
||||
configPath: ReturnInitConfigType;
|
||||
#configPath: ReturnInitConfigType;
|
||||
configDir: string;
|
||||
isMountedConfig?: boolean;
|
||||
constructor(opts?: AssistantConfigOptions) {
|
||||
this.configDir = opts?.configDir || configDir;
|
||||
if (opts?.init) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
set configPath(configPath: ReturnInitConfigType) {
|
||||
this.#configPath = configPath;
|
||||
}
|
||||
get configPath() {
|
||||
if (!this.#configPath) {
|
||||
initConfig(this.configDir);
|
||||
}
|
||||
return this.#configPath;
|
||||
}
|
||||
init() {
|
||||
this.configPath = initConfig(this.configDir);
|
||||
this.isMountedConfig = true;
|
||||
}
|
||||
checkMounted() {
|
||||
if (!this.isMountedConfig) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
getConfigPath() {}
|
||||
getConfig() {
|
||||
try {
|
||||
if (!checkFileExists(this.configPath.configPath)) {
|
||||
|
||||
@@ -6,7 +6,8 @@ export class AssistantApp extends Manager {
|
||||
config: AssistantConfig;
|
||||
|
||||
constructor(config: AssistantConfig) {
|
||||
const appsPath = config.configPath?.appsDir || path.join(process.cwd(), 'apps');
|
||||
config.checkMounted();
|
||||
const appsPath = config?.configPath?.appsDir || path.join(process.cwd(), 'apps');
|
||||
const appsConfigPath = config.configPath?.appsConfigPath;
|
||||
const configFimename = path.basename(appsConfigPath || '');
|
||||
super({
|
||||
|
||||
Reference in New Issue
Block a user