From b9cfe43aefe98072896039b59c230ce00e236827 Mon Sep 17 00:00:00 2001 From: Volodymyr Makukha Date: Thu, 14 May 2026 12:19:42 +0100 Subject: [PATCH 1/2] Print site status json without emopji --- apps/cli/commands/site/status.ts | 14 ++++++++++---- apps/cli/commands/site/tests/status.test.ts | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/cli/commands/site/status.ts b/apps/cli/commands/site/status.ts index 16ea40c2ba..e5eaeb1123 100644 --- a/apps/cli/commands/site/status.ts +++ b/apps/cli/commands/site/status.ts @@ -23,7 +23,8 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) logger.reportSuccess( __( 'Site loaded' ) ); const isOnline = Boolean( await isServerRunning( site.id ) ); - const status = isOnline ? `🟢 ${ __( 'Online' ) }` : `🔴 ${ __( 'Offline' ) }`; + const status = isOnline ? __( 'Online' ) : __( 'Offline' ); + const displayStatus = isOnline ? `🟢 ${ status }` : `🔴 ${ status }`; const siteUrl = getSiteUrl( site ); const sitePath = getPrettyPath( site.path ); const wpVersion = getWordPressVersion( site.path ); @@ -37,6 +38,7 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) key: string; jsonKey: string; value: string | undefined; + displayValue?: string; type?: string; hidden?: boolean; }[] = [ @@ -54,7 +56,7 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) hidden: ! isOnline, }, { key: __( 'Site Path' ), jsonKey: 'sitePath', value: sitePath }, - { key: __( 'Status' ), jsonKey: 'status', value: status }, + { key: __( 'Status' ), jsonKey: 'status', value: status, displayValue: displayStatus }, { key: __( 'PHP version' ), jsonKey: 'phpVersion', value: site.phpVersion }, { key: __( 'WP version' ), jsonKey: 'wpVersion', value: wpVersion }, { key: __( 'Xdebug' ), jsonKey: 'xdebug', value: xdebugStatus }, @@ -81,8 +83,12 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) }, } ); - for ( const { key, value, type } of siteData ) { - table.push( [ key, type === 'url' ? { href: value, content: value } : value ] ); + for ( const { key, value, displayValue, type } of siteData ) { + const tableValue = displayValue ?? value; + table.push( [ + key, + type === 'url' ? { href: tableValue, content: tableValue } : tableValue, + ] ); } console.table( table.toString() ); diff --git a/apps/cli/commands/site/tests/status.test.ts b/apps/cli/commands/site/tests/status.test.ts index 8351a6a8d5..c7e054ff7b 100644 --- a/apps/cli/commands/site/tests/status.test.ts +++ b/apps/cli/commands/site/tests/status.test.ts @@ -80,7 +80,7 @@ describe( 'CLI: studio site status', () => { { siteUrl: 'http://localhost:8080/', sitePath: '/path/to/site', - status: '🔴 Offline', + status: 'Offline', phpVersion: '8.0', wpVersion: '6.4', xdebug: 'Disabled', @@ -113,7 +113,7 @@ describe( 'CLI: studio site status', () => { siteUrl: 'http://localhost:8080/', autoLoginUrl: 'http://localhost:8080/studio-auto-login?redirect_to=%2Fwp-admin%2F', sitePath: '/path/to/site', - status: '🟢 Online', + status: 'Online', phpVersion: '8.0', wpVersion: '6.4', xdebug: 'Disabled', @@ -154,7 +154,7 @@ describe( 'CLI: studio site status', () => { { siteUrl: 'http://localhost:8080/', sitePath: '/path/to/site', - status: '🔴 Offline', + status: 'Offline', wpVersion: '6.4', xdebug: 'Disabled', adminUsername: 'admin', From e1a6ce463347ab3e43af387a79c6fec80f407975 Mon Sep 17 00:00:00 2001 From: Volodymyr Makukha Date: Thu, 14 May 2026 12:33:42 +0100 Subject: [PATCH 2/2] Adjust approach --- apps/cli/commands/site/status.ts | 23 +++++++++++---------- apps/cli/commands/site/tests/status.test.ts | 9 +++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/cli/commands/site/status.ts b/apps/cli/commands/site/status.ts index e5eaeb1123..38f91c03ec 100644 --- a/apps/cli/commands/site/status.ts +++ b/apps/cli/commands/site/status.ts @@ -23,8 +23,7 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) logger.reportSuccess( __( 'Site loaded' ) ); const isOnline = Boolean( await isServerRunning( site.id ) ); - const status = isOnline ? __( 'Online' ) : __( 'Offline' ); - const displayStatus = isOnline ? `🟢 ${ status }` : `🔴 ${ status }`; + const status = isOnline ? `🟢 ${ __( 'Online' ) }` : `🔴 ${ __( 'Offline' ) }`; const siteUrl = getSiteUrl( site ); const sitePath = getPrettyPath( site.path ); const wpVersion = getWordPressVersion( site.path ); @@ -38,7 +37,6 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) key: string; jsonKey: string; value: string | undefined; - displayValue?: string; type?: string; hidden?: boolean; }[] = [ @@ -56,7 +54,7 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) hidden: ! isOnline, }, { key: __( 'Site Path' ), jsonKey: 'sitePath', value: sitePath }, - { key: __( 'Status' ), jsonKey: 'status', value: status, displayValue: displayStatus }, + { key: __( 'Status' ), jsonKey: 'status', value: status }, { key: __( 'PHP version' ), jsonKey: 'phpVersion', value: site.phpVersion }, { key: __( 'WP version' ), jsonKey: 'wpVersion', value: wpVersion }, { key: __( 'Xdebug' ), jsonKey: 'xdebug', value: xdebugStatus }, @@ -83,18 +81,21 @@ export async function runCommand( siteFolder: string, format: 'table' | 'json' ) }, } ); - for ( const { key, value, displayValue, type } of siteData ) { - const tableValue = displayValue ?? value; - table.push( [ - key, - type === 'url' ? { href: tableValue, content: tableValue } : tableValue, - ] ); + for ( const { key, value, type } of siteData ) { + table.push( [ key, type === 'url' ? { href: value, content: value } : value ] ); } console.table( table.toString() ); } else { const logData = Object.fromEntries( - siteData.map( ( { jsonKey, value } ) => [ jsonKey, value ] ) + siteData.flatMap( ( { jsonKey, value } ) => + jsonKey === 'status' + ? [ + [ jsonKey, value ], + [ 'isOnline', isOnline ], + ] + : [ [ jsonKey, value ] ] + ) ); console.log( JSON.stringify( logData, null, 2 ) ); diff --git a/apps/cli/commands/site/tests/status.test.ts b/apps/cli/commands/site/tests/status.test.ts index c7e054ff7b..a03cdbd88b 100644 --- a/apps/cli/commands/site/tests/status.test.ts +++ b/apps/cli/commands/site/tests/status.test.ts @@ -80,7 +80,8 @@ describe( 'CLI: studio site status', () => { { siteUrl: 'http://localhost:8080/', sitePath: '/path/to/site', - status: 'Offline', + status: '🔴 Offline', + isOnline: false, phpVersion: '8.0', wpVersion: '6.4', xdebug: 'Disabled', @@ -113,7 +114,8 @@ describe( 'CLI: studio site status', () => { siteUrl: 'http://localhost:8080/', autoLoginUrl: 'http://localhost:8080/studio-auto-login?redirect_to=%2Fwp-admin%2F', sitePath: '/path/to/site', - status: 'Online', + status: '🟢 Online', + isOnline: true, phpVersion: '8.0', wpVersion: '6.4', xdebug: 'Disabled', @@ -154,7 +156,8 @@ describe( 'CLI: studio site status', () => { { siteUrl: 'http://localhost:8080/', sitePath: '/path/to/site', - status: 'Offline', + status: '🔴 Offline', + isOnline: false, wpVersion: '6.4', xdebug: 'Disabled', adminUsername: 'admin',