@@ -6,15 +6,6 @@ import { tmpdir } from 'node:os'
66import path from 'path'
77import { NextInstance } from './base'
88
9- type NetlifyDeployResponse = {
10- name : string
11- site_id : string
12- site_name : string
13- deploy_id : string
14- deploy_url : string
15- logs : string
16- }
17-
189async function packNextRuntimeImpl ( ) {
1910 const runtimePackDir = await fs . mkdtemp ( path . join ( tmpdir ( ) , 'opennextjs-netlify-pack' ) )
2011
@@ -133,7 +124,7 @@ export class NextDeployInstance extends NextInstance {
133124
134125 const deployRes = await execa (
135126 'npx' ,
136- [ 'netlify' , 'deploy' , '--build' , '--json' , '-- message', deployTitle ?? '' ] ,
127+ [ 'netlify' , 'deploy' , '--build' , '--message' , deployTitle ?? '' ] ,
137128 {
138129 cwd : this . testDir ,
139130 reject : false ,
@@ -142,17 +133,29 @@ export class NextDeployInstance extends NextInstance {
142133
143134 if ( deployRes . exitCode !== 0 ) {
144135 throw new Error (
145- `Failed to deploy project ${ deployRes . stdout } ${ deployRes . stderr } ( ${ deployRes . exitCode } ) ` ,
136+ `Failed to deploy project ( ${ deployRes . exitCode } ) ${ deployRes . stdout } ${ deployRes . stderr } ` ,
146137 )
147138 }
148139
149140 try {
150- const data : NetlifyDeployResponse = JSON . parse ( deployRes . stdout )
151- this . _url = data . deploy_url
141+ const [ url ] = new RegExp ( / h t t p s : .+ \. n e t l i f y \. a p p / gm) . exec ( deployRes . stdout ) || [ ]
142+ if ( ! url ) {
143+ throw new Error ( 'Could not extract the URL from the build logs' )
144+ }
145+ const [ deployID ] = new URL ( url ) . host . split ( '--' )
146+ this . _url = url
152147 this . _parsedUrl = new URL ( this . _url )
153- this . _deployId = data . deploy_id
154- require ( 'console' ) . log ( `Deployment URL: ${ data . deploy_url } ` )
155- require ( 'console' ) . log ( `Logs: ${ data . logs } ` )
148+ this . _deployId = deployID
149+ this . _cliOutput = deployRes . stdout + deployRes . stdout
150+ require ( 'console' ) . log ( `Deployment URL: ${ this . _url } ` )
151+
152+ const [ buildLogsUrl ] =
153+ new RegExp ( / h t t p s : \/ \/ a p p \. n e t l i f y \. c o m \/ s i t e s \/ .+ \/ d e p l o y s \/ [ 0 - 9 a - f ] + / gm) . exec (
154+ deployRes . stdout ,
155+ ) || [ ]
156+ if ( buildLogsUrl ) {
157+ require ( 'console' ) . log ( `Logs: ${ buildLogsUrl } ` )
158+ }
156159 } catch ( err ) {
157160 console . error ( err )
158161 throw new Error ( `Failed to parse deploy output: ${ deployRes . stdout } ` )
0 commit comments