47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { access } from "node:fs/promises"
|
|
import path from "node:path"
|
|
import { fileURLToPath } from "node:url"
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
const projectDir = path.resolve(__dirname, "..")
|
|
|
|
async function has(filePath) {
|
|
try {
|
|
await access(filePath)
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
function nodeOk() {
|
|
const major = Number.parseInt(process.versions.node.split(".")[0] ?? "0", 10)
|
|
return Number.isFinite(major) && major >= 20
|
|
}
|
|
|
|
async function main() {
|
|
const report = {
|
|
node: process.versions.node,
|
|
nodeOk: nodeOk(),
|
|
packageJson: await has(path.join(projectDir, "package.json")),
|
|
nodeModules: await has(path.join(projectDir, "node_modules")),
|
|
distServer: await has(path.join(projectDir, "dist", "server.js")),
|
|
configFile: await has(path.join(projectDir, "config", "browser-tool.config.json")),
|
|
mcpTemplate: await has(path.join(projectDir, "opencode.mcp.example.json")),
|
|
}
|
|
|
|
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`)
|
|
|
|
const ok = Object.values(report).every((value) => value !== false)
|
|
if (!ok) {
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
process.stderr.write(`Verify failed: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
process.exit(1)
|
|
})
|