Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmengo committed Dec 11, 2024
1 parent 08d7f05 commit 1565bdd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
24 changes: 20 additions & 4 deletions packages/theme/src/cli/commands/theme/generate/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {themeFlags} from '../../../flags.js'
import ThemeCommand from '../../../utilities/theme-command.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {renderSuccess} from '@shopify/cli-kit/node/ui'
import {renderSelectPrompt, renderSuccess, renderTextPrompt} from '@shopify/cli-kit/node/ui'

export default class GenerateBlock extends ThemeCommand {
static summary = 'Creates and adds a new block file to your local theme directory'
Expand All @@ -21,22 +21,38 @@ export default class GenerateBlock extends ThemeCommand {
name: Flags.string({
char: 'n',
description: 'Name of the block',
required: true,
env: 'SHOPIFY_FLAG_THEME_GENERATE_BLOCK_NAME',
}),
type: Flags.string({
char: 't',
description: 'Type of block to generate',
required: true,
options: ['text', 'image', 'video', 'product', 'collection'],
env: 'SHOPIFY_FLAG_THEME_GENERATE_BLOCK_TYPE',
}),
}

async run(): Promise<void> {
const {flags} = await this.parse(GenerateBlock)

const name =
flags.name ??
(await renderTextPrompt({
message: 'Name of the block',
}))

const blockTypes = ['text', 'image', 'video', 'product', 'collection']
const choices = blockTypes.map((type) => {
return {label: type, value: type}
})
const type =
flags.type ??
(await renderSelectPrompt({
message: 'Type of block',
choices,
}))

renderSuccess({
body: ['Placeholder: Generating block with name:', flags.name, 'type:', flags.type],
body: [`Placeholder: Generating block with name: ${name}, type: ${type}`],
})
}
}
24 changes: 20 additions & 4 deletions packages/theme/src/cli/commands/theme/generate/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {themeFlags} from '../../../flags.js'
import ThemeCommand from '../../../utilities/theme-command.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {renderSuccess} from '@shopify/cli-kit/node/ui'
import {renderSelectPrompt, renderSuccess, renderTextPrompt} from '@shopify/cli-kit/node/ui'

export default class GenerateSection extends ThemeCommand {
static summary = 'Creates and adds a new section file to your local theme directory'
Expand All @@ -21,22 +21,38 @@ export default class GenerateSection extends ThemeCommand {
name: Flags.string({
char: 'n',
description: 'Name of the section',
required: true,
env: 'SHOPIFY_FLAG_THEME_GENERATE_SECTION_NAME',
}),
type: Flags.string({
char: 't',
description: 'Type of section to generate',
required: true,
options: ['featured-collection', 'image-with-text', 'rich-text', 'custom'],
env: 'SHOPIFY_FLAG_THEME_GENERATE_SECTION_TYPE',
}),
}

async run(): Promise<void> {
const {flags} = await this.parse(GenerateSection)

const name =
flags.name ??
(await renderTextPrompt({
message: 'Name of the section',
}))

const sectionTypes = ['featured-collection', 'image-with-text', 'rich-text', 'custom']
const choices = sectionTypes.map((type) => {
return {label: type, value: type}
})
const type =
flags.type ??
(await renderSelectPrompt({
message: 'Type of section',
choices,
}))

renderSuccess({
body: ['Placeholder: Generating section with name:', flags.name, 'type:', flags.type],
body: [`Placeholder: Generating section with name: ${name}, type: ${type}`],
})
}
}
24 changes: 20 additions & 4 deletions packages/theme/src/cli/commands/theme/generate/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {themeFlags} from '../../../flags.js'
import ThemeCommand from '../../../utilities/theme-command.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {renderSuccess} from '@shopify/cli-kit/node/ui'
import {renderSelectPrompt, renderSuccess, renderTextPrompt} from '@shopify/cli-kit/node/ui'

export default class GenerateTemplate extends ThemeCommand {
static summary = 'Creates and adds a new template file to your local theme directory'
Expand All @@ -21,22 +21,38 @@ export default class GenerateTemplate extends ThemeCommand {
name: Flags.string({
char: 'n',
description: 'Name of the template',
required: true,
env: 'SHOPIFY_FLAG_THEME_GENERATE_TEMPLATE_NAME',
}),
type: Flags.string({
char: 't',
description: 'Type of template to generate',
required: true,
options: ['product', 'collection', 'page', 'blog', 'article', 'custom'],
env: 'SHOPIFY_FLAG_THEME_GENERATE_TEMPLATE_TYPE',
}),
}

async run(): Promise<void> {
const {flags} = await this.parse(GenerateTemplate)

const name =
flags.name ??
(await renderTextPrompt({
message: 'Name of the template',
}))

const templateTypes = ['product', 'collection', 'page', 'blog', 'article', 'custom']
const choices = templateTypes.map((type) => {
return {label: type, value: type}
})
const type =
flags.type ??
(await renderSelectPrompt({
message: 'Type of template',
choices,
}))

renderSuccess({
body: ['Placeholder: Generating template with name:', flags.name, 'type:', flags.type],
body: [`Placeholder: Generating template with name: ${name}, type: ${type}`],
})
}
}

0 comments on commit 1565bdd

Please sign in to comment.