@systemfsoftware/stryker-js-vitest-runner 2.0.1 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @systemfsoftware/stryker-js-vitest-runner
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Plugin code can now ask for the module-loader service instead of touching the host module API: it exposes the same `createRequire`/`isBuiltin` surface as the host module module, and the Node engine supplies it automatically. Plugins that declare their environment through the engine's plugin declaration get the service without extra wiring; upgrades should move the engine and its plugins in the same release.
8
+
9
+ ### Patch Changes
10
+
11
+ - Refreshed builds on the platform-services dependency graph; the packages no longer reach for host builtins directly. No CLI flags or option names change.
12
+
13
+ - Updated dependencies:
14
+ - @systemfsoftware/stryker-js@0.2.0
15
+
16
+ ## 2.0.2
17
+
18
+ ### Patch Changes
19
+
20
+ - Re-published against the oxc-based instrumenter: workspace dependency ranges move to the new instrumenter major; no package's own behavior changes in this release.
21
+
3
22
  ## 2.0.1
4
23
 
5
24
  ### Patch Changes
package/dist/index.mjs CHANGED
@@ -2,12 +2,9 @@ import { RunConfiguration, SandboxDirectory, declarePlugin } from "@systemfsoftw
2
2
  import * as Effect$1 from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import * as S from "effect/Schema";
5
- import { createRequire } from "module";
6
- import { pathToFileURL } from "node:url";
7
- import path from "path";
8
- import { fileURLToPath } from "url";
9
5
  import { createVitest } from "vitest/node";
10
6
  import { Cell, Workflow } from "@systemfsoftware/effect-cell-types";
7
+ import { Module } from "@systemfsoftware/stryker-js/Module";
11
8
  import { INSTRUMENTER_CONSTANTS, errorToString, normalizeFileName } from "@systemfsoftware/stryker-js/Mutant";
12
9
  import { TestRunner, TestRunnerFailed, testFilesProvided } from "@systemfsoftware/stryker-js/TestRunner";
13
10
  import * as FileSystem from "effect/FileSystem";
@@ -608,27 +605,39 @@ const sandboxSelfPlugin = (aliases) => ({
608
605
  for (const alias of aliases) if (alias.find.test(source)) return alias.replacement;
609
606
  }
610
607
  });
