调整同步仓库的策略
This commit is contained in:
24
bin/serve.js
24
bin/serve.js
@@ -1,5 +1,5 @@
|
||||
const {chalkTag, findPages, fs, fsExtra} = require("./tools");
|
||||
const axios = require("axios");
|
||||
|
||||
let apps = {list: [], desc: "用于产品库主页面获取应用使用", type: 'wxwork'}
|
||||
const getFileInfo = (app, file) => {
|
||||
let vue = fs.readFileSync(file).toString()
|
||||
@@ -11,27 +11,9 @@ const getFileInfo = (app, file) => {
|
||||
} else
|
||||
app.style = {navigationBarTitleText: app.label}
|
||||
}
|
||||
if (/^App/.test(app.name) && app.label) {
|
||||
let {name, label} = app,
|
||||
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`)
|
||||
apps.list.push({
|
||||
id: file.replace(/\.\/?(vue)?/g, '').replace(/[\\\/]/g, '_'),
|
||||
name,
|
||||
label,
|
||||
path,
|
||||
libPath: file.replace(/\\/g, '/').replace(/^src(\/.+)\.vue/, '$1'),
|
||||
type: 'wxwork'
|
||||
})
|
||||
}
|
||||
}
|
||||
const saveApps = app => {
|
||||
if (app.list.length > 0) {
|
||||
axios.post("http://192.168.1.87:12525/node/wechatapps/addOrUpdate", app, {timeout: 1000}).then(res => {
|
||||
if (res.data.code == 0) chalkTag.done("产品库目录已同步至后台数据库...")
|
||||
}).catch(err => 0).finally(() => fsExtra.outputJson('src/config.json', {apps: app.list}))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const start = () => {
|
||||
chalkTag.info('开始生成pages.json...')
|
||||
let json = {
|
||||
@@ -79,7 +61,7 @@ const start = () => {
|
||||
}
|
||||
})
|
||||
]).then(() => {
|
||||
saveApps(apps)
|
||||
fsExtra.outputJson('src/config.json', {apps: apps.list})
|
||||
fsExtra.outputJson('src/pages.json', json, () => {
|
||||
chalkTag.done('生成pages.json')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user