Skip to content

Commit 1a922a6

Browse files
authored
Merge pull request #5197 from Shopify/theme-info-rework
Theme info rework
2 parents 3135ec6 + 1b8ad07 commit 1a922a6

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

.changeset/healthy-tips-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/theme': minor
3+
---
4+
5+
Give theme info a facelift using standard UI components

packages/theme/src/cli/commands/theme/info.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
77
import {AbortError} from '@shopify/cli-kit/node/error'
88
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
99
import {formatSection, outputInfo} from '@shopify/cli-kit/node/output'
10+
import {renderInfo} from '@shopify/cli-kit/node/ui'
1011

1112
export default class Info extends ThemeCommand {
1213
static description =
@@ -52,7 +53,7 @@ export default class Info extends ThemeCommand {
5253
outputInfo(infoMessage)
5354
} else {
5455
const infoMessage = await fetchDevInfo({cliVersion: this.config.version})
55-
outputInfo(infoMessage)
56+
renderInfo({customSections: infoMessage})
5657
}
5758
}
5859
}

packages/theme/src/cli/services/info.ts

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import {getDevelopmentTheme, getThemeStore} from './local-storage.js'
22
import {findOrSelectTheme} from '../utilities/theme-selector.js'
33
import {DevelopmentThemeManager} from '../utilities/development-theme-manager.js'
44
import {platformAndArch} from '@shopify/cli-kit/node/os'
5-
import {checkForNewVersion} from '@shopify/cli-kit/node/node-package-manager'
65
import {themeEditorUrl, themePreviewUrl} from '@shopify/cli-kit/node/themes/urls'
76
import {Theme} from '@shopify/cli-kit/node/themes/types'
87
import {AdminSession} from '@shopify/cli-kit/node/session'
9-
import {linesToColumns} from '@shopify/cli-kit/common/string'
10-
import {OutputMessage, formatSection} from '@shopify/cli-kit/node/output'
11-
import {getOutputUpdateCLIReminder} from '@shopify/cli-kit/node/upgrade'
8+
import {AlertCustomSection, InlineToken} from '@shopify/cli-kit/node/ui'
129

1310
interface ThemeInfo {
1411
theme: {
@@ -58,40 +55,32 @@ export async function fetchThemeInfo(
5855
return theme ? themeInfoJSON(theme, adminSession) : undefined
5956
}
6057

61-
export async function fetchDevInfo(config: {cliVersion: string}): Promise<OutputMessage> {
62-
const sections: [string, string][] = [devConfigSection(), await systemInfoSection(config)]
63-
const message = sections.map((sectionContents) => formatSection(...sectionContents)).join('\n\n')
64-
return message
58+
export async function fetchDevInfo(config: {cliVersion: string}): Promise<AlertCustomSection[]> {
59+
return [devConfigSection(), await systemInfoSection(config)]
6560
}
6661

67-
function devConfigSection(): [string, string] {
68-
const title = 'Theme Configuration'
62+
function devConfigSection(): AlertCustomSection {
6963
const store = getThemeStore() || 'Not configured'
70-
let developmentTheme = getDevelopmentTheme()
71-
developmentTheme = developmentTheme ? `#${developmentTheme}` : 'Not set'
72-
const lines: string[][] = [
64+
const developmentTheme = getDevelopmentTheme()
65+
return tabularSection('Theme Configuration', [
7366
['Store', store],
74-
['Development Theme ID', developmentTheme],
75-
]
76-
return [title, linesToColumns(lines)]
67+
['Development Theme ID', developmentTheme ? `#${developmentTheme}` : {subdued: 'Not set'}],
68+
])
7769
}
7870

79-
async function systemInfoSection(config: {cliVersion: string}): Promise<[string, string]> {
80-
const title = 'Tooling and System'
71+
async function systemInfoSection(config: {cliVersion: string}): Promise<AlertCustomSection> {
8172
const {platform, arch} = platformAndArch()
82-
const lines: string[][] = [
83-
['Shopify CLI', await cliVersionInfo(config)],
73+
return tabularSection('Tooling and System', [
74+
['Shopify CLI', config.cliVersion],
8475
['OS', `${platform}-${arch}`],
8576
['Shell', process.env.SHELL || 'unknown'],
8677
['Node version', process.version],
87-
]
88-
return [title, linesToColumns(lines)]
78+
])
8979
}
9080

91-
async function cliVersionInfo(config: {cliVersion: string}): Promise<string> {
92-
const dependency = '@shopify/cli'
93-
const newestVersion = await checkForNewVersion(dependency, config.cliVersion)
94-
if (!newestVersion) return config.cliVersion
95-
const upgradeMessage = getOutputUpdateCLIReminder(newestVersion)
96-
return [config.cliVersion, upgradeMessage].join(' ').trim()
81+
function tabularSection(title: string, data: InlineToken[][]): AlertCustomSection {
82+
return {
83+
title,
84+
body: {tabularData: data, firstColumnSubdued: true},
85+
}
9786
}

0 commit comments

Comments
 (0)