@allurereport/plugin-dashboard 3.15.0 → 3.16.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.
@@ -2,7 +2,7 @@ import type { TestResult } from "@allurereport/core-api";
2
2
  import { type AllureStore, type PluginContext, type ReportFiles } from "@allurereport/plugin-api";
3
3
  import type { DashboardOptions, DashboardPluginOptions, TemplateManifest } from "./model.js";
4
4
  import type { DashboardDataWriter, ReportFile } from "./writer.js";
5
- export declare const readTemplateManifest: (singleFileMode?: boolean) => Promise<TemplateManifest>;
5
+ export declare const readTemplateManifest: (_singleFileMode?: boolean) => Promise<TemplateManifest>;
6
6
  export declare const generateAllCharts: (writer: DashboardDataWriter, store: AllureStore, options: DashboardPluginOptions, context: PluginContext, filter?: (testResult: TestResult) => boolean) => Promise<void>;
7
7
  export declare const generateEnvirontmentsList: (writer: DashboardDataWriter, store: AllureStore) => Promise<void>;
8
8
  export declare const generateStaticFiles: (payload: DashboardOptions & {
@@ -1,12 +1,10 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { readFile } from "node:fs/promises";
3
- import { createRequire } from "node:module";
4
- import { basename, join } from "node:path";
5
2
  import { defaultChartsConfig } from "@allurereport/charts-api";
6
3
  import { createBaseUrlScript, createFontLinkTag, createReportDataScript, stringifyForInlineScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
4
+ import { copyReportStaticAssets, getReportStaticAsset, readReportStaticAssets, } from "@allurereport/plugin-api/static-assets";
7
5
  import { generateCharts } from "@allurereport/web-commons";
8
6
  import Handlebars from "handlebars";
9
- const require = createRequire(import.meta.url);
7
+ const reportStaticArchive = new URL("../dist/static/report.tar", import.meta.url);
10
8
  const template = `<!DOCTYPE html>
11
9
  <html dir="ltr" lang="en">
12
10
  <head>
@@ -43,10 +41,9 @@ const template = `<!DOCTYPE html>
43
41
  </body>
44
42
  </html>
45
43
  `;
46
- export const readTemplateManifest = async (singleFileMode) => {
47
- const templateManifestSource = require.resolve(`@allurereport/web-dashboard/dist/${singleFileMode ? "single" : "multi"}/manifest.json`);
48
- const templateManifest = await readFile(templateManifestSource, { encoding: "utf-8" });
49
- return JSON.parse(templateManifest);
44
+ export const readTemplateManifest = async (_singleFileMode) => {
45
+ const { manifest } = await readReportStaticAssets(reportStaticArchive);
46
+ return manifest;
50
47
  };
51
48
  export const generateAllCharts = async (writer, store, options, context, filter) => {
52
49
  const { layout = defaultChartsConfig } = options;
@@ -60,15 +57,15 @@ export const generateEnvirontmentsList = async (writer, store) => {
60
57
  await writer.writeWidget("environments.json", environments);
61
58
  };
62
59
  export const generateStaticFiles = async (payload) => {
63
- const { reportName = "Allure Report", reportLanguage = "en", singleFile, logo = "", theme = "light", reportFiles, reportDataFiles, reportUuid, allureVersion, } = payload;
60
+ const { reportName = "Allure Report", reportLanguage = "en", logo = "", theme = "light", reportFiles, reportDataFiles, reportUuid, allureVersion, } = payload;
64
61
  const compile = Handlebars.compile(template);
65
- const manifest = await readTemplateManifest(payload.singleFile);
62
+ const staticAssets = await readReportStaticAssets(reportStaticArchive);
63
+ const { manifest } = staticAssets;
66
64
  const headTags = [];
67
65
  const bodyTags = [];
68
66
  if (!payload.singleFile) {
69
67
  for (const key in manifest) {
70
68
  const fileName = manifest[key];
71
- const filePath = require.resolve(join("@allurereport/web-dashboard/dist", singleFile ? "single" : "multi", fileName));
72
69
  if (key.includes(".woff")) {
73
70
  headTags.push(createFontLinkTag(fileName));
74
71
  }
@@ -78,17 +75,17 @@ export const generateStaticFiles = async (payload) => {
78
75
  if (key === "main.js") {
79
76
  bodyTags.push(createScriptTag(fileName));
80
77
  }
81
- if (singleFile) {
82
- continue;
83
- }
84
- const fileContent = await readFile(filePath);
85
- await reportFiles.addFile(basename(filePath), fileContent);
86
78
  }
79
+ await copyReportStaticAssets(staticAssets, reportFiles);
87
80
  }
88
81
  else {
89
82
  const mainJs = manifest["main.js"];
90
- const mainJsSource = require.resolve(`@allurereport/web-dashboard/dist/single/${mainJs}`);
91
- const mainJsContentBuffer = await readFile(mainJsSource);
83
+ const mainCss = manifest["main.css"];
84
+ if (mainCss) {
85
+ const mainCssContent = getReportStaticAsset(staticAssets, mainCss);
86
+ headTags.push(createStylesLinkTag(`data:text/css;base64,${mainCssContent.toString("base64")}`));
87
+ }
88
+ const mainJsContentBuffer = getReportStaticAsset(staticAssets, mainJs);
92
89
  bodyTags.push(createScriptTag(`data:text/javascript;base64,${mainJsContentBuffer.toString("base64")}`));
93
90
  }
94
91
  const reportOptions = {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-dashboard",
3
- "version": "3.15.0",
3
+ "version": "3.16.1",
4
4
  "description": "Allure Dashboard Plugin – plugin for generating dashboard with a mix of charts",
5
5
  "keywords": [
6
6
  "allure",
@@ -25,22 +25,22 @@
25
25
  ".": "./dist/index.js"
26
26
  },
27
27
  "scripts": {
28
- "build": "run clean && tsc --project ./tsconfig.json",
28
+ "build": "run clean && tsc --project ./tsconfig.json && node ../../scripts/pack-report-static.mjs ../web-dashboard/dist/multi ./dist/static/report.tar",
29
29
  "clean": "rimraf ./dist",
30
30
  "test": "rimraf ./out && vitest run",
31
31
  "lint": "oxlint --import-plugin src test features stories",
32
32
  "lint:fix": "oxlint --import-plugin --fix src test features stories"
33
33
  },
34
34
  "dependencies": {
35
- "@allurereport/charts-api": "3.15.0",
36
- "@allurereport/core-api": "3.15.0",
37
- "@allurereport/plugin-api": "3.15.0",
38
- "@allurereport/web-commons": "3.15.0",
39
- "@allurereport/web-dashboard": "3.15.0",
35
+ "@allurereport/charts-api": "3.16.1",
36
+ "@allurereport/core-api": "3.16.1",
37
+ "@allurereport/plugin-api": "3.16.1",
38
+ "@allurereport/web-commons": "3.16.1",
40
39
  "d3-shape": "^3.2.0",
41
40
  "handlebars": "^4.7.9"
42
41
  },
43
42
  "devDependencies": {
43
+ "@allurereport/web-dashboard": "3.16.1",
44
44
  "@types/d3-shape": "^3.1.8",
45
45
  "@types/node": "^20",
46
46
  "@vitest/runner": "^2",