forked from boos/BoosAPI
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:
+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