Skip to content

Commit

Permalink
[3.58] Fix shopify theme push issue when password flag is provided
Browse files Browse the repository at this point in the history
[Themes] Fix Theme Push Execution when password flag is provided
  • Loading branch information
jamesmengo authored Apr 4, 2024
1 parent 3139346 commit f41ab02
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changeset/dull-tips-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/theme': patch
---

- Theme Push: Fix issue with unresponsive server when password flag is provided
- Theme Push: Add 'theme' key to root node of JSON output
11 changes: 11 additions & 0 deletions packages/theme/src/cli/commands/theme/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ describe('Push', () => {
})

describe('run with CLI 2 implementation', () => {
test('should run the CLI 2 implementation if the password flag is provided', async () => {
// Given
const theme = buildTheme({id: 1, name: 'Theme', role: 'development'})!

// When
await runPushCommand(['--password', '123'], path, adminSession, theme)

// Then
expectCLI2ToHaveBeenCalledWith(`theme push ${path} --development-theme-id ${theme.id}`)
})

test('should pass development theme from local storage to CLI 2', async () => {
// Given
const theme = buildTheme({id: 1, name: 'Theme', role: 'development'})!
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/cli/commands/theme/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default class Push extends ThemeCommand {

const developmentThemeManager = new DevelopmentThemeManager(adminSession)

if (!flags.stable) {
if (!flags.stable && !flags.password) {
const {live, development, unpublished, path, nodelete, theme, publish, json, force, ignore, only} = flags

let selectedTheme: Theme
Expand Down
32 changes: 18 additions & 14 deletions packages/theme/src/cli/services/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ interface PushOptions {
}

interface JsonOutput {
id: number
name: string
role: string
shop: string
editor_url: string
preview_url: string
warning?: string
theme: {
id: number
name: string
role: string
shop: string
editor_url: string
preview_url: string
warning?: string
}
}

export async function push(theme: Theme, session: AdminSession, options: PushOptions) {
Expand Down Expand Up @@ -71,17 +73,19 @@ async function handlePushOutput(

function handleJsonOutput(theme: Theme, hasErrors: boolean, session: AdminSession) {
const output: JsonOutput = {
id: theme.id,
name: theme.name,
role: theme.role,
shop: session.storeFqdn,
editor_url: themeEditorUrl(theme, session),
preview_url: themePreviewUrl(theme, session),
theme: {
id: theme.id,
name: theme.name,
role: theme.role,
shop: session.storeFqdn,
editor_url: themeEditorUrl(theme, session),
preview_url: themePreviewUrl(theme, session),
},
}

if (hasErrors) {
const message = `The theme ${themeComponent(theme).join(' ')} was pushed with errors`
output.warning = message
output.theme.warning = message
}
outputInfo(JSON.stringify(output))
}
Expand Down

0 comments on commit f41ab02

Please sign in to comment.