持续集成分支
7
.gitignore
vendored
@@ -23,5 +23,8 @@ yarn-error.log*
|
||||
*.sw*
|
||||
/package-lock.json
|
||||
/.hbuilderx/launch.json
|
||||
/src/pages.json
|
||||
/src/config.json
|
||||
src/pages.json
|
||||
src/config.json
|
||||
src/apps
|
||||
src/common/config.json
|
||||
src/manifest.json
|
||||
|
||||
5
.npmrc
@@ -1,5 +1,4 @@
|
||||
registry=http://192.168.1.87:4873/
|
||||
registry=http://registry.npmmirror.com
|
||||
email=aixianling@sinoecare.com
|
||||
always-auth=true
|
||||
package-lock=false
|
||||
//192.168.1.87:4873/:_auth="YWRtaW46YWRtaW4xMjM="
|
||||
legacy-peer-deps=true
|
||||
|
||||
72
bin/build.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const axios = require("axios");
|
||||
const {copyFiles, fsExtra} = require("./tools");
|
||||
const manifest = {
|
||||
name: "base-wxcp",
|
||||
description: "企业微信应用",
|
||||
versionName: "1.0.0",
|
||||
versionCode: "100",
|
||||
transformPx: true,
|
||||
h5: {
|
||||
title: "加载中",
|
||||
template: "template.h5.html",
|
||||
router: {
|
||||
mode: "history",
|
||||
base: ""
|
||||
},
|
||||
devServer: {
|
||||
disableHostCheck: true,
|
||||
port: "80",
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://192.168.1.87:9000",
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
"^/api": "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
optimization: {
|
||||
preload: true,
|
||||
treeShaking: {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
sdkConfigs: {
|
||||
maps: {
|
||||
qqmap: {
|
||||
key: "RWWBZ-64BEJ-MVLFJ-FTHLQ-JTR6J-SAB2S"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const generate = (extra = {}) => {
|
||||
return Promise.all([
|
||||
// fsExtra.outputJson('src/common/config.json', extra),
|
||||
fsExtra.outputJson('src/manifest.json', manifest),
|
||||
])
|
||||
}
|
||||
module.exports = id => {
|
||||
return axios.post("http://192.168.1.87:12525/node/custom/detail", null, {
|
||||
params: {id}
|
||||
}).then(res => {
|
||||
if (res?.data?.data) {
|
||||
const {customPath, appList, extra} = res.data.data
|
||||
manifest.h5.router.base = extra.base || ""
|
||||
manifest.h5.publicPath = extra.base || "/"
|
||||
let tasks = []
|
||||
return generate(extra)
|
||||
.then(() => customPath ? copyFiles('src/apps', 'library/project/' + customPath) : fsExtra.emptyDir('src/apps'))
|
||||
.then(() => {
|
||||
appList?.map(e => {
|
||||
if (!/project/.test(e.id))
|
||||
tasks.push({dir: 'src/apps/' + e.name, source: 'library/apps/' + e.name})
|
||||
})
|
||||
return Promise.all([
|
||||
copyFiles("src/components/pages", 'library/components/pages'), ...tasks.map(e => copyFiles(e.dir, e.source))])
|
||||
}).then(() => res.data.data)
|
||||
} else Promise.reject("无法找到项目")
|
||||
})
|
||||
}
|
||||
5
bin/extraBuild.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const {fsExtra} = require("./tools");
|
||||
const copyStaticFiles = () => {
|
||||
fsExtra.copy("public/oauth.html", "dist/build/h5/oauth.html")
|
||||
}
|
||||
copyStaticFiles()
|
||||
80
bin/pages.js
Normal file
@@ -0,0 +1,80 @@
|
||||
const {fs, chalkTag, fsExtra, findPages} = require("./tools");
|
||||
const init = require("./build")
|
||||
|
||||
/**
|
||||
* pages.json对象
|
||||
* @type {{globalStyle: {pageOrientation: string, navigationStyle: string}, pages: [{path: string, style: {navigationBarTitleText: string}},{path: string, style: {navigationBarTitleText: string}}], customLogin: *[], easycom: {"^u-(.*)": string, "^(Ai|V)(.*)": string}}}
|
||||
*/
|
||||
const json = {
|
||||
easycom: {
|
||||
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
|
||||
"^(Ai|V)(.*)": "library/components/$1$2.vue",
|
||||
},
|
||||
pages: [
|
||||
{path: 'pages/loading', style: {navigationBarTitleText: "欢迎使用"}},
|
||||
{path: 'pages/auth', style: {navigationBarTitleText: "正在授权"}},
|
||||
],
|
||||
globalStyle: {
|
||||
pageOrientation: "auto",
|
||||
navigationStyle: "custom"
|
||||
},
|
||||
customLogin: []
|
||||
}
|
||||
/**
|
||||
* 生成页面信息
|
||||
* @param app 页面
|
||||
* @param file 文件路径
|
||||
*/
|
||||
const getFileInfo = (app, file) => {
|
||||
let vue = fs.readFileSync(file).toString()
|
||||
if (/appName/.test(vue)) {
|
||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
||||
app.label = appName.replace(/(appName:|["'])/g, '').trim()
|
||||
}
|
||||
if (/customLogin/.test(vue)) {
|
||||
json.customLogin.push(app.name)
|
||||
}
|
||||
if (/customNavigation/.test(vue)) {
|
||||
app.style = {navigationStyle: "custom"}
|
||||
} else app.style = {navigationBarTitleText: app.label}
|
||||
if (/enablePullDownRefresh/.test(vue)) {
|
||||
app.style.enablePullDownRefresh = true
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 生成pages.json
|
||||
*/
|
||||
const generatePages = config => {
|
||||
chalkTag.info('开始生成配置文件...')
|
||||
Promise.all([
|
||||
findPages('src/components/pages', file => {
|
||||
if (/[^\\\/]+\.vue$/g.test(file)) {
|
||||
let app = {
|
||||
path: file.replace(/^src[\\\/](.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
getFileInfo(app, file)
|
||||
return json.pages.push(app)
|
||||
}
|
||||
}),
|
||||
findPages('src/apps', file => {
|
||||
if (/.*[\\\/].+[\\\/]App[^\\\/]+[\\\/][^\\\/]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*[\\\/]([^\\\/]+).vue/g, '$1'),
|
||||
path: file.replace(/^src[\\\/](.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
getFileInfo(app, file)
|
||||
return app.name == config?.extra?.homePage ? json.pages.unshift(app) : json.pages.push(app)
|
||||
}
|
||||
})
|
||||
]).then(() => {
|
||||
fsExtra.outputJson('src/pages.json', json, () => {
|
||||
chalkTag.done('生成pages.json')
|
||||
})
|
||||
fsExtra.outputJson('src/common/config.json', {...config.extra, customLoginPages: json.customLogin}, () => {
|
||||
chalkTag.done('生成config.json')
|
||||
})
|
||||
})
|
||||
}
|
||||
const id = process.argv?.[2] || "8d175659-80d7-47ff-9291-c48e811b9237"
|
||||
init(id)
|
||||
.then(config => generatePages(config))
|
||||
87
bin/serve.js
@@ -1,87 +0,0 @@
|
||||
const {chalkTag, findPages, fs, fsExtra} = require("./tools");
|
||||
|
||||
let apps = {list: [], desc: "用于产品库主页面获取应用使用", type: 'wxwork'}
|
||||
const getFileInfo = (app, file) => {
|
||||
let vue = fs.readFileSync(file).toString()
|
||||
//获取模块名称
|
||||
if (/appName/.test(vue)) {
|
||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
||||
app.label = appName.replace(/(appName:|["'])/g, '').trim()
|
||||
}
|
||||
// 处理页面自定义选项
|
||||
if (/customNavigation/.test(vue)) {
|
||||
app.style = {navigationStyle: "custom"}
|
||||
} else app.style = {navigationBarTitleText: app.label}
|
||||
if (/enablePullDownRefresh/.test(vue)) {
|
||||
app.style.enablePullDownRefresh = true
|
||||
}
|
||||
// 处理和统计模块应用数据
|
||||
if (/^App/.test(app.name) && app.label) {
|
||||
let {name, label} = app,
|
||||
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`)
|
||||
return apps.list.push({
|
||||
id: file.replace(/\.\/?(vue)?/g, '').replace(/[\\\/]/g, '_'),
|
||||
name,
|
||||
label,
|
||||
path,
|
||||
libPath: file.replace(/[\\\/]/g, '/').replace(/^src(\/.+)\.vue/, '$1'),
|
||||
type: 'wxwork'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const start = () => {
|
||||
chalkTag.info('开始生成pages.json...')
|
||||
let json = {
|
||||
easycom: {
|
||||
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
|
||||
"^(Ai|V)(.*)": "@/components/$1$2.vue"
|
||||
},
|
||||
pages: [
|
||||
{path: 'pages/loading'},
|
||||
{path: 'pages/login'}
|
||||
],
|
||||
globalStyle: {
|
||||
pageOrientation: "auto",
|
||||
navigationStyle: "custom"
|
||||
}
|
||||
}
|
||||
Promise.all([
|
||||
findPages('src/components/pages', file => {
|
||||
if (/.+\\[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
getFileInfo(app, file)
|
||||
return json.pages.push(app)
|
||||
}
|
||||
}),
|
||||
findPages('src/apps', file => {
|
||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
||||
path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
getFileInfo(app, file)
|
||||
return json.pages.push(app)
|
||||
}
|
||||
}),
|
||||
findPages('src/project', file => {
|
||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
||||
path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
getFileInfo(app, file)
|
||||
return json.pages.push(app)
|
||||
}
|
||||
})
|
||||
]).then(() => {
|
||||
fsExtra.outputJson('src/config.json', {apps: apps.list})
|
||||
fsExtra.outputJson('src/pages.json', json, () => {
|
||||
chalkTag.done('生成pages.json')
|
||||
})
|
||||
})
|
||||
}
|
||||
start();
|
||||
68
bin/sync.js
@@ -1,68 +0,0 @@
|
||||
const {chalkTag, fs, findPages} = require("./tools");
|
||||
const axios = require("axios");
|
||||
|
||||
let apps = {list: [], desc: "用于产品库主页面获取应用使用", type: 'wxwork'}
|
||||
const saveApps = app => {
|
||||
if (app.list.length > 0) {
|
||||
return 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 => {
|
||||
chalkTag.error(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
const getFileInfo = (app, file) => {
|
||||
let vue = fs.readFileSync(file).toString()
|
||||
if (/appName/.test(vue)) {
|
||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
||||
app.label = appName.replace(/(appName:|["'])/g, '').trim()
|
||||
if (/customNavigation/.test(vue)) {
|
||||
app.style = {navigationStyle: "custom"}
|
||||
} 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`)
|
||||
return apps.list.push({
|
||||
id: file.replace(/\.\/?(vue)?/g, '').replace(/[\\\/]/g, '_'),
|
||||
name,
|
||||
label,
|
||||
path,
|
||||
libPath: file.replace(/\\\//g, '/').replace(/^src(\/.+)\.vue/, '$1'),
|
||||
type: 'wxwork'
|
||||
})
|
||||
}
|
||||
}
|
||||
const start = () => {
|
||||
chalkTag.info('开始同步数据到数据库')
|
||||
Promise.all([
|
||||
findPages('src/components/pages', file => {
|
||||
if (/.+[\\\/][^\\\/]+[\\\/][^\\\/]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
path: file.replace(/^src[\\\/](.*).vue/g, '$1').replace(/[\\\/]/g, '/')
|
||||
}
|
||||
return getFileInfo(app, file)
|
||||
}
|
||||
}),
|
||||
findPages('src/apps', file => {
|
||||
if (/.+[\\\/]App[^\\\/]+[\\\/][^\\\/]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*[\\\/]([^\\\/]+).vue/g, '$1'),
|
||||
path: file.replace(/^src[\\\/](.*).vue/g, '$1').replace(/[\\\/]/g, '/')
|
||||
}
|
||||
return getFileInfo(app, file)
|
||||
}
|
||||
}),
|
||||
findPages('src/project', file => {
|
||||
if (/.+[\\\/]App[^\\\/]+[\\\/][^\\\/]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*[\\\/]([^\\\/]+).vue/g, '$1'),
|
||||
path: file.replace(/^src[\\\/](.*).vue/g, '$1').replace(/[\\\/]/g, '/')
|
||||
}
|
||||
return getFileInfo(app, file)
|
||||
}
|
||||
})
|
||||
]).then(() => saveApps(apps)).finally(() => chalkTag.done('同步完成'))
|
||||
}
|
||||
start()
|
||||
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 979 B After Width: | Height: | Size: 979 B |
|
Before Width: | Height: | Size: 795 B After Width: | Height: | Size: 795 B |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 577 B |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 795 B After Width: | Height: | Size: 795 B |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
|
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 288 B |
|
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 762 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 866 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 757 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 892 B After Width: | Height: | Size: 892 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 757 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 814 B After Width: | Height: | Size: 814 B |
|
Before Width: | Height: | Size: 793 B After Width: | Height: | Size: 793 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |