diff --git a/.changeset/dull-tips-wait.md b/.changeset/dull-tips-wait.md new file mode 100644 index 0000000000..e3c2302bcf --- /dev/null +++ b/.changeset/dull-tips-wait.md @@ -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 diff --git a/packages/theme/src/cli/commands/theme/push.test.ts b/packages/theme/src/cli/commands/theme/push.test.ts index 63e64ee273..41cfea4d43 100644 --- a/packages/theme/src/cli/commands/theme/push.test.ts +++ b/packages/theme/src/cli/commands/theme/push.test.ts @@ -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'})! diff --git a/packages/theme/src/cli/commands/theme/push.ts b/packages/theme/src/cli/commands/theme/push.ts index 184c0f9dbd..603b85e637 100644 --- a/packages/theme/src/cli/commands/theme/push.ts +++ b/packages/theme/src/cli/commands/theme/push.ts @@ -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 diff --git a/packages/theme/src/cli/services/push.ts b/packages/theme/src/cli/services/push.ts index a1809b3366..b09b451502 100644 --- a/packages/theme/src/cli/services/push.ts +++ b/packages/theme/src/cli/services/push.ts @@ -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) { @@ -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)) }