持续集成分支

This commit is contained in:
aixianling
2024-10-10 16:04:11 +08:00
parent f35c272a19
commit 00b2dbb4a4
38 changed files with 2222 additions and 111 deletions

36
bin/scanApps.js Normal file
View File

@@ -0,0 +1,36 @@
const {chalkTag, findApp, fs, fsExtra} = require("./tools");
const compiler = require('vue-template-compiler')
const getAppInfo = (file, apps) => {
if (/[\\\/](App[A-Z][^\\\/]+)\.vue$/g.test(file)) {
const name = file.replace(/.+[\\\/](App[^\\\/]+)\.vue$/, '$1'),
source = fs.readFileSync(file).toString(),
parsed = compiler.parseComponent(source),
script = parsed.script?.content || "",
label = script.match(/label:[^,]+/)?.[0]?.replace(/.+["']([^"']+).+/, '$1')
const paths = file.split(/[\\\/]/)
apps.push({
id: file.replace(/\.vue$/, '').replace(/[\\\/]/g, '_'),
label: label || name,
path: `/${file.replace(/\.vue$/, '').replace(/[\\\/]/g, '/')}`,
workspace: paths.at(0),
esm: file.replace(/[\\\/]/g, '/'),
name
})
}
}
const start = () => {
chalkTag.info("开始扫描库工程...")
const list = []
Promise.all([
findApp('packages', app => getAppInfo(app, list)),
findApp('project', app => getAppInfo(app, list)),
]).then(() => {
fsExtra.outputFile('examples/router/apps.js', `export default [${list.map(e => {
const {name, label, path, esm} = e
return `{name:"${name}",label:"${label}",path:"${path}",component:()=>import("@${esm}")}`
}).join(',\n')}]`)
chalkTag.done("扫描完毕")
})
}
start()