ortoni-report 4.0.2-beta.0 → 4.0.2

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.mjs DELETED
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- DatabaseManager,
4
- FileManager,
5
- HTMLGenerator,
6
- startReportServer
7
- } from "../chunk-JEIWNUQY.mjs";
8
-
9
- // src/cli/cli.ts
10
- import { program } from "commander";
11
- import * as fs from "fs";
12
- 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) => {
23
- const projectRoot = process.cwd();
24
- 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);
45
- const shardFiles = fs.readdirSync(folderPath).filter((f) => f.startsWith("ortoni-shard-") && f.endsWith(".json"));
46
- if (shardFiles.length === 0) {
47
- console.error("\u274C No shard files found to merge.");
48
- process.exit(1);
49
- }
50
- let allResults = [];
51
- let projectSet = /* @__PURE__ */ new Set();
52
- let totalDuration = 0;
53
- for (const file of shardFiles) {
54
- const shardData = JSON.parse(
55
- fs.readFileSync(path.join(folderPath, file), "utf-8")
56
- );
57
- allResults.push(...shardData.results);
58
- shardData.projectSet.forEach((p) => projectSet.add(p));
59
- totalDuration += shardData.duration;
60
- }
61
- const dbManager = new DatabaseManager();
62
- await dbManager.initialize(
63
- path.join(folderPath, "ortoni-data-history.sqlite")
64
- );
65
- const runId = await dbManager.saveTestRun();
66
- if (typeof runId === "number") {
67
- await dbManager.saveTestResults(runId, allResults);
68
- }
69
- const htmlGenerator = new HTMLGenerator({}, dbManager);
70
- const finalReportData = await htmlGenerator.generateFinalReport(
71
- allResults.filter((r) => r.status !== "skipped"),
72
- totalDuration,
73
- allResults,
74
- projectSet
75
- );
76
- const fileManager = new FileManager(folderPath);
77
- const outputPath = fileManager.writeReportFile(filePath, finalReportData);
78
- console.log(`\u2705 Final merged report generated at ${outputPath}`);
79
- });
80
- program.parse(process.argv);