mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 16:17:00 +08:00
部分描述
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { execaCommand } from 'execa'
|
||||
import path from 'path'
|
||||
|
||||
import fsExtra from 'fs-extra'
|
||||
const { existsSync, remove, copy } = fsExtra
|
||||
const cwd = process.cwd()
|
||||
@@ -12,22 +13,22 @@ const goProjectPath = path.resolve(cwd, '../server')
|
||||
async function build_go() {
|
||||
await execaCommand('swag fmt', {
|
||||
stdio: 'inherit',
|
||||
encoding: 'utf-8',
|
||||
encoding: 'utf8',
|
||||
cwd: goProjectPath
|
||||
})
|
||||
await execaCommand('swag init', {
|
||||
stdio: 'inherit',
|
||||
encoding: 'utf-8',
|
||||
encoding: 'utf8',
|
||||
cwd: goProjectPath
|
||||
})
|
||||
await execaCommand('goreleaser release --snapshot --clean', {
|
||||
stdio: 'inherit',
|
||||
encoding: 'utf-8',
|
||||
encoding: 'utf8',
|
||||
cwd: goProjectPath
|
||||
})
|
||||
}
|
||||
async function build_frontend() {
|
||||
await execaCommand('vite build', { stdio: 'inherit', encoding: 'utf-8', cwd })
|
||||
await execaCommand('npm run prod', { stdio: 'inherit', encoding: 'utf8', cwd })
|
||||
if (existsSync(releasePath)) {
|
||||
await remove(releasePath)
|
||||
}
|
||||
@@ -35,12 +36,17 @@ async function build_frontend() {
|
||||
try {
|
||||
await copyFile(distPath, releasePath)
|
||||
} catch (error) {
|
||||
console.log(`\n ${error}`)
|
||||
console.log(error)
|
||||
}
|
||||
console.log(`文件已复制 ==> ${releaseRelativePath}`)
|
||||
}
|
||||
async function build() {
|
||||
await Promise.allSettled([build_go(), build_frontend()])
|
||||
try {
|
||||
console.log('开始打包')
|
||||
await Promise.allSettled([build_go(), build_frontend()])
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
function copyFile(sourceDir, targetDir) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
Reference in New Issue
Block a user