@allurereport/plugin-dashboard
Version:
Allure Dashboard Plugin – plugin for generating dashboard with a mix of charts
70 lines (69 loc) • 3.9 kB
JavaScript
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
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");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _DashboardPlugin_writer, _DashboardPlugin_generate;
import { createPluginSummary, } from "@allurereport/plugin-api";
import { generateAllCharts, generateEnvirontmentsList, generateStaticFiles } from "./generators.js";
import { InMemoryDashboardDataWriter, ReportFileDashboardDataWriter } from "./writer.js";
export class DashboardPlugin {
constructor(options = {}) {
this.options = options;
_DashboardPlugin_writer.set(this, void 0);
_DashboardPlugin_generate.set(this, async (context, store) => {
await generateAllCharts(__classPrivateFieldGet(this, _DashboardPlugin_writer, "f"), store, this.options, context, this.options.filter);
await generateEnvirontmentsList(__classPrivateFieldGet(this, _DashboardPlugin_writer, "f"), store);
const reportDataFiles = this.options.singleFile ? __classPrivateFieldGet(this, _DashboardPlugin_writer, "f").reportFiles() : [];
await generateStaticFiles({
...this.options,
allureVersion: context.allureVersion,
reportFiles: context.reportFiles,
reportDataFiles,
reportUuid: context.reportUuid,
reportName: context.reportName,
});
});
this.start = async (context) => {
if (this.options.singleFile) {
__classPrivateFieldSet(this, _DashboardPlugin_writer, new InMemoryDashboardDataWriter(), "f");
}
else {
__classPrivateFieldSet(this, _DashboardPlugin_writer, new ReportFileDashboardDataWriter(context.reportFiles), "f");
}
};
this.update = async (context, store) => {
if (!__classPrivateFieldGet(this, _DashboardPlugin_writer, "f")) {
throw new Error("call start first");
}
await __classPrivateFieldGet(this, _DashboardPlugin_generate, "f").call(this, context, store);
};
this.done = async (context, store) => {
if (!__classPrivateFieldGet(this, _DashboardPlugin_writer, "f")) {
throw new Error("call start first");
}
await __classPrivateFieldGet(this, _DashboardPlugin_generate, "f").call(this, context, store);
};
}
async info(context, store) {
return createPluginSummary({
name: this.options.reportName || context.reportName,
plugin: "Dashboard",
meta: {
reportId: context.reportUuid,
singleFile: this.options.singleFile ?? false,
},
filter: this.options.filter,
history: context.history,
ci: context.ci,
store,
});
}
}
_DashboardPlugin_writer = new WeakMap(), _DashboardPlugin_generate = new WeakMap();