Skip to content

Commit 92495a6

Browse files
committed
Refactor console command to use ThemeCommand's run method
Previously `theme console` command implemented its own `run` logic. This commit refactors `console` to use ThemeCommand's base `run()` method. This will help to standardize command architecture and allow for out of the box authentication and environments support
1 parent cd188b4 commit 92495a6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import {themeFlags} from '../../flags.js'
2-
import ThemeCommand from '../../utilities/theme-command.js'
3-
import {ensureThemeStore} from '../../utilities/theme-store.js'
2+
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
43
import {ensureReplEnv, initializeRepl} from '../../services/console.js'
54
import {validateThemePassword} from '../../services/flags-validation.js'
65
import {globalFlags} from '@shopify/cli-kit/node/cli'
7-
import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
6+
import {AdminSession} from '@shopify/cli-kit/node/session'
87
import {Flags} from '@oclif/core'
98
import {recordEvent} from '@shopify/cli-kit/node/analytics'
9+
import {InferredFlags} from '@oclif/core/interfaces'
10+
11+
type ConsoleFlags = InferredFlags<typeof Console.flags>
1012

1113
export default class Console extends ThemeCommand {
1214
static summary = 'Shopify Liquid REPL (read-eval-print loop) tool'
@@ -33,15 +35,12 @@ export default class Console extends ThemeCommand {
3335
}),
3436
}
3537

36-
async run() {
37-
const {flags} = await this.parse(Console)
38-
39-
validateThemePassword(flags.password)
38+
static multiEnvironmentsFlags: RequiredFlags = null
4039

41-
const store = ensureThemeStore(flags)
40+
async command(flags: ConsoleFlags, adminSession: AdminSession) {
4241
const {url, password: themeAccessPassword} = flags
4342

44-
const adminSession = await ensureAuthenticatedThemes(store, themeAccessPassword)
43+
validateThemePassword(themeAccessPassword)
4544

4645
const {themeId, storePassword} = await ensureReplEnv(adminSession, flags['store-password'])
4746

0 commit comments

Comments
 (0)