@allurereport/plugin-progress 3.0.0-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.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Progress Plugin
2
+
3
+ [<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")
4
+
5
+ - Learn more about Allure Report at https://allurereport.org
6
+ - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
7
+ - ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
8
+ - 📢 [Official announcements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
9
+ - 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ This plugin indicates the report generation progress in the terminal.
16
+
17
+ ## Install
18
+
19
+ Use your favorite package manager to install the package:
20
+
21
+ ```shell
22
+ npm add @allurereport/plugin-progress
23
+ yarn add @allurereport/plugin-progress
24
+ pnpm add @allurereport/plugin-progress
25
+ ```
26
+
27
+ Then, add the plugin to the Allure configuration file:
28
+
29
+ ```diff
30
+ import { defineConfig } from "allure";
31
+
32
+ export default defineConfig({
33
+ name: "Allure Report",
34
+ output: "./allure-report",
35
+ historyPath: "./history.jsonl",
36
+ plugins: {
37
+ + progress: {
38
+ + options: {
39
+ + },
40
+ + },
41
+ },
42
+ });
43
+ ```
@@ -0,0 +1,2 @@
1
+ import { ProgressPlugin } from "./plugin.js";
2
+ export default ProgressPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { ProgressPlugin } from "./plugin.js";
2
+ export default ProgressPlugin;
@@ -0,0 +1,12 @@
1
+ import type { AllureStore, Plugin, PluginContext, Realtime } from "@allurereport/plugin-api";
2
+ import type { WriteStream } from "node:tty";
3
+ export declare class ProgressPlugin implements Plugin {
4
+ #private;
5
+ readonly options: {
6
+ stream?: WriteStream;
7
+ };
8
+ constructor(options?: {
9
+ stream?: WriteStream;
10
+ });
11
+ start: (context: PluginContext, store: AllureStore, realtime: Realtime) => Promise<void>;
12
+ }
package/dist/plugin.js ADDED
@@ -0,0 +1,53 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ProgressPlugin_terminal, _ProgressPlugin_render;
13
+ import * as process from "node:process";
14
+ import { green, red, yellow } from "yoctocolors";
15
+ import { Terminal } from "./terminal.js";
16
+ export class ProgressPlugin {
17
+ constructor(options = {}) {
18
+ this.options = options;
19
+ _ProgressPlugin_terminal.set(this, void 0);
20
+ this.start = async (context, store, realtime) => {
21
+ realtime.onTestResults(async (trIds) => {
22
+ await __classPrivateFieldGet(this, _ProgressPlugin_render, "f").call(this, store);
23
+ });
24
+ };
25
+ _ProgressPlugin_render.set(this, async (store) => {
26
+ if (!__classPrivateFieldGet(this, _ProgressPlugin_terminal, "f")) {
27
+ return;
28
+ }
29
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").cursorRelativeReset();
30
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").clearLine();
31
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").clearBottom();
32
+ const testsStatistic = await store.testsStatistic();
33
+ if (testsStatistic.failed) {
34
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${red("failed")}: ${testsStatistic.failed}`);
35
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
36
+ }
37
+ if (testsStatistic.broken) {
38
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${yellow("broken")}: ${testsStatistic.broken}`);
39
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
40
+ }
41
+ if (testsStatistic.passed) {
42
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`${green("passed")}: ${testsStatistic.passed}`);
43
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").newline();
44
+ }
45
+ __classPrivateFieldGet(this, _ProgressPlugin_terminal, "f").write(`total: ${testsStatistic.total}`);
46
+ });
47
+ const { stream = process.stdout } = this.options;
48
+ if (stream) {
49
+ __classPrivateFieldSet(this, _ProgressPlugin_terminal, new Terminal(stream), "f");
50
+ }
51
+ }
52
+ }
53
+ _ProgressPlugin_terminal = new WeakMap(), _ProgressPlugin_render = new WeakMap();
@@ -0,0 +1,19 @@
1
+ import type { WriteStream } from "node:tty";
2
+ export declare class Terminal {
3
+ #private;
4
+ constructor(outputStream: WriteStream);
5
+ cursorSave(): void;
6
+ cursorRestore(): void;
7
+ cursor(enabled: boolean): void;
8
+ cursorTo(x: number, y?: number): void;
9
+ cursorRelative(dx: number, dy: number): void;
10
+ cursorRelativeReset(): void;
11
+ clearRight(): void;
12
+ clearLine(): void;
13
+ clearBottom(): void;
14
+ newline(): void;
15
+ write(s: string, rawWrite?: boolean): void;
16
+ lineWrapping(enabled: boolean): void;
17
+ isTTY(): boolean;
18
+ getWidth(): number;
19
+ }
@@ -0,0 +1,117 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Terminal_stream, _Terminal_wrapLines, _Terminal_dy;
13
+ import { clearLine, clearScreenDown, cursorTo, moveCursor } from "node:readline";
14
+ export class Terminal {
15
+ constructor(outputStream) {
16
+ _Terminal_stream.set(this, void 0);
17
+ _Terminal_wrapLines.set(this, void 0);
18
+ _Terminal_dy.set(this, void 0);
19
+ __classPrivateFieldSet(this, _Terminal_stream, outputStream, "f");
20
+ __classPrivateFieldSet(this, _Terminal_wrapLines, true, "f");
21
+ __classPrivateFieldSet(this, _Terminal_dy, 0, "f");
22
+ }
23
+ cursorSave() {
24
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
25
+ return;
26
+ }
27
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B7");
28
+ }
29
+ cursorRestore() {
30
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
31
+ return;
32
+ }
33
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B8");
34
+ }
35
+ cursor(enabled) {
36
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
37
+ return;
38
+ }
39
+ if (enabled) {
40
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B[?25h");
41
+ }
42
+ else {
43
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B[?25l");
44
+ }
45
+ }
46
+ cursorTo(x, y) {
47
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
48
+ return;
49
+ }
50
+ cursorTo(__classPrivateFieldGet(this, _Terminal_stream, "f"), x, y);
51
+ }
52
+ cursorRelative(dx, dy) {
53
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
54
+ return;
55
+ }
56
+ __classPrivateFieldSet(this, _Terminal_dy, __classPrivateFieldGet(this, _Terminal_dy, "f") + dy, "f");
57
+ moveCursor(__classPrivateFieldGet(this, _Terminal_stream, "f"), dx, dy);
58
+ }
59
+ cursorRelativeReset() {
60
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
61
+ return;
62
+ }
63
+ moveCursor(__classPrivateFieldGet(this, _Terminal_stream, "f"), 0, -__classPrivateFieldGet(this, _Terminal_dy, "f"));
64
+ cursorTo(__classPrivateFieldGet(this, _Terminal_stream, "f"), 0);
65
+ __classPrivateFieldSet(this, _Terminal_dy, 0, "f");
66
+ }
67
+ clearRight() {
68
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
69
+ return;
70
+ }
71
+ clearLine(__classPrivateFieldGet(this, _Terminal_stream, "f"), 1);
72
+ }
73
+ clearLine() {
74
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
75
+ return;
76
+ }
77
+ clearLine(__classPrivateFieldGet(this, _Terminal_stream, "f"), 0);
78
+ }
79
+ clearBottom() {
80
+ if (!__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY) {
81
+ return;
82
+ }
83
+ clearScreenDown(__classPrivateFieldGet(this, _Terminal_stream, "f"));
84
+ }
85
+ newline() {
86
+ var _a;
87
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\n");
88
+ __classPrivateFieldSet(this, _Terminal_dy, (_a = __classPrivateFieldGet(this, _Terminal_dy, "f"), _a++, _a), "f");
89
+ }
90
+ write(s, rawWrite = false) {
91
+ if (__classPrivateFieldGet(this, _Terminal_wrapLines, "f") && !rawWrite) {
92
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write(s.slice(0, this.getWidth()));
93
+ }
94
+ else {
95
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write(s);
96
+ }
97
+ }
98
+ lineWrapping(enabled) {
99
+ if (!this.isTTY()) {
100
+ return;
101
+ }
102
+ __classPrivateFieldSet(this, _Terminal_wrapLines, enabled, "f");
103
+ if (enabled) {
104
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B[?7h");
105
+ }
106
+ else {
107
+ __classPrivateFieldGet(this, _Terminal_stream, "f").write("\x1B[?7l");
108
+ }
109
+ }
110
+ isTTY() {
111
+ return __classPrivateFieldGet(this, _Terminal_stream, "f").isTTY;
112
+ }
113
+ getWidth() {
114
+ return __classPrivateFieldGet(this, _Terminal_stream, "f").columns || (__classPrivateFieldGet(this, _Terminal_stream, "f").isTTY ? 80 : 200);
115
+ }
116
+ }
117
+ _Terminal_stream = new WeakMap(), _Terminal_wrapLines = new WeakMap(), _Terminal_dy = new WeakMap();
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@allurereport/plugin-progress",
3
+ "version": "3.0.0-beta.3",
4
+ "description": "Allure Plugin to show generation progress in console",
5
+ "keywords": [
6
+ "allure",
7
+ "testing",
8
+ "report",
9
+ "plugin",
10
+ "cli",
11
+ "stdout"
12
+ ],
13
+ "repository": "https://github.com/allure-framework/allure3",
14
+ "license": "Apache-2.0",
15
+ "author": "Qameta Software",
16
+ "type": "module",
17
+ "exports": {
18
+ ".": "./dist/index.js"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "./dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "run clean && tsc --project ./tsconfig.json",
28
+ "clean": "rimraf ./dist",
29
+ "test": "rimraf ./out && vitest run"
30
+ },
31
+ "dependencies": {
32
+ "@allurereport/core-api": "3.0.0-beta.3",
33
+ "@allurereport/plugin-api": "3.0.0-beta.3",
34
+ "yoctocolors": "^2.1.1"
35
+ },
36
+ "devDependencies": {
37
+ "@stylistic/eslint-plugin": "^2.6.1",
38
+ "@types/eslint": "^8.56.11",
39
+ "@types/node": "^20.17.9",
40
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
41
+ "@typescript-eslint/parser": "^8.0.0",
42
+ "@vitest/runner": "^2.1.8",
43
+ "@vitest/snapshot": "^2.1.8",
44
+ "allure-vitest": "^3.0.7",
45
+ "eslint": "^8.57.0",
46
+ "eslint-config-prettier": "^9.1.0",
47
+ "eslint-plugin-import": "^2.29.1",
48
+ "eslint-plugin-jsdoc": "^50.0.0",
49
+ "eslint-plugin-n": "^17.10.1",
50
+ "eslint-plugin-no-null": "^1.0.2",
51
+ "eslint-plugin-prefer-arrow": "^1.2.3",
52
+ "rimraf": "^6.0.1",
53
+ "typescript": "^5.6.3",
54
+ "vitest": "^2.1.8"
55
+ }
56
+ }