@systemfsoftware/stryker-js-html-reporter 2.0.0 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @systemfsoftware/stryker-js-html-reporter
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @systemfsoftware/effect-cell-types@7.0.0
9
+
10
+ ## 3.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - Reporter plugins are now pull-stream consumers: a reporter exports a factory
15
+ that returns an async consumer of the four run events, instead of registering
16
+ an Effect layer that provides the `Reporter` capability service.
17
+
18
+ - Removed: `ReporterService`, `broadcastReporter`, `NamedReporter`, the
19
+ `Reporter` service class, and the legacy event payload types.
20
+ - The event protocol ships as a Standard Schema object; validate and infer it
21
+ with `import { ReporterEventSchema, type ReporterFactory, type ReporterInit }
22
+ from '@systemfsoftware/stryker-js/ReporterEvent'`.
23
+ - Event payloads are narrowed: the dry-run event no longer carries the coverage
24
+ map; the plan event carries reduced mutant descriptors instead of full run
25
+ options; `mutantTested` drops `killedBy`, `coveredBy`, `static`,
26
+ `testsCompleted` and `statusReason`, and renames `mutatorName` to `mutator`.
27
+ - `ReporterFailed.event` now names the event kind being processed instead of a
28
+ lifecycle method name; `'wrapUp'` no longer occurs.
29
+ - An unknown reporter name now fails the run at startup instead of being
30
+ silently ignored. A reporter that fails on the terminal report now fails the
31
+ run; a reporter that fails earlier is logged and detached with the exit code
32
+ unchanged.
33
+ - `@systemfsoftware/stryker-js-engine/builtin-reporters` no longer exports
34
+ `strykerPlugins`; call `makeBuiltinReporterFactories({ fileSystem, path })`.
35
+ - The built-in json and clear-text reporters write their notices directly to
36
+ stdout and stderr instead of the Effect logger, and the html reporter no
37
+ longer depends on `@effect/platform-node`.
38
+
39
+ ### Patch Changes
40
+
41
+ - Re-released against @systemfsoftware/stryker-js without the removed --llms manifest. The Run stream no longer carries a manifest terminal event, and the RunEvent / RunTerminalEvent unions no longer include the manifest arm, so any exhaustive consumer of those types must drop that case.
42
+
43
+ - Updated dependencies:
44
+ - @systemfsoftware/stryker-js@3.0.0
45
+
3
46
  ## 2.0.0
4
47
 
5
48
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -1,17 +1,10 @@
1
- import { ReporterService } from "@systemfsoftware/stryker-js/Reporter";
2
- import * as FileSystem from "effect/FileSystem";
3
- import * as Path from "effect/Path";
4
- import { Wire } from "@systemfsoftware/effect-cell-types";
5
1
  import "effect/Schema";
6
- import { ProvidedStrykerOptions } from "@systemfsoftware/stryker-js/provided-options";
2
+ import { ReporterFactory } from "@systemfsoftware/stryker-js/ReporterEvent";
7
3
  //#region src/Reporter.d.ts
8
- declare const makeHtmlReporter: (params: {
9
- readonly options?: ProvidedStrykerOptions;
10
- readonly fs: FileSystem.FileSystem;
11
- readonly path: Path.Path;
12
- }) => ReporterService;
4
+ declare const makeHtmlReporter: ReporterFactory;
13
5
  //#endregion
14
6
  //#region src/index.d.ts
15
- declare const strykerPlugins: import("@systemfsoftware/stryker-js/Plugin").PluginContribution<"Reporter">[];
7
+ declare const htmlReporterFactory: ReporterFactory;
8
+ declare const strykerPlugins: import("@systemfsoftware/stryker-js/Plugin").PluginReporterContribution[];
16
9
  //#endregion
