@systemfsoftware/stryker-js-typescript-checker 8.2.1 → 10.0.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 +70 -0
- package/README.md +69 -4
- package/dist/index.d.mts +7 -7
- package/dist/main.mjs +10945 -7023
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/runtime.d.mts +32 -13
- package/dist/runtime.mjs +44 -1583
- package/dist/type-query.d.mts +12 -0
- package/dist/type-query.handle-DrgF8cok.mjs +3551 -0
- package/dist/type-query.mjs +2 -0
- package/package.json +38 -28
- package/schema/typescript-checker-options.json +8 -1
package/dist/runtime.mjs
CHANGED
|
@@ -1,68 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { a as groups, c as nodes, d as CheckMutantsInput, f as MutantVerdict, i as describeDiagnostics, l as programDigest, m as CheckMutantsCommand, n as check, o as init, p as tceFieldOf, r as close, s as make$2, t as layer$1, u as DryRunCompileErrors } from "./type-query.handle-DrgF8cok.mjs";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import { Blueprint, Cell, Sandwich, Workflow } from "@systemfsoftware/effect-cell-types";
|
|
2
5
|
import { SpanTaxonomy } from "@systemfsoftware/stryker-js-cli-contract";
|
|
3
|
-
import { ErrorText
|
|
4
|
-
import { Checker, Mutant } from "@systemfsoftware/stryker-js-plugin-interface";
|
|
6
|
+
import { ErrorText } from "@systemfsoftware/stryker-js-instrumenter";
|
|
7
|
+
import { Checker, Mutant, TypeQuery } from "@systemfsoftware/stryker-js-plugin-interface";
|
|
5
8
|
import * as Arr from "effect/Array";
|
|
6
9
|
import * as Boolean from "effect/Boolean";
|
|
7
|
-
import * as Context from "effect/Context";
|
|
8
10
|
import * as Effect from "effect/Effect";
|
|
9
11
|
import * as FileSystem from "effect/FileSystem";
|
|
10
12
|
import * as HashMap from "effect/HashMap";
|
|
11
|
-
import * as Layer from "effect/Layer";
|
|
12
13
|
import * as Match from "effect/Match";
|
|
13
14
|
import * as Option from "effect/Option";
|
|
14
15
|
import * as Path from "effect/Path";
|
|
15
16
|
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
|
|
16
17
|
import * as Result from "effect/Result";
|
|
17
18
|
import * as S from "effect/Schema";
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import { Schema } from "effect";
|
|
25
|
-
import * as SchemaIssue from "effect/SchemaIssue";
|
|
26
|
-
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
27
|
-
import * as ChildProcess from "effect/process/ChildProcess";
|
|
28
|
-
import * as Clock from "effect/Clock";
|
|
29
|
-
import * as DateTime from "effect/DateTime";
|
|
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
|
-
});
|
|
36
|
-
const SourceFileSchema = S.NonEmptyString.pipe(S.check(S.isPattern(/\.[^./\\]+$/u)));
|
|
37
|
-
const DiagnosticSeveritySchema = S.Literals([
|
|
38
|
-
"error",
|
|
39
|
-
"warning",
|
|
40
|
-
"suggestion",
|
|
41
|
-
"message"
|
|
42
|
-
]);
|
|
43
|
-
var DiagnosticLine = class extends S.Class("DiagnosticLine")({
|
|
44
|
-
fileName: S.optional(SourceFileSchema),
|
|
45
|
-
position: S.String,
|
|
46
|
-
severity: DiagnosticSeveritySchema,
|
|
47
|
-
code: S.Finite,
|
|
48
|
-
text: S.String
|
|
49
|
-
}) {
|
|
50
|
-
get rendered() {
|
|
51
|
-
return this.position + this.severity + " TS" + this.code + ": " + this.text;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var MutantVerdict = class extends S.Class("MutantVerdict")({
|
|
55
|
-
id: Mutant.MutantId,
|
|
56
|
-
diagnostics: S.Array(DiagnosticLine),
|
|
57
|
-
tce: S.optional(TceOutcome)
|
|
58
|
-
}) {};
|
|
59
|
-
var CheckMutantsInput = class extends S.TaggedClass()("CheckMutantsInput", {
|
|
60
|
-
mutants: S.Array(Checker.CheckerMutantWire),
|
|
61
|
-
verdicts: S.Array(MutantVerdict)
|
|
62
|
-
}) {
|
|
63
|
-
static [Workflow.InstrumentationBrand] = {};
|
|
64
|
-
};
|
|
65
|
-
S.is(SourceFileSchema);
|
|
19
|
+
import * as Layer from "effect/Layer";
|
|
20
|
+
//#region src/CheckerRuntime.service.ts
|
|
21
|
+
var CheckerRuntime = class extends Context.Service()("@systemfsoftware/stryker-js-typescript-checker/CheckerRuntime.service/CheckerRuntime") {};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/ts-compiler.service.ts
|
|
24
|
+
var TypeScriptCompiler = class extends Context.Service()("@systemfsoftware/stryker-js-typescript-checker/ts-compiler.service/TypeScriptCompiler") {};
|
|
66
25
|
//#endregion
|
|
67
26
|
//#region src/check-mutants.workflow.ts
|
|
68
27
|
const CheckTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/CheckOutcome");
|
|
@@ -104,7 +63,7 @@ const outcomeOf = (mutantId, diagnostics, tce) => Boolean.match(diagnostics.leng
|
|
|
104
63
|
})
|
|
105
64
|
})
|
|
106
65
|
});
|
|
107
|
-
const decide
|
|
66
|
+
const decide = (input) => {
|
|
108
67
|
const verdicts = HashMap.fromIterable(Arr.map(input.verdicts, (verdict) => [verdict.id, verdict]));
|
|
109
68
|
return Result.succeed(Arr.map(input.mutants, (mutant) => Option.match(HashMap.get(verdicts, mutant.id), {
|
|
110
69
|
onNone: () => outcomeOf(mutant.id, [], void 0),
|
|
@@ -115,1534 +74,24 @@ const checkMutants = Workflow.make({
|
|
|
115
74
|
command: CheckMutantsInput,
|
|
116
75
|
decision: CheckOutcomes,
|
|
117
76
|
error: S.Never,
|
|
118
|
-
decide: decide$8
|
|
119
|
-
});
|
|
120
|
-
S.Struct({ typescriptChecker: S.optional(S.Struct({})) });
|
|
121
|
-
var CheckMutantsCommand = class extends S.TaggedClass()("CheckMutantsCommand", { mutants: S.Array(Checker.CheckerMutantWire) }) {};
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/Tsconfig.schema.ts
|
|
124
|
-
var TsConfigParseError = class extends Schema.TaggedError()("TsConfigParseError", {
|
|
125
|
-
file: Schema.String,
|
|
126
|
-
reason: Schema.String
|
|
127
|
-
}) {
|
|
128
|
-
get message() {
|
|
129
|
-
return `Could not parse tsconfig file '${this.file}': ${this.reason}`;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
var TsConfigNotFoundError = class extends Schema.TaggedError()("TsConfigNotFoundError", { file: Schema.String }) {
|
|
133
|
-
get message() {
|
|
134
|
-
return `The tsconfig file does not exist at: "${this.file}". Please configure the tsconfig file in your stryker.conf file using "tsconfigFile"`;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const PathAliasesSchema = Schema.Record(Schema.String, Schema.Array(Schema.String));
|
|
138
|
-
const JsonRecord = Schema.Record(Schema.String, Schema.Json);
|
|
139
|
-
const ProjectReferenceSchema = Schema.StructWithRest(Schema.Struct({ path: Schema.String }), [JsonRecord]);
|
|
140
|
-
const TsConfigCompilerOptionsSchema = JsonRecord;
|
|
141
|
-
const TsConfigDocumentSchema = Schema.StructWithRest(Schema.Struct({
|
|
142
|
-
references: Schema.optional(Schema.Array(ProjectReferenceSchema)),
|
|
143
|
-
compilerOptions: Schema.optional(TsConfigCompilerOptionsSchema)
|
|
144
|
-
}), [JsonRecord]);
|
|
145
|
-
Schema.is(TsConfigDocumentSchema);
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/CheckerCommands.schema.ts
|
|
148
|
-
var GroupMutantsCommand = class extends S.TaggedClass()("GroupMutantsCommand", { mutants: S.Array(Checker.CheckerMutantWire) }) {
|
|
149
|
-
static [Workflow.InstrumentationBrand] = {};
|
|
150
|
-
};
|
|
151
|
-
var TraceAffectedFilesCommand = class extends S.TaggedClass()("TraceAffectedFilesCommand", {
|
|
152
|
-
importsByFile: S.Record(S.String, S.Array(S.String)),
|
|
153
|
-
mutatedFileNames: S.Array(S.String)
|
|
154
|
-
}) {
|
|
155
|
-
static [Workflow.InstrumentationBrand] = { mutatedFileNames: "stryker.typescript_checker.mutated_files" };
|
|
156
|
-
};
|
|
157
|
-
var RequestAffectedFilesCommand = class extends S.TaggedClass()("RequestAffectedFilesCommand", {
|
|
158
|
-
affectedFileNames: S.Array(S.String),
|
|
159
|
-
presentFileNames: S.Array(S.String)
|
|
160
|
-
}) {
|
|
161
|
-
static [Workflow.InstrumentationBrand] = { affectedFileNames: "stryker.typescript_checker.affected_files" };
|
|
162
|
-
};
|
|
163
|
-
var PlanDiagnosticBatchesCommand = class extends S.TaggedClass()("PlanDiagnosticBatchesCommand", { fileNames: S.Array(S.String) }) {
|
|
164
|
-
static [Workflow.InstrumentationBrand] = { fileNames: "stryker.typescript_checker.requested_files" };
|
|
165
|
-
};
|
|
166
|
-
var CaptureAliasSpecifierCommand = class extends S.TaggedClass()("CaptureAliasSpecifierCommand", {
|
|
167
|
-
pattern: S.String,
|
|
168
|
-
specifier: S.String
|
|
169
|
-
}) {
|
|
170
|
-
static [Workflow.InstrumentationBrand] = { specifier: "stryker.typescript_checker.specifier" };
|
|
171
|
-
};
|
|
172
|
-
var PlanResolutionCandidatesCommand = class extends S.TaggedClass()("PlanResolutionCandidatesCommand", {
|
|
173
|
-
resolved: S.String,
|
|
174
|
-
extension: S.String
|
|
175
|
-
}) {
|
|
176
|
-
static [Workflow.InstrumentationBrand] = { resolved: "stryker.typescript_checker.resolved_file" };
|
|
177
|
-
};
|
|
178
|
-
var OverrideTsconfigOptionsCommand = class extends S.TaggedClass()("OverrideTsconfigOptionsCommand", {
|
|
179
|
-
document: TsConfigDocumentSchema,
|
|
180
|
-
buildMode: S.Boolean
|
|
181
|
-
}) {
|
|
182
|
-
static [Workflow.InstrumentationBrand] = { buildMode: "stryker.typescript_checker.build_mode" };
|
|
183
|
-
};
|
|
184
|
-
var ParseTsconfigTextCommand = class extends S.TaggedClass()("ParseTsconfigTextCommand", { text: S.String }) {
|
|
185
|
-
static [Workflow.InstrumentationBrand] = {};
|
|
186
|
-
};
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/capture-alias-specifier.workflow.ts
|
|
189
|
-
const CaptureTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/AliasCapture");
|
|
190
|
-
var AliasSpecifierCaptured = class extends S.TaggedClass()("AliasSpecifierCaptured", { capture: S.String }) {
|
|
191
|
-
[CaptureTypeId] = CaptureTypeId;
|
|
192
|
-
};
|
|
193
|
-
var AliasSpecifierUnmatched = class extends S.TaggedClass()("AliasSpecifierUnmatched", {}) {
|
|
194
|
-
[CaptureTypeId] = CaptureTypeId;
|
|
195
|
-
};
|
|
196
|
-
const AliasCapture = S.Union([AliasSpecifierCaptured, AliasSpecifierUnmatched]);
|
|
197
|
-
const prefixOf = (pattern) => pattern.slice(0, pattern.indexOf("*"));
|
|
198
|
-
const suffixOf = (pattern) => pattern.slice(pattern.indexOf("*") + 1);
|
|
199
|
-
const stripPrefix = (specifier, prefix) => Option.map(Option.liftPredicate(specifier, (candidate) => candidate.startsWith(prefix)), (candidate) => candidate.slice(prefix.length));
|
|
200
|
-
const stripSuffix = (specifier, suffix) => Option.map(Option.liftPredicate(specifier, (candidate) => candidate.endsWith(suffix)), (candidate) => candidate.slice(0, candidate.length - suffix.length));
|
|
201
|
-
const wildcardCaptureOf = (pattern, specifier) => Option.flatMap(stripPrefix(specifier, prefixOf(pattern)), (rest) => stripSuffix(rest, suffixOf(pattern)));
|
|
202
|
-
const exactCaptureOf = (pattern, specifier) => Option.map(Option.liftPredicate(specifier, (candidate) => candidate === pattern), () => "");
|
|
203
|
-
const captureOf = (pattern, specifier) => Boolean.match(pattern.includes("*"), {
|
|
204
|
-
onTrue: () => wildcardCaptureOf(pattern, specifier),
|
|
205
|
-
onFalse: () => exactCaptureOf(pattern, specifier)
|
|
206
|
-
});
|
|
207
|
-
const decide$7 = (command) => Result.succeed(Option.match(captureOf(command.pattern, command.specifier), {
|
|
208
|
-
onNone: () => AliasSpecifierUnmatched.make({}),
|
|
209
|
-
onSome: (capture) => AliasSpecifierCaptured.make({ capture })
|
|
210
|
-
}));
|
|
211
|
-
const captureAliasSpecifier = Workflow.make({
|
|
212
|
-
command: CaptureAliasSpecifierCommand,
|
|
213
|
-
decision: AliasCapture,
|
|
214
|
-
error: S.Never,
|
|
215
|
-
decide: decide$7
|
|
216
|
-
});
|
|
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
|
|
269
|
-
//#region src/Compiler.schema.ts
|
|
270
|
-
/**
|
|
271
|
-
* Compiler — declarations for the TypeScript compiler and version guard.
|
|
272
|
-
*
|
|
273
|
-
* The error vocabulary every compiler operation refuses with; decoded and
|
|
274
|
-
* reported at the checker boundary, no I/O.
|
|
275
|
-
*/
|
|
276
|
-
/** The installed TypeScript version is below the supported floor. */
|
|
277
|
-
var UnsupportedTypeScriptVersionError = class extends Schema.TaggedError()("UnsupportedTypeScriptVersionError", { version: Schema.String }) {
|
|
278
|
-
get message() {
|
|
279
|
-
return `@systemfsoftware/stryker-js-typescript-checker only supports typescript@7.0.0 or higher. Found typescript@${this.version}`;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
/** Requested file is not present in the hybrid in-memory file map. */
|
|
283
|
-
var HybridFileNotFoundError = class extends Schema.TaggedError()("HybridFileNotFoundError", { fileName: Schema.String }) {
|
|
284
|
-
get message() {
|
|
285
|
-
return `'${this.fileName}' is part of your TypeScript project but could not be found on disk`;
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
var HybridMutantOutsideFileError = class extends Schema.TaggedError()("HybridMutantOutsideFileError", { fileName: Schema.String }) {
|
|
289
|
-
get message() {
|
|
290
|
-
return `A mutant's location falls outside '${this.fileName}'`;
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* Every way the TypeScript compiler can fail while serving a check.
|
|
295
|
-
* One tagged error — callers branch only on failure itself; `reason` keeps
|
|
296
|
-
* cases distinguishable in reports.
|
|
297
|
-
*/
|
|
298
|
-
var CompilerFailed = class extends Schema.TaggedError()("CompilerFailed", {
|
|
299
|
-
reason: Schema.Literals([
|
|
300
|
-
"not-initialized",
|
|
301
|
-
"no-projects",
|
|
302
|
-
"unknown-file-node",
|
|
303
|
-
"file-not-in-project",
|
|
304
|
-
"mutant-outside-file"
|
|
305
|
-
]),
|
|
306
|
-
subject: Schema.optional(Schema.String)
|
|
307
|
-
}) {
|
|
308
|
-
get message() {
|
|
309
|
-
return Match.value(this.reason).pipe(Match.when("not-initialized", () => "The TypeScript compiler was used before it was initialized"), Match.when("no-projects", () => `No projects were found for ${this.subject ?? "the tsconfig"}`), Match.when("unknown-file-node", () => `The file graph has no node for '${this.subject ?? "a file"}', which should not happen`), Match.when("file-not-in-project", () => `'${this.subject ?? "a file"}' is part of your TypeScript project but could not be found on disk`), Match.when("mutant-outside-file", () => `A mutant's location falls outside '${this.subject ?? "a file"}'`), Match.exhaustive);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var DryRunCompileErrors = class extends Schema.TaggedError()("DryRunCompileErrors", { text: Schema.String }) {
|
|
313
|
-
get message() {
|
|
314
|
-
return `Typescript error(s) found in dry run compilation: ${this.text}`;
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/group-mutants.workflow.ts
|
|
319
|
-
const GroupingTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/Grouping");
|
|
320
|
-
var MutantGroup = class extends S.TaggedClass()("MutantGroup", { ids: S.Array(S.String) }) {
|
|
321
|
-
[GroupingTypeId] = GroupingTypeId;
|
|
322
|
-
};
|
|
323
|
-
const MutantGroups = S.Array(MutantGroup);
|
|
324
|
-
const emptyBatching = {
|
|
325
|
-
files: [],
|
|
326
|
-
idsByFile: HashMap.empty()
|
|
327
|
-
};
|
|
328
|
-
const accumulate = (batching, mutant) => Option.match(HashMap.get(batching.idsByFile, mutant.fileName), {
|
|
329
|
-
onNone: () => ({
|
|
330
|
-
files: [...batching.files, mutant.fileName],
|
|
331
|
-
idsByFile: HashMap.set(batching.idsByFile, mutant.fileName, [mutant.id])
|
|
332
|
-
}),
|
|
333
|
-
onSome: (ids) => ({
|
|
334
|
-
...batching,
|
|
335
|
-
idsByFile: HashMap.set(batching.idsByFile, mutant.fileName, [...ids, mutant.id])
|
|
336
|
-
})
|
|
337
|
-
});
|
|
338
|
-
const batchIdsOf = (command) => {
|
|
339
|
-
const batching = Arr.reduce(command.mutants, emptyBatching, accumulate);
|
|
340
|
-
return Arr.map(batching.files, (fileName) => Option.getOrElse(HashMap.get(batching.idsByFile, fileName), () => []));
|
|
341
|
-
};
|
|
342
|
-
const decide$6 = (command) => Result.succeed(Arr.map(batchIdsOf(command), (ids) => MutantGroup.make({ ids })));
|
|
343
|
-
const groupMutants = Workflow.make({
|
|
344
|
-
command: GroupMutantsCommand,
|
|
345
|
-
decision: MutantGroups,
|
|
346
|
-
error: S.Never,
|
|
347
|
-
decide: decide$6
|
|
348
|
-
});
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/override-tsconfig-options.workflow.ts
|
|
351
|
-
const OverrideTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TsconfigOverride");
|
|
352
|
-
var ProjectReferencesOverride = class extends S.TaggedClass()("ProjectReferencesOverride", { text: S.String }) {
|
|
353
|
-
[OverrideTypeId] = OverrideTypeId;
|
|
354
|
-
};
|
|
355
|
-
var SingleProjectOverride = class extends S.TaggedClass()("SingleProjectOverride", { text: S.String }) {
|
|
356
|
-
[OverrideTypeId] = OverrideTypeId;
|
|
357
|
-
};
|
|
358
|
-
const TsconfigOverride = S.Union([ProjectReferencesOverride, SingleProjectOverride]);
|
|
359
|
-
const COMPILER_OPTIONS_OVERRIDES = Object.freeze({
|
|
360
|
-
allowUnreachableCode: true,
|
|
361
|
-
noUnusedLocals: false,
|
|
362
|
-
noUnusedParameters: false,
|
|
363
|
-
skipLibCheck: true
|
|
364
|
-
});
|
|
365
|
-
const NO_EMIT_OPTIONS_FOR_SINGLE_PROJECT = Object.freeze({
|
|
366
|
-
noEmit: true,
|
|
367
|
-
incremental: false,
|
|
368
|
-
tsBuildInfoFile: void 0,
|
|
369
|
-
composite: false
|
|
370
|
-
});
|
|
371
|
-
const LOW_EMIT_OPTIONS_FOR_PROJECT_REFERENCES = Object.freeze({
|
|
372
|
-
emitDeclarationOnly: true,
|
|
373
|
-
noEmit: false,
|
|
374
|
-
declarationMap: true,
|
|
375
|
-
declaration: true,
|
|
376
|
-
composite: true
|
|
377
|
-
});
|
|
378
|
-
const compilerOptionsOf$2 = (document) => Option.getOrElse(Option.fromUndefinedOr(document.compilerOptions), () => ({}));
|
|
379
|
-
const withCompilerOverrides = (document, extraOptions) => ({
|
|
380
|
-
...compilerOptionsOf$2(document),
|
|
381
|
-
...COMPILER_OPTIONS_OVERRIDES,
|
|
382
|
-
...extraOptions
|
|
383
|
-
});
|
|
384
|
-
const projectReferencesJson = (document) => {
|
|
385
|
-
const compilerOptions = withCompilerOverrides(document, LOW_EMIT_OPTIONS_FOR_PROJECT_REFERENCES);
|
|
386
|
-
delete compilerOptions["inlineSourceMap"];
|
|
387
|
-
delete compilerOptions["inlineSources"];
|
|
388
|
-
delete compilerOptions["mapRoute"];
|
|
389
|
-
delete compilerOptions["sourceRoot"];
|
|
390
|
-
delete compilerOptions["outFile"];
|
|
391
|
-
return JSON.stringify({
|
|
392
|
-
...document,
|
|
393
|
-
compilerOptions
|
|
394
|
-
});
|
|
395
|
-
};
|
|
396
|
-
const singleProjectJson = (document) => {
|
|
397
|
-
const compilerOptions = withCompilerOverrides(document, NO_EMIT_OPTIONS_FOR_SINGLE_PROJECT);
|
|
398
|
-
Boolean.match(compilerOptions["declarationDir"] !== null, {
|
|
399
|
-
onTrue: () => {
|
|
400
|
-
delete compilerOptions["declarationDir"];
|
|
401
|
-
},
|
|
402
|
-
onFalse: () => void 0
|
|
403
|
-
});
|
|
404
|
-
const { references: _references, ...withoutReferences } = document;
|
|
405
|
-
return JSON.stringify({
|
|
406
|
-
...withoutReferences,
|
|
407
|
-
compilerOptions
|
|
408
|
-
});
|
|
409
|
-
};
|
|
410
|
-
const decide$5 = (command) => Result.succeed(Boolean.match(command.buildMode, {
|
|
411
|
-
onTrue: () => ProjectReferencesOverride.make({ text: projectReferencesJson(command.document) }),
|
|
412
|
-
onFalse: () => SingleProjectOverride.make({ text: singleProjectJson(command.document) })
|
|
413
|
-
}));
|
|
414
|
-
const overrideTsconfigOptions = Workflow.make({
|
|
415
|
-
command: OverrideTsconfigOptionsCommand,
|
|
416
|
-
decision: TsconfigOverride,
|
|
417
|
-
error: S.Never,
|
|
418
|
-
decide: decide$5
|
|
419
|
-
});
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region ../../node_modules/.pnpm/@jsr+std__jsonc@1.0.2/node_modules/@jsr/std__jsonc/parse.js
|
|
422
|
-
/**
|
|
423
|
-
* Converts a JSON with Comments (JSONC) string into an object.
|
|
424
|
-
*
|
|
425
|
-
* @example Usage
|
|
426
|
-
* ```ts
|
|
427
|
-
* import { parse } from "@std/jsonc";
|
|
428
|
-
* import { assertEquals } from "@std/assert";
|
|
429
|
-
*
|
|
430
|
-
* assertEquals(parse('{"foo": "bar"}'), { foo: "bar" });
|
|
431
|
-
* assertEquals(parse('{"foo": "bar", }'), { foo: "bar" });
|
|
432
|
-
* assertEquals(parse('{"foo": "bar", } /* comment *\/'), { foo: "bar" });
|
|
433
|
-
* ```
|
|
434
|
-
*
|
|
435
|
-
* @throws {SyntaxError} If the JSONC string is invalid.
|
|
436
|
-
* @param text A valid JSONC string.
|
|
437
|
-
* @returns The parsed JsonValue from the JSONC string.
|
|
438
|
-
*/ function parse(text) {
|
|
439
|
-
if (new.target) throw new TypeError("Cannot create an instance: parse is not a constructor");
|
|
440
|
-
return new JsoncParser(text).parse();
|
|
441
|
-
}
|
|
442
|
-
var JsoncParser = class {
|
|
443
|
-
#whitespace = /* @__PURE__ */ new Set(" \r\n");
|
|
444
|
-
#numberEndToken = /* @__PURE__ */ new Set([..."[]{}:,/", ...this.#whitespace]);
|
|
445
|
-
#text;
|
|
446
|
-
#length;
|
|
447
|
-
#tokenized;
|
|
448
|
-
constructor(text) {
|
|
449
|
-
this.#text = `${text}`;
|
|
450
|
-
this.#length = this.#text.length;
|
|
451
|
-
this.#tokenized = this.#tokenize();
|
|
452
|
-
}
|
|
453
|
-
parse() {
|
|
454
|
-
const token = this.#getNext();
|
|
455
|
-
const res = this.#parseJsonValue(token);
|
|
456
|
-
const { done, value } = this.#tokenized.next();
|
|
457
|
-
if (!done) throw new SyntaxError(buildErrorMessage(value));
|
|
458
|
-
return res;
|
|
459
|
-
}
|
|
460
|
-
/** Read the next token. If the token is read to the end, it throws a SyntaxError. */ #getNext() {
|
|
461
|
-
const { done, value } = this.#tokenized.next();
|
|
462
|
-
if (done) throw new SyntaxError("Cannot parse JSONC: unexpected end of JSONC input");
|
|
463
|
-
return value;
|
|
464
|
-
}
|
|
465
|
-
/** Split the JSONC string into token units. Whitespace and comments are skipped. */ *#tokenize() {
|
|
466
|
-
for (let i = 0; i < this.#length; i++) {
|
|
467
|
-
if (this.#whitespace.has(this.#text[i])) continue;
|
|
468
|
-
if (this.#text[i] === "/" && this.#text[i + 1] === "*") {
|
|
469
|
-
i += 2;
|
|
470
|
-
let hasEndOfComment = false;
|
|
471
|
-
for (; i < this.#length; i++) if (this.#text[i] === "*" && this.#text[i + 1] === "/") {
|
|
472
|
-
hasEndOfComment = true;
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
if (!hasEndOfComment) throw new SyntaxError("Cannot parse JSONC: unexpected end of JSONC input");
|
|
476
|
-
i++;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
if (this.#text[i] === "/" && this.#text[i + 1] === "/") {
|
|
480
|
-
i += 2;
|
|
481
|
-
for (; i < this.#length; i++) if (this.#text[i] === "\n" || this.#text[i] === "\r") break;
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
switch (this.#text[i]) {
|
|
485
|
-
case "{":
|
|
486
|
-
yield {
|
|
487
|
-
type: "BeginObject",
|
|
488
|
-
position: i
|
|
489
|
-
};
|
|
490
|
-
break;
|
|
491
|
-
case "}":
|
|
492
|
-
yield {
|
|
493
|
-
type: "EndObject",
|
|
494
|
-
position: i
|
|
495
|
-
};
|
|
496
|
-
break;
|
|
497
|
-
case "[":
|
|
498
|
-
yield {
|
|
499
|
-
type: "BeginArray",
|
|
500
|
-
position: i
|
|
501
|
-
};
|
|
502
|
-
break;
|
|
503
|
-
case "]":
|
|
504
|
-
yield {
|
|
505
|
-
type: "EndArray",
|
|
506
|
-
position: i
|
|
507
|
-
};
|
|
508
|
-
break;
|
|
509
|
-
case ":":
|
|
510
|
-
yield {
|
|
511
|
-
type: "NameSeparator",
|
|
512
|
-
position: i
|
|
513
|
-
};
|
|
514
|
-
break;
|
|
515
|
-
case ",":
|
|
516
|
-
yield {
|
|
517
|
-
type: "ValueSeparator",
|
|
518
|
-
position: i
|
|
519
|
-
};
|
|
520
|
-
break;
|
|
521
|
-
case "\"": {
|
|
522
|
-
const startIndex = i;
|
|
523
|
-
let shouldEscapeNext = false;
|
|
524
|
-
i++;
|
|
525
|
-
for (; i < this.#length; i++) {
|
|
526
|
-
if (this.#text[i] === "\"" && !shouldEscapeNext) break;
|
|
527
|
-
shouldEscapeNext = this.#text[i] === "\\" && !shouldEscapeNext;
|
|
528
|
-
}
|
|
529
|
-
yield {
|
|
530
|
-
type: "String",
|
|
531
|
-
sourceText: this.#text.substring(startIndex, i + 1),
|
|
532
|
-
position: startIndex
|
|
533
|
-
};
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
default: {
|
|
537
|
-
const startIndex = i;
|
|
538
|
-
for (; i < this.#length; i++) if (this.#numberEndToken.has(this.#text[i])) break;
|
|
539
|
-
i--;
|
|
540
|
-
yield {
|
|
541
|
-
type: "NullOrTrueOrFalseOrNumber",
|
|
542
|
-
sourceText: this.#text.substring(startIndex, i + 1),
|
|
543
|
-
position: startIndex
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
#parseJsonValue(value) {
|
|
550
|
-
switch (value.type) {
|
|
551
|
-
case "BeginObject": return this.#parseObject();
|
|
552
|
-
case "BeginArray": return this.#parseArray();
|
|
553
|
-
case "NullOrTrueOrFalseOrNumber": return this.#parseNullOrTrueOrFalseOrNumber(value);
|
|
554
|
-
case "String": return this.#parseString(value);
|
|
555
|
-
default: throw new SyntaxError(buildErrorMessage(value));
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
#parseObject() {
|
|
559
|
-
const target = {};
|
|
560
|
-
while (true) {
|
|
561
|
-
const token1 = this.#getNext();
|
|
562
|
-
if (token1.type === "EndObject") return target;
|
|
563
|
-
if (token1.type !== "String") throw new SyntaxError(buildErrorMessage(token1));
|
|
564
|
-
const key = this.#parseString(token1);
|
|
565
|
-
const token2 = this.#getNext();
|
|
566
|
-
if (token2.type !== "NameSeparator") throw new SyntaxError(buildErrorMessage(token2));
|
|
567
|
-
const token3 = this.#getNext();
|
|
568
|
-
Object.defineProperty(target, key, {
|
|
569
|
-
value: this.#parseJsonValue(token3),
|
|
570
|
-
writable: true,
|
|
571
|
-
enumerable: true,
|
|
572
|
-
configurable: true
|
|
573
|
-
});
|
|
574
|
-
const token4 = this.#getNext();
|
|
575
|
-
if (token4.type === "EndObject") return target;
|
|
576
|
-
if (token4.type !== "ValueSeparator") throw new SyntaxError(buildErrorMessage(token4));
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
#parseArray() {
|
|
580
|
-
const target = [];
|
|
581
|
-
while (true) {
|
|
582
|
-
const token1 = this.#getNext();
|
|
583
|
-
if (token1.type === "EndArray") return target;
|
|
584
|
-
target.push(this.#parseJsonValue(token1));
|
|
585
|
-
const token2 = this.#getNext();
|
|
586
|
-
if (token2.type === "EndArray") return target;
|
|
587
|
-
if (token2.type !== "ValueSeparator") throw new SyntaxError(buildErrorMessage(token2));
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
#parseString(value) {
|
|
591
|
-
let parsed;
|
|
592
|
-
try {
|
|
593
|
-
parsed = JSON.parse(value.sourceText);
|
|
594
|
-
} catch {
|
|
595
|
-
throw new SyntaxError(buildErrorMessage(value));
|
|
596
|
-
}
|
|
597
|
-
if (typeof parsed !== "string") throw new TypeError(`Parsed value is not a string: ${parsed}`);
|
|
598
|
-
return parsed;
|
|
599
|
-
}
|
|
600
|
-
#parseNullOrTrueOrFalseOrNumber(value) {
|
|
601
|
-
if (value.sourceText === "null") return null;
|
|
602
|
-
if (value.sourceText === "true") return true;
|
|
603
|
-
if (value.sourceText === "false") return false;
|
|
604
|
-
let parsed;
|
|
605
|
-
try {
|
|
606
|
-
parsed = JSON.parse(value.sourceText);
|
|
607
|
-
} catch {
|
|
608
|
-
throw new SyntaxError(buildErrorMessage(value));
|
|
609
|
-
}
|
|
610
|
-
if (typeof parsed !== "number") throw new TypeError(`Parsed value is not a number: ${parsed}`);
|
|
611
|
-
return parsed;
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
function buildErrorMessage({ type, sourceText, position }) {
|
|
615
|
-
let token = "";
|
|
616
|
-
switch (type) {
|
|
617
|
-
case "BeginObject":
|
|
618
|
-
token = "{";
|
|
619
|
-
break;
|
|
620
|
-
case "EndObject":
|
|
621
|
-
token = "}";
|
|
622
|
-
break;
|
|
623
|
-
case "BeginArray":
|
|
624
|
-
token = "[";
|
|
625
|
-
break;
|
|
626
|
-
case "EndArray":
|
|
627
|
-
token = "]";
|
|
628
|
-
break;
|
|
629
|
-
case "NameSeparator":
|
|
630
|
-
token = ":";
|
|
631
|
-
break;
|
|
632
|
-
case "ValueSeparator":
|
|
633
|
-
token = ",";
|
|
634
|
-
break;
|
|
635
|
-
case "NullOrTrueOrFalseOrNumber":
|
|
636
|
-
case "String": token = 30 < sourceText.length ? `${sourceText.slice(0, 30)}...` : sourceText;
|
|
637
|
-
}
|
|
638
|
-
return `Cannot parse JSONC: unexpected token "${token}" in JSONC at position ${position}`;
|
|
639
|
-
}
|
|
640
|
-
//#endregion
|
|
641
|
-
//#region src/parse-tsconfig-text.workflow.ts
|
|
642
|
-
const TsconfigTextTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TsconfigText");
|
|
643
|
-
var TsconfigParsed = class extends S.TaggedClass()("TsconfigParsed", { document: TsConfigDocumentSchema }) {
|
|
644
|
-
[TsconfigTextTypeId] = TsconfigTextTypeId;
|
|
645
|
-
};
|
|
646
|
-
var TsconfigRefused = class extends S.TaggedClass()("TsconfigRefused", { reason: S.String }) {
|
|
647
|
-
[TsconfigTextTypeId] = TsconfigTextTypeId;
|
|
648
|
-
};
|
|
649
|
-
const TsconfigTextDecision = S.Union([TsconfigParsed, TsconfigRefused]);
|
|
650
|
-
const reasonOfThrown = (cause) => Option.getOrElse(Option.map(Option.liftPredicate(cause, (error) => error instanceof Error), (error) => error.message), () => "a non-Error value was thrown");
|
|
651
|
-
const documentIssueOf = (value) => new SchemaIssue.InvalidValue({ message: Result.match(S.decodeUnknownResult(TsConfigDocumentSchema)(value), {
|
|
652
|
-
onFailure: (error) => error.message,
|
|
653
|
-
onSuccess: () => "expected a TypeScript configuration object"
|
|
654
|
-
}) });
|
|
655
|
-
const parseJsonc = (jsonText) => Result.match(Result.try({
|
|
656
|
-
try: () => parse(jsonText.replace(/^\uFEFF/, "")),
|
|
657
|
-
catch: (cause) => cause
|
|
658
|
-
}), {
|
|
659
|
-
onFailure: (cause) => Result.fail(new SchemaIssue.InvalidValue({ message: reasonOfThrown(cause) })),
|
|
660
|
-
onSuccess: (value) => Result.mapError(S.decodeUnknownResult(S.Json)(value), (error) => new SchemaIssue.InvalidValue({ message: error.message }))
|
|
661
|
-
});
|
|
662
|
-
const documentOf = (value) => Option.match(Option.liftPredicate(value, S.is(TsConfigDocumentSchema)), {
|
|
663
|
-
onNone: () => Result.fail(documentIssueOf(value)),
|
|
664
|
-
onSome: () => Result.mapError(S.decodeUnknownResult(TsConfigDocumentSchema)(value), (error) => new SchemaIssue.InvalidValue({ message: error.message }))
|
|
665
|
-
});
|
|
666
|
-
const decodeText = (jsonText) => Result.flatMap(parseJsonc(jsonText), documentOf);
|
|
667
|
-
const TsConfigText = S.String.pipe(S.decodeTo(TsConfigDocumentSchema, SchemaTransformation.transformEffect({
|
|
668
|
-
decode: (jsonText) => Result.match(decodeText(jsonText), {
|
|
669
|
-
onFailure: (issue) => Effect.fail(issue),
|
|
670
|
-
onSuccess: (document) => Effect.succeed(document)
|
|
671
|
-
}),
|
|
672
|
-
encode: (document) => Effect.succeed(JSON.stringify(document))
|
|
673
|
-
})));
|
|
674
|
-
const decide$4 = (command) => Result.succeed(Result.match(S.decodeResult(TsConfigText)(command.text), {
|
|
675
|
-
onFailure: (error) => TsconfigRefused.make({ reason: error.message }),
|
|
676
|
-
onSuccess: (document) => TsconfigParsed.make({ document })
|
|
677
|
-
}));
|
|
678
|
-
const parseTsconfigText = Workflow.make({
|
|
679
|
-
command: ParseTsconfigTextCommand,
|
|
680
|
-
decision: TsconfigTextDecision,
|
|
681
|
-
error: S.Never,
|
|
682
|
-
decide: decide$4
|
|
683
|
-
});
|
|
684
|
-
//#endregion
|
|
685
|
-
//#region src/plan-diagnostic-batches.workflow.ts
|
|
686
|
-
const DiagnosticBatchSize = 64;
|
|
687
|
-
const BatchesTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/DiagnosticBatches");
|
|
688
|
-
var DiagnosticBatchesPlanned = class extends S.TaggedClass()("DiagnosticBatchesPlanned", { batches: S.String.pipe(S.Array, S.Array) }) {
|
|
689
|
-
[BatchesTypeId] = BatchesTypeId;
|
|
690
|
-
};
|
|
691
|
-
var NoDiagnosticBatches = class extends S.TaggedClass()("NoDiagnosticBatches", {}) {
|
|
692
|
-
[BatchesTypeId] = BatchesTypeId;
|
|
693
|
-
};
|
|
694
|
-
const DiagnosticBatches = S.Union([DiagnosticBatchesPlanned, NoDiagnosticBatches]);
|
|
695
|
-
const diagnosticBatchesOf = (fileNames) => Arr.chunksOf(fileNames, DiagnosticBatchSize);
|
|
696
|
-
const decide$3 = (command) => Result.succeed(Boolean.match(command.fileNames.length === 0, {
|
|
697
|
-
onTrue: () => NoDiagnosticBatches.make({}),
|
|
698
|
-
onFalse: () => DiagnosticBatchesPlanned.make({ batches: diagnosticBatchesOf(command.fileNames) })
|
|
699
|
-
}));
|
|
700
|
-
const planDiagnosticBatches = Workflow.make({
|
|
701
|
-
command: PlanDiagnosticBatchesCommand,
|
|
702
|
-
decision: DiagnosticBatches,
|
|
703
|
-
error: S.Never,
|
|
704
|
-
decide: decide$3
|
|
705
|
-
});
|
|
706
|
-
//#endregion
|
|
707
|
-
//#region src/plan-resolution-candidates.workflow.ts
|
|
708
|
-
const ExtensionlessTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/ResolutionCandidates");
|
|
709
|
-
var ExtensionNamedPath = class extends S.TaggedClass()("ExtensionNamedPath", { candidates: S.Array(S.String) }) {
|
|
710
|
-
[ExtensionlessTypeId] = ExtensionlessTypeId;
|
|
711
|
-
};
|
|
712
|
-
var ExtensionlessPath = class extends S.TaggedClass()("ExtensionlessPath", { candidates: S.Array(S.String) }) {
|
|
713
|
-
[ExtensionlessTypeId] = ExtensionlessTypeId;
|
|
714
|
-
};
|
|
715
|
-
const ResolutionCandidates = S.Union([ExtensionNamedPath, ExtensionlessPath]);
|
|
716
|
-
const withoutExtensionCandidates = (resolved) => [
|
|
717
|
-
resolved,
|
|
718
|
-
resolved + ".ts",
|
|
719
|
-
resolved + ".tsx",
|
|
720
|
-
resolved + ".d.ts",
|
|
721
|
-
resolved + "/index.ts",
|
|
722
|
-
resolved + "/index.tsx",
|
|
723
|
-
resolved + "/index.d.ts",
|
|
724
|
-
resolved + ".js",
|
|
725
|
-
resolved + ".jsx",
|
|
726
|
-
resolved + ".mjs",
|
|
727
|
-
resolved + ".cjs",
|
|
728
|
-
resolved + "/index.js",
|
|
729
|
-
resolved + "/index.jsx",
|
|
730
|
-
resolved + "/index.mjs",
|
|
731
|
-
resolved + "/index.cjs"
|
|
732
|
-
];
|
|
733
|
-
const withExtensionCandidates = (resolved, extension) => {
|
|
734
|
-
const withoutExtension = resolved.slice(0, -extension.length);
|
|
735
|
-
return [
|
|
736
|
-
resolved,
|
|
737
|
-
withoutExtension + ".ts",
|
|
738
|
-
withoutExtension + ".tsx",
|
|
739
|
-
withoutExtension + ".d.ts",
|
|
740
|
-
withoutExtension + ".js",
|
|
741
|
-
withoutExtension + ".jsx",
|
|
742
|
-
withoutExtension + ".mjs",
|
|
743
|
-
withoutExtension + ".cjs"
|
|
744
|
-
];
|
|
745
|
-
};
|
|
746
|
-
const decide$2 = (command) => Result.succeed(Boolean.match(command.extension === "", {
|
|
747
|
-
onTrue: () => ExtensionlessPath.make({ candidates: withoutExtensionCandidates(command.resolved) }),
|
|
748
|
-
onFalse: () => ExtensionNamedPath.make({ candidates: withExtensionCandidates(command.resolved, command.extension) })
|
|
749
|
-
}));
|
|
750
|
-
const planResolutionCandidates = Workflow.make({
|
|
751
|
-
command: PlanResolutionCandidatesCommand,
|
|
752
|
-
decision: ResolutionCandidates,
|
|
753
|
-
error: S.Never,
|
|
754
|
-
decide: decide$2
|
|
755
|
-
});
|
|
756
|
-
//#endregion
|
|
757
|
-
//#region src/request-affected-files.workflow.ts
|
|
758
|
-
const RequestTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/RequestAffectedFiles");
|
|
759
|
-
var AffectedFilesRequested = class extends S.TaggedClass()("AffectedFilesRequested", { fileNames: S.Array(S.String) }) {
|
|
760
|
-
[RequestTypeId] = RequestTypeId;
|
|
761
|
-
};
|
|
762
|
-
var NoAffectedFileRequested = class extends S.TaggedClass()("NoAffectedFileRequested", {}) {
|
|
763
|
-
[RequestTypeId] = RequestTypeId;
|
|
764
|
-
};
|
|
765
|
-
const RequestedFiles = S.Union([AffectedFilesRequested, NoAffectedFileRequested]);
|
|
766
|
-
const requestedFileNames = (presentFileNames, affectedFileNames) => Arr.filter(presentFileNames, (fileName) => HashSet.has(affectedFileNames, fileName));
|
|
767
|
-
const decide$1 = (command) => {
|
|
768
|
-
const requested = requestedFileNames(command.presentFileNames, HashSet.fromIterable(command.affectedFileNames));
|
|
769
|
-
return Result.succeed(Boolean.match(requested.length === 0, {
|
|
770
|
-
onTrue: () => NoAffectedFileRequested.make({}),
|
|
771
|
-
onFalse: () => AffectedFilesRequested.make({ fileNames: requested })
|
|
772
|
-
}));
|
|
773
|
-
};
|
|
774
|
-
const requestAffectedFiles = Workflow.make({
|
|
775
|
-
command: RequestAffectedFilesCommand,
|
|
776
|
-
decision: RequestedFiles,
|
|
777
|
-
error: S.Never,
|
|
778
|
-
decide: decide$1
|
|
779
|
-
});
|
|
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
|
|
856
|
-
//#region src/trace-affected-files.workflow.ts
|
|
857
|
-
const TraceTypeId = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TraceAffectedFiles");
|
|
858
|
-
var MutatedFileAffected = class extends S.TaggedClass()("MutatedFileAffected", { fileName: S.String }) {
|
|
859
|
-
[TraceTypeId] = TraceTypeId;
|
|
860
|
-
};
|
|
861
|
-
var DependentFileAffected = class extends S.TaggedClass()("DependentFileAffected", { fileName: S.String }) {
|
|
862
|
-
[TraceTypeId] = TraceTypeId;
|
|
863
|
-
};
|
|
864
|
-
const AffectedFiles = S.Array(S.Union([MutatedFileAffected, DependentFileAffected]));
|
|
865
|
-
const dependentsOf = (importsByFile) => Arr.reduce(Object.entries(importsByFile), HashMap.empty(), (dependents, [fileName, imports]) => Arr.reduce(imports, dependents, (accumulated, imported) => HashMap.set(accumulated, imported, HashSet.add(Option.getOrElse(HashMap.get(accumulated, imported), () => HashSet.empty()), fileName))));
|
|
866
|
-
const dependentsOfFile = (dependents, fileName) => Option.getOrElse(HashMap.get(dependents, fileName), () => HashSet.empty());
|
|
867
|
-
const closeOverDependents = (dependents, affected) => {
|
|
868
|
-
const grown = HashSet.union(affected, HashSet.fromIterable(Arr.flatMap(Arr.fromIterable(affected), (fileName) => Arr.fromIterable(dependentsOfFile(dependents, fileName)))));
|
|
869
|
-
return Boolean.match(HashSet.size(grown) === HashSet.size(affected), {
|
|
870
|
-
onTrue: () => grown,
|
|
871
|
-
onFalse: () => closeOverDependents(dependents, grown)
|
|
872
|
-
});
|
|
873
|
-
};
|
|
874
|
-
const affectedEvents = (seed, affected) => Arr.map(Arr.fromIterable(affected), (fileName) => Boolean.match(HashSet.has(seed, fileName), {
|
|
875
|
-
onTrue: () => MutatedFileAffected.make({ fileName }),
|
|
876
|
-
onFalse: () => DependentFileAffected.make({ fileName })
|
|
877
|
-
}));
|
|
878
|
-
const decide = (command) => {
|
|
879
|
-
const seed = HashSet.fromIterable(command.mutatedFileNames);
|
|
880
|
-
return Result.succeed(affectedEvents(seed, closeOverDependents(dependentsOf(command.importsByFile), seed)));
|
|
881
|
-
};
|
|
882
|
-
const traceAffectedFiles = Workflow.make({
|
|
883
|
-
command: TraceAffectedFilesCommand,
|
|
884
|
-
decision: AffectedFiles,
|
|
885
|
-
error: S.Never,
|
|
886
77
|
decide
|
|
887
78
|
});
|
|
888
79
|
//#endregion
|
|
889
|
-
//#region src/ts-files.handle.ts
|
|
890
|
-
const TypeId$2 = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TSFiles");
|
|
891
|
-
const normalizeFileName$1 = (fileName) => fileName.replace(/\\/g, "/");
|
|
892
|
-
const isBuildInfoFile = (fileName) => normalizeFileName$1(fileName).endsWith(".tsbuildinfo");
|
|
893
|
-
const TSFiles = Handle.make()(TypeId$2);
|
|
894
|
-
TSFiles.is;
|
|
895
|
-
const stateOf = (self) => TSFiles.slot(self);
|
|
896
|
-
const emptySources = {
|
|
897
|
-
files: HashMap.empty(),
|
|
898
|
-
overrides: HashMap.empty()
|
|
899
|
-
};
|
|
900
|
-
const make$2 = (host) => TSFiles.make({}, {
|
|
901
|
-
host,
|
|
902
|
-
snapshot: { current: emptySources }
|
|
903
|
-
});
|
|
904
|
-
const publish = (state, next) => Effect.sync(() => {
|
|
905
|
-
state.snapshot.current = next(state.snapshot.current);
|
|
906
|
-
});
|
|
907
|
-
const makeScriptFile = (content, fileName, now) => ({
|
|
908
|
-
content,
|
|
909
|
-
fileName,
|
|
910
|
-
originalContent: content,
|
|
911
|
-
modifiedTime: now,
|
|
912
|
-
lineStarts: lineStartsOf(content)
|
|
913
|
-
});
|
|
914
|
-
const withContent = (file, content, now) => ({
|
|
915
|
-
...file,
|
|
916
|
-
content,
|
|
917
|
-
modifiedTime: now
|
|
918
|
-
});
|
|
919
|
-
const mutateScriptFile = (file, mutant, now) => Option.map(Option.all([offsetAt(file.lineStarts, mutant.location.start), offsetAt(file.lineStarts, mutant.location.end)]), ([start, end]) => withContent(file, file.originalContent.slice(0, start) + mutant.replacement + file.originalContent.slice(end), now));
|
|
920
|
-
const resetScriptFile = (file, now) => ({
|
|
921
|
-
...file,
|
|
922
|
-
content: file.originalContent,
|
|
923
|
-
modifiedTime: now
|
|
924
|
-
});
|
|
925
|
-
const now = Effect.map(Clock.currentTimeMillis, DateTime.makeUnsafe);
|
|
926
|
-
const readFromDisk = Effect.fnUntraced(function* (state, fileName) {
|
|
927
|
-
const at = yield* now;
|
|
928
|
-
const file = Option.map(yield* Effect.option(state.host.readFileString(fileName)), (content) => makeScriptFile(content, fileName, at));
|
|
929
|
-
yield* publish(state, (sources) => ({
|
|
930
|
-
...sources,
|
|
931
|
-
files: HashMap.set(sources.files, fileName, file)
|
|
932
|
-
}));
|
|
933
|
-
return file;
|
|
934
|
-
});
|
|
935
|
-
const getFile = dual(2, (self, fileName) => {
|
|
936
|
-
const state = stateOf(self);
|
|
937
|
-
const normalized = normalizeFileName$1(fileName);
|
|
938
|
-
return Option.match(HashMap.get(state.snapshot.current.files, normalized), {
|
|
939
|
-
onNone: () => readFromDisk(state, normalized),
|
|
940
|
-
onSome: Effect.succeed
|
|
941
|
-
});
|
|
942
|
-
});
|
|
943
|
-
const mutateFile = dual(3, Effect.fnUntraced(function* (self, fileName, mutant) {
|
|
944
|
-
const state = stateOf(self);
|
|
945
|
-
const at = yield* now;
|
|
946
|
-
const file = yield* getFile(self, fileName);
|
|
947
|
-
yield* Option.match(file, {
|
|
948
|
-
onNone: () => Effect.fail(HybridFileNotFoundError.make({ fileName })),
|
|
949
|
-
onSome: (found) => Option.match(mutateScriptFile(found, mutant, at), {
|
|
950
|
-
onNone: () => Effect.fail(HybridMutantOutsideFileError.make({ fileName })),
|
|
951
|
-
onSome: (mutated) => publish(state, (sources) => ({
|
|
952
|
-
...sources,
|
|
953
|
-
files: HashMap.set(sources.files, normalizeFileName$1(fileName), Option.some(mutated))
|
|
954
|
-
}))
|
|
955
|
-
})
|
|
956
|
-
});
|
|
957
|
-
}));
|
|
958
|
-
const resetFile = dual(2, Effect.fnUntraced(function* (self, fileName) {
|
|
959
|
-
const state = stateOf(self);
|
|
960
|
-
const at = yield* now;
|
|
961
|
-
const normalized = normalizeFileName$1(fileName);
|
|
962
|
-
yield* Option.match(HashMap.get(state.snapshot.current.files, normalized), {
|
|
963
|
-
onNone: () => Effect.void,
|
|
964
|
-
onSome: Option.match({
|
|
965
|
-
onNone: () => Effect.void,
|
|
966
|
-
onSome: (file) => publish(state, (sources) => ({
|
|
967
|
-
...sources,
|
|
968
|
-
files: HashMap.set(sources.files, normalized, Option.some(resetScriptFile(file, at)))
|
|
969
|
-
}))
|
|
970
|
-
})
|
|
971
|
-
});
|
|
972
|
-
}));
|
|
973
|
-
const setOverrides = dual(2, (self, overrides) => publish(stateOf(self), (sources) => ({
|
|
974
|
-
...sources,
|
|
975
|
-
overrides
|
|
976
|
-
})));
|
|
977
|
-
const tsFileSystem = (self) => {
|
|
978
|
-
const state = stateOf(self);
|
|
979
|
-
const contentFromSources = (fileName) => Option.match(HashMap.get(state.snapshot.current.overrides, fileName), {
|
|
980
|
-
onSome: (override) => override,
|
|
981
|
-
onNone: () => Option.match(HashMap.get(state.snapshot.current.files, fileName), {
|
|
982
|
-
onNone: () => void 0,
|
|
983
|
-
onSome: Option.match({
|
|
984
|
-
onNone: () => null,
|
|
985
|
-
onSome: (file) => file.content
|
|
986
|
-
})
|
|
987
|
-
})
|
|
988
|
-
});
|
|
989
|
-
const existsInSources = (fileName) => Option.match(HashMap.get(state.snapshot.current.overrides, fileName), {
|
|
990
|
-
onSome: () => true,
|
|
991
|
-
onNone: () => Option.match(HashMap.get(state.snapshot.current.files, fileName), {
|
|
992
|
-
onNone: () => void 0,
|
|
993
|
-
onSome: Option.isSome
|
|
994
|
-
})
|
|
995
|
-
});
|
|
996
|
-
return {
|
|
997
|
-
readFile: (fileName) => Boolean.match(isBuildInfoFile(fileName), {
|
|
998
|
-
onTrue: () => null,
|
|
999
|
-
onFalse: () => contentFromSources(normalizeFileName$1(fileName))
|
|
1000
|
-
}),
|
|
1001
|
-
fileExists: (fileName) => Boolean.match(isBuildInfoFile(fileName), {
|
|
1002
|
-
onTrue: () => false,
|
|
1003
|
-
onFalse: () => existsInSources(normalizeFileName$1(fileName))
|
|
1004
|
-
}),
|
|
1005
|
-
directoryExists: () => void 0,
|
|
1006
|
-
getAccessibleEntries: () => void 0,
|
|
1007
|
-
realpath: () => void 0
|
|
1008
|
-
};
|
|
1009
|
-
};
|
|
1010
|
-
//#endregion
|
|
1011
|
-
//#region src/ts-compiler.handle.ts
|
|
1012
|
-
const TypeId$1 = Symbol.for("@systemfsoftware/stryker-js-typescript-checker/TSCompiler");
|
|
1013
|
-
const normalizeFileName = (fileName) => fileName.replace(/\\/g, "/");
|
|
1014
|
-
const findSourceMapRegex = /\/\/# sourceMappingURL=(.+)$/m;
|
|
1015
|
-
const getSourceMappingURL = (content) => findSourceMapRegex.exec(content)?.[1];
|
|
1016
|
-
const isString = (value) => typeof value === "string";
|
|
1017
|
-
const isNonEmptyString = (value) => value !== void 0 && value !== "";
|
|
1018
|
-
const relativeSpecifierPattern = /^\.\.?\//;
|
|
1019
|
-
const CLEAN_SPECIFIER_PATTERN = /^["']|["']$/g;
|
|
1020
|
-
const ignoredGraphFileNamePattern = /\.d\.ts$|node_modules/;
|
|
1021
|
-
const TSCompiler = Handle.make()(TypeId$1);
|
|
1022
|
-
TSCompiler.is;
|
|
1023
|
-
const runtimeOf = (self) => TSCompiler.slot(self);
|
|
1024
|
-
const decided = (result) => Result.match(result, {
|
|
1025
|
-
onFailure: (refused) => refused,
|
|
1026
|
-
onSuccess: (decision) => decision
|
|
1027
|
-
});
|
|
1028
|
-
const make$1 = dual(2, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerMake.name)(function* (options, services) {
|
|
1029
|
-
const files = make$2(services.host);
|
|
1030
|
-
const tsconfigFile = normalizeFileName(options.tsconfigFile);
|
|
1031
|
-
const state = yield* SynchronizedRef.make({
|
|
1032
|
-
api: void 0,
|
|
1033
|
-
snapshot: void 0,
|
|
1034
|
-
sourceFiles: HashMap.empty(),
|
|
1035
|
-
nodes: HashMap.empty(),
|
|
1036
|
-
lastMutants: [],
|
|
1037
|
-
lastMutatedFileNames: [],
|
|
1038
|
-
aliases: [],
|
|
1039
|
-
allTSConfigFiles: HashSet.fromIterable([tsconfigFile]),
|
|
1040
|
-
tsconfigFile
|
|
1041
|
-
});
|
|
1042
|
-
return TSCompiler.make({}, {
|
|
1043
|
-
options,
|
|
1044
|
-
host: services.host,
|
|
1045
|
-
pathService: services.pathService,
|
|
1046
|
-
spawner: services.spawner,
|
|
1047
|
-
files,
|
|
1048
|
-
sourceFileSystem: tsFileSystem(files),
|
|
1049
|
-
state
|
|
1050
|
-
});
|
|
1051
|
-
}));
|
|
1052
|
-
const minimumTypeScriptVersion = {
|
|
1053
|
-
major: 7,
|
|
1054
|
-
minor: 0,
|
|
1055
|
-
patch: 0
|
|
1056
|
-
};
|
|
1057
|
-
const versionComponent = (parts, index) => Number.parseInt(parts[index] ?? "0", 10);
|
|
1058
|
-
const splitVersion = (version) => {
|
|
1059
|
-
const parts = version.replace(/[-+][\s\S]*$/, "").split(".");
|
|
1060
|
-
return {
|
|
1061
|
-
major: versionComponent(parts, 0),
|
|
1062
|
-
minor: versionComponent(parts, 1),
|
|
1063
|
-
patch: versionComponent(parts, 2)
|
|
1064
|
-
};
|
|
1065
|
-
};
|
|
1066
|
-
const isNewerOrSame = (left, right) => {
|
|
1067
|
-
return ([
|
|
1068
|
-
left.major - right.major,
|
|
1069
|
-
left.minor - right.minor,
|
|
1070
|
-
left.patch - right.patch
|
|
1071
|
-
].find((difference) => difference !== 0) ?? 0) >= 0;
|
|
1072
|
-
};
|
|
1073
|
-
const isSupportedTypeScriptVersion = (version) => {
|
|
1074
|
-
const parsed = splitVersion(version);
|
|
1075
|
-
return [
|
|
1076
|
-
parsed.major,
|
|
1077
|
-
parsed.minor,
|
|
1078
|
-
parsed.patch
|
|
1079
|
-
].every((part) => !Number.isNaN(part)) && isNewerOrSame(parsed, minimumTypeScriptVersion);
|
|
1080
|
-
};
|
|
1081
|
-
const readTypescriptVersion = Effect.fnUntraced(function* (rt) {
|
|
1082
|
-
const packagePath = yield* rt.pathService.fromFileUrl(new URL(import.meta.resolve("typescript/package.json")));
|
|
1083
|
-
const text = yield* rt.host.readFileString(packagePath);
|
|
1084
|
-
return Result.match(S.decodeResult(S.fromJsonString(S.Struct({ version: S.String })))(text), {
|
|
1085
|
-
onFailure: () => "",
|
|
1086
|
-
onSuccess: (pkg) => pkg.version
|
|
1087
|
-
});
|
|
1088
|
-
});
|
|
1089
|
-
const guardTypescriptVersion = (rt) => Effect.flatMap(readTypescriptVersion(rt).pipe(Effect.orElseSucceed(() => "")), (version) => Boolean.match(isSupportedTypeScriptVersion(version), {
|
|
1090
|
-
onFalse: () => Effect.fail(UnsupportedTypeScriptVersionError.make({ version })),
|
|
1091
|
-
onTrue: () => Effect.void
|
|
1092
|
-
}));
|
|
1093
|
-
const parseTsConfig = (fileName, jsonText) => parseTsconfigText(ParseTsconfigTextCommand.make({ text: jsonText })).pipe(decided, Match.value, Match.tag("TsconfigParsed", ({ document }) => Result.succeed(document)), Match.tag("TsconfigRefused", ({ reason }) => Result.fail(TsConfigParseError.make({
|
|
1094
|
-
file: fileName,
|
|
1095
|
-
reason
|
|
1096
|
-
}))), Match.exhaustive);
|
|
1097
|
-
const tsconfigDeclaresReferences = (fileName, jsonText) => Result.match(parseTsConfig(fileName, jsonText), {
|
|
1098
|
-
onFailure: () => false,
|
|
1099
|
-
onSuccess: (config) => config["references"] !== void 0
|
|
1100
|
-
});
|
|
1101
|
-
const overrideTextOf = (document, buildMode) => decided(overrideTsconfigOptions(OverrideTsconfigOptionsCommand.make({
|
|
1102
|
-
document,
|
|
1103
|
-
buildMode
|
|
1104
|
-
}))).text;
|
|
1105
|
-
const tsConfigReferencesOf = (config) => Option.getOrElse(Option.fromUndefinedOr(config.references), () => []);
|
|
1106
|
-
const referencedProjectsOf = (rt, config, fromDirName) => Arr.map(tsConfigReferencesOf(config), (reference) => {
|
|
1107
|
-
const resolved = rt.pathService.resolve(fromDirName, reference.path);
|
|
1108
|
-
return normalizeFileName(Boolean.match(rt.pathService.basename(resolved).endsWith(".json"), {
|
|
1109
|
-
onTrue: () => resolved,
|
|
1110
|
-
onFalse: () => rt.pathService.join(resolved, "tsconfig.json")
|
|
1111
|
-
}));
|
|
1112
|
-
});
|
|
1113
|
-
const compilerOptionsOf = (config) => Option.getOrElse(Option.fromUndefinedOr(config.compilerOptions), () => ({}));
|
|
1114
|
-
const aliasEntriesOf = (compilerOptions) => Object.entries(Option.getOrElse(S.decodeUnknownOption(PathAliasesSchema)(compilerOptions["paths"]), () => ({})));
|
|
1115
|
-
const pathAliasesOf = (pathService, fileName, config) => aliasEntriesOf(compilerOptionsOf(config)).map(([pattern, targets]) => ({
|
|
1116
|
-
pattern,
|
|
1117
|
-
targets,
|
|
1118
|
-
baseDir: pathService.dirname(fileName)
|
|
1119
|
-
}));
|
|
1120
|
-
const recordTsConfig = (rt, buildMode, walk, fileName, jsonText) => Result.match(parseTsConfig(fileName, jsonText), {
|
|
1121
|
-
onFailure: () => ({
|
|
1122
|
-
...walk,
|
|
1123
|
-
overrides: HashMap.set(walk.overrides, fileName, jsonText)
|
|
1124
|
-
}),
|
|
1125
|
-
onSuccess: (config) => ({
|
|
1126
|
-
overrides: HashMap.set(walk.overrides, fileName, overrideTextOf(config, buildMode)),
|
|
1127
|
-
aliases: [...walk.aliases, ...pathAliasesOf(rt.pathService, fileName, config)],
|
|
1128
|
-
files: Arr.reduce(referencedProjectsOf(rt, config, rt.pathService.dirname(fileName)), walk.files, (files, referenced) => HashSet.add(files, normalizeFileName(referenced))),
|
|
1129
|
-
processed: walk.processed
|
|
1130
|
-
})
|
|
1131
|
-
});
|
|
1132
|
-
const enqueueUnseen = (walk, pending) => Arr.reduce(Arr.fromIterable(walk.files), pending, (queued, fileName) => Boolean.match(HashSet.has(walk.processed, fileName) || queued.includes(fileName), {
|
|
1133
|
-
onTrue: () => queued,
|
|
1134
|
-
onFalse: () => [...queued, fileName]
|
|
1135
|
-
}));
|
|
1136
|
-
const readTsConfigText = (rt, preRead, fileName) => Option.match(HashMap.get(preRead, fileName), {
|
|
1137
|
-
onNone: () => rt.host.readFileString(fileName).pipe(Effect.mapError(() => TsConfigNotFoundError.make({ file: fileName }))),
|
|
1138
|
-
onSome: (jsonText) => Effect.succeed(jsonText)
|
|
1139
|
-
});
|
|
1140
|
-
const walkTsConfigs = (rt, buildMode, walk, pending, preRead) => Option.match(Option.filter(Arr.head(pending), (fileName) => !HashSet.has(walk.processed, fileName)), {
|
|
1141
|
-
onNone: () => Effect.succeed(walk),
|
|
1142
|
-
onSome: (fileName) => Effect.flatMap(readTsConfigText(rt, preRead, fileName), (jsonText) => {
|
|
1143
|
-
const recorded = recordTsConfig(rt, buildMode, {
|
|
1144
|
-
...walk,
|
|
1145
|
-
processed: HashSet.add(walk.processed, fileName)
|
|
1146
|
-
}, fileName, jsonText);
|
|
1147
|
-
return walkTsConfigs(rt, buildMode, recorded, enqueueUnseen(recorded, pending.slice(1)), preRead);
|
|
1148
|
-
})
|
|
1149
|
-
});
|
|
1150
|
-
const snapshotOf = (state) => Effect.fromOption(Option.fromUndefinedOr(state.snapshot), () => CompilerFailed.make({ reason: "not-initialized" }));
|
|
1151
|
-
const projectsOf = (rt) => Effect.flatMap(SynchronizedRef.get(rt.state), (state) => Effect.flatMap(snapshotOf(state), (snapshot) => {
|
|
1152
|
-
const projects = snapshot.getProjects();
|
|
1153
|
-
return Boolean.match(projects.length === 0, {
|
|
1154
|
-
onTrue: () => Effect.fail(CompilerFailed.make({
|
|
1155
|
-
reason: "no-projects",
|
|
1156
|
-
subject: state.tsconfigFile
|
|
1157
|
-
})),
|
|
1158
|
-
onFalse: () => Effect.succeed(projects)
|
|
1159
|
-
});
|
|
1160
|
-
}));
|
|
1161
|
-
const programsOf = (rt) => Effect.map(projectsOf(rt), (projects) => Arr.map(projects, (project) => project.program));
|
|
1162
|
-
const resolveFileName = (rt, fileName) => normalizeFileName(rt.pathService.resolve(fileName));
|
|
1163
|
-
const nodeSpanOf = (node) => ({
|
|
1164
|
-
start: node.getStart(node.getSourceFile()),
|
|
1165
|
-
end: node.end
|
|
1166
|
-
});
|
|
1167
|
-
const childrenOf = (node) => {
|
|
1168
|
-
const children = [];
|
|
1169
|
-
node.forEachChild((child) => {
|
|
1170
|
-
children.push(child);
|
|
1171
|
-
});
|
|
1172
|
-
return children;
|
|
1173
|
-
};
|
|
1174
|
-
const spanEqualsOf = (node, start, end) => {
|
|
1175
|
-
const span = nodeSpanOf(node);
|
|
1176
|
-
return span.start === start && span.end === end;
|
|
1177
|
-
};
|
|
1178
|
-
const spanContainsOf = (node, start, end) => {
|
|
1179
|
-
const span = nodeSpanOf(node);
|
|
1180
|
-
return span.start <= start && end <= span.end;
|
|
1181
|
-
};
|
|
1182
|
-
const hasSpanOf = (node, start, end) => {
|
|
1183
|
-
if (spanEqualsOf(node, start, end)) return true;
|
|
1184
|
-
return Arr.some(childrenOf(node), (child) => Boolean.and(spanContainsOf(child, start, end), hasSpanOf(child, start, end)));
|
|
1185
|
-
};
|
|
1186
|
-
const parseHeldOf = (sourceFile, file, mutant) => Option.match(offsetAt(file.lineStarts, mutant.location.start), {
|
|
1187
|
-
onNone: () => true,
|
|
1188
|
-
onSome: (start) => hasSpanOf(sourceFile, start, start + mutant.replacement.length)
|
|
1189
|
-
});
|
|
1190
|
-
const mutatedSourceFileOf = (rt, fileName) => Effect.flatMap(projectsOf(rt), (projects) => Effect.map(projectOfFile(projects, fileName), (owned) => Option.map(owned, (found) => found.sourceFile)));
|
|
1191
|
-
const parseHeldAfterSpliceOf = (rt, file, mutant, fileName) => Effect.gen(function* () {
|
|
1192
|
-
const sourceFile = yield* mutatedSourceFileOf(rt, fileName);
|
|
1193
|
-
return Option.match(Option.all([file, sourceFile]), {
|
|
1194
|
-
onNone: () => true,
|
|
1195
|
-
onSome: ([spliced, mutated]) => parseHeldOf(mutated, spliced, mutant)
|
|
1196
|
-
});
|
|
1197
|
-
});
|
|
1198
|
-
const parenthesizedSpliceOf = (rt, mutant, fileName, changedFiles) => Effect.flatMap(applyMutant(rt, mutant, "(" + mutant.replacement + ")"), () => refreshSnapshot(rt, changedFiles));
|
|
1199
|
-
const applyMutant = (rt, mutant, replacement) => Effect.flatMap(getFile(rt.files, resolveFileName(rt, mutant.fileName)), (file) => Effect.flatMap(Effect.fromOption(file, () => CompilerFailed.make({
|
|
1200
|
-
reason: "file-not-in-project",
|
|
1201
|
-
subject: mutant.fileName
|
|
1202
|
-
})), () => Effect.mapError(mutateFile(rt.files, resolveFileName(rt, mutant.fileName), {
|
|
1203
|
-
location: mutant.location,
|
|
1204
|
-
replacement
|
|
1205
|
-
}), (error) => Match.value(error).pipe(Match.tag("HybridFileNotFoundError", () => CompilerFailed.make({
|
|
1206
|
-
reason: "file-not-in-project",
|
|
1207
|
-
subject: mutant.fileName
|
|
1208
|
-
})), Match.tag("HybridMutantOutsideFileError", () => CompilerFailed.make({
|
|
1209
|
-
reason: "mutant-outside-file",
|
|
1210
|
-
subject: mutant.fileName
|
|
1211
|
-
})), Match.exhaustive))));
|
|
1212
|
-
const resetMutatedFiles = (rt, mutants) => Effect.forEach(mutants, (mutant) => resetFile(rt.files, resolveFileName(rt, mutant.fileName)), { discard: true });
|
|
1213
|
-
const hasOpenSnapshot = (state) => state.api !== void 0 && state.snapshot !== void 0;
|
|
1214
|
-
const updateSnapshot = Effect.fnUntraced(function* (rt, initialized, changedFiles) {
|
|
1215
|
-
const next = yield* Effect.promise(() => initialized.api.updateSnapshot({
|
|
1216
|
-
openProjects: Array.from(initialized.allTSConfigFiles),
|
|
1217
|
-
fileChanges: { changed: [...changedFiles] }
|
|
1218
|
-
}));
|
|
1219
|
-
yield* Effect.promise(() => initialized.snapshot.dispose());
|
|
1220
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1221
|
-
...prev,
|
|
1222
|
-
snapshot: next
|
|
1223
|
-
}));
|
|
1224
|
-
});
|
|
1225
|
-
const refreshSnapshot = (rt, changedFiles) => Effect.flatMap(SynchronizedRef.get(rt.state), (current) => Option.match(Option.liftPredicate(current, hasOpenSnapshot), {
|
|
1226
|
-
onNone: () => Effect.void,
|
|
1227
|
-
onSome: (initialized) => updateSnapshot(rt, initialized, changedFiles)
|
|
1228
|
-
}));
|
|
1229
|
-
const annotateDiagnosticSample = (diagnostics) => Boolean.match(diagnostics.length === 0, {
|
|
1230
|
-
onTrue: () => Effect.void,
|
|
1231
|
-
onFalse: () => Effect.annotateCurrentSpan({ "typescript.diagnostics.sample": Arr.map(Arr.take(diagnostics, 10), (diagnostic) => diagnostic.fileName + ":" + diagnostic.code + ": " + diagnostic.text).join("; ") })
|
|
1232
|
-
});
|
|
1233
|
-
const carriesModuleSpecifier = (statement) => statement.kind === SyntaxKind.ImportDeclaration || statement.kind === SyntaxKind.ExportDeclaration;
|
|
1234
|
-
const moduleSpecifierOf = (statement, sourceFile) => Boolean.match(carriesModuleSpecifier(statement), {
|
|
1235
|
-
onTrue: () => {
|
|
1236
|
-
const children = [];
|
|
1237
|
-
statement.forEachChild((child) => {
|
|
1238
|
-
children.push(child);
|
|
1239
|
-
});
|
|
1240
|
-
return Option.map(Arr.findLast(children, (child) => child.kind === SyntaxKind.StringLiteral), (literal) => literal.getText(sourceFile));
|
|
1241
|
-
},
|
|
1242
|
-
onFalse: () => Option.none()
|
|
1243
|
-
});
|
|
1244
|
-
const keepSome = (option) => Option.match(option, {
|
|
1245
|
-
onNone: () => Result.failVoid,
|
|
1246
|
-
onSome: Result.succeed
|
|
1247
|
-
});
|
|
1248
|
-
const importsOf = (sourceFile) => [
|
|
1249
|
-
...Arr.filterMap(sourceFile.statements, (statement) => keepSome(moduleSpecifierOf(statement, sourceFile))),
|
|
1250
|
-
...Arr.map(sourceFile.referencedFiles, (reference) => reference.fileName),
|
|
1251
|
-
...Arr.map(sourceFile.typeReferenceDirectives, (reference) => reference.fileName)
|
|
1252
|
-
];
|
|
1253
|
-
const aliasTargetPaths = (pathService, aliases, specifier) => Arr.flatMap(aliases, (alias) => {
|
|
1254
|
-
const command = CaptureAliasSpecifierCommand.make({
|
|
1255
|
-
pattern: alias.pattern,
|
|
1256
|
-
specifier
|
|
1257
|
-
});
|
|
1258
|
-
const decision = decided(captureAliasSpecifier(command));
|
|
1259
|
-
return Match.value(decision).pipe(Match.tag("AliasSpecifierCaptured", ({ capture }) => Arr.map(alias.targets, (target) => normalizeFileName(pathService.resolve(alias.baseDir, target.replace("*", capture))))), Match.tag("AliasSpecifierUnmatched", () => []), Match.exhaustive);
|
|
1260
|
-
});
|
|
1261
|
-
const candidatePathsOf = (pathService, resolved) => {
|
|
1262
|
-
const command = PlanResolutionCandidatesCommand.make({
|
|
1263
|
-
resolved,
|
|
1264
|
-
extension: pathService.extname(resolved)
|
|
1265
|
-
});
|
|
1266
|
-
const decision = decided(planResolutionCandidates(command));
|
|
1267
|
-
return Match.value(decision).pipe(Match.tag("ExtensionNamedPath", ({ candidates }) => candidates), Match.tag("ExtensionlessPath", ({ candidates }) => candidates), Match.exhaustive);
|
|
1268
|
-
};
|
|
1269
|
-
const existingCandidateOf = (pathService, sourceFiles, resolved) => Arr.findFirst(candidatePathsOf(pathService, resolved), (candidate) => HashMap.has(sourceFiles, candidate));
|
|
1270
|
-
const resolveAliasedSpecifier = (pathService, aliases, sourceFiles, specifier) => Option.firstSomeOf(Arr.map(aliasTargetPaths(pathService, aliases, specifier), (target) => existingCandidateOf(pathService, sourceFiles, target)));
|
|
1271
|
-
const resolveSpecifier = (pathService, aliases, sourceFiles, fileName, specifier) => {
|
|
1272
|
-
const cleaned = specifier.replace(CLEAN_SPECIFIER_PATTERN, "");
|
|
1273
|
-
return Boolean.match(relativeSpecifierPattern.test(cleaned), {
|
|
1274
|
-
onFalse: () => resolveAliasedSpecifier(pathService, aliases, sourceFiles, cleaned),
|
|
1275
|
-
onTrue: () => Option.filter(existingCandidateOf(pathService, sourceFiles, normalizeFileName(pathService.resolve(pathService.dirname(fileName), cleaned))), (candidate) => candidate !== "")
|
|
1276
|
-
});
|
|
1277
|
-
};
|
|
1278
|
-
const readFileText = (rt, fileName) => Option.liftPredicate(rt.sourceFileSystem.readFile?.(fileName), isString);
|
|
1279
|
-
const onlySourceOf = (sources) => Boolean.match(sources.length !== 1, {
|
|
1280
|
-
onTrue: () => Option.none(),
|
|
1281
|
-
onFalse: () => Option.fromUndefinedOr(sources[0])
|
|
1282
|
-
});
|
|
1283
|
-
const sourceMapSourcesOf = (rt, content) => Result.match(S.decodeResult(S.fromJsonString(S.Struct({ sources: S.Array(S.String) })))(content), {
|
|
1284
|
-
onFailure: () => Option.none(),
|
|
1285
|
-
onSuccess: (map) => onlySourceOf(map.sources)
|
|
1286
|
-
});
|
|
1287
|
-
const sourceMappedFileName = (rt, declarationFileName) => Option.flatMap(Option.flatMap(readFileText(rt, declarationFileName), (content) => Option.liftPredicate(getSourceMappingURL(content), isNonEmptyString)), (reference) => {
|
|
1288
|
-
const sourceMapFileName = normalizeFileName(rt.pathService.resolve(rt.pathService.dirname(declarationFileName), reference));
|
|
1289
|
-
return Option.flatMap(Option.flatMap(readFileText(rt, sourceMapFileName), (content) => sourceMapSourcesOf(rt, content)), (source) => Option.some(normalizeFileName(rt.pathService.resolve(rt.pathService.dirname(sourceMapFileName), source))));
|
|
1290
|
-
});
|
|
1291
|
-
const resolveTSInputFile = (rt, dependencyFileName) => Boolean.match(dependencyFileName.endsWith(".d.ts"), {
|
|
1292
|
-
onFalse: () => dependencyFileName,
|
|
1293
|
-
onTrue: () => Option.getOrElse(sourceMappedFileName(rt, dependencyFileName), () => dependencyFileName)
|
|
1294
|
-
});
|
|
1295
|
-
const registeredEntry = (fileName) => Boolean.match(ignoredGraphFileNamePattern.test(fileName), {
|
|
1296
|
-
onTrue: () => Option.none(),
|
|
1297
|
-
onFalse: () => {
|
|
1298
|
-
const normalized = normalizeFileName(fileName);
|
|
1299
|
-
return Option.some([normalized, {
|
|
1300
|
-
fileName: normalized,
|
|
1301
|
-
imports: HashSet.empty()
|
|
1302
|
-
}]);
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
const registerOwners = (owners, program, fileNames) => Arr.reduce(fileNames, owners, (accumulated, fileName) => {
|
|
1306
|
-
const normalized = normalizeFileName(fileName);
|
|
1307
|
-
return Boolean.match(HashMap.has(accumulated, normalized), {
|
|
1308
|
-
onTrue: () => accumulated,
|
|
1309
|
-
onFalse: () => HashMap.set(accumulated, normalized, program)
|
|
1310
|
-
});
|
|
1311
|
-
});
|
|
1312
|
-
const sourceFileIn = (program, fileName) => Effect.map(Effect.promise(() => program.getSourceFile(fileName)), (found) => Option.fromUndefinedOr(found));
|
|
1313
|
-
const sourceFileOf = (programs, fileName) => Option.match(Arr.head(programs), {
|
|
1314
|
-
onNone: () => Effect.succeed(Option.none()),
|
|
1315
|
-
onSome: (program) => Effect.filterOrElse(sourceFileIn(program, fileName), Option.isSome, () => sourceFileOf(Arr.drop(programs, 1), fileName))
|
|
1316
|
-
});
|
|
1317
|
-
const linkImport = (rt, aliases, sourceFiles, fileName, specifier) => Option.match(Option.filter(resolveSpecifier(rt.pathService, aliases, sourceFiles, fileName, specifier), (resolved) => resolved !== ""), {
|
|
1318
|
-
onNone: () => sourceFiles,
|
|
1319
|
-
onSome: (resolved) => {
|
|
1320
|
-
const imported = resolveTSInputFile(rt, resolved);
|
|
1321
|
-
return Boolean.match(HashMap.has(sourceFiles, imported), {
|
|
1322
|
-
onFalse: () => sourceFiles,
|
|
1323
|
-
onTrue: () => Option.match(HashMap.get(sourceFiles, fileName), {
|
|
1324
|
-
onNone: () => sourceFiles,
|
|
1325
|
-
onSome: (entry) => HashMap.set(sourceFiles, fileName, {
|
|
1326
|
-
...entry,
|
|
1327
|
-
imports: HashSet.add(entry.imports, imported)
|
|
1328
|
-
})
|
|
1329
|
-
})
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
|
-
const ownedSourceFileOf = (owners, programs, fileName) => Option.match(HashMap.get(owners, fileName), {
|
|
1334
|
-
onNone: () => sourceFileOf(programs, fileName),
|
|
1335
|
-
onSome: (owner) => Effect.filterOrElse(sourceFileIn(owner, fileName), Option.isSome, () => sourceFileOf(programs, fileName))
|
|
1336
|
-
});
|
|
1337
|
-
const buildGraph = Effect.fnUntraced(function* (rt, programs) {
|
|
1338
|
-
const state = yield* SynchronizedRef.get(rt.state);
|
|
1339
|
-
const owners = yield* Effect.reduce(programs, () => HashMap.empty(), (accumulated, program) => Effect.map(Effect.promise(() => program.getSourceFileNames()), (fileNames) => registerOwners(accumulated, program, fileNames)));
|
|
1340
|
-
const registered = owners.pipe(Arr.fromIterable, Arr.filterMap(([fileName]) => keepSome(registeredEntry(fileName))), HashMap.fromIterable);
|
|
1341
|
-
const linked = yield* Effect.reduce(Arr.fromIterable(registered), () => registered, (sourceFiles, [fileName]) => Effect.map(ownedSourceFileOf(owners, programs, fileName), (found) => Option.match(found, {
|
|
1342
|
-
onNone: () => sourceFiles,
|
|
1343
|
-
onSome: (sourceFile) => Arr.reduce(importsOf(sourceFile), sourceFiles, (accumulated, specifier) => linkImport(rt, state.aliases, accumulated, fileName, specifier))
|
|
1344
|
-
})));
|
|
1345
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1346
|
-
...prev,
|
|
1347
|
-
sourceFiles: linked
|
|
1348
|
-
}));
|
|
1349
|
-
});
|
|
1350
|
-
const fileNode = (fileName, children, parents = []) => ({
|
|
1351
|
-
children,
|
|
1352
|
-
fileName,
|
|
1353
|
-
parents
|
|
1354
|
-
});
|
|
1355
|
-
const importersOf = (sourceFiles) => Arr.reduce(Arr.fromIterable(sourceFiles), HashMap.empty(), (accumulated, [importer, file]) => Arr.reduce(Arr.fromIterable(file.imports), accumulated, (into, imported) => HashMap.set(into, imported, [...Option.getOrElse(HashMap.get(into, imported), () => []), importer])));
|
|
1356
|
-
const graphNodesOf = (sourceFiles) => {
|
|
1357
|
-
const entries = Arr.fromIterable(sourceFiles);
|
|
1358
|
-
const importers = importersOf(sourceFiles);
|
|
1359
|
-
const leaves = HashMap.fromIterable(Arr.map(entries, ([fileName]) => [fileName, fileNode(fileName, [])]));
|
|
1360
|
-
return HashMap.fromIterable(Arr.map(entries, ([fileName, file]) => [fileName, fileNode(fileName, Arr.filterMap(Arr.fromIterable(file.imports), (imported) => keepSome(HashMap.get(leaves, imported))), Arr.filterMap(Option.getOrElse(HashMap.get(importers, fileName), () => []), (importer) => keepSome(HashMap.get(leaves, importer))))]));
|
|
1361
|
-
};
|
|
1362
|
-
const nodesOf = (rt) => Effect.flatMap(SynchronizedRef.get(rt.state), (state) => Boolean.match(HashMap.isEmpty(state.nodes), {
|
|
1363
|
-
onFalse: () => Effect.succeed(state.nodes),
|
|
1364
|
-
onTrue: () => {
|
|
1365
|
-
const nodes = graphNodesOf(state.sourceFiles);
|
|
1366
|
-
return Effect.as(SynchronizedRef.update(rt.state, (prev) => ({
|
|
1367
|
-
...prev,
|
|
1368
|
-
nodes
|
|
1369
|
-
})), nodes);
|
|
1370
|
-
}
|
|
1371
|
-
}));
|
|
1372
|
-
const init = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerInit.name)(function* (self) {
|
|
1373
|
-
const rt = runtimeOf(self);
|
|
1374
|
-
yield* guardTypescriptVersion(rt);
|
|
1375
|
-
const tsconfigFile = normalizeFileName(rt.pathService.resolve(rt.options.tsconfigFile));
|
|
1376
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1377
|
-
...prev,
|
|
1378
|
-
tsconfigFile,
|
|
1379
|
-
allTSConfigFiles: HashSet.fromIterable([tsconfigFile])
|
|
1380
|
-
}));
|
|
1381
|
-
const tsconfigText = yield* Effect.mapError(rt.host.readFileString(tsconfigFile), () => TsConfigNotFoundError.make({ file: tsconfigFile }));
|
|
1382
|
-
const buildMode = tsconfigDeclaresReferences(tsconfigFile, tsconfigText);
|
|
1383
|
-
const walk = yield* walkTsConfigs(rt, buildMode, {
|
|
1384
|
-
files: HashSet.fromIterable([tsconfigFile]),
|
|
1385
|
-
overrides: HashMap.empty(),
|
|
1386
|
-
processed: HashSet.empty(),
|
|
1387
|
-
aliases: []
|
|
1388
|
-
}, [tsconfigFile], HashMap.fromIterable([[tsconfigFile, tsconfigText]]));
|
|
1389
|
-
yield* setOverrides(rt.files, walk.overrides);
|
|
1390
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1391
|
-
...prev,
|
|
1392
|
-
allTSConfigFiles: walk.files,
|
|
1393
|
-
aliases: walk.aliases
|
|
1394
|
-
}));
|
|
1395
|
-
const api = new API({ fs: rt.sourceFileSystem });
|
|
1396
|
-
const snapshot = yield* Effect.promise(() => api.updateSnapshot({ openProjects: Array.from(walk.files) }));
|
|
1397
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1398
|
-
...prev,
|
|
1399
|
-
api,
|
|
1400
|
-
snapshot
|
|
1401
|
-
}));
|
|
1402
|
-
const programs = yield* programsOf(rt);
|
|
1403
|
-
yield* buildGraph(rt, programs);
|
|
1404
|
-
return yield* dryRunDiagnostics(programs);
|
|
1405
|
-
});
|
|
1406
|
-
const semanticDiagnosticsOf = Effect.fnUntraced(function* (program, affectedFileNames) {
|
|
1407
|
-
const presentFileNames = yield* Effect.promise(() => program.getSourceFileNames());
|
|
1408
|
-
const request = RequestAffectedFilesCommand.make({
|
|
1409
|
-
affectedFileNames: Arr.fromIterable(affectedFileNames),
|
|
1410
|
-
presentFileNames: [...presentFileNames]
|
|
1411
|
-
});
|
|
1412
|
-
const requested = decided(requestAffectedFiles(request));
|
|
1413
|
-
const batchPlan = PlanDiagnosticBatchesCommand.make({ fileNames: Match.value(requested).pipe(Match.tag("AffectedFilesRequested", ({ fileNames }) => fileNames), Match.tag("NoAffectedFileRequested", () => []), Match.exhaustive) });
|
|
1414
|
-
const batches = decided(planDiagnosticBatches(batchPlan));
|
|
1415
|
-
const plannedBatches = Match.value(batches).pipe(Match.tag("DiagnosticBatchesPlanned", ({ batches }) => batches), Match.tag("NoDiagnosticBatches", () => []), Match.exhaustive);
|
|
1416
|
-
return [...yield* Effect.forEach(plannedBatches, (batch) => Effect.map(Effect.promise(() => Promise.all(Arr.map(batch, (fileName) => program.getSemanticDiagnostics(fileName)))), (perFile) => Arr.flatten(perFile)), { concurrency: 1 })].flat();
|
|
1417
|
-
});
|
|
1418
|
-
const programWideDiagnosticsOf = (program) => Effect.map(Effect.promise(() => Promise.all([program.getConfigFileParsingDiagnostics(), program.getProgramDiagnostics()])), ([config, programWide]) => [...config, ...programWide]);
|
|
1419
|
-
const wholeProgramDiagnosticsOf = (program) => Effect.all([programWideDiagnosticsOf(program), Effect.promise(() => program.getSemanticDiagnostics())], { concurrency: 2 }).pipe(Effect.map(([programWide, semantic]) => [...semantic, ...programWide]));
|
|
1420
|
-
const dryRunDiagnostics = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerDryRun.name)(function* (programs) {
|
|
1421
|
-
yield* Effect.annotateCurrentSpan({ "typescript.projects.count": programs.length });
|
|
1422
|
-
return errorDiagnosticsOf(Arr.flatten(yield* Effect.forEach(programs, (program) => wholeProgramDiagnosticsOf(program))));
|
|
1423
|
-
});
|
|
1424
|
-
const errorDiagnosticsOf = (diagnostics) => Arr.filter(diagnostics, (diagnostic) => diagnostic.category === DiagnosticCategory.Error);
|
|
1425
|
-
const projectOfFile = (projects, fileName) => Option.match(Arr.head(projects), {
|
|
1426
|
-
onNone: () => Effect.succeedNone,
|
|
1427
|
-
onSome: (project) => Effect.flatMap(Effect.promise(() => project.program.getSourceFile(fileName)), (sourceFile) => Option.match(Option.fromUndefinedOr(sourceFile), {
|
|
1428
|
-
onNone: () => projectOfFile(Arr.drop(projects, 1), fileName),
|
|
1429
|
-
onSome: (found) => Effect.succeedSome({
|
|
1430
|
-
project,
|
|
1431
|
-
sourceFile: found
|
|
1432
|
-
})
|
|
1433
|
-
}))
|
|
1434
|
-
});
|
|
1435
|
-
const isAmbientGlobal = (sourceFile, statement) => isModuleDeclaration(statement) ? Boolean.and((statement.modifierFlags & ModifierFlags.Ambient) !== 0, statement.name.getText(sourceFile) === "global") : false;
|
|
1436
|
-
const declaresGlobalScope = (sourceFile) => Boolean.or(sourceFile.externalModuleIndicator === void 0, Arr.some(sourceFile.statements, (statement) => isAmbientGlobal(sourceFile, statement)));
|
|
1437
|
-
const importerErrorsOf = (projects, fileNames) => Effect.map(Effect.forEach(projects, (project) => semanticDiagnosticsOf(project.program, fileNames), { concurrency: 1 }), (perProject) => errorDiagnosticsOf(Arr.flatten(perProject)));
|
|
1438
|
-
const wholeProgramErrorsOf = (projects) => Effect.map(Effect.forEach(projects, (project) => wholeProgramDiagnosticsOf(project.program), { concurrency: 1 }), (perProject) => errorDiagnosticsOf(Arr.flatten(perProject)));
|
|
1439
|
-
const ownErrorsOf = (owned, fileName) => Effect.map(Effect.promise(() => owned.project.program.getSemanticDiagnostics(fileName)), errorDiagnosticsOf);
|
|
1440
|
-
const affectedFileNamesOf = (state, mutatedFileNames) => {
|
|
1441
|
-
const command = TraceAffectedFilesCommand.make({
|
|
1442
|
-
importsByFile: Object.fromEntries(Arr.map(Arr.fromIterable(state.sourceFiles), ([fileName, entry]) => [fileName, Arr.fromIterable(entry.imports)])),
|
|
1443
|
-
mutatedFileNames: [...mutatedFileNames]
|
|
1444
|
-
});
|
|
1445
|
-
const affected = decided(traceAffectedFiles(command));
|
|
1446
|
-
return HashSet.fromIterable(Arr.map(affected, (affectedFile) => affectedFile.fileName));
|
|
1447
|
-
};
|
|
1448
|
-
const importerErrorsOfMutant = (state, projects, mutant, fileName) => Effect.map(importerErrorsOf(projects, affectedFileNamesOf(state, [fileName])), (diagnostics) => ({
|
|
1449
|
-
mutantId: mutant.id,
|
|
1450
|
-
diagnostics
|
|
1451
|
-
}));
|
|
1452
|
-
const beyondOwnErrorsOf = (state, projects, mutant, owned, fileName) => Boolean.match(declaresGlobalScope(owned.sourceFile), {
|
|
1453
|
-
onTrue: () => Effect.map(wholeProgramErrorsOf(projects), (diagnostics) => ({
|
|
1454
|
-
mutantId: mutant.id,
|
|
1455
|
-
diagnostics
|
|
1456
|
-
})),
|
|
1457
|
-
onFalse: () => importerErrorsOfMutant(state, projects, mutant, fileName)
|
|
1458
|
-
});
|
|
1459
|
-
const checkedIn = (state, projects, mutant, owned, fileName) => Effect.flatMap(ownErrorsOf(owned, fileName), (own) => Boolean.match(own.length > 0, {
|
|
1460
|
-
onTrue: () => Effect.succeed({
|
|
1461
|
-
mutantId: mutant.id,
|
|
1462
|
-
diagnostics: own
|
|
1463
|
-
}),
|
|
1464
|
-
onFalse: () => beyondOwnErrorsOf(state, projects, mutant, owned, fileName)
|
|
1465
|
-
}));
|
|
1466
|
-
const checkOne = (rt, state, mutant, previousMutants) => Effect.gen(function* () {
|
|
1467
|
-
yield* resetMutatedFiles(rt, previousMutants);
|
|
1468
|
-
const fileName = resolveFileName(rt, mutant.fileName);
|
|
1469
|
-
const previousFileNames = Arr.map(previousMutants, (previous) => resolveFileName(rt, previous.fileName));
|
|
1470
|
-
const changedFiles = Arr.dedupe([...previousFileNames, fileName]);
|
|
1471
|
-
const file = yield* getFile(rt.files, fileName);
|
|
1472
|
-
yield* applyMutant(rt, mutant, mutant.replacement);
|
|
1473
|
-
yield* refreshSnapshot(rt, changedFiles);
|
|
1474
|
-
const held = yield* parseHeldAfterSpliceOf(rt, file, mutant, fileName);
|
|
1475
|
-
yield* Boolean.match(held, {
|
|
1476
|
-
onTrue: () => Effect.void,
|
|
1477
|
-
onFalse: () => parenthesizedSpliceOf(rt, mutant, fileName, changedFiles)
|
|
1478
|
-
});
|
|
1479
|
-
const projects = yield* projectsOf(rt);
|
|
1480
|
-
const owned = yield* projectOfFile(projects, fileName);
|
|
1481
|
-
return yield* Option.match(owned, {
|
|
1482
|
-
onNone: () => Effect.succeed({
|
|
1483
|
-
mutantId: mutant.id,
|
|
1484
|
-
diagnostics: []
|
|
1485
|
-
}),
|
|
1486
|
-
onSome: (found) => checkedIn(state, projects, mutant, found, fileName)
|
|
1487
|
-
});
|
|
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
|
-
});
|
|
1547
|
-
const check = dual(2, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerCheck.name)(function* (self, mutants) {
|
|
1548
|
-
const rt = runtimeOf(self);
|
|
1549
|
-
yield* Effect.annotateCurrentSpan({
|
|
1550
|
-
"stryker.mutants.count": mutants.length,
|
|
1551
|
-
"stryker.mutants.ids": Arr.map(mutants, (mutant) => mutant.id).join(",")
|
|
1552
|
-
});
|
|
1553
|
-
const state = yield* SynchronizedRef.get(rt.state);
|
|
1554
|
-
yield* resetMutatedFiles(rt, state.lastMutants);
|
|
1555
|
-
const batchFileNames = Arr.dedupe(Arr.map(mutants, (mutant) => resolveFileName(rt, mutant.fileName)));
|
|
1556
|
-
yield* refreshSnapshot(rt, Arr.dedupe([...state.lastMutatedFileNames, ...batchFileNames]));
|
|
1557
|
-
const accumulated = yield* Effect.reduce(mutants, () => ({
|
|
1558
|
-
previous: Option.none(),
|
|
1559
|
-
results: []
|
|
1560
|
-
}), (previous, mutant) => Effect.map(checkOne(rt, state, mutant, Option.toArray(previous.previous)), (result) => ({
|
|
1561
|
-
previous: Option.some(mutant),
|
|
1562
|
-
results: [...previous.results, result]
|
|
1563
|
-
})));
|
|
1564
|
-
const checked = yield* classifyBatchTce(rt, state.tsconfigFile, mutants, accumulated.results);
|
|
1565
|
-
yield* SynchronizedRef.update(rt.state, (prev) => ({
|
|
1566
|
-
...prev,
|
|
1567
|
-
lastMutants: [...mutants],
|
|
1568
|
-
lastMutatedFileNames: batchFileNames
|
|
1569
|
-
}));
|
|
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;
|
|
1573
|
-
yield* Effect.annotateCurrentSpan({
|
|
1574
|
-
"typescript.diagnostics.count": Arr.reduce(checked, 0, (total, entry) => total + entry.diagnostics.length),
|
|
1575
|
-
"typescript.compile_errors.count": failed.length,
|
|
1576
|
-
"typescript.tce.equivalent_to_original.count": equivalentToOriginal,
|
|
1577
|
-
"typescript.tce.duplicate_at_site.count": duplicateAtSite
|
|
1578
|
-
});
|
|
1579
|
-
yield* annotateDiagnosticSample(Arr.flatten(Arr.map(failed, (entry) => entry.diagnostics)));
|
|
1580
|
-
return checked;
|
|
1581
|
-
}));
|
|
1582
|
-
const nodes = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerNodes.name)(function* (self) {
|
|
1583
|
-
return yield* self.pipe(runtimeOf, nodesOf);
|
|
1584
|
-
});
|
|
1585
|
-
const groupedMutants = (mutants) => Arr.map(decided(groupMutants(GroupMutantsCommand.make({ mutants: [...mutants] }))), (group) => group.ids);
|
|
1586
|
-
const groups = (mutants) => Effect.sync(() => groupedMutants(mutants)).pipe(Effect.withSpan(SpanTaxonomy.Spans.typescriptCheckerCompilerGroups.name));
|
|
1587
|
-
const getLineAndCharacterOfPosition = dual(3, Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerLineAndCharacter.name)(function* (self, fileName, position) {
|
|
1588
|
-
const rt = runtimeOf(self);
|
|
1589
|
-
const programs = yield* programsOf(rt).pipe(Effect.orElseSucceed(() => []));
|
|
1590
|
-
const found = yield* sourceFileOf(programs, fileName);
|
|
1591
|
-
return Option.getOrUndefined(Option.map(found, (sourceFile) => sourceFile.getLineAndCharacterOfPosition(position)));
|
|
1592
|
-
}));
|
|
1593
|
-
const severityOf = (category) => Match.value(category).pipe(Match.when(DiagnosticCategory.Warning, () => "warning"), Match.when(DiagnosticCategory.Error, () => "error"), Match.when(DiagnosticCategory.Suggestion, () => "suggestion"), Match.orElse(() => "message"));
|
|
1594
|
-
const renderPosition = (fileName, at) => Option.match(Option.fromUndefinedOr(at), {
|
|
1595
|
-
onNone: () => fileName + "(1,1): ",
|
|
1596
|
-
onSome: (position) => fileName + "(" + (position.line + 1) + "," + (position.character + 1) + "): "
|
|
1597
|
-
});
|
|
1598
|
-
const positionOf = (self, diagnostic) => Option.match(Option.filter(Option.fromUndefinedOr(diagnostic.fileName), (fileName) => fileName !== ""), {
|
|
1599
|
-
onNone: () => Effect.succeed(""),
|
|
1600
|
-
onSome: (fileName) => getLineAndCharacterOfPosition(self, fileName, diagnostic.pos).pipe(Effect.orElseSucceed(() => void 0), Effect.map((at) => renderPosition(fileName, at)))
|
|
1601
|
-
});
|
|
1602
|
-
const describedOf = (self, diagnostic) => Effect.map(positionOf(self, diagnostic), (position) => DiagnosticLine.make({
|
|
1603
|
-
position,
|
|
1604
|
-
severity: severityOf(diagnostic.category),
|
|
1605
|
-
code: diagnostic.code,
|
|
1606
|
-
text: diagnostic.text,
|
|
1607
|
-
...diagnostic.fileName === void 0 ? {} : { fileName: diagnostic.fileName }
|
|
1608
|
-
}));
|
|
1609
|
-
const describeDiagnostics = dual(2, (self, diagnostics) => Effect.forEach(diagnostics, (diagnostic) => describedOf(self, diagnostic)));
|
|
1610
|
-
const CLOSE_GRACE = "1 second";
|
|
1611
|
-
const close = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerClose.name)(function* (self) {
|
|
1612
|
-
const rt = runtimeOf(self);
|
|
1613
|
-
const state = yield* SynchronizedRef.getAndUpdate(rt.state, (prev) => ({
|
|
1614
|
-
...prev,
|
|
1615
|
-
snapshot: void 0,
|
|
1616
|
-
api: void 0
|
|
1617
|
-
}));
|
|
1618
|
-
const released = yield* Option.match(Option.fromUndefinedOr(state.api), {
|
|
1619
|
-
onNone: () => Effect.succeed(true),
|
|
1620
|
-
onSome: (api) => Effect.tryPromise(() => api.close()).pipe(Effect.timeoutOption(CLOSE_GRACE), Effect.tapError((error) => Effect.annotateCurrentSpan("typescript.server.close_error", error.message)), Effect.match({
|
|
1621
|
-
onFailure: () => false,
|
|
1622
|
-
onSuccess: Option.isSome
|
|
1623
|
-
}))
|
|
1624
|
-
});
|
|
1625
|
-
yield* Effect.annotateCurrentSpan("typescript.server.released", released);
|
|
1626
|
-
});
|
|
1627
|
-
//#endregion
|
|
1628
|
-
//#region src/ts-compiler.service.ts
|
|
1629
|
-
var TypeScriptCompiler = class extends Context.Service()("@systemfsoftware/stryker-js-typescript-checker/ts-compiler.service/TypeScriptCompiler") {};
|
|
1630
|
-
//#endregion
|
|
1631
80
|
//#region src/Checker.cell.ts
|
|
1632
81
|
const refuse$1 = (options) => Checker.CheckerFailed.make({
|
|
1633
82
|
checkerName: "typescript",
|
|
1634
83
|
mutantIds: options.mutantIds,
|
|
1635
84
|
cause: Option.getOrElse(Option.map(ErrorText.errorTextOf(options.cause), (rendered) => rendered.text), () => "")
|
|
1636
85
|
});
|
|
1637
|
-
const verdictsOf = (
|
|
86
|
+
const verdictsOf = (checked) => Arr.map(checked, (entry) => MutantVerdict.make({
|
|
1638
87
|
id: entry.mutantId,
|
|
1639
|
-
diagnostics: [...diagnostics],
|
|
88
|
+
diagnostics: [...entry.diagnostics],
|
|
1640
89
|
...tceFieldOf(entry.tce)
|
|
1641
|
-
}))
|
|
1642
|
-
const checkCell = Sandwich.named(SpanTaxonomy.Spans.typescriptCheckerCheckMutants.name)((command) => Effect.flatMap(TypeScriptCompiler, (compiler) => Effect.
|
|
90
|
+
}));
|
|
91
|
+
const checkCell = Sandwich.named(SpanTaxonomy.Spans.typescriptCheckerCheckMutants.name)((command) => Effect.flatMap(TypeScriptCompiler, (compiler) => Effect.map(check(compiler, [...command.mutants]), (checked) => CheckMutantsInput.make({
|
|
1643
92
|
mutants: [...command.mutants],
|
|
1644
|
-
verdicts: [...
|
|
1645
|
-
})))
|
|
93
|
+
verdicts: [...verdictsOf(checked)]
|
|
94
|
+
}))).pipe(Effect.mapError((cause) => refuse$1({
|
|
1646
95
|
mutantIds: command.mutants.map((mutant) => mutant.id),
|
|
1647
96
|
cause
|
|
1648
97
|
})))).decide(checkMutants).write({
|
|
@@ -1661,7 +110,7 @@ const scopedOf = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerCompilerScoped.na
|
|
|
1661
110
|
const host = yield* FileSystem.FileSystem;
|
|
1662
111
|
const pathService = yield* Path.Path;
|
|
1663
112
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
1664
|
-
const compiler = yield* make$
|
|
113
|
+
const compiler = yield* make$2(spec, {
|
|
1665
114
|
host,
|
|
1666
115
|
pathService,
|
|
1667
116
|
spawner
|
|
@@ -1677,9 +126,13 @@ const TSCompilerResource = Blueprint.make()(TypeId).steps({
|
|
|
1677
126
|
scoped: scopedOf
|
|
1678
127
|
}
|
|
1679
128
|
});
|
|
1680
|
-
const make = (options) => TSCompilerResource.of(options);
|
|
129
|
+
const make$1 = (options) => TSCompilerResource.of(options);
|
|
1681
130
|
//#endregion
|
|
1682
|
-
//#region src/
|
|
131
|
+
//#region src/typescript-checker-runtime.ts
|
|
132
|
+
var typescript_checker_runtime_exports = /* @__PURE__ */ __exportAll({
|
|
133
|
+
layer: () => layer,
|
|
134
|
+
make: () => make
|
|
135
|
+
});
|
|
1683
136
|
const refuse = (options) => Checker.CheckerFailed.make({
|
|
1684
137
|
checkerName: "typescript",
|
|
1685
138
|
mutantIds: options.mutantIds,
|
|
@@ -1693,7 +146,7 @@ const toCheckResult = (event) => Match.value(event).pipe(Match.tag("MutantPassed
|
|
|
1693
146
|
reason: ignored.reason
|
|
1694
147
|
})), Match.exhaustive);
|
|
1695
148
|
const checkResultsOf = (events) => HashMap.fromIterable(Arr.map(events, (event) => [event.id, toCheckResult(event)]));
|
|
1696
|
-
const
|
|
149
|
+
const make = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerRuntimeMakeChecker.name)(function* (compiler) {
|
|
1697
150
|
const verify = Cell.provideContext(checkCell, Context.make(TypeScriptCompiler, compiler));
|
|
1698
151
|
const createErrorText = (errors) => Effect.map(describeDiagnostics(compiler, errors), (diagnostics) => diagnostics.map((entry) => entry.rendered).join("\n"));
|
|
1699
152
|
const service = {
|
|
@@ -1708,17 +161,25 @@ const makeChecker = Effect.fn(SpanTaxonomy.Spans.typescriptCheckerRuntimeMakeChe
|
|
|
1708
161
|
})), Effect.flatMap(Effect.fail))
|
|
1709
162
|
}))),
|
|
1710
163
|
check: (mutants) => verify.run(CheckMutantsCommand.make({ mutants: [...mutants] })).pipe(Effect.map((events) => checkResultsOf(events)), Effect.withSpan(SpanTaxonomy.Spans.typescriptCheckerCheck.name, { attributes: { "stryker.mutants.count": mutants.length } })),
|
|
1711
|
-
group: (mutants) => groups([...mutants])
|
|
164
|
+
group: (mutants) => groups([...mutants]),
|
|
165
|
+
digest: programDigest(compiler).pipe(Effect.mapError((cause) => refuse({
|
|
166
|
+
mutantIds: [],
|
|
167
|
+
cause
|
|
168
|
+
})))
|
|
1712
169
|
};
|
|
1713
170
|
yield* service.init;
|
|
1714
171
|
return service;
|
|
1715
172
|
});
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
173
|
+
const layer = (options) => Layer.effect(CheckerRuntime, Effect.gen(function* () {
|
|
174
|
+
const compiler = yield* TypeScriptCompiler;
|
|
175
|
+
const checker = yield* make(compiler).pipe(Effect.catchCause((cause) => Effect.fail(cause)), Effect.cached);
|
|
176
|
+
const scope = yield* Effect.scope;
|
|
177
|
+
const typeQuery = yield* Effect.cached(Layer.buildWithScope(layer$1, scope).pipe(Effect.map(Context.get(TypeQuery.TypeQuery))));
|
|
178
|
+
return CheckerRuntime.of({
|
|
179
|
+
checker,
|
|
180
|
+
capabilities: { typeQuery: TypeQuery.TypeQueryVersion.literals },
|
|
181
|
+
typeQuery
|
|
182
|
+
});
|
|
183
|
+
})).pipe(Layer.provideMerge(make$1(options).layer(TypeScriptCompiler)));
|
|
1723
184
|
//#endregion
|
|
1724
|
-
export { CheckerRuntime, TypeScriptCompiler, nodes };
|
|
185
|
+
export { CheckerRuntime, typescript_checker_runtime_exports as TypeScriptCheckerRuntime, TypeScriptCompiler, nodes };
|