Skip to content

Commit

Permalink
Merge pull request #4677 from Shopify/jm/push-flag
Browse files Browse the repository at this point in the history
[Themes] Replace legacy flag in `Push` command
  • Loading branch information
jamesmengo authored Oct 18, 2024
2 parents c350201 + 07468e1 commit d21729b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
8 changes: 8 additions & 0 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5837,6 +5837,14 @@
"name": "legacy",
"type": "boolean"
},
"legacy-3.66": {
"allowNo": false,
"description": "Use the legacy Ruby implementation for the `shopify theme push` command.",
"env": "SHOPIFY_FLAG_LEGACY_3_66",
"hidden": true,
"name": "legacy-3.66",
"type": "boolean"
},
"live": {
"allowNo": false,
"char": "l",
Expand Down
14 changes: 1 addition & 13 deletions packages/theme/src/cli/commands/theme/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,10 @@ describe('Push', () => {
expect(DevelopmentThemeManager.prototype.fetch).not.toHaveBeenCalled()
expectCLI2ToHaveBeenCalledWith(`theme push ${path} --theme ${theme.id} --development-theme-id ${theme.id}`)
})

test('should run the Ruby implementation if the password flag is provided', async () => {
// Given
const theme = buildTheme({id: 1, name: 'Theme', role: 'development'})!
vi.spyOn(DevelopmentThemeManager.prototype, 'fetch').mockResolvedValue(theme)

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

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

async function run(argv: string[]) {
await runPushCommand(['--legacy', ...argv], path, adminSession)
await runPushCommand(['--legacy-3.66', ...argv], path, adminSession)
}

function expectCLI2ToHaveBeenCalledWith(command: string) {
Expand Down
27 changes: 26 additions & 1 deletion packages/theme/src/cli/commands/theme/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session'
import {cwd, resolvePath} from '@shopify/cli-kit/node/path'
import {useEmbeddedThemeCLI} from '@shopify/cli-kit/node/context/local'
import {execCLI2} from '@shopify/cli-kit/node/ruby'
import {renderWarning} from '@shopify/cli-kit/node/ui'

export default class Push extends ThemeCommand {
static summary = 'Uploads your local theme files to the connected store, overwriting the remote version if specified.'
Expand Down Expand Up @@ -109,6 +110,11 @@ export default class Push extends ThemeCommand {
description: 'Use the legacy Ruby implementation for the `shopify theme push` command.',
env: 'SHOPIFY_FLAG_LEGACY',
}),
'legacy-3.66': Flags.boolean({
hidden: true,
description: 'Use the legacy Ruby implementation for the `shopify theme push` command.',
env: 'SHOPIFY_FLAG_LEGACY_3_66',
}),
force: Flags.boolean({
hidden: true,
char: 'f',
Expand All @@ -135,7 +141,26 @@ export default class Push extends ThemeCommand {
async run(): Promise<void> {
const {flags} = await this.parse(Push)

if (flags.password || flags.legacy) {
if (flags.legacy) {
renderWarning({
headline: ['The', {command: '--legacy'}, 'flag is deprecated.'],
body: [
'The',
{command: '--legacy'},
'flag has been deprecated. If this variable is essential to your workflow, please report an issue at',
{
link: {
url: 'https://github.com/Shopify/cli/issues',
},
},
{
char: '.',
},
],
})
}

if (flags['legacy-3.66']) {
await this.execLegacyPush()
return
}
Expand Down

0 comments on commit d21729b

Please sign in to comment.