部分描述

This commit is contained in:
xiangheng
2024-06-13 14:22:19 +08:00
parent 4a5c2853e5
commit 1bde62f68a
4 changed files with 21 additions and 26 deletions

View File

@@ -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) => {