@denyhs/cortex-cli
Advanced tools
Comparing version
{ | ||
"name": "@denyhs/cortex-cli", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.4", | ||
"description": "CLI tool to generate commit messages based on repository changes", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -109,3 +109,14 @@ import chalk from 'chalk'; | ||
// Normalize paths to use forward slashes and remove any leading/trailing whitespace | ||
return files.map(file => file.trim().replace(/\\/g, '/')); | ||
const normalizedFiles = files.map(file => file.trim().replace(/\\/g, '/')); | ||
// Get the current directory name | ||
const currentDir = process.cwd().split(path.sep).pop(); | ||
// Remove redundant directory prefix if it matches current directory | ||
return normalizedFiles.map(file => { | ||
if (file.startsWith(`${currentDir}/`)) { | ||
return file.substring(currentDir.length + 1); | ||
} | ||
return file; | ||
}); | ||
} | ||
@@ -122,2 +133,5 @@ | ||
console.log(chalk.blue('\nFound modified files:')); | ||
modifiedFiles.forEach(file => console.log(chalk.gray(` - ${file}`))); | ||
let filesToStage = modifiedFiles; | ||
@@ -127,2 +141,4 @@ | ||
filesToStage = micromatch(filesToStage, options.include); | ||
console.log(chalk.blue('\nFiles matching include patterns:'), options.include); | ||
filesToStage.forEach(file => console.log(chalk.gray(` - ${file}`))); | ||
} | ||
@@ -132,6 +148,8 @@ | ||
filesToStage = micromatch.not(filesToStage, options.exclude); | ||
console.log(chalk.blue('\nFiles after applying exclude patterns:'), options.exclude); | ||
filesToStage.forEach(file => console.log(chalk.gray(` - ${file}`))); | ||
} | ||
if (filesToStage.length === 0) { | ||
console.log(chalk.yellow('No files match the include/exclude patterns.')); | ||
console.log(chalk.yellow('\nNo files match the include/exclude patterns.')); | ||
return; | ||
@@ -144,5 +162,6 @@ } | ||
console.log(chalk.blue('\nAttempting to stage files...')); | ||
for (const file of filesToStage) { | ||
try { | ||
await git.add([file]); // Pass as array to ensure proper escaping | ||
await git.add([file]); | ||
stagedFiles.push(file); | ||
@@ -166,2 +185,3 @@ } catch (error) { | ||
console.log(chalk.gray(` Error: ${error}`)); | ||
console.log(chalk.gray(` Working directory: ${process.cwd()}`)); | ||
}); | ||
@@ -177,2 +197,3 @@ } | ||
console.error(chalk.red('Error staging changes:'), error.message); | ||
console.error(chalk.gray(`Working directory: ${process.cwd()}`)); | ||
process.exit(1); | ||
@@ -179,0 +200,0 @@ } |
17042
6.09%288
6.67%