@nx/vite 22.2.0-beta.1 → 22.2.0-beta.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/migrations.json +5 -0
- package/package.json +5 -5
- package/src/executors/test/vitest.impl.d.ts +3 -1
- package/src/executors/test/vitest.impl.d.ts.map +1 -1
- package/src/executors/test/vitest.impl.js +1 -1
- package/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.d.ts +12 -0
- package/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.d.ts.map +1 -0
- package/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.js +140 -0
package/migrations.json
CHANGED
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"description": "Create AI Instructions to help migrate users workspaces past breaking changes for Vitest 4.",
|
|
34
34
|
"implementation": "./src/migrations/update-22-2-0/create-ai-instructions-for-vitest-4"
|
|
35
|
+
},
|
|
36
|
+
"migrate-vitest-to-vitest-package": {
|
|
37
|
+
"version": "22.2.0-beta.2",
|
|
38
|
+
"description": "Migrate Vitest usage from @nx/vite to @nx/vitest package.",
|
|
39
|
+
"implementation": "./src/migrations/update-22-2-0/migrate-vitest-to-vitest-package"
|
|
35
40
|
}
|
|
36
41
|
},
|
|
37
42
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "22.2.0-beta.
|
|
3
|
+
"version": "22.2.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nx/devkit": "22.2.0-beta.
|
|
33
|
+
"@nx/devkit": "22.2.0-beta.2",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "22.2.0-beta.
|
|
37
|
-
"@nx/vitest": "22.2.0-beta.
|
|
36
|
+
"@nx/js": "22.2.0-beta.2",
|
|
37
|
+
"@nx/vitest": "22.2.0-beta.2",
|
|
38
38
|
"picomatch": "4.0.2",
|
|
39
39
|
"tsconfig-paths": "^4.1.2",
|
|
40
40
|
"semver": "^7.6.3",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ajv": "^8.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"nx": "22.2.0-beta.
|
|
45
|
+
"nx": "22.2.0-beta.2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -3,6 +3,8 @@ import { VitestExecutorOptions } from './schema';
|
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use `@nx/vitest:test` instead. This executor will be removed in Nx 23.
|
|
5
5
|
*/
|
|
6
|
-
export declare function vitestExecutor(options: VitestExecutorOptions, context: ExecutorContext): AsyncGenerator<never,
|
|
6
|
+
export declare function vitestExecutor(options: VitestExecutorOptions, context: ExecutorContext): AsyncGenerator<never, {
|
|
7
|
+
success: boolean;
|
|
8
|
+
}, unknown>;
|
|
7
9
|
export default vitestExecutor;
|
|
8
10
|
//# sourceMappingURL=vitest.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/executors/test/vitest.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAGrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,wBAAuB,cAAc,CACnC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe
|
|
1
|
+
{"version":3,"file":"vitest.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/executors/test/vitest.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAGrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,wBAAuB,cAAc,CACnC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe;;YAYzB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -11,6 +11,6 @@ async function* vitestExecutor(options, context) {
|
|
|
11
11
|
devkit_1.logger.warn(`The '@nx/vite:test' executor is deprecated. Please use '@nx/vitest:test' instead. This executor will be removed in Nx 23.`);
|
|
12
12
|
(0, devkit_2.ensurePackage)('@nx/vitest', versions_1.nxVersion);
|
|
13
13
|
const { vitestExecutor: actualVitestExecutor } = await Promise.resolve().then(() => require('@nx/vitest/executors'));
|
|
14
|
-
yield* actualVitestExecutor(options, context);
|
|
14
|
+
return yield* actualVitestExecutor(options, context);
|
|
15
15
|
}
|
|
16
16
|
exports.default = vitestExecutor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Migrates Vitest usage from @nx/vite to @nx/vitest package.
|
|
4
|
+
*
|
|
5
|
+
* This migration:
|
|
6
|
+
* 1. Installs @nx/vitest package if not present
|
|
7
|
+
* 2. Converts @nx/vite:test executor usages to @nx/vitest:test
|
|
8
|
+
* 3. Splits @nx/vite/plugin configurations to add @nx/vitest plugin
|
|
9
|
+
* 4. Migrates targetDefaults from @nx/vite:test to @nx/vitest:test
|
|
10
|
+
*/
|
|
11
|
+
export default function migrateVitestToVitestPackage(tree: Tree): Promise<GeneratorCallback>;
|
|
12
|
+
//# sourceMappingURL=migrate-vitest-to-vitest-package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-vitest-to-vitest-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAItB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAYpB;;;;;;;;GAQG;AACH,wBAA8B,4BAA4B,CACxD,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,iBAAiB,CAAC,CAS5B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateVitestToVitestPackage;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
/**
|
|
8
|
+
* Migrates Vitest usage from @nx/vite to @nx/vitest package.
|
|
9
|
+
*
|
|
10
|
+
* This migration:
|
|
11
|
+
* 1. Installs @nx/vitest package if not present
|
|
12
|
+
* 2. Converts @nx/vite:test executor usages to @nx/vitest:test
|
|
13
|
+
* 3. Splits @nx/vite/plugin configurations to add @nx/vitest plugin
|
|
14
|
+
* 4. Migrates targetDefaults from @nx/vite:test to @nx/vitest:test
|
|
15
|
+
*/
|
|
16
|
+
async function migrateVitestToVitestPackage(tree) {
|
|
17
|
+
const installTask = installVitestPackageIfNeeded(tree);
|
|
18
|
+
migrateExecutorUsages(tree);
|
|
19
|
+
migratePluginConfigurations(tree);
|
|
20
|
+
migrateTargetDefaults(tree);
|
|
21
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
22
|
+
return installTask;
|
|
23
|
+
}
|
|
24
|
+
function installVitestPackageIfNeeded(tree) {
|
|
25
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
26
|
+
const hasVitest = packageJson.dependencies?.['@nx/vitest'] ||
|
|
27
|
+
packageJson.devDependencies?.['@nx/vitest'];
|
|
28
|
+
if (hasVitest) {
|
|
29
|
+
return () => { };
|
|
30
|
+
}
|
|
31
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vitest': versions_1.nxVersion });
|
|
32
|
+
}
|
|
33
|
+
function migrateExecutorUsages(tree) {
|
|
34
|
+
const projectsToUpdate = new Set();
|
|
35
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/vite:test', (_options, projectName, _targetName, _configuration) => {
|
|
36
|
+
projectsToUpdate.add(projectName);
|
|
37
|
+
});
|
|
38
|
+
for (const projectName of projectsToUpdate) {
|
|
39
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
40
|
+
for (const [targetName, target] of Object.entries(projectConfig.targets || {})) {
|
|
41
|
+
if (target.executor === '@nx/vite:test') {
|
|
42
|
+
target.executor = '@nx/vitest:test';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function migratePluginConfigurations(tree) {
|
|
49
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
50
|
+
if (!nxJson?.plugins) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const newPlugins = [];
|
|
54
|
+
const vitestPluginsToAdd = [];
|
|
55
|
+
const hasVitestPlugin = nxJson.plugins.some((p) => typeof p === 'string' ? p === '@nx/vitest' : p.plugin === '@nx/vitest');
|
|
56
|
+
for (const plugin of nxJson.plugins) {
|
|
57
|
+
// Handle string plugin format
|
|
58
|
+
if (typeof plugin === 'string') {
|
|
59
|
+
newPlugins.push(plugin);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Handle non-vite plugins
|
|
63
|
+
if (plugin.plugin !== '@nx/vite/plugin') {
|
|
64
|
+
newPlugins.push(plugin);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const options = plugin.options || {};
|
|
68
|
+
const { testTargetName, ciTargetName, ciGroupName, ...viteOptions } = options;
|
|
69
|
+
// Check if this plugin has test-related options
|
|
70
|
+
if (testTargetName || ciTargetName || ciGroupName) {
|
|
71
|
+
// Build vitest plugin for THIS specific vite plugin registration
|
|
72
|
+
const vitestPluginOptions = {};
|
|
73
|
+
if (testTargetName) {
|
|
74
|
+
vitestPluginOptions.testTargetName = testTargetName;
|
|
75
|
+
}
|
|
76
|
+
if (ciTargetName) {
|
|
77
|
+
vitestPluginOptions.ciTargetName = ciTargetName;
|
|
78
|
+
}
|
|
79
|
+
if (ciGroupName) {
|
|
80
|
+
vitestPluginOptions.ciGroupName = ciGroupName;
|
|
81
|
+
}
|
|
82
|
+
const vitestPlugin = {
|
|
83
|
+
plugin: '@nx/vitest',
|
|
84
|
+
};
|
|
85
|
+
if (Object.keys(vitestPluginOptions).length > 0) {
|
|
86
|
+
vitestPlugin.options = vitestPluginOptions;
|
|
87
|
+
}
|
|
88
|
+
if (plugin.include) {
|
|
89
|
+
vitestPlugin.include = plugin.include;
|
|
90
|
+
}
|
|
91
|
+
if (plugin.exclude) {
|
|
92
|
+
vitestPlugin.exclude = plugin.exclude;
|
|
93
|
+
}
|
|
94
|
+
vitestPluginsToAdd.push(vitestPlugin);
|
|
95
|
+
// Update the vite plugin to remove test options
|
|
96
|
+
const updatedVitePlugin = { ...plugin };
|
|
97
|
+
if (Object.keys(viteOptions).length > 0) {
|
|
98
|
+
updatedVitePlugin.options = viteOptions;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
delete updatedVitePlugin.options;
|
|
102
|
+
}
|
|
103
|
+
newPlugins.push(updatedVitePlugin);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
newPlugins.push(plugin);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Add all vitest plugins if @nx/vitest not already present
|
|
110
|
+
if (!hasVitestPlugin && vitestPluginsToAdd.length > 0) {
|
|
111
|
+
newPlugins.push(...vitestPluginsToAdd);
|
|
112
|
+
}
|
|
113
|
+
nxJson.plugins = newPlugins;
|
|
114
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
115
|
+
}
|
|
116
|
+
function migrateTargetDefaults(tree) {
|
|
117
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
118
|
+
if (!nxJson?.targetDefaults) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let hasChanges = false;
|
|
122
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
123
|
+
// Pattern A: Executor-keyed (e.g., "@nx/vite:test": { ... })
|
|
124
|
+
if (targetOrExecutor === '@nx/vite:test') {
|
|
125
|
+
// Move config to new executor key
|
|
126
|
+
nxJson.targetDefaults['@nx/vitest:test'] ??= {};
|
|
127
|
+
Object.assign(nxJson.targetDefaults['@nx/vitest:test'], targetConfig);
|
|
128
|
+
delete nxJson.targetDefaults['@nx/vite:test'];
|
|
129
|
+
hasChanges = true;
|
|
130
|
+
}
|
|
131
|
+
// Pattern B: Target-name-keyed (e.g., "test": { "executor": "@nx/vite:test", ... })
|
|
132
|
+
else if (targetConfig.executor === '@nx/vite:test') {
|
|
133
|
+
targetConfig.executor = '@nx/vitest:test';
|
|
134
|
+
hasChanges = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (hasChanges) {
|
|
138
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
139
|
+
}
|
|
140
|
+
}
|