From 25df1defd77996a25e00c16ca41a1280712f9980 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 4 May 2026 13:06:00 +0200 Subject: [PATCH 1/5] docs: add npm, license, build status and bundle size badges --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 246eac6..a2ce22a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # jsonkdiff -![Build status](https://github.com/grrtbrtr/jsonkdiff/actions/workflows/test.yml/badge.svg) -![NPM version](https://img.shields.io/npm/v/@grrtbrtr/jsonkdiff) +![NPM version](https://img.shields.io/npm/v/@grrtbrtr/jsonkdiff?color=blue) ![License](https://img.shields.io/github/license/grrtbrtr/jsonkdiff) ![Build](https://img.shields.io/github/actions/workflow/status/grrtbrtr/jsonkdiff/test.yml) ![Bundle size](https://img.shields.io/bundlephobia/min/@grrtbrtr/jsonkdiff) A lightweight, zero-dependency CLI tool to compare multiple JSON files and identify missing (non-common) keys. It generates a per-file report of unique keys to help identify schema drift. From 5ae44dae6e4210c8a69ac12d8cac1e912f3539a3 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 4 May 2026 13:06:08 +0200 Subject: [PATCH 2/5] 1.0.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c86a021..e7db798 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "license": "GPL-3.0-only", "bin": { "jsonkdiff": "bin/cli.js" diff --git a/package.json b/package.json index 54d1e6a..a894515 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "description": "Compare multiple JSON files and find non-common keys. Generates a per-file report of unique keys to help identify schema drift.", "keywords": [ "json", From bb637225f4b456574441823dc3d8001e6b1b94c0 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Fri, 8 May 2026 17:03:39 +0200 Subject: [PATCH 3/5] feature: optimize key comparison using Set for O(1) lookups (#5) - Refactor computeKeyDiff to convert key arrays into Sets - Improve time complexity from O(n^2) to O(n) - Reduce execution time for large JSON datasets Co-authored-by: Gerrit Bertier --- src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 80ca10b..7f69ad1 100644 --- a/src/index.js +++ b/src/index.js @@ -13,15 +13,20 @@ import { getDeepKeys } from './utils/object-utils.js'; */ export function computeKeyDiff(datasets) { const allKeys = new Set(); + const processedData = datasets.map(ds => { const keys = getDeepKeys(ds.object); keys.forEach(k => allKeys.add(k)); - return { name: ds.name, keys }; + + return { + name: ds.name, + keySet: new Set(keys), + }; }); const report = {}; for (const item of processedData) { - report[item.name] = [...allKeys].filter(k => !item.keys.includes(k)); + report[item.name] = [...allKeys].filter(k => !item.keySet.has(k)); } return report; } From 4ec60b41db6470b86e14d45f6f3e82f38864e9aa Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 11 May 2026 11:46:46 +0200 Subject: [PATCH 4/5] Updated documentation for usage clarity --- README.md | 47 ++++++++++++++++++++++++++++++++++++++--------- package.json | 27 +++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a2ce22a..41f8b71 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ A lightweight, zero-dependency CLI tool to compare multiple JSON files and identify missing (non-common) keys. It generates a per-file report of unique keys to help identify schema drift. -Perfect for auditing translation files, config sets, or API mocks. +### Why jsonkdiff? +Standard diff tools (like `git diff`) show line-by-line changes. `@grrtbrtr/jsonkdiff` focuses on **structural completeness**. It answers the question: *"I added a new key to my English translation file; did I forget to add it to the other 5 languages?"* ## Features @@ -29,16 +30,44 @@ npm install -g @grrtbrtr/jsonkdiff jsonkdiff file1.json file2.json file3.json ``` -## Example output +## Usage example: auditing i18n files -If `en.json` has `{"auth": {"login": "Log In"}}` and `es.json` is empty, `jsonkdiff` will report: +**file-a.json (English)** ```JSON -{ - "es.json": [ - "auth", - "auth.login" - ] -} +{ "nav": { "home": "Home", "about": "About" }, "logout": "Log Out" } +``` + +**file-b.json (French)** +```JSON +{ "nav": { "home": "Accueil" } } +``` + +**Running:** +```bash +npx @grrtbrtr/jsonkdiff file-a.json file-b.json +``` + +**Output:** +``` +--- JSON Key Diff Report --- + +File: b.json + × Missing key: nav.about + × Missing key: logout +``` + +## CI/CD integration + +`jsonkdiff` follows standard Unix exit codes, making it usable in CI/CD pipelines (GitHub Actions, GitLab CI, etc.): + +- **Exit code `0`**: No missing keys found (Success). +- **Exit code `1`**: Missing keys detected or an error occurred (Failure). + +**Example: failing a GitHub Action if keys are missing** + +```yaml +- name: Audit JSON Schemas + run: npx @grrtbrtr/jsonkdiff locales/en.json locales/fr.json ``` ## License diff --git a/package.json b/package.json index a894515..bc40a2b 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,30 @@ { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.2", + "version": "1.1.0", "description": "Compare multiple JSON files and find non-common keys. Generates a per-file report of unique keys to help identify schema drift.", "keywords": [ "json", "json-keys", + "json-diff", + "json-compare", "json-comparison", - "diff", + "json-schema-validator", + "i18n-audit", + "i18n-checker", + "i18n-validator", + "localization-tools", + "localization-helper", + "translation-check", "schema", "schema-drift", - "comparison", + "deep-diff", + "recursive-compare", + "zero-dependencies", "cli", - "devtools" + "cli-tool", + "devtools", + "config-validator", + "deep-comparison" ], "homepage": "https://github.com/grrtbrtr/jsonkdiff#readme", "bugs": { @@ -23,8 +36,14 @@ }, "license": "GPL-3.0-only", "author": "Gerrit Bertier ", + "funding": "https://github.com/grrtbrtr", "type": "module", + "sideEffects": false, "main": "src/index.js", + "exports": { + ".": "./src/index.js", + "./package.json": "./package.json" + }, "bin": { "jsonkdiff": "bin/cli.js" }, From b2e3ffa9a00ed7919cc4514776d56111c68fd957 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 11 May 2026 11:47:22 +0200 Subject: [PATCH 5/5] Updated CLI tool to use exit code 1 when not enough file paths are passed to the tool --- bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index 76164d0..56fc735 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -14,7 +14,7 @@ const files = process.argv.slice(2); if (files.length < 2) { console.log(`\n${STYLES.bold}Usage:${STYLES.reset} jsonkdiff ...`); - process.exit(0); + process.exit(1); } async function main() {