periderm-cli 0.1.17 → 0.1.19

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/dist/index.js CHANGED
@@ -30,7 +30,7 @@ const program = new Command();
30
30
  program
31
31
  .name("periderm")
32
32
  .description("A pre-launch checklist.")
33
- .version("0.1.17");
33
+ .version("0.1.18");
34
34
  // Easter egg: `periderm bless` — hidden, undocumented
35
35
  program
36
36
  .command("bless", { hidden: true })
@@ -622,6 +622,76 @@ const deadEndPage = (source, file) => {
622
622
  return out;
623
623
  };
624
624
  // ───────────────────────────────────────────────────────────────────────
625
+ // 14. Aggressive DB/API polling for "live" updates instead of websockets
626
+ // ───────────────────────────────────────────────────────────────────────
627
+ const dbPollingAbuse = (source, file) => {
628
+ const out = [];
629
+ if (!/\.(tsx|jsx|ts|js)$/.test(file))
630
+ return out;
631
+ const intervalPatterns = [
632
+ [/refetchInterval\s*:\s*(\d+)/g, "TanStack/React Query refetchInterval"],
633
+ [/refreshInterval\s*:\s*(\d+)/g, "SWR refreshInterval"],
634
+ [/(?:pollInterval|pollingInterval)\s*[:=]\s*(\d+)/g, "polling interval"],
635
+ ];
636
+ for (const [re, label] of intervalPatterns) {
637
+ let m;
638
+ while ((m = re.exec(source))) {
639
+ const ms = parseInt(m[1], 10);
640
+ if (ms > 0 && ms < 5000) {
641
+ out.push(mkFinding({
642
+ id: "db-polling-interval",
643
+ category: "Runaway Cloud Costs",
644
+ severity: "critical",
645
+ file,
646
+ line: lineOf(source, m.index),
647
+ message: `${label} set to ${ms}ms — polling the database/API several times per second.`,
648
+ why: "Vibecoded \"live feedback\" loops hammer your DB/API on every tab open. On Supabase/Firebase/serverless this can burn through free tiers and bankrupt you overnight. Use websockets, Supabase Realtime, or SSE instead.",
649
+ fix: "Replace polling with Supabase Realtime (.channel/.subscribe), WebSockets, or server-sent events. If you must poll, use ≥30s intervals and pause when the tab is hidden.",
650
+ aiPrompt: `In ${file} near line ${lineOf(source, m.index)}, ${label} is ${ms}ms — far too aggressive for live updates. Refactor to Supabase Realtime channels or WebSockets for push updates, or raise the interval to 30s+ with visibility-based pausing.`,
651
+ }));
652
+ }
653
+ }
654
+ }
655
+ const intervalFetchRe = /setInterval\s*\(\s*(?:async\s*)?\(?[^)]*\)?\s*=>\s*\{[\s\S]{0,700}?(supabase\.(?:from|rpc)|\.select\s*\(|fetch\s*\(|axios\.|\.get\s*\()/gi;
656
+ let m;
657
+ while ((m = intervalFetchRe.exec(source))) {
658
+ const snippet = m[0];
659
+ const hasRealtime = /\.channel\s*\(|\.subscribe\s*\(|WebSocket|useRealtime|postgres_changes/.test(source);
660
+ const intervalMs = snippet.match(/setInterval\s*\([^,]+,\s*(\d+)/)?.[1];
661
+ const ms = intervalMs ? parseInt(intervalMs, 10) : 1000;
662
+ if (ms < 5000 && !hasRealtime) {
663
+ out.push(mkFinding({
664
+ id: "setinterval-db-poll",
665
+ category: "Runaway Cloud Costs",
666
+ severity: "critical",
667
+ file,
668
+ line: lineOf(source, m.index),
669
+ message: `setInterval (${ms}ms) repeatedly hits the database/API for live updates.`,
670
+ why: "This pattern mimics realtime with expensive polling. Every user multiplies reads/writes. It is the #1 surprise bill for AI-generated dashboards and chat UIs.",
671
+ fix: "Use Supabase Realtime, WebSockets, or SSE. Delete the interval and subscribe to push events instead.",
672
+ aiPrompt: `In ${file} near line ${lineOf(source, m.index)}, a setInterval every ${ms}ms fetches from the database/API. Replace with Supabase Realtime (.channel().on('postgres_changes')) or WebSockets so updates push instead of poll.`,
673
+ }));
674
+ }
675
+ }
676
+ const useEffectPollRe = /useEffect\s*\(\s*\(\s*\)\s*=>\s*\{[\s\S]{0,500}?setInterval\s*\([\s\S]{0,400}?(supabase\.(?:from|rpc)|fetch\s*\()/g;
677
+ while ((m = useEffectPollRe.exec(source))) {
678
+ if (/\.channel\s*\(|WebSocket|realtime/.test(m[0]))
679
+ continue;
680
+ out.push(mkFinding({
681
+ id: "useeffect-polling",
682
+ category: "Runaway Cloud Costs",
683
+ severity: "high",
684
+ file,
685
+ line: lineOf(source, m.index),
686
+ message: "useEffect sets up interval polling against the database/API.",
687
+ why: "Polling in useEffect is a common vibecoder pattern for \"live\" dashboards. It scales linearly with users and tabs, unlike websocket subscriptions.",
688
+ fix: "Switch to Supabase Realtime subscriptions or WebSockets. Add cleanup if you keep any polling.",
689
+ aiPrompt: `In ${file} near line ${lineOf(source, m.index)}, useEffect starts interval polling for data. Replace with a Realtime subscription (supabase.channel) or WebSocket listener, and return an unsubscribe cleanup.`,
690
+ }));
691
+ }
692
+ return out;
693
+ };
694
+ // ───────────────────────────────────────────────────────────────────────
625
695
  // Registry
626
696
  // ───────────────────────────────────────────────────────────────────────
627
697
  const CHECKS = [
@@ -646,6 +716,7 @@ const CHECKS = [
646
716
  missingRateLimit,
647
717
  idorDataFetch,
648
718
  deadEndPage,
719
+ dbPollingAbuse,
649
720
  ];
650
721
  export const PER_FILE_CHECK_COUNT = CHECKS.length;
651
722
  export function runChecks(source, file, ast) {
@@ -3,6 +3,7 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { readConfig } from "./config.js";
6
+ import { PERIDERM_ASCII } from "./constants.js";
6
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
8
  const pkgPath = path.join(__dirname, "..", "package.json");
8
9
  export async function checkUpdate() {
@@ -27,22 +28,19 @@ export async function checkUpdate() {
27
28
  const isUnix = process.platform !== "win32" && process.platform !== "android";
28
29
  const npmCmd = isUnix ? `sudo npm install -g ${name}` : `npm install -g ${name}`;
29
30
  const curlCmd = `curl -fsSL ${apiUrl}/install.sh | bash`;
30
- const title = `A new version of Periderm CLI is available: ${currentVersion} → ${latestVersion}`;
31
- const textNpm = `Update via npm: ${npmCmd}`;
32
- const textCurl = `Update via curl: ${curlCmd}`;
33
- const width = Math.max(title.length, textNpm.length, textCurl.length) + 4;
34
- const pad = (rawLen) => " ".repeat(Math.max(0, width - rawLen - 2));
35
- const box = `
36
- ╭${"─".repeat(width)}╮
37
- │${" ".repeat(width)}│
38
- │ A new version of Periderm CLI is available: ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}${pad(title.length)}│
39
- │${" ".repeat(width)}│
40
- │ Update via npm: ${chalk.cyan(npmCmd)}${pad(textNpm.length)}│
41
- │ Update via curl: ${chalk.cyan(curlCmd)}${pad(textCurl.length)}│
42
- │${" ".repeat(width)}│
43
- ╰${"─".repeat(width)}╯
44
- `;
45
- console.log(box);
31
+ const actualLogoLines = PERIDERM_ASCII.split("\n");
32
+ console.info("");
33
+ for (const line of actualLogoLines) {
34
+ console.info(chalk.hex("#FF4D00")(line));
35
+ }
36
+ console.info("");
37
+ console.info(chalk.bold.cyan("Update Available!"));
38
+ console.info(chalk.white("───────────────────────────────────"));
39
+ console.info(chalk.bold.green(`✓ New version: ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}`));
40
+ console.info("");
41
+ console.info(chalk.bold.white("NPM : ") + chalk.cyan(npmCmd));
42
+ console.info(chalk.bold.white("Curl : ") + chalk.cyan(curlCmd));
43
+ console.info("");
46
44
  }
47
45
  }
48
46
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "periderm-cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "A pre-launch checklist for your codebase. Scan JS, TS, JSX, and TSX projects before you ship.",
5
5
  "type": "module",
6
6
  "bin": {