ortoni-report 4.0.2-beta.0 → 4.0.2-beta.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/dist/cli/cli.js CHANGED
@@ -88,6 +88,10 @@ function openBrowser(url) {
88
88
  }
89
89
 
90
90
  // src/cli/cli.ts
91
+ var fs3 = __toESM(require("fs"));
92
+ var path4 = __toESM(require("path"));
93
+
94
+ // src/cli/mergeData.ts
91
95
  var fs2 = __toESM(require("fs"));
92
96
  var path3 = __toESM(require("path"));
93
97
 
@@ -383,6 +387,75 @@ var DatabaseManager = class {
383
387
  }
384
388
  };
385
389
 
390
+ // src/helpers/fileManager.ts
391
+ var import_fs = __toESM(require("fs"));
392
+ var import_path2 = __toESM(require("path"));
393
+ var FileManager = class {
394
+ constructor(folderPath) {
395
+ this.folderPath = folderPath;
396
+ }
397
+ ensureReportDirectory() {
398
+ const ortoniDataFolder = import_path2.default.join(this.folderPath, "ortoni-data");
399
+ if (!import_fs.default.existsSync(this.folderPath)) {
400
+ import_fs.default.mkdirSync(this.folderPath, { recursive: true });
401
+ } else {
402
+ if (import_fs.default.existsSync(ortoniDataFolder)) {
403
+ import_fs.default.rmSync(ortoniDataFolder, { recursive: true, force: true });
404
+ }
405
+ }
406
+ }
407
+ writeReportFile(filename, data) {
408
+ const templatePath = import_path2.default.join(__dirname, "..", "index.html");
409
+ console.log("temp path - " + templatePath);
410
+ let html = import_fs.default.readFileSync(templatePath, "utf-8");
411
+ const reportJSON = JSON.stringify({
412
+ data
413
+ });
414
+ html = html.replace("__ORTONI_TEST_REPORTDATA__", reportJSON);
415
+ import_fs.default.writeFileSync(filename, html);
416
+ return filename;
417
+ }
418
+ writeRawFile(filename, data) {
419
+ const outputPath = import_path2.default.join(process.cwd(), this.folderPath, filename);
420
+ import_fs.default.mkdirSync(import_path2.default.dirname(outputPath), { recursive: true });
421
+ const content = typeof data === "string" ? data : JSON.stringify(data, null, 2);
422
+ import_fs.default.writeFileSync(outputPath, content, "utf-8");
423
+ return outputPath;
424
+ }
425
+ copyTraceViewerAssets(skip) {
426
+ if (skip) return;
427
+ const traceViewerFolder = import_path2.default.join(
428
+ require.resolve("playwright-core"),
429
+ "..",
430
+ "lib",
431
+ "vite",
432
+ "traceViewer"
433
+ );
434
+ const traceViewerTargetFolder = import_path2.default.join(this.folderPath, "trace");
435
+ const traceViewerAssetsTargetFolder = import_path2.default.join(
436
+ traceViewerTargetFolder,
437
+ "assets"
438
+ );
439
+ import_fs.default.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
440
+ for (const file of import_fs.default.readdirSync(traceViewerFolder)) {
441
+ if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
442
+ continue;
443
+ import_fs.default.copyFileSync(
444
+ import_path2.default.join(traceViewerFolder, file),
445
+ import_path2.default.join(traceViewerTargetFolder, file)
446
+ );
447
+ }
448
+ const assetsFolder = import_path2.default.join(traceViewerFolder, "assets");
449
+ for (const file of import_fs.default.readdirSync(assetsFolder)) {
450
+ if (file.endsWith(".map") || file.includes("xtermModule")) continue;
451
+ import_fs.default.copyFileSync(
452
+ import_path2.default.join(assetsFolder, file),
453
+ import_path2.default.join(traceViewerAssetsTargetFolder, file)
454
+ );
455
+ }
456
+ }
457
+ };
458
+
386
459
  // src/utils/groupProjects.ts
