Skip to content

Commit f5a992b

Browse files
authored
Merge pull request #6341 from Shopify/08-29-add_new_channel_spec
Add new channel spec
2 parents c5eb8a5 + 2f32d4a commit f5a992b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

packages/app/src/cli/models/extensions/load-specifications.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import themeSpec from './specifications/theme.js'
2525
import uiExtensionSpec from './specifications/ui_extension.js'
2626
import webPixelSpec from './specifications/web_pixel_extension.js'
2727
import editorExtensionCollectionSpecification from './specifications/editor_extension_collection.js'
28+
import channelSpecificationSpec from './specifications/channel.js'
2829

2930
const SORTED_CONFIGURATION_SPEC_IDENTIFIERS = [
3031
BrandingSpecIdentifier,
@@ -73,6 +74,7 @@ function loadSpecifications() {
7374
uiExtensionSpec,
7475
webPixelSpec,
7576
editorExtensionCollectionSpecification,
77+
channelSpecificationSpec,
7678
]
7779

7880
return [...configModuleSpecs, ...moduleSpecs] as ExtensionSpecification[]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {createExtensionSpecification} from '../specification.js'
2+
import {BaseSchemaWithHandle} from '../schemas.js'
3+
import {zod} from '@shopify/cli-kit/node/schema'
4+
import {joinPath} from '@shopify/cli-kit/node/path'
5+
6+
const ChannelSpecificationSchema = BaseSchemaWithHandle.extend({
7+
type: zod.literal('channel_config'),
8+
name: zod.string().optional(),
9+
description: zod.string().optional(),
10+
})
11+
12+
const SUBDIRECTORY_NAME = 'specifications'
13+
const FILE_EXTENSIONS = ['json', 'toml', 'yaml', 'yml', 'svg']
14+
15+
// Generate glob patterns for all supported file types
16+
const getGlobPatterns = () => FILE_EXTENSIONS.map((ext) => joinPath(SUBDIRECTORY_NAME, '**', `*.${ext}`))
17+
18+
const channelSpecificationSpec = createExtensionSpecification({
19+
identifier: 'channel_config',
20+
schema: ChannelSpecificationSchema,
21+
buildConfig: {mode: 'copy_files', filePatterns: getGlobPatterns()},
22+
appModuleFeatures: () => [],
23+
deployConfig: async (config, _directory) => {
24+
return {
25+
handle: config.handle,
26+
name: config.name,
27+
description: config.description,
28+
}
29+
},
30+
})
31+
32+
export default channelSpecificationSpec

0 commit comments

Comments
 (0)