611
- const readVitestVersion = (readPackageJson) => S.decodeUnknownSync(VitestPackageSchema)(readPackageJson()).version;
612
- /** Falls back to the Vitest bundled with this package when `dir` has none. */
613
- const resolveVitest = async (dir) => {
614
- try {
615
- const projectRequire = createRequire(path.join(dir, "package.json"));
616
- const vitestNodePath = projectRequire.resolve("vitest/node");
617
- const vitestNodeUrl = pathToFileURL(vitestNodePath).href;
608
+ const isRunnerTestSuite = (value) => typeof value === "object" && value !== null && "tasks" in value && Array.isArray(Reflect.get(value, "tasks"));
609
+ const STRYKER_SETUP_URL = new URL("./stryker-setup.mjs", import.meta.url);
610
+ const resolveVitest = (_dir) => Effect$1.gen(function* () {
611
+ const fallback = Effect$1.gen(function* () {
612
+ const pathService = yield* Path.Path;
613
+ const fs = yield* FileSystem.FileSystem;
614
+ const urlString = import.meta.resolve("vitest/package.json");
615
+ const packageJsonPath = yield* pathService.fromFileUrl(new URL(urlString));
616
+ const content = yield* fs.readFileString(packageJsonPath);
617
+ const parsed = JSON.parse(content);
618
+ const decoded = yield* S.decodeUnknownEffect(VitestPackageSchema)(parsed);
618
619
  return {
619
- createVitest: S.decodeUnknownSync(VitestNodeModuleSchema)(await import(vitestNodeUrl)).createVitest,
620
- version: readVitestVersion(() => projectRequire(projectRequire.resolve("vitest/package.json")))
620
+ createVitest,
621
+ version: decoded.version
621
622
  };
622
- } catch {
623
- const bundledRequire = createRequire(import.meta.url);
623
+ }).pipe(Effect$1.orDie);
624
+ return yield* Effect$1.gen(function* () {
625
+ const module = yield* Module;
626
+ const pathService = yield* Path.Path;
627
+ const fs = yield* FileSystem.FileSystem;
628
+ const requireFromProject = module.createRequire(pathService.join(_dir, "package.json"));
629
+ const imported = requireFromProject("vitest/node");
630
+ const decodedNode = yield* S.decodeUnknownEffect(VitestNodeModuleSchema)(imported);
631
+ const packageJsonPath = requireFromProject.resolve("vitest/package.json");
632
+ const content = yield* fs.readFileString(packageJsonPath);
633
+ const parsed = JSON.parse(content);
634
+ const decodedPackage = yield* S.decodeUnknownEffect(VitestPackageSchema)(parsed);
624
635
  return {
625
- createVitest,
626
- version: readVitestVersion(() => bundledRequire(bundledRequire.resolve("vitest/package.json")))
636
+ createVitest: decodedNode.createVitest,
637
+ version: decodedPackage.version
627
638
  };
628
- }
629
- };
630
- const isRunnerTestSuite = (value) => typeof value === "object" && value !== null && "tasks" in value && Array.isArray(Reflect.get(value, "tasks"));
631
- const STRYKER_SETUP = fileURLToPath(new URL("./stryker-setup.mjs", import.meta.url));
639
+ }).pipe(Effect$1.catchCause(() => fallback), Effect$1.catchDefect(() => fallback));
640
+ }).pipe(Effect$1.orDie);
632
641
  const shouldUseSuiteMetaSecondArg = (version) => {
633
642
  const parts = version.split(".");
634
643
  const major = Number(parts[0] ?? "0");
@@ -704,6 +713,7 @@ const makeVitestRunnerLayer = (input) => Layer.effect(TestRunner, Effect$1.gen(f
704
713
  });
705
714
  const fsService = yield* FileSystem.FileSystem;
706
715
  const pathService = yield* Path.Path;
716
+ const moduleService = yield* Module;
707
717
  const getState = Ref.get(stateRef);
708
718
  const requireCtx = Effect$1.gen(function* () {
709
719
  const state = yield* getState;
@@ -739,20 +749,21 @@ const makeVitestRunnerLayer = (input) => Layer.effect(TestRunner, Effect$1.gen(f
739
749
  ...s,
740
750
  localSetupFile
741
751
  }));
742
- yield* fsService.copyFile(input.setupFilePath ?? STRYKER_SETUP, localSetupFile).pipe(Effect$1.mapError((cause) => new TestRunnerFailed({
752
+ const defaultSetupPath = yield* pathService.fromFileUrl(STRYKER_SETUP_URL).pipe(Effect$1.mapError((cause) => new TestRunnerFailed({
743
753
  runnerName: "vitest",
744
754
  phase: "init",
745
755
  cause: errorToString(cause)
746
756
  })));
747
- const resolver = input.resolveVitestFor ?? resolveVitest;
748
- const { createVitest, version } = yield* Effect$1.tryPromise({
749
- try: () => resolver(projectRoot),
750
- catch: (cause) => new TestRunnerFailed({
751
- runnerName: "vitest",
752
- phase: "init",
753
- cause: errorToString(cause)
754
- })
755
- });
757
+ yield* fsService.copyFile(input.setupFilePath ?? defaultSetupPath, localSetupFile).pipe(Effect$1.mapError((cause) => new TestRunnerFailed({
758
+ runnerName: "vitest",
759
+ phase: "init",
760
+ cause: errorToString(cause)
761
+ })));
762
+ const { createVitest, version } = yield* (input.resolveVitestFor ?? resolveVitest)(projectRoot).pipe(Effect$1.provideService(Module, moduleService), Effect$1.provideService(FileSystem.FileSystem, fsService), Effect$1.provideService(Path.Path, pathService), Effect$1.catchDefect((cause) => Effect$1.fail(new TestRunnerFailed({
763
+ runnerName: "vitest",
764
+ phase: "init",
765
+ cause: errorToString(cause)
766
+ }))));
756
767
  const namespace = input.globalNamespace ?? INSTRUMENTER_CONSTANTS.NAMESPACE;
757
768
  const scanDir = (() => {
758
769
  if (typeof options.vitest.dir === "string") return pathService.resolve(projectRoot, options.vitest.dir);
@@ -803,7 +814,7 @@ const makeVitestRunnerLayer = (input) => Layer.effect(TestRunner, Effect$1.gen(f
803
814
  return new TestRunnerFailed({
804
815
  runnerName: "vitest",
805
816
  phase: "init",
806
- cause
817
+ cause: errorToString(cause)
807
818
  });
808
819
  })()));
809
820
  const resetContext = Effect$1.gen(function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@systemfsoftware/stryker-js-vitest-runner",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/systemfsoftware/systemfsoftware.git",
@@ -31,8 +31,8 @@
31
31
  "coverageAnalysis": "perTest"
32
32
  },
33
33
  "dependencies": {
34
- "@systemfsoftware/effect-cell-types": "^5.0.1",
35
- "@systemfsoftware/stryker-js": "^0.1.0"
34
+ "@systemfsoftware/effect-cell-types": "^5.0.2",
35
+ "@systemfsoftware/stryker-js": "^0.2.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "effect": "^4.0.0-rc.112",
@@ -49,10 +49,11 @@
49
49
  "rimraf": "^6.1.3",
50
50
  "tsdown": "^0.22.14",
51
51
  "typescript": "^7",
52
- "vitest": "^4.1.10",
53
- "@systemfsoftware/effect-gherkin-spec": "^2.0.2",
54
- "@systemfsoftware/all": "^1.0.1",
52
+ "vitest": "^4",
53
+ "@systemfsoftware/all": "^1.1.0",
54
+ "@systemfsoftware/effect-gherkin-spec": "^4.0.0",
55
55
  "@systemfsoftware/oxlint-config": "^0.1.0",
56
+ "@systemfsoftware/stryker-js-platform-node": "^0.2.0",
56
57
  "@systemfsoftware/tsconfig": "^1.3.3",
57
58
  "@systemfsoftware/vitest-config": "^0.1.0"
58
59
  },