Skip to content

Commit e885a89

Browse files
committed
Refactor open command to use ThemeCommand's run method
Previously `theme open` command implemented its own `run` logic. This commit refactors `open` 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 ed5364c commit e885a89

File tree

1 file changed

+6
-7
lines changed
  • packages/theme/src/cli/commands/theme

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import {ensureThemeStore} from '../../utilities/theme-store.js'
2-
import ThemeCommand from '../../utilities/theme-command.js'
1+
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
32
import {themeFlags} from '../../flags.js'
43
import {open} from '../../services/open.js'
54
import {Flags} from '@oclif/core'
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'
7+
import {InferredFlags} from '@oclif/core/interfaces'
88

9+
type OpenFlags = InferredFlags<typeof Open.flags>
910
export default class Open extends ThemeCommand {
1011
static summary = 'Opens the preview of your remote theme.'
1112

@@ -43,11 +44,9 @@ export default class Open extends ThemeCommand {
4344
}),
4445
}
4546

46-
async run(): Promise<void> {
47-
const {flags} = await this.parse(Open)
48-
const store = ensureThemeStore(flags)
49-
const adminSession = await ensureAuthenticatedThemes(store, flags.password)
47+
static multiEnvironmentsFlags: RequiredFlags = null
5048

49+
async command(flags: OpenFlags, adminSession: AdminSession) {
5150
await open(adminSession, flags)
5251
}
5352
}

0 commit comments

Comments
 (0)