11import assert from 'node:assert' ;
22import path from 'node:path' ;
33
4+ import * as prompts from '@voidzero-dev/vite-plus-prompts' ;
5+ import colors from 'picocolors' ;
6+
47import type { WorkspaceInfo } from '../../types/index.js' ;
58import type { ExecutionResult } from '../command.js' ;
69import { discoverTemplate } from '../discovery.js' ;
@@ -41,11 +44,24 @@ export async function executeBuiltinTemplate(
4144 false ,
4245 options ?. silent ?? false ,
4346 ) ;
47+ if ( result . exitCode !== 0 ) {
48+ return { ...result , projectDir : templateInfo . targetDir } ;
49+ }
4450 const fullPath = path . join ( workspaceInfo . rootDir , templateInfo . targetDir ) ;
4551 setPackageName ( fullPath , templateInfo . packageName ) ;
4652 return { ...result , projectDir : templateInfo . targetDir } ;
4753 }
4854
55+ // Unknown vite: template (e.g. vite:test) — application was already rewritten to create-vite@latest
56+ if ( templateInfo . command . startsWith ( 'vite:' ) ) {
57+ if ( ! options ?. silent ) {
58+ prompts . log . error (
59+ `Unknown builtin template "${ templateInfo . command } ". Run ${ colors . yellow ( 'vp create --list' ) } to see available templates.` ,
60+ ) ;
61+ }
62+ return { exitCode : 1 } ;
63+ }
64+
4965 // Handle remote/external templates with fspy monitoring
5066 const result = await runRemoteTemplateCommand (
5167 workspaceInfo ,
@@ -54,6 +70,9 @@ export async function executeBuiltinTemplate(
5470 false ,
5571 options ?. silent ?? false ,
5672 ) ;
73+ if ( result . exitCode !== 0 ) {
74+ return { ...result , projectDir : templateInfo . targetDir } ;
75+ }
5776 const fullPath = path . join ( workspaceInfo . rootDir , templateInfo . targetDir ) ;
5877 // set package name in the project directory
5978 setPackageName ( fullPath , templateInfo . packageName ) ;
0 commit comments