@alimaandev/ripple 0.1.1 → 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.
- package/README.md +163 -57
- package/dist/bin.js +490 -119
- package/dist/bin.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -16,7 +16,10 @@ Change less. Break less. Know the blast radius of any file before you touch it.
|
|
|
16
16
|
<a href="package.json"><img alt="Node.js >= 22" src="https://img.shields.io/badge/Node.js-%3E%3D22-339933?logo=nodedotjs&logoColor=white&style=for-the-badge"/></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
|
-
<pre><code>npm install -g @alimaandev/ripple
|
|
19
|
+
<pre><code>npm install -g @alimaandev/ripple
|
|
20
|
+
|
|
21
|
+
# or try it without installing anything:
|
|
22
|
+
npx @alimaandev/ripple analyze src/your-file.ts</code></pre>
|
|
20
23
|
|
|
21
24
|
<img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/hero.svg" alt="Terminal output of `ripple analyze` — risk, affected files, routes, components, tests, and confidence score" title="ripple analyze" width="100%" />
|
|
22
25
|
|
|
@@ -44,13 +47,12 @@ exactly how a change propagates through your codebase:
|
|
|
44
47
|
```text
|
|
45
48
|
$ ripple analyze src/authentication/login.ts
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Confidence 100%
|
|
50
|
+
File src/authentication/login.ts
|
|
51
|
+
Risk MEDIUM · 34.7/100 ███░░░░░░░
|
|
52
|
+
Impact 4 routes · 2 components · 1 test
|
|
53
|
+
Affected 7 files
|
|
54
|
+
Max depth 2
|
|
55
|
+
Confidence 100%
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
No black box.
|
|
@@ -77,6 +79,7 @@ Just deterministic analysis against the code you actually have.
|
|
|
77
79
|
| **Categorized results** | Routes, layouts, components, utilities, and tests detected by path conventions — not a raw string of file names. |
|
|
78
80
|
| **Entry-point intelligence** | `package.json` `main`/`bin` plus conventional root and `src` entry files, flagged in the report. |
|
|
79
81
|
| **Stable JSON contract** | A machine-readable report for CI gates, dashboards, and tooling — additive-only compatibility. |
|
|
82
|
+
| **Change-set gating** | `ripple diff` analyzes every changed file since a base ref and blocks the merge on risky code. |
|
|
80
83
|
| **Error-tolerant parsing** | A broken file lowers confidence instead of aborting the run. No false precision. |
|
|
81
84
|
| **Deterministic & offline** | Same input, same output, every time. No hidden network dependency. |
|
|
82
85
|
|
|
@@ -109,38 +112,49 @@ npm link # exposes the global `ripple` binary
|
|
|
109
112
|
|
|
110
113
|
### Run your first analysis
|
|
111
114
|
|
|
115
|
+
No install required — `npx` pulls the package from the registry on the fly:
|
|
116
|
+
|
|
112
117
|
```bash
|
|
113
118
|
cd tests/fixtures/basic
|
|
119
|
+
npx @alimaandev/ripple analyze src/authentication/login.ts
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Once you're sold, install it globally:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm install -g @alimaandev/ripple
|
|
114
126
|
ripple analyze src/authentication/login.ts
|
|
115
127
|
```
|
|
116
128
|
|
|
117
129
|
Expected output:
|
|
118
130
|
|
|
119
131
|
```text
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Top
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
╭ ripple ────────────────────────────╮
|
|
133
|
+
│ ❯ impact analysis · v0.2.0 │
|
|
134
|
+
╰────────────────────────────────────╯
|
|
135
|
+
|
|
136
|
+
File src/authentication/login.ts
|
|
137
|
+
Risk MEDIUM · 34.7/100 ███░░░░░░░
|
|
138
|
+
Impact 4 routes · 2 components · 1 test
|
|
139
|
+
Affected 7 files
|
|
140
|
+
Max depth 2
|
|
141
|
+
Confidence 100%
|
|
142
|
+
|
|
143
|
+
────────────────────────────────────
|
|
144
|
+
Top impact
|
|
145
|
+
● Dashboard (2)
|
|
146
|
+
● Admin (1)
|
|
147
|
+
● Index TS (1)
|
|
148
|
+
|
|
149
|
+
────────────────────────────────────
|
|
150
|
+
Circular dependencies
|
|
151
|
+
◯ src/circular/a.ts → src/circular/c.ts → src/circular/b.ts → src/circular/a.ts
|
|
152
|
+
|
|
153
|
+
────────────────────────────────────
|
|
154
|
+
Affected files (7)
|
|
155
|
+
├─ src/admin/page.tsx · depth 1
|
|
156
|
+
├─ src/dashboard/page.tsx · depth 1
|
|
157
|
+
└─ src/main.ts · depth 2
|
|
144
158
|
```
|
|
145
159
|
|
|
146
160
|
### See more of the project
|
|
@@ -153,7 +167,9 @@ ripple graph
|
|
|
153
167
|
```
|
|
154
168
|
|
|
155
169
|
```text
|
|
156
|
-
|
|
170
|
+
╭ ripple ────────────────────────────╮
|
|
171
|
+
│ ❯ dependency graph · v0.2.0 │
|
|
172
|
+
╰────────────────────────────────────╯
|
|
157
173
|
|
|
158
174
|
Files 25
|
|
159
175
|
Edges 28
|
|
@@ -161,8 +177,9 @@ External 4
|
|
|
161
177
|
Unresolved 0
|
|
162
178
|
Circular groups 1
|
|
163
179
|
|
|
164
|
-
|
|
165
|
-
|
|
180
|
+
────────────────────────────────────
|
|
181
|
+
Circular dependencies
|
|
182
|
+
◯ src/circular/a.ts → src/circular/c.ts → src/circular/b.ts → src/circular/a.ts
|
|
166
183
|
```
|
|
167
184
|
|
|
168
185
|
Point it at a file to see its dependency tree — forwards (what it imports)
|
|
@@ -188,28 +205,35 @@ ripple <command> [options]
|
|
|
188
205
|
| ---------------- | ------------------------------------------------- |
|
|
189
206
|
| `analyze <file>` | Impact analysis for a target file |
|
|
190
207
|
| `graph [file]` | Project stats, or a single file's dependency tree |
|
|
208
|
+
| `diff` | Gate all files changed since a git base ref |
|
|
191
209
|
| `doctor` | Project and environment health check |
|
|
192
210
|
| `init` | Scaffold a `ripple.config.json` |
|
|
193
211
|
| `version` | Print the current version |
|
|
194
212
|
|
|
195
213
|
### Options
|
|
196
214
|
|
|
197
|
-
| Command | Flag | Description
|
|
198
|
-
| --------- | --------------------- |
|
|
199
|
-
| `analyze` | `-j, --json` | Emit the JSON report instead of the terminal report
|
|
200
|
-
| `analyze` | `-v, --verbose` | Include the risk-factor point breakdown
|
|
201
|
-
| `analyze` | `-d, --depth <n>` | Cap the reverse traversal at `n` levels
|
|
202
|
-
| `analyze` | `-c, --config <path>` | Use a specific config file
|
|
203
|
-
| `analyze` | `--no-color` | Disable ANSI colors
|
|
204
|
-
| `graph` | `-j, --json` | Emit the JSON report
|
|
205
|
-
| `graph` | `-r, --reverse` | Show dependents (what imports this file) instead of dependencies
|
|
206
|
-
| `graph` | `-d, --depth <n>` | Cap tree depth
|
|
207
|
-
| `graph` | `-c, --config <path>` | Use a specific config file
|
|
208
|
-
| `graph` | `--no-color` | Disable ANSI colors
|
|
209
|
-
| `doctor` | `-c, --config <path>` | Use a specific config file
|
|
210
|
-
| `doctor` | `-v, --verbose` | Verbose output
|
|
211
|
-
| `doctor` | `--no-color` | Disable ANSI colors
|
|
212
|
-
| `init` | `-f, --force` | Overwrite an existing config
|
|
215
|
+
| Command | Flag | Description |
|
|
216
|
+
| --------- | --------------------- | ------------------------------------------------------------------ |
|
|
217
|
+
| `analyze` | `-j, --json` | Emit the JSON report instead of the terminal report |
|
|
218
|
+
| `analyze` | `-v, --verbose` | Include the risk-factor point breakdown |
|
|
219
|
+
| `analyze` | `-d, --depth <n>` | Cap the reverse traversal at `n` levels |
|
|
220
|
+
| `analyze` | `-c, --config <path>` | Use a specific config file |
|
|
221
|
+
| `analyze` | `--no-color` | Disable ANSI colors |
|
|
222
|
+
| `graph` | `-j, --json` | Emit the JSON report |
|
|
223
|
+
| `graph` | `-r, --reverse` | Show dependents (what imports this file) instead of dependencies |
|
|
224
|
+
| `graph` | `-d, --depth <n>` | Cap tree depth |
|
|
225
|
+
| `graph` | `-c, --config <path>` | Use a specific config file |
|
|
226
|
+
| `graph` | `--no-color` | Disable ANSI colors |
|
|
227
|
+
| `doctor` | `-c, --config <path>` | Use a specific config file |
|
|
228
|
+
| `doctor` | `-v, --verbose` | Verbose output |
|
|
229
|
+
| `doctor` | `--no-color` | Disable ANSI colors |
|
|
230
|
+
| `init` | `-f, --force` | Overwrite an existing config |
|
|
231
|
+
| `diff` | `-j, --json` | Emit the JSON report instead of the terminal report |
|
|
232
|
+
| `diff` | `-b, --base <ref>` | Git ref to diff against (default: `origin/main`, `main`, `HEAD~1`) |
|
|
233
|
+
| `diff` | `-g, --gate <level>` | Blocking level: `medium`, `high`, or `critical` (default: `high`) |
|
|
234
|
+
| `diff` | `-d, --depth <n>` | Cap reverse traversal per file |
|
|
235
|
+
| `diff` | `-c, --config <path>` | Use a specific config file |
|
|
236
|
+
| `diff` | `--no-color` | Disable ANSI colors |
|
|
213
237
|
|
|
214
238
|
### `ripple doctor`
|
|
215
239
|
|
|
@@ -239,6 +263,41 @@ $ ripple doctor
|
|
|
239
263
|
|
|
240
264
|
Writes `ripple.config.json` with the recommended defaults, ready to edit.
|
|
241
265
|
|
|
266
|
+
### `ripple diff`
|
|
267
|
+
|
|
268
|
+
Analyzes every file that changed since a base git ref, scores each with the
|
|
269
|
+
same risk model as `analyze`, and gates the change set: any file reaching
|
|
270
|
+
the gate level (HIGH by default) makes the command exit `1`. Untracked
|
|
271
|
+
files are included; deleted files and non-source changes are skipped.
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
cd my-project
|
|
275
|
+
ripple diff # vs origin/main (then main, then HEAD~1)
|
|
276
|
+
ripple diff --base HEAD~1 --json # machine-readable gate report
|
|
277
|
+
ripple diff --gate critical # only CRITICAL blocks the merge
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
```text
|
|
281
|
+
╭ ripple ─────────────────────╮
|
|
282
|
+
│ ❯ diff vs origin/main │
|
|
283
|
+
╰─────────────────────────────╯
|
|
284
|
+
|
|
285
|
+
Changed 2 files
|
|
286
|
+
Source 2 files
|
|
287
|
+
Duration 118ms
|
|
288
|
+
|
|
289
|
+
✖ Gate blocked — 1 CRITICAL (no HIGH or CRITICAL)
|
|
290
|
+
|
|
291
|
+
─────────────────────────────────────
|
|
292
|
+
Risk analysis (2 files)
|
|
293
|
+
✖ src/auth/token.ts CRITICAL · 88.2/100 ████████░░
|
|
294
|
+
● src/auth/session.ts LOW · 12.4/100 █░░░░░░░░░
|
|
295
|
+
… src/api/legacy.js (not a source file)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Run `ripple diff` locally before opening a PR, and in CI as the same gate —
|
|
299
|
+
identical code, identical verdict.
|
|
300
|
+
|
|
242
301
|
## Configuration
|
|
243
302
|
|
|
244
303
|
Ripple discovers `ripple.config.ts`, `.js`, `.cjs`, `.mjs`, or `.json` in the
|
|
@@ -375,6 +434,39 @@ error-tolerant recovery, `graph/` resolves specifiers and detects cycles, and
|
|
|
375
434
|
> change without a major version bump. `graph --json` follows the same
|
|
376
435
|
> convention.
|
|
377
436
|
|
|
437
|
+
### `ripple diff --json`
|
|
438
|
+
|
|
439
|
+
The diff report wraps a per-file view of the same risk model, plus the gate
|
|
440
|
+
verdict:
|
|
441
|
+
|
|
442
|
+
```json
|
|
443
|
+
{
|
|
444
|
+
"tool": "ripple",
|
|
445
|
+
"version": "0.3.0",
|
|
446
|
+
"command": "diff",
|
|
447
|
+
"base": "origin/main",
|
|
448
|
+
"changedFiles": 2,
|
|
449
|
+
"files": [
|
|
450
|
+
{
|
|
451
|
+
"file": "src/auth/token.ts",
|
|
452
|
+
"analyzed": true,
|
|
453
|
+
"risk": { "score": 88.2, "level": "CRITICAL", "factors": [] },
|
|
454
|
+
"affectedFiles": 14,
|
|
455
|
+
"targetInCycle": false
|
|
456
|
+
},
|
|
457
|
+
{ "file": "src/api/legacy.js", "analyzed": false }
|
|
458
|
+
],
|
|
459
|
+
"gate": {
|
|
460
|
+
"level": "high",
|
|
461
|
+
"blocked": true,
|
|
462
|
+
"counts": { "low": 0, "medium": 0, "high": 0, "critical": 1 }
|
|
463
|
+
},
|
|
464
|
+
"durationMs": 118
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
`blocked` tells CI everything: exit code `1` if `true`, `0` otherwise.
|
|
469
|
+
|
|
378
470
|
### Use it in CI
|
|
379
471
|
|
|
380
472
|
```bash
|
|
@@ -382,6 +474,16 @@ ripple analyze src/authentication/login.ts --json | jq -r .risk.level
|
|
|
382
474
|
# MEDIUM
|
|
383
475
|
```
|
|
384
476
|
|
|
477
|
+
Gate every changed file in one call:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
#!/usr/bin/env bash
|
|
481
|
+
set -euo pipefail
|
|
482
|
+
|
|
483
|
+
ripple diff --json --gate high
|
|
484
|
+
# exits 1 when any changed file is HIGH or CRITICAL
|
|
485
|
+
```
|
|
486
|
+
|
|
385
487
|
```bash
|
|
386
488
|
#!/usr/bin/env bash
|
|
387
489
|
set -euo pipefail
|
|
@@ -426,12 +528,12 @@ fi
|
|
|
426
528
|
|
|
427
529
|
## Exit codes
|
|
428
530
|
|
|
429
|
-
| Code | Meaning
|
|
430
|
-
| ---- |
|
|
431
|
-
| `0` | Success
|
|
432
|
-
| `1` | General failure
|
|
433
|
-
| `2` | Target file not found
|
|
434
|
-
| `3` | Config missing or invalid
|
|
531
|
+
| Code | Meaning |
|
|
532
|
+
| ---- | ------------------------------------- |
|
|
533
|
+
| `0` | Success |
|
|
534
|
+
| `1` | General failure / gate blocked |
|
|
535
|
+
| `2` | Target file or git base ref not found |
|
|
536
|
+
| `3` | Config missing or invalid |
|
|
435
537
|
|
|
436
538
|
## Development
|
|
437
539
|
|
|
@@ -457,6 +559,10 @@ npm install -g @alimaandev/ripple
|
|
|
457
559
|
ripple analyze src/your-file.ts --json | jq -r .risk.level # MEDIUM, HIGH, ...
|
|
458
560
|
```
|
|
459
561
|
|
|
562
|
+
If Ripple has ever kept you from an accidental breaking change, a
|
|
563
|
+
[little star](https://github.com/alimaandev/ripple) goes a long way — it
|
|
564
|
+
helps other developers find it.
|
|
565
|
+
|
|
460
566
|
## License
|
|
461
567
|
|
|
462
568
|
MIT — see [LICENSE](LICENSE).
|