qualink 0.0.1 → 0.1.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -11
  3. package/bin/qualink.js +15 -1
  4. package/dist/cli/cli-error.d.ts +4 -0
  5. package/dist/cli/cli-error.js +7 -0
  6. package/dist/cli/command-factory.d.ts +77 -0
  7. package/dist/cli/command-factory.js +36 -0
  8. package/dist/cli/commands/biome.d.ts +64 -0
  9. package/dist/cli/commands/biome.js +38 -0
  10. package/dist/cli/commands/coverage-dotnet.d.ts +64 -0
  11. package/dist/cli/commands/coverage-dotnet.js +12 -0
  12. package/dist/cli/commands/coverage-js.d.ts +64 -0
  13. package/dist/cli/commands/coverage-js.js +21 -0
  14. package/dist/cli/commands/eslint.d.ts +64 -0
  15. package/dist/cli/commands/eslint.js +38 -0
  16. package/dist/cli/commands/index.d.ts +7 -0
  17. package/dist/cli/commands/index.js +7 -0
  18. package/dist/cli/commands/lighthouse.d.ts +64 -0
  19. package/dist/cli/commands/lighthouse.js +20 -0
  20. package/dist/cli/commands/meta.d.ts +64 -0
  21. package/dist/cli/commands/meta.js +19 -0
  22. package/dist/cli/commands/sarif.d.ts +64 -0
  23. package/dist/cli/commands/sarif.js +34 -0
  24. package/dist/cli/common-args.d.ts +88 -0
  25. package/dist/cli/common-args.js +44 -0
  26. package/dist/cli/detect-ci.d.ts +5 -0
  27. package/dist/cli/detect-ci.js +41 -0
  28. package/dist/cli/detect-package.d.ts +3 -0
  29. package/dist/cli/detect-package.js +42 -0
  30. package/dist/cli/detect-project.d.ts +2 -0
  31. package/dist/cli/detect-project.js +28 -0
  32. package/dist/cli/detect-repo.d.ts +3 -0
  33. package/dist/cli/detect-repo.js +37 -0
  34. package/dist/cli/git.d.ts +1 -0
  35. package/dist/cli/git.js +14 -0
  36. package/dist/cli/index.d.ts +1 -0
  37. package/dist/cli/index.js +40 -0
  38. package/dist/cli/load-input.d.ts +3 -0
  39. package/dist/cli/load-input.js +11 -0
  40. package/dist/cli/parse-languages.d.ts +2 -0
  41. package/dist/cli/parse-languages.js +10 -0
  42. package/dist/cli/parse-metadata.d.ts +3 -0
  43. package/dist/cli/parse-metadata.js +49 -0
  44. package/dist/cli/send-to-sink.d.ts +3 -0
  45. package/dist/cli/send-to-sink.js +55 -0
  46. package/dist/collectors/biome.d.ts +21 -0
  47. package/dist/collectors/biome.js +137 -0
  48. package/dist/collectors/coverage-dotnet.d.ts +2 -0
  49. package/dist/collectors/coverage-dotnet.js +96 -0
  50. package/dist/collectors/coverage-js.d.ts +7 -0
  51. package/dist/collectors/coverage-js.js +128 -0
  52. package/dist/collectors/eslint.d.ts +22 -0
  53. package/dist/collectors/eslint.js +124 -0
  54. package/dist/collectors/index.d.ts +6 -0
  55. package/dist/collectors/index.js +6 -0
  56. package/dist/collectors/lighthouse.d.ts +2 -0
  57. package/dist/collectors/lighthouse.js +37 -0
  58. package/dist/collectors/sarif.d.ts +8 -0
  59. package/dist/collectors/sarif.js +110 -0
  60. package/dist/normalize.d.ts +11 -0
  61. package/dist/normalize.js +20 -0
  62. package/dist/sinks/elastic.d.ts +18 -0
  63. package/dist/sinks/elastic.js +114 -0
  64. package/dist/sinks/index.d.ts +10 -0
  65. package/dist/sinks/index.js +16 -0
  66. package/dist/sinks/stdout.d.ts +4 -0
  67. package/dist/sinks/stdout.js +10 -0
  68. package/dist/sinks/types.d.ts +8 -0
  69. package/dist/sinks/types.js +1 -0
  70. package/dist/types.d.ts +106 -0
  71. package/dist/types.js +1 -0
  72. package/dist/utils/assert.d.ts +2 -0
  73. package/dist/utils/assert.js +12 -0
  74. package/dist/utils/file.d.ts +2 -0
  75. package/dist/utils/file.js +8 -0
  76. package/dist/utils/guards.d.ts +1 -0
  77. package/dist/utils/guards.js +3 -0
  78. package/dist/utils/metrics.d.ts +2 -0
  79. package/dist/utils/metrics.js +12 -0
  80. package/package.json +38 -6
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Allan Kimmer Jensen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,19 +1,32 @@
1
1
  # qualink
