feat(mod_commit): Add CLI UI helpers and improve commit workflow with progress, recommendations and summary

This commit is contained in:
2025-10-23 23:44:38 +00:00
parent a41e3d5d2c
commit 0d3b10bd00
5 changed files with 290 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import * as plugins from './mod.plugins.js';
import * as paths from '../paths.js';
import { logger } from '../gitzone.logging.js';
import * as ui from './mod.ui.js';
export type ProjectType = 'npm' | 'deno' | 'both' | 'none';
export type VersionType = 'patch' | 'minor' | 'major';
@@ -204,25 +205,40 @@ async function syncVersionToDenoJson(version: string): Promise<void> {
* Bumps the project version based on project type
* @param projectType The detected project type
* @param versionType The type of version bump
* @param currentStep The current step number for progress display
* @param totalSteps The total number of steps for progress display
* @returns The new version string
*/
export async function bumpProjectVersion(
projectType: ProjectType,
versionType: VersionType
versionType: VersionType,
currentStep?: number,
totalSteps?: number
): Promise<string> {
const projectEmoji = projectType === 'npm' ? '📦' : projectType === 'deno' ? '🦕' : '🔀';
const description = `🏷️ Bumping version (${projectEmoji} ${projectType})`;
if (currentStep && totalSteps) {
ui.printStep(currentStep, totalSteps, description, 'in-progress');
}
let newVersion: string;
switch (projectType) {
case 'npm':
return await bumpNpmVersion(versionType);
newVersion = await bumpNpmVersion(versionType);
break;
case 'deno':
return await bumpDenoVersion(versionType);
newVersion = await bumpDenoVersion(versionType);
break;
case 'both': {
// Bump npm version first (it handles git tags)
const newVersion = await bumpNpmVersion(versionType);
newVersion = await bumpNpmVersion(versionType);
// Then sync to deno.json
await syncVersionToDenoJson(newVersion);
return newVersion;
break;
}
case 'none':
@@ -231,4 +247,10 @@ export async function bumpProjectVersion(
default:
throw new Error(`Unknown project type: ${projectType}`);
}
if (currentStep && totalSteps) {
ui.printStep(currentStep, totalSteps, description, 'done');
}
return newVersion;
}