From 3ebf072bfbb829980fb572693d67ce3cd5d9adc6 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Mon, 15 Dec 2025 12:00:10 +0000 Subject: [PATCH] feat(format): Add --diff option to format command to display file diffs; pass flag through CLI and show formatter diffs. Bump @git.zone/tsdoc to ^1.11.0. --- changelog.md | 8 ++++ package.json | 2 +- pnpm-lock.yaml | 83 +++++++++++++++++++++++++++++++++++----- ts/00_commitinfo_data.ts | 2 +- ts/gitzone.cli.ts | 1 + ts/mod_format/index.ts | 16 ++++++++ 6 files changed, 101 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index 8ea586d..c7ec1f7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-12-15 - 2.9.0 - feat(format) +Add --diff option to format command to display file diffs; pass flag through CLI and show formatter diffs. Bump @git.zone/tsdoc to ^1.11.0. + +- Add a diff boolean option to mod_format to enable showing file diffs during format operations. +- CLI change: pass argvArg.diff into the options so the --diff flag is honored by the format command. +- When diff is enabled, run formatter.check() for each active formatter and call displayAllDiffs() for those with differences, with informational logging. +- Update dependency @git.zone/tsdoc from ^1.10.2 to ^1.11.0. + ## 2025-12-15 - 2.8.0 - feat(commit) Add commit configuration and automatic pre-commit tests diff --git a/package.json b/package.json index 7f23382..9b83133 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@types/node": "^25.0.2" }, "dependencies": { - "@git.zone/tsdoc": "^1.10.2", + "@git.zone/tsdoc": "^1.11.0", "@git.zone/tspublish": "^1.10.3", "@push.rocks/commitinfo": "^1.0.12", "@push.rocks/early": "^4.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a218ddb..147a8f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@git.zone/tsdoc': - specifier: ^1.10.2 - version: 1.10.2(ws@8.18.3)(zod@3.25.76) + specifier: ^1.11.0 + version: 1.11.0(ws@8.18.3)(zod@3.25.76) '@git.zone/tspublish': specifier: ^1.10.3 version: 1.10.3 @@ -520,8 +520,8 @@ packages: resolution: {integrity: sha512-YD1qMYA/4eOuF57V0ccR+xo6ww1+QOYFA2K5gBPFBDNh9VdfvWxxDhOUybja8lT9PVMoli8PHG5WA5tKJkdXIQ==} hasBin: true - '@git.zone/tsdoc@1.10.2': - resolution: {integrity: sha512-r4pKv74CH0KtzRvGdLioJd3DznSKmr8ZVE43QPFfGSNftH5P2eLAe5lc5nK8gCWb8mgEkb8WNfqtTL3Lkg+XyQ==} + '@git.zone/tsdoc@1.11.0': + resolution: {integrity: sha512-GUt/FFUwPB7rAdWaJW23YNCnEAJYrWHPcE6gjma8ojcmxc2f4vpofTKKXckLTefy8VMNnwE0EVYUm8iw9rPFtA==} hasBin: true '@git.zone/tspublish@1.10.3': @@ -999,12 +999,18 @@ packages: '@push.rocks/qenv@6.1.3': resolution: {integrity: sha512-+z2hsAU/7CIgpYLFqvda8cn9rUBMHqLdQLjsFfRn5jPoD7dJ5rFlpkbhfM4Ws8mHMniwWaxGKo+q/YBhtzRBLg==} + '@push.rocks/smartagent@file:../../push.rocks/smartagent': + resolution: {directory: ../../push.rocks/smartagent, type: directory} + '@push.rocks/smartai@0.8.0': resolution: {integrity: sha512-guzi28meUDc3mydC8kpoA+4pzExRQqygXYFDD4qQSWPpIRHQ7qhpeNqJzrrGezT1yOH5Gb9taPEGwT56hI+nwQ==} '@push.rocks/smartarchive@4.2.4': resolution: {integrity: sha512-uiqVAXPxmr8G5rv3uZvZFMOCt8l7cZC3nzvsy4YQqKf/VkPhKIEX+b7LkAeNlxPSYUiBQUkNRoawg9+5BaMcHg==} + '@push.rocks/smartarchive@5.0.1': + resolution: {integrity: sha512-x4bie9IIdL9BZqBZLc8Pemp8xZOJGa6mXSVgKJRL4/Rw+E5N4rVHjQOYGRV75nC2mAMJh9GIbixuxLnWjj77ag==} + '@push.rocks/smartarray@1.1.0': resolution: {integrity: sha512-b5YgBmUdglOJH8zeUf2ZWdPCoqySgwvkycRi2BhA9zVZHkpASh39Ej0q0fxFJetlUVyYqGfVoMVjbVrLFfFV7g==} @@ -1042,6 +1048,9 @@ packages: '@push.rocks/smartdelay@3.0.5': resolution: {integrity: sha512-mUuI7kj2f7ztjpic96FvRIlf2RsKBa5arw81AHNsndbxO6asRcxuWL8dTVxouEIK8YsBUlj0AsrCkHhMbLQdHw==} + '@push.rocks/smartdeno@1.2.0': + resolution: {integrity: sha512-6S1plCaMUVOZiRSflfoz9Fqk9phACCuKmc7Z6SfTvfl+p9VcPUmewKgaa/0QiLOpiI6ksfxdfmkS5Rw5HpYeIA==} + '@push.rocks/smartdiff@1.1.0': resolution: {integrity: sha512-AAz/unmko0C+g+60odOoK32PE3Ci3YLoB+zfg1LGLyVRCthcdzjqa1C2Km0MfG7IyJQKPdj8J5HPubtpm3ZeaQ==} @@ -2905,8 +2914,8 @@ packages: resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==} engines: {node: '>=16'} - isomorphic-git@1.36.0: - resolution: {integrity: sha512-22tU165ptowHYoDEwYJy5EKRzpHiuLMliaR01fH9ZwaUj1z/IqE++tGpjw/pD6eCWoxiOp6TPWX434aJ9zA4Lg==} + isomorphic-git@1.36.1: + resolution: {integrity: sha512-fC8SRT8MwoaXDK8G4z5biPEbqf2WyEJUb2MJ2ftSd39/UIlsnoZxLGux+lae0poLZO4AEcx6aUVOh5bV+P8zFA==} engines: {node: '>=14.17'} hasBin: true @@ -5060,12 +5069,13 @@ snapshots: - '@swc/helpers' - supports-color - '@git.zone/tsdoc@1.10.2(ws@8.18.3)(zod@3.25.76)': + '@git.zone/tsdoc@1.11.0(ws@8.18.3)(zod@3.25.76)': dependencies: '@git.zone/tspublish': 1.10.3 '@push.rocks/early': 4.0.4 '@push.rocks/npmextra': 5.3.3 '@push.rocks/qenv': 6.1.3 + '@push.rocks/smartagent': file:../../push.rocks/smartagent(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76) '@push.rocks/smartai': 0.8.0(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76) '@push.rocks/smartcli': 4.0.19 '@push.rocks/smartdelay': 3.0.5 @@ -5877,6 +5887,29 @@ snapshots: '@push.rocks/smartlog': 3.1.10 '@push.rocks/smartpath': 6.0.0 + '@push.rocks/smartagent@file:../../push.rocks/smartagent(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)': + dependencies: + '@push.rocks/smartai': 0.8.0(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76) + '@push.rocks/smartbrowser': 2.0.8(typescript@5.9.3) + '@push.rocks/smartdeno': 1.2.0 + '@push.rocks/smartfs': 1.2.0 + '@push.rocks/smartrequest': 5.0.1 + '@push.rocks/smartshell': 3.3.0 + transitivePeerDependencies: + - '@nuxt/kit' + - aws-crt + - bare-abort-controller + - bare-buffer + - bufferutil + - react + - react-native-b4a + - supports-color + - typescript + - utf-8-validate + - vue + - ws + - zod + '@push.rocks/smartai@0.8.0(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)': dependencies: '@anthropic-ai/sdk': 0.65.0(zod@3.25.76) @@ -5923,6 +5956,26 @@ snapshots: - react-native-b4a - supports-color + '@push.rocks/smartarchive@5.0.1': + dependencies: + '@push.rocks/smartdelay': 3.0.5 + '@push.rocks/smartfile': 13.1.2 + '@push.rocks/smartpath': 6.0.0 + '@push.rocks/smartpromise': 4.2.3 + '@push.rocks/smartrequest': 4.4.2 + '@push.rocks/smartrx': 3.0.10 + '@push.rocks/smartstream': 3.2.5 + '@push.rocks/smartunique': 3.0.9 + '@push.rocks/smarturl': 3.1.0 + '@types/tar-stream': 3.1.4 + fflate: 0.8.2 + file-type: 21.1.1 + tar-stream: 3.1.7 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + - supports-color + '@push.rocks/smartarray@1.1.0': {} '@push.rocks/smartbrowser@2.0.8(typescript@5.9.3)': @@ -6046,6 +6099,18 @@ snapshots: dependencies: '@push.rocks/smartpromise': 4.2.3 + '@push.rocks/smartdeno@1.2.0': + dependencies: + '@push.rocks/smartarchive': 5.0.1 + '@push.rocks/smartfs': 1.2.0 + '@push.rocks/smartpath': 6.0.0 + '@push.rocks/smartshell': 3.3.0 + '@push.rocks/smartunique': 3.0.9 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + - supports-color + '@push.rocks/smartdiff@1.1.0': dependencies: diff: 8.0.2 @@ -6177,7 +6242,7 @@ snapshots: '@push.rocks/smarttime': 4.1.1 '@types/diff': 8.0.0 diff: 8.0.2 - isomorphic-git: 1.36.0 + isomorphic-git: 1.36.1 minimatch: 10.1.1 '@push.rocks/smartguard@3.1.0': @@ -8573,7 +8638,7 @@ snapshots: isexe@3.1.1: {} - isomorphic-git@1.36.0: + isomorphic-git@1.36.1: dependencies: async-lock: 1.4.1 clean-git-ref: 2.0.1 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 7d50897..c871cd7 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: '2.8.0', + version: '2.9.0', 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/gitzone.cli.ts b/ts/gitzone.cli.ts index 1d6b7ca..92f6882 100644 --- a/ts/gitzone.cli.ts +++ b/ts/gitzone.cli.ts @@ -92,6 +92,7 @@ export let run = async () => { interactive: argvArg.interactive !== false, parallel: argvArg.parallel !== false, verbose: argvArg.verbose, + diff: argvArg.diff, }); }); diff --git a/ts/mod_format/index.ts b/ts/mod_format/index.ts index edf9673..fbf465f 100644 --- a/ts/mod_format/index.ts +++ b/ts/mod_format/index.ts @@ -29,6 +29,7 @@ export let run = async ( interactive?: boolean; parallel?: boolean; verbose?: boolean; + diff?: boolean; // Show file diffs } = {}, ): Promise => { // Set verbose mode if requested @@ -132,6 +133,21 @@ export let run = async ( return; } + // Show diffs if requested (works in both dry-run and write modes) + if (options.diff) { + logger.log('info', 'Showing file diffs:'); + console.log(''); + + for (const formatter of activeFormatters) { + const checkResult = await formatter.check(); + if (checkResult.hasDiff) { + logger.log('info', `[${formatter.name}]`); + formatter.displayAllDiffs(checkResult); + console.log(''); + } + } + } + // Dry-run mode (default behavior) if (!shouldWrite) { logger.log('info', 'Dry-run mode - use --write (-w) to apply changes');