|
|
|
@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
|
|
const path = require("path"); |
|
|
|
|
const prettier = require("prettier"); |
|
|
|
|
const { exec } = require("child_process"); |
|
|
|
|
const { search, initDepts } = require("./es6.xtype"); |
|
|
|
|
const { search, initDepts, depts } = require("./es6.xtype"); |
|
|
|
|
|
|
|
|
|
async function fix(path) { |
|
|
|
|
new Promise(res => { |
|
|
|
@ -42,28 +42,42 @@ const target = [
|
|
|
|
|
"remove", |
|
|
|
|
"createItems", |
|
|
|
|
"makeArrayByArray", |
|
|
|
|
"VerticalAlign", |
|
|
|
|
"transformItems", |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// 加载模块
|
|
|
|
|
const loader = { |
|
|
|
|
G: { "@/core": { shortcut: true } }, |
|
|
|
|
async load(srcName, module) { |
|
|
|
|
load(srcName, module) { |
|
|
|
|
const G = loader.G; |
|
|
|
|
if (target.indexOf(module) >= 0) { |
|
|
|
|
G["@/core"][module] = true; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (module.startsWith('"bi.')) { |
|
|
|
|
const key = search(srcName, module); |
|
|
|
|
if (key) { |
|
|
|
|
if (!G[key]) { |
|
|
|
|
G[key] = {}; |
|
|
|
|
} |
|
|
|
|
const clzName = depts[module].clzName; |
|
|
|
|
G[key][clzName] = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const key = search(srcName, module); |
|
|
|
|
if (key) { |
|
|
|
|
if (!G[key]) { |
|
|
|
|
G[key] = {}; |
|
|
|
|
return !!key; |
|
|
|
|
} else { |
|
|
|
|
const key = search(srcName, module); |
|
|
|
|
if (key) { |
|
|
|
|
if (!G[key]) { |
|
|
|
|
G[key] = {}; |
|
|
|
|
} |
|
|
|
|
G[key][module] = true; |
|
|
|
|
} |
|
|
|
|
G[key][module] = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return !!key; |
|
|
|
|
return !!key; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -74,7 +88,24 @@ async function handleFile(srcName) {
|
|
|
|
|
|
|
|
|
|
const result = /BI\.(.*?)\s\=\sBI\.inherit\(/.exec(sourceCode); |
|
|
|
|
if (!result) { |
|
|
|
|
console.log(`可能是已经es6过了 ${srcName}`); |
|
|
|
|
console.log(`可能是已经es6过了 ${srcName}, 尝试替换 xtype`); |
|
|
|
|
// 处理 xtype
|
|
|
|
|
|
|
|
|
|
// 尝试对 xtype 进行替换
|
|
|
|
|
const noXtypeCode = sourceCode.replace(/"bi\.(.*?)"/g, matchedSentence => { |
|
|
|
|
const loadSuccess = loader.load(srcName, matchedSentence); |
|
|
|
|
if (loadSuccess) { |
|
|
|
|
const clzName = depts[matchedSentence].clzName; |
|
|
|
|
|
|
|
|
|
return `${clzName}.xtype`; |
|
|
|
|
} else { |
|
|
|
|
console.log(`加载 ${matchedSentence}失败`); |
|
|
|
|
|
|
|
|
|
return matchedSentence; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
fs.writeFileSync(srcName, noXtypeCode); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -157,7 +188,21 @@ async function handleFile(srcName) {
|
|
|
|
|
if (loadSuccess) { |
|
|
|
|
return target + end; |
|
|
|
|
} else { |
|
|
|
|
console.log(`加载 ${target}失败`); |
|
|
|
|
console.log(`BI.xxx 加载 ${target}失败`); |
|
|
|
|
|
|
|
|
|
return matchedSentence; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 尝试对 xtype 进行替换
|
|
|
|
|
f = f.replace(/"bi\.(.*?)"/g, matchedSentence => { |
|
|
|
|
const loadSuccess = loader.load(srcName, matchedSentence); |
|
|
|
|
if (loadSuccess) { |
|
|
|
|
const clzName = depts[matchedSentence].clzName; |
|
|
|
|
|
|
|
|
|
return `${clzName}.xtype`; |
|
|
|
|
} else { |
|
|
|
|
console.log(`加载 ${matchedSentence}失败`); |
|
|
|
|
|
|
|
|
|
return matchedSentence; |
|
|
|
|
} |
|
|
|
|