Skip to content

Commit

Permalink
Show intro line on first used prompt during app create
Browse files Browse the repository at this point in the history
  • Loading branch information
amcaplan committed Jul 6, 2023
1 parent b9f2b44 commit 309393b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/create-app/src/prompts/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import init from './init.js'
import {describe, expect, vi, test} from 'vitest'
import {renderSelectPrompt, renderTextPrompt} from '@shopify/cli-kit/node/ui'
import {renderSelectPrompt, renderText, renderTextPrompt} from '@shopify/cli-kit/node/ui'

vi.mock('@shopify/cli-kit/node/ui')

Expand All @@ -18,6 +18,9 @@ describe('init', () => {
const got = await init(options)

// Then
expect(renderText).toHaveBeenCalledWith({
text: '\nWelcome. Let’s get started by naming your app project. You can change it later.',
})
expect(renderTextPrompt).toHaveBeenCalledWith({
message: 'Your app project name?',
defaultValue: expect.stringMatching(/^\w+-\w+-app$/),
Expand All @@ -36,6 +39,9 @@ describe('init', () => {
const got = await init(options)

// Then
expect(renderText).toHaveBeenCalledWith({
text: '\nWelcome. Let’s get started by choosing a template for your app project.',
})
expect(renderTextPrompt).not.toHaveBeenCalled()
expect(got).toEqual({...options, ...answers, templateType: 'custom'})
})
Expand Down
8 changes: 7 additions & 1 deletion packages/create-app/src/prompts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const init = async (options: InitOptions): Promise<InitOutput> => {
template: templateURLMap.node,
} as const

renderText({text: '\nWelcome. Let’s get started by naming your app project. You can change it later.'})
let welcomed = false

if (!name) {
renderText({text: '\nWelcome. Let’s get started by naming your app project. You can change it later.'})
welcomed = true
name = await renderTextPrompt({
message: 'Your app project name?',
defaultValue: defaults.name,
Expand All @@ -57,6 +59,10 @@ const init = async (options: InitOptions): Promise<InitOutput> => {
}

if (!template) {
if (!welcomed) {
renderText({text: '\nWelcome. Let’s get started by choosing a template for your app project.'})
welcomed = true
}
template = await renderSelectPrompt({
choices: Object.keys(templateURLMap).map((key) => {
return {
Expand Down

0 comments on commit 309393b

Please sign in to comment.