-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1565bdd
commit 4b5ca46
Showing
6 changed files
with
50 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {renderSelectPrompt} from '@shopify/cli-kit/node/ui' | ||
|
||
export const BLOCK_TYPES = ['text', 'image', 'video', 'product', 'collection'] as const | ||
export const SECTION_TYPES = ['featured-collection', 'image-with-text', 'rich-text', 'custom'] as const | ||
export const TEMPLATE_TYPES = ['product', 'collection', 'page', 'blog', 'article', 'custom'] as const | ||
|
||
export type BlockType = (typeof BLOCK_TYPES)[number] | ||
export type SectionType = (typeof SECTION_TYPES)[number] | ||
export type TemplateType = (typeof TEMPLATE_TYPES)[number] | ||
|
||
export interface Choice { | ||
label: string | ||
value: string | ||
} | ||
|
||
export function generateChoices<T extends string>(types: ReadonlyArray<T>): Choice[] { | ||
return types.map((type) => ({label: type, value: type})) | ||
} | ||
|
||
export async function promptForType<T extends string>(message: string, types: ReadonlyArray<T>): Promise<T> { | ||
const choices = generateChoices(types) | ||
const result = await renderSelectPrompt({ | ||
message, | ||
choices, | ||
}) | ||
return result as T | ||
} |