MCPcopy Create free account
hub / github.com/formkit/formkit / completeOptions

Function completeOptions

packages/cli/src/createTheme.ts:93–140  ·  view source on GitHub ↗
(
  name: string,
  options: Partial<CreateThemeOptions>
)

Source from the content-addressed store, hash-verified

91}
92
93async function completeOptions(
94 name: string,
95 options: Partial<CreateThemeOptions>
96): Promise<CreateThemeOptions> {
97 while (!name) {
98 const { themeName } = await prompts({
99 type: 'text',
100 name: 'themeName',
101 message: 'The name of your theme, for example "Monokai"',
102 })
103 name = themeName
104 }
105
106 let packageName = options.packageName
107 if (!packageName) {
108 const { themePackageName } = await prompts({
109 type: 'text',
110 name: 'themePackageName',
111 message:
112 'The name of the package on npm, for example formkit-theme-monokai.',
113 initial: `formkit-theme-${slugify(name)}`,
114 })
115 packageName = themePackageName as string
116 }
117
118 let dirName = options.dir
119 let emptyDir = dirName
120 ? await isDirEmpty(resolve(process.cwd(), `./${dirName}`))
121 : false
122
123 while (!dirName || !emptyDir) {
124 const { directory } = await prompts({
125 type: 'text',
126 name: 'directory',
127 message: `The directory to create the theme in.`,
128 initial: options.dir || packageName,
129 })
130 dirName = directory
131 emptyDir = await isDirEmpty(resolve(process.cwd(), `./${dirName}`))
132 }
133 const dir = resolve(process.cwd(), `./${dirName}`)
134
135 return {
136 name,
137 packageName,
138 dir,
139 }
140}

Callers 1

createThemeFunction · 0.85

Calls 2

slugifyFunction · 0.90
isDirEmptyFunction · 0.90

Tested by

no test coverage detected