ortoni-report 4.0.1-beta.0 → 4.0.1-beta.3

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 (37) hide show
  1. package/dist/chunk-4RZ5C7KY.mjs +744 -0
  2. package/dist/{chunk-MPZLDOCN.mjs → chunk-HOOC3MDY.mjs} +305 -304
  3. package/dist/chunk-ISCRDMPY.mjs +693 -0
  4. package/dist/{chunk-INS3E7E6.mjs → chunk-P72FKFLZ.mjs} +352 -298
  5. package/dist/chunk-S45BZGXX.mjs +744 -0
  6. package/dist/{chunk-OZS6QIJS.mjs → chunk-ZG4JPYLC.mjs} +352 -298
  7. package/dist/{chunk-TI33PMMQ.mjs → chunk-ZSPTPISU.mjs} +352 -299
  8. package/dist/{cli/cli.js → cli.js} +403 -189
  9. package/dist/cli.mjs +206 -0
  10. package/dist/index.html +2 -2
  11. package/dist/ortoni-report.d.mts +7 -0
  12. package/dist/ortoni-report.d.ts +7 -0
  13. package/dist/ortoni-report.js +189 -72
  14. package/dist/ortoni-report.mjs +9 -5
  15. package/package.json +11 -4
  16. package/dist/chunk-45EJSEX2.mjs +0 -632
  17. package/dist/chunk-75EAJL2U.mjs +0 -632
  18. package/dist/chunk-A6HCKATU.mjs +0 -76
  19. package/dist/chunk-FGIYOFIC.mjs +0 -632
  20. package/dist/chunk-FHKWBHU6.mjs +0 -633
  21. package/dist/chunk-GLICR3VS.mjs +0 -637
  22. package/dist/chunk-HFO6XSKC.mjs +0 -633
  23. package/dist/chunk-HOZD6YIV.mjs +0 -634
  24. package/dist/chunk-IJO2YIFE.mjs +0 -637
  25. package/dist/chunk-JEIWNUQY.mjs +0 -632
  26. package/dist/chunk-JPLAGYR7.mjs +0 -632
  27. package/dist/chunk-NM6ULN2O.mjs +0 -632
  28. package/dist/chunk-P57227VN.mjs +0 -633
  29. package/dist/chunk-QMTRYN5N.js +0 -635
  30. package/dist/chunk-Z5NBP5TS.mjs +0 -635
  31. package/dist/cli/cli.cjs +0 -678
  32. package/dist/cli/cli.d.cts +0 -1
  33. package/dist/cli/cli.mjs +0 -103
  34. package/dist/ortoni-report.cjs +0 -2134
  35. package/dist/ortoni-report.d.cts +0 -111
  36. /package/dist/{cli/cli.d.mts → cli.d.mts} +0 -0
  37. /package/dist/{cli/cli.d.ts → cli.d.ts} +0 -0
@@ -8,241 +8,14 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
  });
9
9
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
10
 
