@nx/vitest 23.0.0-beta.5 → 23.0.0-beta.7
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/package.json +6 -6
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +2 -2
- package/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.d.ts.map +1 -1
- package/src/migrations/update-22-6-0/prefix-reports-directory-with-project-root.js +2 -2
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +13 -20
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": "23.0.0-beta.
|
|
4
|
+
"version": "23.0.0-beta.7",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"executors": "./executors.json",
|
|
53
53
|
"generators": "./generators.json",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nx/devkit": "23.0.0-beta.
|
|
56
|
-
"@nx/js": "23.0.0-beta.
|
|
55
|
+
"@nx/devkit": "23.0.0-beta.7",
|
|
56
|
+
"@nx/js": "23.0.0-beta.7",
|
|
57
57
|
"tslib": "^2.3.0",
|
|
58
58
|
"semver": "^7.6.3",
|
|
59
|
-
"@phenomnomnominal/tsquery": "~6.
|
|
59
|
+
"@phenomnomnominal/tsquery": "~6.2.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@nx/eslint": "23.0.0-beta.
|
|
62
|
+
"@nx/eslint": "23.0.0-beta.7",
|
|
63
63
|
"vitest": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
64
64
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
65
65
|
},
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"nx": "23.0.0-beta.
|
|
78
|
+
"nx": "23.0.0-beta.7"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,EAOvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAa/C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,qBA2BzE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QA4B9C;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,8BAkC1E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateDependencies = updateDependencies;
|
|
4
4
|
exports.updateNxJsonSettings = updateNxJsonSettings;
|
|
5
5
|
exports.initGenerator = initGenerator;
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
8
8
|
const versions_1 = require("../../utils/versions");
|
|
9
9
|
const plugin_1 = require("../../plugins/plugin");
|
|
10
10
|
const version_utils_1 = require("../../utils/version-utils");
|
|
@@ -53,7 +53,7 @@ async function initGenerator(tree, schema) {
|
|
|
53
53
|
nxJson.useInferencePlugins !== false;
|
|
54
54
|
schema.addPlugin ??= addPluginDefault;
|
|
55
55
|
if (schema.addPlugin) {
|
|
56
|
-
await (0,
|
|
56
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/vitest', plugin_1.createNodesV2, {
|
|
57
57
|
testTargetName: ['test', 'vitest:test', 'vitest-test'],
|
|
58
58
|
ciTargetName: ['test-ci', 'vitest:test-ci', 'vitest-test-ci'],
|
|
59
59
|
}, schema.updatePackageScripts);
|
|
@@ -1 +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":"
|
|
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":"AACA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,YAAY,CAAC;AAOpB;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qCAAqC,CAAC,IAAI,EAAE,IAAI,QAGvE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = prefixReportsDirectoryWithProjectRoot;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
/**
|
|
8
8
|
* Migrates reportsDirectory option for @nx/vitest:test and @nx/vite:test executors.
|
|
@@ -18,7 +18,7 @@ function prefixReportsDirectoryWithProjectRoot(tree) {
|
|
|
18
18
|
function migrateProjectConfigurations(tree) {
|
|
19
19
|
const projectsToUpdate = new Map();
|
|
20
20
|
for (const executorName of ['@nx/vitest:test', '@nx/vite:test']) {
|
|
21
|
-
(0,
|
|
21
|
+
(0, internal_1.forEachExecutorOptions)(tree, executorName, (options, projectName, targetName, configuration) => {
|
|
22
22
|
if (needsMigration(options.reportsDirectory)) {
|
|
23
23
|
if (!projectsToUpdate.has(projectName)) {
|
|
24
24
|
projectsToUpdate.set(projectName, new Map());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAOd,MAAM,YAAY,CAAC;AAapB,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAC5B;AAOD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAgG1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -34,25 +34,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
37
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
37
38
|
const devkit_1 = require("@nx/devkit");
|
|
38
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
39
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
40
39
|
const js_1 = require("@nx/js");
|
|
41
|
-
const
|
|
40
|
+
const internal_2 = require("@nx/js/src/internal");
|
|
42
41
|
const node_fs_1 = require("node:fs");
|
|
43
42
|
const node_path_1 = require("node:path");
|
|
44
43
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
45
44
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
46
45
|
const plugins_1 = require("nx/src/utils/plugins");
|
|
47
46
|
const executor_utils_1 = require("../utils/executor-utils");
|
|
48
|
-
function readTargetsCache(cachePath) {
|
|
49
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
|
|
50
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
51
|
-
: {};
|
|
52
|
-
}
|
|
53
|
-
function writeTargetsToCache(cachePath, results) {
|
|
54
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
55
|
-
}
|
|
56
47
|
/**
|
|
57
48
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
58
49
|
*/
|
|
@@ -68,7 +59,7 @@ exports.createNodes = [
|
|
|
68
59
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
69
60
|
const normalizedOptions = normalizeOptions(options);
|
|
70
61
|
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `vitest-${optionsHash}.hash`);
|
|
71
|
-
const targetsCache =
|
|
62
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
72
63
|
const { roots: projectRoots, configFiles: validConfigFiles } = configFilePaths.reduce((acc, configFile) => {
|
|
73
64
|
const potentialRoot = (0, node_path_1.dirname)(configFile);
|
|
74
65
|
if (checkIfConfigFileShouldBeProject(potentialRoot, context)) {
|
|
@@ -82,7 +73,7 @@ exports.createNodes = [
|
|
|
82
73
|
});
|
|
83
74
|
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
84
75
|
const tsconfigChainsByProjectRoot = collectTsconfigInputsByProjectRoot(projectRoots, context.workspaceRoot);
|
|
85
|
-
const hashes = await (0,
|
|
76
|
+
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, normalizedOptions, context, projectRoots.map((root) => [
|
|
86
77
|
lockfile,
|
|
87
78
|
...(tsconfigChainsByProjectRoot.get(root) ?? []),
|
|
88
79
|
]));
|
|
@@ -94,8 +85,10 @@ exports.createNodes = [
|
|
|
94
85
|
// Adding the config file path to the hash ensures that the final hash value is different
|
|
95
86
|
// for different config files.
|
|
96
87
|
const hash = hashes[idx] + configFile;
|
|
97
|
-
|
|
98
|
-
await buildVitestTargets(configFile, projectRoot, normalizedOptions, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []));
|
|
88
|
+
if (!targetsCache.has(hash)) {
|
|
89
|
+
targetsCache.set(hash, await buildVitestTargets(configFile, projectRoot, normalizedOptions, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []));
|
|
90
|
+
}
|
|
91
|
+
const { projectType, metadata, targets } = targetsCache.get(hash);
|
|
99
92
|
const project = {
|
|
100
93
|
root: projectRoot,
|
|
101
94
|
targets,
|
|
@@ -110,7 +103,7 @@ exports.createNodes = [
|
|
|
110
103
|
}, validConfigFiles, options, context);
|
|
111
104
|
}
|
|
112
105
|
finally {
|
|
113
|
-
|
|
106
|
+
targetsCache.writeToDisk();
|
|
114
107
|
}
|
|
115
108
|
},
|
|
116
109
|
];
|
|
@@ -166,7 +159,7 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context,
|
|
|
166
159
|
}
|
|
167
160
|
let metadata = {};
|
|
168
161
|
const { testOutputs, hasTest } = getOutputs(viteBuildConfig, projectRoot, context.workspaceRoot);
|
|
169
|
-
const namedInputs = (0,
|
|
162
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
170
163
|
const targets = {};
|
|
171
164
|
// if file is vitest.config or vite.config has definition for test, create targets for test and/or atomized tests
|
|
172
165
|
if (configFilePath.includes('vitest.config') || hasTest) {
|
|
@@ -370,7 +363,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
370
363
|
// 1. Walk the project tsconfig's extends chain
|
|
371
364
|
const projectTsconfig = (0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.json');
|
|
372
365
|
if ((0, node_fs_1.existsSync)(projectTsconfig)) {
|
|
373
|
-
(0,
|
|
366
|
+
(0, internal_2.walkTsconfigExtendsChain)(projectTsconfig, (absPath) => {
|
|
374
367
|
collect(absPath);
|
|
375
368
|
return 'continue';
|
|
376
369
|
}, { jsonCache });
|
|
@@ -381,7 +374,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
381
374
|
while (dir && dir !== '.') {
|
|
382
375
|
const ancestorTsconfig = (0, node_path_1.join)(workspaceRoot, dir, 'tsconfig.json');
|
|
383
376
|
if ((0, node_fs_1.existsSync)(ancestorTsconfig)) {
|
|
384
|
-
(0,
|
|
377
|
+
(0, internal_2.walkTsconfigExtendsChain)(ancestorTsconfig, (absPath) => {
|
|
385
378
|
collect(absPath);
|
|
386
379
|
return 'continue';
|
|
387
380
|
}, { jsonCache });
|
|
@@ -394,7 +387,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
394
387
|
// 3. Check the workspace root itself (dirname loop above stops at '.')
|
|
395
388
|
const rootTsconfig = (0, node_path_1.join)(workspaceRoot, 'tsconfig.json');
|
|
396
389
|
if ((0, node_fs_1.existsSync)(rootTsconfig)) {
|
|
397
|
-
(0,
|
|
390
|
+
(0, internal_2.walkTsconfigExtendsChain)(rootTsconfig, (absPath) => {
|
|
398
391
|
collect(absPath);
|
|
399
392
|
return 'continue';
|
|
400
393
|
}, { jsonCache });
|