@systemfsoftware/stryker-js-typescript-checker 8.1.1 → 8.2.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 +12 -0
- package/dist/main.mjs +2878 -597
- package/dist/runtime.d.mts +3 -1
- package/dist/runtime.mjs +242 -13
- package/package.json +9 -8
package/dist/runtime.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ import * as HashMap from "effect/HashMap";
|
|
|
8
8
|
import * as Layer from "effect/Layer";
|
|
9
9
|
import * as Option from "effect/Option";
|
|
10
10
|
import * as Path from "effect/Path";
|
|
11
|
+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
|
|
11
12
|
import "effect/Schema";
|
|
12
13
|
import * as HashSet from "effect/HashSet";
|
|
13
14
|
import * as SynchronizedRef from "effect/SynchronizedRef";
|
|
@@ -72,6 +73,7 @@ interface TSCompilerRuntime {
|
|
|
72
73
|
readonly options: Options.StrykerOptions;
|
|
73
74
|
readonly host: FileSystem$1.FileSystem;
|
|
74
75
|
readonly pathService: Path.Path;
|
|
76
|
+
readonly spawner: ChildProcessSpawner.ChildProcessSpawner['Service'];
|
|
75
77
|
readonly files: TSFiles;
|
|
76
78
|
readonly sourceFileSystem: FileSystem;
|
|
77
79
|
readonly state: SynchronizedRef.SynchronizedRef<CompilerState>;
|
|
@@ -96,7 +98,7 @@ interface CheckerRuntimeShape {
|
|
|
96
98
|
}
|
|
97
99
|
declare const CheckerRuntime_base: Context.ServiceClass<CheckerRuntime, "@systemfsoftware/stryker-js-typescript-checker/CheckerRuntime.service/CheckerRuntime", CheckerRuntimeShape>;
|
|
98
100
|
export declare class CheckerRuntime extends CheckerRuntime_base {
|
|
99
|
-
static readonly layer: (options: Options.StrykerOptions) => Layer.Layer<CheckerRuntime | TypeScriptCompiler, never, FileSystem$1.FileSystem | Path.Path>;
|
|
101
|
+
static readonly layer: (options: Options.StrykerOptions) => Layer.Layer<CheckerRuntime | TypeScriptCompiler, never, FileSystem$1.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
|
|
100
102
|
}
|
|
101
103
|
//#endregion
|
|
102
104
|
export type { CheckerRuntimeShape };
|
package/dist/runtime.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import * as Layer from "effect/Layer";
|
|
|
12
12
|
import * as Match from "effect/Match";
|
|
13
13
|
import * as Option from "effect/Option";
|
|
14
14
|
import * as Path from "effect/Path";
|
|
15
|
+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
|
|
15
16
|
import * as Result from "effect/Result";
|
|
16
17
|
import * as S from "effect/Schema";
|
|
17
18
|
import { dual } from "effect/Function";
|
|
@@ -23,9 +24,15 @@ import { API, DiagnosticCategory, ModifierFlags } from "typescript/unstable/asyn
|
|
|
23
24
|
import { Schema } from "effect";
|
|
24
25
|
import * as SchemaIssue from "effect/SchemaIssue";
|
|
25
26
|
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
27
|
+
import * as ChildProcess from "effect/process/ChildProcess";
|
|
26
28
|
import * as Clock from "effect/Clock";
|
|
27
29
|
import * as DateTime from "effect/DateTime";
|
|
28
30
|
//#region src/CheckMutants.schema.ts
|
|
31
|
+
const TceOutcome = S.Literals(["original", "sibling"]);
|
|
32
|
+
const tceFieldOf = (tce) => Option.match(Option.fromUndefinedOr(tce), {
|
|
33
|
+
onNone: () => ({}),
|
|
34
|
+
onSome: (present) => ({ tce: present })
|
|
35
|
+
});
|
|
29
36
|
const SourceFileSchema = S.NonEmptyString.pipe(S.check(S.isPattern(/\.[^./\\]+$/u)));
|
|
30
37
|
const DiagnosticSeveritySchema = S.Literals([
|
|
31
38
|
"error",
|
|
@@ -46,7 +53,8 @@ var DiagnosticLine = class extends S.Class("DiagnosticLine")({
|
|
|
46
53
|
};
|
|
47
54
|
var MutantVerdict = class extends S.Class("MutantVerdict")({
|
|
48
55
|
id: Mutant.MutantId,
|
|
49
|
-
diagnostics: S.Array(DiagnosticLine)
|
|
56
|
+
diagnostics: S.Array(DiagnosticLine),
|
|
57
|
+
tce: S.optional(TceOutcome)
|
|
50
58
|
}) {};
|
|
51
59
|
var CheckMutantsInput = class extends S.TaggedClass()("CheckMutantsInput", {
|
|
52
60
|
mutants: S.Array(Checker.CheckerMutantWire),
|
|
@@ -67,17 +75,41 @@ var MutantFailed = class extends S.TaggedClass()("MutantFailed", {
|
|
|
67
75
|
}) {
|
|
68
76
|
[CheckTypeId] = CheckTypeId;
|
|
69
77
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
var MutantIgnored = class extends S.TaggedClass()("MutantIgnored", {
|
|
79
|
+
id: Mutant.MutantId,
|
|
80
|
+
reason: S.String
|
|
81
|
+
}) {
|
|
82
|
+
[CheckTypeId] = CheckTypeId;
|
|
83
|
+
};
|
|
84
|
+
const CheckOutcomes = S.Array(S.Union([
|
|
85
|
+
MutantPassed,
|
|
86
|
+
MutantFailed,
|
|
87
|
+
MutantIgnored
|
|
88
|
+
]));
|
|
89
|
+
const IGNORE_REASON = {
|
|
90
|
+
original: "equivalent-to-original: tce",
|
|
91
|
+
sibling: "duplicate-at-site: tce"
|
|
92
|
+
};
|
|
93
|
+
const ignoreReasonOf = (tce) => Option.flatMap(Option.fromUndefinedOr(tce), (present) => Option.fromUndefinedOr(IGNORE_REASON[present]));
|
|
94
|
+
const outcomeOf = (mutantId, diagnostics, tce) => Boolean.match(diagnostics.length === 0, {
|
|
73
95
|
onFalse: () => MutantFailed.make({
|
|
74
96
|
id: mutantId,
|
|
75
97
|
reason: Arr.map(diagnostics, (diagnostic) => diagnostic.rendered).join("\n")
|
|
98
|
+
}),
|
|
99
|
+
onTrue: () => Option.match(ignoreReasonOf(tce), {
|
|
100
|
+
onNone: () => MutantPassed.make({ id: mutantId }),
|
|
101
|
+
onSome: (reason) => MutantIgnored.make({
|
|
102
|
+
id: mutantId,
|
|
103
|
+
reason
|
|
104
|
+
})
|
|
76
105
|
})
|
|
77
106
|
});
|
|
78
107
|
const decide$8 = (input) => {
|
|
79
|
-
const
|
|
80
|
-
return Result.succeed(Arr.map(input.mutants, (mutant) =>
|
|
108
|
+
const verdicts = HashMap.fromIterable(Arr.map(input.verdicts, (verdict) => [verdict.id, verdict]));
|
|
109
|
+
return Result.succeed(Arr.map(input.mutants, (mutant) => Option.match(HashMap.get(verdicts, mutant.id), {
|
|
110
|
+
onNone: () => outcomeOf(mutant.id, [], void 0),
|
|
111
|
+
onSome: (verdict) => outcomeOf(mutant.id, verdict.diagnostics, verdict.tce)
|
|
112
|
+
})));
|
|
81
113
|
};
|
|
82
114
|
const checkMutants = Workflow.make({
|
|
83
115
|
command: CheckMutantsInput,
|
|
@@ -183,6 +215,57 @@ const captureAliasSpecifier = Workflow.make({
|
|
|
183
215
|
decide: decide$7
|
|
184
216
|
});
|
|
185
217
|
//#endregion
|
|
218
|
+
//#region src/classify-tce.workflow.ts
|
|
219
|
+
const TceDecisionTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TceDecision");
|
|
220
|
+
const TceClassification = S.Literals(["original", "sibling"]);
|
|
221
|
+
const TceCandidate = S.Struct({
|
|
222
|
+
id: S.String,
|
|
223
|
+
site: S.String,
|
|
224
|
+
emit: S.String
|
|
225
|
+
});
|
|
226
|
+
const candidateIdsAreDistinct = S.makeFilter((candidates) => Option.getOrUndefined(Option.map(Option.fromUndefinedOr(Mutant.duplicatedValue(candidates.map((candidate) => candidate.id))), (duplicated) => `candidate ids must identify distinct mutants, got "${duplicated}"`)), { arbitraryConstraint: { uniqueBy: (candidate) => candidate.id } });
|
|
227
|
+
const DistinctCandidates = S.Array(TceCandidate).check(candidateIdsAreDistinct);
|
|
228
|
+
var TceDecision = class extends S.TaggedClass()("TceDecision", {
|
|
229
|
+
id: S.String,
|
|
230
|
+
classification: TceClassification
|
|
231
|
+
}) {
|
|
232
|
+
[TceDecisionTypeId] = TceDecisionTypeId;
|
|
233
|
+
};
|
|
234
|
+
var ClassifyTceCommand = class extends S.TaggedClass()("ClassifyTceCommand", {
|
|
235
|
+
originalEmit: S.String,
|
|
236
|
+
candidates: DistinctCandidates
|
|
237
|
+
}) {
|
|
238
|
+
static [Workflow.InstrumentationBrand] = {};
|
|
239
|
+
};
|
|
240
|
+
const matchesEarlierSibling = (candidates, index) => Option.match(Option.fromUndefinedOr(candidates[index]), {
|
|
241
|
+
onNone: () => false,
|
|
242
|
+
onSome: (candidate) => Arr.some(Arr.take(candidates, index), (earlier) => Boolean.and(earlier.site === candidate.site, earlier.emit === candidate.emit))
|
|
243
|
+
});
|
|
244
|
+
const indexedOf = (command) => Arr.map(command.candidates, (candidate, index) => ({
|
|
245
|
+
candidate,
|
|
246
|
+
original: candidate.emit === command.originalEmit,
|
|
247
|
+
sibling: matchesEarlierSibling(command.candidates, index)
|
|
248
|
+
}));
|
|
249
|
+
const classifyOf = (command) => Arr.filterMap(indexedOf(command), (entry) => Boolean.match(entry.original, {
|
|
250
|
+
onTrue: () => Result.succeed(TceDecision.make({
|
|
251
|
+
id: entry.candidate.id,
|
|
252
|
+
classification: "original"
|
|
253
|
+
})),
|
|
254
|
+
onFalse: () => Boolean.match(entry.sibling, {
|
|
255
|
+
onTrue: () => Result.succeed(TceDecision.make({
|
|
256
|
+
id: entry.candidate.id,
|
|
257
|
+
classification: "sibling"
|
|
258
|
+
})),
|
|
259
|
+
onFalse: () => Result.failVoid
|
|
260
|
+
})
|
|
261
|
+
}));
|
|
262
|
+
const classifyTce = Workflow.make({
|
|
263
|
+
command: ClassifyTceCommand,
|
|
264
|
+
decision: S.Array(TceDecision),
|
|
265
|
+
error: S.Never,
|
|
266
|
+
decide: (command) => Result.succeed(classifyOf(command))
|
|
267
|
+
});
|
|
268
|
+
//#endregion
|
|
186
269
|
//#region src/Compiler.schema.ts
|
|
187
270
|
/**
|
|
188
271
|
* Compiler — declarations for the TypeScript compiler and version guard.
|
|
@@ -292,9 +375,9 @@ const LOW_EMIT_OPTIONS_FOR_PROJECT_REFERENCES = Object.freeze({
|
|
|
292
375
|
declaration: true,
|
|
293
376
|
composite: true
|
|
294
377
|
});
|
|
295
|
-
const compilerOptionsOf$
|
|
378
|
+
const compilerOptionsOf$2 = (document) => Option.getOrElse(Option.fromUndefinedOr(document.compilerOptions), () => ({}));
|
|
296
379
|
const withCompilerOverrides = (document, extraOptions) => ({
|
|
297
|
-
...compilerOptionsOf$
|
|
380
|
+
...compilerOptionsOf$2(document),
|
|
298
381
|
...COMPILER_OPTIONS_OVERRIDES,
|
|
299
382
|
...extraOptions
|
|
300
383
|
});
|
|
@@ -695,6 +778,81 @@ const requestAffectedFiles = Workflow.make({
|
|
|
695
778
|
decide: decide$1
|
|
696
779
|
});
|
|
697
780
|
//#endregion
|
|
781
|
+
//#region src/emit-text.ts
|
|
782
|
+
const SOURCE_MAP_COMMENT = /^\/\/# sourceMappingURL=.*$/gmu;
|
|
783
|
+
const normalizeEmit = (emit) => emit.replace(/^\uFEFF/u, "").replace(/\r\n?/gu, "\n").replace(SOURCE_MAP_COMMENT, "").split("\n").map((line) => line.replace(/[ \t]+$/u, "")).filter((line) => line.length > 0).join("\n").trim();
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region src/tce-emit.ts
|
|
786
|
+
const sourceFileName = (index, extension) => `tce-input-${index}${extension}`;
|
|
787
|
+
const EMITTED_EXTENSION = {
|
|
788
|
+
".mts": ".mjs",
|
|
789
|
+
".cts": ".cjs"
|
|
790
|
+
};
|
|
791
|
+
const emittedExtensionOf = (extension) => EMITTED_EXTENSION[extension] ?? ".js";
|
|
792
|
+
const compilerOptionsOf$1 = (outDir, rootDir) => ({
|
|
793
|
+
noEmit: false,
|
|
794
|
+
noCheck: true,
|
|
795
|
+
noEmitOnError: false,
|
|
796
|
+
emitDeclarationOnly: false,
|
|
797
|
+
declaration: false,
|
|
798
|
+
declarationMap: false,
|
|
799
|
+
sourceMap: false,
|
|
800
|
+
composite: false,
|
|
801
|
+
incremental: false,
|
|
802
|
+
outDir,
|
|
803
|
+
rootDir,
|
|
804
|
+
skipLibCheck: true
|
|
805
|
+
});
|
|
806
|
+
const cliPathOf = Effect.gen(function* () {
|
|
807
|
+
const path = yield* Path.Path;
|
|
808
|
+
const packageFile = yield* path.fromFileUrl(new URL(import.meta.resolve("typescript/package.json")));
|
|
809
|
+
return path.join(path.dirname(packageFile), "bin", "tsc");
|
|
810
|
+
});
|
|
811
|
+
const writeInputs = (request, directory) => Effect.gen(function* () {
|
|
812
|
+
const fs = yield* FileSystem.FileSystem;
|
|
813
|
+
const path = yield* Path.Path;
|
|
814
|
+
const originalName = sourceFileName(0, request.sourceExtension);
|
|
815
|
+
yield* fs.writeFileString(path.join(directory, originalName), request.originalContent);
|
|
816
|
+
const names = Arr.map(request.mutants, (_, index) => sourceFileName(index + 1, request.sourceExtension));
|
|
817
|
+
yield* Effect.forEach(request.mutants, (mutant, index) => fs.writeFileString(path.join(directory, sourceFileName(index + 1, request.sourceExtension)), mutant.content), { discard: true });
|
|
818
|
+
return [originalName, ...names];
|
|
819
|
+
}).pipe(Effect.orDie);
|
|
820
|
+
const tsconfigTextOf = Effect.fnUntraced(function* (request, directory, files) {
|
|
821
|
+
const outDir = (yield* Path.Path).join(directory, "out");
|
|
822
|
+
return yield* S.encodeEffect(S.fromJsonString(S.Unknown))({
|
|
823
|
+
extends: request.tsconfigFile,
|
|
824
|
+
compilerOptions: compilerOptionsOf$1(outDir, directory),
|
|
825
|
+
references: [],
|
|
826
|
+
files,
|
|
827
|
+
include: [],
|
|
828
|
+
exclude: []
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
const runEmit = (request, directory) => Effect.gen(function* () {
|
|
832
|
+
const fs = yield* FileSystem.FileSystem;
|
|
833
|
+
const path = yield* Path.Path;
|
|
834
|
+
const cli = yield* cliPathOf;
|
|
835
|
+
const files = yield* writeInputs(request, directory);
|
|
836
|
+
const outDir = path.join(directory, "out");
|
|
837
|
+
yield* fs.writeFileString(path.join(directory, "tsconfig.json"), yield* tsconfigTextOf(request, directory, files));
|
|
838
|
+
yield* Effect.scoped(ChildProcess.make(cli, ["-p", path.join(directory, "tsconfig.json")], {
|
|
839
|
+
cwd: directory,
|
|
840
|
+
stdout: "ignore",
|
|
841
|
+
stderr: "ignore"
|
|
842
|
+
}).pipe(Effect.flatMap((handle) => handle.exitCode)));
|
|
843
|
+
const readEmitted = (index) => Effect.map(fs.readFileString(path.join(outDir, `tce-input-${index}${emittedExtensionOf(request.sourceExtension)}`)), normalizeEmit);
|
|
844
|
+
const original = yield* readEmitted(0);
|
|
845
|
+
const emits = yield* Effect.forEach(request.mutants, (_, index) => readEmitted(index + 1));
|
|
846
|
+
return {
|
|
847
|
+
original,
|
|
848
|
+
byKey: HashMap.fromIterable(Arr.map(Arr.zip(request.mutants, emits), ([mutant, emit]) => [mutant.key, emit]))
|
|
849
|
+
};
|
|
850
|
+
}).pipe(Effect.orDie);
|
|
851
|
+
const emitNormalized = (request) => Effect.flatMap(FileSystem.FileSystem, (fs) => Effect.flatMap(fs.makeTempDirectory({ prefix: "stryker-tce-" }), (directory) => runEmit(request, directory).pipe(Effect.ensuring(fs.remove(directory, {
|
|
852
|
+
recursive: true,
|
|
853
|
+
force: true
|
|
854
|
+
}).pipe(Effect.ignore)), Effect.asSome))).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
855
|
+
//#endregion
|
|
698
856
|
//#region src/trace-affected-files.workflow.ts
|
|
699
857
|
const TraceTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TraceAffectedFiles");
|
|
700
858
|
var MutatedFileAffected = class extends S.TaggedClass()("MutatedFileAffected", { fileName: S.String }) {
|
|
@@ -885,6 +1043,7 @@ const make$1 = dual(2, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerMak
|
|
|
885
1043
|
options,
|
|
886
1044
|
host: services.host,
|
|
887
1045
|
pathService: services.pathService,
|
|
1046
|
+
spawner: services.spawner,
|
|
888
1047
|
files,
|
|
889
1048
|
sourceFileSystem: tsFileSystem(files),
|
|
890
1049
|
state
|
|
@@ -1327,6 +1486,64 @@ const checkOne = (rt, state, mutant, previousMutants) => Effect.gen(function* ()
|
|
|
1327
1486
|
onSome: (found) => checkedIn(state, projects, mutant, found, fileName)
|
|
1328
1487
|
});
|
|
1329
1488
|
});
|
|
1489
|
+
const siteKeyOf = (mutant) => `${mutant.fileName}:${mutant.location.start.line}:${mutant.location.start.column}:${mutant.location.end.line}:${mutant.location.end.column}`;
|
|
1490
|
+
const splicedContentOf = (file, mutant) => Option.map(Option.all([offsetAt(file.lineStarts, mutant.location.start), offsetAt(file.lineStarts, mutant.location.end)]), ([start, end]) => file.originalContent.slice(0, start) + mutant.replacement + file.originalContent.slice(end));
|
|
1491
|
+
const tceEntriesOf = (script, fileMutants) => Arr.getSomes(Arr.map(fileMutants, (mutant) => Option.map(splicedContentOf(script, mutant), (content) => ({
|
|
1492
|
+
key: mutant.id,
|
|
1493
|
+
content,
|
|
1494
|
+
site: siteKeyOf(mutant)
|
|
1495
|
+
}))));
|
|
1496
|
+
const tceCandidatesOf = (entries, byKey) => Arr.getSomes(Arr.map(entries, (entry) => Option.map(HashMap.get(byKey, entry.key), (emit) => ({
|
|
1497
|
+
id: entry.key,
|
|
1498
|
+
site: entry.site,
|
|
1499
|
+
emit
|
|
1500
|
+
}))));
|
|
1501
|
+
const emitForFile = (rt, tsconfigFile, fileName, script, entries) => emitNormalized({
|
|
1502
|
+
tsconfigFile,
|
|
1503
|
+
sourceExtension: rt.pathService.extname(fileName),
|
|
1504
|
+
originalContent: script.originalContent,
|
|
1505
|
+
mutants: Arr.map(entries, (entry) => ({
|
|
1506
|
+
key: entry.key,
|
|
1507
|
+
content: entry.content
|
|
1508
|
+
}))
|
|
1509
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, rt.host), Effect.provideService(Path.Path, rt.pathService), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, rt.spawner));
|
|
1510
|
+
const tceScriptOf = (file, fileName) => Option.match(file, {
|
|
1511
|
+
onNone: () => Result.fail(CompilerFailed.make({
|
|
1512
|
+
reason: "file-not-in-project",
|
|
1513
|
+
subject: fileName
|
|
1514
|
+
})),
|
|
1515
|
+
onSome: (script) => Result.succeed(script)
|
|
1516
|
+
});
|
|
1517
|
+
const decisionsOfFile = Effect.fnUntraced(function* (rt, tsconfigFile, fileName, fileMutants) {
|
|
1518
|
+
const file = yield* getFile(rt.files, fileName);
|
|
1519
|
+
const script = yield* Effect.fromResult(tceScriptOf(file, fileName));
|
|
1520
|
+
const entries = tceEntriesOf(script, fileMutants);
|
|
1521
|
+
const emitted = yield* Option.match(Option.liftPredicate(entries, (present) => present.length > 0), {
|
|
1522
|
+
onNone: () => Effect.succeedNone,
|
|
1523
|
+
onSome: (present) => emitForFile(rt, tsconfigFile, fileName, script, present)
|
|
1524
|
+
});
|
|
1525
|
+
return Option.match(emitted, {
|
|
1526
|
+
onNone: () => [],
|
|
1527
|
+
onSome: (result) => decided(classifyTce(ClassifyTceCommand.make({
|
|
1528
|
+
originalEmit: result.original,
|
|
1529
|
+
candidates: tceCandidatesOf(entries, result.byKey)
|
|
1530
|
+
})))
|
|
1531
|
+
});
|
|
1532
|
+
});
|
|
1533
|
+
const classifyBatchTce = Effect.fnUntraced(function* (rt, tsconfigFile, mutants, checked) {
|
|
1534
|
+
const passedIds = HashSet.fromIterable(Arr.map(Arr.filter(checked, (entry) => entry.diagnostics.length === 0), (entry) => entry.mutantId));
|
|
1535
|
+
const passedMutants = Arr.filter(mutants, (mutant) => HashSet.has(passedIds, mutant.id));
|
|
1536
|
+
const fileNames = Arr.dedupe(Arr.map(passedMutants, (mutant) => resolveFileName(rt, mutant.fileName)));
|
|
1537
|
+
const perFile = yield* Effect.forEach(fileNames, (fileName) => decisionsOfFile(rt, tsconfigFile, fileName, Arr.filter(passedMutants, (mutant) => resolveFileName(rt, mutant.fileName) === fileName)));
|
|
1538
|
+
const decisions = Arr.flatten(perFile);
|
|
1539
|
+
return Arr.map(checked, (entry) => Option.match(Arr.findFirst(decisions, (decision) => decision.id === entry.mutantId), {
|
|
1540
|
+
onNone: () => entry,
|
|
1541
|
+
onSome: (decision) => ({
|
|
1542
|
+
...entry,
|
|
1543
|
+
tce: decision.classification
|
|
1544
|
+
})
|
|
1545
|
+
}));
|
|
1546
|
+
});
|
|
1330
1547
|
const check = dual(2, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerCheck.name)(function* (self, mutants) {
|
|
1331
1548
|
const rt = runtimeOf(self);
|
|
1332
1549
|
yield* Effect.annotateCurrentSpan({
|
|
@@ -1337,22 +1554,27 @@ const check = dual(2, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerChec
|
|
|
1337
1554
|
yield* resetMutatedFiles(rt, state.lastMutants);
|
|
1338
1555
|
const batchFileNames = Arr.dedupe(Arr.map(mutants, (mutant) => resolveFileName(rt, mutant.fileName)));
|
|
1339
1556
|
yield* refreshSnapshot(rt, Arr.dedupe([...state.lastMutatedFileNames, ...batchFileNames]));
|
|
1340
|
-
const
|
|
1557
|
+
const accumulated = yield* Effect.reduce(mutants, () => ({
|
|
1341
1558
|
previous: Option.none(),
|
|
1342
1559
|
results: []
|
|
1343
1560
|
}), (previous, mutant) => Effect.map(checkOne(rt, state, mutant, Option.toArray(previous.previous)), (result) => ({
|
|
1344
1561
|
previous: Option.some(mutant),
|
|
1345
1562
|
results: [...previous.results, result]
|
|
1346
|
-
})))
|
|
1563
|
+
})));
|
|
1564
|
+
const checked = yield* classifyBatchTce(rt, state.tsconfigFile, mutants, accumulated.results);
|
|
1347
1565
|
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1348
1566
|
...prev,
|
|
1349
1567
|
lastMutants: [...mutants],
|
|
1350
1568
|
lastMutatedFileNames: batchFileNames
|
|
1351
1569
|
}));
|
|
1352
1570
|
const failed = Arr.filter(checked, (entry) => entry.diagnostics.length > 0);
|
|
1571
|
+
const equivalentToOriginal = Arr.filter(checked, (entry) => entry.tce === "original").length;
|
|
1572
|
+
const duplicateAtSite = Arr.filter(checked, (entry) => entry.tce === "sibling").length;
|
|
1353
1573
|
yield* Effect.annotateCurrentSpan({
|
|
1354
1574
|
"typescript.diagnostics.count": Arr.reduce(checked, 0, (total, entry) => total + entry.diagnostics.length),
|
|
1355
|
-
"typescript.compile_errors.count": failed.length
|
|
1575
|
+
"typescript.compile_errors.count": failed.length,
|
|
1576
|
+
"typescript.tce.equivalent_to_original.count": equivalentToOriginal,
|
|
1577
|
+
"typescript.tce.duplicate_at_site.count": duplicateAtSite
|
|
1356
1578
|
});
|
|
1357
1579
|
yield* annotateDiagnosticSample(Arr.flatten(Arr.map(failed, (entry) => entry.diagnostics)));
|
|
1358
1580
|
return checked;
|
|
@@ -1414,7 +1636,8 @@ const refuse$1 = (options) => Checker.CheckerFailed.make({
|
|
|
1414
1636
|
});
|
|
1415
1637
|
const verdictsOf = (compiler, checked) => Effect.forEach(checked, (entry) => Effect.map(describeDiagnostics(compiler, entry.diagnostics), (diagnostics) => MutantVerdict.make({
|
|
1416
1638
|
id: entry.mutantId,
|
|
1417
|
-
diagnostics: [...diagnostics]
|
|
1639
|
+
diagnostics: [...diagnostics],
|
|
1640
|
+
...tceFieldOf(entry.tce)
|
|
1418
1641
|
})), { concurrency: 1 });
|
|
1419
1642
|
const checkCell = Sandwich.named(SpanTaxonomy.Spans.typescriptCheckerCheckMutants.name)((command) => Effect.flatMap(TypeScriptCompiler, (compiler) => Effect.flatMap(check(compiler, [...command.mutants]), (checked) => Effect.map(verdictsOf(compiler, checked), (verdicts) => CheckMutantsInput.make({
|
|
1420
1643
|
mutants: [...command.mutants],
|
|
@@ -1425,6 +1648,7 @@ const checkCell = Sandwich.named(SpanTaxonomy.Spans.typescriptCheckerCheckMutant
|
|
|
1425
1648
|
})))).decide(checkMutants).write({
|
|
1426
1649
|
MutantPassed: (outcome) => Effect.succeed(outcome),
|
|
1427
1650
|
MutantFailed: (outcome) => Effect.succeed(outcome),
|
|
1651
|
+
MutantIgnored: (outcome) => Effect.succeed(outcome),
|
|
1428
1652
|
CommandRejected: ({ issue }) => Effect.fail(refuse$1({
|
|
1429
1653
|
mutantIds: [],
|
|
1430
1654
|
cause: issue
|
|
@@ -1436,9 +1660,11 @@ const TypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TSComp
|
|
|
1436
1660
|
const scopedOf = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerScoped.name)(function* (spec) {
|
|
1437
1661
|
const host = yield* FileSystem.FileSystem;
|
|
1438
1662
|
const pathService = yield* Path.Path;
|
|
1663
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
1439
1664
|
const compiler = yield* make$1(spec, {
|
|
1440
1665
|
host,
|
|
1441
|
-
pathService
|
|
1666
|
+
pathService,
|
|
1667
|
+
spawner
|
|
1442
1668
|
});
|
|
1443
1669
|
yield* Effect.addFinalizer(() => close(compiler));
|
|
1444
1670
|
return compiler;
|
|
@@ -1462,6 +1688,9 @@ const refuse = (options) => Checker.CheckerFailed.make({
|
|
|
1462
1688
|
const toCheckResult = (event) => Match.value(event).pipe(Match.tag("MutantPassed", () => ({ status: "passed" })), Match.tag("MutantFailed", (failed) => ({
|
|
1463
1689
|
status: "compileError",
|
|
1464
1690
|
reason: failed.reason
|
|
1691
|
+
})), Match.tag("MutantIgnored", (ignored) => ({
|
|
1692
|
+
status: "ignored",
|
|
1693
|
+
reason: ignored.reason
|
|
1465
1694
|
})), Match.exhaustive);
|
|
1466
1695
|
const checkResultsOf = (events) => HashMap.fromIterable(Arr.map(events, (event) => [event.id, toCheckResult(event)]));
|
|
1467
1696
|
const makeChecker = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerRuntimeMakeChecker.name)(function* (options, compiler) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/stryker-js-typescript-checker",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"@systemfsoftware/effect-cell-types": "^12.0.0",
|
|
35
35
|
"effect": "^4.0.0",
|
|
36
36
|
"typescript": "^7",
|
|
37
|
-
"@systemfsoftware/stryker-js-cli-contract": "^0.
|
|
38
|
-
"@systemfsoftware/stryker-js-
|
|
39
|
-
"@systemfsoftware/stryker-js-
|
|
40
|
-
"@systemfsoftware/stryker-js-plugin-
|
|
37
|
+
"@systemfsoftware/stryker-js-cli-contract": "^0.3.0",
|
|
38
|
+
"@systemfsoftware/stryker-js-instrumenter": "^12.1.0",
|
|
39
|
+
"@systemfsoftware/stryker-js-plugin-runtime": "^7.0.1",
|
|
40
|
+
"@systemfsoftware/stryker-js-plugin-interface": "^13.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@effect/platform-node": "^4.0.0",
|
|
44
44
|
"@effect/platform-node-shared": "^4.0.0",
|
|
45
|
-
"@effect/tsgo": "^0.
|
|
45
|
+
"@effect/tsgo": "^0.47.2",
|
|
46
46
|
"@microsoft/api-extractor": "^7",
|
|
47
47
|
"@std/jsonc": "npm:@jsr/std__jsonc@^1",
|
|
48
48
|
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"rimraf": "^6.1.3",
|
|
62
62
|
"tsdown": "^0.23.0",
|
|
63
63
|
"vitest": "^5",
|
|
64
|
-
"@systemfsoftware/
|
|
64
|
+
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
65
65
|
"@systemfsoftware/vitest-config": "^0.1.0",
|
|
66
|
-
"@systemfsoftware/
|
|
66
|
+
"@systemfsoftware/stryker-config": "^0.1.0"
|
|
67
67
|
},
|
|
68
68
|
"inlinedDependencies": {
|
|
69
69
|
"@effect/opentelemetry": "4.0.0",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"ws": "8.22.0"
|
|
93
93
|
},
|
|
94
94
|
"publishConfig": {
|
|
95
|
+
"access": "public",
|
|
95
96
|
"provenance": true
|
|
96
97
|
},
|
|
97
98
|
"scripts": {
|