@@ -4,14 +4,15 @@ import {getShortUUID, useProjectJobListener, useStartShipOnMount} from '@cli/uti
44import { getJobBuildsRetry } from '@cli/api/index.js'
55
66import { CommandContext , GameContext , JobProgress , QRCodeTerminal } from './index.js'
7- import { Job , Platform } from '@cli/types/api.js'
7+ import { Job , Platform } from '@cli/types/api.js'
8+ import { useGoRuntimeLogListener } from '@cli/utils/hooks/useGoRuntimeLogListener.js'
89
910interface Props {
1011 onComplete : ( ) => void
1112 onError : ( error : any ) => void
1213}
1314
14- export const Go = ( { onComplete, onError} : Props ) : JSX . Element | null => {
15+ export const Go = ( { onComplete, onError} : Props ) : JSX . Element | null => {
1516 const { command} = useContext ( CommandContext )
1617 const { gameId} = useContext ( GameContext )
1718 if ( ! command || ! gameId ) return null
@@ -23,18 +24,27 @@ interface GoCommandProps extends Props {
2324 gameId : string
2425}
2526
26- const GoCommand = ( { command, gameId, onComplete, onError} : GoCommandProps ) : JSX . Element | null => {
27+ const LogListener = ( { projectId, buildId} : { projectId : string ; buildId : string } ) => {
28+ useGoRuntimeLogListener ( { projectId, buildId} )
29+ return null
30+ }
31+
32+ const GoCommand = ( { command, gameId, onComplete, onError} : GoCommandProps ) : JSX . Element | null => {
2733 const flags = { follow : false , platform : 'go' }
2834
35+ const [ buildId , setBuildId ] = useState < string | null > ( null )
36+ const [ qrCodeData , setQRCodeData ] = useState < string | null > ( null )
37+
2938 const { jobs : startedJobs } = useStartShipOnMount ( command , flags , onError )
3039
3140 const handleJobCompleted = async ( job : Job ) => {
3241 if ( job . type != Platform . GO ) return
3342 const [ goBuild ] = await getJobBuildsRetry ( job . id , command . getGameId ( ) )
43+ setBuildId ( goBuild . id )
3444 setQRCodeData ( getShortUUID ( goBuild . id ) )
3545 const sleep = ( ms : number ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
3646 await sleep ( 500 )
37- onComplete ( )
47+ // onComplete()
3848 }
3949
4050 const handleJobFailed = ( job : any ) => {
@@ -48,10 +58,13 @@ const GoCommand = ({command, gameId, onComplete, onError}: GoCommandProps): JSX.
4858 onJobFailed : handleJobFailed ,
4959 } )
5060
51- const [ qrCodeData , setQRCodeData ] = useState < string | null > ( null )
52-
53- if ( qrCodeData ) {
54- return < QRCodeTerminal data = { qrCodeData } />
61+ if ( qrCodeData && buildId ) {
62+ return (
63+ < >
64+ < QRCodeTerminal data = { qrCodeData } />
65+ < LogListener projectId = { gameId } buildId = { buildId } />
66+ </ >
67+ )
5568 }
5669
5770 if ( startedJobs && startedJobs ?. length > 0 ) {
0 commit comments