2024-10-12 16:17:37 +08:00
|
|
|
const axios = require('axios')
|
|
|
|
|
const {fsExtra, copyFiles} = require("./tools");
|
|
|
|
|
const getBuildConfig = id => {
|
2024-10-17 15:54:07 +08:00
|
|
|
axios.post('http://192.168.1.87:12525/ns/node/custom/detail', null, {params: {id}}).then(res => {
|
2024-10-12 16:17:37 +08:00
|
|
|
if (res?.data) {
|
|
|
|
|
const config = res.data.data
|
|
|
|
|
fsExtra.outputJson('src/config.json', config.extra)
|
|
|
|
|
createPages(config)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const createPages = (config = {}) => {
|
|
|
|
|
fsExtra.emptyDir("src/apps", err => {
|
|
|
|
|
if (!err) {
|
|
|
|
|
const {customPath, appList} = config
|
|
|
|
|
const stdApps = {}
|
|
|
|
|
appList.filter(e => !/project/.test(e.id))?.forEach(e => {
|
|
|
|
|
const paths = e.libPath.split('/').filter(Boolean) || []
|
|
|
|
|
paths.pop()
|
|
|
|
|
stdApps[paths.join("/")] = 1
|
|
|
|
|
})
|
|
|
|
|
Promise.all([
|
|
|
|
|
copyFiles("src/apps/core", "packages/core"),
|
|
|
|
|
copyFiles("src/apps/custom", `project/${customPath}`),
|
|
|
|
|
...Object.keys(stdApps).map(e => copyFiles(`src/apps/${e.replace(/^packages[\\\/]/, '')}`, e)),
|
|
|
|
|
]).then(() => fsExtra.ensureFile("src/apps/actions.js"))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const start = () => {
|
|
|
|
|
const buildId = process.argv[2] || 'f670cc46-7cf7-4a0f-86ee-3077044c0b17'
|
|
|
|
|
getBuildConfig(buildId)
|
|
|
|
|
}
|
|
|
|
|
start()
|