@alimaandev/ripple 0.1.0 → 0.1.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- <img src="assets/ripple-logo.png" alt="Ripple" width="120" />
3
+ <img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/ripple-logo.png" alt="Ripple" width="120" />
4
4
 
5
5
  # Ripple
6
6
 
@@ -16,7 +16,9 @@ Change less. Break less. Know the blast radius of any file before you touch it.
16
16
  &nbsp;<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>&nbsp;
17
17
  </p>
18
18
 
19
- <img src="assets/hero.svg" alt="Terminal output of `ripple analyze` — risk, affected files, routes, components, tests, and confidence score" title="ripple analyze" width="100%" />
19
+ <pre><code>npm install -g @alimaandev/ripple</code></pre>
20
+
21
+ <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%" />
20
22
 
21
23
  </div>
22
24
 
@@ -92,7 +94,7 @@ Everything below is real output against a shipped example project in `tests/fixt
92
94
  ```bash
93
95
  npm install -g @alimaandev/ripple
94
96
 
95
- ripple version # → 0.1.0
97
+ ripple version # → 0.1.1
96
98
  ```
97
99
 
98
100
  Or install from source:
@@ -294,7 +296,7 @@ That yields a score from 0–100 and a level at thresholds 30, 55, 80 — the
294
296
  same colors the CLI prints on your terminal:
295
297
 
296
298
  <p align="center">
297
- <img src="assets/risk-levels.svg" alt="Risk levels: LOW, MEDIUM, HIGH, CRITICAL" title="Risk levels" width="440" />
299
+ <img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/risk-levels.svg" alt="Risk levels: LOW, MEDIUM, HIGH, CRITICAL" title="Risk levels" width="440" />
298
300
  </p>
299
301
 
300
302
  Confidence (0–100) is separate — how trustworthy the analysis is. It drops
@@ -448,6 +450,13 @@ pnpm run build # tsup
448
450
  Architecture and design decisions live in [docs/architecture.md](docs/architecture.md).
449
451
  Before contributing, read [CONTRIBUTING.md](CONTRIBUTING.md).
450
452
 
453
+ ## Get started
454
+
455
+ ```bash
456
+ npm install -g @alimaandev/ripple
457
+ ripple analyze src/your-file.ts --json | jq -r .risk.level # MEDIUM, HIGH, ...
458
+ ```
459
+
451
460
  ## License
452
461
 
453
462
  MIT — see [LICENSE](LICENSE).
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/bin.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import { DEFAULT_CONFIG, rippleConfigSchema, formatSchemaIssues } from './chunk-OOERV74D.js';
2
3
  import { CommanderError, Command } from 'commander';
3
4
  import { createJiti } from 'jiti';
4
5
  import path8 from 'path';
5
6
  import fs from 'fs/promises';
6
7
  import fs2 from 'fs';
7
8
  import { Project, ts, SyntaxKind } from 'ts-morph';
8
- import { z } from 'zod';
9
9
  import ora from 'ora';
10
10
  import treeify from 'treeify';
11
11
  import chalk from 'chalk';
@@ -183,66 +183,6 @@ function substituteAlias(specifier, aliases) {
183
183
  return void 0;
184
184
  }
185
185
 
186
- // src/config/defaults.ts
187
- var DEFAULT_CONFIG = {
188
- include: ["**/*.{ts,tsx,js,jsx}"],
189
- ignore: ["node_modules", "dist", "build", "coverage", ".next", "out", ".git"],
190
- aliases: {},
191
- tsconfigPath: "tsconfig.json",
192
- risk: {
193
- weights: {
194
- affectedFiles: 0.3,
195
- entryPoint: 0.15,
196
- sharedUtility: 0.15,
197
- publicExports: 0.1,
198
- tests: 0.1,
199
- routes: 0.1,
200
- cycleMembership: 0.1
201
- },
202
- thresholds: {
203
- medium: 30,
204
- high: 55,
205
- critical: 80
206
- }
207
- }
208
- };
209
-
210
- // src/config/schema.ts
211
- var fraction = z.number().min(0).max(1);
212
- var score = z.number().min(0).max(100);
213
- var riskWeightsSchema = z.object({
214
- affectedFiles: fraction.default(DEFAULT_CONFIG.risk.weights.affectedFiles),
215
- entryPoint: fraction.default(DEFAULT_CONFIG.risk.weights.entryPoint),
216
- sharedUtility: fraction.default(DEFAULT_CONFIG.risk.weights.sharedUtility),
217
- publicExports: fraction.default(DEFAULT_CONFIG.risk.weights.publicExports),
218
- tests: fraction.default(DEFAULT_CONFIG.risk.weights.tests),
219
- routes: fraction.default(DEFAULT_CONFIG.risk.weights.routes),
220
- cycleMembership: fraction.default(DEFAULT_CONFIG.risk.weights.cycleMembership)
221
- }).strict();
222
- var riskThresholdsSchema = z.object({
223
- medium: score.default(DEFAULT_CONFIG.risk.thresholds.medium),
224
- high: score.default(DEFAULT_CONFIG.risk.thresholds.high),
225
- critical: score.default(DEFAULT_CONFIG.risk.thresholds.critical)
226
- }).strict();
227
- var riskConfigSchema = z.object({
228
- weights: riskWeightsSchema.default(DEFAULT_CONFIG.risk.weights),
229
- thresholds: riskThresholdsSchema.default(DEFAULT_CONFIG.risk.thresholds)
230
- }).strict();
231
- var rippleConfigSchema = z.object({
232
- include: z.array(z.string().min(1)).min(1).default(DEFAULT_CONFIG.include),
233
- ignore: z.array(z.string()).default(DEFAULT_CONFIG.ignore),
234
- aliases: z.record(z.string(), z.string()).default(DEFAULT_CONFIG.aliases),
235
- tsconfigPath: z.string().min(1).default(DEFAULT_CONFIG.tsconfigPath),
236
- risk: riskConfigSchema.default(DEFAULT_CONFIG.risk)
237
- }).strict();
238
- function formatSchemaIssues(error) {
239
- return error.issues.map((issue) => {
240
- const path12 = issue.path.join(".");
241
- const location = path12 === "" ? "config" : `config.${path12}`;
242
- return `${location}: ${issue.message}`;
243
- });
244
- }
245
-
246
186
  // src/config/loader.ts
247
187
  var CONFIG_CANDIDATES = [
248
188
  "ripple.config.ts",
@@ -600,10 +540,10 @@ function reverseTraverse(graph, targetKey, options) {
600
540
  }
601
541
 
602
542
  // src/risk/levels.ts
603
- function scoreToLevel(score2, thresholds) {
604
- if (score2 >= thresholds.critical) return "CRITICAL";
605
- if (score2 >= thresholds.high) return "HIGH";
606
- if (score2 >= thresholds.medium) return "MEDIUM";
543
+ function scoreToLevel(score, thresholds) {
544
+ if (score >= thresholds.critical) return "CRITICAL";
545
+ if (score >= thresholds.high) return "HIGH";
546
+ if (score >= thresholds.medium) return "MEDIUM";
607
547
  return "LOW";
608
548
  }
609
549
  function clamp(value, min, max) {
@@ -684,14 +624,14 @@ function scoreRisk(input) {
684
624
  contribution: Math.round(weight * value * 100 * 100) / 100
685
625
  };
686
626
  });
687
- const score2 = clamp(
627
+ const score = clamp(
688
628
  Math.round(factors.reduce((sum, factor) => sum + factor.contribution, 0) * 100) / 100,
689
629
  0,
690
630
  100
691
631
  );
692
632
  return {
693
- score: score2,
694
- level: scoreToLevel(score2, input.riskConfig.thresholds),
633
+ score,
634
+ level: scoreToLevel(score, input.riskConfig.thresholds),
695
635
  factors
696
636
  };
697
637
  }
@@ -1814,7 +1754,7 @@ async function run({ argv, ctx: ctx2 }) {
1814
1754
 
1815
1755
  // package.json
1816
1756
  var package_default = {
1817
- version: "0.1.0"};
1757
+ version: "0.1.1"};
1818
1758
 
1819
1759
  // src/cli/bin.ts
1820
1760
  var ctx = {