@allurereport/plugin-dashboard 3.20.1 → 3.22.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.
@@ -1,8 +1,7 @@
1
1
  import type { TestResult } from "@allurereport/core-api";
2
2
  import { type AllureStore, type PluginContext, type ReportFiles } from "@allurereport/plugin-api";
3
- import type { DashboardOptions, DashboardPluginOptions, TemplateManifest } from "./model.js";
3
+ import type { DashboardOptions, DashboardPluginOptions } from "./model.js";
4
4
  import type { DashboardDataWriter, ReportFile } from "./writer.js";
5
- export declare const readTemplateManifest: (_singleFileMode?: boolean) => Promise<TemplateManifest>;
6
5
  export declare const generateAllCharts: (writer: DashboardDataWriter, store: AllureStore, options: DashboardPluginOptions, context: PluginContext, filter?: (testResult: TestResult) => boolean) => Promise<void>;
7
6
  export declare const generateEnvirontmentsList: (writer: DashboardDataWriter, store: AllureStore) => Promise<void>;
8
7
  export declare const generateStaticFiles: (payload: DashboardOptions & {
@@ -11,4 +10,5 @@ export declare const generateStaticFiles: (payload: DashboardOptions & {
11
10
  reportDataFiles: ReportFile[];
12
11
  reportUuid: string;
13
12
  reportName: string;
13
+ overviewHref?: string;
14
14
  }) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { defaultChartsConfig } from "@allurereport/charts-api";
3
- import { createBaseUrlScript, createFontLinkTag, createReportDataScript, stringifyForInlineScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
4
- import { copyReportStaticAssets, getReportStaticAsset, readReportStaticAssets, } from "@allurereport/plugin-api/static-assets";
3
+ import { createBaseUrlScript, createFontLinkTag, injectReportDataScript, reportDataScriptPlaceholder, stringifyForInlineScript, createScriptTag, createStylesLinkTag, } from "@allurereport/core-api";
4
+ import { createSingleFileScripts, copyReportStaticAssets, getReportStaticAsset, readReportStaticAssets, } from "@allurereport/plugin-api/static-assets";
5
5
  import { generateCharts } from "@allurereport/web-commons";
6
6
  import Handlebars from "handlebars";
7
7
  const reportStaticArchive = new URL("../dist/static/report.tar", import.meta.url);
@@ -41,10 +41,6 @@ const template = `<!DOCTYPE html>
41
41
  </body>
42
42
  </html>
43
43
  `;
44
- export const readTemplateManifest = async (_singleFileMode) => {
45
- const { manifest } = await readReportStaticAssets(reportStaticArchive);
46
- return manifest;
47
- };
48
44
  export const generateAllCharts = async (writer, store, options, context, filter) => {
49
45
  const { layout = defaultChartsConfig } = options;
50
46
  const generatedChartsData = await generateCharts(layout, store, context.reportName, randomUUID, filter);
@@ -57,7 +53,7 @@ export const generateEnvirontmentsList = async (writer, store) => {
57
53
  await writer.writeWidget("environments.json", environments);
58
54
  };
59
55
  export const generateStaticFiles = async (payload) => {
60
- const { reportName = "Allure Report", reportLanguage = "en", logo = "", theme = "light", reportFiles, reportDataFiles, reportUuid, allureVersion, } = payload;
56
+ const { reportName = "Allure Report", reportLanguage = "en", logo = "", theme = "light", reportFiles, reportDataFiles, reportUuid, allureVersion, overviewHref, } = payload;
61
57
  const compile = Handlebars.compile(template);
62
58
  const staticAssets = await readReportStaticAssets(reportStaticArchive);
63
59
  const { manifest } = staticAssets;
@@ -85,8 +81,7 @@ export const generateStaticFiles = async (payload) => {
85
81
  const mainCssContent = getReportStaticAsset(staticAssets, mainCss);
86
82
  headTags.push(createStylesLinkTag(`data:text/css;base64,${mainCssContent.toString("base64")}`));
87
83
  }
88
- const mainJsContentBuffer = getReportStaticAsset(staticAssets, mainJs);
89
- bodyTags.push(createScriptTag(`data:text/javascript;base64,${mainJsContentBuffer.toString("base64")}`));
84
+ bodyTags.push(createSingleFileScripts(staticAssets.files, mainJs, { compress: false }));
90
85
  }
91
86
  const reportOptions = {
92
87
  reportName,
@@ -96,12 +91,13 @@ export const generateStaticFiles = async (payload) => {
96
91
  createdAt: Date.now(),
97
92
  reportUuid,
98
93
  allureVersion,
94
+ overviewHref,
99
95
  };
100
96
  try {
101
97
  const html = compile({
102
98
  headTags: headTags.join("\n"),
103
99
  bodyTags: bodyTags.join("\n"),
104
- reportFilesScript: createReportDataScript(reportDataFiles),
100
+ reportFilesScript: reportDataScriptPlaceholder,
105
101
  reportOptions: stringifyForInlineScript(reportOptions),
106
102
  analyticsEnable: true,
107
103
  allureVersion,
@@ -109,7 +105,7 @@ export const generateStaticFiles = async (payload) => {
109
105
  reportName,
110
106
  singleFile: payload.singleFile,
111
107
  });
112
- await reportFiles.addFile("index.html", Buffer.from(html, "utf8"));
108
+ await reportFiles.addFile("index.html", injectReportDataScript(html, reportDataFiles));
113
109
  }
114
110
  catch (err) {
115
111
  if (err instanceof RangeError) {
package/dist/model.d.ts CHANGED
@@ -10,4 +10,3 @@ export type DashboardOptions = {
10
10
  filter?: (testResult: TestResult) => boolean;
11
11
  };
12
12
  export type DashboardPluginOptions = DashboardOptions;
13
- export type TemplateManifest = Record<string, string>;
package/dist/plugin.js CHANGED
@@ -11,6 +11,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
11
11
  };
12
12
  var _DashboardPlugin_writer, _DashboardPlugin_generateAfterStart, _DashboardPlugin_generate;
13
13
  import { createPluginSummary, } from "@allurereport/plugin-api";
14
+ import { validateChartsOptions } from "@allurereport/web-commons";
14
15
  import { generateAllCharts, generateEnvirontmentsList, generateStaticFiles } from "./generators.js";
15
16
  import { InMemoryDashboardDataWriter, ReportFileDashboardDataWriter } from "./writer.js";
16
17
  export class DashboardPlugin {
@@ -34,6 +35,7 @@ export class DashboardPlugin {
34
35
  reportDataFiles,
35
36
  reportUuid: context.reportUuid,
36
37
  reportName: context.reportName,
38
+ overviewHref: context.overviewHref,
37
39
  });
38
40
  });
39
41
  this.start = async (context) => {
@@ -50,6 +52,7 @@ export class DashboardPlugin {
50
52
  this.done = async (context, store) => {
51
53
  await __classPrivateFieldGet(this, _DashboardPlugin_generateAfterStart, "f").call(this, context, store);
52
54
  };
55
+ validateChartsOptions(options.layout ?? []);
53
56
  }
54
57
  async info(context, store) {
55
58
  return createPluginSummary({
Binary file
package/dist/writer.d.ts CHANGED
@@ -6,11 +6,6 @@ export type ReportFile = {
6
6
  export interface DashboardDataWriter {
7
7
  writeWidget<T>(fileName: string, data: T): Promise<void>;
8
8
  }
9
- export declare class FileSystemReportDataWriter implements DashboardDataWriter {
10
- private readonly output;
11
- constructor(output: string);
12
- writeWidget<T>(fileName: string, data: T): Promise<void>;
13
- }
14
9
  export declare class InMemoryDashboardDataWriter implements DashboardDataWriter {
15
10
  #private;
16
11
  writeWidget<T>(fileName: string, data: T): Promise<void>;
package/dist/writer.js CHANGED
@@ -4,19 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _InMemoryDashboardDataWriter_data;
7
- import { mkdir, writeFile } from "node:fs/promises";
8
- import { resolve } from "node:path";
9
7
  import { join as joinPosix } from "node:path/posix";
10
- export class FileSystemReportDataWriter {
11
- constructor(output) {
12
- this.output = output;
13
- }
14
- async writeWidget(fileName, data) {
15
- const distFolder = resolve(this.output, "widgets");
16
- await mkdir(distFolder, { recursive: true });
17
- await writeFile(resolve(distFolder, fileName), JSON.stringify(data), { encoding: "utf-8" });
18
- }
19
- }
20
8
  export class InMemoryDashboardDataWriter {
21
9
  constructor() {
22
10
  _InMemoryDashboardDataWriter_data.set(this, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-dashboard",
3
- "version": "3.20.1",
3
+ "version": "3.22.0",
4
4
  "description": "Allure Dashboard Plugin – plugin for generating dashboard with a mix of charts",
5
5
  "keywords": [
6
6
  "allure",
@@ -25,29 +25,34 @@
25
25
  ".": "./dist/index.js"
26
26
  },
27
27
  "scripts": {
28
- "build": "run clean && tsc --project ./tsconfig.json && node ../../scripts/pack-report-static.mjs ../web-dashboard/dist/multi ./dist/static/report.tar",
28
+ "build": "run clean && tsc --project ./tsconfig.json && node ../../scripts/pack-report-static.mjs ../web-dashboard/dist/multi ./dist/static/report.tar --allow-chunks",
29
29
  "clean": "rimraf ./dist",
30
- "test": "rimraf ./out && vitest run",
31
- "lint": "oxlint --import-plugin src test features stories",
32
- "lint:fix": "oxlint --import-plugin --fix src test features stories"
30
+ "test": "rimraf out && vp test run",
31
+ "test:unit": "yarn test",
32
+ "lint": "vp lint --import-plugin src test features stories",
33
+ "lint:fix": "vp lint --import-plugin --fix src test features stories"
33
34
  },
34
35
  "dependencies": {
35
- "@allurereport/charts-api": "3.20.1",
36
- "@allurereport/core-api": "3.20.1",
37
- "@allurereport/plugin-api": "3.20.1",
38
- "@allurereport/web-commons": "3.20.1",
36
+ "@allurereport/charts-api": "3.22.0",
37
+ "@allurereport/core-api": "3.22.0",
38
+ "@allurereport/plugin-api": "3.22.0",
39
+ "@allurereport/web-commons": "3.22.0",
39
40
  "d3-shape": "^3.2.0",
40
- "handlebars": "^4.7.9"
41
+ "handlebars": "4.7.10"
41
42
  },
42
43
  "devDependencies": {
43
- "@allurereport/web-dashboard": "3.20.1",
44
+ "@allurereport/common-config": "3.22.0",
45
+ "@allurereport/web-dashboard": "3.22.0",
44
46
  "@types/d3-shape": "^3.1.8",
45
47
  "@types/node": "^20",
48
+ "@vitest/coverage-istanbul": "5.0.4",
46
49
  "@vitest/runner": "^2",
47
50
  "allure-js-commons": "^3",
48
51
  "allure-vitest": "^3",
49
52
  "rimraf": "^6",
50
53
  "typescript": "^5",
51
- "vitest": "^4.1.0"
54
+ "vite": "@voidzero-dev/vite-plus-core@1.2.0",
55
+ "vite-plus": "1.2.0",
56
+ "vitest": "5.0.4"
52
57
  }
53
58
  }