|
@@ -7,21 +7,24 @@ const fs = require('fs')
|
|
|
const WEB_HOST = process.env.WEB_HOST || 'localhost:8080'
|
|
const WEB_HOST = process.env.WEB_HOST || 'localhost:8080'
|
|
|
const PUBLIC_HOST = WEB_HOST.startsWith('http') ? WEB_HOST : `https://${WEB_HOST}`
|
|
const PUBLIC_HOST = WEB_HOST.startsWith('http') ? WEB_HOST : `https://${WEB_HOST}`
|
|
|
|
|
|
|
|
|
|
+// 项目根目录(从 scripts/ 目录向上 4 级)
|
|
|
|
|
+const PROJECT_ROOT = path.resolve(__dirname, '../../../../')
|
|
|
|
|
+
|
|
|
// 小程序配置
|
|
// 小程序配置
|
|
|
const MINI_CONFIGS = {
|
|
const MINI_CONFIGS = {
|
|
|
enterprise: {
|
|
enterprise: {
|
|
|
name: '企业小程序',
|
|
name: '企业小程序',
|
|
|
appid: 'wx1e791ed2e0229eb8',
|
|
appid: 'wx1e791ed2e0229eb8',
|
|
|
- projectPath: path.resolve(__dirname, '../mini/dist/weapp/production'),
|
|
|
|
|
- privateKeyPath: path.resolve(__dirname, '../mini/certs/private.upload.key'),
|
|
|
|
|
|
|
+ projectPath: path.resolve(PROJECT_ROOT, 'mini/dist/weapp/production'),
|
|
|
|
|
+ privateKeyPath: path.resolve(PROJECT_ROOT, 'mini/certs/private.upload.key'),
|
|
|
buildCmd: 'cd mini && pnpm build:weapp',
|
|
buildCmd: 'cd mini && pnpm build:weapp',
|
|
|
distPath: 'dist/weapp',
|
|
distPath: 'dist/weapp',
|
|
|
},
|
|
},
|
|
|
talent: {
|
|
talent: {
|
|
|
name: '人才小程序',
|
|
name: '人才小程序',
|
|
|
appid: 'wx3c47dbce1ea7d43c',
|
|
appid: 'wx3c47dbce1ea7d43c',
|
|
|
- projectPath: path.resolve(__dirname, '../mini-talent/dist/weapp/production'),
|
|
|
|
|
- privateKeyPath: path.resolve(__dirname, '../mini-talent/certs/private.upload.key'),
|
|
|
|
|
|
|
+ projectPath: path.resolve(PROJECT_ROOT, 'mini-talent/dist/weapp/production'),
|
|
|
|
|
+ privateKeyPath: path.resolve(PROJECT_ROOT, 'mini-talent/certs/private.upload.key'),
|
|
|
buildCmd: 'cd mini-talent && pnpm build:weapp',
|
|
buildCmd: 'cd mini-talent && pnpm build:weapp',
|
|
|
distPath: 'dist/weapp',
|
|
distPath: 'dist/weapp',
|
|
|
},
|
|
},
|
|
@@ -33,7 +36,7 @@ const MINI_CONFIGS = {
|
|
|
function buildMiniProject(config) {
|
|
function buildMiniProject(config) {
|
|
|
console.log(`\n🔨 正在构建 ${config.name}...`)
|
|
console.log(`\n🔨 正在构建 ${config.name}...`)
|
|
|
try {
|
|
try {
|
|
|
- execSync(config.buildCmd, { stdio: 'inherit' })
|
|
|
|
|
|
|
+ execSync(config.buildCmd, { stdio: 'inherit', cwd: PROJECT_ROOT, shell: true })
|
|
|
console.log(`✅ ${config.name} 构建完成`)
|
|
console.log(`✅ ${config.name} 构建完成`)
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(`❌ ${config.name} 构建失败`)
|
|
console.error(`❌ ${config.name} 构建失败`)
|
|
@@ -107,7 +110,7 @@ async function previewDevProject(config, options) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 二维码保存目录
|
|
// 二维码保存目录
|
|
|
- const qrcodeDir = path.resolve(__dirname, '../web/public/qrcode')
|
|
|
|
|
|
|
+ const qrcodeDir = path.resolve(PROJECT_ROOT, 'web/public/qrcode')
|
|
|
const qrcodeFileName = `qrcode-${config.appid}.jpg`
|
|
const qrcodeFileName = `qrcode-${config.appid}.jpg`
|
|
|
const qrcodePath = path.join(qrcodeDir, qrcodeFileName)
|
|
const qrcodePath = path.join(qrcodeDir, qrcodeFileName)
|
|
|
|
|
|