chore: fixes parse prd to show loading indicator in cli.
This commit is contained in:
@@ -10,6 +10,7 @@ import boxen from 'boxen';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import https from 'https';
|
import https from 'https';
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
|
import ora from 'ora'; // Import ora
|
||||||
|
|
||||||
import { log, readJSON } from './utils.js';
|
import { log, readJSON } from './utils.js';
|
||||||
import {
|
import {
|
||||||
@@ -519,31 +520,36 @@ function registerCommands(programInstance) {
|
|||||||
|
|
||||||
// Helper function to check if tasks.json exists and confirm overwrite
|
// Helper function to check if tasks.json exists and confirm overwrite
|
||||||
async function confirmOverwriteIfNeeded() {
|
async function confirmOverwriteIfNeeded() {
|
||||||
if (fs.existsSync(outputPath) && !force && !append) {
|
if (fs.existsSync(outputPath) && !useForce && !useAppend) {
|
||||||
const overwrite = await confirmTaskOverwrite(outputPath); // Calls inquirer prompt
|
const overwrite = await confirmTaskOverwrite(outputPath);
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
log('info', 'Operation cancelled.');
|
log('info', 'Operation cancelled.');
|
||||||
return false; // Exit if user selects 'N'
|
return false;
|
||||||
}
|
}
|
||||||
// If user confirms 'y', we should set useForce = true for the parsePRD call
|
// If user confirms 'y', we should set useForce = true for the parsePRD call
|
||||||
|
// Only overwrite if not appending
|
||||||
useForce = true;
|
useForce = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no input file specified, check for default PRD location
|
let spinner;
|
||||||
|
|
||||||
|
try {
|
||||||
if (!inputFile) {
|
if (!inputFile) {
|
||||||
if (fs.existsSync(defaultPrdPath)) {
|
if (fs.existsSync(defaultPrdPath)) {
|
||||||
console.log(chalk.blue(`Using default PRD file: ${defaultPrdPath}`));
|
console.log(
|
||||||
|
chalk.blue(`Using default PRD file path: ${defaultPrdPath}`)
|
||||||
// Check for existing tasks.json before proceeding
|
);
|
||||||
if (!(await confirmOverwriteIfNeeded())) return;
|
if (!(await confirmOverwriteIfNeeded())) return;
|
||||||
|
|
||||||
console.log(chalk.blue(`Generating ${numTasks} tasks...`));
|
console.log(chalk.blue(`Generating ${numTasks} tasks...`));
|
||||||
|
spinner = ora('Parsing PRD and generating tasks...').start();
|
||||||
await parsePRD(defaultPrdPath, outputPath, numTasks, {
|
await parsePRD(defaultPrdPath, outputPath, numTasks, {
|
||||||
useAppend,
|
useAppend,
|
||||||
useForce
|
useForce
|
||||||
});
|
});
|
||||||
|
spinner.succeed('Tasks generated successfully!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +591,13 @@ function registerCommands(programInstance) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for existing tasks.json before proceeding with specified input file
|
if (!fs.existsSync(inputFile)) {
|
||||||
|
console.error(
|
||||||
|
chalk.red(`Error: Input PRD file not found: ${inputFile}`)
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(await confirmOverwriteIfNeeded())) return;
|
if (!(await confirmOverwriteIfNeeded())) return;
|
||||||
|
|
||||||
console.log(chalk.blue(`Parsing PRD file: ${inputFile}`));
|
console.log(chalk.blue(`Parsing PRD file: ${inputFile}`));
|
||||||
@@ -594,7 +606,20 @@ function registerCommands(programInstance) {
|
|||||||
console.log(chalk.blue('Appending to existing tasks...'));
|
console.log(chalk.blue('Appending to existing tasks...'));
|
||||||
}
|
}
|
||||||
|
|
||||||
await parsePRD(inputFile, outputPath, numTasks, { append });
|
spinner = ora('Parsing PRD and generating tasks...').start();
|
||||||
|
await parsePRD(inputFile, outputPath, numTasks, {
|
||||||
|
append: useAppend,
|
||||||
|
force: useForce
|
||||||
|
});
|
||||||
|
spinner.succeed('Tasks generated successfully!');
|
||||||
|
} catch (error) {
|
||||||
|
if (spinner) {
|
||||||
|
spinner.fail(`Error parsing PRD: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
console.error(chalk.red(`Error parsing PRD: ${error.message}`));
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// update command
|
// update command
|
||||||
|
|||||||
Reference in New Issue
Block a user