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.cjs CHANGED
@@ -1154,8 +1154,8 @@ var import_promises7 = require("fs/promises");
1154
1154
  var import_node_path6 = __toESM(require("path"), 1);
1155
1155
  var import_node_url = require("url");
1156
1156
  async function resolveToolVersion() {
1157
- if ("0.4.9".length > 0) {
1158
- return "0.4.9";
1157
+ if ("0.5.0".length > 0) {
1158
+ return "0.5.0";
1159
1159
  }
1160
1160
  try {
1161
1161
  const packagePath = resolvePackageJsonPath();
@@ -2498,8 +2498,11 @@ async function createReportData(root, validation, configResult) {
2498
2498
  db: dbFiles
2499
2499
  } = await collectContractFiles(uiRoot, apiRoot, dbRoot);
2500
2500
  const contractIndex = await buildContractIndex(root, config);
2501
- const specContractRefs = await collectSpecContractRefs(specFiles);
2502
2501
  const contractIdList = Array.from(contractIndex.ids);
2502
+ const specContractRefs = await collectSpecContractRefs(
2503
+ specFiles,
2504
+ contractIdList
2505
+ );
2503
2506
  const referencedContracts = /* @__PURE__ */ new Set();
2504
2507
  for (const ids of specContractRefs.specToContractIds.values()) {
2505
2508
  ids.forEach((id) => referencedContracts.add(id));
@@ -2580,6 +2583,7 @@ async function createReportData(root, validation, configResult) {
2580
2583
  },
2581
2584
  specs: {
2582
2585
  contractRefMissing: specContractRefs.missingRefSpecs.size,
2586
+ missingRefSpecs: toSortedArray2(specContractRefs.missingRefSpecs),
2583
2587
  specToContractIds: specToContractIdsRecord
2584
2588
  }
2585
2589
  },
@@ -2662,6 +2666,16 @@ function formatReportMarkdown(data) {
2662
2666
  }
2663
2667
  }
2664
2668
  lines.push("");
2669
+ lines.push("## Spec\u3067 contract-ref \u672A\u5BA3\u8A00");
2670
+ const missingRefSpecs = data.traceability.specs.missingRefSpecs;
2671
+ if (missingRefSpecs.length === 0) {
2672
+ lines.push("- (none)");
2673
+ } else {
2674
+ for (const specId of missingRefSpecs) {
2675
+ lines.push(`- ${specId}`);
2676
+ }
2677
+ }
2678
+ lines.push("");
2665
2679
  lines.push("## SC\u30AB\u30D0\u30EC\u30C3\u30B8");
2666
2680
  lines.push(`- total: ${data.traceability.sc.total}`);
2667
2681
  lines.push(`- covered: ${data.traceability.sc.covered}`);
@@ -2765,10 +2779,13 @@ function formatReportMarkdown(data) {
2765
2779
  function formatReportJson(data) {
2766
2780
  return JSON.stringify(data, null, 2);
2767
2781
  }
2768
- async function collectSpecContractRefs(specFiles) {
2782
+ async function collectSpecContractRefs(specFiles, contractIdList) {
2769
2783
  const specToContractIds = /* @__PURE__ */ new Map();
2770
2784
  const idToSpecs = /* @__PURE__ */ new Map();
2771
2785
  const missingRefSpecs = /* @__PURE__ */ new Set();
2786
+ for (const contractId of contractIdList) {
2787
+ idToSpecs.set(contractId, /* @__PURE__ */ new Set());
2788
+ }
2772
2789
  for (const file of specFiles) {
2773
2790
  const text = await (0, import_promises14.readFile)(file, "utf-8");
2774
2791
  const parsed = parseSpec(text, file);
@@ -2776,13 +2793,15 @@ async function collectSpecContractRefs(specFiles) {
2776
2793
  const refs = parsed.contractRefs;
2777
2794
  if (refs.lines.length === 0) {
2778
2795
  missingRefSpecs.add(specKey);
2796
+ continue;
2779
2797
  }
2780
2798
  const currentContracts = specToContractIds.get(specKey) ?? /* @__PURE__ */ new Set();
2781
2799
  for (const id of refs.ids) {
2782
2800
  currentContracts.add(id);
2783
- const specs = idToSpecs.get(id) ?? /* @__PURE__ */ new Set();
2784
- specs.add(specKey);
2785
- idToSpecs.set(id, specs);
2801
+ const specs = idToSpecs.get(id);
2802
+ if (specs) {
2803
+ specs.add(specKey);
2804
+ }
2786
2805
  }
2787
2806
  specToContractIds.set(specKey, currentContracts);
2788
2807
  }