Skip to content

Commit f1929c3

Browse files
authored
Merge pull request #6146 from Shopify/07-22-fix_validation_error_when_theme_extension_deployed_with_no-build
fix validation error when theme extension deployed with no-build
2 parents 5808f59 + 949bf81 commit f1929c3

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

packages/app/src/cli/models/extensions/extension-instance.test.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {FunctionConfigType} from '../extensions/specifications/function.js'
1717
import {ExtensionBuildOptions} from '../../services/build/extension.js'
1818
import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
1919
import {joinPath} from '@shopify/cli-kit/node/path'
20-
import {describe, expect, test} from 'vitest'
20+
import {describe, expect, test, vi} from 'vitest'
2121
import {inTemporaryDirectory, readFile, mkdir, writeFile, fileExistsSync} from '@shopify/cli-kit/node/fs'
2222
import {slugify} from '@shopify/cli-kit/common/string'
2323
import {hashString, nonRandomUUID} from '@shopify/cli-kit/node/crypto'
@@ -232,6 +232,39 @@ describe('build', async () => {
232232
expect(outputFileContent).toEqual('(()=>{})();')
233233
})
234234
})
235+
236+
test('does not copy shopify.extension.toml file when bundling theme extensions', async () => {
237+
await inTemporaryDirectory(async (tmpDir) => {
238+
// Given
239+
const extension = await testThemeExtensions(tmpDir)
240+
241+
const blocksDir = joinPath(tmpDir, 'blocks')
242+
await mkdir(blocksDir)
243+
244+
await writeFile(joinPath(blocksDir, 'product.liquid'), '<div>Product block</div>')
245+
await writeFile(joinPath(tmpDir, 'shopify.extension.toml'), '[extensions]')
246+
247+
const bundleDirectory = joinPath(tmpDir, 'bundle')
248+
await mkdir(bundleDirectory)
249+
250+
const options: ExtensionBuildOptions = {
251+
stdout: new Writable({write: vi.fn()}),
252+
stderr: new Writable({write: vi.fn()}),
253+
app: testApp(),
254+
environment: 'production',
255+
}
256+
257+
// When
258+
await extension.copyIntoBundle(options, bundleDirectory)
259+
260+
// Then
261+
const outputTomlPath = joinPath(extension.outputPath, 'shopify.extension.toml')
262+
expect(fileExistsSync(outputTomlPath)).toBe(false)
263+
264+
const outputProductPath = joinPath(extension.outputPath, 'blocks', 'product.liquid')
265+
expect(fileExistsSync(outputProductPath)).toBe(true)
266+
})
267+
})
235268
})
236269

237270
describe('deployConfig', async () => {

packages/app/src/cli/models/extensions/extension-instance.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
385385

386386
const buildMode = this.buildMode(options)
387387

388-
if (buildMode !== 'none') {
388+
if (this.isThemeExtension) {
389+
await bundleThemeExtension(this, options)
390+
} else if (buildMode !== 'none') {
389391
outputDebug(`Will copy pre-built file from ${defaultOutputPath} to ${this.outputPath}`)
390392
if (await fileExists(defaultOutputPath)) {
391393
await copyFile(defaultOutputPath, this.outputPath)
@@ -394,10 +396,6 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
394396
await bundleFunctionExtension(this.outputPath, this.outputPath)
395397
}
396398
}
397-
398-
if (this.isThemeExtension) {
399-
await bundleThemeExtension(this, options)
400-
}
401399
}
402400
}
403401

0 commit comments

Comments
 (0)