@repometry/cli 0.4.0 → 0.6.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.
Files changed (57) hide show
  1. package/README.md +8 -5
  2. package/package.json +3 -3
  3. package/target/main/resources/report/json/report-v2.schema.json +1 -0
  4. package/target/main/resources/report/json/repository-summary-v1.schema.json +12 -0
  5. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +31 -0
  6. package/target/main/resources/viewer/index.html +9 -9
  7. package/target/main/resources/viewer/styles.css +8 -9
  8. package/target/main/ts/cli/distribution.d.ts +8 -0
  9. package/target/main/ts/cli/distribution.js +23 -0
  10. package/target/main/ts/cli/imports.js +21 -17
  11. package/target/main/ts/cli/run.d.ts +2 -2
  12. package/target/main/ts/cli/run.js +7 -4
  13. package/target/main/ts/compose/analysis-inventory.d.ts +12 -0
  14. package/target/main/ts/compose/analysis-inventory.js +18 -0
  15. package/target/main/ts/compose/analysis-report.js +3 -16
  16. package/target/main/ts/compose/analysis-results.d.ts +1 -0
  17. package/target/main/ts/compose/analysis-results.js +14 -12
  18. package/target/main/ts/compose/built-ins.d.ts +2 -2
  19. package/target/main/ts/compose/built-ins.js +2 -2
  20. package/target/main/ts/compose/load-plugins.js +9 -6
  21. package/target/main/ts/plugins/built-in.d.ts +2 -0
  22. package/target/main/ts/plugins/built-in.js +2 -1
  23. package/target/main/ts/plugins/json-spans.js +56 -42
  24. package/target/main/ts/plugins/legal/composer-lock.js +1 -1
  25. package/target/main/ts/plugins/legal/cyclonedx.d.ts +2 -0
  26. package/target/main/ts/plugins/legal/cyclonedx.js +61 -0
  27. package/target/main/ts/plugins/legal/dependencies.d.ts +53 -7
  28. package/target/main/ts/plugins/legal/dependencies.js +34 -14
  29. package/target/main/ts/plugins/legal/expression.d.ts +2 -0
  30. package/target/main/ts/plugins/legal/expression.js +69 -0
  31. package/target/main/ts/plugins/legal/licenses.d.ts +1 -0
  32. package/target/main/ts/plugins/legal/licenses.js +55 -28
  33. package/target/main/ts/plugins/legal/npm-lock.js +2 -1
  34. package/target/main/ts/plugins/legal/policy.d.ts +7 -11
  35. package/target/main/ts/plugins/legal/policy.js +23 -102
  36. package/target/main/ts/plugins/legal/sbom-model.d.ts +7 -0
  37. package/target/main/ts/plugins/legal/sbom-model.js +11 -0
  38. package/target/main/ts/plugins/legal/sbom.js +2 -116
  39. package/target/main/ts/plugins/legal/spdx-catalog.d.ts +9 -0
  40. package/target/main/ts/plugins/legal/spdx-catalog.js +28 -0
  41. package/target/main/ts/plugins/legal/spdx-sbom.d.ts +2 -0
  42. package/target/main/ts/plugins/legal/spdx-sbom.js +65 -0
  43. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +2 -0
  44. package/target/main/ts/report/html/app/viewer-metric-format.js +17 -0
  45. package/target/main/ts/report/html/app/viewer-metrics.d.ts +1 -2
  46. package/target/main/ts/report/html/app/viewer-metrics.js +1 -17
  47. package/target/main/ts/report/html/app/viewer-overview-cards.js +15 -37
  48. package/target/main/ts/report/html/app/viewer-overview-lead.js +1 -1
  49. package/target/main/ts/report/html/site/asset-versions.d.ts +2 -0
  50. package/target/main/ts/report/html/site/asset-versions.js +36 -0
  51. package/target/main/ts/report/html/site/badges.d.ts +5 -1
  52. package/target/main/ts/report/html/site/badges.js +17 -11
  53. package/target/main/ts/report/html/site/export-site.js +2 -1
  54. package/target/main/ts/report/html/site/local-server.js +2 -0
  55. package/target/main/ts/report/html/site/projects.js +4 -3
  56. package/target/main/ts/report/json/projections/inspection-details.js +3 -0
  57. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +2 -0
package/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  <a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/maintainability.svg" alt="Maintainability"></a>
12
12
  <a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/coverage.svg" alt="Coverage"></a>
13
13
  <a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/security.svg" alt="Security"></a>
