@allurereport/core 3.0.0 → 3.1.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/dist/api.d.ts +1 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.js +3 -0
- package/dist/history.d.ts +5 -2
- package/dist/history.js +17 -6
- package/dist/report.js +22 -17
- package/package.json +19 -18
package/dist/api.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface FullConfig {
|
|
|
13
13
|
open: boolean;
|
|
14
14
|
port: string | undefined;
|
|
15
15
|
historyPath?: string;
|
|
16
|
+
historyLimit?: number;
|
|
16
17
|
knownIssuesPath: string;
|
|
17
18
|
defaultLabels?: DefaultLabelsConfig;
|
|
18
19
|
stage?: string;
|
|
@@ -27,8 +28,6 @@ export interface FullConfig {
|
|
|
27
28
|
realTime?: any;
|
|
28
29
|
qualityGate?: QualityGateConfig;
|
|
29
30
|
allureService?: {
|
|
30
|
-
url?: string;
|
|
31
|
-
project?: string;
|
|
32
31
|
accessToken?: string;
|
|
33
32
|
};
|
|
34
33
|
}
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -52,6 +52,7 @@ export const validateConfig = (config) => {
|
|
|
52
52
|
"open",
|
|
53
53
|
"port",
|
|
54
54
|
"historyPath",
|
|
55
|
+
"historyLimit",
|
|
55
56
|
"knownIssuesPath",
|
|
56
57
|
"plugins",
|
|
57
58
|
"defaultLabels",
|
|
@@ -105,6 +106,7 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
105
106
|
const open = override.open ?? config.open ?? false;
|
|
106
107
|
const port = override.port ?? config.port ?? undefined;
|
|
107
108
|
const historyPath = override.historyPath ?? config.historyPath;
|
|
109
|
+
const historyLimit = override.historyLimit ?? config.historyLimit;
|
|
108
110
|
const appendHistory = config.appendHistory ?? true;
|
|
109
111
|
const knownIssuesPath = resolve(override.knownIssuesPath ?? config.knownIssuesPath ?? "./allure/known.json");
|
|
110
112
|
const output = resolve(override.output ?? config.output ?? "./allure-report");
|
|
@@ -129,6 +131,7 @@ export const resolveConfig = async (config, override = {}) => {
|
|
|
129
131
|
variables,
|
|
130
132
|
environments,
|
|
131
133
|
appendHistory,
|
|
134
|
+
historyLimit,
|
|
132
135
|
historyPath: historyPath ? resolve(historyPath) : undefined,
|
|
133
136
|
reportFiles: new FileSystemReportFiles(output),
|
|
134
137
|
plugins: pluginInstances,
|
package/dist/history.d.ts
CHANGED
|
@@ -2,8 +2,11 @@ import type { AllureHistory, HistoryDataPoint, TestCase, TestResult } from "@all
|
|
|
2
2
|
export declare const createHistory: (reportUuid: string, reportName: string | undefined, testCases: TestCase[], testResults: TestResult[], remoteUrl?: string) => HistoryDataPoint;
|
|
3
3
|
export declare const writeHistory: (historyPath: string, data: HistoryDataPoint) => Promise<void>;
|
|
4
4
|
export declare class AllureLocalHistory implements AllureHistory {
|
|
5
|
-
private readonly
|
|
6
|
-
constructor(
|
|
5
|
+
private readonly params;
|
|
6
|
+
constructor(params: {
|
|
7
|
+
historyPath: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
});
|
|
7
10
|
readHistory(): Promise<HistoryDataPoint[]>;
|
|
8
11
|
appendHistory(data: HistoryDataPoint): Promise<void>;
|
|
9
12
|
}
|
package/dist/history.js
CHANGED
|
@@ -46,16 +46,20 @@ export const writeHistory = async (historyPath, data) => {
|
|
|
46
46
|
await writeFile(path, `${JSON.stringify(data)}\n`, { encoding: "utf-8", flag: "a+" });
|
|
47
47
|
};
|
|
48
48
|
export class AllureLocalHistory {
|
|
49
|
-
constructor(
|
|
50
|
-
this.
|
|
49
|
+
constructor(params) {
|
|
50
|
+
this.params = params;
|
|
51
51
|
}
|
|
52
52
|
async readHistory() {
|
|
53
|
-
const path = resolve(this.historyPath);
|
|
53
|
+
const path = resolve(this.params.historyPath);
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
const historyPoints = (await readFile(path, { encoding: "utf-8" }))
|
|
56
56
|
.split("\n")
|
|
57
57
|
.filter((line) => line && line.trim() !== "")
|
|
58
58
|
.map((line) => JSON.parse(line));
|
|
59
|
+
if (this.params.limit) {
|
|
60
|
+
return historyPoints.slice(-this.params.limit);
|
|
61
|
+
}
|
|
62
|
+
return historyPoints;
|
|
59
63
|
}
|
|
60
64
|
catch (e) {
|
|
61
65
|
if (isFileNotFoundError(e)) {
|
|
@@ -65,9 +69,16 @@ export class AllureLocalHistory {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
async appendHistory(data) {
|
|
68
|
-
const path = resolve(this.historyPath);
|
|
72
|
+
const path = resolve(this.params.historyPath);
|
|
69
73
|
const parentDir = dirname(path);
|
|
70
74
|
await mkdir(parentDir, { recursive: true });
|
|
71
|
-
|
|
75
|
+
if (!this.params.limit) {
|
|
76
|
+
await writeFile(path, `${JSON.stringify(data)}\n`, { encoding: "utf-8", flag: "a+" });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const existingHistory = await this.readHistory();
|
|
80
|
+
const updatedHistory = [...existingHistory, data].slice(-this.params.limit);
|
|
81
|
+
const fileContent = updatedHistory.reduce((acc, point) => `${acc}${JSON.stringify(point)}\n`, "");
|
|
82
|
+
await writeFile(path, fileContent, "utf-8");
|
|
72
83
|
}
|
|
73
84
|
}
|
package/dist/report.js
CHANGED
|
@@ -95,7 +95,7 @@ export class AllureReport {
|
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
catch
|
|
98
|
+
catch { }
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
this.validate = async (params) => {
|
|
@@ -412,14 +412,15 @@ export class AllureReport {
|
|
|
412
412
|
try {
|
|
413
413
|
outputDirFiles = await readdir(__classPrivateFieldGet(this, _AllureReport_output, "f"));
|
|
414
414
|
}
|
|
415
|
-
catch
|
|
415
|
+
catch { }
|
|
416
416
|
if (outputDirFiles.length === 0) {
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
419
|
const reportPath = join(__classPrivateFieldGet(this, _AllureReport_output, "f"), outputDirFiles[0]);
|
|
420
|
+
const reportStats = await lstat(reportPath);
|
|
420
421
|
const outputEntriesStats = await Promise.all(outputDirFiles.map((file) => lstat(join(__classPrivateFieldGet(this, _AllureReport_output, "f"), file))));
|
|
421
422
|
const outputDirectoryEntries = outputEntriesStats.filter((entry) => entry.isDirectory());
|
|
422
|
-
if (outputDirectoryEntries.length === 1) {
|
|
423
|
+
if (reportStats.isDirectory() && outputDirectoryEntries.length === 1) {
|
|
423
424
|
const reportContent = await readdir(reportPath);
|
|
424
425
|
for (const entry of reportContent) {
|
|
425
426
|
const currentFilePath = join(reportPath, entry);
|
|
@@ -432,7 +433,7 @@ export class AllureReport {
|
|
|
432
433
|
try {
|
|
433
434
|
await rm(dir, { recursive: true });
|
|
434
435
|
}
|
|
435
|
-
catch
|
|
436
|
+
catch { }
|
|
436
437
|
}
|
|
437
438
|
if (__classPrivateFieldGet(this, _AllureReport_history, "f")) {
|
|
438
439
|
try {
|
|
@@ -495,6 +496,7 @@ export class AllureReport {
|
|
|
495
496
|
state: pluginState,
|
|
496
497
|
reportFiles: pluginFiles,
|
|
497
498
|
reportUrl: this.reportUrl,
|
|
499
|
+
output: __classPrivateFieldGet(this, _AllureReport_output, "f"),
|
|
498
500
|
ci: __classPrivateFieldGet(this, _AllureReport_ci, "f"),
|
|
499
501
|
};
|
|
500
502
|
try {
|
|
@@ -508,8 +510,10 @@ export class AllureReport {
|
|
|
508
510
|
}
|
|
509
511
|
}
|
|
510
512
|
});
|
|
511
|
-
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, defaultLabels = {}, variables = {}, environment, environments, output, qualityGate, stage, allureService: allureServiceConfig, } = opts;
|
|
512
|
-
__classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceConfig?.
|
|
513
|
+
const { name, readers = [allure1, allure2, cucumberjson, junitXml, attachments], plugins = [], known, reportFiles, realTime, historyPath, historyLimit, defaultLabels = {}, variables = {}, environment, environments, output, qualityGate, stage, allureService: allureServiceConfig, } = opts;
|
|
514
|
+
__classPrivateFieldSet(this, _AllureReport_allureServiceClient, allureServiceConfig?.accessToken
|
|
515
|
+
? new AllureServiceClient(allureServiceConfig)
|
|
516
|
+
: undefined, "f");
|
|
513
517
|
this.reportUuid = randomUUID();
|
|
514
518
|
__classPrivateFieldSet(this, _AllureReport_ci, detect(), "f");
|
|
515
519
|
const reportTitleSuffix = __classPrivateFieldGet(this, _AllureReport_ci, "f")?.pullRequestName ?? __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunName;
|
|
@@ -520,14 +524,21 @@ export class AllureReport {
|
|
|
520
524
|
__classPrivateFieldSet(this, _AllureReport_realtimeSubscriber, new RealtimeSubscriber(__classPrivateFieldGet(this, _AllureReport_eventEmitter, "f")), "f");
|
|
521
525
|
__classPrivateFieldSet(this, _AllureReport_realTime, realTime, "f");
|
|
522
526
|
__classPrivateFieldSet(this, _AllureReport_stage, stage, "f");
|
|
527
|
+
if (qualityGate) {
|
|
528
|
+
__classPrivateFieldSet(this, _AllureReport_qualityGate, new QualityGate(qualityGate), "f");
|
|
529
|
+
}
|
|
523
530
|
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
|
|
524
|
-
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(
|
|
531
|
+
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory({
|
|
532
|
+
allureServiceClient: __classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"),
|
|
533
|
+
branch: __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch,
|
|
534
|
+
limit: historyLimit,
|
|
535
|
+
}), "f");
|
|
525
536
|
}
|
|
526
537
|
else if (historyPath) {
|
|
527
|
-
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
538
|
+
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory({
|
|
539
|
+
historyPath,
|
|
540
|
+
limit: historyLimit,
|
|
541
|
+
}), "f");
|
|
531
542
|
}
|
|
532
543
|
__classPrivateFieldSet(this, _AllureReport_store, new DefaultAllureStore({
|
|
533
544
|
realtimeSubscriber: __classPrivateFieldGet(this, _AllureReport_realtimeSubscriber, "f"),
|
|
@@ -543,12 +554,6 @@ export class AllureReport {
|
|
|
543
554
|
__classPrivateFieldSet(this, _AllureReport_plugins, [...plugins], "f");
|
|
544
555
|
__classPrivateFieldSet(this, _AllureReport_reportFiles, reportFiles, "f");
|
|
545
556
|
__classPrivateFieldSet(this, _AllureReport_output, output, "f");
|
|
546
|
-
if (__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f")) {
|
|
547
|
-
__classPrivateFieldSet(this, _AllureReport_history, new AllureRemoteHistory(__classPrivateFieldGet(this, _AllureReport_allureServiceClient, "f"), __classPrivateFieldGet(this, _AllureReport_ci, "f")?.jobRunBranch), "f");
|
|
548
|
-
}
|
|
549
|
-
else if (historyPath) {
|
|
550
|
-
__classPrivateFieldSet(this, _AllureReport_history, new AllureLocalHistory(historyPath), "f");
|
|
551
|
-
}
|
|
552
557
|
}
|
|
553
558
|
get hasQualityGate() {
|
|
554
559
|
return !!__classPrivateFieldGet(this, _AllureReport_qualityGate, "f");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Collection of generic Allure utilities used across the entire project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure"
|
|
@@ -25,23 +25,24 @@
|
|
|
25
25
|
"test": "vitest run"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@allurereport/ci": "3.
|
|
29
|
-
"@allurereport/core-api": "3.
|
|
30
|
-
"@allurereport/plugin-allure2": "3.
|
|
31
|
-
"@allurereport/plugin-api": "3.
|
|
32
|
-
"@allurereport/plugin-awesome": "3.
|
|
33
|
-
"@allurereport/plugin-classic": "3.
|
|
34
|
-
"@allurereport/plugin-csv": "3.
|
|
35
|
-
"@allurereport/plugin-dashboard": "3.
|
|
36
|
-
"@allurereport/plugin-jira": "3.
|
|
37
|
-
"@allurereport/plugin-log": "3.
|
|
38
|
-
"@allurereport/plugin-progress": "3.
|
|
39
|
-
"@allurereport/plugin-slack": "3.
|
|
40
|
-
"@allurereport/plugin-
|
|
41
|
-
"@allurereport/
|
|
42
|
-
"@allurereport/reader
|
|
43
|
-
"@allurereport/
|
|
44
|
-
"@allurereport/
|
|
28
|
+
"@allurereport/ci": "3.1.0",
|
|
29
|
+
"@allurereport/core-api": "3.1.0",
|
|
30
|
+
"@allurereport/plugin-allure2": "3.1.0",
|
|
31
|
+
"@allurereport/plugin-api": "3.1.0",
|
|
32
|
+
"@allurereport/plugin-awesome": "3.1.0",
|
|
33
|
+
"@allurereport/plugin-classic": "3.1.0",
|
|
34
|
+
"@allurereport/plugin-csv": "3.1.0",
|
|
35
|
+
"@allurereport/plugin-dashboard": "3.1.0",
|
|
36
|
+
"@allurereport/plugin-jira": "3.1.0",
|
|
37
|
+
"@allurereport/plugin-log": "3.1.0",
|
|
38
|
+
"@allurereport/plugin-progress": "3.1.0",
|
|
39
|
+
"@allurereport/plugin-slack": "3.1.0",
|
|
40
|
+
"@allurereport/plugin-testops": "3.1.0",
|
|
41
|
+
"@allurereport/plugin-testplan": "3.1.0",
|
|
42
|
+
"@allurereport/reader": "3.1.0",
|
|
43
|
+
"@allurereport/reader-api": "3.1.0",
|
|
44
|
+
"@allurereport/service": "3.1.0",
|
|
45
|
+
"@allurereport/summary": "3.1.0",
|
|
45
46
|
"handlebars": "^4.7.8",
|
|
46
47
|
"markdown-it": "^14.1.0",
|
|
47
48
|
"node-stream-zip": "^1.15.0",
|