qfai 0.4.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -119,6 +119,7 @@ type ReportContractCoverage = {
119
119
  };
120
120
  type ReportSpecCoverage = {
121
121
  contractRefMissing: number;
122
+ missingRefSpecs: string[];
122
123
  specToContractIds: Record<string, string[]>;
123
124
  };
124
125
  type ReportTraceability = {
package/dist/index.d.ts CHANGED
@@ -119,6 +119,7 @@ type ReportContractCoverage = {
119
119
  };
120
120
  type ReportSpecCoverage = {
121
121
  contractRefMissing: number;
122
+ missingRefSpecs: string[];
122
123
  specToContractIds: Record<string, string[]>;
123
124
  };
124
125
  type ReportTraceability = {
package/dist/index.mjs CHANGED
@@ -1102,8 +1102,8 @@ import { readFile as readFile4 } from "fs/promises";
1102
1102
  import path6 from "path";
1103
1103
  import { fileURLToPath } from "url";
1104
1104
  async function resolveToolVersion() {
1105
- if ("0.4.9".length > 0) {
1106
- return "0.4.9";
1105
+ if ("0.5.0".length > 0) {
1106
+ return "0.5.0";
1107
1107
  }
1108
1108
  try {
1109
1109
  const packagePath = resolvePackageJsonPath();
@@ -2446,8 +2446,11 @@ async function createReportData(root, validation, configResult) {
2446
2446
  db: dbFiles
2447
2447
  } = await collectContractFiles(uiRoot, apiRoot, dbRoot);
2448
2448
  const contractIndex = await buildContractIndex(root, config);
2449
- const specContractRefs = await collectSpecContractRefs(specFiles);
2450
2449
  const contractIdList = Array.from(contractIndex.ids);
2450
+ const specContractRefs = await collectSpecContractRefs(
2451
+ specFiles,
2452
+ contractIdList
2453
+ );
2451
2454
  const referencedContracts = /* @__PURE__ */ new Set();
2452
2455
  for (const ids of specContractRefs.specToContractIds.values()) {
2453
2456
  ids.forEach((id) => referencedContracts.add(id));
@@ -2528,6 +2531,7 @@ async function createReportData(root, validation, configResult) {
2528
2531
  },
2529
2532
  specs: {
2530
2533
  contractRefMissing: specContractRefs.missingRefSpecs.size,
2534
+ missingRefSpecs: toSortedArray2(specContractRefs.missingRefSpecs),
2531
2535
  specToContractIds: specToContractIdsRecord
2532
2536
  }
2533
2537
  },
@@ -2610,6 +2614,16 @@ function formatReportMarkdown(data) {
2610
2614
  }
2611
2615
  }
2612
2616
  lines.push("");
2617
+ lines.push("## Spec\u3067 contract-ref \u672A\u5BA3\u8A00");
2618
+ const missingRefSpecs = data.traceability.specs.missingRefSpecs;
2619
+ if (missingRefSpecs.length === 0) {
2620
+ lines.push("- (none)");
2621
+ } else {
2622
+ for (const specId of missingRefSpecs) {
2623
+ lines.push(`- ${specId}`);
2624
+ }
2625
+ }
2626
+ lines.push("");
2613
2627
  lines.push("## SC\u30AB\u30D0\u30EC\u30C3\u30B8");
2614
2628
  lines.push(`- total: ${data.traceability.sc.total}`);
2615
2629
  lines.push(`- covered: ${data.traceability.sc.covered}`);
@@ -2713,10 +2727,13 @@ function formatReportMarkdown(data) {
2713
2727
  function formatReportJson(data) {
2714
2728
  return JSON.stringify(data, null, 2);
2715
2729
  }
2716
- async function collectSpecContractRefs(specFiles) {
2730
+ async function collectSpecContractRefs(specFiles, contractIdList) {
2717
2731
  const specToContractIds = /* @__PURE__ */ new Map();
2718
2732
  const idToSpecs = /* @__PURE__ */ new Map();
2719
2733
  const missingRefSpecs = /* @__PURE__ */ new Set();
2734
+ for (const contractId of contractIdList) {
2735
+ idToSpecs.set(contractId, /* @__PURE__ */ new Set());
2736
+ }
2720
2737
  for (const file of specFiles) {
2721
2738
  const text = await readFile11(file, "utf-8");
2722
2739
  const parsed = parseSpec(text, file);
@@ -2724,13 +2741,15 @@ async function collectSpecContractRefs(specFiles) {
2724
2741
  const refs = parsed.contractRefs;
2725
2742
  if (refs.lines.length === 0) {
2726
2743
  missingRefSpecs.add(specKey);
2744
+ continue;
2727
2745
  }
2728
2746
  const currentContracts = specToContractIds.get(specKey) ?? /* @__PURE__ */ new Set();
2729
2747
  for (const id of refs.ids) {
2730
2748
  currentContracts.add(id);
2731
- const specs = idToSpecs.get(id) ?? /* @__PURE__ */ new Set();
2732
- specs.add(specKey);
2733
- idToSpecs.set(id, specs);
2749
+ const specs = idToSpecs.get(id);
2750
+ if (specs) {
2751
+ specs.add(specKey);
2752
+ }
2734
2753
  }
2735
2754
  specToContractIds.set(specKey, currentContracts);
2736
2755
  }