14
+ <a href="https://idleware.github.io/repometry/"><img src="https://idleware.github.io/repometry/legal.svg" alt="Legal"></a>
14
15
  </p>
15
16
 
16
17
  Git can serve as a project’s single source of truth for code, tests, docs, and CI configuration. Repometry lets you keep coverage and maintainability metrics alongside your code, commit by commit.
@@ -39,11 +40,13 @@ npm install --global repometry
39
40
 
40
41
  ### Which package
41
42
 
42
- | Package | Command | Languages | Install size |
43
- | --- | --- | --- | --- |
44
- | `@repometry/cli` | `repometry-cli` | JavaScript, TypeScript | about 8 MB |
45
- | `repometry` | `repometry` | The above, Go, Python, Java, PHP | about 15 MB |
46
- | `@repometry/all` | `repometry-all` | The above, Ruby, Kotlin, HCL, Lua, Scala, Elixir, Rust, R, Zig, OCaml, Perl | about 33 MB |
43
+ | Package | Languages | Install size |
44
+ | --- | --- | --- |
45
+ | `@repometry/cli` | JavaScript, TypeScript | about 8 MB |
46
+ | `repometry` | The above, Go, Python, Java, PHP | about 15 MB |
47
+ | `@repometry/all` | The above, Ruby, Kotlin, HCL, Lua, Scala, Elixir, Rust, R, Zig, OCaml, Perl | about 33 MB |
48
+
49
+ Every package uses the `repometry` command. If several are installed together, the command uses the largest distribution.
47
50
 
48
51
  To add a language to `@repometry/cli`, install its `@repometry/language-*` package with your package manager and list it in `plugins`. Repometry never installs a plugin. See [Packages](docs/cli.md#packages).
49
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repometry/cli",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Track repository metrics without SaaS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "node": ">=24"
24
24
  },
25
25
  "bin": {
26
- "repometry-cli": "target/main/ts/cli/main.js"
26
+ "repometry": "target/main/ts/cli/main.js"
27
27
  },
