Skip to content

Commit ef64211

Browse files
Update changeset and remove redundant code for single environment theme calls
Co-authored-by: Gray Gilmore <[email protected]>
1 parent 60f74d1 commit ef64211

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

.changeset/itchy-houses-kick.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
'@shopify/theme': patch
33
---
44

5-
fix the way we detect single or non environments & improve output for multienvironment commands
5+
Improvement and fixes when handling multi-environment commands
6+
7+
- Fixes a bug where passing a single environment to multi-env commands would cause it to fail if the environment didn't have all of the required attributes for multi-env
8+
- Updates output when running multi-env commands to ensure the results from each command don't overlap one another

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Config, Flags} from '@oclif/core'
44
import {AdminSession, ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
55
import {loadEnvironment} from '@shopify/cli-kit/node/environments'
66
import {renderConcurrent} from '@shopify/cli-kit/node/ui'
7-
import {Writable} from 'stream'
7+
import type {Writable} from 'stream'
88

99
vi.mock('@shopify/cli-kit/node/session')
1010
vi.mock('@shopify/cli-kit/node/environments')
@@ -70,7 +70,7 @@ describe('ThemeCommand', () => {
7070

7171
test('single environment provided', async () => {
7272
// Given
73-
const environmentConfig = {store: 'env-store.myshopify.com', theme: '123'}
73+
const environmentConfig = {store: 'env-store.myshopify.com'}
7474
vi.mocked(loadEnvironment).mockResolvedValue(environmentConfig)
7575

7676
await CommandConfig.load()
@@ -88,7 +88,6 @@ describe('ThemeCommand', () => {
8888
flags: {
8989
environment: ['development'],
9090
store: 'env-store.myshopify.com',
91-
theme: '123',
9291
},
9392
session: mockSession,
9493
context: undefined,
@@ -97,7 +96,7 @@ describe('ThemeCommand', () => {
9796

9897
test('multiple environments provided - uses renderConcurrent for parallel execution', async () => {
9998
// Given
100-
const environmentConfig = {store: 'store.myshopify.com', theme: '123'}
99+
const environmentConfig = {store: 'store.myshopify.com'}
101100
vi.mocked(loadEnvironment).mockResolvedValue(environmentConfig)
102101
vi.mocked(ensureAuthenticatedThemes).mockResolvedValue(mockSession)
103102

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {loadEnvironment} from '@shopify/cli-kit/node/environments'
77
import {renderWarning, renderConcurrent} from '@shopify/cli-kit/node/ui'
88
import {AbortError} from '@shopify/cli-kit/node/error'
99
import {AbortController} from '@shopify/cli-kit/node/abort'
10-
import {Writable} from 'stream'
10+
import type {Writable} from 'stream'
1111

1212
export interface FlagValues {
1313
[key: string]: boolean | string | string[] | number | undefined
@@ -72,28 +72,8 @@ export default abstract class ThemeCommand extends Command {
7272

7373
// If only one environment is specified, treat it as single environment mode
7474
if (environments.length === 1) {
75-
const environmentName = environments[0]
76-
// If the environment is the default environment, the config is already available.
77-
if (environmentName === 'default') {
78-
const session = await this.ensureAuthenticated(flags)
79-
await this.command(flags, session)
80-
return
81-
}
82-
83-
// For non-default environments, we need to load the config
84-
const environmentConfig = await loadEnvironment(environmentName, 'shopify.theme.toml', {
85-
from: flags.path,
86-
silent: true,
87-
})
88-
const environmentFlags = {
89-
...flags,
90-
...environmentConfig,
91-
environment: environments,
92-
}
93-
94-
const session = await this.ensureAuthenticated(environmentConfig as FlagValues)
95-
await this.command(environmentFlags, session)
96-
75+
const session = await this.ensureAuthenticated(flags)
76+
await this.command(flags, session)
9777
return
9878
}
9979

0 commit comments

Comments
 (0)