@mutineerjs/mutineer 0.2.4 → 0.3.2
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/README.md +48 -42
- package/dist/bin/mutineer.js +0 -0
- package/dist/mutators/__tests__/operator.spec.js +169 -0
- package/dist/mutators/__tests__/registry.spec.js +6 -0
- package/dist/mutators/__tests__/return-value.spec.js +239 -0
- package/dist/mutators/__tests__/utils.spec.js +68 -1
- package/dist/mutators/operator.d.ts +25 -0
- package/dist/mutators/operator.js +50 -0
- package/dist/mutators/registry.d.ts +6 -28
- package/dist/mutators/registry.js +14 -66
- package/dist/mutators/return-value.d.ts +39 -0
- package/dist/mutators/return-value.js +104 -0
- package/dist/mutators/utils.d.ts +21 -0
- package/dist/mutators/utils.js +44 -27
- package/dist/runner/__tests__/pool-executor.spec.js +2 -4
- package/dist/runner/__tests__/variants.spec.js +3 -1
- package/dist/runner/discover.js +2 -1
- package/dist/runner/jest/__tests__/adapter.spec.js +1 -1
- package/dist/runner/jest/__tests__/pool.spec.js +5 -6
- package/dist/runner/jest/__tests__/worker-runtime.spec.js +2 -2
- package/dist/runner/jest/adapter.js +1 -1
- package/dist/runner/jest/pool.d.ts +1 -1
- package/dist/runner/jest/pool.js +6 -6
- package/dist/runner/jest/worker.mjs +1 -1
- package/dist/runner/pool-executor.js +1 -1
- package/dist/runner/shared/__tests__/redirect-state.spec.js +3 -3
- package/dist/runner/shared/index.d.ts +1 -1
- package/dist/runner/shared/index.js +1 -1
- package/dist/runner/shared/redirect-state.d.ts +2 -2
- package/dist/runner/shared/redirect-state.js +4 -4
- package/dist/runner/types.d.ts +1 -1
- package/dist/runner/vitest/__tests__/adapter.spec.js +1 -1
- package/dist/runner/vitest/__tests__/pool.spec.js +1 -1
- package/dist/runner/vitest/__tests__/redirect-loader.spec.js +83 -1
- package/dist/runner/vitest/__tests__/worker-runtime.spec.js +84 -0
- package/dist/runner/vitest/adapter.js +1 -1
- package/dist/runner/vitest/index.d.ts +0 -1
- package/dist/runner/vitest/index.js +0 -1
- package/dist/runner/vitest/pool.d.ts +1 -1
- package/dist/runner/vitest/pool.js +7 -7
- package/dist/runner/vitest/redirect-loader.d.ts +1 -1
- package/dist/runner/vitest/redirect-loader.js +1 -1
- package/dist/runner/vitest/worker-runtime.js +3 -3
- package/dist/runner/vitest/worker.mjs +1 -1
- package/dist/utils/__tests__/coverage.spec.js +167 -0
- package/dist/utils/__tests__/progress.spec.js +96 -0
- package/package.json +71 -22
- package/dist/admin/assets/index-B7nXq-e7.js +0 -32
- package/dist/admin/assets/index-B7nXq-e7.js.map +0 -1
- package/dist/admin/assets/index-BDQLkBUE.js +0 -32
- package/dist/admin/assets/index-BDQLkBUE.js.map +0 -1
- package/dist/admin/assets/index-DVkP-Tc7.css +0 -1
- package/dist/admin/index.html +0 -13
- package/dist/admin/server/admin.d.ts +0 -6
- package/dist/admin/server/admin.js +0 -234
- package/dist/bin/mutate-vitest.d.ts +0 -2
- package/dist/bin/mutate-vitest.js +0 -90
- package/dist/plugin/viteMutate.d.ts +0 -15
- package/dist/plugin/viteMutate.js +0 -52
- package/dist/plugin/vitest.setup.d.ts +0 -47
- package/dist/plugin/vitest.setup.js +0 -118
- package/dist/plugin/withVitest.d.ts +0 -13
- package/dist/plugin/withVitest.js +0 -30
- package/dist/runner/__tests__/orchestrator.spec.js +0 -55
- package/dist/runner/adapters/__tests__/jest.spec.js +0 -88
- package/dist/runner/adapters/__tests__/vitest-worker-runtime.spec.d.ts +0 -1
- package/dist/runner/adapters/__tests__/vitest-worker-runtime.spec.js +0 -59
- package/dist/runner/adapters/__tests__/vitest.spec.d.ts +0 -1
- package/dist/runner/adapters/__tests__/vitest.spec.js +0 -118
- package/dist/runner/adapters/index.d.ts +0 -10
- package/dist/runner/adapters/index.js +0 -9
- package/dist/runner/adapters/jest/__tests__/index.spec.d.ts +0 -1
- package/dist/runner/adapters/jest/__tests__/index.spec.js +0 -88
- package/dist/runner/adapters/jest/index.d.ts +0 -24
- package/dist/runner/adapters/jest/index.js +0 -216
- package/dist/runner/adapters/jest/worker-runtime.d.ts +0 -37
- package/dist/runner/adapters/jest/worker-runtime.js +0 -171
- package/dist/runner/adapters/jest-worker-runtime.d.ts +0 -37
- package/dist/runner/adapters/jest-worker-runtime.js +0 -171
- package/dist/runner/adapters/jest.d.ts +0 -24
- package/dist/runner/adapters/jest.js +0 -216
- package/dist/runner/adapters/types.d.ts +0 -89
- package/dist/runner/adapters/types.js +0 -8
- package/dist/runner/adapters/vitest/__tests__/index.spec.d.ts +0 -1
- package/dist/runner/adapters/vitest/__tests__/index.spec.js +0 -118
- package/dist/runner/adapters/vitest/__tests__/worker-runtime.spec.d.ts +0 -1
- package/dist/runner/adapters/vitest/__tests__/worker-runtime.spec.js +0 -59
- package/dist/runner/adapters/vitest/index.d.ts +0 -33
- package/dist/runner/adapters/vitest/index.js +0 -267
- package/dist/runner/adapters/vitest/worker-runtime.d.ts +0 -25
- package/dist/runner/adapters/vitest/worker-runtime.js +0 -118
- package/dist/runner/adapters/vitest-worker-runtime.d.ts +0 -25
- package/dist/runner/adapters/vitest-worker-runtime.js +0 -118
- package/dist/runner/adapters/vitest.d.ts +0 -33
- package/dist/runner/adapters/vitest.js +0 -267
- package/dist/runner/pool/__tests__/index.spec.d.ts +0 -1
- package/dist/runner/pool/__tests__/index.spec.js +0 -83
- package/dist/runner/pool/__tests__/pool-plugin.spec.d.ts +0 -1
- package/dist/runner/pool/__tests__/pool-plugin.spec.js +0 -59
- package/dist/runner/pool/__tests__/pool-redirect-loader.spec.d.ts +0 -1
- package/dist/runner/pool/__tests__/pool-redirect-loader.spec.js +0 -78
- package/dist/runner/pool/index.d.ts +0 -8
- package/dist/runner/pool/index.js +0 -9
- package/dist/runner/pool/jest/pool.d.ts +0 -52
- package/dist/runner/pool/jest/pool.js +0 -309
- package/dist/runner/pool/jest/worker.d.mts +0 -1
- package/dist/runner/pool/jest/worker.mjs +0 -60
- package/dist/runner/pool/jest-pool.d.ts +0 -52
- package/dist/runner/pool/jest-pool.js +0 -309
- package/dist/runner/pool/jest-worker.d.mts +0 -1
- package/dist/runner/pool/jest-worker.mjs +0 -60
- package/dist/runner/pool/plugin.d.ts +0 -18
- package/dist/runner/pool/plugin.js +0 -60
- package/dist/runner/pool/pool-plugin.d.ts +0 -18
- package/dist/runner/pool/pool-plugin.js +0 -60
- package/dist/runner/pool/pool-redirect-loader.d.ts +0 -19
- package/dist/runner/pool/pool-redirect-loader.js +0 -116
- package/dist/runner/pool/pool-redirect-loader.mjs +0 -146
- package/dist/runner/pool/redirect-loader.d.ts +0 -19
- package/dist/runner/pool/redirect-loader.js +0 -116
- package/dist/runner/pool/vitest/pool.d.ts +0 -70
- package/dist/runner/pool/vitest/pool.js +0 -376
- package/dist/runner/pool/vitest/worker.d.mts +0 -15
- package/dist/runner/pool/vitest/worker.mjs +0 -96
- package/dist/runner/pool/vitest-worker.d.mts +0 -15
- package/dist/runner/pool/vitest-worker.mjs +0 -96
- package/dist/runner/shared-module-redirect.d.ts +0 -56
- package/dist/runner/shared-module-redirect.js +0 -84
- package/dist/types/api.d.ts +0 -20
- package/dist/types/api.js +0 -1
- /package/dist/{runner/__tests__/orchestrator.spec.d.ts → mutators/__tests__/operator.spec.d.ts} +0 -0
- /package/dist/{runner/adapters/__tests__/jest.spec.d.ts → mutators/__tests__/return-value.spec.d.ts} +0 -0
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared module redirection utilities for both Jest and Vitest runners.
|
|
3
|
-
*
|
|
4
|
-
* This module provides common functionality for intercepting module resolution
|
|
5
|
-
* and redirecting imports to mutated versions of source files.
|
|
6
|
-
*/
|
|
7
|
-
import * as path from 'node:path';
|
|
8
|
-
import * as fs from 'node:fs';
|
|
9
|
-
/**
|
|
10
|
-
* Get the path where a mutant should be written.
|
|
11
|
-
* Mutants are stored in __mutineer__/ subdirectories alongside source files.
|
|
12
|
-
*
|
|
13
|
-
* @param originalFile - The original source file path
|
|
14
|
-
* @param mutantId - The mutation ID
|
|
15
|
-
* @returns Path to the mutant file in __mutineer__/ directory
|
|
16
|
-
*/
|
|
17
|
-
export function getMutantFilePath(originalFile, mutantId) {
|
|
18
|
-
const dir = path.dirname(originalFile);
|
|
19
|
-
const ext = path.extname(originalFile);
|
|
20
|
-
const basename = path.basename(originalFile, ext);
|
|
21
|
-
const mutineerDir = path.join(dir, '__mutineer__');
|
|
22
|
-
if (!fs.existsSync(mutineerDir)) {
|
|
23
|
-
fs.mkdirSync(mutineerDir, { recursive: true });
|
|
24
|
-
}
|
|
25
|
-
const idMatch = mutantId.match(/#(\d+)$/);
|
|
26
|
-
const suffix = idMatch ? idMatch[1] : mutantId.replace(/[^a-zA-Z0-9]/g, '_').slice(0, 20);
|
|
27
|
-
return path.join(mutineerDir, `${basename}_${suffix}${ext}`);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get the current redirect configuration from globalThis.
|
|
31
|
-
* Used by both Jest and Vitest to check if a module should be redirected.
|
|
32
|
-
*
|
|
33
|
-
* @returns Object with normalized from/to paths, or null if no redirect is active
|
|
34
|
-
*/
|
|
35
|
-
export function getActiveRedirect() {
|
|
36
|
-
const redirect = globalThis.__mutineer_redirect__;
|
|
37
|
-
if (!redirect?.from || !redirect?.to) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
from: path.resolve(redirect.from),
|
|
42
|
-
to: redirect.to,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Initialize the global redirect state.
|
|
47
|
-
* Should be called once when the runtime starts.
|
|
48
|
-
*/
|
|
49
|
-
export function initializeRedirect() {
|
|
50
|
-
globalThis.__mutineer_redirect__ = { from: null, to: null };
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Set a redirect for module resolution.
|
|
54
|
-
*
|
|
55
|
-
* @param originalFile - The original source file (absolute path)
|
|
56
|
-
* @param mutantPath - The mutant file path
|
|
57
|
-
*/
|
|
58
|
-
export function setRedirect(originalFile, mutantPath) {
|
|
59
|
-
globalThis.__mutineer_redirect__ = {
|
|
60
|
-
from: path.resolve(originalFile),
|
|
61
|
-
to: mutantPath,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Clear the current redirect.
|
|
66
|
-
*/
|
|
67
|
-
export function clearRedirect() {
|
|
68
|
-
globalThis.__mutineer_redirect__ = { from: null, to: null };
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Check if a given file path matches the current redirect source.
|
|
72
|
-
* Handles path normalization and extension matching.
|
|
73
|
-
*
|
|
74
|
-
* @param filePath - The file path to check
|
|
75
|
-
* @returns true if this file should be redirected
|
|
76
|
-
*/
|
|
77
|
-
export function shouldRedirectPath(filePath) {
|
|
78
|
-
const redirect = getActiveRedirect();
|
|
79
|
-
if (!redirect) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
const normalized = path.resolve(filePath);
|
|
83
|
-
return normalized === redirect.from;
|
|
84
|
-
}
|
package/dist/types/api.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { MutineerConfig } from './config.js';
|
|
2
|
-
import type { MutantResult } from './mutant.js';
|
|
3
|
-
export type { MutantCacheEntry, MutantResult, MutantStatus } from './mutant.js';
|
|
4
|
-
export type DiffLineType = 'context' | 'add' | 'remove';
|
|
5
|
-
export interface DiffLine {
|
|
6
|
-
readonly type: DiffLineType;
|
|
7
|
-
readonly leftNumber?: number;
|
|
8
|
-
readonly rightNumber?: number;
|
|
9
|
-
readonly text: string;
|
|
10
|
-
}
|
|
11
|
-
export interface DiffResponse {
|
|
12
|
-
readonly lines: readonly DiffLine[];
|
|
13
|
-
}
|
|
14
|
-
export interface ApiResponse {
|
|
15
|
-
readonly mutants: readonly MutantResult[];
|
|
16
|
-
}
|
|
17
|
-
export interface ConfigResponse {
|
|
18
|
-
readonly config?: MutineerConfig;
|
|
19
|
-
readonly error?: string;
|
|
20
|
-
}
|
package/dist/types/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
/package/dist/{runner/__tests__/orchestrator.spec.d.ts → mutators/__tests__/operator.spec.d.ts}
RENAMED
|
File without changes
|
/package/dist/{runner/adapters/__tests__/jest.spec.d.ts → mutators/__tests__/return-value.spec.d.ts}
RENAMED
|
File without changes
|