Skip to content

Commit 9cb8102

Browse files
committed
feat(create): clearer --no-interactive message for @org templates
Rewrite the `vp create @org --no-interactive` output to match the existing `vp create` missing-argument message in `bin.ts:387-399`. Same opening sentence shape, same `Examples:` block — users get a consistent error shape across the command. Before: error: vp create @org requires a template selection in non-interactive mode. available templates from @org/create: ... hint: rerun with an explicit selection, e.g. `vp create @org/web`, ... After: A template name is required when running `vp create @org` in non-interactive mode. Available templates in @org/create: ... Examples: # Scaffold a specific template from the org vp create @org/web --no-interactive # Or use a Vite+ built-in template vp create vite:application --no-interactive Changes: - Drop the `error:` prefix. Matches the existing missing-arg pattern, which uses plain `console.error` with no prefix — it's a usage message, not an error to recover from. - Lead with the same "A template name is required..." sentence shape users already see for bare `vp create --no-interactive`. - Table kept unchanged for AI agents / script parsing. - Replace the `hint:` tail with an `Examples:` block containing full runnable commands (both with `--no-interactive`), so users can copy-paste verbatim. - Also simplify the schema-error / network-error path: drop the redundant `Failed to resolve org template manifest` cancel line that stacked beneath the real error. Just `prompts.log.error(msg); process.exit(1)` with the schema message that already includes the package name. Snap outputs regenerated; RFC and guide updated to match. 263 unit tests pass; 6 org snap-tests byte-stable.
1 parent 81105fe commit 9cb8102

7 files changed

Lines changed: 63 additions & 40 deletions

File tree

