@nx/vitest 22.6.4 → 22.6.5

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 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.4",
4
+ "version": "22.6.5",
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.4",
56
- "@nx/js": "22.6.4",
55
+ "@nx/devkit": "22.6.5",
56
+ "@nx/js": "22.6.5",
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.4"
74
+ "nx": "22.6.5"
75
75
  },
76
76
  "types": "./src/index.d.ts"
77
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAQd,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;AAoBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CA+E1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EASd,MAAM,YAAY,CAAC;AAWpB,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;AAoBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAmF1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
@@ -11,7 +11,6 @@ const file_hasher_1 = require("nx/src/hasher/file-hasher");
11
11
  const cache_directory_1 = require("nx/src/utils/cache-directory");
12
12
  const plugins_1 = require("nx/src/utils/plugins");
13
13
  const executor_utils_1 = require("../utils/executor-utils");
14
- const pmc = (0, devkit_1.getPackageManagerCommand)();
15
14
  function readTargetsCache(cachePath) {
16
15
  return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
17
16
  ? (0, devkit_1.readJsonFile)(cachePath)
@@ -31,6 +30,7 @@ const vitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';
31
30
  exports.createNodes = [
32
31
  vitestConfigGlob,
33
32
  async (configFilePaths, options, context) => {
33
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
34
34
  const optionsHash = (0, file_hasher_1.hashObject)(options);
35
35
  const normalizedOptions = normalizeOptions(options);
36
36
  const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `vitest-${optionsHash}.hash`);
@@ -57,7 +57,7 @@ exports.createNodes = [
57
57
  // for different config files.
58
58
  const hash = hashes[idx] + configFile;
59
59
  const { projectType, metadata, targets } = (targetsCache[hash] ??=
60
- await buildVitestTargets(configFile, projectRoot, normalizedOptions, context));
60
+ await buildVitestTargets(configFile, projectRoot, normalizedOptions, context, pmc));
61
61
  const project = {
62
62
  root: projectRoot,
63
63
  targets,
@@ -77,7 +77,7 @@ exports.createNodes = [
77
77
  },
78
78
  ];
79
79
  exports.createNodesV2 = exports.createNodes;
80
- async function buildVitestTargets(configFilePath, projectRoot, options, context) {
80
+ async function buildVitestTargets(configFilePath, projectRoot, options, context, pmc) {
81
81
  const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
82
82
  // Workaround for the `build$3 is not a function` error that we sometimes see in agents.
83
83
  // This should be removed later once we address the issue properly
@@ -132,7 +132,7 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context)
132
132
  const targets = {};
133
133
  // if file is vitest.config or vite.config has definition for test, create targets for test and/or atomized tests
134
134
  if (configFilePath.includes('vitest.config') || hasTest) {
135
- targets[options.testTargetName] = await testTarget(namedInputs, testOutputs, projectRoot, options.testMode);
135
+ targets[options.testTargetName] = await testTarget(namedInputs, testOutputs, projectRoot, options.testMode, pmc);
136
136
  if (options.ciTargetName) {
137
137
  const groupName = options.ciGroupName ?? (0, plugins_1.deriveGroupNameFromTarget)(options.ciTargetName);
138
138
  const targetGroup = [];
@@ -207,7 +207,7 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context)
207
207
  }
208
208
  return { targets, metadata, projectType: 'library' };
209
209
  }
210
- async function testTarget(namedInputs, outputs, projectRoot, testMode = 'watch') {
210
+ async function testTarget(namedInputs, outputs, projectRoot, testMode = 'watch', pmc) {
211
211
  const command = testMode === 'run' ? 'vitest run' : 'vitest';
212
212
  return {
213
213
  command,
@@ -261,10 +261,10 @@ function normalizeOutputPath(outputPath, projectRoot, workspaceRoot, path) {
261
261
  }
262
262
  else {
263
263
  if (outputPath.startsWith('..')) {
264
- return (0, node_path_1.join)('{workspaceRoot}', (0, node_path_1.join)(projectRoot, outputPath));
264
+ return (0, devkit_1.joinPathFragments)('{workspaceRoot}', projectRoot, outputPath);
265
265
  }
266
266
  else {
267
- return (0, node_path_1.join)('{projectRoot}', outputPath);
267
+ return (0, devkit_1.joinPathFragments)('{projectRoot}', outputPath);
268
268
  }
269
269
  }
270
270
  }
@@ -296,5 +296,5 @@ async function getTestPathsRelativeToProjectRoot(projectRoot, workspaceRoot) {
296
296
  const relevantTestSpecifications = await vitest.getRelevantTestSpecifications();
297
297
  return relevantTestSpecifications
298
298
  .filter((ts) => fullProjectRoot === '.' ? true : ts.moduleId.startsWith(fullProjectRoot))
299
- .map((ts) => (0, node_path_1.relative)(projectRoot, ts.moduleId));
299
+ .map((ts) => (0, devkit_1.normalizePath)((0, node_path_1.relative)(projectRoot, ts.moduleId)));
300
300
  }