Browse Source

Pull request #3405: KERNEL-14076 feat: 脚本修复bug,有的没有xtype,null 也是obj类型

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '7129532c68ac3d954e853979cbfcd047caaf8412':
  KERNEL-14076 feat: 脚本修复bug,有的没有xtype,null 也是obj类型
es6
treecat-罗群 2 years ago
parent
commit
ecf38254e5
  1. 18
      es6.js

18
es6.js

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

Loading…
Cancel
Save