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