@allurereport/summary 3.0.0-beta.11

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,57 @@
1
+ # Summary 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
+ The plugin generates brand new Allure Report with modern design and new features.
16
+
17
+ ## Install
18
+
19
+ Use your favorite package manager to install the package:
20
+
21
+ ```shell
22
+ npm add @allurereport/plugin-awesome
23
+ yarn add @allurereport/plugin-awesome
24
+ pnpm add @allurereport/plugin-awesome
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
+ + awesome: {
38
+ + options: {
39
+ + reportName: "HelloWorld",
40
+ + },
41
+ + },
42
+ },
43
+ });
44
+ ```
45
+
46
+ ## Options
47
+
48
+ The plugin accepts the following options:
49
+
50
+ | Option | Description | Type | Default |
51
+ |------------------|-------------------------------------------------|--------------------------------------------------------------|-----------------|
52
+ | `reportName` | Name of the report | `string` | `Allure Report` |
53
+ | `singleFile` | Writes the report as a single `index.html` file | `boolean` | `false` |
54
+ | `logo` | Path to the logo image | `string` | `null` |
55
+ | `theme` | Default color theme of the report | `light \| dark` | OS theme |
56
+ | `reportLanguage` | Default language of the report | `string` | OS language |
57
+ | `ci` | CI data which will be rendered in the report | `{ type: "github" \| "jenkins", url: string, name: string }` | `undefined` |
@@ -0,0 +1,6 @@
1
+ import type { PluginSummary } from "@allurereport/plugin-api";
2
+ export type TemplateManifest = Record<string, string>;
3
+ export declare const readTemplateManifest: () => Promise<TemplateManifest>;
4
+ export declare const generateSummaryStaticFiles: (payload: {
5
+ summaries: PluginSummary[];
6
+ }) => Promise<string>;
@@ -0,0 +1,45 @@
1
+ import { createBaseUrlScript, createScriptTag } from "@allurereport/web-commons";
2
+ import Handlebars from "handlebars";
3
+ import { readFile } from "node:fs/promises";
4
+ import { createRequire } from "node:module";
5
+ const require = createRequire(import.meta.url);
6
+ const template = `<!DOCTYPE html>
7
+ <html dir="ltr" lang="en">
8
+ <head>
9
+ <meta charset="utf-8">
10
+ <title> {{ reportName }} </title>
11
+ <link rel="icon" href="favicon.ico">
12
+ </head>
13
+ <body>
14
+ <div id="app"></div>
15
+ ${createBaseUrlScript()}
16
+ <script>
17
+ window.allure = window.allure || {};
18
+ </script>
19
+ {{{ bodyTags }}}
20
+ <script>
21
+ window.reportSummaries = {{{ reportSummaries }}}
22
+ </script>
23
+ {{{ reportFilesScript }}}
24
+ </body>
25
+ </html>
26
+ `;
27
+ export const readTemplateManifest = async () => {
28
+ const templateManifestSource = require.resolve("@allurereport/web-summary/dist/manifest.json");
29
+ const templateManifest = await readFile(templateManifestSource, { encoding: "utf-8" });
30
+ return JSON.parse(templateManifest);
31
+ };
32
+ export const generateSummaryStaticFiles = async (payload) => {
33
+ const compile = Handlebars.compile(template);
34
+ const manifest = await readTemplateManifest();
35
+ const bodyTags = [];
36
+ const mainJs = manifest["main.js"];
37
+ const mainJsSource = require.resolve(`@allurereport/web-summary/dist/${mainJs}`);
38
+ const mainJsContentBuffer = await readFile(mainJsSource);
39
+ bodyTags.push(createScriptTag(`data:text/javascript;base64,${mainJsContentBuffer.toString("base64")}`));
40
+ return compile({
41
+ bodyTags: bodyTags.join("\n"),
42
+ analyticsEnable: true,
43
+ reportSummaries: JSON.stringify(payload.summaries),
44
+ });
45
+ };
@@ -0,0 +1,3 @@
1
+ import type { PluginSummary } from "@allurereport/plugin-api";
2
+ export declare const generateSummary: (output: string, summaries: PluginSummary[]) => Promise<void>;
3
+ export default generateSummary;
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { generateSummaryStaticFiles } from "./generators.js";
4
+ export const generateSummary = async (output, summaries) => {
5
+ if (!summaries.length) {
6
+ return;
7
+ }
8
+ const summaryHtml = await generateSummaryStaticFiles({ summaries });
9
+ await writeFile(resolve(output, "index.html"), summaryHtml, "utf8");
10
+ };
11
+ export default generateSummary;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@allurereport/summary",
3
+ "version": "3.0.0-beta.11",
4
+ "description": "Allure Summary Plugin – dashboard page generator with charts for Allure Report",
5
+ "keywords": [
6
+ "allure",
7
+ "testing",
8
+ "report",
9
+ "plugin",
10
+ "html"
11
+ ],
12
+ "repository": "https://github.com/allure-framework/allure3",
13
+ "license": "Apache-2.0",
14
+ "author": "Qameta Software",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": "./dist/index.js"
18
+ },
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "./dist"
24
+ ],
25
+ "scripts": {
26
+ "build": "run clean && tsc --project ./tsconfig.json",
27
+ "clean": "rimraf ./dist",
28
+ "eslint": "eslint ./src/**/*.{js,jsx,ts,tsx}",
29
+ "eslint:format": "eslint --fix ./src/**/*.{js,jsx,ts,tsx}",
30
+ "test": "rimraf ./out && vitest run"
31
+ },
32
+ "dependencies": {
33
+ "@allurereport/plugin-api": "3.0.0-beta.11",
34
+ "@allurereport/web-commons": "3.0.0-beta.11",
35
+ "@allurereport/web-summary": "3.0.0-beta.11",
36
+ "handlebars": "^4.7.8"
37
+ },
38
+ "devDependencies": {
39
+ "@stylistic/eslint-plugin": "^2.6.1",
40
+ "@types/eslint": "^8.56.11",
41
+ "@types/handlebars": "^4.1.0",
42
+ "@types/node": "^20.17.9",
43
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
44
+ "@typescript-eslint/parser": "^8.0.0",
45
+ "@vitest/runner": "^2.1.8",
46
+ "allure-vitest": "^3.0.9",
47
+ "eslint": "^8.57.0",
48
+ "eslint-config-prettier": "^9.1.0",
49
+ "eslint-plugin-import": "^2.29.1",
50
+ "eslint-plugin-jsdoc": "^50.0.0",
51
+ "eslint-plugin-n": "^17.10.1",
52
+ "eslint-plugin-no-null": "^1.0.2",
53
+ "eslint-plugin-prefer-arrow": "^1.2.3",
54
+ "rimraf": "^6.0.1",
55
+ "typescript": "^5.6.3",
56
+ "vitest": "^2.1.8"
57
+ }
58
+ }