Export conformance schema catalog
This commit is contained in:
parent
227c6bd59d
commit
2437181caf
6 changed files with 90 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ if (!exportDirectory) {
|
|||
" --expect-scenario <id>",
|
||||
" --expect-split-target <id>",
|
||||
" --expect-capability-matrix",
|
||||
" --expect-schema <schemaId>",
|
||||
" --expect-capability-gap <substring>",
|
||||
" --expect-runtime-plugin-projection <runtimeId:pluginId:status:ownerRepo>",
|
||||
" --expect-provider-runtime-plugin-projection <providerId:surfaceId:runtimeId:pluginId:status:runtimeOwnerRepo>",
|
||||
|
|
@ -85,6 +86,7 @@ function validateIndex(index, directory, expectations, errors) {
|
|||
const packIds = new Set(packs.map(pack => pack.id));
|
||||
const fixtureIds = new Set();
|
||||
const exportedRuntimeTargets = [];
|
||||
validateSchemaCatalog(index.schemaCatalog, directory, expectations.schemas, errors);
|
||||
for (const requiredPack of ["core", "plugin", "provider", "runtime"]) {
|
||||
if (!packIds.has(requiredPack)) errors.push(`pack:${requiredPack}:missing`);
|
||||
}
|
||||
|
|
@ -990,6 +992,32 @@ function validateSplitTargetRecords(splitTargets, errors) {
|
|||
}
|
||||
}
|
||||
|
||||
function validateSchemaCatalog(schemaCatalog, directory, expectedSchemas, errors) {
|
||||
if (!Array.isArray(schemaCatalog)) {
|
||||
errors.push("schemaCatalog:missing");
|
||||
return;
|
||||
}
|
||||
for (const [index, schema] of schemaCatalog.entries()) {
|
||||
const label = `schemaCatalog:${index}`;
|
||||
for (const field of ["schemaId", "path", "exportPath"]) {
|
||||
if (!schema?.[field]) errors.push(`${label}:${field}:missing`);
|
||||
}
|
||||
if (schema?.exportPath && !existsSync(path.join(directory, schema.exportPath))) {
|
||||
errors.push(`${label}:exportPath:${schema.exportPath}:missing`);
|
||||
}
|
||||
}
|
||||
for (const schemaId of expectedSchemas) {
|
||||
const schema = schemaCatalog.find(candidate => candidate.schemaId === schemaId);
|
||||
if (!schema) {
|
||||
errors.push(`schemaCatalog:${schemaId}:missing`);
|
||||
continue;
|
||||
}
|
||||
if (!schema.exportPath || !existsSync(path.join(directory, schema.exportPath))) {
|
||||
errors.push(`schemaCatalog:${schemaId}:exportPath:missing`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function capabilityGapText(gap) {
|
||||
return [
|
||||
gap.kind,
|
||||
|
|
@ -1005,6 +1033,7 @@ function parseArguments(args) {
|
|||
const exportPath = args[0] ? path.resolve(args[0]) : "";
|
||||
const expectations = {
|
||||
packs: [],
|
||||
schemas: [],
|
||||
fixtures: [],
|
||||
plugins: [],
|
||||
pluginOperations: [],
|
||||
|
|
@ -1055,6 +1084,7 @@ function parseArguments(args) {
|
|||
};
|
||||
const optionTargets = new Map([
|
||||
["--expect-pack", expectations.packs],
|
||||
["--expect-schema", expectations.schemas],
|
||||
["--expect-fixture", expectations.fixtures],
|
||||
["--expect-plugin", expectations.plugins],
|
||||
["--expect-provider", expectations.providers],
|
||||
|
|
|
|||
|
|
@ -1728,6 +1728,7 @@ function buildConformanceExport(report) {
|
|||
sourceManifest: report.manifest,
|
||||
boundaryRule: report.repoStrategy.boundaryRule || "",
|
||||
incubationPolicy: report.repoStrategy.incubationPolicy || "",
|
||||
schemaCatalog: buildSchemaCatalog(),
|
||||
conformanceHandoffPath: report.repoStrategy.conformanceHandoffPath || "",
|
||||
conformanceHandoffExportPath: makeHandoffExportPath("conformance", "EveConformance", report.repoStrategy.conformanceHandoffPath || ""),
|
||||
packs,
|
||||
|
|
@ -1798,6 +1799,16 @@ function buildConformanceExport(report) {
|
|||
};
|
||||
}
|
||||
|
||||
function buildSchemaCatalog() {
|
||||
return Object.entries(manifest.schemas || {})
|
||||
.map(([schemaId, schemaPath]) => ({
|
||||
schemaId,
|
||||
path: schemaPath,
|
||||
exportPath: `schemas/${path.basename(schemaPath)}`,
|
||||
}))
|
||||
.sort((left, right) => left.schemaId.localeCompare(right.schemaId));
|
||||
}
|
||||
|
||||
function buildCapabilityMatrix(report) {
|
||||
const packs = (report.conformancePacks || []).map(pack => {
|
||||
const fixtures = (report.fixtures || []).filter(fixture => fixture.pack === pack.id);
|
||||
|
|
@ -2422,11 +2433,20 @@ function buildWorldSurfaceLoweringTargetIndex(report) {
|
|||
async function writeConformanceExport(conformanceExport, directory) {
|
||||
await mkdir(path.join(directory, "packs"), { recursive: true });
|
||||
await mkdir(path.join(directory, "handoffs"), { recursive: true });
|
||||
await mkdir(path.join(directory, "schemas"), { recursive: true });
|
||||
await writeFile(path.join(directory, "index.json"), `${JSON.stringify(conformanceExport, null, 2)}\n`);
|
||||
await writeFile(path.join(directory, "index.md"), renderConformanceExportMarkdown(conformanceExport));
|
||||
for (const pack of conformanceExport.packs) {
|
||||
await writeFile(path.join(directory, "packs", `${pack.id}.json`), `${JSON.stringify(pack, null, 2)}\n`);
|
||||
}
|
||||
for (const schema of conformanceExport.schemaCatalog || []) {
|
||||
if (!schema.path || !schema.exportPath) continue;
|
||||
const sourcePath = path.join(repoRoot, schema.path);
|
||||
if (!existsSync(sourcePath)) continue;
|
||||
const destinationPath = path.join(directory, schema.exportPath);
|
||||
await mkdir(path.dirname(destinationPath), { recursive: true });
|
||||
await writeFile(destinationPath, await readFile(sourcePath, "utf8"));
|
||||
}
|
||||
for (const handoff of collectConformanceHandoffs(conformanceExport)) {
|
||||
if (!handoff.sourcePath || !handoff.exportPath) continue;
|
||||
const sourcePath = path.join(repoRoot, handoff.sourcePath);
|
||||
|
|
|
|||
Loading…
Reference in a new issue