periderm-cli 0.1.15 → 0.1.17

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,13 +1,23 @@
1
- # periderm
1
+ # periderm-cli
2
2
 
3
- A pre-launch checklist for every project.
3
+ A pre-launch checklist for every JavaScript and TypeScript project.
4
+
5
+ Scan **`.js`**, **`.jsx`**, **`.ts`**, and **`.tsx`** codebases (plus `.mjs` / `.cjs`) before you ship.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g periderm-cli
11
+ ```
12
+
13
+ ## Quick start
4
14
 
5
15
  ```bash
6
- periderm scan # scan current directory, print verdict, write .periderm/last-report.md
7
- periderm scan --upload # also push to dashboard
8
- periderm watch # rerun on file change
9
- periderm login # authenticate the CLI
10
- periderm whoami # show current token + plan
16
+ periderm login # authenticate once
17
+ periderm scan # scan + upload to your dashboard
18
+ periderm scan --local-only # local report only, no upload
19
+ periderm watch # rerun on file change
20
+ periderm whoami # show current token + plan
11
21
  ```
12
22
 
13
- See full install + usage at the project `/docs` page.
23
+ Full docs: [periderm-cli.vercel.app/docs](https://periderm-cli.vercel.app/docs)
@@ -0,0 +1,79 @@
1
+ import os from "node:os";
2
+ import { readConfig } from "./config.js";
3
+ import { verifyToken } from "./api.js";
4
+ const FORMSPREE_URL = "https://formspree.io/f/mqakppnn";
5
+ function buildContext(input) {
6
+ const cfg = readConfig();
7
+ return {
8
+ source: input.source,
9
+ where: input.where ?? "periderm-cli",
10
+ command: input.command ?? (process.argv.slice(2).join(" ") || "unknown"),
11
+ cwd: input.cwd ?? process.cwd(),
12
+ node: input.nodeVersion ?? process.version,
13
+ platform: `${os.platform()} ${os.release()}`,
14
+ hostname: os.hostname(),
15
+ apiUrl: cfg.apiUrl,
16
+ cause: input.cause,
17
+ ...input.extra,
18
+ };
19
+ }
20
+ function formatFormspreeBody(input, userEmail) {
21
+ const ctx = buildContext(input);
22
+ const lines = [
23
+ `Periderm CLI Error Report`,
24
+ ``,
25
+ `What: ${input.message}`,
26
+ input.cause ? `Cause: ${input.cause}` : null,
27
+ `Where: ${ctx.where}`,
28
+ `How: command \`${ctx.command}\` in ${ctx.cwd}`,
29
+ `Platform: ${ctx.platform} · Node ${ctx.node}`,
30
+ `API: ${ctx.apiUrl}`,
31
+ userEmail !== "unknown" ? `User: ${userEmail}` : null,
32
+ input.stack ? `\nStack trace:\n${input.stack}` : null,
33
+ Object.keys(input.extra ?? {}).length
34
+ ? `\nExtra:\n${JSON.stringify(input.extra, null, 2)}`
35
+ : null,
36
+ ].filter(Boolean);
37
+ return lines.join("\n");
38
+ }
39
+ export async function reportCliError(input) {
40
+ let userEmail = "unknown";
41
+ try {
42
+ const cfg = readConfig();
43
+ if (cfg.token) {
44
+ const v = await verifyToken(cfg.token);
45
+ if (v.valid && v.email)
46
+ userEmail = v.email;
47
+ }
48
+ }
49
+ catch {
50
+ /* ignore during crash reporting */
51
+ }
52
+ const cfg = readConfig();
53
+ const context = buildContext(input);
54
+ const body = formatFormspreeBody(input, userEmail);
55
+ const tasks = [
56
+ fetch(FORMSPREE_URL, {
57
+ method: "POST",
58
+ headers: { Accept: "application/json", "Content-Type": "application/json" },
59
+ body: JSON.stringify({
60
+ name: "Periderm CLI Error Reporter",
61
+ _replyto: userEmail === "unknown" ? "princejaphethjj@gmail.com" : userEmail,
62
+ message: body,
63
+ }),
64
+ }).catch(() => undefined),
65
+ fetch(`${cfg.apiUrl}/api/public/report-error`, {
66
+ method: "POST",
67
+ headers: { Accept: "application/json", "Content-Type": "application/json" },
68
+ body: JSON.stringify({
69
+ source: input.source,
70
+ message: input.message,
71
+ stack: input.stack,
72
+ user_email: userEmail === "unknown" ? undefined : userEmail,
73
+ url: `cli://${context.command}`,
74
+ context,
75
+ }),
76
+ }).catch(() => undefined),
77
+ ];
78
+ await Promise.allSettled(tasks);
79
+ }
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import ora from "ora";
14
14
  import { PERIDERM_ASCII } from "./constants.js";
15
15
  import { PRE_SCAN_MESSAGES, UPLOAD_MESSAGES, startRotatingMessages, finishRotatingMessages } from "./loading-messages.js";
