Skip to content

Commit 29bd2f3

Browse files
Add a warning
1 parent 14c1504 commit 29bd2f3

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

packages/cli-kit/src/public/node/base-command.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ const deleteDefaultEnvironment = async (tmpDir: string): Promise<void> => {
562562

563563
describe('removeDuplicatedPlugins', () => {
564564
let capturedPlugins: Map<string, any> | undefined
565+
let outputMock: ReturnType<typeof mockAndCaptureOutput>
565566

566567
class PluginTestCommand extends MockCommand {
567568
async init() {
@@ -583,6 +584,8 @@ describe('removeDuplicatedPlugins', () => {
583584

584585
beforeEach(() => {
585586
capturedPlugins = undefined
587+
outputMock = mockAndCaptureOutput()
588+
outputMock.clear()
586589
})
587590

588591
test('removes @shopify/app plugin when present', async () => {
@@ -606,6 +609,11 @@ describe('removeDuplicatedPlugins', () => {
606609
expect(capturedPlugins.has('@shopify/plugin-ngrok')).toBe(true)
607610
expect(capturedPlugins.has('@shopify/plugin-did-you-mean')).toBe(true)
608611
expect(capturedPlugins.size).toBe(2)
612+
613+
// Verify warning was shown
614+
expect(outputMock.output()).toMatch(/Unsupported plugins detected.*@shopify\/app/s)
615+
expect(outputMock.output()).toMatch(/shopify plugins remove @shopify\/app/)
616+
expect(outputMock.output()).not.toMatch(/shopify plugins remove @shopify\/plugin-cloudflare/)
609617
})
610618
})
611619

@@ -630,6 +638,11 @@ describe('removeDuplicatedPlugins', () => {
630638
expect(capturedPlugins.has('@shopify/plugin-ngrok')).toBe(true)
631639
expect(capturedPlugins.has('@shopify/plugin-did-you-mean')).toBe(true)
632640
expect(capturedPlugins.size).toBe(2)
641+
642+
// Verify warning was shown
643+
expect(outputMock.output()).toMatch(/Unsupported plugins detected.*@shopify\/plugin-cloudflare/s)
644+
expect(outputMock.output()).toMatch(/shopify plugins remove @shopify\/plugin-cloudflare/)
645+
expect(outputMock.output()).not.toMatch(/shopify plugins remove @shopify\/app/)
633646
})
634647
})
635648

@@ -657,6 +670,11 @@ describe('removeDuplicatedPlugins', () => {
657670
expect(capturedPlugins.has('@shopify/plugin-ngrok')).toBe(true)
658671
expect(capturedPlugins.has('@shopify/plugin-did-you-mean')).toBe(true)
659672
expect(capturedPlugins.size).toBe(2)
673+
674+
// Verify warning was shown with both plugins
675+
expect(outputMock.output()).toMatch(/Unsupported plugins detected.*@shopify\/app.*@shopify\/plugin-cloudflare/s)
676+
expect(outputMock.output()).toMatch(/shopify plugins remove @shopify\/app/)
677+
expect(outputMock.output()).toMatch(/shopify plugins remove @shopify\/plugin-cloudflare/)
660678
})
661679
})
662680

@@ -681,6 +699,9 @@ describe('removeDuplicatedPlugins', () => {
681699
expect(capturedPlugins.has('@shopify/plugin-ngrok')).toBe(true)
682700
expect(capturedPlugins.has('@shopify/plugin-did-you-mean')).toBe(true)
683701
expect(capturedPlugins.has('some-other-plugin')).toBe(true)
702+
703+
// Verify no warning was shown
704+
expect(outputMock.output()).toBe('')
684705
})
685706
})
686707

@@ -694,6 +715,9 @@ describe('removeDuplicatedPlugins', () => {
694715

695716
// Then - verify map is still empty
696717
expect(capturedPlugins.size).toBe(0)
718+
719+
// Verify no warning was shown
720+
expect(outputMock.output()).toBe('')
697721
})
698722
})
699723

@@ -729,6 +753,10 @@ describe('removeDuplicatedPlugins', () => {
729753
expect(remainingPlugin.version).toBe('2.0.0')
730754
expect(remainingPlugin.type).toBe('user')
731755
expect(remainingPlugin.root).toBe('/path/to/theme')
756+
757+
// Verify warning was shown
758+
expect(outputMock.output()).toMatch(/Unsupported plugins detected.*@shopify\/app/s)
759+
expect(outputMock.output()).toMatch(/shopify plugins remove @shopify\/app/)
732760
})
733761
})
734762
})

packages/cli-kit/src/public/node/base-command.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,20 @@ function commandSupportsFlag(flags: FlagInput | undefined, flagName: string): bo
338338
}
339339

340340
async function removeDuplicatedPlugins(config: Config): Promise<void> {
341+
const plugins = Array.from(config.plugins.values())
341342
const bundlePlugins = ['@shopify/app', '@shopify/plugin-cloudflare']
342-
const filteredPlugins = Array.from(config.plugins.values()).filter((plugin) => !bundlePlugins.includes(plugin.name))
343+
const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name))
344+
if (pluginsToRemove.length > 0) {
345+
const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\n')
346+
renderWarning({
347+
headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,
348+
body: [
349+
'They are already included in the CLI and installing them as custom plugins can cause conflicts.',
350+
`You can fix it by running:\n${commandsToRun}`,
351+
],
352+
})
353+
}
354+
const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name))
343355
config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]))
344356
}
345357

0 commit comments

Comments
 (0)