Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.58] Fix shopify theme push issue when password flag is provided #3651

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
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