modestbench 0.6.0 → 0.7.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.
- package/CHANGELOG.md +7 -0
- package/README.md +6 -2
- package/dist/cli/commands/run.cjs +17 -11
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.js +9 -3
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/test.cjs +14 -15
- package/dist/cli/commands/test.cjs.map +1 -1
- package/dist/cli/commands/test.d.cts.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +2 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.cjs +3 -0
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/reporters/index.cjs +3 -1
- package/dist/reporters/index.cjs.map +1 -1
- package/dist/reporters/index.d.cts +1 -0
- package/dist/reporters/index.d.cts.map +1 -1
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js +1 -0
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/nyan.cjs +318 -0
- package/dist/reporters/nyan.cjs.map +1 -0
- package/dist/reporters/nyan.d.cts +118 -0
- package/dist/reporters/nyan.d.cts.map +1 -0
- package/dist/reporters/nyan.d.ts +118 -0
- package/dist/reporters/nyan.d.ts.map +1 -0
- package/dist/reporters/nyan.js +314 -0
- package/dist/reporters/nyan.js.map +1 -0
- package/dist/types/core.cjs.map +1 -1
- package/dist/types/core.d.cts +13 -12
- package/dist/types/core.d.cts.map +1 -1
- package/dist/types/core.d.ts +13 -12
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +0 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/commands/run.ts +10 -3
- package/src/cli/commands/test.ts +2 -3
- package/src/cli/index.ts +8 -0
- package/src/constants.ts +2 -1
- package/src/index.ts +3 -0
- package/src/reporters/index.ts +1 -0
- package/src/reporters/nyan.ts +409 -0
- package/src/types/core.ts +16 -14
- package/src/types/index.ts +0 -3
- package/dist/types/cli.cjs +0 -12
- package/dist/types/cli.cjs.map +0 -1
- package/dist/types/cli.d.cts +0 -75
- package/dist/types/cli.d.cts.map +0 -1
- package/dist/types/cli.d.ts +0 -75
- package/dist/types/cli.d.ts.map +0 -1
- package/dist/types/cli.js +0 -9
- package/dist/types/cli.js.map +0 -1
- package/src/types/cli.ts +0 -82
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ModestBench Nyan Cat Reporter
|
|
4
|
+
*
|
|
5
|
+
* Because benchmarking should be more colorful. Displays an animated nyan cat
|
|
6
|
+
* flying through a rainbow trail as benchmarks complete.
|
|
7
|
+
*
|
|
8
|
+
* Based on Mocha's legendary nyan reporter, adapted for the glory of
|
|
9
|
+
* performance measurement.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.NyanReporter = void 0;
|
|
15
|
+
const reporter_registry_js_1 = require("../services/reporter-registry.cjs");
|
|
16
|
+
const ansi_js_1 = require("../utils/ansi.cjs");
|
|
17
|
+
/**
|
|
18
|
+
* Nyan Cat reporter - because your benchmarks deserve rainbow power
|
|
19
|
+
*/
|
|
20
|
+
class NyanReporter extends reporter_registry_js_1.BaseReporter {
|
|
21
|
+
/** Index into rainbow colors for cycling */
|
|
22
|
+
colorIndex = 0;
|
|
23
|
+
/** Current file being processed */
|
|
24
|
+
currentFile = '';
|
|
25
|
+
/** Current suite being processed */
|
|
26
|
+
currentSuite = '';
|
|
27
|
+
/** Total failed tasks */
|
|
28
|
+
failed = 0;
|
|
29
|
+
/** Collected failures for summary */
|
|
30
|
+
failures = [];
|
|
31
|
+
/** Number of lines the cat occupies */
|
|
32
|
+
numberOfLines = 4;
|
|
33
|
+
/** Total passed tasks */
|
|
34
|
+
passed = 0;
|
|
35
|
+
/** Whether the display is active */
|
|
36
|
+
progressActive = false;
|
|
37
|
+
/** Quiet mode - suppress output */
|
|
38
|
+
quiet;
|
|
39
|
+
/** Generated rainbow color palette */
|
|
40
|
+
rainbowColors = [];
|
|
41
|
+
/** Width of scoreboard */
|
|
42
|
+
scoreboardWidth = 5;
|
|
43
|
+
/** Start time for duration calculation */
|
|
44
|
+
startTime = 0;
|
|
45
|
+
/** Animation tick (alternates between frames) */
|
|
46
|
+
tick = false;
|
|
47
|
+
/** Rainbow trail storage - one trajectory per cat line */
|
|
48
|
+
trajectories = [[], [], [], []];
|
|
49
|
+
/** Maximum width of the rainbow trail */
|
|
50
|
+
trajectoryWidthMax = 0;
|
|
51
|
+
/** Whether to use colors */
|
|
52
|
+
useColor;
|
|
53
|
+
constructor(options = {}) {
|
|
54
|
+
super('nyan', options);
|
|
55
|
+
this.quiet = options.quiet ?? false;
|
|
56
|
+
// Auto-detect color support if not explicitly set
|
|
57
|
+
this.useColor =
|
|
58
|
+
options.color ??
|
|
59
|
+
(process.stdout.isTTY &&
|
|
60
|
+
process.env.FORCE_COLOR !== '0' &&
|
|
61
|
+
process.env.NO_COLOR == null);
|
|
62
|
+
// Generate the rainbow colors on construction
|
|
63
|
+
this.rainbowColors = this.generateColors();
|
|
64
|
+
// Calculate trajectory width based on terminal width
|
|
65
|
+
// Leave room for scoreboard (5) + cat (11) + some padding
|
|
66
|
+
const termWidth = process.stdout.columns || 80;
|
|
67
|
+
const nyanCatWidth = 11;
|
|
68
|
+
this.trajectoryWidthMax = Math.floor(termWidth * 0.75) - nyanCatWidth;
|
|
69
|
+
}
|
|
70
|
+
onEnd(run) {
|
|
71
|
+
if (this.quiet) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Show cursor and move past the cat
|
|
75
|
+
this.showCursor();
|
|
76
|
+
for (let i = 0; i < this.numberOfLines; i++) {
|
|
77
|
+
process.stdout.write('\n');
|
|
78
|
+
}
|
|
79
|
+
// Print summary
|
|
80
|
+
this.printEpilogue(run);
|
|
81
|
+
}
|
|
82
|
+
onError(error) {
|
|
83
|
+
if (this.quiet) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Make sure cursor is visible
|
|
87
|
+
this.showCursor();
|
|
88
|
+
console.error(`\n${ansi_js_1.colors.red}Error: ${error.message}${ansi_js_1.colors.reset}`);
|
|
89
|
+
}
|
|
90
|
+
onFileEnd(_result) {
|
|
91
|
+
// Just keep flying
|
|
92
|
+
}
|
|
93
|
+
onFileStart(file) {
|
|
94
|
+
this.currentFile = file;
|
|
95
|
+
}
|
|
96
|
+
onStart(_run) {
|
|
97
|
+
this.startTime = Date.now();
|
|
98
|
+
this.passed = 0;
|
|
99
|
+
this.failed = 0;
|
|
100
|
+
this.failures = [];
|
|
101
|
+
this.colorIndex = 0;
|
|
102
|
+
this.tick = false;
|
|
103
|
+
this.trajectories = [[], [], [], []];
|
|
104
|
+
if (this.quiet) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Hide cursor for cleaner animation
|
|
108
|
+
this.hideCursor();
|
|
109
|
+
// Initial draw
|
|
110
|
+
this.draw();
|
|
111
|
+
this.progressActive = true;
|
|
112
|
+
}
|
|
113
|
+
onSuiteEnd(_result) {
|
|
114
|
+
// Keep flying
|
|
115
|
+
}
|
|
116
|
+
onSuiteStart(suite) {
|
|
117
|
+
this.currentSuite = suite;
|
|
118
|
+
}
|
|
119
|
+
onTaskResult(result) {
|
|
120
|
+
if (result.error) {
|
|
121
|
+
this.failed++;
|
|
122
|
+
this.failures.push({
|
|
123
|
+
error: result.error.message || String(result.error),
|
|
124
|
+
file: this.currentFile,
|
|
125
|
+
suite: this.currentSuite,
|
|
126
|
+
task: result.name,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else if (!result.aborted) {
|
|
130
|
+
this.passed++;
|
|
131
|
+
}
|
|
132
|
+
if (this.quiet) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.draw();
|
|
136
|
+
}
|
|
137
|
+
onTaskStart(_task) {
|
|
138
|
+
// The cat flies on results, not starts
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Append a segment to the rainbow trail
|
|
142
|
+
*/
|
|
143
|
+
appendRainbow() {
|
|
144
|
+
const segment = this.tick ? '_' : '-';
|
|
145
|
+
const rainbowified = this.rainbowify(segment);
|
|
146
|
+
for (let index = 0; index < this.numberOfLines; index++) {
|
|
147
|
+
const trajectory = this.trajectories[index];
|
|
148
|
+
if (trajectory.length >= this.trajectoryWidthMax) {
|
|
149
|
+
trajectory.shift();
|
|
150
|
+
}
|
|
151
|
+
trajectory.push(rainbowified);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Move cursor down n lines
|
|
156
|
+
*/
|
|
157
|
+
cursorDown(n) {
|
|
158
|
+
process.stdout.write(`\x1b[${n}B`);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Move cursor up n lines
|
|
162
|
+
*/
|
|
163
|
+
cursorUp(n) {
|
|
164
|
+
process.stdout.write(`\x1b[${n}A`);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Draw the complete nyan cat scene
|
|
168
|
+
*/
|
|
169
|
+
draw() {
|
|
170
|
+
this.appendRainbow();
|
|
171
|
+
this.drawScoreboard();
|
|
172
|
+
this.drawRainbow();
|
|
173
|
+
this.drawNyanCat();
|
|
174
|
+
this.tick = !this.tick;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Draw the nyan cat ASCII art
|
|
178
|
+
*/
|
|
179
|
+
drawNyanCat() {
|
|
180
|
+
const startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
181
|
+
const dist = `\x1b[${startWidth}C`;
|
|
182
|
+
process.stdout.write(dist);
|
|
183
|
+
process.stdout.write('_,------,');
|
|
184
|
+
process.stdout.write('\n');
|
|
185
|
+
process.stdout.write(dist);
|
|
186
|
+
const padding1 = this.tick ? ' ' : ' ';
|
|
187
|
+
process.stdout.write(`_|${padding1}/\\_/\\ `);
|
|
188
|
+
process.stdout.write('\n');
|
|
189
|
+
process.stdout.write(dist);
|
|
190
|
+
const padding2 = this.tick ? '_' : '__';
|
|
191
|
+
const tail = this.tick ? '~' : '^';
|
|
192
|
+
process.stdout.write(`${tail}|${padding2}${this.face()} `);
|
|
193
|
+
process.stdout.write('\n');
|
|
194
|
+
process.stdout.write(dist);
|
|
195
|
+
const padding3 = this.tick ? ' ' : ' ';
|
|
196
|
+
process.stdout.write(`${padding3}"" "" `);
|
|
197
|
+
process.stdout.write('\n');
|
|
198
|
+
this.cursorUp(this.numberOfLines);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Draw the rainbow trail
|
|
202
|
+
*/
|
|
203
|
+
drawRainbow() {
|
|
204
|
+
for (const line of this.trajectories) {
|
|
205
|
+
process.stdout.write(`\x1b[${this.scoreboardWidth}C`);
|
|
206
|
+
process.stdout.write(line.join(''));
|
|
207
|
+
process.stdout.write('\n');
|
|
208
|
+
}
|
|
209
|
+
this.cursorUp(this.numberOfLines);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Draw the scoreboard showing pass/fail counts
|
|
213
|
+
*/
|
|
214
|
+
drawScoreboard() {
|
|
215
|
+
const draw = (type, n) => {
|
|
216
|
+
process.stdout.write(' ');
|
|
217
|
+
if (this.useColor) {
|
|
218
|
+
process.stdout.write(`${ansi_js_1.colors[type]}${n}${ansi_js_1.colors.reset}`);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
process.stdout.write(String(n));
|
|
222
|
+
}
|
|
223
|
+
process.stdout.write('\n');
|
|
224
|
+
};
|
|
225
|
+
draw('green', this.passed);
|
|
226
|
+
draw('red', this.failed);
|
|
227
|
+
process.stdout.write('\n');
|
|
228
|
+
process.stdout.write('\n');
|
|
229
|
+
this.cursorUp(this.numberOfLines);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the nyan cat's face based on current state
|
|
233
|
+
*/
|
|
234
|
+
face() {
|
|
235
|
+
if (this.failed > 0) {
|
|
236
|
+
return '( x .x)';
|
|
237
|
+
}
|
|
238
|
+
else if (this.passed > 0) {
|
|
239
|
+
return '( ^ .^)';
|
|
240
|
+
}
|
|
241
|
+
return '( - .-)';
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Generate rainbow colors using sine wave color cycling
|
|
245
|
+
*
|
|
246
|
+
* Uses 256-color palette (colors 16-231 are a 6x6x6 color cube)
|
|
247
|
+
*/
|
|
248
|
+
generateColors() {
|
|
249
|
+
const colorList = [];
|
|
250
|
+
// Generate 42 colors (6 * 7) cycling through the spectrum
|
|
251
|
+
for (let i = 0; i < 6 * 7; i++) {
|
|
252
|
+
const pi3 = Math.floor(Math.PI / 3);
|
|
253
|
+
const n = i * (1.0 / 6);
|
|
254
|
+
const r = Math.floor(3 * Math.sin(n) + 3);
|
|
255
|
+
const g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
|
|
256
|
+
const b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
|
|
257
|
+
// Calculate 256-color code from RGB values (16 + 36*r + 6*g + b)
|
|
258
|
+
colorList.push(36 * r + 6 * g + b + 16);
|
|
259
|
+
}
|
|
260
|
+
return colorList;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Hide the cursor
|
|
264
|
+
*/
|
|
265
|
+
hideCursor() {
|
|
266
|
+
if (process.stdout.isTTY) {
|
|
267
|
+
process.stdout.write('\x1b[?25l');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Print the epilogue summary after the run
|
|
272
|
+
*/
|
|
273
|
+
printEpilogue(run) {
|
|
274
|
+
const duration = Date.now() - this.startTime;
|
|
275
|
+
const durationStr = reporter_registry_js_1.BaseReporter.formatDuration(duration * 1000000);
|
|
276
|
+
console.log();
|
|
277
|
+
console.log(` ${this.useColor ? ansi_js_1.colors.green : ''}${this.passed} passing${this.useColor ? ansi_js_1.colors.reset : ''} ${this.useColor ? ansi_js_1.colors.gray : ''}(${durationStr})${this.useColor ? ansi_js_1.colors.reset : ''}`);
|
|
278
|
+
if (this.failed > 0) {
|
|
279
|
+
console.log(` ${this.useColor ? ansi_js_1.colors.red : ''}${this.failed} failing${this.useColor ? ansi_js_1.colors.reset : ''}`);
|
|
280
|
+
console.log();
|
|
281
|
+
// Print failure details
|
|
282
|
+
for (let i = 0; i < this.failures.length; i++) {
|
|
283
|
+
const failure = this.failures[i];
|
|
284
|
+
console.log(` ${i + 1}) ${failure.suite === 'default' ? '' : failure.suite + ' > '}${failure.task}`);
|
|
285
|
+
console.log(` ${this.useColor ? ansi_js_1.colors.red : ''}${failure.error}${this.useColor ? ansi_js_1.colors.reset : ''}`);
|
|
286
|
+
console.log();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Show total files/suites for context
|
|
290
|
+
let totalSuites = 0;
|
|
291
|
+
for (const file of run.files) {
|
|
292
|
+
totalSuites += file.suites.length;
|
|
293
|
+
}
|
|
294
|
+
console.log();
|
|
295
|
+
console.log(` ${this.useColor ? ansi_js_1.colors.gray : ''}Files: ${run.files.length} | Suites: ${totalSuites} | Tasks: ${this.passed + this.failed}${this.useColor ? ansi_js_1.colors.reset : ''}`);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Apply rainbow coloring to a string
|
|
299
|
+
*/
|
|
300
|
+
rainbowify(str) {
|
|
301
|
+
if (!this.useColor) {
|
|
302
|
+
return str;
|
|
303
|
+
}
|
|
304
|
+
const color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
|
|
305
|
+
this.colorIndex += 1;
|
|
306
|
+
return `\x1b[38;5;${color}m${str}\x1b[0m`;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Show the cursor
|
|
310
|
+
*/
|
|
311
|
+
showCursor() {
|
|
312
|
+
if (process.stdout.isTTY) {
|
|
313
|
+
process.stdout.write('\x1b[?25h');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
exports.NyanReporter = NyanReporter;
|
|
318
|
+
//# sourceMappingURL=nyan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nyan.js","sourceRoot":"","sources":["../../src/reporters/nyan.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AASH,4EAAgE;AAChE,+CAA0C;AAE1C;;GAEG;AACH,MAAa,YAAa,SAAQ,mCAAY;IAC5C,4CAA4C;IACpC,UAAU,GAAG,CAAC,CAAC;IAEvB,mCAAmC;IAC3B,WAAW,GAAG,EAAE,CAAC;IAEzB,oCAAoC;IAC5B,YAAY,GAAG,EAAE,CAAC;IAE1B,yBAAyB;IACjB,MAAM,GAAG,CAAC,CAAC;IAEnB,qCAAqC;IAC7B,QAAQ,GAKX,EAAE,CAAC;IAER,uCAAuC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AAC,WAAW,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF;AA/XD,oCA+XC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Nyan Cat Reporter
|
|
3
|
+
*
|
|
4
|
+
* Because benchmarking should be more colorful. Displays an animated nyan cat
|
|
5
|
+
* flying through a rainbow trail as benchmarks complete.
|
|
6
|
+
*
|
|
7
|
+
* Based on Mocha's legendary nyan reporter, adapted for the glory of
|
|
8
|
+
* performance measurement.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { BenchmarkRun, FileResult, SuiteResult, TaskResult } from "../types/index.cjs";
|
|
13
|
+
import { BaseReporter } from "../services/reporter-registry.cjs";
|
|
14
|
+
/**
|
|
15
|
+
* Nyan Cat reporter - because your benchmarks deserve rainbow power
|
|
16
|
+
*/
|
|
17
|
+
export declare class NyanReporter extends BaseReporter {
|
|
18
|
+
/** Index into rainbow colors for cycling */
|
|
19
|
+
private colorIndex;
|
|
20
|
+
/** Current file being processed */
|
|
21
|
+
private currentFile;
|
|
22
|
+
/** Current suite being processed */
|
|
23
|
+
private currentSuite;
|
|
24
|
+
/** Total failed tasks */
|
|
25
|
+
private failed;
|
|
26
|
+
/** Collected failures for summary */
|
|
27
|
+
private failures;
|
|
28
|
+
/** Number of lines the cat occupies */
|
|
29
|
+
private readonly numberOfLines;
|
|
30
|
+
/** Total passed tasks */
|
|
31
|
+
private passed;
|
|
32
|
+
/** Whether the display is active */
|
|
33
|
+
private progressActive;
|
|
34
|
+
/** Quiet mode - suppress output */
|
|
35
|
+
private readonly quiet;
|
|
36
|
+
/** Generated rainbow color palette */
|
|
37
|
+
private rainbowColors;
|
|
38
|
+
/** Width of scoreboard */
|
|
39
|
+
private readonly scoreboardWidth;
|
|
40
|
+
/** Start time for duration calculation */
|
|
41
|
+
private startTime;
|
|
42
|
+
/** Animation tick (alternates between frames) */
|
|
43
|
+
private tick;
|
|
44
|
+
/** Rainbow trail storage - one trajectory per cat line */
|
|
45
|
+
private trajectories;
|
|
46
|
+
/** Maximum width of the rainbow trail */
|
|
47
|
+
private trajectoryWidthMax;
|
|
48
|
+
/** Whether to use colors */
|
|
49
|
+
private readonly useColor;
|
|
50
|
+
constructor(options?: {
|
|
51
|
+
color?: boolean;
|
|
52
|
+
quiet?: boolean;
|
|
53
|
+
});
|
|
54
|
+
onEnd(run: BenchmarkRun): void;
|
|
55
|
+
onError(error: Error): void;
|
|
56
|
+
onFileEnd(_result: FileResult): void;
|
|
57
|
+
onFileStart(file: string): void;
|
|
58
|
+
onStart(_run: BenchmarkRun): void;
|
|
59
|
+
onSuiteEnd(_result: SuiteResult): void;
|
|
60
|
+
onSuiteStart(suite: string): void;
|
|
61
|
+
onTaskResult(result: TaskResult): void;
|
|
62
|
+
onTaskStart(_task: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Append a segment to the rainbow trail
|
|
65
|
+
*/
|
|
66
|
+
private appendRainbow;
|
|
67
|
+
/**
|
|
68
|
+
* Move cursor down n lines
|
|
69
|
+
*/
|
|
70
|
+
private cursorDown;
|
|
71
|
+
/**
|
|
72
|
+
* Move cursor up n lines
|
|
73
|
+
*/
|
|
74
|
+
private cursorUp;
|
|
75
|
+
/**
|
|
76
|
+
* Draw the complete nyan cat scene
|
|
77
|
+
*/
|
|
78
|
+
private draw;
|
|
79
|
+
/**
|
|
80
|
+
* Draw the nyan cat ASCII art
|
|
81
|
+
*/
|
|
82
|
+
private drawNyanCat;
|
|
83
|
+
/**
|
|
84
|
+
* Draw the rainbow trail
|
|
85
|
+
*/
|
|
86
|
+
private drawRainbow;
|
|
87
|
+
/**
|
|
88
|
+
* Draw the scoreboard showing pass/fail counts
|
|
89
|
+
*/
|
|
90
|
+
private drawScoreboard;
|
|
91
|
+
/**
|
|
92
|
+
* Get the nyan cat's face based on current state
|
|
93
|
+
*/
|
|
94
|
+
private face;
|
|
95
|
+
/**
|
|
96
|
+
* Generate rainbow colors using sine wave color cycling
|
|
97
|
+
*
|
|
98
|
+
* Uses 256-color palette (colors 16-231 are a 6x6x6 color cube)
|
|
99
|
+
*/
|
|
100
|
+
private generateColors;
|
|
101
|
+
/**
|
|
102
|
+
* Hide the cursor
|
|
103
|
+
*/
|
|
104
|
+
private hideCursor;
|
|
105
|
+
/**
|
|
106
|
+
* Print the epilogue summary after the run
|
|
107
|
+
*/
|
|
108
|
+
private printEpilogue;
|
|
109
|
+
/**
|
|
110
|
+
* Apply rainbow coloring to a string
|
|
111
|
+
*/
|
|
112
|
+
private rainbowify;
|
|
113
|
+
/**
|
|
114
|
+
* Show the cursor
|
|
115
|
+
*/
|
|
116
|
+
private showCursor;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=nyan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nyan.d.ts","sourceRoot":"","sources":["../../src/reporters/nyan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACX,2BAA0B;AAE3B,OAAO,EAAE,YAAY,EAAE,0CAAyC;AAGhE;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;IAC5C,4CAA4C;IAC5C,OAAO,CAAC,UAAU,CAAK;IAEvB,mCAAmC;IACnC,OAAO,CAAC,WAAW,CAAM;IAEzB,oCAAoC;IACpC,OAAO,CAAC,YAAY,CAAM;IAE1B,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAK;IAEnB,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAKR;IAER,uCAAuC;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAK;IAEnC,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAK;IAEnB,oCAAoC;IACpC,OAAO,CAAC,cAAc,CAAS;IAE/B,mCAAmC;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAEhC,sCAAsC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AEG;IACH,OAAO,CAAC,UAAU;IAMlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAwCrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAYlB;;OAEG;IACH,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Nyan Cat Reporter
|
|
3
|
+
*
|
|
4
|
+
* Because benchmarking should be more colorful. Displays an animated nyan cat
|
|
5
|
+
* flying through a rainbow trail as benchmarks complete.
|
|
6
|
+
*
|
|
7
|
+
* Based on Mocha's legendary nyan reporter, adapted for the glory of
|
|
8
|
+
* performance measurement.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { BenchmarkRun, FileResult, SuiteResult, TaskResult } from "../types/index.js";
|
|
13
|
+
import { BaseReporter } from "../services/reporter-registry.js";
|
|
14
|
+
/**
|
|
15
|
+
* Nyan Cat reporter - because your benchmarks deserve rainbow power
|
|
16
|
+
*/
|
|
17
|
+
export declare class NyanReporter extends BaseReporter {
|
|
18
|
+
/** Index into rainbow colors for cycling */
|
|
19
|
+
private colorIndex;
|
|
20
|
+
/** Current file being processed */
|
|
21
|
+
private currentFile;
|
|
22
|
+
/** Current suite being processed */
|
|
23
|
+
private currentSuite;
|
|
24
|
+
/** Total failed tasks */
|
|
25
|
+
private failed;
|
|
26
|
+
/** Collected failures for summary */
|
|
27
|
+
private failures;
|
|
28
|
+
/** Number of lines the cat occupies */
|
|
29
|
+
private readonly numberOfLines;
|
|
30
|
+
/** Total passed tasks */
|
|
31
|
+
private passed;
|
|
32
|
+
/** Whether the display is active */
|
|
33
|
+
private progressActive;
|
|
34
|
+
/** Quiet mode - suppress output */
|
|
35
|
+
private readonly quiet;
|
|
36
|
+
/** Generated rainbow color palette */
|
|
37
|
+
private rainbowColors;
|
|
38
|
+
/** Width of scoreboard */
|
|
39
|
+
private readonly scoreboardWidth;
|
|
40
|
+
/** Start time for duration calculation */
|
|
41
|
+
private startTime;
|
|
42
|
+
/** Animation tick (alternates between frames) */
|
|
43
|
+
private tick;
|
|
44
|
+
/** Rainbow trail storage - one trajectory per cat line */
|
|
45
|
+
private trajectories;
|
|
46
|
+
/** Maximum width of the rainbow trail */
|
|
47
|
+
private trajectoryWidthMax;
|
|
48
|
+
/** Whether to use colors */
|
|
49
|
+
private readonly useColor;
|
|
50
|
+
constructor(options?: {
|
|
51
|
+
color?: boolean;
|
|
52
|
+
quiet?: boolean;
|
|
53
|
+
});
|
|
54
|
+
onEnd(run: BenchmarkRun): void;
|
|
55
|
+
onError(error: Error): void;
|
|
56
|
+
onFileEnd(_result: FileResult): void;
|
|
57
|
+
onFileStart(file: string): void;
|
|
58
|
+
onStart(_run: BenchmarkRun): void;
|
|
59
|
+
onSuiteEnd(_result: SuiteResult): void;
|
|
60
|
+
onSuiteStart(suite: string): void;
|
|
61
|
+
onTaskResult(result: TaskResult): void;
|
|
62
|
+
onTaskStart(_task: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Append a segment to the rainbow trail
|
|
65
|
+
*/
|
|
66
|
+
private appendRainbow;
|
|
67
|
+
/**
|
|
68
|
+
* Move cursor down n lines
|
|
69
|
+
*/
|
|
70
|
+
private cursorDown;
|
|
71
|
+
/**
|
|
72
|
+
* Move cursor up n lines
|
|
73
|
+
*/
|
|
74
|
+
private cursorUp;
|
|
75
|
+
/**
|
|
76
|
+
* Draw the complete nyan cat scene
|
|
77
|
+
*/
|
|
78
|
+
private draw;
|
|
79
|
+
/**
|
|
80
|
+
* Draw the nyan cat ASCII art
|
|
81
|
+
*/
|
|
82
|
+
private drawNyanCat;
|
|
83
|
+
/**
|
|
84
|
+
* Draw the rainbow trail
|
|
85
|
+
*/
|
|
86
|
+
private drawRainbow;
|
|
87
|
+
/**
|
|
88
|
+
* Draw the scoreboard showing pass/fail counts
|
|
89
|
+
*/
|
|
90
|
+
private drawScoreboard;
|
|
91
|
+
/**
|
|
92
|
+
* Get the nyan cat's face based on current state
|
|
93
|
+
*/
|
|
94
|
+
private face;
|
|
95
|
+
/**
|
|
96
|
+
* Generate rainbow colors using sine wave color cycling
|
|
97
|
+
*
|
|
98
|
+
* Uses 256-color palette (colors 16-231 are a 6x6x6 color cube)
|
|
99
|
+
*/
|
|
100
|
+
private generateColors;
|
|
101
|
+
/**
|
|
102
|
+
* Hide the cursor
|
|
103
|
+
*/
|
|
104
|
+
private hideCursor;
|
|
105
|
+
/**
|
|
106
|
+
* Print the epilogue summary after the run
|
|
107
|
+
*/
|
|
108
|
+
private printEpilogue;
|
|
109
|
+
/**
|
|
110
|
+
* Apply rainbow coloring to a string
|
|
111
|
+
*/
|
|
112
|
+
private rainbowify;
|
|
113
|
+
/**
|
|
114
|
+
* Show the cursor
|
|
115
|
+
*/
|
|
116
|
+
private showCursor;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=nyan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nyan.d.ts","sourceRoot":"","sources":["../../src/reporters/nyan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACX,0BAA0B;AAE3B,OAAO,EAAE,YAAY,EAAE,yCAAyC;AAGhE;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;IAC5C,4CAA4C;IAC5C,OAAO,CAAC,UAAU,CAAK;IAEvB,mCAAmC;IACnC,OAAO,CAAC,WAAW,CAAM;IAEzB,oCAAoC;IACpC,OAAO,CAAC,YAAY,CAAM;IAE1B,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAK;IAEnB,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAKR;IAER,uCAAuC;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAK;IAEnC,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAK;IAEnB,oCAAoC;IACpC,OAAO,CAAC,cAAc,CA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