@systemfsoftware/stryker-js-instrumenter 0.2.0 → 1.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 CHANGED
@@ -1,5 +1,49 @@
1
1
  # @systemfsoftware/stryker-js-instrumenter
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Parse, transform and mutant-placement failures now carry a message naming the
8
+ file and what went wrong, and their `cause` survives being written to JSON — so
9
+ a failure that crossed a process boundary no longer arrives blank.
10
+
11
+ Every error tag is now qualified, which is what makes two identically named
12
+ errors from different packages distinguishable.
13
+
14
+ `MutantPlacementFailed` is removed; it was a second name for `PlacementFailed`
15
+ and had no constructor anywhere. Match `PlacementFailed`.
16
+
17
+ - svelte is now an optional peer dependency. Install it to mutate .svelte components; without it, every other file type is unaffected. A copy of the Svelte compiler used to be bundled in, which pinned whichever version was present when the package was built and made the compiler version check read the wrong answer.
18
+
19
+ ### Patch Changes
20
+
21
+ - The instrumenter no longer depends on `weapon-regex`, a Scala library compiled to JavaScript that is no longer maintained. It is replaced by `@eslint-community/regexpp`, which has no dependencies of its own. Regular expression mutants are unchanged, so no action is required.
22
+
23
+ - The shared helpers package is gone. Nothing installs it any more, and the
24
+ handful of helpers worth sharing now live in the plugin contract next to the
25
+ types they serve:
26
+
27
+ - `strykerReportBugUrl`, `normalizeFileName`, `propertyPath`, `errorToString`
28
+ and `isErrnoException` from `@systemfsoftware/stryker-js-plugin-api/core`
29
+ - `noopLogger` from `@systemfsoftware/stryker-js-plugin-api/logging`
30
+ - `testFilesProvided` from `@systemfsoftware/stryker-js-plugin-api/test-runner`
31
+
32
+ If you imported any of those, change the specifier. Everything else it exported
33
+ had no consumer and is removed: use `Predicate.isNotNullish` from Effect in place
34
+ of `notEmpty`, and `RegExp.escape` in place of `escapeRegExp`.
35
+
36
+ - These packages no longer install dependencies they never imported, so installing them pulls less into your tree.
37
+
38
+ `tslib` is gone from all six. The mutation runner additionally stops installing `lodash.groupby`, `semver` and `source-map`, and the command line interface stops installing `@effect/platform-node-shared`. Nothing exported changes.
39
+
40
+ - When a mutant cannot be placed, the reported error now links to this project's issue tracker rather than the upstream StrykerJS one.
41
+
42
+ - Published packages no longer carry build artifacts left over from earlier builds. One package was shipping about a megabyte of bundled test-runner internals this way.
43
+
44
+ - Updated dependencies:
45
+ - @systemfsoftware/stryker-js-plugin-api@3.0.0
46
+
3
47
  ## 0.2.0
4
48
 
5
49
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,98 +1,13 @@
1
- import { BaseContext, Injector, PluginKind } from "@systemfsoftware/stryker-js-plugin-api/plugin";
2
- import { FileDescription, Mutant, MutateDescription, Position } from "@systemfsoftware/stryker-js-plugin-api/core";
1
+ import { FileDescription, Mutant } from "@systemfsoftware/stryker-js-plugin-api/core";
2
+ import * as S from "effect/Schema";
3
3
  import { types } from "@babel/core";
