@@ -586,34 +586,42 @@ ipcMain.handle('deploy-to-vercel', async (_event, params: { databaseUrl: string,
586586 try {
587587 // 0. Ensure linked to a UNIQUE project name
588588 // This creates/links the Vercel project with a name unique to THIS local project
589- await runVercelCommand ( `npx vercel link --project ${ vercelProjectName } --yes` )
589+ await runVercelCommand ( `npx vercel@latest link --project ${ vercelProjectName } --yes` )
590590
591591 // 1. Set DATABASE_URL
592- const resDb = await runVercelCommand ( `npx vercel env add DATABASE_URL production` , params . databaseUrl )
592+ const resDb = await runVercelCommand ( `npx vercel@latest env add DATABASE_URL production` , params . databaseUrl )
593593 if ( ! resDb . success ) {
594594 mainWindow ?. webContents . send ( 'deploy-output' , `Note: Proceeding even if env var exists or failed to set.\n` )
595595 }
596596
597597 // 2. Set ADMIN_TOKEN if provided
598598 if ( params . adminToken ) {
599- const resAdmin = await runVercelCommand ( `npx vercel env add ADMIN_TOKEN production` , params . adminToken )
599+ const resAdmin = await runVercelCommand ( `npx vercel@latest env add ADMIN_TOKEN production` , params . adminToken )
600600 if ( ! resAdmin . success ) {
601601 mainWindow ?. webContents . send ( 'deploy-output' , `Note: Proceeding even if env var exists or failed to set.\n` )
602602 }
603603 }
604604
605605 // 3. Final Production Deployment
606- const resDeploy = await runVercelCommand ( `npx vercel --prod --yes` )
606+ const resDeploy = await runVercelCommand ( `npx vercel@latest --prod --yes` )
607607
608608 if ( resDeploy . success && resDeploy . output ) {
609609 const lines = resDeploy . output . split ( '\n' )
610610 let url = ''
611611
612612 for ( const line of lines ) {
613- const prodMatch = line . match ( / P r o d u c t i o n : \s * ( h t t p s : \/ \/ \S + ) / i )
613+ // Look for Aliased URL (preferred clean domain )
614614 const aliasMatch = line . match ( / A l i a s e d : \s * ( h t t p s : \/ \/ \S + ) / i)
615- if ( aliasMatch ) url = aliasMatch [ 1 ]
616- else if ( prodMatch && ! url ) url = prodMatch [ 1 ]
615+ if ( aliasMatch ) {
616+ url = aliasMatch [ 1 ]
617+ continue
618+ }
619+
620+ // Look for Production URL (backup if alias not found yet)
621+ const prodMatch = line . match ( / P r o d u c t i o n : \s * ( h t t p s : \/ \/ \S + ) / i)
622+ if ( prodMatch && ! url ) {
623+ url = prodMatch [ 1 ]
624+ }
617625 }
618626
619627 if ( url ) {
@@ -642,7 +650,7 @@ ipcMain.handle('delete-vercel-project', async (_event, params: { projectId: stri
642650
643651 return new Promise ( ( resolve ) => {
644652 const shell = process . platform === 'win32' ? 'cmd' : 'sh'
645- const command = `npx vercel project rm ${ vercelProjectName } `
653+ const command = `npx vercel@latest project rm ${ vercelProjectName } `
646654 const args = process . platform === 'win32' ? [ '/c' , command ] : [ '-c' , command ]
647655
648656 const child = spawn ( shell , args , { cwd : serverPath } )
0 commit comments