Skip to content

Commit b58268b

Browse files
committed
Refactor profile command to use ThemeCommand's run method
Previously, theme profile command implemented its own run logic. This commit refactors profile to use ThemeCommand's base `run()` method. This will help to standardize command architecture
1 parent 8c63d1a commit b58268b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {themeFlags} from '../../flags.js'
2-
import ThemeCommand from '../../utilities/theme-command.js'
2+
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
33
import {profile} from '../../services/profile.js'
4-
import {ensureThemeStore} from '../../utilities/theme-store.js'
54
import {findOrSelectTheme} from '../../utilities/theme-selector.js'
65
import {renderTasksToStdErr} from '../../utilities/theme-ui.js'
76
import {validateThemePassword} from '../../services/flags-validation.js'
8-
import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
97
import {Flags} from '@oclif/core'
108
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
119
import {Task} from '@shopify/cli-kit/node/ui'
10+
import {InferredFlags} from '@oclif/core/interfaces'
11+
import {AdminSession} from '@shopify/cli-kit/node/session'
1212

13+
type ProfileFlags = InferredFlags<typeof Profile.flags>
1314
export default class Profile extends ThemeCommand {
1415
static summary = 'Profile the Liquid rendering of a theme page.'
1516

@@ -41,15 +42,13 @@ export default class Profile extends ThemeCommand {
4142
...jsonFlag,
4243
}
4344

44-
async run(): Promise<void> {
45-
const {flags} = await this.parse(Profile)
45+
static multiEnvironmentsFlags: RequiredFlags = null
4646

47-
validateThemePassword(flags.password)
48-
49-
const store = ensureThemeStore(flags)
47+
async command(flags: ProfileFlags, adminSession: AdminSession) {
5048
const {password: themeAccessPassword} = flags
5149

52-
const adminSession = await ensureAuthenticatedThemes(store, themeAccessPassword)
50+
validateThemePassword(themeAccessPassword)
51+
5352
let filter
5453
if (flags.theme) {
5554
filter = {filter: {theme: flags.theme}}
@@ -60,7 +59,7 @@ export default class Profile extends ThemeCommand {
6059

6160
const tasks: Task[] = [
6261
{
63-
title: `Generating Liquid profile for ${store + flags.url}`,
62+
title: `Generating Liquid profile for ${adminSession.storeFqdn} ${flags.url}`,
6463
task: async () => {
6564
await profile(
6665
adminSession,

0 commit comments

Comments
 (0)