@dragonshorn-studios/elyseum-cli 1.0.12 → 1.1.1
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/README.md +137 -49
- package/dist/adapters/clover.d.ts +10 -0
- package/dist/adapters/clover.d.ts.map +1 -0
- package/dist/adapters/go-coverprofile.d.ts +15 -0
- package/dist/adapters/go-coverprofile.d.ts.map +1 -0
- package/dist/adapters/go-test-json.d.ts +15 -0
- package/dist/adapters/go-test-json.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +18 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/junit.d.ts +15 -0
- package/dist/adapters/junit.d.ts.map +1 -0
- package/dist/adapters/types.d.ts +66 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/vitest-json.d.ts +12 -0
- package/dist/adapters/vitest-json.d.ts.map +1 -0
- package/dist/commands/command.d.ts +1 -1
- package/dist/commands/command.d.ts.map +1 -1
- package/dist/commands/coverage-command.d.ts +3 -3
- package/dist/commands/coverage-command.d.ts.map +1 -1
- package/dist/commands/diff-coverage-command.d.ts +4 -4
- package/dist/commands/diff-coverage-command.d.ts.map +1 -1
- package/dist/commands/emit-envelope-command.d.ts +43 -0
- package/dist/commands/emit-envelope-command.d.ts.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/core/ci-env.d.ts +27 -0
- package/dist/core/ci-env.d.ts.map +1 -0
- package/dist/core/envelope.d.ts +69 -0
- package/dist/core/envelope.d.ts.map +1 -0
- package/dist/core/errors.d.ts +30 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/exit-codes.d.ts +21 -0
- package/dist/core/exit-codes.d.ts.map +1 -0
- package/dist/core/git-diff.d.ts +80 -0
- package/dist/core/git-diff.d.ts.map +1 -0
- package/dist/core/lcov.d.ts +56 -0
- package/dist/core/lcov.d.ts.map +1 -0
- package/dist/core/quality-gate.d.ts +15 -0
- package/dist/core/quality-gate.d.ts.map +1 -0
- package/dist/index.js +12628 -4434
- package/dist/index.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/package.json +17 -10
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-codes";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for every deliberate CLI failure. Commands throw these; the
|
|
4
|
+
* entry point turns them into stderr messages plus the documented exit code.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class CliError extends Error {
|
|
7
|
+
abstract readonly exitCode: ExitCode;
|
|
8
|
+
abstract readonly actionable: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class InvalidConfigError extends CliError {
|
|
11
|
+
readonly exitCode: 2;
|
|
12
|
+
readonly actionable: string;
|
|
13
|
+
constructor(validationSummary: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class MissingGitError extends CliError {
|
|
16
|
+
readonly exitCode: 3;
|
|
17
|
+
readonly actionable: string;
|
|
18
|
+
constructor(dir: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class MissingLcovError extends CliError {
|
|
21
|
+
readonly exitCode: 4;
|
|
22
|
+
readonly actionable: string;
|
|
23
|
+
constructor(path: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class CalculationFailure extends CliError {
|
|
26
|
+
readonly exitCode: 5;
|
|
27
|
+
readonly actionable: string;
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,8BAAsB,QAAS,SAAQ,KAAK;IAC1C,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CACtC;AAED,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,QAAQ,IAA6B;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,iBAAiB,EAAE,MAAM;CAItC;AAED,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,QAAQ,IAA0B;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,GAAG,EAAE,MAAM;CAKxB;AAED,qBAAa,gBAAiB,SAAQ,QAAQ;IAC5C,QAAQ,CAAC,QAAQ,IAA2B;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,IAAI,EAAE,MAAM;CAIzB;AAED,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,QAAQ,IAAgC;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documented exit-code contract for elyseum-cli. These codes are part of
|
|
3
|
+
* the CLI's public contract (README "Exit codes"); they never change within
|
|
4
|
+
* a major version.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EXIT_CODES: {
|
|
7
|
+
/** Success, or a warning-only condition. */
|
|
8
|
+
readonly SUCCESS: 0;
|
|
9
|
+
/** A configured quality gate was not met. */
|
|
10
|
+
readonly QUALITY_GATE_FAILED: 1;
|
|
11
|
+
/** The configuration file (or CLI arguments) are invalid. */
|
|
12
|
+
readonly INVALID_CONFIG: 2;
|
|
13
|
+
/** A git repository is required but was not found. */
|
|
14
|
+
readonly MISSING_GIT: 3;
|
|
15
|
+
/** The LCOV report file was not found. */
|
|
16
|
+
readonly MISSING_LCOV: 4;
|
|
17
|
+
/** Any other calculation or runtime error. */
|
|
18
|
+
readonly CALCULATION_ERROR: 5;
|
|
19
|
+
};
|
|
20
|
+
export type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
|
|
21
|
+
//# sourceMappingURL=exit-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.d.ts","sourceRoot":"","sources":["../../src/core/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU;IACrB,4CAA4C;;IAE5C,6CAA6C;;IAE7C,6DAA6D;;IAE7D,sDAAsD;;IAEtD,0CAA0C;;IAE1C,8CAA8C;;CAEtC,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { LcovRecord } from "./lcov";
|
|
2
|
+
export interface ChangedFile {
|
|
3
|
+
path: string;
|
|
4
|
+
/** Present when the diff is computed from git; absent for whole-file lists. */
|
|
5
|
+
lines?: number;
|
|
6
|
+
type?: "add" | "modify" | "remove";
|
|
7
|
+
/** Present when the diff is computed from git; absent for whole-file lists. */
|
|
8
|
+
diff?: {
|
|
9
|
+
hunks: {
|
|
10
|
+
newStart: number;
|
|
11
|
+
newLines: number;
|
|
12
|
+
lines?: string[];
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface DiffFacts {
|
|
17
|
+
headSha: string;
|
|
18
|
+
baseSha: string;
|
|
19
|
+
}
|
|
20
|
+
/** Normalizes a leading slash so LCOV paths and diff paths compare equal. */
|
|
21
|
+
export declare function normalizePath(path: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Lines the diff adds that can carry coverage: added (+) lines, or — when a
|
|
24
|
+
* hunk carries no per-line annotations (new files) — every new line in the
|
|
25
|
+
* hunk. Removed lines, context lines, and comment/blank additions are
|
|
26
|
+
* excluded. Pure.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractChangedLineNumbers(hunks: {
|
|
29
|
+
newStart: number;
|
|
30
|
+
newLines: number;
|
|
31
|
+
lines?: string[];
|
|
32
|
+
}[], coverableLineNumbers: Set<number>): Set<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Comment-only or blank additions cannot carry coverage; counting them as
|
|
35
|
+
* uncovered would punish documentation. Pure.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isCommentLine(line: string): boolean;
|
|
38
|
+
/** Pure diff-coverage aggregation over changed files and LCOV records. */
|
|
39
|
+
export declare function calculateDiffCoverage(files: ChangedFile[], coverage: LcovRecord[], facts: DiffFacts): {
|
|
40
|
+
headSha: string;
|
|
41
|
+
baseSha: string;
|
|
42
|
+
lines: {
|
|
43
|
+
total: number;
|
|
44
|
+
covered: number;
|
|
45
|
+
percent: number;
|
|
46
|
+
};
|
|
47
|
+
functions: {
|
|
48
|
+
total: number;
|
|
49
|
+
covered: number;
|
|
50
|
+
percent: number;
|
|
51
|
+
};
|
|
52
|
+
branches: {
|
|
53
|
+
total: number;
|
|
54
|
+
covered: number;
|
|
55
|
+
percent: number;
|
|
56
|
+
};
|
|
57
|
+
files: {
|
|
58
|
+
file: string;
|
|
59
|
+
lines: {
|
|
60
|
+
total: number;
|
|
61
|
+
covered: number;
|
|
62
|
+
percent: number;
|
|
63
|
+
};
|
|
64
|
+
functions: {
|
|
65
|
+
total: number;
|
|
66
|
+
covered: number;
|
|
67
|
+
percent: number;
|
|
68
|
+
};
|
|
69
|
+
branches: {
|
|
70
|
+
total: number;
|
|
71
|
+
covered: number;
|
|
72
|
+
percent: number;
|
|
73
|
+
};
|
|
74
|
+
}[];
|
|
75
|
+
};
|
|
76
|
+
/** Throws MissingGitError when the working directory is not a git checkout. */
|
|
77
|
+
export declare function assertGitRepository(dir: string): Promise<void>;
|
|
78
|
+
/** Walks head vs base and returns changed files with their unified diffs. */
|
|
79
|
+
export declare function getChangedFiles(dir: string, head: string, base: string): Promise<ChangedFile[]>;
|
|
80
|
+
//# sourceMappingURL=git-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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AO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3D,SAAS,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/D,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/D,EAAE,CAAC;CACL,CAwIA;AAED,+EAA+E;AAC/E,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASpE;AAED,6EAA6E;AAC7E,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,WAAW,EAAE,CAAC,CA4DxB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CoverageDetail, CoverageFile } from "../types/coverage-result";
|
|
2
|
+
/**
|
|
3
|
+
* Pure coverage math. Total coverage percentages are finite by definition:
|
|
4
|
+
* a zero denominator means "nothing to cover", which is 100% covered —
|
|
5
|
+
* never NaN.
|
|
6
|
+
*/
|
|
7
|
+
export declare function percent(covered: number, total: number): number;
|
|
8
|
+
/** LCOV record as produced by lcov-parse, typed loosely on purpose. */
|
|
9
|
+
export interface LcovRecord {
|
|
10
|
+
file: string;
|
|
11
|
+
lines: {
|
|
12
|
+
found: number;
|
|
13
|
+
hit: number;
|
|
14
|
+
details: LineDetail[];
|
|
15
|
+
};
|
|
16
|
+
functions: {
|
|
17
|
+
found: number;
|
|
18
|
+
hit: number;
|
|
19
|
+
details: FunctionDetail[];
|
|
20
|
+
};
|
|
21
|
+
branches: {
|
|
22
|
+
found: number;
|
|
23
|
+
hit: number;
|
|
24
|
+
details: BranchDetail[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface LineDetail {
|
|
28
|
+
line: number;
|
|
29
|
+
hit: number;
|
|
30
|
+
}
|
|
31
|
+
export interface FunctionDetail {
|
|
32
|
+
name: string;
|
|
33
|
+
line: number;
|
|
34
|
+
hit: number;
|
|
35
|
+
}
|
|
36
|
+
export interface BranchDetail {
|
|
37
|
+
block: number;
|
|
38
|
+
branch: number;
|
|
39
|
+
line: number;
|
|
40
|
+
taken: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads and parses an LCOV report. A missing file is an actionable
|
|
44
|
+
* MissingLcovError; a malformed file is a calculation error.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readLcovReport(path: string): Promise<LcovRecord[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Aggregates parsed LCOV records into the total coverage result. Pure.
|
|
49
|
+
*/
|
|
50
|
+
export declare function calculateTotalCoverage(records: LcovRecord[]): {
|
|
51
|
+
lines: CoverageDetail;
|
|
52
|
+
functions: CoverageDetail;
|
|
53
|
+
branches: CoverageDetail;
|
|
54
|
+
files: CoverageFile[];
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=lcov.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcov.d.ts","sourceRoot":"","sources":["../../src/core/lcov.ts"],"names":[],"mappings":"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;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CA6CA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type QualityGateOutcome = "passed" | "warning" | "failed";
|
|
2
|
+
export interface QualityGateThresholds {
|
|
3
|
+
/** Warn band ceiling: percent < gate warns; percent >= gate passes.
|
|
4
|
+
* Undefined means no warn band. */
|
|
5
|
+
gate?: number;
|
|
6
|
+
/** Fail ceiling, inclusive: percent <= fail fails. Undefined disables
|
|
7
|
+
* the fail path (the gate alone can only warn). */
|
|
8
|
+
fail?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Pure quality-gate evaluation: the changed-line coverage percentage against
|
|
12
|
+
* the configured thresholds. Absent thresholds mean the gate is disabled.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evaluateQualityGate(percent: number, thresholds: QualityGateThresholds): QualityGateOutcome;
|
|
15
|
+
//# sourceMappingURL=quality-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-gate.d.ts","sourceRoot":"","sources":["../../src/core/quality-gate.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,qBAAqB;IACpC;wCACoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;wDACoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,GAChC,kBAAkB,CAgBpB"}
|