@under18dev/veritas-mutation-adapter 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +12 -2
- package/dist/detect.d.ts +27 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +143 -0
- package/dist/detect.js.map +1 -0
- package/dist/import.d.ts +72 -0
- package/dist/import.d.ts.map +1 -0
- package/dist/import.js +164 -0
- package/dist/import.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/run.d.ts +49 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +303 -0
- package/dist/run.js.map +1 -0
- package/dist/schema.d.ts +126 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +50 -0
- package/dist/schema.js.map +1 -0
- package/dist/vitest-config.d.ts +14 -0
- package/dist/vitest-config.d.ts.map +1 -0
- package/dist/vitest-config.js +66 -0
- package/dist/vitest-config.js.map +1 -0
- package/package.json +26 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
const CONFIG_NAMES = ['vitest', 'vite'].flatMap((base) => ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'].map((ext) => `${base}.config.${ext}`));
|
|
5
|
+
/** The project's Vitest config file, found the way Vitest finds it. */
|
|
6
|
+
export function findVitestConfig(root) {
|
|
7
|
+
for (const name of CONFIG_NAMES) {
|
|
8
|
+
const file = path.join(root, name);
|
|
9
|
+
if (existsSync(file))
|
|
10
|
+
return file;
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Write a Vitest config that is the project's own, limited to `testFiles` (POSIX, relative to `root`).
|
|
16
|
+
* mutator runs its baseline and every mutant with the tests this config selects, and it has no other way
|
|
17
|
+
* to choose tests. Inline `test.projects` keep only the files their include/exclude globs match; projects
|
|
18
|
+
* defined in other files cannot be narrowed and are kept as they are.
|
|
19
|
+
*/
|
|
20
|
+
export function writeNarrowedVitestConfig(options) {
|
|
21
|
+
const root = path.resolve(options.root);
|
|
22
|
+
const base = findVitestConfig(root);
|
|
23
|
+
const file = path.join(options.dir, 'vitest.mutation.config.mjs');
|
|
24
|
+
const absolute = options.testFiles.map((test) => path.join(root, test));
|
|
25
|
+
const lines = [
|
|
26
|
+
'// Written by Veritas for one mutation run: the project Vitest config, limited to the tests that',
|
|
27
|
+
'// import the mutated code. Safe to delete.',
|
|
28
|
+
"import path from 'node:path';",
|
|
29
|
+
base
|
|
30
|
+
? `import * as baseModule from ${JSON.stringify(pathToFileURL(base).href)};`
|
|
31
|
+
: 'const baseModule = {};',
|
|
32
|
+
`const configDir = ${JSON.stringify(root)};`,
|
|
33
|
+
`const files = ${JSON.stringify(absolute)};`,
|
|
34
|
+
'const matches = (relative, globs) => globs.some((glob) => path.posix.matchesGlob(relative, glob));',
|
|
35
|
+
'const select = (test, vitestRoot) => {',
|
|
36
|
+
" const relative = files.map((f) => path.relative(vitestRoot, f).split(path.sep).join('/'));",
|
|
37
|
+
' return relative.filter(',
|
|
38
|
+
' (f) => (!test?.include || matches(f, test.include)) && !(test?.exclude && matches(f, test.exclude)),',
|
|
39
|
+
' );',
|
|
40
|
+
'};',
|
|
41
|
+
'export default async (env) => {',
|
|
42
|
+
' let base = baseModule.default ?? {};',
|
|
43
|
+
" if (typeof base === 'function') base = await base(env);",
|
|
44
|
+
' base = (await base) ?? {};',
|
|
45
|
+
' const vitestRoot = base.root ? path.resolve(configDir, base.root) : configDir;',
|
|
46
|
+
' const test = base.test ?? {};',
|
|
47
|
+
' if (!Array.isArray(test.projects))',
|
|
48
|
+
' return { ...base, root: vitestRoot, test: { ...test, include: select(test, vitestRoot) } };',
|
|
49
|
+
' const projects = [];',
|
|
50
|
+
' for (const entry of test.projects) {',
|
|
51
|
+
" if (!entry || typeof entry !== 'object') {",
|
|
52
|
+
' projects.push(entry);',
|
|
53
|
+
' continue;',
|
|
54
|
+
' }',
|
|
55
|
+
' const projectRoot = entry.root ? path.resolve(vitestRoot, entry.root) : vitestRoot;',
|
|
56
|
+
' const include = select(entry.test, projectRoot);',
|
|
57
|
+
' if (include.length > 0) projects.push({ ...entry, test: { ...entry.test, include } });',
|
|
58
|
+
' }',
|
|
59
|
+
' return { ...base, root: vitestRoot, test: { ...test, projects } };',
|
|
60
|
+
'};',
|
|
61
|
+
'',
|
|
62
|
+
];
|
|
63
|
+
writeFileSync(file, lines.join('\n'));
|
|
64
|
+
return file;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=vitest-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest-config.js","sourceRoot":"","sources":["../src/vitest-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACvD,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,WAAW,GAAG,EAAE,CAAC,CAC/E,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEnC,IA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AAI;QACJ,EAAE;KACH,CAAC;IACF,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEtC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@under18dev/veritas-mutation-adapter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Mutation testing adapter (@mizchi/mutator) for Veritas",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/under18dev/veritas.git",
|
|
9
|
+
"directory": "packages/mutation-adapter"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=24"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@under18dev/veritas-core": "0.1.1",
|
|
26
|
+
"@mizchi/mutator": "0.4.5",
|
|
27
|
+
"zod": "4.6.7"
|
|
28
|
+
}
|
|
6
29
|
}
|