4
- import { I } from "@systemfsoftware/stryker-js-util";
5
- import { Ignorer } from "@systemfsoftware/stryker-js-plugin-api/ignore";
6
- import { Logger } from "@systemfsoftware/stryker-js-plugin-api/logging";
7
- //#region src/instrumenter-tokens.d.ts
8
- declare const instrumenterTokens: Readonly<{
9
- readonly createParser: 'instrumenterCreateParser';
10
- readonly print: 'instrumenterPrint';
11
- readonly transform: 'instrumenterTransform';
12
- }>;
13
- //#endregion
14
- //#region src/syntax/index.d.ts
15
- declare enum AstFormat {
16
- Html = "html",
17
- JS = "js",
18
- TS = "ts",
19
- Tsx = "tsx",
20
- Svelte = "svelte"
21
- }
22
- interface AstByFormat {
23
- [AstFormat.Html]: HtmlAst;
24
- [AstFormat.JS]: JSAst;
25
- [AstFormat.TS]: TSAst;
26
- [AstFormat.Tsx]: TsxAst;
27
- [AstFormat.Svelte]: SvelteAst;
28
- }
29
- type Ast = HtmlAst | JSAst | SvelteAst | TSAst | TsxAst;
30
- type ScriptAst = JSAst | TSAst | TsxAst;
31
- interface BaseAst {
32
- originFileName: string;
33
- rawContent: string;
34
- root: Ast['root'];
35
- offset?: Position;
36
- }
37
- /**
38
- * Represents an Html AST.
39
- */
40
- interface HtmlAst extends BaseAst {
41
- format: AstFormat.Html;
42
- root: HtmlRootNode;
43
- }
44
- /**
45
- * Represents a TS AST
46
- */
47
- interface JSAst extends BaseAst {
48
- format: AstFormat.JS;
49
- root: types.File;
50
- }
51
- /**
52
- * Represents a TS AST
53
- */
54
- interface TSAst extends BaseAst {
55
- format: AstFormat.TS;
56
- root: types.File;
57
- }
58
- /**
59
- * Represents a TS AST
60
- */
61
- interface TsxAst extends BaseAst {
62
- format: AstFormat.Tsx;
63
- root: types.File;
64
- }
65
- /**
66
- * Represents a Svelte AST
67
- */
68
- interface SvelteAst extends BaseAst {
69
- format: AstFormat.Svelte;
70
- root: SvelteRootNode;
71
- }
72
- /**
73
- * Represents the root node of an HTML AST
74
- * We've taken a shortcut here, instead of representing the entire AST, we're only representing the script tags.
75
- * We might need to expand this in the future if we would ever want to support mutating the actual HTML (rather than only the JS/TS)
76
- */
77
- interface HtmlRootNode {
78
- scripts: ScriptAst[];
79
- }
80
- interface SvelteRootNode {
81
- moduleScript?: TemplateScript;
82
- additionalScripts: TemplateScript[];
83
- }
84
- /**
85
- * Represents a svelte script or binding expression
86
- * We've taken a shortcut here, instead of representing the entire AST, we're only representing the script tags and expression bindings.
87
- */
88
- interface TemplateScript {
89
- ast: ScriptAst;
90
- range: Range;
91
- isExpression: boolean;
92
- }
93
- interface Range {
94
- start: number;
95
- end: number;
4
+ import "effect/Option";
5
+ import { IgnorerService } from "@systemfsoftware/stryker-js-plugin-api/ignore";
6
+ import * as Effect from "effect/Effect";
7
+ //#region src/file.d.ts
8
+ interface File extends FileDescription {
9
+ name: string;
10
+ content: string;
96
11
  }
97
12
  //#endregion
98
13
  //#region src/parsers/parser-options.d.ts
@@ -100,108 +15,6 @@ interface ParserOptions {
100
15
  plugins: unknown[] | null;
101
16
  }
102
17
  //#endregion
103
- //#region src/parsers/create-parser.d.ts
104
- declare function createParser(parserOptions: ParserOptions): {
105
- <T extends AstFormat>(code: string, fileName: string, formatOverride: T): Promise<AstByFormat[T]>;
106
- (code: string, fileName: string, formatOverride?: AstFormat): Promise<Ast>;
107
- };
108
- //#endregion
109
- //#region src/printers/index.d.ts
110
- declare function print(file: Ast): string;
111
- //#endregion
112
- //#region src/mutant.d.ts
113
- interface Mutable {
114
- mutatorName: string;
115
- ignoreReason?: string | undefined;
116
- replacement: types.Node;
117
- }
118
- declare class Mutant$1 implements Mutable {
119
- readonly id: string;
120
- readonly fileName: string;
121
- readonly original: types.Node;
122
- readonly offset: Position;
123
- readonly replacementCode: string;
124
- readonly replacement: types.Node;
125
- readonly mutatorName: string;
126
- readonly ignoreReason: string | undefined;
127
- constructor(id: string, fileName: string, original: types.Node, specs: Mutable, offset?: Position);
128
- toApiMutant(): Mutant;
129
- /**
130
- * Applies the mutant in (a copy of) the AST, without changing provided AST.
131
- * Can the tree itself (in which case the replacement is returned),
132
- * or can be nested in the given tree.
133
- *
134
- * Returns a plain node rather than the argument's own type: whether the
135
- * replacement fits a given position is the placer's claim, and the placer
136
- * checks it with a Babel predicate. A generic return would have to assert it
137
- * here, where nothing can check it.
138
- * @param originalTree The original node, which will be treated as readonly
139
- */
140
- applied(originalTree: types.Node): types.Node;
141
- }
142
- //#endregion
143
- //#region src/transformers/mutant-collector.d.ts
144
- declare class MutantCollector {
145
- private readonly _mutants;
146
- get mutants(): readonly Mutant$1[];
147
- /**
148
- * Adds mutants to the internal mutant list.
149
- * @param fileName file name that houses the mutant
150
- * @param original The node to mutate
151
- * @param mutables the named node mutation to be added
152
- * @param contextPath the context where these mutants are found and should be placed as close by as possible
153
- * @param offset offset of mutant nodes
154
- * @returns The mutant (for testability)
155
- */
156
- collect(fileName: string, original: types.Node, mutable: Mutable, offset?: Position): Mutant$1;
157
- hasPlacedMutants(fileName: string): boolean;
158
- }
159
- //#endregion
160
- //#region src/mutators/mutator-options.d.ts
161
- interface MutatorOptions {
162
- excludedMutations: string[];
163
- noHeader?: boolean;
164
- }
165
- //#endregion
166
- //#region src/transformers/transformer-options.d.ts
167
- interface TransformerOptions extends MutatorOptions {
168
- ignorers: Ignorer[];
169
- }
170
- //#endregion
171
- //#region src/transformers/transformer.d.ts
172
- /**
173
- * Transform the AST by generating mutants and placing them in the AST.
174
- * Supports all AST formats supported by Stryker.
175
- * @param ast The Abstract Syntax Tree
176
- * @param mutantCollector the mutant collector that will be used to register and administer mutants
177
- * @param transformerContext the options used during transforming
178
- */
179
- declare function transform(ast: Ast, mutantCollector: I<MutantCollector>, transformerContext: Omit<TransformerContext, 'transform'>): void;
180
- type AstTransformer<T extends AstFormat> = (ast: AstByFormat[T], mutantCollector: I<MutantCollector>, context: TransformerContext) => void;
181
- interface TransformerContext {
182
- transform: AstTransformer<AstFormat>;
183
- options: TransformerOptions;
184
- mutateDescription: MutateDescription;
185
- logger: Logger;
186
- }
187
- //#endregion
188
- //#region src/create-instrumenter.d.ts
189
- interface InstrumenterContext extends BaseContext {
190
- [instrumenterTokens.createParser]: typeof createParser;
191
- [instrumenterTokens.print]: typeof print;
192
- [instrumenterTokens.transform]: typeof transform;
193
- }
194
- declare function createInstrumenter(injector: Injector<BaseContext>): Instrumenter;
195
- declare namespace createInstrumenter {
196
- var inject: ["$injector"];
197
- }
198
- //#endregion
199
- //#region src/file.d.ts
200
- interface File extends FileDescription {
201
- name: string;
202
- content: string;
203
- }
204
- //#endregion
205
18
  //#region src/disable-type-checks.d.ts
206
19
  /**
207
20
  * Disables TypeScript type checking for a single file by inserting `// @ts-nocheck` commands.
@@ -212,8 +25,11 @@ interface File extends FileDescription {
212
25
  */
213
26
  declare function disableTypeChecks(file: File, options: ParserOptions): Promise<File>;
214
27
  //#endregion
28
+ //#region src/frameworks/angular-ignorer.d.ts
29
+ declare const angularIgnorer: IgnorerService;
30
+ //#endregion
215
31
  //#region src/frameworks/index.d.ts
216
- declare const strykerPlugins: import("@systemfsoftware/stryker-js-plugin-api/plugin").ClassPlugin<PluginKind.Ignore, []>[];
32
+ declare const strykerPlugins: readonly unknown[];
217
33
  declare const frameworkPluginsFileUrl: string;
218
34
  //#endregion
219
35
  //#region src/instrument-result.d.ts
@@ -222,25 +38,33 @@ interface InstrumentResult {
222
38
  mutants: readonly Mutant[];
223
39
  }
224
40
  //#endregion
41
+ //#region src/mutators/mutator-options.d.ts
42
+ interface MutatorOptions {
43
+ excludedMutations: string[];
44
+ noHeader?: boolean;
45
+ }
46
+ //#endregion
47
+ //#region src/transformers/transformer-options.d.ts
48
+ interface TransformerOptions extends MutatorOptions {
49
+ ignorers: IgnorerService[];
50
+ }
51
+ //#endregion
225
52
  //#region src/instrumenter-options.d.ts
226
53
  interface InstrumenterOptions extends ParserOptions, TransformerOptions {}
227
54
  //#endregion
228
- //#region src/instrumenter.d.ts
229
- /**
230
- * The instrumenter is responsible for
231
- * * Generating mutants based on source files
232
- * * Instrumenting the source code with the mutants placed in `mutant switches`.
233
- * * Adding mutant coverage expressions in the source code.
234
- * @see https://github.com/stryker-mutator/stryker-js/issues/1514
235
- */
236
- declare class Instrumenter {
237
- private readonly logger;
238
- private readonly _createParser;
239
- private readonly _print;
240
- private readonly _transform;
241
- static inject: ["logger", "instrumenterCreateParser", "instrumenterPrint", "instrumenterTransform"];
242
- constructor(logger: Logger, _createParser?: typeof createParser, _print?: typeof print, _transform?: typeof transform);
243
- instrument(files: readonly File[], options: InstrumenterOptions): Promise<InstrumentResult>;
55
+ //#region src/instrument-error.schema.d.ts
56
+ declare const InstrumentError_base: S.Class<InstrumentError, S.TaggedStruct<"InstrumentError", {
57
+ readonly message: S.String;
58
+ readonly cause: S.Defect;
59
+ }>, import("effect/Cause").YieldableError>;
60
+ declare class InstrumentError extends InstrumentError_base {
61
+ get message(): string;
244
62
  }
245
63
  //#endregion
246
- export { File, InstrumentResult, Instrumenter, InstrumenterContext, InstrumenterOptions, type ParserOptions, createInstrumenter, disableTypeChecks, frameworkPluginsFileUrl, strykerPlugins };
64
+ //#region src/instrumenter.d.ts
65
+ declare const instrument: (files: readonly File[], options: InstrumenterOptions) => Effect.Effect<{
66
+ files: File[];
67
+ mutants: import("@systemfsoftware/stryker-js-plugin-api/core").Mutant[];
68
+ }, InstrumentError, never>;
69
+ //#endregion
70
+ export { File, InstrumentResult, InstrumenterOptions, type ParserOptions, angularIgnorer, disableTypeChecks, frameworkPluginsFileUrl, instrument, strykerPlugins };