feat: 建立统一目录元数据与获取契约 (#5)

* feat: 建立 Registry 目录元数据验证基础

* feat: 迁移 Registry 应用目录元数据

* test: 解耦目录迁移进度断言

* feat: 迁移 Registry 服务目录元数据

* fix(catalog): 强制 Registry 目录元数据

* fix(catalog): 兼容 Registry v4 外部集成
This commit is contained in:
2026-08-31 04:03:38 -04:00
committed by GitHub
parent 67aeb72b20
commit 223be1f04b
31 changed files with 3169 additions and 10 deletions

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env node
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { validateRegistry } from './validator.mjs'
const scriptDir = dirname(fileURLToPath(import.meta.url))
const defaultRoot = resolve(scriptDir, '..', '..')
const args = process.argv.slice(2)
const rootIndex = args.indexOf('--root')
const root = rootIndex >= 0 ? resolve(args[rootIndex + 1]) : defaultRoot
const json = args.includes('--json')
const requireSidecars = args.includes('--require-sidecars') ? true : undefined
const report = validateRegistry(root, { requireSidecars })
if (json) {
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`)
} else {
const { counts } = report
process.stdout.write(`Registry 校验:${report.ok ? '通过' : '失败'}\n`)
process.stdout.write(`条目 ${counts.totalEntries}App ${counts.dockerApps} / MCP ${counts.mcpServices} / HTTP ${counts.httpApis}\n`)
process.stdout.write(`Catalog sidecar ${counts.sidecars}legacy fallback ${counts.legacyOnly}\n`)
for (const item of report.diagnostics) {
process.stdout.write(`${item.level === 'error' ? 'ERROR' : 'WARN '} ${item.file} ${item.path} [${item.code}] ${item.message}\n`)
}
}
process.exitCode = report.ok ? 0 : 1