Smail/deploy/prepare-frontend.mjs
smail f60d3b0880
Some checks are pending
Security Checks / security (push) Waiting to run
整理前后端与测试构建目录并完善配置和安全引导
统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
2026-09-05 19:19:52 +08:00

17 lines
882 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { cp, mkdir, readdir, readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
const root = fileURLToPath(new URL('../', import.meta.url))
const plugin = process.argv[2] === 'telegram'
const source = path.join(root, 'out', ...(plugin ? ['plugins', 'telegram-ui'] : ['frontend']))
const target = path.join(root, ...(plugin ? ['plugins', 'pmail_telegram_push', 'hook', 'dist'] : ['backend', 'listen', 'http_server', 'dist']))
// Go 嵌入文件不能越过模块目录;这里仅同步构建中间文件,不保存运行数据。
await readFile(path.join(source, 'index.html'))
await mkdir(target, { recursive: true })
for (const entry of await readdir(source)) {
await cp(path.join(source, entry), path.join(target, entry), { recursive: true })
}
console.log('前端产物已生成至 out,并同步 Go 嵌入目录。')