17
- export { makeHtmlReporter, strykerPlugins };
10
+ export { htmlReporterFactory, makeHtmlReporter, strykerPlugins };
package/dist/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
- import { RunConfiguration, declarePlugin } from "@systemfsoftware/stryker-js/Plugin";
2
- import { Reporter, ReporterFailed } from "@systemfsoftware/stryker-js/Reporter";
1
+ import { declarePlugin } from "@systemfsoftware/stryker-js/Plugin";
2
+ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
3
+ import * as NodePath from "@effect/platform-node-shared/NodePath";
4
+ import { MutationTestReportReady } from "@systemfsoftware/stryker-js/Reporter";
3
5
  import * as Effect from "effect/Effect";
4
6
  import * as FileSystem from "effect/FileSystem";
5
7
  import * as Layer from "effect/Layer";
6
8
  import * as Path from "effect/Path";
7
- import { writeOutputFile } from "@systemfsoftware/stryker-js/output-file";
8
- import * as Cause from "effect/Cause";
9
- import { Wire } from "@systemfsoftware/effect-cell-types";
10
9
  import * as S from "effect/Schema";
11
10
  //#region src/Reporter.schema.ts
12
- const MutationTestResultSchema = Wire.mint(S.Unknown);
11
+ const MutationTestResultSchema = S.Unknown;
13
12
  var HtmlReportCommand = class extends S.TaggedClass()("HtmlReportCommand", {
14
13
  report: MutationTestResultSchema,
15
14
  scriptContent: S.String
@@ -49,46 +48,45 @@ function buildReportHtml(report, scriptContent) {
49
48
  </html>`;
50
49
  }
51
50
  const buildHtmlDocument = (command) => HtmlDocument.make({ html: buildReportHtml(command.report, command.scriptContent) });
52
- const makeHtmlReporter = (params) => {
53
- const options = params.options;
54
- return {
55
- onDryRunCompleted: (_event) => Effect.void,
56
- onMutationTestingPlanReady: (_event) => Effect.void,
57
- onMutantTested: (_result) => Effect.void,
58
- onMutationTestReportReady: (report, metrics) => Effect.gen(function* () {
59
- const path = yield* Path.Path;
60
- const fs = yield* FileSystem.FileSystem;
61
- const scriptPath = yield* path.fromFileUrl(new URL(import.meta.resolve("mutation-testing-elements/dist/mutation-test-elements.js")));
62
- const scriptContent = yield* fs.readFileString(scriptPath);
63
- const html = buildHtmlDocument(HtmlReportCommand.make({
64
- report,
65
- scriptContent
66
- })).html;
67
- if (options === void 0) return;
68
- const fileName = options.htmlReporter.fileName;
69
- yield* Effect.logDebug(`Using file "${fileName}"`);
70
- yield* writeOutputFile(fs, path, fileName, html);
71
- const fileUrl = yield* path.toFileUrl(path.resolve(fileName));
72
- yield* Effect.logInfo(`Your report can be found at: ${fileUrl.href}`);
73
- }).pipe(Effect.provideService(FileSystem.FileSystem, params.fs), Effect.provideService(Path.Path, params.path), Effect.catchCause((cause) => Effect.fail(new ReporterFailed({
74
- reporterName: "html",
75
- event: "onMutationTestReportReady",
76
- cause: Cause.pretty(cause)
77
- })))),
78
- wrapUp: Effect.void
51
+ const BUNDLE_SPECIFIER = "mutation-testing-elements/dist/mutation-test-elements.js";
52
+ const nodeFsPathLayer = Layer.mergeAll(NodeFileSystem.layer, NodePath.layer);
53
+ const readBundleContent = Effect.gen(function* () {
54
+ const fs = yield* FileSystem.FileSystem;
55
+ const bundlePath = yield* (yield* Path.Path).fromFileUrl(new URL(import.meta.resolve(BUNDLE_SPECIFIER)));
56
+ return yield* fs.readFileString(bundlePath);
57
+ });
58
+ const writeHtmlFile = (fileName, html) => Effect.gen(function* () {
59
+ const fs = yield* FileSystem.FileSystem;
60
+ const path = yield* Path.Path;
61
+ yield* fs.makeDirectory(path.dirname(fileName), { recursive: true });
62
+ yield* fs.writeFileString(fileName, html);
63
+ });
64
+ const bundleLoader = () => {
65
+ let cached;
66
+ return async () => {
67
+ cached ??= await Effect.runPromise(Effect.provide(readBundleContent, nodeFsPathLayer));
68
+ return cached;
79
69
  };
80
70
  };
71
+ const writeReportHtml = async (fileName, event, loadBundle) => {
72
+ const html = buildHtmlDocument(HtmlReportCommand.make({
73
+ report: event.report,
74
+ scriptContent: await loadBundle()
75
+ })).html;
76
+ await Effect.runPromise(Effect.provide(writeHtmlFile(fileName, html), nodeFsPathLayer));
77
+ };
78
+ const writeReportHtmlIfReady = async (fileName, event, loadBundle) => {
79
+ if (!S.is(MutationTestReportReady)(event)) return;
80
+ await writeReportHtml(fileName, event, loadBundle);
81
+ };
82
+ const makeHtmlReporter = (options, _init) => async (events) => {
83
+ const fileName = options.htmlReporter.fileName;
84
+ const loadBundle = bundleLoader();
85
+ for await (const event of events) await writeReportHtmlIfReady(fileName, event, loadBundle);
86
+ };
81
87
  //#endregion
82
88
  //#region src/index.ts
83
- const strykerPlugins = [declarePlugin("Reporter", "html", Layer.effect(Reporter, Effect.gen(function* () {
84
- const options = yield* RunConfiguration;
85
- const fs = yield* FileSystem.FileSystem;
86
- const path = yield* Path.Path;
87
- return makeHtmlReporter({
88
- options,
89
- fs,
90
- path
91
- });
92
- })))];
89
+ const htmlReporterFactory = makeHtmlReporter;
90
+ const strykerPlugins = [declarePlugin("Reporter", "html", htmlReporterFactory)];
93
91
  //#endregion
94
- export { makeHtmlReporter, strykerPlugins };
92
+ export { htmlReporterFactory, makeHtmlReporter, strykerPlugins };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@systemfsoftware/stryker-js-html-reporter",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/systemfsoftware/systemfsoftware.git",
@@ -14,26 +14,25 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
+ "@effect/platform-node-shared": "4.0.0-rc.112",
17
18
  "mutation-testing-elements": "3.7.3",
18
- "mutation-testing-metrics": "3.7.3",
19
- "mutation-testing-report-schema": "3.7.3",
20
- "@systemfsoftware/effect-cell-types": "^6.0.1",
21
- "@systemfsoftware/stryker-js": "^2.0.0"
19
+ "@systemfsoftware/stryker-js": "^3.0.1",
20
+ "@systemfsoftware/effect-cell-types": "^7.0.0"
22
21
  },
23
22
  "devDependencies": {
24
23
  "@systemfsoftware/arethetypeswrong-cli": "^1.1.1",
25
24
  "@types/node": "^24",
26
- "effect": "^4.0.0-rc.112",
25
+ "effect": "4.0.0-rc.112",
27
26
  "oxlint": "^1.77.0",
28
27
  "oxlint-tsgolint": "7.0.2001",
29
28
  "rimraf": "^6.1.3",
30
29
  "tsdown": "^0.22.14",
31
30
  "typescript": "^7",
32
31
  "vitest": "^4",
33
- "@systemfsoftware/all": "^1.1.3",
34
- "@systemfsoftware/effect-gherkin-spec": "^4.0.1",
32
+ "@systemfsoftware/all": "^2.0.0",
33
+ "@systemfsoftware/vitest-config": "^0.1.0",
35
34
  "@systemfsoftware/tsconfig": "^1.3.3",
36
- "@systemfsoftware/vitest-config": "^0.1.0"
35
+ "@systemfsoftware/effect-gherkin-spec": "^4.0.1"
37
36
  },
38
37
  "engines": {
39
38
  "node": ">=20.0.0"
@@ -44,7 +43,7 @@
44
43
  "provenance": true
45
44
  },
46
45
  "peerDependencies": {
47
- "effect": "^4.0.0-rc.112"
46
+ "effect": "4.0.0-rc.112"
48
47
  },
49
48
  "exports": {
50
49
  ".": "./dist/index.mjs",