@nx/vitest 22.6.0-beta.1 → 22.6.0-beta.11
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/migrations.json +5 -0
- package/package.json +4 -4
- package/src/executors/test/lib/utils.d.ts +7 -0
- package/src/executors/test/lib/utils.d.ts.map +1 -1
- package/src/executors/test/lib/utils.js +28 -5
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +51 -13
- package/src/generators/configuration/schema.d.ts +1 -0
- package/src/generators/configuration/schema.json +5 -0
- package/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.d.ts +10 -0
- package/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.d.ts.map +1 -0
- package/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.js +105 -0
- package/src/utils/generator-utils.d.ts.map +1 -1
- package/src/utils/generator-utils.js +1 -1
package/migrations.json
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"description": "Create AI Instructions to help migrate users workspaces past breaking changes for Vitest 4.",
|
|
19
19
|
"implementation": "./src/migrations/update-22-1-0/create-ai-instructions-for-vitest-4"
|
|
20
|
+
},
|
|
21
|
+
"update-22-6-0-prefix-reports-directory": {
|
|
22
|
+
"version": "22.6.0-beta.11",
|
|
23
|
+
"description": "Prefix reportsDirectory with {projectRoot} to maintain correct resolution after workspace-root-relative behavior change.",
|
|
24
|
+
"implementation": "./src/migrations/update-22-6-0/prefix-reports-directory-with-project-root"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vitest",
|
|
3
3
|
"description": "The Nx Plugin for Vitest to enable fast unit testing with Vitest.",
|
|
4
|
-
"version": "22.6.0-beta.
|
|
4
|
+
"version": "22.6.0-beta.11",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"executors": "./executors.json",
|
|
53
53
|
"generators": "./generators.json",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nx/devkit": "22.6.0-beta.
|
|
56
|
-
"@nx/js": "22.6.0-beta.
|
|
55
|
+
"@nx/devkit": "22.6.0-beta.11",
|
|
56
|
+
"@nx/js": "22.6.0-beta.11",
|
|
57
57
|
"tslib": "^2.3.0",
|
|
58
58
|
"semver": "^7.6.3",
|
|
59
59
|
"@phenomnomnominal/tsquery": "~6.1.4"
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"nx": "22.6.0-beta.
|
|
74
|
+
"nx": "22.6.0-beta.11"
|
|
75
75
|
},
|
|
76
76
|
"types": "./src/index.d.ts"
|
|
77
77
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { VitestExecutorOptions } from '../schema';
|
|
3
3
|
export declare function getOptions(options: VitestExecutorOptions, context: ExecutorContext, projectRoot: string): Promise<Record<string, any>>;
|
|
4
|
+
/**
|
|
5
|
+
* Nx's resolveNxTokensInOptions strips {workspaceRoot}/ from option values,
|
|
6
|
+
* leaving a workspace-root-relative path. However, vitest resolves
|
|
7
|
+
* reportsDirectory relative to the project root. This function converts
|
|
8
|
+
* the path to absolute so vitest resolves it correctly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveReportsDirectory(reportsDirectory: string): string;
|
|
4
11
|
export declare function getOptionsAsArgv(obj: Record<string, any>): string[];
|
|
5
12
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vitest/src/executors/test/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vitest/src/executors/test/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAQlD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAoG9B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAKxE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,CAcnE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptions = getOptions;
|
|
4
|
+
exports.resolveReportsDirectory = resolveReportsDirectory;
|
|
4
5
|
exports.getOptionsAsArgv = getOptionsAsArgv;
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const options_utils_1 = require("../../../utils/options-utils");
|
|
@@ -38,7 +39,7 @@ async function getOptions(options, context, projectRoot) {
|
|
|
38
39
|
// Filter out options that are handled specially or are parseCLI artifacts
|
|
39
40
|
const {
|
|
40
41
|
// Handled specially by executor
|
|
41
|
-
testFiles: _testFiles, configFile: _configFile, mode: _mode, runMode: _runMode, reportsDirectory, coverage,
|
|
42
|
+
testFiles: _testFiles, configFile: _configFile, mode: _mode, runMode: _runMode, reportsDirectory, coverage, reporter, reporters,
|
|
42
43
|
// parseCLI artifacts
|
|
43
44
|
'--': _dashdash, color: _color, w: _w,
|
|
44
45
|
// Pass through any additional Vitest options
|
|
@@ -53,15 +54,37 @@ async function getOptions(options, context, projectRoot) {
|
|
|
53
54
|
// but leaving it here in case someone did not migrate correctly
|
|
54
55
|
root: resolved?.config?.root ?? root,
|
|
55
56
|
config: viteConfigPath,
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
57
|
+
// Vitest's resolveConfig processes reporters in two steps:
|
|
58
|
+
// 1. options.reporters (plural) sets resolved.reporters
|
|
59
|
+
// 2. resolved.reporter (singular, from config) overwrites resolved.reporters
|
|
60
|
+
// Setting reporter to [] prevents config's reporter from overriding NxReporter
|
|
61
|
+
// (which is pushed onto reporters in vitest.impl.ts).
|
|
62
|
+
reporter: [],
|
|
63
|
+
reporters: reporter ??
|
|
64
|
+
reporters ??
|
|
65
|
+
// reporter (singular) has higher priority in vitest but is not declared in InlineConfig
|
|
66
|
+
resolved?.config?.['test']?.reporter ??
|
|
67
|
+
resolved?.config?.['test']?.reporters,
|
|
59
68
|
coverage: {
|
|
60
69
|
...(coverage ?? {}),
|
|
61
|
-
...(reportsDirectory && {
|
|
70
|
+
...(reportsDirectory && {
|
|
71
|
+
reportsDirectory: resolveReportsDirectory(reportsDirectory),
|
|
72
|
+
}),
|
|
62
73
|
},
|
|
63
74
|
};
|
|
64
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Nx's resolveNxTokensInOptions strips {workspaceRoot}/ from option values,
|
|
78
|
+
* leaving a workspace-root-relative path. However, vitest resolves
|
|
79
|
+
* reportsDirectory relative to the project root. This function converts
|
|
80
|
+
* the path to absolute so vitest resolves it correctly.
|
|
81
|
+
*/
|
|
82
|
+
function resolveReportsDirectory(reportsDirectory) {
|
|
83
|
+
if ((0, path_1.isAbsolute)(reportsDirectory)) {
|
|
84
|
+
return reportsDirectory;
|
|
85
|
+
}
|
|
86
|
+
return (0, path_1.resolve)(devkit_1.workspaceRoot, reportsDirectory);
|
|
87
|
+
}
|
|
65
88
|
function getOptionsAsArgv(obj) {
|
|
66
89
|
const argv = [];
|
|
67
90
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EASjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAcpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAmCjD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,qBAAqB,EAC7B,SAAS,UAAQ,8BAOlB;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,qBAAqB,EAC7B,SAAS,UAAQ,
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EASjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAcpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAmCjD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,qBAAqB,EAC7B,SAAS,UAAQ,8BAOlB;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,qBAAqB,EAC7B,SAAS,UAAQ,8BAmNlB;AAuOD,eAAe,sBAAsB,CAAC"}
|
|
@@ -68,10 +68,19 @@ async function configurationGeneratorInternal(tree, schema, hasPlugin = false) {
|
|
|
68
68
|
const relativeTestSetupPath = (0, devkit_1.joinPathFragments)('src', 'test-setup.ts');
|
|
69
69
|
const setupFile = (0, devkit_1.joinPathFragments)(root, relativeTestSetupPath);
|
|
70
70
|
if (!tree.exists(setupFile)) {
|
|
71
|
-
|
|
71
|
+
const angularMajorVersion = getAngularMajorVersion(tree);
|
|
72
|
+
const zoneless = schema.zoneless ?? isZonelessProject(tree, schema.project);
|
|
73
|
+
if (angularMajorVersion >= 21) {
|
|
72
74
|
tree.write(setupFile, `import '@angular/compiler';
|
|
73
|
-
import '@analogjs/vitest-angular/setup-
|
|
75
|
+
import '@analogjs/vitest-angular/setup-snapshots';
|
|
76
|
+
import { setupTestBed } from '@analogjs/vitest-angular/setup-testbed';
|
|
74
77
|
|
|
78
|
+
setupTestBed(${zoneless ? '' : '{ zoneless: false }'});
|
|
79
|
+
`);
|
|
80
|
+
}
|
|
81
|
+
else if (angularMajorVersion === 20) {
|
|
82
|
+
tree.write(setupFile, `import '@angular/compiler';
|
|
83
|
+
import '@analogjs/vitest-angular/${zoneless ? 'setup-snapshots' : 'setup-zone'}';
|
|
75
84
|
import {
|
|
76
85
|
BrowserTestingModule,
|
|
77
86
|
platformBrowserTesting,
|
|
@@ -80,13 +89,12 @@ import { getTestBed } from '@angular/core/testing';
|
|
|
80
89
|
|
|
81
90
|
getTestBed().initTestEnvironment(
|
|
82
91
|
BrowserTestingModule,
|
|
83
|
-
platformBrowserTesting()
|
|
92
|
+
platformBrowserTesting(),
|
|
84
93
|
);
|
|
85
94
|
`);
|
|
86
95
|
}
|
|
87
96
|
else {
|
|
88
|
-
tree.write(setupFile, `import '@analogjs/vitest-angular
|
|
89
|
-
|
|
97
|
+
tree.write(setupFile, `import '@analogjs/vitest-angular/${zoneless ? 'setup-snapshots' : 'setup-zone'}';
|
|
90
98
|
import {
|
|
91
99
|
BrowserDynamicTestingModule,
|
|
92
100
|
platformBrowserDynamicTesting,
|
|
@@ -95,7 +103,7 @@ import { getTestBed } from '@angular/core/testing';
|
|
|
95
103
|
|
|
96
104
|
getTestBed().initTestEnvironment(
|
|
97
105
|
BrowserDynamicTestingModule,
|
|
98
|
-
platformBrowserDynamicTesting()
|
|
106
|
+
platformBrowserDynamicTesting(),
|
|
99
107
|
);
|
|
100
108
|
`);
|
|
101
109
|
}
|
|
@@ -302,17 +310,47 @@ function tryFindSetupFile(tree, projectRoot) {
|
|
|
302
310
|
return setupFile;
|
|
303
311
|
}
|
|
304
312
|
}
|
|
305
|
-
function
|
|
313
|
+
function getAngularMajorVersion(tree) {
|
|
306
314
|
const angularVersion = (0, devkit_1.getDependencyVersionFromPackageJson)(tree, '@angular/core');
|
|
307
315
|
if (!angularVersion) {
|
|
308
|
-
// assume the latest version will be installed
|
|
309
|
-
return
|
|
316
|
+
// assume the latest version will be installed
|
|
317
|
+
return 21;
|
|
310
318
|
}
|
|
311
|
-
const cleanedAngularVersion = (0, semver_1.clean)(angularVersion) ?? (0, semver_1.coerce)(angularVersion)
|
|
319
|
+
const cleanedAngularVersion = (0, semver_1.clean)(angularVersion) ?? (0, semver_1.coerce)(angularVersion)?.version;
|
|
312
320
|
if (typeof cleanedAngularVersion !== 'string') {
|
|
313
|
-
// assume the latest version will be installed
|
|
314
|
-
return
|
|
321
|
+
// assume the latest version will be installed
|
|
322
|
+
return 21;
|
|
323
|
+
}
|
|
324
|
+
return (0, semver_1.major)(cleanedAngularVersion);
|
|
325
|
+
}
|
|
326
|
+
function isZonelessProject(tree, projectName) {
|
|
327
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
328
|
+
if (project.projectType === 'application') {
|
|
329
|
+
const buildTarget = findBuildTarget(project);
|
|
330
|
+
if (!buildTarget?.options?.polyfills) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
const polyfills = buildTarget.options.polyfills;
|
|
334
|
+
const polyfillsList = Array.isArray(polyfills) ? polyfills : [polyfills];
|
|
335
|
+
return !polyfillsList.includes('zone.js');
|
|
336
|
+
}
|
|
337
|
+
// For libraries, check if zone.js is installed in the workspace
|
|
338
|
+
return (0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'zone.js') === null;
|
|
339
|
+
}
|
|
340
|
+
function findBuildTarget(project) {
|
|
341
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
342
|
+
if ([
|
|
343
|
+
'@angular-devkit/build-angular:browser',
|
|
344
|
+
'@angular-devkit/build-angular:browser-esbuild',
|
|
345
|
+
'@angular-devkit/build-angular:application',
|
|
346
|
+
'@angular/build:application',
|
|
347
|
+
'@nx/angular:application',
|
|
348
|
+
'@nx/angular:browser-esbuild',
|
|
349
|
+
'@nx/angular:webpack-browser',
|
|
350
|
+
].includes(target.executor)) {
|
|
351
|
+
return target;
|
|
352
|
+
}
|
|
315
353
|
}
|
|
316
|
-
return
|
|
354
|
+
return project.targets?.build ?? null;
|
|
317
355
|
}
|
|
318
356
|
exports.default = configurationGenerator;
|
|
@@ -65,6 +65,11 @@
|
|
|
65
65
|
"default": false,
|
|
66
66
|
"description": "Do not add dependencies to `package.json`.",
|
|
67
67
|
"x-priority": "internal"
|
|
68
|
+
},
|
|
69
|
+
"zoneless": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"description": "Whether the Angular project is zoneless. When not provided, it is auto-detected from the project configuration.",
|
|
72
|
+
"x-priority": "internal"
|
|
68
73
|
}
|
|
69
74
|
},
|
|
70
75
|
"required": ["project"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Migrates reportsDirectory option for @nx/vitest:test and @nx/vite:test executors.
|
|
4
|
+
*
|
|
5
|
+
* Previously, reportsDirectory was resolved relative to the project root (cwd).
|
|
6
|
+
* Now it is resolved relative to the workspace root. This migration prepends
|
|
7
|
+
* {projectRoot}/ to existing naked paths so the resolved location stays the same.
|
|
8
|
+
*/
|
|
9
|
+
export default function prefixReportsDirectoryWithProjectRoot(tree: Tree): void;
|
|
10
|
+
//# sourceMappingURL=prefix-reports-directory-with-project-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-reports-directory-with-project-root.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,YAAY,CAAC;AAQpB;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qCAAqC,CAAC,IAAI,EAAE,IAAI,QAGvE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = prefixReportsDirectoryWithProjectRoot;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Migrates reportsDirectory option for @nx/vitest:test and @nx/vite:test executors.
|
|
9
|
+
*
|
|
10
|
+
* Previously, reportsDirectory was resolved relative to the project root (cwd).
|
|
11
|
+
* Now it is resolved relative to the workspace root. This migration prepends
|
|
12
|
+
* {projectRoot}/ to existing naked paths so the resolved location stays the same.
|
|
13
|
+
*/
|
|
14
|
+
function prefixReportsDirectoryWithProjectRoot(tree) {
|
|
15
|
+
migrateProjectConfigurations(tree);
|
|
16
|
+
migrateTargetDefaults(tree);
|
|
17
|
+
}
|
|
18
|
+
function migrateProjectConfigurations(tree) {
|
|
19
|
+
const projectsToUpdate = new Map();
|
|
20
|
+
for (const executorName of ['@nx/vitest:test', '@nx/vite:test']) {
|
|
21
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, executorName, (options, projectName, targetName, configuration) => {
|
|
22
|
+
if (needsMigration(options.reportsDirectory)) {
|
|
23
|
+
if (!projectsToUpdate.has(projectName)) {
|
|
24
|
+
projectsToUpdate.set(projectName, new Map());
|
|
25
|
+
}
|
|
26
|
+
const key = configuration
|
|
27
|
+
? `${targetName}::${configuration}`
|
|
28
|
+
: targetName;
|
|
29
|
+
projectsToUpdate
|
|
30
|
+
.get(projectName)
|
|
31
|
+
.set(key, { target: targetName, configuration });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
for (const [projectName] of projectsToUpdate) {
|
|
36
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
37
|
+
for (const [_targetName, target] of Object.entries(projectConfig.targets || {})) {
|
|
38
|
+
if (target.executor !== '@nx/vitest:test' &&
|
|
39
|
+
target.executor !== '@nx/vite:test') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (needsMigration(target.options?.reportsDirectory)) {
|
|
43
|
+
target.options.reportsDirectory = prependProjectRoot(target.options.reportsDirectory);
|
|
44
|
+
}
|
|
45
|
+
if (target.configurations) {
|
|
46
|
+
for (const config of Object.values(target.configurations)) {
|
|
47
|
+
if (needsMigration(config?.reportsDirectory)) {
|
|
48
|
+
config.reportsDirectory = prependProjectRoot(config.reportsDirectory);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function migrateTargetDefaults(tree) {
|
|
57
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
58
|
+
if (!nxJson?.targetDefaults) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let hasChanges = false;
|
|
62
|
+
for (const [_key, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
63
|
+
if (targetConfig.executor !== '@nx/vitest:test' &&
|
|
64
|
+
targetConfig.executor !== '@nx/vite:test' &&
|
|
65
|
+
_key !== '@nx/vitest:test' &&
|
|
66
|
+
_key !== '@nx/vite:test') {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (needsMigration(targetConfig.options?.reportsDirectory)) {
|
|
70
|
+
targetConfig.options.reportsDirectory = prependProjectRoot(targetConfig.options.reportsDirectory);
|
|
71
|
+
hasChanges = true;
|
|
72
|
+
}
|
|
73
|
+
if (targetConfig.configurations) {
|
|
74
|
+
for (const config of Object.values(targetConfig.configurations)) {
|
|
75
|
+
if (needsMigration(config?.reportsDirectory)) {
|
|
76
|
+
config.reportsDirectory = prependProjectRoot(config.reportsDirectory);
|
|
77
|
+
hasChanges = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (hasChanges) {
|
|
83
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function needsMigration(reportsDirectory) {
|
|
87
|
+
if (!reportsDirectory) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if ((0, path_1.isAbsolute)(reportsDirectory)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// Already starts with {projectRoot} — already project-root-relative
|
|
94
|
+
if (reportsDirectory.startsWith('{projectRoot}')) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
// Already starts with {workspaceRoot} — user intended workspace-root-relative
|
|
98
|
+
if (reportsDirectory.startsWith('{workspaceRoot}')) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
function prependProjectRoot(reportsDirectory) {
|
|
104
|
+
return `{projectRoot}/${reportsDirectory}`;
|
|
105
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/generator-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,IAAI,EAGL,MAAM,YAAY,CAAC;AAMpB,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;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, hasPlugin) {
|
|
|
16
16
|
}
|
|
17
17
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
18
18
|
const target = options.testTarget ?? 'test';
|
|
19
|
-
const reportsDirectory = (0, devkit_1.joinPathFragments)(
|
|
19
|
+
const reportsDirectory = (0, devkit_1.joinPathFragments)('coverage', project.root === '.' ? options.project : project.root);
|
|
20
20
|
const testOptions = {
|
|
21
21
|
reportsDirectory,
|
|
22
22
|
};
|