Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/goofy-colts-sink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': patch
---

Fix issue where certain theme commands were failing to have sessions created
4 changes: 3 additions & 1 deletion packages/theme/src/cli/commands/theme/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {themeFlags} from '../../flags.js'
import ThemeCommand from '../../utilities/theme-command.js'
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
import {
cloneRepoAndCheckoutLatestTag,
cloneRepo,
Expand Down Expand Up @@ -57,6 +57,8 @@ export default class Init extends ThemeCommand {
}),
}

static multiEnvironmentsFlags: RequiredFlags = null

async command(flags: InitFlags, _adminSession: AdminSession, _multiEnvironment: boolean, args: InitArgs) {
const name = args.name || (await this.promptName(flags.path))
const repoUrl = flags['clone-url']
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/src/cli/commands/theme/language-server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ThemeCommand from '../../utilities/theme-command.js'
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {startServer} from '@shopify/theme-language-server-node'

Expand All @@ -13,6 +13,8 @@ export default class LanguageServer extends ThemeCommand {
...globalFlags,
}

static multiEnvironmentsFlags: RequiredFlags = null

async command() {
startServer()
}
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/src/cli/commands/theme/package.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {themeFlags} from '../../flags.js'
import ThemeCommand from '../../utilities/theme-command.js'
import ThemeCommand, {RequiredFlags} from '../../utilities/theme-command.js'
import {packageTheme} from '../../services/package.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {InferredFlags} from '@oclif/core/interfaces'
Expand All @@ -23,6 +23,8 @@ export default class Package extends ThemeCommand {
path: themeFlags.path,
}

static multiEnvironmentsFlags: RequiredFlags = null

async command(flags: PackageFlags) {
await packageTheme(flags.path)
}
Expand Down
9 changes: 3 additions & 6 deletions packages/theme/src/cli/utilities/theme-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ class TestThemeCommandWithoutStoreRequired extends ThemeCommand {
env: 'SHOPIFY_FLAG_PATH',
default: 'current/working/directory',
}),
password: Flags.string({
env: 'SHOPIFY_FLAG_PASSWORD',
}),
store: Flags.string({
env: 'SHOPIFY_FLAG_STORE',
}),
Expand Down Expand Up @@ -267,7 +264,7 @@ describe('ThemeCommand', () => {
expect(ensureAuthenticatedThemes).not.toHaveBeenCalled()
})

test('single environment provided with store - creates session when store is provided even if not required', async () => {
test('single environment provided with store - does not create session when command does not require auth', async () => {
// Given
const environmentConfig = {path: '/some/path', store: 'store.myshopify.com'}
vi.mocked(loadEnvironment).mockResolvedValue(environmentConfig)
Expand All @@ -279,9 +276,9 @@ describe('ThemeCommand', () => {
await command.run()

// Then
expect(ensureAuthenticatedThemes).toHaveBeenCalledOnce()
expect(ensureAuthenticatedThemes).not.toHaveBeenCalled()
expect(command.commandCalls).toHaveLength(1)
expect(command.commandCalls[0]?.session).toEqual(mockSession)
expect(command.commandCalls[0]?.session).toBeUndefined()
})

test('multiple environments provided - uses renderConcurrent for parallel execution', async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/theme/src/cli/utilities/theme-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export default abstract class ThemeCommand extends Command {
throw new AbortError(`Please provide a valid environment.`)
}

const shouldCreateSession = commandRequiresAuth && (storeIsRequired || flags.store)
const session = shouldCreateSession ? await this.createSession(flags) : undefined
const session = commandRequiresAuth ? await this.createSession(flags) : undefined
const commandName = this.constructor.name.toLowerCase()

recordEvent(`theme-command:${commandName}:single-env:authenticated`)
Expand Down
Loading