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,20 @@
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
const distDir = path.resolve(__dirname, '..', 'dist')
|
||||
const typesDir = path.join(distDir, 'types')
|
||||
|
||||
function rewriteTypesEntry(content) {
|
||||
return content
|
||||
.replace(/from\s+(['"])\.\//g, 'from $1./types/')
|
||||
.replace(/import\((['"])\.\//g, 'import($1./types/')
|
||||
}
|
||||
|
||||
const sourcePath = path.join(typesDir, 'exports.d.ts')
|
||||
const targetPath = path.join(distDir, 'index.d.ts')
|
||||
|
||||
if (fs.existsSync(sourcePath)) {
|
||||
const content = rewriteTypesEntry(fs.readFileSync(sourcePath, 'utf8'))
|
||||
fs.writeFileSync(targetPath, content)
|
||||
console.log('Rewrote', targetPath, 'from', sourcePath)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
|
||||
const fromDir = path.resolve('dist-tw')
|
||||
const toDir = path.resolve('dist')
|
||||
|
||||
const fromCss = path.join(fromDir, 'index.tailwind.css')
|
||||
const toCss = path.join(toDir, 'index.tailwind.css')
|
||||
|
||||
async function main() {
|
||||
await fs.mkdir(toDir, { recursive: true })
|
||||
|
||||
try {
|
||||
await fs.copyFile(fromCss, toCss)
|
||||
}
|
||||
catch (err) {
|
||||
const e = err
|
||||
throw new Error(`[copy-tailwind-css] Missing ${fromCss}. Did the tailwind build run? (${e?.message || e})`)
|
||||
}
|
||||
|
||||
await fs.rm(fromDir, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -0,0 +1,51 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import dts from 'rollup-plugin-dts'
|
||||
|
||||
const fallbackInput = './dist/index.d.ts'
|
||||
const preferredInput = './dist/types/exports.d.ts'
|
||||
|
||||
const preferredExists = fs.existsSync(path.resolve(preferredInput))
|
||||
const fallbackExists = fs.existsSync(path.resolve(fallbackInput))
|
||||
|
||||
if (!preferredExists && !fallbackExists) {
|
||||
throw new Error(
|
||||
'No declaration entry found. Run the build first to emit declarations before running build:dts.',
|
||||
)
|
||||
}
|
||||
|
||||
const inputPath = preferredExists ? preferredInput : fallbackInput
|
||||
|
||||
export default [
|
||||
{
|
||||
input: inputPath,
|
||||
plugins: [
|
||||
{
|
||||
name: 'normalize-vue-demi-imports',
|
||||
transform(code, id) {
|
||||
if (!id.endsWith('.d.ts'))
|
||||
return null
|
||||
const rewritten = code
|
||||
.replace(/from\s+['"](?:\.\.\/)+vue-demi['"]/g, 'from \'vue-demi\'')
|
||||
.replace(/import\(\s*['"](?:\.\.\/)+vue-demi['"]\s*\)/g, 'import(\'vue-demi\')')
|
||||
if (rewritten === code)
|
||||
return null
|
||||
return { code: rewritten, map: null }
|
||||
},
|
||||
},
|
||||
dts({
|
||||
respectExternal: false,
|
||||
}),
|
||||
],
|
||||
external: [
|
||||
/^stream-markdown-parser(?:\/.*)?$/,
|
||||
/^vue-demi(?:\/.*)?$/,
|
||||
],
|
||||
output: [
|
||||
{
|
||||
file: 'dist/index.d.ts',
|
||||
format: 'es',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = resolve(__dirname, '..')
|
||||
const distDir = resolve(rootDir, 'dist')
|
||||
const esmEntry = resolve(distDir, 'index.js')
|
||||
const cjsEntry = resolve(distDir, 'index.cjs')
|
||||
|
||||
function assert(condition, message) {
|
||||
if (!condition)
|
||||
throw new Error(message)
|
||||
}
|
||||
|
||||
function read(file) {
|
||||
return readFileSync(file, 'utf8')
|
||||
}
|
||||
|
||||
assert(existsSync(esmEntry), `[validate-dist] Missing ESM entry: ${esmEntry}`)
|
||||
assert(existsSync(cjsEntry), `[validate-dist] Missing CJS entry: ${cjsEntry}`)
|
||||
|
||||
const esmSource = read(esmEntry)
|
||||
const cjsSource = read(cjsEntry)
|
||||
|
||||
function collectFiles(dir, files = []) {
|
||||
for (const name of readdirSync(dir)) {
|
||||
const fullPath = resolve(dir, name)
|
||||
const stat = statSync(fullPath)
|
||||
if (stat.isDirectory())
|
||||
collectFiles(fullPath, files)
|
||||
else
|
||||
files.push(fullPath)
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
assert(
|
||||
!/\bObject\.defineProperty\(exports\b|\bexports\./.test(esmSource),
|
||||
'[validate-dist] dist/index.js still contains CommonJS export markers.',
|
||||
)
|
||||
|
||||
await import(pathToFileURL(esmEntry).href)
|
||||
console.log('[validate-dist] ESM entry loaded successfully.')
|
||||
|
||||
const cjsFiles = collectFiles(distDir).filter(file => file.endsWith('.cjs'))
|
||||
const localRequirePattern = /require\(\s*['"](\.{1,2}\/[^'"]+)['"]\s*\)/g
|
||||
|
||||
for (const file of cjsFiles) {
|
||||
const source = file === cjsEntry ? cjsSource : read(file)
|
||||
assert(
|
||||
!/\brequire\(\s*['"]\.{1,2}\/[^'"]+\.js['"]\s*\)/.test(source),
|
||||
`[validate-dist] ${file} still requires local .js chunks under a type=module package.`,
|
||||
)
|
||||
|
||||
for (const match of source.matchAll(localRequirePattern)) {
|
||||
const requiredPath = resolve(dirname(file), match[1])
|
||||
assert(
|
||||
existsSync(requiredPath),
|
||||
`[validate-dist] Missing local CJS dependency ${match[1]} referenced from ${file}.`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[validate-dist] CJS entries reference only local .cjs dependencies that exist.')
|
||||
Reference in New Issue
Block a user