Skip to content

Commit 185c0de

Browse files
committed
fix(create): handle unknown vite templates and improve error logging
1 parent 71b90b4 commit 185c0de

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

packages/cli/src/create/templates/builtin.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import assert from 'node:assert';
22
import path from 'node:path';
33

4+
import * as prompts from '@voidzero-dev/vite-plus-prompts';
5+
import colors from 'picocolors';
6+
47
import type { WorkspaceInfo } from '../../types/index.js';
58
import type { ExecutionResult } from '../command.js';
69
import { 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

Comments
 (0)