@cejel/cejel 0.1.3 → 0.1.5

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.js CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ createWitanAttestation,
3
4
  formatExternalSourceLine,
4
5
  renderWitanBadgeEndpoint,
5
6
  renderWitanBadgeSvg,
6
7
  renderWitanHtmlReport,
7
- runCejelScan
8
- } from "./chunk-QQVCIG4N.js";
8
+ runCejelScan,
9
+ serializeWitanReport
10
+ } from "./chunk-A7NZKJ5H.js";
9
11
 
10
12
  // src/index.ts
11
13
  import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "fs";
@@ -14,11 +16,15 @@ import { pathToFileURL } from "url";
14
16
 
15
17
  // src/terminal.ts
16
18
  function renderTerminalCertificate(summary) {
17
- const lines = summary.insufficientSourceReason ? [
19
+ const abstained = summary.verdict === "Insufficient source";
20
+ if (!abstained && (summary.overallScore === null || summary.codeTrustScore === null || summary.processTrustScore === null)) {
21
+ throw new Error("A scored Cejel summary must carry numeric headline scores.");
22
+ }
23
+ const lines = abstained ? [
18
24
  `Cejel Trust Certificate \u2014 ${summary.productDisplayName}`,
19
25
  "",
20
26
  "Insufficient source to certify.",
21
- ` ${summary.insufficientSourceReason}`,
27
+ ` ${summary.insufficientSourceReason ?? "No ratable source was found."}`,
22
28
  ""
23
29
  ] : [
24
30
  `Cejel Trust Certificate \u2014 ${summary.productDisplayName}`,
@@ -35,7 +41,7 @@ function renderTerminalCertificate(summary) {
35
41
  }
36
42
  lines.push("");
37
43
  }
38
- if (summary.insufficientSourceReason) {
44
+ if (abstained) {
39
45
  lines.push("See report.json / certificate.html for the full per-criterion detail.");
40
46
  } else if (summary.topFindings.length === 0) {
41
47
  lines.push("No evidence-backed findings.");
@@ -49,7 +55,7 @@ function renderTerminalCertificate(summary) {
49
55
  lines.push(` ...and ${remaining} more \u2014 see the written report for the full list.`);
50
56
  }
51
57
  }
52
- if (!summary.insufficientSourceReason && summary.externalFindingCount > 0) {
58
+ if (!abstained && summary.externalFindingCount > 0) {
53
59
  lines.push(
54
60
  "",
55
61
  `External findings (${summary.externalFindingCount} total, attributed to tool + criterion):`
@@ -68,6 +74,7 @@ function renderTerminalCertificate(summary) {
68
74
  `;
69
75
  }
70
76
  function formatScore(score) {
77
+ if (score === null) throw new Error("A scored Cejel summary must carry numeric scores.");
71
78
  return score.toFixed(1);
72
79
  }
73
80
 
@@ -115,6 +122,9 @@ var CLI_FLAG_KIND_BY_TOKEN = new Map(
115
122
  CLI_FLAG_SPECS.flatMap((spec) => spec.tokens.map((token) => [token, spec.kind]))
116
123
  );
117
124
  function cliVersion() {
125
+ if (typeof __CEJEL_SEA_VERSION__ === "string" && __CEJEL_SEA_VERSION__.length > 0) {
126
+ return __CEJEL_SEA_VERSION__;
127
+ }
118
128
  const manifest = JSON.parse(
119
129
  readFileSync(new URL("../package.json", import.meta.url), "utf8")
120
130
  );
@@ -132,7 +142,7 @@ var usageOptions = CLI_FLAG_SPECS.map(
132
142
  ).join("\n");
133
143
  var USAGE = `cejel \u2014 a trust certificate for your codebase
134
144
 
135
- Usage: npx @cejel/cejel [path] [options]
145
+ Usage: npx cejel [path] [options]
136
146
 
137
147
  Options:
138
148
  ${usageOptions}
@@ -160,8 +170,14 @@ async function runWitanFreeCli(args) {
160
170
  ingestPatterns: options.ingestPatterns,
161
171
  warnOnEmptyIngestMatch: !options.quiet
162
172
  });
173
+ const attestation = createWitanAttestation(report, { toolVersion: cliVersion() });
163
174
  mkdirSync(options.outDir, { recursive: true });
164
- writeFileSync(join(options.outDir, "report.json"), JSON.stringify(report, null, 2), "utf8");
175
+ writeFileSync(join(options.outDir, "report.json"), serializeWitanReport(report), "utf8");
176
+ writeFileSync(
177
+ join(options.outDir, "attestation.json"),
178
+ JSON.stringify(attestation, null, 2),
179
+ "utf8"
180
+ );
165
181
  writeFileSync(join(options.outDir, "certificate.html"), renderWitanHtmlReport(report), "utf8");
166
182
  writeFileSync(
167
183
  join(options.outDir, "badge.json"),
@@ -176,18 +192,28 @@ async function runWitanFreeCli(args) {
176
192
  `
177
193
  Wrote:
178
194
  ${options.outDir}/report.json
195
+ ${options.outDir}/attestation.json
179
196
  ${options.outDir}/certificate.html
180
197
  ${options.outDir}/badge.json
181
198
  ${options.outDir}/badge.svg
182
199
  `
183
200
  );
184
201
  }
185
- if (options.minScore != null && report.overallScore < options.minScore) {
186
- process.stderr.write(
187
- `Cejel: overall score ${report.overallScore.toFixed(1)}/4.0 is below the required minimum ${options.minScore.toFixed(1)}/4.0
202
+ if (options.minScore != null) {
203
+ if (report.verdict === "insufficient_source") {
204
+ process.stderr.write(
205
+ `Cejel: cannot evaluate the required minimum ${options.minScore.toFixed(1)}/4.0 because this repository has insufficient source.
188
206
  `
189
- );
190
- return 1;
207
+ );
208
+ return 1;
209
+ }
210
+ if (report.overallScore < options.minScore) {
211
+ process.stderr.write(
212
+ `Cejel: overall score ${report.overallScore.toFixed(1)}/4.0 is below the required minimum ${options.minScore.toFixed(1)}/4.0
213
+ `
214
+ );
215
+ return 1;
216
+ }
191
217
  }
192
218
  return 0;
193
219
  }