重构打包脚本

This commit is contained in:
aixianling
2022-04-20 11:35:08 +08:00
parent c239698292
commit c04c89507c
2 changed files with 19 additions and 16 deletions

View File

@@ -87,27 +87,29 @@ const init = () => {
const generateMain = project => {
const getApps = new Promise(resolve => {
const appLib = path.join(__dirname, project.toString(), 'apps.import.json')
fsExtra.readJson(appLib, (err, data) => {
chalkTag.info(project + '加载业务应用配置...')
fsExtra.emptyDirSync(`project/${project}/apps`)
let apps = []
if (data) {
fsExtra.emptyDirSync(`project/${project}/apps`)
chalkTag.info(project + '加载业务应用配置...')
Promise.all([
findApp(`src/project/${project}`, f => apps.push(f)),
findApp('src/mods', file => apps.push(file))
]).then(() => {
Promise.all(Object.keys(data).map(e => {
let app = [...new Set(apps)].find(s => s.indexOf(e) > -1)
if (app) {
return copyFiles(`project/${project}/apps/${e}`, app)
findApp(`project/${project}`, file => {
let reg = new RegExp(/.+(App[^\\\/]+)$/)
if (reg.test(file)) {
data[file.replace(reg, '$1')] = file.replace(reg, '$1')
}
})).then(() => {
chalkTag.done(project + '业务应用加载完成')
resolve()
})
return apps.push(file)
}),
findApp('src/mods', file => apps.push(file))
]).then(() => Promise.all(Object.keys(data).map(e => {
let app = [...new Set(apps)].find(s => s.indexOf(e) > -1)
if (app) {
return copyFiles(`project/${project}/apps/${e}`, app)
}
}))).then(() => {
chalkTag.done(project + '业务应用加载完成')
resolve()
})
} else {
chalkTag.done(project + '业务应用无打包')
resolve()

View File

@@ -2,7 +2,8 @@
"name": "@dvcp-wechat-apps/sanjianxi",
"version": "1.0.0",
"files": [
"apps"
"apps",
"static"
],
"dependencies": {
}