11import { useContext , useState } from 'react'
2+ import { Box , Text } from 'ink'
23
3- import { getShortUUID , useProjectJobListener , useStartShipOnMount } from '@cli/utils/index.js'
4+ import { TruncatedText } from './common/TruncatedText.js'
5+ import {
6+ getRuntimeLogLevelColor ,
7+ getShortTime ,
8+ getShortUUID ,
9+ useGoRuntimeLogListener ,
10+ useProjectJobListener ,
11+ useStartShipOnMount ,
12+ } from '@cli/utils/index.js'
413import { getJobBuildsRetry } from '@cli/api/index.js'
514
6- import { CommandContext , GameContext , JobProgress , QRCodeTerminal } from './index.js'
15+ import { CommandContext , GameContext , JobProgress , QRCodeTerminal , Title } from './index.js'
716import { Job , Platform } from '@cli/types/api.js'
8- import { useGoRuntimeLogListener } from '@cli/utils/hooks/useGoRuntimeLogListener.js'
917
1018interface Props {
1119 onComplete : ( ) => void
@@ -25,8 +33,27 @@ interface GoCommandProps extends Props {
2533}
2634
2735const LogListener = ( { projectId, buildId} : { projectId : string ; buildId : string } ) => {
28- useGoRuntimeLogListener ( { projectId, buildId} )
29- return null
36+ const { tail, messages} = useGoRuntimeLogListener ( { projectId, buildId} )
37+
38+ return (
39+ < >
40+ < Box flexDirection = "column" >
41+ { messages . map ( ( log , i ) => {
42+ const messageColor = getRuntimeLogLevelColor ( log . level )
43+ return (
44+ < Box flexDirection = "row" height = { 1 } key = { i } overflow = "hidden" >
45+ < Box >
46+ < Text > { getShortTime ( log . sentAt ) } </ Text >
47+ </ Box >
48+ < Box height = { 1 } marginLeft = { 1 } marginRight = { 2 } overflow = "hidden" >
49+ < TruncatedText color = { messageColor } > { log . message } </ TruncatedText >
50+ </ Box >
51+ </ Box >
52+ )
53+ } ) }
54+ </ Box >
55+ </ >
56+ )
3057}
3158
3259const GoCommand = ( { command, gameId, onComplete, onError} : GoCommandProps ) : JSX . Element | null => {
@@ -60,15 +87,22 @@ const GoCommand = ({command, gameId, onComplete, onError}: GoCommandProps): JSX.
6087
6188 if ( qrCodeData && buildId ) {
6289 return (
63- < >
90+ < Box flexDirection = 'column' >
91+ < Title > Go Build QR Code</ Title >
6492 < QRCodeTerminal data = { qrCodeData } />
93+ < Text > { `Go build ID: ${ getShortUUID ( buildId ) } ` } </ Text >
6594 < LogListener projectId = { gameId } buildId = { buildId } />
66- </ >
95+ </ Box >
6796 )
6897 }
6998
7099 if ( startedJobs && startedJobs ?. length > 0 ) {
71- return < JobProgress job = { startedJobs [ 0 ] } />
100+ return (
101+ < Box flexDirection = 'column' >
102+ < Text > Generating Go build, please wait...</ Text >
103+ < JobProgress job = { startedJobs [ 0 ] } />
104+ </ Box >
105+ )
72106 }
73107
74108 return null
0 commit comments