新模块自动创建config.ts

This commit is contained in:
小鹏 2023-03-16 17:09:37 +08:00
parent 4c9f6dc2c2
commit 801658f290

View File

@ -268,8 +268,7 @@ export class BaseSysMenuService extends BaseService {
'entity',
`${fileName}.ts`
);
this.createFile(entityPath, entity);
// // 生成Controller
// 生成Controller
const controllerPath = pathUtil.join(
basePath,
'modules',
@ -278,9 +277,48 @@ export class BaseSysMenuService extends BaseService {
'admin',
`${fileName}.ts`
);
this.createConfigFile(module);
this.createFile(entityPath, entity);
this.createFile(controllerPath, controller);
}
/**
*
* @param module
*/
async createConfigFile(module: string) {
const basePath = this.app.getBaseDir();
const configFilePath = pathUtil.join(
basePath,
'modules',
module,
'config.ts'
);
if (!fs.existsSync(configFilePath)) {
const data = `import { ModuleConfig } from '@cool-midway/core';
/**
*
*/
export default () => {
return {
// 模块名称
name: 'xxx',
// 模块描述
description: 'xxx',
// 中间件,只对本模块有效
middlewares: [],
// 中间件,全局有效
globalMiddlewares: [],
// 模块加载顺序默认为0值越大越优先加载
order: 0,
} as ModuleConfig;
};
`;
await this.createFile(configFilePath, data);
}
}
/**
*
* @param controller