feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as a monorepo subdirectory under desktop/. Source only — node_modules, dist, Cargo target and the upstream .git history are excluded. desktop/ keeps its own independent Cargo workspace (desktop/src-tauri with crates/*); it is not part of the backend boosapi crate, so a `cargo check` at the metapi root still compiles only the backend. Build the desktop app from desktop/src-tauri per desktop/README.md. Note: app icons are still placeholder assets pending the final BoosAPI logo. The updater signing keys live outside the repo and are not included.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
|
||||
const root = process.cwd()
|
||||
const enDir = path.join(root, 'docs', 'guide')
|
||||
const zhDir = path.join(root, 'docs', 'zh', 'guide')
|
||||
|
||||
async function ensureDir(d) {
|
||||
try {
|
||||
await fs.mkdir(d, { recursive: true })
|
||||
}
|
||||
catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
function toZhFilename(file) {
|
||||
return file
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await ensureDir(zhDir)
|
||||
const files = await fs.readdir(enDir)
|
||||
const mdFiles = files.filter(f => f.endsWith('.md'))
|
||||
|
||||
const created = []
|
||||
for (const f of mdFiles) {
|
||||
const enPath = path.join(enDir, f)
|
||||
const zhPath = path.join(zhDir, toZhFilename(f))
|
||||
// decide whether to create or refresh placeholder
|
||||
let shouldWrite = false
|
||||
try {
|
||||
await fs.access(zhPath)
|
||||
const cur = await fs.readFile(zhPath, 'utf8')
|
||||
if (/中文占位|自动生成占位/.test(cur)) {
|
||||
shouldWrite = true // refresh old placeholder with improved template
|
||||
}
|
||||
else {
|
||||
// translation exists; skip
|
||||
continue
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// file doesn't exist -> create placeholder
|
||||
shouldWrite = true
|
||||
}
|
||||
|
||||
if (!shouldWrite)
|
||||
continue
|
||||
const enContent = await fs.readFile(enPath, 'utf8')
|
||||
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
||||
const titleMatch = enContent.match(/^#\s+(.+)$/m)
|
||||
const title = titleMatch ? titleMatch[1].trim() : path.basename(f, '.md')
|
||||
|
||||
// include a short excerpt to help translators
|
||||
// Use a robust, non-regex approach to extract a short excerpt from the
|
||||
// section content to avoid regexp backtracking issues flagged by eslint.
|
||||
const startIdx = titleMatch ? enContent.indexOf(titleMatch[0]) + titleMatch[0].length : 0
|
||||
const excerptRaw = enContent.slice(startIdx).trim().split('\n').slice(0, 6).join(' ')
|
||||
const excerpt = excerptRaw.substring(0, 300).trim()
|
||||
|
||||
const placeholder = `# ${title}(中文占位)\n\n`
|
||||
+ `> 原文节选(仅供翻译参考):\n\n${
|
||||
excerpt ? `> ${excerpt.replace(/\n/g, '\n> ')}\n\n` : ''
|
||||
}## 说明\n\n此页面为中文占位,原文(English):/guide/${f}。\n\n`
|
||||
+ `- [ ] 翻译标题和正文\n`
|
||||
+ `- [ ] 本地化示例中的代码注释\n`
|
||||
+ `- [ ] 检查链接并改为 /zh/ 前缀(如有)\n`
|
||||
+ `\n`
|
||||
+ `如果你愿意贡献中文翻译,请参考翻译指南并提交 PR:/guide/translation\n\n`
|
||||
+ `---\n\n`
|
||||
+ `> 自动生成占位:将原文翻译并替换此文件的内容即可。`
|
||||
|
||||
await fs.writeFile(zhPath, placeholder, 'utf8')
|
||||
created.push(zhPath)
|
||||
}
|
||||
|
||||
if (created.length) {
|
||||
console.log('Created placeholders for missing zh docs:')
|
||||
created.forEach(f => console.log(' -', f))
|
||||
}
|
||||
else {
|
||||
console.log('All zh docs exist. Nothing to create.')
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user