cliguard 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +26 -0
  2. package/dist/bin.js +25 -5
  3. package/package.json +12 -3
package/README.md CHANGED
@@ -71,6 +71,25 @@ npx cliguard update ./bin/cli.js
71
71
 
72
72
  `cliguard check` exits `1` if it finds even one `BREAKING` change, and `0` otherwise - safe to drop straight into any CI pipeline.
73
73
 
74
+ Pass `--json` to `check` for a machine-readable result instead of the emoji lines above - useful for a bot that comments on the PR, a dashboard, or any other script consuming the result instead of a human reading it:
75
+
76
+ ```sh
77
+ npx cliguard check ./bin/cli.js --json
78
+ ```
79
+
80
+ ```json
81
+ {
82
+ "ok": false,
83
+ "changes": [
84
+ { "type": "BREAKING", "path": "root -> build -> option[--target]", "message": "Option \"--target\" was removed." }
85
+ ],
86
+ "summary": { "breaking": 1, "additive": 0, "patch": 0 },
87
+ "suggestedBump": "major"
88
+ }
89
+ ```
90
+
91
+ `suggestedBump` is the semver bump this diff implies (`"major"`, `"minor"`, `"patch"`, or `null` if nothing changed) - a direct read of the same BREAKING/ADDITIVE/PATCH classification the emoji output already uses, so a release script never has to re-derive it.
92
+
74
93
  ## How changes get classified
75
94
 
76
95
  | | Removed | Added | Required flipped | Value type / default changed |
@@ -115,6 +134,13 @@ Extracting a contract runs the target entry file's own top-level code, the same
115
134
 
116
135
  The CLI and core diffing engine are, and will stay, free and open-source. Planned next: a hosted add-on for teams that want more than a CI exit code - a dashboard with the history of contract changes across releases, and Slack/webhook alerts the moment a breaking change lands. See [issue: Webhook reporter for SaaS integration](https://github.com/Bryandero98/cliguard/issues) for the first building block.
117
136
 
137
+ ## Support this project
138
+
139
+ cliguard is free and will stay free. If it's saving you from a broken release, a small tip helps keep it going:
140
+
141
+ - **Ko-fi:** [ko-fi.com/bryandero98](https://ko-fi.com/bryandero98)
142
+ - **USDT (TRC20):** `TEG4Kk2qXYMQ4mHNd7dPhSPRyT14CGr2or` — double-check the network is set to **TRC20** before sending; a transfer on the wrong network can't be recovered.
143
+
118
144
  ## Contributing
119
145
 
120
146
  See [CONTRIBUTING.md](./CONTRIBUTING.md).
package/dist/bin.js CHANGED
@@ -42,28 +42,33 @@ program
42
42
  .option(...adapterOption)
43
43
  .action(async (entry, options) => {
44
44
  if ((0, storage_1.contractExists)()) {
45
- console.warn(`El contrato ya existe. Usa "cliguard update" para sobrescribirlo.`);
45
+ console.warn(`A contract already exists. Run "cliguard update" to overwrite it.`);
46
46
  process.exit(1);
47
47
  }
48
48
  const contract = await resolveAdapter(options.adapter).extract(entry);
49
49
  (0, storage_1.writeContract)(contract);
50
- console.log(`✅ Contrato de CLI inicializado con éxito en ${(0, storage_1.getContractDisplayPath)()}.`);
50
+ console.log(`✅ CLI contract initialized successfully at ${(0, storage_1.getContractDisplayPath)()}.`);
51
51
  });
52
52
  program
53
53
  .command("check")
54
54
  .description("Compare the current CLI surface against the committed contract")
55
55
  .argument("<entry>", "path to the target CLI's entry file")
56
56
  .option(...adapterOption)
57
+ .option("--json", "print a machine-readable JSON result instead of text", false)
57
58
  .action(async (entry, options) => {
58
59
  const oldContract = (0, storage_1.readContract)();
59
60
  const newContract = await resolveAdapter(options.adapter).extract(entry);
60
61
  const diff = diffEngine.compare(oldContract, newContract);
62
+ const hasBreaking = diff.some((entry) => entry.type === types_1.ChangeType.BREAKING);
63
+ if (options.json) {
64
+ console.log(JSON.stringify(toJsonResult(diff), null, 2));
65
+ process.exit(hasBreaking ? 1 : 0);
66
+ }
61
67
  if (diff.length === 0) {
62
- console.log("✅ El contrato de la CLI está intacto.");
68
+ console.log("✅ CLI contract is intact.");
63
69
  process.exit(0);
64
70
  }
65
71
  printDiff(diff);
66
- const hasBreaking = diff.some((entry) => entry.type === types_1.ChangeType.BREAKING);
67
72
  process.exit(hasBreaking ? 1 : 0);
68
73
  });
69
74
  program
@@ -74,8 +79,23 @@ program
74
79
  .action(async (entry, options) => {
75
80
  const contract = await resolveAdapter(options.adapter).extract(entry);
76
81
  (0, storage_1.writeContract)(contract);
77
- console.log("🔄 Contrato de CLI actualizado con éxito.");
82
+ console.log("🔄 CLI contract updated successfully.");
78
83
  });
84
+ function toJsonResult(diff) {
85
+ const summary = {
86
+ breaking: diff.filter((entry) => entry.type === types_1.ChangeType.BREAKING).length,
87
+ additive: diff.filter((entry) => entry.type === types_1.ChangeType.ADDITIVE).length,
88
+ patch: diff.filter((entry) => entry.type === types_1.ChangeType.PATCH).length,
89
+ };
90
+ const suggestedBump = summary.breaking > 0
91
+ ? "major"
92
+ : summary.additive > 0
93
+ ? "minor"
94
+ : summary.patch > 0
95
+ ? "patch"
96
+ : null;
97
+ return { ok: summary.breaking === 0, changes: diff, summary, suggestedBump };
98
+ }
79
99
  function printDiff(diff) {
80
100
  for (const entry of diff) {
81
101
  console.log(`${emojiFor(entry.type)} [${entry.path}] ${entry.message}`);
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "cliguard",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Snapshot-tests your CLI's contract (commands, flags, defaults) so you never ship a breaking change by accident.",
5
- "keywords": ["cli", "contract-testing", "snapshot-testing", "commander", "ci"],
5
+ "keywords": [
6
+ "cli",
7
+ "contract-testing",
8
+ "snapshot-testing",
9
+ "commander",
10
+ "ci"
11
+ ],
6
12
  "author": "Bryandero98",
7
13
  "license": "MIT",
8
14
  "homepage": "https://github.com/Bryandero98/cliguard",
@@ -13,10 +19,13 @@
13
19
  "bugs": {
14
20
  "url": "https://github.com/Bryandero98/cliguard/issues"
15
21
  },
22
+ "funding": "https://ko-fi.com/bryandero98",
16
23
  "bin": {
17
24
  "cliguard": "dist/bin.js"
18
25
  },
19
- "files": ["dist"],
26
+ "files": [
27
+ "dist"
28
+ ],
20
29
  "scripts": {
21
30
  "build": "tsc",
22
31
  "lint": "eslint src --ext .ts",