1 | import { CoverageMap, CoverageSummary, FileCoverage } from "istanbul-lib-coverage";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export function createContext(options?: Partial<ContextOptions>): Context;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export function getDefaultWatermarks(): Watermarks;
|
12 | export class ReportBase {
|
13 | constructor(options?: Partial<ReportBaseOptions>);
|
14 | execute(context: Context): void;
|
15 | }
|
16 |
|
17 | export interface ReportBaseOptions {
|
18 | summarizer: Summarizers;
|
19 | }
|
20 |
|
21 | export type Summarizers = "flat" | "nested" | "pkg" | "defaultSummarizer";
|
22 |
|
23 | export interface ContextOptions {
|
24 | coverageMap: CoverageMap;
|
25 | defaultSummarizer: Summarizers;
|
26 | dir: string;
|
27 | watermarks: Partial<Watermarks>;
|
28 | sourceFinder(filepath: string): string;
|
29 | }
|
30 |
|
31 | export interface Context {
|
32 | data: any;
|
33 | dir: string;
|
34 | sourceFinder(filepath: string): string;
|
35 | watermarks: Watermarks;
|
36 | writer: FileWriter;
|
37 | |
38 |
|
39 |
|
40 |
|
41 | classForPercent(type: keyof Watermarks, value: number): string;
|
42 | |
43 |
|
44 |
|
45 |
|
46 | getSource(filepath: string): string;
|
47 | getTree(summarizer?: Summarizers): Tree;
|
48 | |
49 |
|
50 |
|
51 | getVisitor<N extends Node = Node>(visitor: Partial<Visitor<N>>): Visitor<N>;
|
52 | |
53 |
|
54 |
|
55 |
|
56 | getWriter(): FileWriter;
|
57 | |
58 |
|
59 |
|
60 | getXmlWriter(contentWriter: ContentWriter): XmlWriter;
|
61 | }
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | export class ContentWriter {
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | colorize(str: string, clazz?: string): string;
|
74 | |
75 |
|
76 |
|
77 | println(str: string): void;
|
78 | |
79 |
|
80 |
|
81 | close(): void;
|
82 | }
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | export class FileContentWriter extends ContentWriter {
|
88 | constructor(fileDescriptor: number);
|
89 | write(str: string): void;
|
90 | }
|
91 |
|
92 | /**
|
93 | * a content writer that writes to the console
|
94 | */
|
95 | export class ConsoleWriter extends ContentWriter {
|
96 | write(str: string): void;
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export class FileWriter {
|
103 | constructor(baseDir: string);
|
104 | static startCapture(): void;
|
105 | static stopCapture(): void;
|
106 | static getOutput(): string;
|
107 | static resetOutput(): void;
|
108 | /**
|
109 | * returns a FileWriter that is rooted at the supplied subdirectory
|
110 | */
|
111 | writeForDir(subdir: string): FileWriter;
|
112 | /**
|
113 | * copies a file from a source directory to a destination name
|
114 | */
|
115 | copyFile(source: string, dest: string, header?: string): void;
|
116 | /**
|
117 | * returns a content writer for writing content to the supplied file.
|
118 | */
|
119 | writeFile(file: string | null): ContentWriter;
|
120 | }
|
121 |
|
122 | export interface XmlWriter {
|
123 | indent(str: string): string;
|
124 | |
125 |
|
126 |
|
127 | openTag(name: string, attrs?: any): void;
|
128 | |
129 |
|
130 |
|
131 | closeTag(name: string): void;
|
132 | |
133 |
|
134 |
|
135 | inlineTag(name: string, attrs?: any, content?: string): void;
|
136 | |
137 |
|
138 |
|
139 | closeAll(): void;
|
140 | }
|
141 |
|
142 | export type Watermark = [number, number];
|
143 |
|
144 | export interface Watermarks {
|
145 | statements: Watermark;
|
146 | functions: Watermark;
|
147 | branches: Watermark;
|
148 | lines: Watermark;
|
149 | }
|
150 |
|
151 | export interface Node {
|
152 | isRoot(): boolean;
|
153 | visit(visitor: Visitor, state: any): void;
|
154 | }
|
155 |
|
156 | export interface ReportNode extends Node {
|
157 | path: string;
|
158 | parent: ReportNode | null;
|
159 | fileCoverage: FileCoverage;
|
160 | children: ReportNode[];
|
161 | addChild(child: ReportNode): void;
|
162 | asRelative(p: string): string;
|
163 | getQualifiedName(): string;
|
164 | getRelativeName(): string;
|
165 | getParent(): Node;
|
166 | getChildren(): Node[];
|
167 | isSummary(): boolean;
|
168 | getFileCoverage(): FileCoverage;
|
169 | getCoverageSummary(filesOnly: boolean): CoverageSummary;
|
170 | visit(visitor: Visitor<ReportNode>, state: any): void;
|
171 | }
|
172 |
|
173 | export interface Visitor<N extends Node = Node> {
|
174 | onStart(root: N, state: any): void;
|
175 | onSummary(root: N, state: any): void;
|
176 | onDetail(root: N, state: any): void;
|
177 | onSummaryEnd(root: N, state: any): void;
|
178 | onEnd(root: N, state: any): void;
|
179 | }
|
180 |
|
181 | export interface Tree<N extends Node = Node> {
|
182 | getRoot(): N;
|
183 | visit(visitor: Partial<Visitor<N>>, state: any): void;
|
184 | }
|