11
- // src/helpers/fileManager.ts
12
- import fs from "fs";
13
- import path from "path";
14
- var FileManager = class {
15
- constructor(folderPath) {
16
- this.folderPath = folderPath;
17
- }
18
- ensureReportDirectory() {
19
- const ortoniDataFolder = path.join(this.folderPath, "ortoni-data");
20
- if (!fs.existsSync(this.folderPath)) {
21
- fs.mkdirSync(this.folderPath, { recursive: true });
22
- } else {
23
- if (fs.existsSync(ortoniDataFolder)) {
24
- fs.rmSync(ortoniDataFolder, { recursive: true, force: true });
25
- }
26
- }
27
- }
28
- writeReportFile(filename, data) {
29
- const templatePath = path.join(__dirname, "..", "index.html");
30
- console.log(templatePath);
31
- let html = fs.readFileSync(templatePath, "utf-8");
32
- const reportJSON = JSON.stringify({
33
- data
34
- });
35
- html = html.replace("__ORTONI_TEST_REPORTDATA__", reportJSON);
36
- const outputDir = path.join(process.cwd(), this.folderPath);
37
- if (!fs.existsSync(outputDir)) {
38
- fs.mkdirSync(outputDir, { recursive: true });
39
- }
40
- const outputPath = path.join(outputDir, filename);
41
- console.log(`Writing report to ${outputPath}`);
42
- fs.writeFileSync(outputPath, html);
43
- return outputPath;
44
- }
45
- writeRawFile(filename, data) {
46
- const outputPath = path.join(process.cwd(), this.folderPath, filename);
47
- fs.mkdirSync(path.dirname(outputPath), { recursive: true });
48
- const content = typeof data === "string" ? data : JSON.stringify(data, null, 2);
49
- fs.writeFileSync(outputPath, content, "utf-8");
50
- return outputPath;
51
- }
52
- copyTraceViewerAssets(skip) {
53
- if (skip) return;
54
- const traceViewerFolder = path.join(
55
- __require.resolve("playwright-core"),
56
- "..",
57
- "lib",
58
- "vite",
59
- "traceViewer"
60
- );
61
- const traceViewerTargetFolder = path.join(this.folderPath, "trace");
62
- const traceViewerAssetsTargetFolder = path.join(
63
- traceViewerTargetFolder,
64
- "assets"
65
- );
66
- fs.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
67
- for (const file of fs.readdirSync(traceViewerFolder)) {
68
- if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
69
- continue;
70
- fs.copyFileSync(
71
- path.join(traceViewerFolder, file),
72
- path.join(traceViewerTargetFolder, file)
73
- );
74
- }
75
- const assetsFolder = path.join(traceViewerFolder, "assets");
76
- for (const file of fs.readdirSync(assetsFolder)) {
77
- if (file.endsWith(".map") || file.includes("xtermModule")) continue;
78
- fs.copyFileSync(
79
- path.join(assetsFolder, file),
80
- path.join(traceViewerAssetsTargetFolder, file)
81
- );
82
- }
83
- }
84
- };
85
-
86
- // src/utils/groupProjects.ts
87
- function groupResults(config, results) {
88
- if (config.showProject) {
89
- const groupedResults = results.reduce((acc, result, index) => {
90
- const testId = `${result.filePath}:${result.projectName}:${result.title}`;
91
- const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
92
- const { filePath, suite, projectName } = result;
93
- acc[filePath] = acc[filePath] || {};
94
- acc[filePath][suite] = acc[filePath][suite] || {};
95
- acc[filePath][suite][projectName] = acc[filePath][suite][projectName] || [];
96
- acc[filePath][suite][projectName].push({ ...result, index, testId, key });
97
- return acc;
98
- }, {});
99
- return groupedResults;
100
- } else {
101
- const groupedResults = results.reduce((acc, result, index) => {
102
- const testId = `${result.filePath}:${result.projectName}:${result.title}`;
103
- const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
104
- const { filePath, suite } = result;
105
- acc[filePath] = acc[filePath] || {};
106
- acc[filePath][suite] = acc[filePath][suite] || [];
107
- acc[filePath][suite].push({ ...result, index, testId, key });
108
- return acc;
109
- }, {});
110
- return groupedResults;
111
- }
112
- }
113
-
114
- // src/helpers/HTMLGenerator.ts
115
- var HTMLGenerator = class {
116
- constructor(ortoniConfig, dbManager) {
117
- this.ortoniConfig = ortoniConfig;
118
- this.dbManager = dbManager;
119
- }
120
- async generateFinalReport(filteredResults, totalDuration, results, projectSet) {
121
- const data = await this.prepareReportData(
122
- filteredResults,
123
- totalDuration,
124
- results,
125
- projectSet
126
- );
127
- return data;
128
- }
129
- async getReportData() {
130
- return {
131
- summary: await this.dbManager.getSummaryData(),
132
- trends: await this.dbManager.getTrends(),
133
- flakyTests: await this.dbManager.getFlakyTests(),
134
- slowTests: await this.dbManager.getSlowTests()
135
- };
136
- }
137
- async prepareReportData(filteredResults, totalDuration, results, projectSet) {
138
- const totalTests = filteredResults.length;
139
- const passedTests = results.filter((r) => r.status === "passed").length;
140
- const flakyTests = results.filter((r) => r.status === "flaky").length;
141
- const failed = filteredResults.filter(
142
- (r) => r.status === "failed" || r.status === "timedOut"
143
- ).length;
144
- const successRate = ((passedTests + flakyTests) / totalTests * 100).toFixed(2);
145
- const allTags = /* @__PURE__ */ new Set();
146
- results.forEach(
147
- (result) => result.testTags.forEach((tag) => allTags.add(tag))
148
- );
149
- const projectResults = this.calculateProjectResults(
150
- filteredResults,
151
- results,
152
- projectSet
153
- );
154
- const lastRunDate = (/* @__PURE__ */ new Date()).toLocaleString();
155
- const testHistories = await Promise.all(
156
- results.map(async (result) => {
157
- const testId = `${result.filePath}:${result.projectName}:${result.title}`;
158
- const history = await this.dbManager.getTestHistory(testId);
159
- return {
160
- testId,
161
- history
162
- };
163
- })
164
- );
165
- return {
166
- summary: {
167
- overAllResult: {
168
- pass: passedTests,
169
- fail: failed,
170
- skip: results.filter((r) => r.status === "skipped").length,
171
- retry: results.filter((r) => r.retryAttemptCount).length,
172
- flaky: flakyTests,
173
- total: filteredResults.length
174
- },
175
- successRate,
176
- lastRunDate,
177
- totalDuration,
178
- stats: this.extractProjectStats(projectResults)
179
- },
180
- testResult: {
181
- tests: groupResults(this.ortoniConfig, results),
182
- testHistories,
183
- allTags: Array.from(allTags),
184
- set: projectSet
185
- },
186
- userConfig: {
187
- projectName: this.ortoniConfig.projectName,
188
- authorName: this.ortoniConfig.authorName,
189
- type: this.ortoniConfig.testType,
190
- title: this.ortoniConfig.title
191
- },
192
- userMeta: {
193
- meta: this.ortoniConfig.meta
194
- },
195
- preferences: {
196
- logo: this.ortoniConfig.logo || void 0,
197
- showProject: this.ortoniConfig.showProject || false
198
- },
199
- analytics: {
200
- reportData: await this.getReportData()
201
- }
202
- };
203
- }
204
- calculateProjectResults(filteredResults, results, projectSet) {
205
- return Array.from(projectSet).map((projectName) => {
206
- const projectTests = filteredResults.filter(
207
- (r) => r.projectName === projectName
208
- );
209
- const allProjectTests = results.filter(
210
- (r) => r.projectName === projectName
211
- );
212
- return {
213
- projectName,
214
- passedTests: projectTests.filter((r) => r.status === "passed").length,
215
- failedTests: projectTests.filter(
216
- (r) => r.status === "failed" || r.status === "timedOut"
217
- ).length,
218
- skippedTests: allProjectTests.filter((r) => r.status === "skipped").length,
219
- retryTests: allProjectTests.filter((r) => r.retryAttemptCount).length,
220
- flakyTests: allProjectTests.filter((r) => r.status === "flaky").length,
221
- totalTests: projectTests.length
222
- };
223
- });
224
- }
225
- extractProjectStats(projectResults) {
226
- return {
227
- projectNames: projectResults.map((result) => result.projectName),
228
- totalTests: projectResults.map((result) => result.totalTests),
229
- passedTests: projectResults.map((result) => result.passedTests),
230
- failedTests: projectResults.map((result) => result.failedTests),
231
- skippedTests: projectResults.map((result) => result.skippedTests),
232
- retryTests: projectResults.map((result) => result.retryTests),
233
- flakyTests: projectResults.map((result) => result.flakyTests)
234
- };
235
- }
236
- };
237
-
238
11
  // src/utils/utils.ts
