diff --git a/changelog.md b/changelog.md index f2c4806..378ec7f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-10-23 - 1.18.9 - fix(mod_commit) +Stage and commit deno.json when bumping/syncing versions and create/update git tags + +- bumpDenoVersion now creates a Smartshell instance and runs git add deno.json, git commit -m "v", and git tag v to persist the version bump +- syncVersionToDenoJson now stages deno.json, amends the npm version commit with --no-edit, and recreates the tag with -fa to keep package.json and deno.json in sync +- Added informative logger messages after creating commits and tags + ## 2025-10-23 - 1.18.8 - fix(mod_commit) Improve commit workflow: detect project type and current branch; add robust version bump helpers for npm/deno diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b7d9475..100bb3e 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/cli', - version: '1.18.8', + version: '1.18.9', description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.' } diff --git a/ts/mod_commit/mod.helpers.ts b/ts/mod_commit/mod.helpers.ts index ebe573b..84c1d9d 100644 --- a/ts/mod_commit/mod.helpers.ts +++ b/ts/mod_commit/mod.helpers.ts @@ -90,12 +90,16 @@ function calculateNewVersion(currentVersion: string, versionType: VersionType): } /** - * Bumps the version in deno.json + * Bumps the version in deno.json, commits the change, and creates a tag * @param versionType Type of version bump * @returns The new version string */ export async function bumpDenoVersion(versionType: VersionType): Promise { const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json'); + const smartshellInstance = new plugins.smartshell.Smartshell({ + executor: 'bash', + sourceFilePaths: [], + }); try { // Read deno.json @@ -121,6 +125,17 @@ export async function bumpDenoVersion(versionType: VersionType): Promise denoJsonPath ); + // Stage the deno.json file + await smartshellInstance.exec('git add deno.json'); + + // Commit the version bump + await smartshellInstance.exec(`git commit -m "v${newVersion}"`); + + // Create the version tag + await smartshellInstance.exec(`git tag v${newVersion} -m "v${newVersion}"`); + + logger.log('info', `Created commit and tag v${newVersion}`); + return newVersion; } catch (error) { throw new Error(`Failed to bump deno.json version: ${error.message}`); @@ -147,11 +162,15 @@ async function bumpNpmVersion(versionType: VersionType): Promise { } /** - * Syncs the version from package.json to deno.json + * Syncs the version from package.json to deno.json and amends the npm commit * @param version The version to sync */ async function syncVersionToDenoJson(version: string): Promise { const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json'); + const smartshellInstance = new plugins.smartshell.Smartshell({ + executor: 'bash', + sourceFilePaths: [], + }); try { const denoConfig = plugins.smartfile.fs.toObjectSync( @@ -165,6 +184,17 @@ async function syncVersionToDenoJson(version: string): Promise { JSON.stringify(denoConfig, null, 2) + '\n', denoJsonPath ); + + // Stage the deno.json file + await smartshellInstance.exec('git add deno.json'); + + // Amend the npm version commit to include deno.json + await smartshellInstance.exec('git commit --amend --no-edit'); + + // Re-create the tag with force to update it + await smartshellInstance.exec(`git tag -fa v${version} -m "v${version}"`); + + logger.log('info', `Amended commit to include deno.json and updated tag v${version}`); } catch (error) { throw new Error(`Failed to sync version to deno.json: ${error.message}`); }