periderm-cli 0.1.61 → 0.1.63

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/bin.js CHANGED
@@ -12,7 +12,7 @@ process.on("unhandledRejection", (err) => {
12
12
  });
13
13
  // Import index.js. This starts executing the CLI but parseAsync() runs async
14
14
  // inside it — we grab mainDone so we can properly sequence the banner.
15
- const mod = await import("./index.js");
15
+ const mod = (await import("./index.js"));
16
16
  // Wait for the command to fully complete, then print update banner
17
17
  try {
18
18
  if (mod.mainDone)
package/dist/config.js CHANGED
@@ -11,9 +11,11 @@ export function readConfig() {
11
11
  try {
12
12
  if (fs.existsSync(CONFIG_FILE)) {
13
13
  const raw = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
14
- // Auto-fix corrupted config by clearing out localhost URLs
14
+ // Auto-fix corrupted config by clearing out localhost URLs
15
15
  // (forces the CLI to use the production default or the explicitly set PERIDERM_API_URL)
16
- if (raw.apiUrl && !process.env.PERIDERM_API_URL && (raw.apiUrl.includes("localhost") || raw.apiUrl.includes("127.0.0.1"))) {
16
+ if (raw.apiUrl &&
17
+ !process.env.PERIDERM_API_URL &&
18
+ (raw.apiUrl.includes("localhost") || raw.apiUrl.includes("127.0.0.1"))) {
17
19
  console.warn("[periderm] Detected local dev URL in config. Clearing corrupted config...");
18
20
  fs.unlinkSync(CONFIG_FILE); // Purge the corrupted file
19
21
  return { apiUrl: resolveApiUrl() };
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { verifyToken, uploadScan, fetchCloudPolicies } from "./api.js";
13
13
  import http from "node:http";
14
14
  import ora from "ora";
15
15
  import { PERIDERM_ASCII } from "./constants.js";
16
- import { PRE_SCAN_MESSAGES, UPLOAD_MESSAGES, startRotatingMessages, finishRotatingMessages } from "./loading-messages.js";
16
+ import { PRE_SCAN_MESSAGES, UPLOAD_MESSAGES, startRotatingMessages, finishRotatingMessages, } from "./loading-messages.js";
17
17
  import { formatScanPath } from "./scanner/progress.js";
18
18
  import { reportCliError } from "./error-report.js";
19
19
  function requireAuth() {
@@ -23,15 +23,14 @@ function requireAuth() {
23
23
  console.info(chalk.bold.red("✖ Authentication Required"));
24
24
  console.info("");
25
25
  console.info(chalk.white("You must be logged in to run this command."));
26
- console.info(chalk.white("Run ") + chalk.bold.cyan("$ periderm login") + chalk.white(" to securely authenticate."));
26
+ console.info(chalk.white("Run ") +
27
+ chalk.bold.cyan("$ periderm login") +
28
+ chalk.white(" to securely authenticate."));
27
29
  console.info("");
28
30
  process.exit(1);
29
31
  }
30
32
  const program = new Command();
31
- program
32
- .name("periderm")
33
- .description("A pre-launch checklist.")
34
- .version("0.1.57");
33
+ program.name("periderm").description("A pre-launch checklist.").version("0.1.57");
35
34
  // Easter egg: `periderm bless` — hidden, undocumented
36
35
  program
37
36
  .command("bless", { hidden: true })
@@ -41,10 +40,10 @@ program
41
40
  "",
42
41
  chalk.bold.hex("#FFD700")(" ✞ ─────────────────────────────────── ✞"),
43
42
  "",
44
- chalk.white(" \"For God so loved the world that he gave"),
43
+ chalk.white(' "For God so loved the world that he gave'),
45
44
  chalk.white(" his one and only Son, that whoever"),
46
45
  chalk.white(" believes in him shall not perish but"),
47
- chalk.white(" have eternal life.\""),
46
+ chalk.white(' have eternal life."'),
48
47
  chalk.dim(" — John 3:16"),
49
48
  "",
50
49
  chalk.bold.hex("#FFD700")(" ✦ Jesus Is Lord ✦"),
@@ -79,7 +78,8 @@ program
79
78
  console.info(chalk.yellow(`\nUpgrade at ${cfg.apiUrl}/dashboard/billing\n`));
80
79
  process.exit(1);
81
80
  }
82
- if (v.plan !== "unlimited" && (v.scans_remaining === undefined || v.scans_remaining <= 0)) {
81
+ if (v.plan !== "unlimited" &&
82
+ (v.scans_remaining === undefined || v.scans_remaining <= 0)) {
83
83
  verifySpinner.fail(`No scans left on your ${v.plan} plan.`);
84
84
  console.info(chalk.yellow(`\nRenew or upgrade at ${cfg.apiUrl}/dashboard/billing\n`));
85
85
  process.exit(1);
@@ -107,14 +107,19 @@ program
107
107
  const empty = 20 - filled;
108
108
  return `[${"█".repeat(filled)}${"░".repeat(empty)}] ${Math.round(pct * 100)}%`;
109
109
  };
110
- const result = await scan(root, { cloudIgnores, cloudAiRules,
110
+ const result = await scan(root, {
111
+ cloudIgnores,
112
+ cloudAiRules,
111
113
  onProgress: (ev) => {
112
114
  switch (ev.type) {
113
115
  case "discovering":
114
116
  scanSpinner.text = "Discovering project files…";
115
117
  break;
116
118
  case "discovered":
117
- scanSpinner.stopAndPersist({ symbol: chalk.green("✔"), text: chalk.white(`Found ${ev.total} source files.`) });
119
+ scanSpinner.stopAndPersist({
120
+ symbol: chalk.green("✔"),
121
+ text: chalk.white(`Found ${ev.total} source files.`),
122
+ });
118
123
  scanSpinner = ora({ text: "Scanning...", color: "cyan" }).start();
119
124
  break;
120
125
  case "file": {
@@ -137,10 +142,7 @@ program
137
142
  },
138
143
  });
139
144
  const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
140
- const totalFindings = result.counts.critical +
141
- result.counts.high +
142
- result.counts.medium +
143
- result.counts.low;
145
+ const totalFindings = result.counts.critical + result.counts.high + result.counts.medium + result.counts.low;
144
146
  scanSpinner.succeed(`Scanned ${result.filesScanned} files · ${totalFindings} finding${totalFindings === 1 ? "" : "s"} · ${elapsed}s`);
145
147
  printTerminal(result);
146
148
  // Easter egg: score 77 = perfection in disguise
@@ -167,7 +169,9 @@ program
167
169
  await finishRotatingMessages(stopUploadRotate, uploadStarted);
168
170
  if (res.error) {
169
171
  uploadSpinner.fail(`upload failed: ${res.error}`);
170
- if (res.error.includes("401") || res.error.includes("Invalid token") || res.error.includes("expired")) {
172
+ if (res.error.includes("401") ||
173
+ res.error.includes("Invalid token") ||
174
+ res.error.includes("expired")) {
171
175
  writeConfig({ ...cfg, token: undefined });
172
176
  console.info(chalk.yellow("\nYour session expired or your token is invalid. Please run `periderm login` to authenticate again."));
173
177
  }
@@ -190,7 +194,8 @@ program
190
194
  console.info(chalk.white(" 2. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
191
195
  console.info("");
192
196
  if (remainingNum <= 3 && v.plan !== "unlimited") {
193
- console.info(chalk.yellow(`⚠ Almost exhausted! Renew or upgrade at `) + chalk.underline.cyan(`${cfg.apiUrl}/dashboard/billing`));
197
+ console.info(chalk.yellow(`⚠ Almost exhausted! Renew or upgrade at `) +
198
+ chalk.underline.cyan(`${cfg.apiUrl}/dashboard/billing`));
194
199
  }
195
200
  }
196
201
  }
@@ -371,7 +376,9 @@ program
371
376
  console.info(chalk.white(" 1. Scan + upload ") + chalk.hex("#FF4D00")("$ periderm scan"));
372
377
  console.info(chalk.white(" 2. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
373
378
  console.info("");
374
- console.info(chalk.white("Need help? Visit ") + chalk.underline.cyan(`${apiUrl}/docs`) + chalk.white("\n"));
379
+ console.info(chalk.white("Need help? Visit ") +
380
+ chalk.underline.cyan(`${apiUrl}/docs`) +
381
+ chalk.white("\n"));
375
382
  server.close();
376
383
  process.exit(0);
377
384
  }
@@ -384,9 +391,10 @@ program
384
391
  const address = server.address();
385
392
  if (address && typeof address === "object") {
386
393
  const port = address.port;
387
- const loginUrl = `${apiUrl}/dashboard/cli-login?port=${port}&device=${encodeURIComponent(os.hostname())}`;
394
+ const loginUrl = `${apiUrl}/cli-login?port=${port}&device=${encodeURIComponent(os.hostname())}`;
388
395
  console.info(chalk.cyan("Waiting for authentication..."));
389
- console.info(chalk.white("If your browser does not open automatically, click here: ") + chalk.underline.cyan(loginUrl));
396
+ console.info(chalk.white("If your browser does not open automatically, click here: ") +
397
+ chalk.underline.cyan(loginUrl));
390
398
  try {
391
399
  await open(loginUrl);
392
400
  }
@@ -7,7 +7,7 @@ export async function runLocalLighthouse(url) {
7
7
  try {
8
8
  const lighthouse = (await import("lighthouse")).default;
9
9
  const chrome = await chromeLauncher.launch({
10
- chromeFlags: ["--headless", "--no-sandbox", "--disable-gpu"]
10
+ chromeFlags: ["--headless", "--no-sandbox", "--disable-gpu"],
11
11
  });
12
12
  spinner.text = `Running Lighthouse audit on ${url}... This usually takes 10-20 seconds.`;
13
13
  const options = {
@@ -26,14 +26,14 @@ export async function runLocalLighthouse(url) {
26
26
  return {
27
27
  performance_score: Math.round((categories.performance?.score ?? 0) * 100),
28
28
  accessibility_score: Math.round((categories.accessibility?.score ?? 0) * 100),
29
- best_practices_score: Math.round((categories['best-practices']?.score ?? 0) * 100),
29
+ best_practices_score: Math.round((categories["best-practices"]?.score ?? 0) * 100),
30
30
  seo_score: Math.round((categories.seo?.score ?? 0) * 100),
31
31
  metrics: {
32
- fcp: audits['first-contentful-paint'].displayValue,
33
- si: audits['speed-index'].displayValue,
34
- lcp: audits['largest-contentful-paint'].displayValue,
35
- tbt: audits['total-blocking-time'].displayValue,
36
- }
32
+ fcp: audits["first-contentful-paint"].displayValue,
33
+ si: audits["speed-index"].displayValue,
34
+ lcp: audits["largest-contentful-paint"].displayValue,
35
+ tbt: audits["total-blocking-time"].displayValue,
36
+ },
37
37
  };
38
38
  }
39
39
  catch (err) {
@@ -13,7 +13,16 @@ export function renderMarkdown(r) {
13
13
  lines.push("## Scan audit");
14
14
  lines.push("");
15
15
  lines.push(`- **Deterministic checks run:** ${r.meta.totalChecksRun.toLocaleString()} (${r.meta.perFileCheckCount} per source file + repo/SEO/policy passes)`);
16
- lines.push(`- **Privacy policy cross-reference:** ${r.meta.policySignalsChecked} tracking/legal signals compared against your policy pages`);
16
+ if (r.meta.policyPagesFound === undefined) {
17
+ // Back-compat with reports stored before the count existed.
18
+ lines.push(`- **Privacy policy cross-reference:** ${r.meta.policySignalsChecked} tracking/legal signals compared against your policy pages`);
19
+ }
20
+ else if (r.meta.policyPagesFound === 0) {
21
+ lines.push(`- **Privacy policy cross-reference:** no privacy/legal pages found — the mismatch checks don't apply until you add them`);
22
+ }
23
+ else {
24
+ lines.push(`- **Privacy policy cross-reference:** ${r.meta.policySignalsChecked} tracking/legal signal${r.meta.policySignalsChecked === 1 ? "" : "s"} compared against ${r.meta.policyPagesFound} policy page${r.meta.policyPagesFound === 1 ? "" : "s"}`);
25
+ }
17
26
  lines.push(`- **Files analyzed:** ${r.filesScanned}`);
18
27
  if (r.meta.projectProfile) {
19
28
  lines.push(`- **Project profile:** ${r.meta.projectProfile}${r.meta.stacks?.length ? ` (${r.meta.stacks.join(", ")})` : ""}`);
@@ -26,8 +35,8 @@ export function renderMarkdown(r) {
26
35
  lines.push(`| Metric | Score |`);
27
36
  lines.push(`| --- | --- |`);
28
37
  lines.push(`| Launch Confidence | **${r.scores.confidence} / 100** |`);
29
- lines.push(`| Reality Score | **${r.scores.reality} / 100** |`);
30
- lines.push(`| Perceived Performance | **${r.scores.perceived} / 100** |`);
38
+ lines.push(`| Reality Score | **${r.scores.reality} / 100** (robustness & resilience) |`);
39
+ lines.push(`| Perceived Performance | **${r.scores.perceived} / 100** (UX feel & accessibility) |`);
31
40
  lines.push("");
32
41
  lines.push(`| Severity | Count |`);
33
42
  lines.push(`| --- | --- |`);
@@ -40,7 +49,8 @@ export function renderMarkdown(r) {
40
49
  lines.push("No findings. Ship it.");
41
50
  return lines.join("\n");
42
51
  }
43
- const isMobile = r.meta?.projectProfile === "mobile-app" || r.meta?.stacks?.some(s => ["react-native", "expo", "flutter", "swift-ios"].includes(s));
52
+ const isMobile = r.meta?.projectProfile === "mobile-app" ||
53
+ r.meta?.stacks?.some((s) => ["react-native", "expo", "flutter", "swift-ios"].includes(s));
44
54
  if (isMobile) {
45
55
  lines.push("## Mobile Launch Advice");
46
56
  lines.push("");
@@ -13,8 +13,8 @@ export function printTerminal(r) {
13
13
  console.info("");
14
14
  console.info(chalk.bold("Periderm CLI Verdict"));
15
15
  console.info(`Launch Confidence: ${score(r.scores.confidence)}/100`);
16
- console.info(`Reality Score: ${score(r.scores.reality)}/100`);
17
- console.info(`Perceived Performance: ${score(r.scores.perceived)}/100`);
16
+ console.info(`Reality Score: ${score(r.scores.reality)}/100 ${dim("(robustness & resilience)")}`);
17
+ console.info(`Perceived Performance: ${score(r.scores.perceived)}/100 ${dim("(UX feel & accessibility)")}`);
18
18
  console.info("");
19
19
  console.info(hairline);
20
20
  console.info("");
@@ -19,9 +19,7 @@ export function computeScores(findings) {
19
19
  return { confidence, reality, perceived };
20
20
  }
21
21
  export function computeVerdict(c, confidence) {
22
- const verdict = c.critical > 0 ? "blocked"
23
- : confidence < 75 ? "hold"
24
- : "launch_ready";
22
+ const verdict = c.critical > 0 ? "blocked" : confidence < 75 ? "hold" : "launch_ready";
25
23
  return { score: confidence, verdict };
26
24
  }
27
25
  function clamp(n) {
@@ -33,10 +31,7 @@ function weightedSubset(findings, pred) {
33
31
  if (!pred(f))
34
32
  continue;
35
33
  pen +=
36
- f.severity === "critical" ? 20
37
- : f.severity === "high" ? 10
38
- : f.severity === "medium" ? 4
39
- : 1;
34
+ f.severity === "critical" ? 20 : f.severity === "high" ? 10 : f.severity === "medium" ? 4 : 1;
40
35
  }
41
36
  return pen;
42
37
  }
@@ -31,7 +31,7 @@ async function groqJson(token, apiUrl, system, user) {
31
31
  const text = await res.text();
32
32
  throw new Error(`Deep review API error ${res.status}: ${text.slice(0, 200)}`);
33
33
  }
34
- const data = await res.json();
34
+ const data = (await res.json());
35
35
  if (!data.valid)
36
36
  throw new Error(`Deep review failed: ${data.error}`);
37
37
  return data.content ?? "{}";