@@ -272,13 +272,15 @@ export async function env(
272272 tursoSetup . stop (
273273 `${ label ( 'Turso' , TursoColorway , color . black ) } Failed to retrieve a valid database URL.`
274274 ) ;
275- ctx . prompt . log . error ( StudioCMSColorwayError ( `Invalid database URL: ${ dbURL || 'undefined' } ` ) ) ;
276-
275+ ctx . prompt . log . error (
276+ StudioCMSColorwayError ( `Invalid database URL: ${ dbURL || 'undefined' } ` )
277+ ) ;
278+
277279 const manualURL = await ctx . prompt . text ( {
278280 message : 'Enter your Turso database URL manually' ,
279281 placeholder : 'libsql://your-database.turso.io' ,
280282 } ) ;
281-
283+
282284 if ( typeof manualURL === 'symbol' ) {
283285 ctx . promptCancel ( manualURL ) ;
284286 } else {
@@ -292,13 +294,17 @@ export async function env(
292294 tursoSetup . stop (
293295 `${ label ( 'Turso' , TursoColorway , color . black ) } Failed to retrieve a valid token.`
294296 ) ;
295- ctx . prompt . log . error ( StudioCMSColorwayError ( `Invalid database token: ${ dbToken ? 'too short' : 'undefined' } ` ) ) ;
296-
297+ ctx . prompt . log . error (
298+ StudioCMSColorwayError (
299+ `Invalid database token: ${ dbToken ? 'too short' : 'undefined' } `
300+ )
301+ ) ;
302+
297303 const manualToken = await ctx . prompt . text ( {
298304 message : 'Enter your Turso database token manually' ,
299305 placeholder : 'eyJh...Nzc2' ,
300306 } ) ;
301-
307+
302308 if ( typeof manualToken === 'symbol' ) {
303309 ctx . promptCancel ( manualToken ) ;
304310 } else {
@@ -313,28 +319,29 @@ export async function env(
313319 tursoSetup . message (
314320 `${ label ( 'Turso' , TursoColorway , color . black ) } Verifying database connection...`
315321 ) ;
316-
322+
317323 try {
318324 // Test connection using curl (doesn't require additional dependencies)
319325 const connectionTest = await runShellCommand (
320326 `curl -s -o /dev/null -w "%{http_code}" ${ envBuilderOpts . astroDbRemoteUrl } /health -H "Authorization: Bearer ${ envBuilderOpts . astroDbToken } "`
321327 ) ;
322-
328+
323329 const statusCode = Number . parseInt ( connectionTest . trim ( ) , 10 ) ;
324-
330+
325331 if ( statusCode >= 200 && statusCode < 300 ) {
326- ctx . debug && ctx . logger . debug ( `Database connection successful: ${ statusCode } ` ) ;
332+ ctx . debug &&
333+ ctx . logger . debug ( `Database connection successful: ${ statusCode } ` ) ;
327334 } else {
328335 ctx . debug && ctx . logger . debug ( `Database connection failed: ${ statusCode } ` ) ;
329336 ctx . prompt . log . warn (
330337 `${ label ( 'Warning' , StudioCMSColorwayWarnBg , color . black ) } Could not verify database connection. Status: ${ statusCode } `
331338 ) ;
332-
339+
333340 const confirmContinue = await ctx . prompt . confirm ( {
334341 message : 'Continue with these credentials anyway?' ,
335342 initialValue : true ,
336343 } ) ;
337-
344+
338345 if ( typeof confirmContinue === 'symbol' ) {
339346 ctx . promptCancel ( confirmContinue ) ;
340347 } else if ( ! confirmContinue ) {
@@ -344,7 +351,9 @@ export async function env(
344351 astroDbRemoteUrl : ( ) =>
345352 ctx . prompt . text ( {
346353 message : 'Remote URL for AstroDB' ,
347- initialValue : envBuilderOpts . astroDbRemoteUrl || 'libsql://your-database.turso.io' ,
354+ initialValue :
355+ envBuilderOpts . astroDbRemoteUrl ||
356+ 'libsql://your-database.turso.io' ,
348357 } ) ,
349358 astroDbToken : ( ) =>
350359 ctx . prompt . text ( {
@@ -356,13 +365,16 @@ export async function env(
356365 onCancel : ( ) => ctx . promptOnCancel ( ) ,
357366 }
358367 ) ;
359-
368+
360369 envBuilderOpts . astroDbRemoteUrl = newCredentials . astroDbRemoteUrl || '' ;
361370 envBuilderOpts . astroDbToken = newCredentials . astroDbToken || '' ;
362371 }
363372 }
364373 } catch ( error ) {
365- ctx . debug && ctx . logger . debug ( `Database connection test error: ${ error instanceof Error ? error . message : 'unknown error' } ` ) ;
374+ ctx . debug &&
375+ ctx . logger . debug (
376+ `Database connection test error: ${ error instanceof Error ? error . message : 'unknown error' } `
377+ ) ;
366378 ctx . prompt . log . warn (
367379 `${ label ( 'Warning' , StudioCMSColorwayWarnBg , color . black ) } Could not verify database connection due to an error.`
368380 ) ;
@@ -414,59 +426,65 @@ export async function env(
414426 // Validate the manually entered credentials
415427 let dbUrl = envBuilderStep_AstroDB . astroDbRemoteUrl || '' ;
416428 let dbToken = envBuilderStep_AstroDB . astroDbToken || '' ;
417-
429+
418430 // Check URL format
419431 if ( ! dbUrl . startsWith ( 'libsql://' ) && dbUrl !== '' ) {
420432 ctx . prompt . log . warn (
421433 `${ label ( 'Warning' , StudioCMSColorwayWarnBg , color . black ) } The database URL should start with 'libsql://'.`
422434 ) ;
423-
435+
424436 const fixUrl = await ctx . prompt . confirm ( {
425437 message : 'Would you like to prepend "libsql://" to your URL?' ,
426438 initialValue : true ,
427439 } ) ;
428-
440+
429441 if ( typeof fixUrl === 'symbol' ) {
430442 ctx . promptCancel ( fixUrl ) ;
431443 } else if ( fixUrl ) {
432444 dbUrl = `libsql://${ dbUrl } ` ;
433445 }
434446 }
435-
447+
436448 // Verify the credentials with a connection test
437449 if ( dbUrl && dbToken && dbToken !== 'your-astrodb-token' ) {
438450 const verifyConnection = await ctx . prompt . confirm ( {
439451 message : 'Would you like to verify these credentials?' ,
440452 initialValue : true ,
441453 } ) ;
442-
454+
443455 if ( typeof verifyConnection === 'symbol' ) {
444456 ctx . promptCancel ( verifyConnection ) ;
445457 } else if ( verifyConnection ) {
446458 const connectionTestSpinner = ctx . prompt . spinner ( ) ;
447- connectionTestSpinner . start ( `${ label ( 'Turso' , TursoColorway , color . black ) } Verifying database connection...` ) ;
448-
459+ connectionTestSpinner . start (
460+ `${ label ( 'Turso' , TursoColorway , color . black ) } Verifying database connection...`
461+ ) ;
462+
449463 try {
450464 // Test connection using curl (doesn't require additional dependencies)
451465 const connectionTest = await runShellCommand (
452466 `curl -s -o /dev/null -w "%{http_code}" ${ dbUrl } /health -H "Authorization: Bearer ${ dbToken } "`
453467 ) ;
454-
468+
455469 const statusCode = Number . parseInt ( connectionTest . trim ( ) , 10 ) ;
456-
470+
457471 if ( statusCode >= 200 && statusCode < 300 ) {
458- connectionTestSpinner . stop ( `${ label ( 'Turso' , TursoColorway , color . black ) } Connection successful!` ) ;
472+ connectionTestSpinner . stop (
473+ `${ label ( 'Turso' , TursoColorway , color . black ) } Connection successful!`
474+ ) ;
459475 } else {
460- connectionTestSpinner . stop ( `${ label ( 'Turso' , TursoColorway , color . black ) } Connection failed (${ statusCode } ).` ) ;
476+ connectionTestSpinner . stop (
477+ `${ label ( 'Turso' , TursoColorway , color . black ) } Connection failed (${ statusCode } ).`
478+ ) ;
461479 ctx . prompt . log . warn (
462480 `${ label ( 'Warning' , StudioCMSColorwayWarnBg , color . black ) } Could not verify database connection. Status: ${ statusCode } `
463481 ) ;
464-
482+
465483 const retryCredentials = await ctx . prompt . confirm ( {
466484 message : 'Would you like to enter different credentials?' ,
467485 initialValue : true ,
468486 } ) ;
469-
487+
470488 if ( typeof retryCredentials === 'symbol' ) {
471489 ctx . promptCancel ( retryCredentials ) ;
472490 } else if ( retryCredentials ) {
@@ -487,21 +505,26 @@ export async function env(
487505 onCancel : ( ) => ctx . promptOnCancel ( ) ,
488506 }
489507 ) ;
490-
508+
491509 dbUrl = newCredentials . astroDbRemoteUrl || '' ;
492510 dbToken = newCredentials . astroDbToken || '' ;
493511 }
494512 }
495513 } catch ( error ) {
496- connectionTestSpinner . stop ( `${ label ( 'Turso' , TursoColorway , color . black ) } Connection test failed.` ) ;
497- ctx . debug && ctx . logger . debug ( `Database connection test error: ${ error instanceof Error ? error . message : 'unknown error' } ` ) ;
514+ connectionTestSpinner . stop (
515+ `${ label ( 'Turso' , TursoColorway , color . black ) } Connection test failed.`
516+ ) ;
517+ ctx . debug &&
518+ ctx . logger . debug (
519+ `Database connection test error: ${ error instanceof Error ? error . message : 'unknown error' } `
520+ ) ;
498521 ctx . prompt . log . warn (
499522 `${ label ( 'Warning' , StudioCMSColorwayWarnBg , color . black ) } Could not verify database connection due to an error.`
500523 ) ;
501524 }
502525 }
503526 }
504-
527+
505528 // Save the validated credentials
506529 envBuilderOpts . astroDbRemoteUrl = dbUrl ;
507530 envBuilderOpts . astroDbToken = dbToken ;
@@ -539,14 +562,14 @@ export async function env(
539562 // Preserve AstroDB URL and token while merging
540563 const previousDbValues = {
541564 astroDbRemoteUrl : envBuilderOpts . astroDbRemoteUrl ,
542- astroDbToken : envBuilderOpts . astroDbToken
565+ astroDbToken : envBuilderOpts . astroDbToken ,
543566 } ;
544-
545- envBuilderOpts = {
567+
568+ envBuilderOpts = {
546569 ...envBuilderOpts ,
547570 ...envBuilderStep1 ,
548571 astroDbRemoteUrl : previousDbValues . astroDbRemoteUrl || '' ,
549- astroDbToken : previousDbValues . astroDbToken || ''
572+ astroDbToken : previousDbValues . astroDbToken || '' ,
550573 } ;
551574
552575 if ( envBuilderStep1 . oAuthOptions . includes ( 'github' ) ) {
0 commit comments