|
|
@ -13,6 +13,10 @@ const ConflictImport = []; |
|
|
|
const CircularDependency = []; |
|
|
|
const CircularDependency = []; |
|
|
|
|
|
|
|
|
|
|
|
function objHaveFunction(obj) { |
|
|
|
function objHaveFunction(obj) { |
|
|
|
|
|
|
|
if (obj === null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Object.keys(obj).some(key => { |
|
|
|
return Object.keys(obj).some(key => { |
|
|
|
const value = obj[key]; |
|
|
|
const value = obj[key]; |
|
|
|
if (typeof value === "object") { |
|
|
|
if (typeof value === "object") { |
|
|
@ -105,6 +109,7 @@ async function handleFile(srcName) { |
|
|
|
const sourceCode = fs.readFileSync(srcName).toString(); |
|
|
|
const sourceCode = fs.readFileSync(srcName).toString(); |
|
|
|
|
|
|
|
|
|
|
|
const result = /BI\.(.*?)\s=\sBI\.inherit\(/.exec(sourceCode); |
|
|
|
const result = /BI\.(.*?)\s=\sBI\.inherit\(/.exec(sourceCode); |
|
|
|
|
|
|
|
|
|
|
|
if (!result) { |
|
|
|
if (!result) { |
|
|
|
// console.log(`已经es6过,替换 xtype => ${srcName}`);
|
|
|
|
// console.log(`已经es6过,替换 xtype => ${srcName}`);
|
|
|
|
if (!/export class/.test(sourceCode)) { |
|
|
|
if (!/export class/.test(sourceCode)) { |
|
|
@ -167,11 +172,13 @@ async function handleFile(srcName) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let circle = false; |
|
|
|
let circle = false; |
|
|
|
// 处理循环依赖
|
|
|
|
// 处理循环依赖,base: ["@/case", "@/base", "@/widget"] 等于 base 不能直接引数组内的包
|
|
|
|
const forbiddenCrossRules = { |
|
|
|
const forbiddenCrossRules = { |
|
|
|
base: ["@/case", "@/base", "@/widget"], |
|
|
|
base: ["@/case", "@/base", "@/widget"], |
|
|
|
"case": ["@/case", "@/widget"], |
|
|
|
"case": ["@/case", "@/widget"], |
|
|
|
widget: ["@/widget"], |
|
|
|
widget: ["@/widget"], |
|
|
|
|
|
|
|
component: ["@/component"], |
|
|
|
|
|
|
|
core: ["@/core", "@base", "@/widget", "@/case"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const forbiddenKeys = []; |
|
|
|
const forbiddenKeys = []; |
|
|
@ -180,6 +187,7 @@ async function handleFile(srcName) { |
|
|
|
lodash.forEach(G, (depts, module) => { |
|
|
|
lodash.forEach(G, (depts, module) => { |
|
|
|
// 找出 rule
|
|
|
|
// 找出 rule
|
|
|
|
const packages = Object.keys(forbiddenCrossRules); |
|
|
|
const packages = Object.keys(forbiddenCrossRules); |
|
|
|
|
|
|
|
|
|
|
|
let key = packages.filter( |
|
|
|
let key = packages.filter( |
|
|
|
_package => srcName.indexOf(_package) >= 0, |
|
|
|
_package => srcName.indexOf(_package) >= 0, |
|
|
|
); |
|
|
|
); |
|
|
@ -407,6 +415,10 @@ async function handleFile(srcName) { |
|
|
|
M += `${f}\n`; |
|
|
|
M += `${f}\n`; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!collection.xtype) { |
|
|
|
|
|
|
|
delete G["@/core"].shortcut; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Object.keys(G).forEach(key => { |
|
|
|
Object.keys(G).forEach(key => { |
|
|
|
let moduleKey = key; |
|
|
|
let moduleKey = key; |
|
|
|
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { |
|
|
|
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { |
|
|
@ -429,9 +441,9 @@ async function handleFile(srcName) { |
|
|
|
const outputCode = ` |
|
|
|
const outputCode = ` |
|
|
|
${I} |
|
|
|
${I} |
|
|
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
${collection.xtype ? "@shortcut()" : ""} |
|
|
|
export class ${clzName} extends ${superName} { |
|
|
|
export class ${clzName} extends ${superName} { |
|
|
|
\tstatic xtype = "${collection.xtype}" |
|
|
|
${collection.xtype ? `static xtype = "${collection.xtype}"` : ""} |
|
|
|
|
|
|
|
|
|
|
|
${A} |
|
|
|
${A} |
|
|
|
|
|
|
|
|
|
|
|