239
- import path2 from "path";
12
+ import path from "path";
240
13
  function normalizeFilePath(filePath) {
241
- const normalizedPath = path2.normalize(filePath);
242
- return path2.basename(normalizedPath);
14
+ const normalizedPath = path.normalize(filePath);
15
+ return path.basename(normalizedPath);
243
16
  }
244
17
  function ensureHtmlExtension(filename) {
245
- const ext = path2.extname(filename);
18
+ const ext = path.extname(filename);
246
19
  if (ext && ext.toLowerCase() === ".html") {
247
20
  return filename;
248
21
  }
@@ -290,67 +63,6 @@ function extractSuites(titlePath) {
290
63
  };
291
64
  }
292
65
 
293
- // src/utils/expressServer.ts
294
- import express from "express";
295
- import path3 from "path";
296
- import { spawn } from "child_process";
297
- function startReportServer(reportFolder, reportFilename, port = 2004, open2) {
298
- const app = express();
299
- app.use(express.static(reportFolder));
300
- app.get("/", (_req, res) => {
301
- try {
302
- res.sendFile(path3.resolve(reportFolder, reportFilename));
303
- } catch (error) {
304
- console.error("Ortoni-Report: Error sending report file:", error);
305
- res.status(500).send("Error loading report");
306
- }
307
- });
308
- try {
309
- const server = app.listen(port, () => {
310
- console.log(
311
- `Server is running at http://localhost:${port}
312
- Press Ctrl+C to stop.`
313
- );
314
- if (open2 === "always" || open2 === "on-failure") {
315
- try {
316
- openBrowser(`http://localhost:${port}`);
317
- } catch (error) {
318
- console.error("Ortoni-Report: Error opening browser:", error);
319
- }
320
- }
321
- });
322
- server.on("error", (error) => {
323
- if (error.code === "EADDRINUSE") {
324
- console.error(
325
- `Ortoni-Report: Port ${port} is already in use. Trying a different port...`
326
- );
327
- } else {
328
- console.error("Ortoni-Report: Server error:", error);
329
- }
330
- });
331
- } catch (error) {
332
- console.error("Ortoni-Report: Error starting the server:", error);
333
- }
334
- }
335
- function openBrowser(url) {
336
- const platform = process.platform;
337
- let command;
338
- try {
339
- if (platform === "win32") {
340
- command = "cmd";
341
- spawn(command, ["/c", "start", url]);
342
- } else if (platform === "darwin") {
343
- command = "open";
344
- spawn(command, [url]);
345
- } else {
346
- command = "xdg-open";
347
- spawn(command, [url]);
348
- }
349
- } catch (error) {
350
- console.error("Ortoni-Report: Error opening the browser:", error);
351
- }
352
- }
353
-
354
66
  // src/helpers/databaseManager.ts