16
16
  import { formatScanPath } from "./scanner/progress.js";
17
+ import { reportCliError } from "./error-report.js";
17
18
  function requireAuth() {
18
19
  console.info("");
19
20
  console.info(chalk.bold.hex("#FF4D00")("▸_ Periderm CLI"));
@@ -29,7 +30,7 @@ const program = new Command();
29
30
  program
30
31
  .name("periderm")
31
32
  .description("A pre-launch checklist.")
32
- .version("0.1.0");
33
+ .version("0.1.17");
33
34
  // Easter egg: `periderm bless` — hidden, undocumented
34
35
  program
35
36
  .command("bless", { hidden: true })
@@ -56,7 +57,7 @@ program
56
57
  program
57
58
  .command("scan")
58
59
  .description("Scan the current directory and write a markdown report.")
59
- .option("--upload", "Upload the scan to your Periderm dashboard")
60
+ .option("--local-only", "Scan locally without uploading to your Periderm dashboard")
60
61
  .option("--cwd <dir>", "Directory to scan", process.cwd())
61
62
  .action(async (opts) => {
62
63
  const root = path.resolve(opts.cwd);
@@ -142,7 +143,7 @@ program
142
143
  result.counts.low;
143
144
  scanSpinner.succeed(`Scanned ${result.filesScanned} files · ${totalFindings} finding${totalFindings === 1 ? "" : "s"} · ${elapsed}s`);
144
145
  printTerminal(result);
145
- // 🥚 Easter egg: score 77 = perfection in disguise
146
+ // Easter egg: score 77 = perfection in disguise
146
147
  if (result.score === 77) {
147
148
  console.info("");
148
149
  console.info(chalk.dim(" ✦ " + Buffer.from("SmVzdXMgSXMgTG9yZA==", "base64").toString("utf8") + " ✦"));
@@ -152,7 +153,7 @@ program
152
153
  await fs.mkdir(outDir, { recursive: true });
153
154
  await fs.writeFile(path.join(outDir, "last-report.md"), result.markdown, "utf8");
154
155
  await fs.writeFile(path.join(outDir, "last-report.json"), JSON.stringify(result, null, 2), "utf8");
155
- if (opts.upload) {
156
+ if (!opts.localOnly) {
156
157
  const cfg = readConfig();
157
158
  if (!cfg.token) {
158
159
  console.info(chalk.yellow("no token configured — run `periderm login` first to sync to dashboard."));
@@ -353,9 +354,9 @@ program
353
354
  console.info(chalk.bold.white("Quota : ") + chalk.yellow(`${formatQuota} scans`));
354
355
  console.info("");
355
356
  console.info(chalk.bold.white("[Next Steps]"));
356
- console.info(chalk.white(" 1. Local scan ") + chalk.hex("#FF4D00")("$ periderm scan"));
357
- console.info(chalk.white(" 2. Cloud upload ") + chalk.hex("#FF4D00")("$ periderm scan --upload"));
358
- console.info(chalk.white(" 3. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
357
+ console.info(chalk.white(" 1. Scan + upload ") + chalk.hex("#FF4D00")("$ periderm scan"));
358
+ console.info(chalk.white(" 2. Local only ") + chalk.hex("#FF4D00")("$ periderm scan --local-only"));
359
+ console.info(chalk.white(" 3. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
359
360
  console.info("");
360
361
  console.info(chalk.white("Need help? Visit ") + chalk.underline.cyan(`${apiUrl}/docs`) + chalk.white("\n"));
361
362
  server.close();
@@ -428,35 +429,14 @@ if (process.argv.length === 2) {
428
429
  else {
429
430
  program.parseAsync().catch(async (e) => {
430
431
  console.error(e);
431
- try {
432
- const formData = new FormData();
433
- formData.append("name", "Periderm CLI Crash Reporter");
434
- let userEmail = "princejaphethjj@gmail.com";
435
- try {
436
- const cfg = readConfig();
437
- if (cfg.token) {
438
- const v = await verifyToken(cfg.token);
439
- if (v.valid && v.email) {
440
- userEmail = v.email;
441
- }
442
- }
443
- }
444
- catch {
445
- // ignore token verification errors during crash
446
- }
447
- formData.append("_replyto", userEmail);
448
- const marker = `\n\n---\n[System Info: Sent from Periderm CLI]\n[User Email: ${userEmail === "princejaphethjj@gmail.com" ? "Unknown" : userEmail}]`;
449
- const errMsg = e instanceof Error ? `${e.message}\n${e.stack}` : String(e);
450
- formData.append("message", `CLI Crash:\n\n${errMsg}${marker}`);
451
- await fetch("https://formspree.io/f/mqakppnn", {
452
- method: "POST",
453
- body: formData,
454
- headers: { Accept: "application/json" }
455
- });
456
- }
457
- catch (err) {
458
- // silently fail
459
- }
432
+ const err = e instanceof Error ? e : new Error(String(e));
433
+ await reportCliError({
434
+ source: "cli",
435
+ message: err.message,
436
+ stack: err.stack,
437
+ cause: err.cause instanceof Error ? err.cause.message : err.cause ? String(err.cause) : undefined,
438
+ where: "periderm-cli unhandled",
439
+ });
460
440
  process.exit(1);
461
441
  });
462
442
  }
@@ -108,7 +108,7 @@ export function renderMarkdown(r) {
108
108
  lines.push(`Fix them in priority order. For each finding, open the listed file, apply the Exact fix, and keep the change minimal.`);
109
109
  lines.push("```");
110
110
  lines.push("");
111
- // 🥚 Hidden watermark — only visible in raw .md source
111
+ // Hidden watermark — only visible in raw .md source
112
112
  lines.push("<!-- ✞ Jesus Is Lord ✞ — Philippians 2:10-11 -->");
113
113
  return lines.join("\n");
114
114
  }
@@ -143,6 +143,7 @@ Rules: max 5 new findings, be specific, cite files, no hallucinated files.${orgR
143
143
  : ["No additional findings beyond the static scan."]),
144
144
  "",
145
145
  `_Agent tools used: ${toolLog.length ? toolLog.join(", ") : "none"}_`,
146
+ "<!-- ✞ Jesus Is Lord ✞ -->",
146
147
  ].join("\n");
147
148
  return { markdown: md, findings };
148
149
  }
@@ -1,22 +1,55 @@
1
1
  import { parse } from "@babel/parser";
2
- export function parseSource(source, filename) {
2
+ import path from "node:path";
3
+ const PLUGINS = [
4
+ "typescript",
5
+ "jsx",
6
+ "decorators-legacy",
7
+ "topLevelAwait",
8
+ "importMeta",
9
+ "classProperties",
10
+ "classPrivateProperties",
11
+ "classPrivateMethods",
12
+ "dynamicImport",
13
+ "optionalChaining",
14
+ "nullishCoalescingOperator",
15
+ ];
16
+ function sourceTypeFor(filename) {
17
+ const ext = path.extname(filename).toLowerCase();
18
+ if (ext === ".cjs")
19
+ return "script";
20
+ if (ext === ".mjs" || ext === ".ts" || ext === ".tsx")
21
+ return "module";
22
+ return "unambiguous";
23
+ }
24
+ function tryParse(source, filename, sourceType) {
3
25
  try {
4
26
  return parse(source, {
5
- sourceType: "module",
27
+ sourceType,
6
28
  sourceFilename: filename,
7
29
  allowImportExportEverywhere: true,
8
30
  allowReturnOutsideFunction: true,
9
31
  errorRecovery: true,
10
- plugins: [
11
- "typescript",
12
- "jsx",
13
- "decorators-legacy",
14
- "topLevelAwait",
15
- "importMeta",
16
- ],
32
+ plugins: [...PLUGINS],
17
33
  });
18
34
  }
19
35
  catch {
20
36
  return null;
21
37
  }
22
38
  }
39
+ export function parseSource(source, filename) {
40
+ const preferred = sourceTypeFor(filename);
41
+ const attempts = [preferred];
42
+ if (preferred !== "module")
43
+ attempts.push("module");
44
+ if (preferred !== "script")
45
+ attempts.push("script");
46
+ for (const sourceType of attempts) {
47
+ const ast = tryParse(source, filename, sourceType);
48
+ if (ast)
49
+ return ast;
50
+ }
51
+ return null;
52
+ }
53
+ export function isSupportedSourceFile(filename) {
54
+ return /\.(tsx?|jsx?|mjs|cjs)$/i.test(filename);
55
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "periderm-cli",
3
- "version": "0.1.15",
4
- "description": "A pre-launch checklist for your codebase.",
3
+ "version": "0.1.17",
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": {
7
7
  "periderm": "./dist/bin.js"
@@ -10,6 +10,32 @@
10
10
  "dist",
11
11
  "README.md"
12
12
  ],
13
+ "keywords": [
14
+ "cli",
15
+ "code-quality",
16
+ "pre-launch",
17
+ "security",
18
+ "scanning",
19
+ "javascript",
20
+ "typescript",
21
+ "jsx",
22
+ "tsx",
23
+ "react",
24
+ "launch-checklist",
25
+ "static-analysis",
26
+ "code-review"
27
+ ],
28
+ "homepage": "https://periderm-cli.vercel.app",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/Prince-Japheth/LaunchGuard.git",
32
+ "directory": "packages/cli"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/Prince-Japheth/LaunchGuard/issues"
36
+ },
37
+ "author": "Periderm",
38
+ "license": "MIT",
13
39
  "scripts": {
14
40
  "build": "tsc -p tsconfig.json && chmod +x dist/bin.js",
15
41
  "postpublish": "cd ../../ && tsx --env-file=.env scripts/broadcast-update.ts",