@@ -15,16 +15,25 @@ const options = defineAddonOptions()
1515 } )
1616 . build ( ) ;
1717
18+ // Manage only version before current
19+ let vitestV3Installed = false ;
20+
1821export default defineAddon ( {
1922 id : 'vitest' ,
2023 shortDescription : 'unit testing' ,
2124 homepage : 'https://vitest.dev' ,
2225 options,
23- run : ( { sv, files, typescript, kit, options } ) => {
26+
27+ run : ( { sv, files, typescript, kit, options, dependencyVersion } ) => {
2428 const ext = typescript ? 'ts' : 'js' ;
2529 const unitTesting = options . usages . includes ( 'unit' ) ;
2630 const componentTesting = options . usages . includes ( 'component' ) ;
2731
32+ vitestV3Installed = ( dependencyVersion ( 'vitest' ) ?? '' )
33+ . replaceAll ( '^' , '' )
34+ . replaceAll ( '~' , '' )
35+ ?. startsWith ( '3.' ) ;
36+
2837 sv . devDependency ( 'vitest' , '^4.0.10' ) ;
2938
3039 if ( componentTesting ) {
@@ -149,5 +158,27 @@ export default defineAddon({
149158
150159 return generateCode ( ) ;
151160 } ) ;
161+ } ,
162+
163+ nextSteps : ( { highlighter, typescript, options } ) => {
164+ const toReturn : string [ ] = [ ] ;
165+
166+ if ( vitestV3Installed ) {
167+ const componentTesting = options . usages . includes ( 'component' ) ;
168+ if ( componentTesting ) {
169+ toReturn . push ( `Uninstall ${ highlighter . command ( '@vitest/browser' ) } package` ) ;
170+ toReturn . push (
171+ `Update usage from ${ highlighter . command ( "'@vitest/browser...'" ) } to ${ highlighter . command ( "'vitest/browser'" ) } `
172+ ) ;
173+ }
174+ toReturn . push (
175+ `${ highlighter . optional ( 'Optional' ) } Check ${ highlighter . path ( './vite.config.ts' ) } and remove duplicate project definitions`
176+ ) ;
177+ toReturn . push (
178+ `${ highlighter . optional ( 'Optional' ) } Remove ${ highlighter . path ( './vitest-setup-client' + ( typescript ? '.ts' : '.js' ) ) } file`
179+ ) ;
180+ }
181+
182+ return toReturn ;
152183 }
153184} ) ;
0 commit comments