355
67
  import { open } from "sqlite";
356
68
  import sqlite3 from "sqlite3";
@@ -625,14 +337,356 @@ var DatabaseManager = class {
625
337
  }
626
338
  };
627
339
 
628
- export {
629
- __publicField,
630
- FileManager,
631
- HTMLGenerator,
340
+ // src/utils/groupProjects.ts
341
+ function groupResults(config, results) {
342
+ if (config.showProject) {
343
+ const groupedResults = results.reduce((acc, result, index) => {
344
+ const testId = `${result.filePath}:${result.projectName}:${result.title}`;
345
+ const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
346
+ const { filePath, suite, projectName } = result;
347
+ acc[filePath] = acc[filePath] || {};
348
+ acc[filePath][suite] = acc[filePath][suite] || {};
349
+ acc[filePath][suite][projectName] = acc[filePath][suite][projectName] || [];
350
+ acc[filePath][suite][projectName].push({ ...result, index, testId, key });
351
+ return acc;
352
+ }, {});
353
+ return groupedResults;
354
+ } else {
355
+ const groupedResults = results.reduce((acc, result, index) => {
356
+ const testId = `${result.filePath}:${result.projectName}:${result.title}`;
357
+ const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
358
+ const { filePath, suite } = result;
359
+ acc[filePath] = acc[filePath] || {};
360
+ acc[filePath][suite] = acc[filePath][suite] || [];
361
+ acc[filePath][suite].push({ ...result, index, testId, key });
362
+ return acc;
363
+ }, {});
364
+ return groupedResults;
365
+ }
366
+ }
367
+
368
+ // src/helpers/HTMLGenerator.ts
369
+ var HTMLGenerator = class {
370
+ constructor(ortoniConfig, dbManager) {
371
+ this.ortoniConfig = ortoniConfig;
372
+ this.dbManager = dbManager;
373
+ }
374
+ async generateFinalReport(filteredResults, totalDuration, results, projectSet) {
375
+ const data = await this.prepareReportData(
376
+ filteredResults,
377
+ totalDuration,
378
+ results,
379
+ projectSet
380
+ );
381
+ return data;
382
+ }
383
+ async getReportData() {
384
+ return {
385
+ summary: await this.dbManager.getSummaryData(),
386
+ trends: await this.dbManager.getTrends(),
387
+ flakyTests: await this.dbManager.getFlakyTests(),
388
+ slowTests: await this.dbManager.getSlowTests()
389
+ };
390
+ }
391
+ async prepareReportData(filteredResults, totalDuration, results, projectSet) {
392
+ const totalTests = filteredResults.length;
393
+ const passedTests = results.filter((r) => r.status === "passed").length;
394
+ const flakyTests = results.filter((r) => r.status === "flaky").length;
395
+ const failed = filteredResults.filter(
396
+ (r) => r.status === "failed" || r.status === "timedOut"
397
+ ).length;
398
+ const successRate = ((passedTests + flakyTests) / totalTests * 100).toFixed(2);
399
+ const allTags = /* @__PURE__ */ new Set();
400
+ results.forEach(
401
+ (result) => result.testTags.forEach((tag) => allTags.add(tag))
402
+ );
403
+ const projectResults = this.calculateProjectResults(
404
+ filteredResults,
405
+ results,
406
+ projectSet
407
+ );
408
+ const lastRunDate = (/* @__PURE__ */ new Date()).toLocaleString();
409
+ const testHistories = await Promise.all(
410
+ results.map(async (result) => {
411
+ const testId = `${result.filePath}:${result.projectName}:${result.title}`;
412
+ const history = await this.dbManager.getTestHistory(testId);
413
+ return {
414
+ testId,
415
+ history
416
+ };
417
+ })
418
+ );
419
+ return {
420
+ summary: {
421
+ overAllResult: {
422
+ pass: passedTests,
423
+ fail: failed,
424
+ skip: results.filter((r) => r.status === "skipped").length,
425
+ retry: results.filter((r) => r.retryAttemptCount).length,
426
+ flaky: flakyTests,
427
+ total: filteredResults.length
428
+ },
429
+ successRate,
430
+ lastRunDate,
431
+ totalDuration,
432
+ stats: this.extractProjectStats(projectResults)
433
+ },
434
+ testResult: {
435
+ tests: groupResults(this.ortoniConfig, results),
436
+ testHistories,
437
+ allTags: Array.from(allTags),
438
+ set: projectSet
439
+ },
440
+ userConfig: {
441
+ projectName: this.ortoniConfig.projectName,
442
+ authorName: this.ortoniConfig.authorName,
443
+ type: this.ortoniConfig.testType,
444
+ title: this.ortoniConfig.title
445
+ },
446
+ userMeta: {
447
+ meta: this.ortoniConfig.meta
448
+ },
449
+ preferences: {
450
+ logo: this.ortoniConfig.logo || void 0,
451
+ showProject: this.ortoniConfig.showProject || false
452
+ },
453
+ analytics: {
454
+ reportData: await this.getReportData()
455
+ }
456
+ };
457
+ }
458
+ calculateProjectResults(filteredResults, results, projectSet) {
459
+ return Array.from(projectSet).map((projectName) => {
460
+ const projectTests = filteredResults.filter(
461
+ (r) => r.projectName === projectName
462
+ );
463
+ const allProjectTests = results.filter(
464
+ (r) => r.projectName === projectName
465
+ );
466
+ return {
467
+ projectName,
468
+ passedTests: projectTests.filter((r) => r.status === "passed").length,
469
+ failedTests: projectTests.filter(
470
+ (r) => r.status === "failed" || r.status === "timedOut"
471
+ ).length,
472
+ skippedTests: allProjectTests.filter((r) => r.status === "skipped").length,
473
+ retryTests: allProjectTests.filter((r) => r.retryAttemptCount).length,
474
+ flakyTests: allProjectTests.filter((r) => r.status === "flaky").length,
475
+ totalTests: projectTests.length
476
+ };
477
+ });
478
+ }
479
+ extractProjectStats(projectResults) {
480
+ return {
481
+ projectNames: projectResults.map((result) => result.projectName),
482
+ totalTests: projectResults.map((result) => result.totalTests),
483
+ passedTests: projectResults.map((result) => result.passedTests),
484
+ failedTests: projectResults.map((result) => result.failedTests),
485
+ skippedTests: projectResults.map((result) => result.skippedTests),
486
+ retryTests: projectResults.map((result) => result.retryTests),
487
+ flakyTests: projectResults.map((result) => result.flakyTests)
488
+ };
489
+ }
490
+ };
491
+
492
+ // src/helpers/fileManager.ts
493
+ import fs2 from "fs";
494
+ import path3 from "path";
495
+
496
+ // src/helpers/templateLoader.ts
497
+ import fs from "fs";
498
+ import path2 from "path";
499
+ async function readBundledTemplate(pkgName = "ortoni-report") {
500
+ const packagedRel = "dist/index.html";
501
+ try {
502
+ if (typeof __require === "function") {
503
+ const resolved = __require.resolve(`${pkgName}/${packagedRel}`);
504
+ if (fs.existsSync(resolved)) {
505
+ return fs.readFileSync(resolved, "utf-8");
506
+ }
507
+ }
508
+ } catch {
509
+ }
510
+ try {
511
+ const moduleNS = await import("module");
512
+ if (moduleNS && typeof moduleNS.createRequire === "function") {
513
+ const createRequire = moduleNS.createRequire;
514
+ const req = createRequire(
515
+ typeof __filename !== "undefined" ? __filename : import.meta.url
516
+ );
517
+ const resolved = req.resolve(`${pkgName}/${packagedRel}`);
518
+ if (fs.existsSync(resolved)) {
519
+ return fs.readFileSync(resolved, "utf-8");
520
+ }
521
+ }
522
+ } catch {
523
+ }
524
+ try {
525
+ const here = path2.resolve(__dirname, "../dist/index.html");
526
+ if (fs.existsSync(here)) return fs.readFileSync(here, "utf-8");
527
+ } catch {
528
+ }
529
+ try {
530
+ const nm = path2.join(process.cwd(), "node_modules", pkgName, packagedRel);
531
+ if (fs.existsSync(nm)) return fs.readFileSync(nm, "utf-8");
532
+ } catch {
533
+ }
534
+ try {
535
+ const alt = path2.join(process.cwd(), "dist", "index.html");
536
+ if (fs.existsSync(alt)) return fs.readFileSync(alt, "utf-8");
537
+ } catch {
538
+ }
539
+ throw new Error(
540
+ `ortoni-report template not found (tried:
541
+ - require.resolve('${pkgName}/${packagedRel}')
542
+ - import('module').createRequire(...).resolve('${pkgName}/${packagedRel}')
543
+ - relative ../dist/index.html
544
+ - ${path2.join(
545
+ process.cwd(),
546
+ "node_modules",
547
+ pkgName,
548
+ packagedRel
549
+ )}
550
+ - ${path2.join(process.cwd(), "dist", "index.html")}
551
+ Ensure 'dist/index.html' is present in the published package and package.json 'files' includes 'dist/'.`
552
+ );
553
+ }
554
+
555
+ // src/helpers/fileManager.ts
556
+ var FileManager = class {
557
+ constructor(folderPath) {
558
+ this.folderPath = folderPath;
559
+ }
560
+ ensureReportDirectory() {
561
+ const ortoniDataFolder = path3.join(this.folderPath, "ortoni-data");
562
+ if (!fs2.existsSync(this.folderPath)) {
563
+ fs2.mkdirSync(this.folderPath, { recursive: true });
564
+ } else {
565
+ if (fs2.existsSync(ortoniDataFolder)) {
566
+ fs2.rmSync(ortoniDataFolder, { recursive: true, force: true });
567
+ }
568
+ }
569
+ }
570
+ async writeReportFile(filename, data) {
571
+ let html = await readBundledTemplate();
572
+ const reportJSON = JSON.stringify({
573
+ data
574
+ });
575
+ html = html.replace("__ORTONI_TEST_REPORTDATA__", reportJSON);
576
+ const outputPath = path3.join(process.cwd(), this.folderPath, filename);
577
+ fs2.writeFileSync(outputPath, html);
578
+ return outputPath;
579
+ }
580
+ writeRawFile(filename, data) {
581
+ const outputPath = path3.join(process.cwd(), this.folderPath, filename);
582
+ fs2.mkdirSync(path3.dirname(outputPath), { recursive: true });
583
+ const content = typeof data === "string" ? data : JSON.stringify(data, null, 2);
584
+ fs2.writeFileSync(outputPath, content, "utf-8");
585
+ return outputPath;
586
+ }
587
+ copyTraceViewerAssets(skip) {
588
+ if (skip) return;
589
+ const traceViewerFolder = path3.join(
590
+ __require.resolve("playwright-core"),
591
+ "..",
592
+ "lib",
593
+ "vite",
594
+ "traceViewer"
595
+ );
596
+ const traceViewerTargetFolder = path3.join(this.folderPath, "trace");
597
+ const traceViewerAssetsTargetFolder = path3.join(
598
+ traceViewerTargetFolder,
599
+ "assets"
600
+ );
601
+ fs2.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
602
+ for (const file of fs2.readdirSync(traceViewerFolder)) {
603
+ if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
604
+ continue;
605
+ fs2.copyFileSync(
606
+ path3.join(traceViewerFolder, file),
607
+ path3.join(traceViewerTargetFolder, file)
608
+ );
609
+ }
610
+ const assetsFolder = path3.join(traceViewerFolder, "assets");
611
+ for (const file of fs2.readdirSync(assetsFolder)) {
612
+ if (file.endsWith(".map") || file.includes("xtermModule")) continue;
613
+ fs2.copyFileSync(
614
+ path3.join(assetsFolder, file),
615
+ path3.join(traceViewerAssetsTargetFolder, file)
616
+ );
617
+ }
618
+ }
619
+ };
620
+
621
+ // src/utils/expressServer.ts
622
+ import express from "express";
623
+ import path4 from "path";
624
+ import { spawn } from "child_process";
625
+ function startReportServer(reportFolder, reportFilename, port = 2004, open2) {
626
+ const app = express();
627
+ app.use(express.static(reportFolder));
628
+ app.get("/", (_req, res) => {
629
+ try {
630
+ res.sendFile(path4.resolve(reportFolder, reportFilename));
631
+ } catch (error) {
632
+ console.error("Ortoni Report: Error sending report file:", error);
633
+ res.status(500).send("Error loading report");
634
+ }
635
+ });
636
+ try {
637
+ const server = app.listen(port, () => {
638
+ console.log(
639
+ `Server is running at http://localhost:${port}
640
+ Press Ctrl+C to stop.`
641
+ );
642
+ if (open2 === "always" || open2 === "on-failure") {
643
+ try {
644
+ openBrowser(`http://localhost:${port}`);
645
+ } catch (error) {
646
+ console.error("Ortoni Report: Error opening browser:", error);
647
+ }
648
+ }
649
+ });
650
+ server.on("error", (error) => {
651
+ if (error.code === "EADDRINUSE") {
652
+ console.error(
653
+ `Ortoni Report: Port ${port} is already in use. Trying a different port...`
654
+ );
655
+ } else {
656
+ console.error("Ortoni Report: Server error:", error);
657
+ }
658
+ });
659
+ } catch (error) {
660
+ console.error("Ortoni Report: Error starting the server:", error);
661
+ }
662
+ }
663
+ function openBrowser(url) {
664
+ const platform = process.platform;
665
+ let command;
666
+ try {
667
+ if (platform === "win32") {
668
+ command = "cmd";
669
+ spawn(command, ["/c", "start", url]);
670
+ } else if (platform === "darwin") {
671
+ command = "open";
672
+ spawn(command, [url]);
673
+ } else {
674
+ command = "xdg-open";
675
+ spawn(command, [url]);
676
+ }
677
+ } catch (error) {
678
+ console.error("Ortoni Report: Error opening the browser:", error);
679
+ }
680
+ }
681
+
682
+ export {
683
+ __publicField,
632
684
  normalizeFilePath,
633
685
  ensureHtmlExtension,
634
686
  escapeHtml,
635
687
  extractSuites,
636
- startReportServer,
637
- DatabaseManager
688
+ DatabaseManager,
689
+ HTMLGenerator,
690
+ FileManager,
691
+ startReportServer
638
692
  };