28
28
  "exports": {
29
29
  ".": {
@@ -67,7 +67,7 @@
67
67
  "dependencies": {
68
68
  "@babel/parser": "7.29.15",
69
69
  "@babel/types": "7.29.15",
70
- "@repometry/core": "0.7.0",
70
+ "@repometry/core": "0.8.0",
71
71
  "ajv": "8.20.0",
72
72
  "semver": "7.8.6"
73
73
  },
@@ -471,6 +471,7 @@
471
471
  "type": "number",
472
472
  "minimum": 0
473
473
  },
474
+ "groups": { "type": "array", "items": { "type": "string", "minLength": 1 }, "uniqueItems": true },
474
475
  "anchor": {
475
476
  "type": "string",
476
477
  "minLength": 1
@@ -77,6 +77,18 @@
77
77
  "grade": { "enum": ["A", "B", "C", "D", "F"] },
78
78
  "checked": { "type": "integer", "minimum": 0 },
79
79
  "inputs": { "type": "integer", "minimum": 1 },
80
+ "unknownLicenses": { "type": "integer", "minimum": 0 },
81
+ "deniedLicenses": { "type": "integer", "minimum": 0 },
82
+ "licenseKinds": {
83
+ "type": "object",
84
+ "required": ["osi", "other", "unknown"],
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "osi": { "type": "integer", "minimum": 0 },
88
+ "other": { "type": "integer", "minimum": 0 },
89
+ "unknown": { "type": "integer", "minimum": 0 }
90
+ }
91
+ },
80
92
  "low": { "type": "integer", "minimum": 0 },
81
93
  "medium": { "type": "integer", "minimum": 0 },
82
94
  "high": { "type": "integer", "minimum": 0 },
@@ -44,6 +44,37 @@
44
44
  "diagnostics": {
45
45
  "$ref": "urn:repometry:schema:report:2#/properties/diagnostics"
46
46
  },
47
+ "licenseInputs": {
48
+ "type": "array",
49
+ "items": {
50
+ "type": "object",
51
+ "required": ["path", "checked", "groups", "licenseKinds"],
52
+ "additionalProperties": false,
53
+ "properties": {
54
+ "path": { "type": "string" },
55
+ "checked": { "type": "integer", "minimum": 0 },
56
+ "licenseKinds": {
57
+ "type": "object",
58
+ "required": ["osi", "other", "unknown"],
59
+ "additionalProperties": false,
60
+ "properties": {
61
+ "osi": { "type": "integer", "minimum": 0 },
62
+ "other": { "type": "integer", "minimum": 0 },
63
+ "unknown": { "type": "integer", "minimum": 0 }
64
+ }
65
+ },
66
+ "groups": {
67
+ "type": "array",
68
+ "items": {
69
+ "type": "object",
70
+ "required": ["name", "count"],
71
+ "additionalProperties": false,
72
+ "properties": { "name": { "type": "string", "minLength": 1 }, "count": { "type": "integer", "minimum": 0 } }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ },
47
78
  "findings": {
48
79
  "$ref": "urn:repometry:schema:report:2#/properties/findings"
49
80
  },
@@ -50,20 +50,20 @@
50
50
  <div class="card verdict-card">
51
51
  <div class="verdicts" role="tablist" aria-label="Quality area">
52
52
  <div class="verdict">
53
- <span id="maintainability" class="mark grade"></span>
54
- <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="debt" aria-controls="trend" aria-describedby="maintainability maintainability-detail maintainability-scope">Maintainability</button><span id="maintainability-detail" class="verdict-detail"></span><span id="maintainability-scope" class="verdict-detail verdict-more" hidden></span></span>
53
+ <span id="maintainability" class="mark grade" data-grade="none">–</span>
54
+ <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="debt" aria-controls="trend" aria-describedby="maintainability maintainability-detail">Maintainability</button><span id="maintainability-detail" class="verdict-detail">Not measured</span></span>
55
55
  </div>
56
56
  <div class="verdict">
57
- <span id="coverage-mark" class="mark ring" aria-hidden="true"></span>
58
- <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="coverage" aria-controls="trend" aria-describedby="coverage-detail coverage-kinds">Coverage</button><span id="coverage-detail" class="verdict-detail"></span><span id="coverage-kinds" class="verdict-detail verdict-more" hidden></span></span>
57
+ <span id="coverage-mark" class="mark ring" data-grade="none" aria-hidden="true">–</span>
58
+ <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="coverage" aria-controls="trend" aria-describedby="coverage-detail">Coverage</button><span id="coverage-detail" class="verdict-detail">Not measured</span></span>
59
59
  </div>
60
- <div class="verdict" id="security-verdict" data-loaded hidden>
61
- <span id="security-mark" class="mark severity"></span>
62
- <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="security" aria-controls="trend" aria-describedby="security-mark security-detail">Security</button><span id="security-detail" class="verdict-detail"></span></span>
60
+ <div class="verdict" id="security-verdict">
61
+ <span id="security-mark" class="mark severity" data-severity="none">–</span>
62
+ <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="security" aria-controls="trend" aria-describedby="security-mark security-detail">Security</button><span id="security-detail" class="verdict-detail">Not measured</span></span>
63
63
  </div>
64
64
  <div class="verdict" id="legal-verdict">
65
- <span id="legal-mark" class="mark grade"></span>
66
- <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="legal" aria-controls="trend" aria-describedby="legal-mark legal-detail legal-scope">Legal</button><span id="legal-detail" class="verdict-detail"></span><span id="legal-scope" class="verdict-detail verdict-more"></span></span>
65
+ <span id="legal-mark" class="mark grade" data-grade="none">–</span>
66
+ <span class="verdict-text"><button type="button" role="tab" class="verdict-tab" data-metric="legal" aria-controls="trend" aria-describedby="legal-mark legal-detail">Legal</button><span id="legal-detail" class="verdict-detail">Not measured</span></span>
67
67
  </div>
68
68
  </div>
69
69
  <section id="trend" class="trend" role="tabpanel" aria-labelledby="trend-title">
@@ -269,9 +269,6 @@ main:focus { outline: none; }
269
269
  .verdict-tab:focus-visible { outline: none; }
270
270
  .verdict:has(.verdict-tab:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
271
271
  .verdict-detail { color: var(--secondary); font-size: .875rem; overflow-wrap: anywhere; }
272
- /* The coverage kinds beyond lines: a quieter second line under the headline's detail. */
273
- .verdict-more { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
274
- .verdict-more > span { white-space: nowrap; }
275
272
  /* A detail that counts something leads to exactly what it counts. */
276
273
  .verdict-detail a { position: relative; z-index: 1; color: inherit; text-decoration-color: var(--rule-strong); }
277
274
  @container (min-width: 33rem) and (max-width: 49rem) {
@@ -281,13 +278,14 @@ main:focus { outline: none; }
281
278
  }
282
279
  .verdict-detail a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
283
280
  .mark { flex: none; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 8px; font-size: 1.25rem; font-weight: 650; color: #fff; font-variant-numeric: tabular-nums; }
284
- .grade { background: var(--grade-a); }
281
+ .grade, .severity { background: var(--grade-none); }
282
+ .grade[data-grade="A"], .severity[data-severity="clear"] { background: var(--grade-a); }
285
283
  .grade[data-grade="B"] { background: var(--grade-b); }
286
284
  .grade[data-grade="C"] { background: var(--grade-c); }
287
285
  .grade[data-grade="D"] { background: var(--grade-d); }
288
286
  .grade[data-grade="F"] { background: var(--grade-f); }
289
- .grade[data-grade="none"] { background: var(--grade-none); }
290
287
  .ring { color: var(--ink); }
288
+ .ring[data-grade="none"] { border: .25rem solid var(--rule); border-radius: 50%; }
291
289
  .ring svg { width: 2.5rem; height: 2.5rem; }
292
290
  .ring-track { fill: none; stroke: var(--rule); stroke-width: 4.5; }
293
291
  .ring-arc { fill: none; stroke: var(--grade-a); stroke-width: 4.5; stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 20px 20px; }
@@ -297,13 +295,13 @@ main:focus { outline: none; }
297
295
  .ring[data-grade="D"] .ring-arc { stroke: var(--grade-d); }
298
296
  .ring[data-grade="F"] .ring-arc { stroke: var(--grade-f); }
299
297
  .ring-label { fill: var(--ink); font-size: 12.5px; font-weight: 650; text-anchor: middle; }
300
- .severity { background: var(--grade-a); font-size: 1.125rem; }
301
- .severity[data-severity="none"] { background: var(--grade-none); }
298
+ .severity { font-size: 1.125rem; }
302
299
  .severity[data-severity="low"] { background: var(--grade-b); }
303
300
  .severity[data-severity="medium"] { background: var(--grade-c); }
304
301
  .severity[data-severity="high"] { background: var(--grade-d); }
305
302
  .severity[data-severity="critical"] { background: var(--grade-f); }
306
303
  @media (prefers-color-scheme: dark) { .mark:not(.ring) { color: #0d1117; } }
304
+ .grade[data-grade="none"], .severity[data-severity="none"] { color: var(--ink); }
307
305
 
308
306
  .trend { padding: 1rem 1.25rem .5rem; }
309
307
  .chart { min-width: 0; margin-top: .5rem; }
@@ -577,8 +575,9 @@ body > main { flex: 1 0 auto; width: 100%; box-sizing: border-box; padding-botto
577
575
  .chip-level[data-level="3"] { background: var(--grade-d); }
578
576
  .chip-level[data-level="4"] { background: var(--grade-f); }
579
577
  @media (prefers-color-scheme: dark) { .chip-level { color: #0d1117; } }
580
- /* An area with no chart says so once, in the chart's place; the figures under it would only repeat it. */
581
- .verdict-card:has(#trend[data-empty="true"]) .lead:has(.lead-empty) { display: none; }
578
+ /* An area with no chart says so once, in the area's own words and what to do about it, not the chart's generic line. */
579
+ .verdict-card:has(.lead-empty) #trend[data-empty="true"] .empty { display: none; }
580
+ .verdict-card:has(#trend[data-empty="true"]) .lead:has(.lead-empty) { border-top: 0; }
582
581
  /* A lead figure that counts findings, files or a function leads to them, with a quiet underline. */
583
582
  .figure-value a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-decoration-thickness: 1px; text-underline-offset: .15em; }
584
583
  .figure-value a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }
@@ -0,0 +1,8 @@
1
+ import type { Distribution } from '../compose/distribution.js';
2
+ declare const candidates: readonly [readonly ['all', '@repometry/all/internal/distribution'], readonly ['repometry', 'repometry/internal/distribution']];
3
+ export interface CliDistribution {
4
+ readonly name: 'cli' | (typeof candidates)[number][0];
5
+ readonly distribution?: Distribution;
6
+ }
7
+ export declare function installedDistribution(): Promise<CliDistribution>;
8
+ export {};
@@ -0,0 +1,23 @@
1
+ const candidates = [
2
+ ['all', '@repometry/all/internal/distribution'],
3
+ ['repometry', 'repometry/internal/distribution'],
4
+ ];
5
+ export async function installedDistribution() {
6
+ for (const [name, specifier] of candidates) {
7
+ let entry;
8
+ try {
9
+ entry = import.meta.resolve(specifier);
10
+ }
11
+ catch (error) {
12
+ // A distribution may be absent or predate the optional entry point.
13
+ if (error instanceof Error && 'code' in error
14
+ && (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'))
15
+ continue;
16
+ throw error;
17
+ }
18
+ const { default: distribution } = await import(entry);
19
+ return { name, distribution };
20
+ }
21
+ return { name: 'cli' };
22
+ }
23
+ //# sourceMappingURL=distribution.js.map
@@ -15,27 +15,31 @@ export function readInputs(base, inputs) {
15
15
  const cobertura = [];
16
16
  const findings = [];
17
17
  const licenseInputs = [];
18
+ const coverageInputs = new Map([['lcov', lcov], ['go-cover', goCover], ['cobertura', cobertura]]);
18
19
  for (const value of inputs) {
19
- const equal = value.indexOf('=');
20
- const format = value.slice(0, equal);
21
- const file = value.slice(equal + 1);
22
- if (equal < 1 || !/^[a-z][a-z0-9-]*$/.test(format) || file === '')
23
- throw new Error('Use --import FORMAT=PATH');
24
- if (format === 'lcov')
25
- lcov.push(resolve(base, file));
26
- else if (format === 'go-cover')
27
- goCover.push(resolve(base, file));
28
- else if (format === 'cobertura')
29
- cobertura.push(resolve(base, file));
20
+ const { format, file } = importInput(base, value);
21
+ const coverage = coverageInputs.get(format);
22
+ if (coverage !== undefined)
23
+ coverage.push(file);
30
24
  else if (format === 'cyclonedx' || format === 'spdx')
31
- licenseInputs.push({ format, file: resolve(base, file) });
32
- else {
33
- if (!Object.hasOwn(scanners, format))
34
- throw new Error(`Unknown import format: ${format}. Choose ${importerIds.join(', ')}.`);
35
- findings.push({ ...scanners[format], file: resolve(base, file) });
36
- }
25
+ licenseInputs.push({ format, file });
26
+ else
27
+ findings.push(scannerInput(format, file));
37
28
  }
38
29
  return { lcov: lcov.length ? lcov : undefined, goCover: goCover.length ? goCover : undefined,
39
30
  cobertura: cobertura.length ? cobertura : undefined, findings, ...(licenseInputs.length ? { licenseInputs } : {}) };
40
31
  }
32
+ function importInput(base, value) {
33
+ const equal = value.indexOf('=');
34
+ const format = value.slice(0, equal);
35
+ const file = value.slice(equal + 1);
36
+ if (equal < 1 || !/^[a-z][a-z0-9-]*$/.test(format) || file === '')
37
+ throw new Error('Use --import FORMAT=PATH');
38
+ return { format, file: resolve(base, file) };
39
+ }
40
+ function scannerInput(format, file) {
41
+ if (!Object.hasOwn(scanners, format))
42
+ throw new Error('Unknown import format: ' + format + '. Choose ' + importerIds.join(', ') + '.');
43
+ return { ...scanners[format], file };
44
+ }
41
45
  //# sourceMappingURL=imports.js.map
@@ -1,2 +1,2 @@
1
- import type { Distribution } from '../compose/distribution.js';
2
- export declare function runCli(distribution?: Distribution): Promise<void>;
1
+ import type { CliDistribution } from './distribution.js';
2
+ export declare function runCli(explicit?: CliDistribution): Promise<void>;
@@ -19,6 +19,7 @@ import { LocalObjectStore } from '../report/json/store/object-store.js';
19
19
  import { checkStore } from '../report/json/store/store-check.js';
20
20
  import { dispatch, flag, option } from './arguments.js';
21
21
  import { configFile, listOption, loadConfig, readConfig, readConfigValue, readDisplayConfig } from './config.js';
22
+ import { installedDistribution } from './distribution.js';
22
23
  import { analyzeCommits, isSaved } from './range-jobs.js';
23
24
  import { importerIds, readInputs } from './imports.js';
24
25
  import { displayLanguages, outputReports, reporterIds, viewTarget } from './reporting.js';
@@ -34,7 +35,7 @@ const storageOptions = { repo: repoOption, store: storeOption };
34
35
  const displayOptions = {
35
36
  ...configOptions, branch: option('NAME', 'Name the branch shown in the report.'), title: option('NAME', 'Set the report title.'),
36
37
  };
37
- function commands(distribution) {
38
+ function commands({ distribution, name }) {
38
39
  return {
39
40
  analyze: {
40
41
  description: 'Analyze and save one revision or a range of commits.', parameters: '[REVISION | BASE..[HEAD]]', max: 1,
@@ -85,7 +86,7 @@ function commands(distribution) {
85
86
  const { root, repository } = await repositoryContext(input);
86
87
  const config = await readConfig(root, input, true, distribution);
87
88
  const missingLanguagePlugins = repository === undefined ? [] : await discoverHead(repository, config);
88
- print({ schema: 'urn:repometry:schema:plugin-list:2', plugins: effectivePlugins(config.plugins, config.parsers),
89
+ print({ schema: 'urn:repometry:schema:plugin-list:2', distribution: name, plugins: effectivePlugins(config.plugins, config.parsers),
89
90
  importers: importerIds, reporters: reporterIds, ci: ['github'], stores: ['local', 'git'], missingLanguagePlugins });
90
91
  },
91
92
  },
@@ -298,11 +299,13 @@ function inspectionSummary(report) {
298
299
  function print(value) {
299
300
  process.stdout.write(JSON.stringify(value, null, 2) + '\n');
300
301
  }
301
- export async function runCli(distribution) {
302
+ export async function runCli(explicit) {
302
303
  try {
304
+ const selection = explicit ?? await installedDistribution();
305
+ const { distribution, name } = selection;
303
306
  const packageUrl = new URL(distribution?.packageUrl ?? '../../../../package.json', import.meta.url);
304
307
  const manifest = JSON.parse(await readFile(packageUrl, 'utf8'));
305
- process.exitCode = await dispatch(commands(distribution), process.argv.slice(2), manifest.version);
308
+ process.exitCode = await dispatch(commands(selection), process.argv.slice(2), `${manifest.version} ${name}`);
306
309
  }
307
310
  catch (error) {
308
311
  process.stderr.write(`repometry: ${error instanceof Error ? error.message : String(error)}\n`);
@@ -0,0 +1,12 @@
1
+ import type { SourceSnapshot } from '@repometry/core/internal/model/source.js';
2
+ import type { AnalysisResults } from './analysis-results.js';
3
+ import type { AnalysisSources } from './phases.js';
4
+ export declare function reportInventory(snapshot: SourceSnapshot, sources: AnalysisSources, results: AnalysisResults): {
5
+ path: string;
6
+ lines: number | null;
7
+ bytes?: number | undefined;
8
+ language: string;
9
+ analysed: boolean;
10
+ provider?: string | undefined;
11
+ unmeasured?: readonly ("classes" | "codeLines" | "cognitiveComplexity" | "commentLines" | "cyclomaticComplexity" | "duplication" | "functions" | "structuralRules")[] | undefined;
12
+ }[];
@@ -0,0 +1,18 @@
1
+ import { structureMeasures } from '@repometry/core/internal/model/code-structure.js';
2
+ import { fileTypeId } from '@repometry/core/internal/model/file-types.js';
3
+ import { comparePaths, textLineCount } from '@repometry/core/internal/model/snapshot.js';
4
+ export function reportInventory(snapshot, sources, results) {
5
+ const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
6
+ for (const { path, bytes } of snapshot.files) {
7
+ if (!inventory.has(path))
8
+ inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
9
+ }
10
+ return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
11
+ const provider = sources.providersByPath.get(path);
12
+ const unmeasured = sources.unavailableFiles.has(path) ? structureMeasures : results.unmeasured.get(path);
13
+ return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? fileTypeId(path),
14
+ analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }),
15
+ ...(unmeasured === undefined ? {} : { unmeasured }) };
16
+ });
17
+ }
18
+ //# sourceMappingURL=analysis-inventory.js.map
@@ -1,11 +1,12 @@
1
- import { codeStructure, codeStructures, structureMeasures } from '@repometry/core/internal/model/code-structure.js';
1
+ import { codeStructure, codeStructures } from '@repometry/core/internal/model/code-structure.js';
2
2
  import { pluginRegistration } from './registered-plugin.js';
3
3
  import { pluginScope } from './plugin-scope.js';
4
4
  import { checkedDependencies } from '@repometry/core/internal/model/license-evidence.js';
5
5
  import { definitions } from '@repometry/core/internal/model/measurement.js';
6
6
  import { debtModel } from '@repometry/core/internal/model/quality-summary.js';
7
7
  import { reportSchema } from '@repometry/core/internal/model/report.js';
8
- import { comparePaths, digest, sourceDirectoriesExcluded, textLineCount } from '@repometry/core/internal/model/snapshot.js';
8
+ import { digest, sourceDirectoriesExcluded } from '@repometry/core/internal/model/snapshot.js';
9
+ import { reportInventory } from './analysis-inventory.js';
9
10
  import { defaultSourceExclusions, generatedSourcePolicy } from '@repometry/core/internal/profile/exclusions.js';
10
11
  import { duplicationSettings, structuralRules } from '@repometry/core/internal/profile/maintainability.js';
11
12
  import { fileTypeId } from '@repometry/core/internal/model/file-types.js';
@@ -118,18 +119,4 @@ function inspectionStatus(hasSources, results) {
118
119
  return 'partial';
119
120
  return !hasSources && !results.completedInspection ? 'not-applicable' : 'complete';
120
121
  }
121
- function reportInventory(snapshot, sources, results) {
122
- const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
123
- for (const { path, bytes } of snapshot.files) {
124
- if (!inventory.has(path))
125
- inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
126
- }
127
- return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
128
- const provider = sources.providersByPath.get(path);
129
- const unmeasured = sources.unavailableFiles.has(path) ? structureMeasures : results.unmeasured.get(path);
130
- return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? fileTypeId(path),
131
- analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }),
132
- ...(unmeasured === undefined ? {} : { unmeasured }) };
133
- });
134
- }
135
122
  //# sourceMappingURL=analysis-report.js.map
@@ -32,6 +32,7 @@ export declare class AnalysisResults {
32
32
  }[];
33
33
  record(task: PlannedOperation, outcome: Outcome, path?: string, paths?: readonly string[]): void;
34
34
  hasBlockingDiagnostics(): boolean;
35
+ private recordFindings;
35
36
  private recordRecovery;
36
37
  private recordInspection;
37
38
  }
@@ -53,18 +53,8 @@ export class AnalysisResults {
53
53
  const stored = this.products.record(task, outcome.product, path);
54
54
  this.recordRecovery(task, outcome.product.value, path);
55
55
  this.recordInspection(task, outcome.diagnostics ?? [], path, paths);
56
- if (stored) {
57
- for (const measurement of stored.measurements)
58
- this.measurements.push(measurement);
59
- const reasons = new Map(stored.ignored?.map(({ index, reason }) => [index, reason]));
60
- for (const [index, finding] of stored.findings.entries()) {
61
- const reason = reasons.get(index);
62
- if (reason === undefined)
63
- this.findings.push(finding);
64
- else
65
- this.ignoredFindings.push({ finding, reason });
66
- }
67
- }
56
+ if (stored)
57
+ this.recordFindings(stored);
68
58
  }
69
59
  catch (error) {
70
60
  this.diagnostics.push({ operation: task.key, state: 'failed', path, message: error instanceof Error ? error.message : String(error) });
@@ -73,6 +63,18 @@ export class AnalysisResults {
73
63
  hasBlockingDiagnostics() {
74
64
  return this.diagnostics.some(row => row.path === undefined || this.recovered.get(row.path) !== row);
75
65
  }
66
+ recordFindings(stored) {
67
+ for (const measurement of stored.measurements)
68
+ this.measurements.push(measurement);
69
+ const reasons = new Map(stored.ignored?.map(({ index, reason }) => [index, reason]));
70
+ for (const [index, finding] of stored.findings.entries()) {
71
+ const reason = reasons.get(index);
72
+ if (reason === undefined)
73
+ this.findings.push(finding);
74
+ else
75
+ this.ignoredFindings.push({ finding, reason });
76
+ }
77
+ }
76
78
  recordRecovery(task, value, path) {
77
79
  if (path === undefined || this.recovered.has(path) || !this.recoveryOperations.has(task.key))
78
80
  return;
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
2
- import { builtInConfigurations, builtInPlugins } from '../plugins/built-in.js';
3
- export { builtInConfigurations, builtInPlugins };
2
+ import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from '../plugins/built-in.js';
3
+ export { builtInConfigurations, builtInOptionChecks, builtInPlugins };
4
4
  export declare const builtInPluginIds: ReadonlySet<string>;
5
5
  /** Configured built-ins replace their defaults in registration order. */
6
6
  export declare function registeredPlugins(additional: readonly Plugin[]): readonly Plugin[];
@@ -1,7 +1,7 @@
1
1
  import { pluginRegistration } from './registered-plugin.js';
2
- import { builtInConfigurations, builtInPlugins } from '../plugins/built-in.js';
2
+ import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from '../plugins/built-in.js';
3
3
  // The one edge from compose to plugins: everything else in compose reads the built-ins from here.
4
- export { builtInConfigurations, builtInPlugins };
4
+ export { builtInConfigurations, builtInOptionChecks, builtInPlugins };
5
5
  export const builtInPluginIds = new Set(builtInPlugins.map(({ id }) => id));
6
6
  /** Configured built-ins replace their defaults in registration order. */
7
7
  export function registeredPlugins(additional) {
@@ -1,5 +1,5 @@
1
1
  import { dirname, resolve } from 'node:path';
2
- import { builtInConfigurations, builtInPlugins } from './built-ins.js';
2
+ import { builtInConfigurations, builtInOptionChecks, builtInPlugins } from './built-ins.js';
3
3
  import { installedModule, javaScriptManifest, localModule } from './js-plugin.js';
4
4
  import { validatePluginOptions } from './plugin-options.js';
5
5
  import { dockerPluginFile, dockerPluginImage } from './process-plugins.js';
@@ -50,16 +50,13 @@ async function resolvePlugin(input, entry, folder, context, builtIns) {
50
50
  return { ...await dockerPluginImage(use.slice(7), entry, { base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
51
51
  }
52
52
  if (use.startsWith('./') || use.startsWith('../') || use.startsWith('/')) {
53
- const path = resolve(folder, use);
54
- if (path.endsWith('.json')) {
55
- return { ...await dockerPluginFile(path, entry, { base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
56
- }
57
- return { ...await localModule(path, entry, context), builtIn: false };
53
+ return resolvePluginFile(resolve(folder, use), entry, context);
58
54
  }
59
55
  const pkg = use.startsWith('npm:') ? use.slice(4) : use;
60
56
  const alias = pkg.startsWith('@repometry/language-') ? builtIns.get(pkg.slice('@repometry/'.length)) : undefined;
61
57
  const builtIn = builtIns.get(use) ?? alias;
62
58
  if (builtIn !== undefined) {
59
+ builtInOptionChecks.get(builtIn.id)?.(entry.options);
63
60
  validatePluginOptions(builtIn.config, entry.options, base);
64
61
  const configure = builtInConfigurations.get(builtIn.id);
65
62
  const plugin = configure && entry.options !== undefined ? configure(entry.options) : builtIn;
@@ -70,4 +67,10 @@ async function resolvePlugin(input, entry, folder, context, builtIns) {
70
67
  ? { ...installed.plugin, languageProvenanceRequiresSource: true } : installed.plugin;
71
68
  return { ...installed, plugin, builtIn: false };
72
69
  }
70
+ async function resolvePluginFile(path, entry, context) {
71
+ if (path.endsWith('.json')) {
72
+ return { ...await dockerPluginFile(path, entry, { base: context.base, packageUrl: context.distribution?.packageUrl }), builtIn: false };
73
+ }
74
+ return { ...await localModule(path, entry, context), builtIn: false };
75
+ }
73
76
  //# sourceMappingURL=load-plugins.js.map
@@ -1,5 +1,7 @@
1
1
  import type { JsonValue } from '@repometry/core/internal/model/plugin-data.js';
2
+ import { rejectRemovedLicenseOptions } from './legal/licenses.js';
2
3
  import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
4
+ export declare const builtInOptionChecks: Map<string, typeof rejectRemovedLicenseOptions>;
3
5
  export declare const builtInConfigurations: Map<string, (options: JsonValue) => Plugin>;
4
6
  /** The built-in plugins in run order. The first language plugin is the default provider. */
5
7
  export declare const builtInPlugins: readonly Plugin[];
@@ -1,4 +1,4 @@
1
- import { licenses } from './legal/licenses.js';
1
+ import { licenses, rejectRemovedLicenseOptions } from './legal/licenses.js';
2
2
  import { bundledPlugin } from '@repometry/core/internal/engine/plugin-manifest.js';
3
3
  import { coverage } from './coverage/coverage.js';
4
4
  import { diffCoverage } from './coverage/diff-coverage.js';
@@ -14,6 +14,7 @@ import { githubSource, gitlabSource, localSource } from './source/forges.js';
14
14
  import { structure } from './structure/structure.js';
15
15
  // The review path uses the importer kind, which is also part of existing inspection profiles.
16
16
  const licensePlugin = licenses();
17
+ export const builtInOptionChecks = new Map([[licensePlugin.id, rejectRemovedLicenseOptions]]);
17
18
  export const builtInConfigurations = new Map([[licensePlugin.id, licenses]]);
18
19
  const lcov = { ...bundledPlugin(coverage), kinds: ['coverage', 'import'] };
19
20
  /** The built-in plugins in run order. The first language plugin is the default provider. */