docs/guide/create.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,21 @@ The picker always appends a trailing **Vite+ built-in templates** entry so `vite
204204
`vp create @org --no-interactive` prints a stable, fixed-column table of the manifest (name, description, resolved template specifier) and exits 1. The output is machine-parseable, so scripts and AI agents can recover the list without a separate `--list` flag:
205205

206206
```
207-
error: vp create @your-org requires a template selection in non-interactive mode.
207+
A template name is required when running `vp create @your-org` in non-interactive mode.
208208
209-
available templates from @your-org/create:
209+
Available templates in @your-org/create:
210210
211211
NAME DESCRIPTION TEMPLATE
212212
web Web app template (Vite + React) @your-org/template-web
213213
library TypeScript library template @your-org/template-library
214214
demo Bundled demo template ./templates/demo
215215
216-
hint: rerun with an explicit selection, e.g. `vp create @your-org/web`,
217-
or use a Vite+ built-in template like `vp create vite:application`.
216+
Examples:
217+
# Scaffold a specific template from the org
218+
vp create @your-org/web --no-interactive
219+
220+
# Or use a Vite+ built-in template
221+
vp create vite:application --no-interactive
218222
```
219223

220224
### Publishing checklist
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[1]> node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org --no-interactive # `../outside` path rejected at schema-validation, before any tarball fetch
22

33
@your-org/create: vp.templates[0].template escapes the package root: ../outside
4-
Failed to resolve org template manifest
5-
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[1]> node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org --no-interactive # invalid manifest -> schema error
22

33
@your-org/create: vp.templates[0].template must be a non-empty string
4-
Failed to resolve org template manifest
5-
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
[1]> node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org --no-interactive # inside monorepo, hides monorepo:true entries + shows omitted footer
2-
error: vp create @your-org requires a template selection in non-interactive mode.
32

4-
available templates from @your-org/create:
3+
A template name is required when running `vp create @your-org` in non-interactive mode.
4+
5+
Available templates in @your-org/create:
56

67
NAME DESCRIPTION TEMPLATE
78
web Web app template (Vite + React) @your-org/template-web
89
library TypeScript library template @your-org/template-library
910

1011
(omitted 1 monorepo-only entry because this workspace is already a monorepo)
1112

12-
hint: rerun with an explicit selection, e.g. `vp create @your-org/web`,
13-
or use a Vite+ built-in template like `vp create vite:application`.
13+
Examples:
14+
# Scaffold a specific template from the org
15+
vp create @your-org/web --no-interactive
16+
17+
# Or use a Vite+ built-in template
18+
vp create vite:application --no-interactive
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
[1]> node $SNAP_CASES_DIR/.shared/mock-npm-registry.mjs -- vp create @your-org --no-interactive # prints manifest table, exits 1
2-
error: vp create @your-org requires a template selection in non-interactive mode.
32

4-
available templates from @your-org/create:
3+
A template name is required when running `vp create @your-org` in non-interactive mode.
4+
5+
Available templates in @your-org/create:
56

67
NAME DESCRIPTION TEMPLATE
78
web Web app template @your-org/template-web
89
library TypeScript library template @your-org/template-library
910

10-
hint: rerun with an explicit selection, e.g. `vp create @your-org/web`,
11-
or use a Vite+ built-in template like `vp create vite:application`.
11+
Examples:
12+
# Scaffold a specific template from the org
13+
vp create @your-org/web --no-interactive
14+
15+
# Or use a Vite+ built-in template
16+
vp create vite:application --no-interactive

packages/cli/src/create/org-resolve.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as prompts from '@voidzero-dev/vite-plus-prompts';
22

33
import { findViteConfigUp } from '../resolve-vite-config.ts';
4-
import { errorMsg } from '../utils/terminal.ts';
54
import {
65
isRelativePath,
76
OrgManifestSchemaError,
@@ -41,30 +40,37 @@ function printNonInteractiveTable(
4140
isMonorepo: boolean,
4241
): void {
4342
const { lines, filteredCount } = formatManifestTable(manifest, isMonorepo);
44-
errorMsg(`vp create ${orgSpec.scope} requires a template selection in non-interactive mode.`);
45-
const stderrBody: string[] = [
43+
const firstVisible = manifest.templates.find((t) => !(t.monorepo && isMonorepo));
44+
const body: string[] = [
45+
'',
46+
`A template name is required when running \`vp create ${orgSpec.scope}\` in non-interactive mode.`,
4647
'',
47-
`available templates from ${manifest.packageName}:`,
48+
`Available templates in ${manifest.packageName}:`,
4849
'',
4950
...lines,
5051
];
5152
if (filteredCount > 0) {
52-
stderrBody.push(
53+
body.push(
5354
'',
5455
`(omitted ${filteredCount} monorepo-only ${
5556
filteredCount === 1 ? 'entry' : 'entries'
5657
} because this workspace is already a monorepo)`,
5758
);
5859
}
59-
stderrBody.push('');
60-
const firstVisible = manifest.templates.find((t) => !(t.monorepo && isMonorepo));
60+
body.push('', 'Examples:');
6161
if (firstVisible) {
62-
stderrBody.push(
63-
`hint: rerun with an explicit selection, e.g. \`vp create ${orgSpec.scope}/${firstVisible.name}\`,`,
62+
body.push(
63+
' # Scaffold a specific template from the org',
64+
` vp create ${orgSpec.scope}/${firstVisible.name} --no-interactive`,
65+
'',
6466
);
6567
}
66-
stderrBody.push(' or use a Vite+ built-in template like `vp create vite:application`.');
67-
process.stderr.write(`${stderrBody.join('\n')}\n`);
68+
body.push(
69+
' # Or use a Vite+ built-in template',
70+
' vp create vite:application --no-interactive',
71+
'',
72+
);
73+
process.stderr.write(body.join('\n'));
6874
}
6975

7076
function rejectMonorepoEntryInsideMonorepo(entry: OrgTemplateEntry, isMonorepo: boolean): void {
@@ -111,19 +117,17 @@ export async function resolveOrgManifestForCreate(args: {
111117
return { kind: 'passthrough' };
112118
}
113119

120+
// Never silently skip the picker when the user explicitly typed `@org`.
114121
let manifest: OrgManifest | null;
115122
try {
116123
manifest = await readOrgManifest(orgSpec.scope);
117124
} catch (error) {
118-
if (error instanceof OrgManifestSchemaError) {
119-
prompts.log.error(error.message);
120-
} else {
121-
prompts.log.error(
122-
`Failed to read ${orgSpec.scope}/create manifest: ${(error as Error).message}`,
123-
);
124-
}
125-
// Never silently skip the picker when the user explicitly typed `@org`.
126-
cancelAndExit('Failed to resolve org template manifest', 1);
125+
const message =
126+
error instanceof OrgManifestSchemaError
127+
? error.message
128+
: `Failed to read ${orgSpec.scope}/create manifest: ${(error as Error).message}`;
129+
prompts.log.error(message);
130+
process.exit(1);
127131
}
128132

129133
if (!manifest) {

rfcs/create-org-default-templates.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ context (name, description, underlying template) to pick an appropriate
501501
option and retry with `vp create @org/<name>`:
502502

503503
```
504-
error: vp create @your-org requires a template selection in non-interactive mode.
504+
A template name is required when running `vp create @your-org` in non-interactive mode.
505505
506-
available templates from @your-org/create:
506+
Available templates in @your-org/create:
507507
508508
NAME DESCRIPTION TEMPLATE
509509
web Web app template (Vite + React) @your-org/template-web
@@ -512,10 +512,19 @@ available templates from @your-org/create:
512512
library TypeScript library template @your-org/template-library
513513
demo Bundled demo template ./templates/demo
514514
515-
hint: rerun with an explicit selection, e.g. `vp create @your-org/web`,
516-
or use a Vite+ built-in template like `vp create vite:application`.
515+
Examples:
516+
# Scaffold a specific template from the org
517+
vp create @your-org/web --no-interactive
518+
519+
# Or use a Vite+ built-in template
520+
vp create vite:application --no-interactive
517521
```
518522

523+
Shape matches the existing `vp create` missing-argument message
524+
(`packages/cli/src/create/bin.ts:387-399`) — same opening sentence pattern,
525+
same `Examples:` block — so users see a consistent shape for any
526+
missing-template error across the command.
527+
519528
Notes:
520529

521530
- Output is stable and machine-parseable (fixed column order, whitespace-

0 commit comments

Comments
 (0)