(promptName, genPath)
| 305 | } |
| 306 | |
| 307 | export async function prompt(promptName, genPath) { |
| 308 | if (!promptName) { |
| 309 | output.error('Please specify prompt name: writeStep, healStep, or generatePageObject') |
| 310 | output.print('Usage: npx codeceptjs generate:prompt <promptName>') |
| 311 | return |
| 312 | } |
| 313 | |
| 314 | const validPrompts = ['writeStep', 'healStep', 'generatePageObject'] |
| 315 | if (!validPrompts.includes(promptName)) { |
| 316 | output.error(`Invalid prompt name: ${promptName}`) |
| 317 | output.print(`Valid prompts: ${validPrompts.join(', ')}`) |
| 318 | return |
| 319 | } |
| 320 | |
| 321 | const testsPath = getTestRoot(genPath) |
| 322 | |
| 323 | const promptsDir = path.join(testsPath, 'prompts') |
| 324 | if (!fileExists(promptsDir)) { |
| 325 | mkdirp.sync(promptsDir) |
| 326 | } |
| 327 | |
| 328 | const templatePath = path.join(__dirname, `../template/prompts/${promptName}.js`) |
| 329 | const promptContent = fs.readFileSync(templatePath, 'utf8') |
| 330 | |
| 331 | const promptFile = path.join(promptsDir, `${promptName}.${extension}`) |
| 332 | if (!safeFileWrite(promptFile, promptContent)) return |
| 333 | |
| 334 | output.success(`Prompt ${promptName} was created in ${promptFile}`) |
| 335 | output.print('Customize this prompt to fit your needs.') |
| 336 | output.print('This prompt will be automatically loaded when AI features are enabled.') |
| 337 | } |
no test coverage detected