387
460
  function groupResults(config, results) {
388
461
  if (config.showProject) {
@@ -535,116 +608,21 @@ var HTMLGenerator = class {
535
608
  }
536
609
  };
537
610
 
538
- // src/helpers/fileManager.ts
539
- var import_fs = __toESM(require("fs"));
540
- var import_path2 = __toESM(require("path"));
541
- var FileManager = class {
542
- constructor(folderPath) {
543
- this.folderPath = folderPath;
544
- }
545
- ensureReportDirectory() {
546
- const ortoniDataFolder = import_path2.default.join(this.folderPath, "ortoni-data");
547
- if (!import_fs.default.existsSync(this.folderPath)) {
548
- import_fs.default.mkdirSync(this.folderPath, { recursive: true });
549
- } else {
550
- if (import_fs.default.existsSync(ortoniDataFolder)) {
551
- import_fs.default.rmSync(ortoniDataFolder, { recursive: true, force: true });
552
- }
553
- }
554
- }
555
- writeReportFile(filename, data) {
556
- const templatePath = import_path2.default.join(__dirname, "..", "index.html");
557
- console.log("temp path - " + templatePath);
558
- let html = import_fs.default.readFileSync(templatePath, "utf-8");
559
- const reportJSON = JSON.stringify({
560
- data
561
- });
562
- html = html.replace("__ORTONI_TEST_REPORTDATA__", reportJSON);
563
- import_fs.default.writeFileSync(filename, html);
564
- return filename;
565
- }
566
- writeRawFile(filename, data) {
567
- const outputPath = import_path2.default.join(process.cwd(), this.folderPath, filename);
568
- import_fs.default.mkdirSync(import_path2.default.dirname(outputPath), { recursive: true });
569
- const content = typeof data === "string" ? data : JSON.stringify(data, null, 2);
570
- import_fs.default.writeFileSync(outputPath, content, "utf-8");
571
- return outputPath;
572
- }
573
- copyTraceViewerAssets(skip) {
574
- if (skip) return;
575
- const traceViewerFolder = import_path2.default.join(
576
- require.resolve("playwright-core"),
577
- "..",
578
- "lib",
579
- "vite",
580
- "traceViewer"
581
- );
582
- const traceViewerTargetFolder = import_path2.default.join(this.folderPath, "trace");
583
- const traceViewerAssetsTargetFolder = import_path2.default.join(
584
- traceViewerTargetFolder,
585
- "assets"
586
- );
587
- import_fs.default.mkdirSync(traceViewerAssetsTargetFolder, { recursive: true });
588
- for (const file of import_fs.default.readdirSync(traceViewerFolder)) {
589
- if (file.endsWith(".map") || file.includes("watch") || file.includes("assets"))
590
- continue;
591
- import_fs.default.copyFileSync(
592
- import_path2.default.join(traceViewerFolder, file),
593
- import_path2.default.join(traceViewerTargetFolder, file)
594
- );
595
- }
596
- const assetsFolder = import_path2.default.join(traceViewerFolder, "assets");
597
- for (const file of import_fs.default.readdirSync(assetsFolder)) {
598
- if (file.endsWith(".map") || file.includes("xtermModule")) continue;
599
- import_fs.default.copyFileSync(
600
- import_path2.default.join(assetsFolder, file),
601
- import_path2.default.join(traceViewerAssetsTargetFolder, file)
602
- );
603
- }
604
- }
605
- };
606
-
607
- // src/cli/cli.ts
608
- import_commander.program.version("2.0.9").description("Ortoni Playwright Test Report CLI");
609
- import_commander.program.command("show-report").description("Open the generated Ortoni report").option(
610
- "-d, --dir <path>",
611
- "Path to the folder containing the report",
612
- "ortoni-report"
613
- ).option(
614
- "-f, --file <filename>",
615
- "Name of the report file",
616
- "ortoni-report.html"
617
- ).option("-p, --port <port>", "Port to run the server", "2004").action((options) => {
611
+ // src/cli/mergeData.ts
612
+ async function mergerData(options) {
618
613
  const projectRoot = process.cwd();
619
614
  const folderPath = path3.resolve(projectRoot, options.dir);
620
- const filePath = path3.resolve(folderPath, options.file);
621
- const port = parseInt(options.port) || 2004;
622
- if (!fs2.existsSync(filePath)) {
623
- console.error(
624
- `\u274C Error: The file "${filePath}" does not exist in "${folderPath}".`
625
- );
626
- process.exit(1);
627
- }
628
- startReportServer(folderPath, path3.basename(filePath), port, "always");
629
- });
630
- import_commander.program.command("merge-shards").description("Merge sharded reports into one final report").option(
631
- "-d, --dir <path>",
632
- "Path to the folder containing shard files",
633
- "ortoni-report"
634
- ).option("-f, --file <filename>", "Output report file", "ortoni-report.html").action(async (options) => {
635
- const projectRoot = process.cwd();
636
- const folderPath = path3.resolve(projectRoot, options.dir);
637
- console.log("folder - " + folderPath);
638
- console.log(`Merging shard files in folder: ${folderPath}`);
639
- const filePath = path3.resolve(folderPath, options.file);
615
+ console.info(`Ortoni Report: Merging shard files in folder: ${folderPath}`);
640
616
  const shardFiles = fs2.readdirSync(folderPath).filter((f) => f.startsWith("ortoni-shard-") && f.endsWith(".json"));
641
617
  if (shardFiles.length === 0) {
642
- console.error("\u274C No shard files found to merge.");
618
+ console.error("Ortoni Report: \u274C No shard files found to merge.");
643
619
  process.exit(1);
644
620
  }
645
621
  let allResults = [];
646
622
  let projectSet = /* @__PURE__ */ new Set();
647
623
  let totalDuration = 0;
624
+ let mergedUserConfig = null;
625
+ let mergedUserMeta = null;
648
626
  for (const file of shardFiles) {
649
627
  const shardData = JSON.parse(
650
628
  fs2.readFileSync(path3.join(folderPath, file), "utf-8")
@@ -652,6 +630,10 @@ import_commander.program.command("merge-shards").description("Merge sharded repo
652
630
  allResults.push(...shardData.results);
653
631
  shardData.projectSet.forEach((p) => projectSet.add(p));
654
632
  totalDuration += shardData.duration;
633
+ if (!mergedUserConfig && shardData.userConfig)
634
+ mergedUserConfig = shardData.userConfig;
635
+ if (!mergedUserMeta && shardData.userMeta)
636
+ mergedUserMeta = shardData.userMeta;
655
637
  }
656
638
  const dbManager = new DatabaseManager();
657
639
  await dbManager.initialize(
@@ -660,8 +642,13 @@ import_commander.program.command("merge-shards").description("Merge sharded repo
660
642
  const runId = await dbManager.saveTestRun();
661
643
  if (typeof runId === "number") {
662
644
  await dbManager.saveTestResults(runId, allResults);
645
+ } else {
646
+ console.error("Ortoni Report: \u274C Failed to save test run to database.");
663
647
  }
664
- const htmlGenerator = new HTMLGenerator({}, dbManager);
648
+ const htmlGenerator = new HTMLGenerator(
649
+ { ...mergedUserConfig, meta: mergedUserMeta?.meta },
650
+ dbManager
651
+ );
665
652
  const finalReportData = await htmlGenerator.generateFinalReport(
666
653
  allResults.filter((r) => r.status !== "skipped"),
667
654
  totalDuration,
@@ -669,7 +656,43 @@ import_commander.program.command("merge-shards").description("Merge sharded repo
669
656
  projectSet
670
657
  );
671
658
  const fileManager = new FileManager(folderPath);
672
- const outputPath = fileManager.writeReportFile(filePath, finalReportData);
659
+ const outputFileName = options.file || "ortoni-report.html";
660
+ const outputFilenamePath = path3.join(folderPath, outputFileName);
661
+ const outputPath = fileManager.writeReportFile(
662
+ outputFilenamePath,
663
+ finalReportData
664
+ );
673
665
  console.log(`\u2705 Final merged report generated at ${outputPath}`);
666
+ }
667
+
668
+ // src/cli/cli.ts
669
+ import_commander.program.version("4.0.1").description("Ortoni Report - CLI");
670
+ import_commander.program.command("show-report").description("Open Ortoni Report").option(
671
+ "-d, --dir <path>",
672
+ "Path to the folder containing the report",
673
+ "ortoni-report"
674
+ ).option(
675
+ "-f, --file <filename>",
676
+ "Name of the report file",
677
+ "ortoni-report.html"
678
+ ).option("-p, --port <port>", "Port to run the server", "2004").action((options) => {
679
+ const projectRoot = process.cwd();
680
+ const folderPath = path4.resolve(projectRoot, options.dir);
681
+ const filePath = path4.resolve(folderPath, options.file);
682
+ const port = parseInt(options.port) || 2004;
683
+ if (!fs3.existsSync(filePath)) {
684
+ console.error(
685
+ `\u274C Error: The file "${filePath}" does not exist in "${folderPath}".`
686
+ );
687
+ process.exit(1);
688
+ }
689
+ startReportServer(folderPath, path4.basename(filePath), port, "always");
690
+ });
691
+ import_commander.program.command("merge-report").description("Merge sharded reports into one final report").option(
692
+ "-d, --dir <path>",
693
+ "Path to the folder containing shard files",
694
+ "ortoni-report"
695
+ ).option("-f, --file <filename>", "Output report file", "ortoni-report.html").action(async (options) => {
696
+ await mergerData(options);
674
697
  });
675
698
  import_commander.program.parse(process.argv);
package/dist/cli/cli.mjs CHANGED
@@ -8,48 +8,26 @@ import {
8
8
 
9
9
  // src/cli/cli.ts
10
10
  import { program } from "commander";
11
+ import * as fs2 from "fs";
12
+ import * as path2 from "path";
13
+
14
+ // src/cli/mergeData.ts
11
15
  import * as fs from "fs";
12
16
  import * as path from "path";
13
- program.version("2.0.9").description("Ortoni Playwright Test Report CLI");
14
- program.command("show-report").description("Open the generated Ortoni report").option(
15
- "-d, --dir <path>",
16
- "Path to the folder containing the report",
17
- "ortoni-report"
18
- ).option(
19
- "-f, --file <filename>",
20
- "Name of the report file",
21
- "ortoni-report.html"
22
- ).option("-p, --port <port>", "Port to run the server", "2004").action((options) => {
17
+ async function mergerData(options) {
23
18
  const projectRoot = process.cwd();
24
19
  const folderPath = path.resolve(projectRoot, options.dir);
25
- const filePath = path.resolve(folderPath, options.file);
26
- const port = parseInt(options.port) || 2004;
27
- if (!fs.existsSync(filePath)) {
28
- console.error(
29
- `\u274C Error: The file "${filePath}" does not exist in "${folderPath}".`
30
- );
31
- process.exit(1);
32
- }
33
- startReportServer(folderPath, path.basename(filePath), port, "always");
34
- });
35
- program.command("merge-shards").description("Merge sharded reports into one final report").option(
36
- "-d, --dir <path>",
37
- "Path to the folder containing shard files",
38
- "ortoni-report"
39
- ).option("-f, --file <filename>", "Output report file", "ortoni-report.html").action(async (options) => {
40
- const projectRoot = process.cwd();
41
- const folderPath = path.resolve(projectRoot, options.dir);
42
- console.log("folder - " + folderPath);
43
- console.log(`Merging shard files in folder: ${folderPath}`);
44
- const filePath = path.resolve(folderPath, options.file);
20
+ console.info(`Ortoni Report: Merging shard files in folder: ${folderPath}`);
45
21
  const shardFiles = fs.readdirSync(folderPath).filter((f) => f.startsWith("ortoni-shard-") && f.endsWith(".json"));
46
22
  if (shardFiles.length === 0) {
47
- console.error("\u274C No shard files found to merge.");
23
+ console.error("Ortoni Report: \u274C No shard files found to merge.");
48
24
  process.exit(1);
49
25
  }
50
26
  let allResults = [];
51
27
  let projectSet = /* @__PURE__ */ new Set();
52
28
  let totalDuration = 0;
29
+ let mergedUserConfig = null;
30
+ let mergedUserMeta = null;
53
31
  for (const file of shardFiles) {
54
32
  const shardData = JSON.parse(
55
33
  fs.readFileSync(path.join(folderPath, file), "utf-8")
@@ -57,6 +35,10 @@ program.command("merge-shards").description("Merge sharded reports into one fina
57
35
  allResults.push(...shardData.results);
58
36
  shardData.projectSet.forEach((p) => projectSet.add(p));
59
37
  totalDuration += shardData.duration;
38
+ if (!mergedUserConfig && shardData.userConfig)
39
+ mergedUserConfig = shardData.userConfig;
40
+ if (!mergedUserMeta && shardData.userMeta)
41
+ mergedUserMeta = shardData.userMeta;
60
42
  }
61
43
  const dbManager = new DatabaseManager();
62
44
  await dbManager.initialize(
@@ -65,8 +47,13 @@ program.command("merge-shards").description("Merge sharded reports into one fina
65
47
  const runId = await dbManager.saveTestRun();
66
48
  if (typeof runId === "number") {
67
49
  await dbManager.saveTestResults(runId, allResults);
50
+ } else {
51
+ console.error("Ortoni Report: \u274C Failed to save test run to database.");
68
52
  }
69
- const htmlGenerator = new HTMLGenerator({}, dbManager);
53
+ const htmlGenerator = new HTMLGenerator(
54
+ { ...mergedUserConfig, meta: mergedUserMeta?.meta },
55
+ dbManager
56
+ );
70
57
  const finalReportData = await htmlGenerator.generateFinalReport(
71
58
  allResults.filter((r) => r.status !== "skipped"),
72
59
  totalDuration,
@@ -74,7 +61,43 @@ program.command("merge-shards").description("Merge sharded reports into one fina
74
61
  projectSet
75
62
  );
76
63
  const fileManager = new FileManager(folderPath);
77
- const outputPath = fileManager.writeReportFile(filePath, finalReportData);
64
+ const outputFileName = options.file || "ortoni-report.html";
65
+ const outputFilenamePath = path.join(folderPath, outputFileName);
66
+ const outputPath = fileManager.writeReportFile(
67
+ outputFilenamePath,
68
+ finalReportData
69
+ );
78
70
  console.log(`\u2705 Final merged report generated at ${outputPath}`);
71
+ }
72
+
73
+ // src/cli/cli.ts
74
+ program.version("4.0.1").description("Ortoni Report - CLI");
75
+ program.command("show-report").description("Open Ortoni Report").option(
76
+ "-d, --dir <path>",
77
+ "Path to the folder containing the report",
78
+ "ortoni-report"
79
+ ).option(
80
+ "-f, --file <filename>",
81
+ "Name of the report file",
82
+ "ortoni-report.html"
83
+ ).option("-p, --port <port>", "Port to run the server", "2004").action((options) => {
84
+ const projectRoot = process.cwd();
85
+ const folderPath = path2.resolve(projectRoot, options.dir);
86
+ const filePath = path2.resolve(folderPath, options.file);
87
+ const port = parseInt(options.port) || 2004;
88
+ if (!fs2.existsSync(filePath)) {
89
+ console.error(
90
+ `\u274C Error: The file "${filePath}" does not exist in "${folderPath}".`
91
+ );
92
+ process.exit(1);
93
+ }
94
+ startReportServer(folderPath, path2.basename(filePath), port, "always");
95
+ });
96
+ program.command("merge-report").description("Merge sharded reports into one final report").option(
97
+ "-d, --dir <path>",
98
+ "Path to the folder containing shard files",
99
+ "ortoni-report"
100
+ ).option("-f, --file <filename>", "Output report file", "ortoni-report.html").action(async (options) => {
101
+ await mergerData(options);
79
102
  });
80
103
  program.parse(process.argv);
@@ -2072,7 +2072,16 @@ var OrtoniReport = class {
2072
2072
  status: result.status,
2073
2073
  duration: totalDuration,
2074
2074
  results: this.results,
2075
- projectSet: Array.from(this.projectSet)
2075
+ projectSet: Array.from(this.projectSet),
2076
+ userConfig: {
2077
+ projectName: this.ortoniConfig.projectName,
2078
+ authorName: this.ortoniConfig.authorName,
2079
+ type: this.ortoniConfig.testType,
2080
+ title: this.ortoniConfig.title
2081
+ },
2082
+ userMeta: {
2083
+ meta: this.ortoniConfig.meta
2084
+ }
2076
2085
  };
2077
2086
  this.fileManager.writeRawFile(shardFile, shardData);
2078
2087
  console.log(`\u{1F4E6} OrtoniReport wrote shard file: ${shardFile}`);
@@ -1434,7 +1434,16 @@ var OrtoniReport = class {
1434
1434
  status: result.status,
1435
1435
  duration: totalDuration,
1436
1436
  results: this.results,
1437
- projectSet: Array.from(this.projectSet)
1437
+ projectSet: Array.from(this.projectSet),
1438
+ userConfig: {
1439
+ projectName: this.ortoniConfig.projectName,
1440
+ authorName: this.ortoniConfig.authorName,
1441
+ type: this.ortoniConfig.testType,
1442
+ title: this.ortoniConfig.title
1443
+ },
1444
+ userMeta: {
1445
+ meta: this.ortoniConfig.meta
1446
+ }
1438
1447
  };
1439
1448
  this.fileManager.writeRawFile(shardFile, shardData);
1440
1449
  console.log(`\u{1F4E6} OrtoniReport wrote shard file: ${shardFile}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ortoni-report",
3
- "version": "4.0.2-beta.0",
3
+ "version": "4.0.2-beta.1",
4
4
  "description": "Playwright Report By LetCode with Koushik",
5
5
  "scripts": {
6
6
  "tsc": "tsc",