Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show intro line on first used prompt during app create #2357

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly necessary, but good for preventing bugs in case we add more prompts (which hopefully we never will).

}
template = await renderSelectPrompt({
choices: Object.keys(templateURLMap).map((key) => {
return {
Expand Down