make:domain不再依赖config/externalLib.json
This commit is contained in:
parent
95adca90d3
commit
ec4ce79d1f
|
|
@ -1,6 +1,7 @@
|
|||
const { existsSync } = require('fs');
|
||||
const { existsSync, readFileSync } = require('fs');
|
||||
const { removeSync } = require('fs-extra');
|
||||
const { join } = require('path');
|
||||
const ts = require('typescript');
|
||||
const {
|
||||
buildSchema,
|
||||
analyzeEntities,
|
||||
|
|
@ -9,15 +10,17 @@ const {
|
|||
// todo,这里还是很奇怪,要把src/entites的依赖给去掉
|
||||
analyzeEntities(`${process.cwd()}/node_modules/oak-domain/src/entities`, 'oak-domain/lib/entities');
|
||||
// 从config中读出相应依赖
|
||||
const externalLibFile = join(process.cwd(), 'src', 'config', 'oakExternalLib.json');
|
||||
if (existsSync(externalLibFile)) {
|
||||
const exteralLibs = require(externalLibFile);
|
||||
exteralLibs.forEach(
|
||||
const depConfigTsFile = join(process.cwd(), 'src', 'configuration', 'dependency.ts');
|
||||
if (existsSync(depConfigTsFile)) {
|
||||
const result = ts.transpileModule(readFileSync(depConfigTsFile, 'utf-8'), { compilerOptions: { module: ts.ModuleKind.CommonJS } });
|
||||
const dependencies = eval(result.outputText);
|
||||
dependencies.forEach(
|
||||
(ele) => {
|
||||
analyzeEntities(`${process.cwd()}/node_modules/${ele}/src/entities`, `${ele}/lib/entities`);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
analyzeEntities(join(process.cwd(), 'src', 'entities'));
|
||||
removeSync(join(process.cwd(), 'src', 'oak-app-domain'));
|
||||
buildSchema(join(process.cwd(), 'src', 'oak-app-domain'));
|
||||
Loading…
Reference in New Issue