2
2
 
3
+ [![CI](https://github.com/Saturate/qualink/actions/workflows/ci.yml/badge.svg)](https://github.com/Saturate/qualink/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/qualink)](https://www.npmjs.com/package/qualink)
5
+
3
6
  Collect, normalize, and relay code quality metrics from CI.
7
+ `qualink` standardizes code quality telemetry across repos and languages, then ships it to a sink (Elastic for now, if you need something else do a PR or a ticket).
8
+
9
+ ## Install
4
10
 
5
- ## Why
11
+ ```bash
12
+ npm install -g qualink
13
+ pnpm add -g qualink
14
+ bun add -g qualink
15
+ ```
6
16
 
7
- `qualink` standardizes code quality telemetry across repos and languages, then ships it to a sink (Elastic first).
17
+ Or run directly:
8
18
 
9
- ## Scope (v1)
19
+ ```bash
20
+ npx qualink collect eslint --input report.json --sink stdout
21
+ ```
10
22
 
11
- - Frontend: ESLint, Lighthouse, Vitest coverage
12
- - Backend: Roslyn analyzers (SARIF), .NET coverage
13
- - CI: Azure DevOps
14
- - Sink: Elasticsearch
23
+ ## CI Examples
15
24
 
16
- ## CLI shape
25
+ Repo, branch, commit SHA, pipeline run ID, and provider are auto-detected from CI environment variables, no need to pass them manually.
26
+
27
+ See the [examples/](examples/) folder for copy-paste snippets for Azure DevOps and GitHub Actions.
28
+
29
+ ## CLI usage
17
30
 
18
31
  ```bash
19
32
  qualink collect <collector> --input <path> --sink elastic [flags]
@@ -22,8 +35,53 @@ qualink collect <collector> --input <path> --sink elastic [flags]
22
35
  Examples:
23
36
 
24
37
  ```bash
25
- qualink collect eslint --input eslint-report.json --sink elastic --repo frontend-mono --team frontend --branch main --commit-sha abc123 --pipeline-run-id 987
26
- qualink collect sarif --input analyzers.sarif --sink elastic --repo backend-api --team backend --branch main --commit-sha def456 --pipeline-run-id 654
38
+ qualink collect eslint --input eslint-report.json --sink elastic --repo frontend-mono --category frontend --tags frontend,web --branch main --commit-sha abc123 --pipeline-run-id 987
39
+ qualink collect sarif --input analyzers.sarif --sink elastic --repo backend-api --category backend --tags backend,api --branch main --commit-sha def456 --pipeline-run-id 654
40
+ qualink collect coverage-dotnet --input coverage.cobertura.xml --sink elastic --repo backend-api --category backend --tags backend,api --branch main --commit-sha def456 --pipeline-run-id 654
27
41
  ```
28
42
 
29
- See `ADR-qualink-v1.md` for the full architecture and rollout plan.
43
+ Collectors:
44
+
45
+ - `biome` (Biome JSON)
46
+ - `eslint` (ESLint JSON)
47
+ - `lighthouse` (Lighthouse JSON)
48
+ - `coverage-js` (Istanbul/Vitest JSON)
49
+ - `sarif` (Roslyn or generic SARIF JSON)
50
+ - `coverage-dotnet` (Cobertura/OpenCover XML)
51
+
52
+ ESLint file-level options (optional):
53
+
54
+ - `--top-files <n>` adds `top_files` with the top offending files (default: `0`, disabled)
55
+ - `--include-all-files` adds `all_files` with every file that has lint issues
56
+
57
+ Classification metadata (optional):
58
+
59
+ - `--category` for a single broad bucket
60
+ - `--tags` for flexible multi-label filtering (`comma,separated`)
61
+
62
+ Metadata auto-detection:
63
+
64
+ - `repo`: from flag/env, then git origin, then current folder name
65
+ - `branch`: from flag/env, then git branch
66
+ - `commit_sha`: from flag/env, then git commit
67
+ - `pipeline_run_id`: from flag/env, fallback `local-<timestamp>`
68
+
69
+ If needed, you can still pass explicit values with `--repo`, `--branch`, `--commit-sha`, and `--pipeline-run-id`.
70
+
71
+ Sink configuration:
72
+
73
+ - `--sink elastic` (default) requires `ELASTIC_URL` and `ELASTIC_API_KEY`
74
+ - `--sink stdout` prints normalized documents for debugging
75
+
76
+ Dry run mode:
77
+
78
+ - `--dry-run` validates and prints normalized payloads without sending to any sink
79
+
80
+ Useful env fallbacks:
81
+
82
+ - `QUALINK_REPO`, `QUALINK_CATEGORY`, `QUALINK_TAGS`, `QUALINK_BRANCH`, `QUALINK_COMMIT_SHA`, `QUALINK_PIPELINE_RUN_ID`
83
+ - `QUALINK_PACKAGE` (monorepo package name, auto-detected from `PNPM_PACKAGE_NAME`)
84
+ - `QUALINK_PROJECT` (backend project identity)
85
+ - `QUALINK_PIPELINE_PROVIDER` (auto-detected, fallback: `local`)
86
+ - `QUALINK_ENVIRONMENT` (default: `ci`)
87
+ - `QUALINK_SINK` (default: `elastic`)
package/bin/qualink.js CHANGED
@@ -1,3 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- console.log('qualink: CLI scaffold is in place.');
3
+ import { existsSync } from "node:fs";
4
+ import { fileURLToPath } from "node:url";
5
+ import { dirname, join } from "node:path";
6
+
7
+ const currentDir = dirname(fileURLToPath(import.meta.url));
8
+ const cliFile = join(currentDir, "..", "dist", "cli", "index.js");
9
+
10
+ if (!existsSync(cliFile)) {
11
+ process.stderr.write(
12
+ "qualink build output not found. Run `npm run build` before using the CLI.\n",
13
+ );
14
+ process.exit(1);
15
+ }
16
+
17
+ await import(cliFile);
@@ -0,0 +1,4 @@
1
+ export declare class CliError extends Error {
2
+ readonly exitCode: number;
3
+ constructor(message: string, exitCode: number);
4
+ }
@@ -0,0 +1,7 @@
1
+ export class CliError extends Error {
2
+ exitCode;
3
+ constructor(message, exitCode) {
4
+ super(message);
5
+ this.exitCode = exitCode;
6
+ }
7
+ }
@@ -0,0 +1,77 @@
1
+ import type { CommonMetadata, MetricType, NormalizedDocument } from "../types.js";
2
+ import { type CommonArgs } from "./common-args.js";
3
+ interface CollectorResult {
4
+ metricType: MetricType;
5
+ documents: NormalizedDocument[];
6
+ }
7
+ interface CollectorCommandConfig<TExtra extends Record<string, unknown>> {
8
+ name: string;
9
+ description: string;
10
+ extraArgs?: TExtra;
11
+ collect: (args: CommonArgs, metadata: CommonMetadata) => Promise<CollectorResult>;
12
+ }
13
+ export declare function createCollectorCommand<TExtra extends Record<string, unknown>>(config: CollectorCommandConfig<TExtra>): import("citty").CommandDef<{
14
+ input: {
15
+ readonly type: "string";
16
+ readonly required: true;
17
+ };
18
+ sink: {
19
+ readonly type: "string";
20
+ readonly default: "elastic";
21
+ };
22
+ repo: {
23
+ readonly type: "string";
24
+ };
25
+ category: {
26
+ readonly type: "string";
27
+ };
28
+ tags: {
29
+ readonly type: "string";
30
+ };
31
+ branch: {
32
+ readonly type: "string";
33
+ };
34
+ "commit-sha": {
35
+ readonly type: "string";
36
+ };
37
+ "pipeline-run-id": {
38
+ readonly type: "string";
39
+ };
40
+ "pipeline-provider": {
41
+ readonly type: "string";
42
+ };
43
+ environment: {
44
+ readonly type: "string";
45
+ readonly default: "ci";
46
+ };
47
+ package: {
48
+ readonly type: "string";
49
+ };
50
+ project: {
51
+ readonly type: "string";
52
+ };
53
+ "collector-version": {
54
+ readonly type: "string";
55
+ };
56
+ "elastic-url": {
57
+ readonly type: "string";
58
+ };
59
+ "elastic-api-key": {
60
+ readonly type: "string";
61
+ };
62
+ "retry-max": {
63
+ readonly type: "string";
64
+ };
65
+ "retry-backoff-ms": {
66
+ readonly type: "string";
67
+ };
68
+ "allow-empty": {
69
+ readonly type: "boolean";
70
+ readonly default: false;
71
+ };
72
+ "dry-run": {
73
+ readonly type: "boolean";
74
+ readonly default: false;
75
+ };
76
+ }>;
77
+ export {};
@@ -0,0 +1,36 @@
1
+ import { defineCommand } from "citty";
2
+ import { CliError } from "./cli-error.js";
3
+ import { commonArgs, isDryRun } from "./common-args.js";
4
+ import { parseCommonMetadata } from "./parse-metadata.js";
5
+ import { sendToSink } from "./send-to-sink.js";
6
+ export function createCollectorCommand(config) {
7
+ return defineCommand({
8
+ meta: {
9
+ name: config.name,
10
+ description: config.description,
11
+ },
12
+ args: {
13
+ ...commonArgs,
14
+ ...config.extraArgs,
15
+ },
16
+ async run({ args }) {
17
+ try {
18
+ const parsedArgs = args;
19
+ const metadata = parseCommonMetadata(parsedArgs);
20
+ const { metricType, documents } = await config.collect(parsedArgs, metadata);
21
+ await sendToSink(metricType, parsedArgs, documents);
22
+ const verb = isDryRun(parsedArgs) ? "dry-run produced" : "relayed";
23
+ process.stdout.write(`${verb} ${documents.length} ${metricType} document(s)\n`);
24
+ }
25
+ catch (error) {
26
+ if (error instanceof CliError) {
27
+ throw error;
28
+ }
29
+ if (error instanceof Error) {
30
+ throw new CliError(error.message, 2);
31
+ }
32
+ throw new CliError("Unknown error", 2);
33
+ }
34
+ },
35
+ });
36
+ }
@@ -0,0 +1,64 @@
1
+ export declare const biomeCommand: import("citty").CommandDef<{
2
+ input: {
3
+ readonly type: "string";
4
+ readonly required: true;
5
+ };
6
+ sink: {
7
+ readonly type: "string";
8
+ readonly default: "elastic";
9
+ };
10
+ repo: {
11
+ readonly type: "string";
12
+ };
13
+ category: {
14
+ readonly type: "string";
15
+ };
16
+ tags: {
17
+ readonly type: "string";
18
+ };
19
+ branch: {
20
+ readonly type: "string";
21
+ };
22
+ "commit-sha": {
23
+ readonly type: "string";
24
+ };
25
+ "pipeline-run-id": {
26
+ readonly type: "string";
27
+ };
28
+ "pipeline-provider": {
29
+ readonly type: "string";
30
+ };
31
+ environment: {
32
+ readonly type: "string";
33
+ readonly default: "ci";
34
+ };
35
+ package: {
36
+ readonly type: "string";
37
+ };
38
+ project: {
39
+ readonly type: "string";
40
+ };
41
+ "collector-version": {
42
+ readonly type: "string";
43
+ };
44
+ "elastic-url": {
45
+ readonly type: "string";
46
+ };
47
+ "elastic-api-key": {
48
+ readonly type: "string";
49
+ };
50
+ "retry-max": {
51
+ readonly type: "string";
52
+ };
53
+ "retry-backoff-ms": {
54
+ readonly type: "string";
55
+ };
56
+ "allow-empty": {
57
+ readonly type: "boolean";
58
+ readonly default: false;
59
+ };
60
+ "dry-run": {
61
+ readonly type: "boolean";
62
+ readonly default: false;
63
+ };
64
+ }>;
@@ -0,0 +1,38 @@
1
+ import { collectBiome } from "../../collectors/biome.js";
2
+ import { createCollectorCommand } from "../command-factory.js";
3
+ import { loadJsonInput } from "../load-input.js";
4
+ import { parseLanguages } from "../parse-languages.js";
5
+ function parseIntWithMin(value, fallback, min) {
6
+ if (typeof value === "number") {
7
+ return value >= min ? Math.floor(value) : fallback;
8
+ }
9
+ if (typeof value === "string" && value.trim().length > 0) {
10
+ const parsed = Number(value);
11
+ if (Number.isFinite(parsed) && parsed >= min) {
12
+ return Math.floor(parsed);
13
+ }
14
+ }
15
+ return fallback;
16
+ }
17
+ export const biomeCommand = createCollectorCommand({
18
+ name: "biome",
19
+ description: "Collect Biome lint metrics and relay them",
20
+ extraArgs: {
21
+ "include-rules": { type: "boolean", default: true },
22
+ "top-rules": { type: "string", default: "25" },
23
+ "include-all-files": { type: "boolean", default: false },
24
+ "top-files": { type: "string", default: "0" },
25
+ language: { type: "string" },
26
+ },
27
+ async collect(args, metadata) {
28
+ const input = await loadJsonInput(args);
29
+ const documents = collectBiome(input, metadata, {
30
+ includeRules: (args.includeRules ?? args["include-rules"]) !== false,
31
+ topRules: parseIntWithMin(args.topRules ?? args["top-rules"], 25, 1),
32
+ includeAllFiles: (args.includeAllFiles ?? args["include-all-files"]) === true,
33
+ topFiles: parseIntWithMin(args.topFiles ?? args["top-files"], 0, 0),
34
+ languages: parseLanguages(args.language),
35
+ });
36
+ return { metricType: "biome", documents };
37
+ },
38
+ });
@@ -0,0 +1,64 @@
1
+ export declare const coverageDotnetCommand: import("citty").CommandDef<{
2
+ input: {
3
+ readonly type: "string";
4
+ readonly required: true;
5
+ };
6
+ sink: {
7
+ readonly type: "string";
8
+ readonly default: "elastic";
9
+ };
10
+ repo: {
11
+ readonly type: "string";
12
+ };
13
+ category: {
14
+ readonly type: "string";
15
+ };
16
+ tags: {
17
+ readonly type: "string";
18
+ };
19
+ branch: {
20
+ readonly type: "string";
21
+ };
22
+ "commit-sha": {
23
+ readonly type: "string";
24
+ };
25
+ "pipeline-run-id": {
26
+ readonly type: "string";
27
+ };
28
+ "pipeline-provider": {
29
+ readonly type: "string";
30
+ };
31
+ environment: {
32
+ readonly type: "string";
33
+ readonly default: "ci";
34
+ };
35
+ package: {
36
+ readonly type: "string";
37
+ };
38
+ project: {
39
+ readonly type: "string";
40
+ };
41
+ "collector-version": {
42
+ readonly type: "string";
43
+ };
44
+ "elastic-url": {
45
+ readonly type: "string";
46
+ };
47
+ "elastic-api-key": {
48
+ readonly type: "string";
49
+ };
50
+ "retry-max": {
51
+ readonly type: "string";
52
+ };
53
+ "retry-backoff-ms": {
54
+ readonly type: "string";
55
+ };
56
+ "allow-empty": {
57
+ readonly type: "boolean";
58
+ readonly default: false;
59
+ };
60
+ "dry-run": {
61
+ readonly type: "boolean";
62
+ readonly default: false;
63
+ };
64
+ }>;
@@ -0,0 +1,12 @@
1
+ import { collectCoverageDotnet } from "../../collectors/coverage-dotnet.js";
2
+ import { createCollectorCommand } from "../command-factory.js";
3
+ import { loadTextInput } from "../load-input.js";
4
+ export const coverageDotnetCommand = createCollectorCommand({
5
+ name: "coverage-dotnet",
6
+ description: "Collect .NET coverage metrics and relay them",
7
+ async collect(args, metadata) {
8
+ const input = await loadTextInput(args);
9
+ const documents = collectCoverageDotnet(input, metadata);
10
+ return { metricType: "coverage-dotnet", documents };
11
+ },
12
+ });
@@ -0,0 +1,64 @@
1
+ export declare const coverageJsCommand: import("citty").CommandDef<{
2
+ input: {
3
+ readonly type: "string";
4
+ readonly required: true;
5
+ };
6
+ sink: {
7
+ readonly type: "string";
8
+ readonly default: "elastic";
9
+ };
10
+ repo: {
11
+ readonly type: "string";
12
+ };
13
+ category: {
14
+ readonly type: "string";
15
+ };
16
+ tags: {
17
+ readonly type: "string";
18
+ };
19
+ branch: {
20
+ readonly type: "string";
21
+ };
22
+ "commit-sha": {
23
+ readonly type: "string";
24
+ };
25
+ "pipeline-run-id": {
26
+ readonly type: "string";
27
+ };
28
+ "pipeline-provider": {
29
+ readonly type: "string";
30
+ };
31
+ environment: {
32
+ readonly type: "string";
33
+ readonly default: "ci";
34
+ };
35
+ package: {
36
+ readonly type: "string";
37
+ };
38
+ project: {
39
+ readonly type: "string";
40
+ };
41
+ "collector-version": {
42
+ readonly type: "string";
43
+ };
44
+ "elastic-url": {
45
+ readonly type: "string";
46
+ };
47
+ "elastic-api-key": {
48
+ readonly type: "string";
49
+ };
50
+ "retry-max": {
51
+ readonly type: "string";
52
+ };
53
+ "retry-backoff-ms": {
54
+ readonly type: "string";
55
+ };
56
+ "allow-empty": {
57
+ readonly type: "boolean";
58
+ readonly default: false;
59
+ };
60
+ "dry-run": {
61
+ readonly type: "boolean";
62
+ readonly default: false;
63
+ };
64
+ }>;
@@ -0,0 +1,21 @@
1
+ import { collectCoverageJs } from "../../collectors/coverage-js.js";
2
+ import { createCollectorCommand } from "../command-factory.js";
3
+ import { loadJsonInput } from "../load-input.js";
4
+ import { parseLanguages } from "../parse-languages.js";
5
+ export const coverageJsCommand = createCollectorCommand({
6
+ name: "coverage-js",
7
+ description: "Collect JS coverage metrics and relay them",
8
+ extraArgs: {
9
+ language: { type: "string" },
10
+ "tool-name": { type: "string" },
11
+ },
12
+ async collect(args, metadata) {
13
+ const input = await loadJsonInput(args);
14
+ const toolName = args["tool-name"];
15
+ const documents = collectCoverageJs(input, metadata, {
16
+ languages: parseLanguages(args.language),
17
+ tool: typeof toolName === "string" && toolName.length > 0 ? toolName : undefined,
18
+ });
19
+ return { metricType: "coverage-js", documents };
20
+ },
21
+ });
@@ -0,0 +1,64 @@
1
+ export declare const eslintCommand: import("citty").CommandDef<{
2
+ input: {
3
+ readonly type: "string";
4
+ readonly required: true;
5
+ };
6
+ sink: {
7
+ readonly type: "string";
8
+ readonly default: "elastic";
9
+ };
10
+ repo: {
11
+ readonly type: "string";
12
+ };
13
+ category: {
14
+ readonly type: "string";
15
+ };
16
+ tags: {
17
+ readonly type: "string";
18
+ };
19
+ branch: {
20
+ readonly type: "string";
21
+ };
22
+ "commit-sha": {
23
+ readonly type: "string";
24
+ };
25
+ "pipeline-run-id": {
26
+ readonly type: "string";
27
+ };
28
+ "pipeline-provider": {
29
+ readonly type: "string";
30
+ };
31
+ environment: {
32
+ readonly type: "string";
33
+ readonly default: "ci";
34
+ };
35
+ package: {
36
+ readonly type: "string";
37
+ };
38
+ project: {
39
+ readonly type: "string";
40
+ };
41
+ "collector-version": {
42
+ readonly type: "string";
43
+ };
44
+ "elastic-url": {
45
+ readonly type: "string";
46
+ };
47
+ "elastic-api-key": {
48
+ readonly type: "string";
49
+ };
50
+ "retry-max": {
51
+ readonly type: "string";
52
+ };
53
+ "retry-backoff-ms": {
54
+ readonly type: "string";
55
+ };
56
+ "allow-empty": {
57
+ readonly type: "boolean";
58
+ readonly default: false;
59
+ };
60
+ "dry-run": {
61
+ readonly type: "boolean";
62
+ readonly default: false;
63
+ };
64
+ }>;
@@ -0,0 +1,38 @@
1
+ import { collectEslint } from "../../collectors/eslint.js";
2
+ import { createCollectorCommand } from "../command-factory.js";
3
+ import { loadJsonInput } from "../load-input.js";
4
+ import { parseLanguages } from "../parse-languages.js";
5
+ function parseIntWithMin(value, fallback, min) {
6
+ if (typeof value === "number") {
7
+ return value >= min ? Math.floor(value) : fallback;
8
+ }
9
+ if (typeof value === "string" && value.trim().length > 0) {
10
+ const parsed = Number(value);
11
+ if (Number.isFinite(parsed) && parsed >= min) {
12
+ return Math.floor(parsed);
13
+ }
14
+ }
15
+ return fallback;
16
+ }
17
+ export const eslintCommand = createCollectorCommand({
18
+ name: "eslint",
19
+ description: "Collect ESLint metrics and relay them",
20
+ extraArgs: {
21
+ "include-rules": { type: "boolean", default: true },
22
+ "top-rules": { type: "string", default: "25" },
23
+ "include-all-files": { type: "boolean", default: false },
24
+ "top-files": { type: "string", default: "0" },
25
+ language: { type: "string" },
26
+ },
27
+ async collect(args, metadata) {
28
+ const input = await loadJsonInput(args);
29
+ const documents = collectEslint(input, metadata, {
30
+ includeRules: (args.includeRules ?? args["include-rules"]) !== false,
31
+ topRules: parseIntWithMin(args.topRules ?? args["top-rules"], 25, 1),
32
+ includeAllFiles: (args.includeAllFiles ?? args["include-all-files"]) === true,
33
+ topFiles: parseIntWithMin(args.topFiles ?? args["top-files"], 0, 0),
34
+ languages: parseLanguages(args.language),
35
+ });
36
+ return { metricType: "eslint", documents };
37
+ },
38
+ });
@@ -0,0 +1,7 @@
1
+ export { biomeCommand } from "./biome.js";
2
+ export { coverageDotnetCommand } from "./coverage-dotnet.js";
3
+ export { coverageJsCommand } from "./coverage-js.js";
4
+ export { eslintCommand } from "./eslint.js";
5
+ export { lighthouseCommand } from "./lighthouse.js";
6
+ export { metaCommand } from "./meta.js";
7
+ export { sarifCommand } from "./sarif.js";
@@ -0,0 +1,7 @@
1
+ export { biomeCommand } from "./biome.js";
2
+ export { coverageDotnetCommand } from "./coverage-dotnet.js";
3
+ export { coverageJsCommand } from "./coverage-js.js";
4
+ export { eslintCommand } from "./eslint.js";
5
+ export { lighthouseCommand } from "./lighthouse.js";
6
+ export { metaCommand } from "./meta.js";
7
+ export { sarifCommand } from "./sarif.js";