@@ -70,7 +70,11 @@ export default class Setup extends BaseCommand {
7070
7171 async run ( ) : Promise < JsonEnvelope > {
7272 const { flags } = await this . parse ( Setup ) ;
73- await this . toMeta ( flags ) ;
73+ try {
74+ await this . toMeta ( flags ) ;
75+ } catch ( error ) {
76+ throw localSetupHint ( error , flags . framework , this . config . version ) ;
77+ }
7478 const { cwd, nonInteractive, dryRun, force } = this . meta ;
7579
7680 if ( await hasZitadelConfig ( cwd ) ) {
@@ -170,6 +174,7 @@ export default class Setup extends BaseCommand {
170174 answers . server ,
171175 this . meta . cliVersion ,
172176 issuer ,
177+ framework . id ,
173178 ) ;
174179 consola . success ( `Created project ${ project . id } ` ) ;
175180
@@ -180,6 +185,7 @@ export default class Setup extends BaseCommand {
180185 issuer,
181186 server : answers . server ,
182187 cliVersion : this . meta . cliVersion ,
188+ scaffoldedFramework,
183189 } ;
184190 consola . start ( `Patching project files${ dryRun ? " (dry run)" : "" } ` ) ;
185191 const result = await orca . patcherFor ( framework . id ) . patch ( ctx , { cwd, dryRun, force } ) ;
@@ -290,6 +296,7 @@ async function createProjectWithLocalHint(
290296 server : string ,
291297 cliVersion : string ,
292298 issuer : string ,
299+ framework : string ,
293300) : Promise < CreateProject201 > {
294301 try {
295302 // Register the app's own origin so the backend's origin check allows the
@@ -300,11 +307,11 @@ async function createProjectWithLocalHint(
300307 throw new ZitadelError ( normalized . code , normalized . message , {
301308 hint :
302309 `${ normalized . hint ? `${ normalized . hint } ` : "" } ` +
303- "If you meant to use a local Zitadel server, run npx @zitadel/cli@alpha start " +
304- " and retry setup with --server local." ,
310+ "If you meant to use a local Zitadel server, start it first " +
311+ ` and retry setup with --framework ${ framework } -- server local.` ,
305312 nextCommands : [
306313 publicCliCommand ( "start" , cliVersion ) ,
307- publicCliCommand ( " setup --server local" , cliVersion ) ,
314+ publicCliCommand ( ` setup --framework ${ framework } -- server local` , cliVersion ) ,
308315 ] ,
309316 details : {
310317 server,
@@ -314,6 +321,29 @@ async function createProjectWithLocalHint(
314321 }
315322}
316323
324+ function localSetupHint ( error : unknown , framework : string | undefined , cliVersion : string ) : unknown {
325+ const normalized = toZitadelError ( error ) ;
326+ if ( normalized . code !== "E_LOCAL_SERVER_NOT_RUNNING" ) {
327+ return error ;
328+ }
329+
330+ const setupCommand = framework
331+ ? `setup --framework ${ framework } --server local`
332+ : "setup --server local" ;
333+
334+ return new ZitadelError ( normalized . code , normalized . message , {
335+ hint :
336+ `${ normalized . hint ? `${ normalized . hint } ` : "" } ` +
337+ "Start local Zitadel first, then rerun setup. " +
338+ "After setup succeeds, follow its next_commands to start the app and verify registration, logout, and login in the browser." ,
339+ nextCommands : [
340+ publicCliCommand ( "start" , cliVersion ) ,
341+ publicCliCommand ( setupCommand , cliVersion ) ,
342+ ] ,
343+ details : normalized . details ,
344+ } ) ;
345+ }
346+
317347/** Renders an absolute path relative to `cwd` for human-readable output. */
318348function relativeDisplay ( cwd : string , path : string ) : string {
319349 return path . startsWith ( cwd ) ? path . slice ( cwd . length + 1 ) : path ;
@@ -378,6 +408,7 @@ const SENTENCE_BY_PATH: Record<string, { subject: string }> = {
378408 ".env.example" : { subject : "the .env example template" } ,
379409 ".env.local" : { subject : "the local development environment variables" } ,
380410 ".zitadel/state.json" : { subject : "the empty sync state file" } ,
411+ "app/page.tsx" : { subject : "the auth home page" } ,
381412 "app/login/page.tsx" : { subject : "the login page" } ,
382413 "app/register/page.tsx" : { subject : "the registration page" } ,
383414 "app/profile/page.tsx" : { subject : "the profile page" } ,
@@ -414,6 +445,7 @@ function buildSummary(opts: {
414445 } ) ;
415446 }
416447 for ( const [ label , suffix ] of [
448+ [ "Home page" , "app/page.tsx" ] ,
417449 [ "Login page" , "app/login/page.tsx" ] ,
418450 [ "Register page" , "app/register/page.tsx" ] ,
419451 [ "Profile page" , "app/profile/page.tsx" ] ,
0 commit comments