Skip to content

Commit 5b6905a

Browse files
committed
Ensure warning is displayed if multiple envs aren't supported
1 parent eaf324c commit 5b6905a

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

packages/theme/src/cli/utilities/theme-command.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {describe, vi, expect, test, beforeEach} from 'vitest'
44
import {Config, Flags} from '@oclif/core'
55
import {AdminSession, ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
66
import {loadEnvironment} from '@shopify/cli-kit/node/environments'
7-
import {renderConcurrent, renderConfirmationPrompt, renderError} from '@shopify/cli-kit/node/ui'
87
import {fileExistsSync} from '@shopify/cli-kit/node/fs'
98
import {AbortError} from '@shopify/cli-kit/node/error'
109
import {resolvePath} from '@shopify/cli-kit/node/path'
10+
import {renderConcurrent, renderConfirmationPrompt, renderError, renderWarning} from '@shopify/cli-kit/node/ui'
1111
import type {Writable} from 'stream'
1212

1313
vi.mock('@shopify/cli-kit/node/session')
@@ -120,6 +120,10 @@ class TestUnauthenticatedThemeCommand extends ThemeCommand {
120120
}
121121
}
122122

123+
class TestNoMultiEnvThemeCommand extends TestThemeCommand {
124+
static multiEnvironmentsFlags: RequiredFlags = null
125+
}
126+
123127
describe('ThemeCommand', () => {
124128
let mockSession: AdminSession
125129

@@ -227,6 +231,31 @@ describe('ThemeCommand', () => {
227231
await expect(command.run()).rejects.toThrow(AbortError)
228232
expect(fileExistsSync).toHaveBeenCalledWith('current/working/directory')
229233
})
234+
235+
test('multiple environments provided - displays warning if not allowed', async () => {
236+
// Given
237+
const environmentConfig = {store: 'store.myshopify.com'}
238+
vi.mocked(loadEnvironment).mockResolvedValue(environmentConfig)
239+
vi.mocked(ensureAuthenticatedThemes).mockResolvedValue(mockSession)
240+
241+
vi.mocked(renderConcurrent).mockResolvedValue(undefined)
242+
243+
await CommandConfig.load()
244+
const command = new TestNoMultiEnvThemeCommand(
245+
['--environment', 'development', '--environment', 'staging'],
246+
CommandConfig,
247+
)
248+
249+
// When
250+
await command.run()
251+
252+
// Then
253+
expect(renderWarning).toHaveBeenCalledWith(
254+
expect.objectContaining({
255+
body: 'This command does not support multiple environments.',
256+
}),
257+
)
258+
})
230259
})
231260

232261
describe('multi environment', () => {

packages/theme/src/cli/utilities/theme-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {fileExistsSync} from '@shopify/cli-kit/node/fs'
2222
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
2323
import type {Writable} from 'stream'
2424

25-
export interface FlagValues {
25+
interface FlagValues {
2626
[key: string]: boolean | string | string[] | number | undefined
2727
}
2828
interface ValidEnvironment {

0 commit comments

Comments
 (0)