periderm-cli 0.1.57 → 0.1.60
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/api.js +5 -3
- package/dist/bin.js +3 -2
- package/dist/error-report.js +3 -2
- package/dist/index.js +0 -16
- package/dist/lighthouse.js +2 -3
- package/dist/review/deep.js +17 -10
- package/dist/scanner/checks.js +171 -0
- package/dist/scanner/context-agent.js +6 -2
- package/dist/scanner/project-context.js +27 -8
- package/dist/scanner/repo-checks.js +17 -3
- package/dist/update-notifier.js +8 -2
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function verifyToken(token) {
|
|
|
23
23
|
return (await res.json());
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
return { valid: false, error: e.message
|
|
26
|
+
return { valid: false, error: e instanceof Error ? e.message : "Failed to reach server" };
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
export async function uploadScan(token, result) {
|
|
@@ -55,7 +55,7 @@ export async function uploadScan(token, result) {
|
|
|
55
55
|
return (await res.json());
|
|
56
56
|
}
|
|
57
57
|
catch (e) {
|
|
58
|
-
return { error: e.message
|
|
58
|
+
return { error: e instanceof Error ? e.message : "Network error: failed to reach server" };
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
export async function fetchCloudPolicies(token) {
|
|
@@ -70,7 +70,9 @@ export async function fetchCloudPolicies(token) {
|
|
|
70
70
|
return { global_ignores: [], custom_ai_rules: "" };
|
|
71
71
|
return (await res.json());
|
|
72
72
|
}
|
|
73
|
-
catch {
|
|
73
|
+
catch (e) {
|
|
74
|
+
if (process.env.DEBUG)
|
|
75
|
+
console.error("Error fetching cloud policies:", e instanceof Error ? e.message : String(e));
|
|
74
76
|
return { global_ignores: [], custom_ai_rules: "" };
|
|
75
77
|
}
|
|
76
78
|
}
|
package/dist/bin.js
CHANGED
package/dist/error-report.js
CHANGED
|
@@ -46,8 +46,9 @@ export async function reportCliError(input) {
|
|
|
46
46
|
userEmail = v.email;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
catch {
|
|
50
|
-
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (process.env.DEBUG)
|
|
51
|
+
console.error("Error verifying token during crash report:", err instanceof Error ? err.message : String(err));
|
|
51
52
|
}
|
|
52
53
|
const cfg = readConfig();
|
|
53
54
|
const context = buildContext(input);
|
package/dist/index.js
CHANGED
|
@@ -464,19 +464,3 @@ else {
|
|
|
464
464
|
process.exit(1);
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
|
-
function readLine() {
|
|
468
|
-
return new Promise((resolve) => {
|
|
469
|
-
let data = "";
|
|
470
|
-
process.stdin.setEncoding("utf8");
|
|
471
|
-
const onData = (chunk) => {
|
|
472
|
-
data += chunk;
|
|
473
|
-
if (data.includes("\n")) {
|
|
474
|
-
process.stdin.removeListener("data", onData);
|
|
475
|
-
process.stdin.pause();
|
|
476
|
-
resolve(data.split("\n")[0]);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
process.stdin.on("data", onData);
|
|
480
|
-
process.stdin.resume();
|
|
481
|
-
});
|
|
482
|
-
}
|
package/dist/lighthouse.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./types.d.ts" />
|
|
2
2
|
import * as chromeLauncher from "chrome-launcher";
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
// We use dynamic import for lighthouse because its types and module resolution can be tricky
|
|
5
5
|
export async function runLocalLighthouse(url) {
|
|
6
6
|
const spinner = ora({ text: `Launching Headless Chrome...`, color: "cyan" }).start();
|
|
7
7
|
try {
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
const lighthouse = (await import("lighthouse")).default;
|
|
10
9
|
const chrome = await chromeLauncher.launch({
|
|
11
10
|
chromeFlags: ["--headless", "--no-sandbox", "--disable-gpu"]
|
|
@@ -38,7 +37,7 @@ export async function runLocalLighthouse(url) {
|
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
catch (err) {
|
|
41
|
-
spinner.fail(`Lighthouse audit failed: ${err.message}`);
|
|
40
|
+
spinner.fail(`Lighthouse audit failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
42
41
|
throw err;
|
|
43
42
|
}
|
|
44
43
|
}
|
package/dist/review/deep.js
CHANGED
|
@@ -13,14 +13,20 @@ function stripCodeFences(text) {
|
|
|
13
13
|
return (m?.[1] ?? text).trim();
|
|
14
14
|
}
|
|
15
15
|
async function groqJson(token, apiUrl, system, user) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
let res;
|
|
17
|
+
try {
|
|
18
|
+
res = await fetch(`${apiUrl}/api/public/deep-review`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
"x-periderm-token": token,
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({ system, user }),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new Error(`Network error calling deep review API: ${e instanceof Error ? e.message : String(e)}`);
|
|
29
|
+
}
|
|
24
30
|
if (!res.ok) {
|
|
25
31
|
const text = await res.text();
|
|
26
32
|
throw new Error(`Deep review API error ${res.status}: ${text.slice(0, 200)}`);
|
|
@@ -68,8 +74,9 @@ async function searchFiles(root, query) {
|
|
|
68
74
|
if (hits.length >= 10)
|
|
69
75
|
break;
|
|
70
76
|
}
|
|
71
|
-
catch {
|
|
72
|
-
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (process.env.DEBUG)
|
|
79
|
+
console.error("Error reading file during search:", e instanceof Error ? e.message : String(e));
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
}
|
package/dist/scanner/checks.js
CHANGED
|
@@ -137,6 +137,8 @@ const imgAlt = (source, file, ast) => {
|
|
|
137
137
|
const out = [];
|
|
138
138
|
if (!ast || !/\.(tsx|jsx)$/.test(file))
|
|
139
139
|
return out;
|
|
140
|
+
if (isInternalSurface(file))
|
|
141
|
+
return out;
|
|
140
142
|
traverse(ast, {
|
|
141
143
|
JSXOpeningElement(p) {
|
|
142
144
|
const n = p.node.name;
|
|
@@ -166,6 +168,8 @@ const clickableDiv = (source, file, ast) => {
|
|
|
166
168
|
const out = [];
|
|
167
169
|
if (!ast || !/\.(tsx|jsx)$/.test(file))
|
|
168
170
|
return out;
|
|
171
|
+
if (isInternalSurface(file))
|
|
172
|
+
return out;
|
|
169
173
|
traverse(ast, {
|
|
170
174
|
JSXOpeningElement(p) {
|
|
171
175
|
const n = p.node.name;
|
|
@@ -982,6 +986,170 @@ const heavyLibImport = (source, file) => {
|
|
|
982
986
|
return out;
|
|
983
987
|
};
|
|
984
988
|
// ───────────────────────────────────────────────────────────────────────
|
|
989
|
+
// 29. Missing Error Property Typing Issue
|
|
990
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
991
|
+
const missingErrorTyping = (source, file, ast) => {
|
|
992
|
+
const out = [];
|
|
993
|
+
if (!ast)
|
|
994
|
+
return out;
|
|
995
|
+
traverse(ast, {
|
|
996
|
+
CatchClause(p) {
|
|
997
|
+
if (!p.node.param || p.node.param.type !== "Identifier")
|
|
998
|
+
return;
|
|
999
|
+
const errorName = p.node.param.name;
|
|
1000
|
+
const catchBodySrc = source.slice(p.node.body.start ?? 0, p.node.body.end ?? 0);
|
|
1001
|
+
const propAccessRegex = new RegExp(`\\b${errorName}\\.(message|code|name|stack)\\b`);
|
|
1002
|
+
if (propAccessRegex.test(catchBodySrc)) {
|
|
1003
|
+
// Check if there is a type narrowing guard
|
|
1004
|
+
const hasGuard = new RegExp(`instanceof\\s+Error|typeof\\s+${errorName}\\s*===?\\s*['"]object['"]|${errorName}\\s+is\\s+|as\\s+Error`).test(catchBodySrc) || new RegExp(`\\b${errorName}\\s+instanceof\\b`).test(catchBodySrc) || /Error\s*\(/.test(catchBodySrc) || new RegExp(`isError\\s*\\(\\s*${errorName}\\s*\\)`).test(catchBodySrc);
|
|
1005
|
+
if (!hasGuard) {
|
|
1006
|
+
out.push(mkFinding({
|
|
1007
|
+
id: "missing-error-typing",
|
|
1008
|
+
category: "Data Integrity",
|
|
1009
|
+
severity: "medium",
|
|
1010
|
+
file, line: p.node.loc?.start.line ?? 1,
|
|
1011
|
+
message: `Error property accessed without type narrowing.`,
|
|
1012
|
+
why: "In TypeScript, caught errors are of type `unknown` or `any`. Accessing properties like `.message` directly can crash if the thrown value is a string or null.",
|
|
1013
|
+
fix: "Check if the error is an instance of Error (e.g. `if (e instanceof Error)`) before accessing its properties, or safely cast it.",
|
|
1014
|
+
aiPrompt: `In ${file} near line ${p.node.loc?.start.line ?? 1}, the catch block accesses properties on the caught error without type narrowing. Wrap the property access in an \`if (${errorName} instanceof Error)\` check.`,
|
|
1015
|
+
}));
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
return out;
|
|
1021
|
+
};
|
|
1022
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1023
|
+
// 30. Unused Variables/Imports
|
|
1024
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1025
|
+
const unusedVariablesImports = (source, file, ast) => {
|
|
1026
|
+
const out = [];
|
|
1027
|
+
if (!ast || !/\.(tsx|jsx|ts|js|mjs|cjs)$/.test(file))
|
|
1028
|
+
return out;
|
|
1029
|
+
if (/\.d\.ts$/.test(file))
|
|
1030
|
+
return out;
|
|
1031
|
+
traverse(ast, {
|
|
1032
|
+
Program(p) {
|
|
1033
|
+
for (const [name, binding] of Object.entries(p.scope.bindings)) {
|
|
1034
|
+
if (!binding.referenced && binding.constant && binding.kind !== "param") {
|
|
1035
|
+
if (name.startsWith("_"))
|
|
1036
|
+
continue;
|
|
1037
|
+
if (name === "React")
|
|
1038
|
+
continue; // Ignore React import if unused
|
|
1039
|
+
// Ignore exports
|
|
1040
|
+
if (binding.path.parentPath?.isExportDeclaration() || binding.path.parentPath?.isExportDefaultDeclaration())
|
|
1041
|
+
continue;
|
|
1042
|
+
if (binding.path.isExportDeclaration() || binding.path.isExportDefaultDeclaration())
|
|
1043
|
+
continue;
|
|
1044
|
+
// Ignore type imports and type declarations
|
|
1045
|
+
if (binding.path.parentPath?.isImportDeclaration() && binding.path.parentPath.node.importKind === "type")
|
|
1046
|
+
continue;
|
|
1047
|
+
if (binding.path.isImportSpecifier() && binding.path.node.importKind === "type")
|
|
1048
|
+
continue;
|
|
1049
|
+
if (binding.path.parentPath?.isTSTypeAliasDeclaration() || binding.path.parentPath?.isTSInterfaceDeclaration())
|
|
1050
|
+
continue;
|
|
1051
|
+
// Babel sometimes misses type references, so skip uppercase identifiers (common convention for types/interfaces)
|
|
1052
|
+
if (/^[A-Z]/.test(name))
|
|
1053
|
+
continue;
|
|
1054
|
+
const typeLabel = binding.kind === "module" ? "import" : "variable";
|
|
1055
|
+
out.push(mkFinding({
|
|
1056
|
+
id: `unused-${typeLabel}`,
|
|
1057
|
+
category: "Polish & Embarrassment Risks",
|
|
1058
|
+
severity: "low",
|
|
1059
|
+
file, line: binding.identifier.loc?.start.line ?? 1,
|
|
1060
|
+
message: `Unused ${typeLabel}: '${name}'.`,
|
|
1061
|
+
why: "Unused variables and imports clutter the codebase, increase bundle size, and make code harder to read.",
|
|
1062
|
+
fix: `Remove the unused ${typeLabel}.`,
|
|
1063
|
+
aiPrompt: `In ${file} near line ${binding.identifier.loc?.start.line ?? 1}, remove the unused ${typeLabel} '${name}'.`,
|
|
1064
|
+
}));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
Function(p) {
|
|
1069
|
+
for (const [name, binding] of Object.entries(p.scope.bindings)) {
|
|
1070
|
+
if (!binding.referenced && binding.kind !== "param") {
|
|
1071
|
+
if (name.startsWith("_"))
|
|
1072
|
+
continue;
|
|
1073
|
+
out.push(mkFinding({
|
|
1074
|
+
id: "unused-variable",
|
|
1075
|
+
category: "Polish & Embarrassment Risks",
|
|
1076
|
+
severity: "low",
|
|
1077
|
+
file, line: binding.identifier.loc?.start.line ?? 1,
|
|
1078
|
+
message: `Unused variable: '${name}'.`,
|
|
1079
|
+
why: "Unused variables clutter the codebase and make code harder to read.",
|
|
1080
|
+
fix: "Remove the unused variable.",
|
|
1081
|
+
aiPrompt: `In ${file} near line ${binding.identifier.loc?.start.line ?? 1}, remove the unused variable '${name}'.`,
|
|
1082
|
+
}));
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
return out;
|
|
1088
|
+
};
|
|
1089
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1090
|
+
// 31. Empty links (no accessible name)
|
|
1091
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1092
|
+
const emptyLinkText = (source, file, ast) => {
|
|
1093
|
+
const out = [];
|
|
1094
|
+
if (!ast || !/\.(tsx|jsx)$/.test(file))
|
|
1095
|
+
return out;
|
|
1096
|
+
if (isInternalSurface(file))
|
|
1097
|
+
return out;
|
|
1098
|
+
traverse(ast, {
|
|
1099
|
+
JSXOpeningElement(p) {
|
|
1100
|
+
const n = p.node.name;
|
|
1101
|
+
if (n.type !== "JSXIdentifier" || n.name !== "a")
|
|
1102
|
+
return;
|
|
1103
|
+
const hasAriaLabel = p.node.attributes.some((a) => a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" && (a.name.name === "aria-label" || a.name.name === "aria-labelledby"));
|
|
1104
|
+
if (hasAriaLabel)
|
|
1105
|
+
return;
|
|
1106
|
+
const parent = p.parentPath.node;
|
|
1107
|
+
if (parent.type !== "JSXElement")
|
|
1108
|
+
return;
|
|
1109
|
+
const isSelfClosing = p.node.selfClosing;
|
|
1110
|
+
const hasChildren = parent.children && parent.children.length > 0;
|
|
1111
|
+
let hasTextOrImgWithAlt = false;
|
|
1112
|
+
if (hasChildren) {
|
|
1113
|
+
for (const child of parent.children) {
|
|
1114
|
+
if (child.type === "JSXText" && child.value.trim().length > 0) {
|
|
1115
|
+
hasTextOrImgWithAlt = true;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
if (child.type === "JSXExpressionContainer") {
|
|
1119
|
+
hasTextOrImgWithAlt = true;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
if (child.type === "JSXElement") {
|
|
1123
|
+
const childName = child.openingElement.name;
|
|
1124
|
+
if (childName.type === "JSXIdentifier" && childName.name === "img") {
|
|
1125
|
+
const hasAlt = child.openingElement.attributes.some(a => a.type === "JSXAttribute" && a.name.type === "JSXIdentifier" && a.name.name === "alt" && a.value?.type === "StringLiteral" && a.value.value.trim().length > 0);
|
|
1126
|
+
if (hasAlt)
|
|
1127
|
+
hasTextOrImgWithAlt = true;
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
hasTextOrImgWithAlt = true; // Assuming other elements might have text
|
|
1131
|
+
}
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (isSelfClosing || !hasTextOrImgWithAlt) {
|
|
1137
|
+
out.push(mkFinding({
|
|
1138
|
+
id: "empty-link",
|
|
1139
|
+
category: "Accessibility",
|
|
1140
|
+
severity: "medium",
|
|
1141
|
+
file, line: p.node.loc?.start.line ?? 1,
|
|
1142
|
+
message: "Link (<a>) contains no text content or accessible name.",
|
|
1143
|
+
why: "Screen reader users won't know the purpose of the link. It fails WCAG 2.4.4 (Link Purpose).",
|
|
1144
|
+
fix: "Provide text inside the link, or use aria-label.",
|
|
1145
|
+
aiPrompt: `In ${file} near line ${p.node.loc?.start.line ?? 1}, the <a> tag is empty or contains no accessible text. Add text content or an aria-label attribute.`,
|
|
1146
|
+
}));
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
});
|
|
1150
|
+
return out;
|
|
1151
|
+
};
|
|
1152
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
985
1153
|
// Registry
|
|
986
1154
|
// ───────────────────────────────────────────────────────────────────────
|
|
987
1155
|
const CHECKS = [
|
|
@@ -1002,6 +1170,7 @@ const CHECKS = [
|
|
|
1002
1170
|
unhandledFetch,
|
|
1003
1171
|
unsafeUserAccess,
|
|
1004
1172
|
sourceMaps,
|
|
1173
|
+
emptyLinkText,
|
|
1005
1174
|
unauthAdmin,
|
|
1006
1175
|
missingRateLimit,
|
|
1007
1176
|
idorDataFetch,
|
|
@@ -1014,6 +1183,8 @@ const CHECKS = [
|
|
|
1014
1183
|
sqlStringConcat,
|
|
1015
1184
|
mysqlNoUtf8mb4,
|
|
1016
1185
|
heavyLibImport,
|
|
1186
|
+
missingErrorTyping,
|
|
1187
|
+
unusedVariablesImports,
|
|
1017
1188
|
];
|
|
1018
1189
|
export const PER_FILE_CHECK_COUNT = CHECKS.length;
|
|
1019
1190
|
export function runChecks(source, file, ast) {
|
|
@@ -36,7 +36,9 @@ async function groqJson(apiKey, system, user) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
catch {
|
|
39
|
+
catch (e) {
|
|
40
|
+
if (process.env.DEBUG)
|
|
41
|
+
console.error("Error communicating with backend for triage:", e instanceof Error ? e.message : String(e));
|
|
40
42
|
// Fallback to direct Groq API if backend fails or network error
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -67,7 +69,9 @@ async function groqJson(apiKey, system, user) {
|
|
|
67
69
|
return null;
|
|
68
70
|
return JSON.parse(text);
|
|
69
71
|
}
|
|
70
|
-
catch {
|
|
72
|
+
catch (e) {
|
|
73
|
+
if (process.env.DEBUG)
|
|
74
|
+
console.error("Error communicating with Groq API:", e instanceof Error ? e.message : String(e));
|
|
71
75
|
return null;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -50,7 +50,9 @@ async function readMaybe(p) {
|
|
|
50
50
|
try {
|
|
51
51
|
return await fs.readFile(p, "utf8");
|
|
52
52
|
}
|
|
53
|
-
catch {
|
|
53
|
+
catch (e) {
|
|
54
|
+
if (process.env.DEBUG)
|
|
55
|
+
console.error(`readMaybe failed for ${p}:`, e instanceof Error ? e.message : String(e));
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -62,8 +64,9 @@ async function loadContextFile(root) {
|
|
|
62
64
|
try {
|
|
63
65
|
return JSON.parse(raw);
|
|
64
66
|
}
|
|
65
|
-
catch {
|
|
66
|
-
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (process.env.DEBUG)
|
|
69
|
+
console.error("Failed to parse context file:", e instanceof Error ? e.message : String(e));
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
return null;
|
|
@@ -117,12 +120,24 @@ export async function detectProjectContext(root, files) {
|
|
|
117
120
|
|| relFiles.some((f) => /\.xcodeproj\//i.test(f));
|
|
118
121
|
const hasDart = relFiles.some((f) => f.endsWith(".dart"));
|
|
119
122
|
const hasSwift = relFiles.some((f) => f.endsWith(".swift"));
|
|
120
|
-
|
|
123
|
+
let pkg = {};
|
|
124
|
+
if (pkgRaw) {
|
|
125
|
+
try {
|
|
126
|
+
pkg = JSON.parse(pkgRaw);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
if (process.env.DEBUG)
|
|
130
|
+
console.error(e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
134
|
+
const hasRn = !!deps["react-native"];
|
|
135
|
+
const hasExpoDep = !!deps["expo"];
|
|
121
136
|
if (hasPubspec || hasDart) {
|
|
122
137
|
stacks.push("flutter");
|
|
123
138
|
reasoning.push("Detected Flutter/Dart (pubspec.yaml or .dart files).");
|
|
124
139
|
}
|
|
125
|
-
if (hasAppJson || hasExpo ||
|
|
140
|
+
if (hasAppJson || hasExpo || hasExpoDep) {
|
|
126
141
|
stacks.push("expo");
|
|
127
142
|
reasoning.push("Detected Expo.");
|
|
128
143
|
}
|
|
@@ -134,7 +149,10 @@ export async function detectProjectContext(root, files) {
|
|
|
134
149
|
stacks.push("swift-ios");
|
|
135
150
|
reasoning.push("Detected Swift/iOS.");
|
|
136
151
|
}
|
|
137
|
-
|
|
152
|
+
const isWebJs = [
|
|
153
|
+
"react", "vite", "next", "svelte", "vue", "angular", "astro", "nuxt", "remix", "gatsby", "@tanstack/react-router"
|
|
154
|
+
].some(d => deps[d]);
|
|
155
|
+
if (isWebJs || (!hasRn && !hasExpoDep && !hasPubspec && !hasDart && !hasPackageSwift && !hasSwift)) {
|
|
138
156
|
stacks.push("web-js");
|
|
139
157
|
reasoning.push("Detected web JavaScript/TypeScript stack.");
|
|
140
158
|
}
|
|
@@ -227,8 +245,9 @@ export async function detectFaviconPresent(root, files) {
|
|
|
227
245
|
return true;
|
|
228
246
|
}
|
|
229
247
|
}
|
|
230
|
-
catch {
|
|
231
|
-
|
|
248
|
+
catch (e) {
|
|
249
|
+
if (process.env.DEBUG)
|
|
250
|
+
console.error("Error reading public directory:", e instanceof Error ? e.message : String(e));
|
|
232
251
|
}
|
|
233
252
|
for (const abs of files) {
|
|
234
253
|
const content = await readMaybe(abs);
|
|
@@ -68,7 +68,18 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
68
68
|
}
|
|
69
69
|
// public dir favicon — any rel=icon, manifest icons, or public/*icon* file counts
|
|
70
70
|
const pkgRaw = await readMaybe(path.join(root, "package.json"));
|
|
71
|
-
|
|
71
|
+
let looksLikeWeb = false;
|
|
72
|
+
if (pkgRaw) {
|
|
73
|
+
try {
|
|
74
|
+
const parsedPkg = JSON.parse(pkgRaw);
|
|
75
|
+
const combinedDeps = { ...parsedPkg.dependencies, ...parsedPkg.devDependencies };
|
|
76
|
+
looksLikeWeb = ["react", "vite", "next", "svelte", "vue", "astro", "nuxt", "remix"].some(d => combinedDeps[d]);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
if (process.env.DEBUG)
|
|
80
|
+
console.error("Error parsing package.json:", e instanceof Error ? e.message : String(e));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
72
83
|
const skipLegalGlobally = ctx?.skipCategories.has("Legal & Compliance") ||
|
|
73
84
|
ctx?.profile === "admin-only" ||
|
|
74
85
|
ctx?.profile === "internal-tool";
|
|
@@ -210,7 +221,10 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
210
221
|
try {
|
|
211
222
|
pkg = JSON.parse(pkgRaw);
|
|
212
223
|
}
|
|
213
|
-
catch {
|
|
224
|
+
catch (e) {
|
|
225
|
+
if (process.env.DEBUG)
|
|
226
|
+
console.error(e);
|
|
227
|
+
}
|
|
214
228
|
const runtimeDeps = Object.keys(pkg.dependencies ?? {});
|
|
215
229
|
const allDeps = [...runtimeDeps, ...Object.keys(pkg.devDependencies ?? {})];
|
|
216
230
|
// Build one combined haystack of source imports so we can answer
|
|
@@ -233,7 +247,7 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
233
247
|
{
|
|
234
248
|
name: "HTTP clients",
|
|
235
249
|
members: ["axios", "ky", "got", "superagent", "node-fetch"],
|
|
236
|
-
recommend: "the platform fetch
|
|
250
|
+
recommend: "the built-in platform fetch covers 95% of cases. Keep at most one wrapper.",
|
|
237
251
|
},
|
|
238
252
|
{
|
|
239
253
|
name: "state managers",
|
package/dist/update-notifier.js
CHANGED
|
@@ -21,9 +21,13 @@ export async function checkUpdate() {
|
|
|
21
21
|
const timeoutId = setTimeout(() => controller.abort(), 3000);
|
|
22
22
|
const res = await fetch(`https://registry.npmjs.org/${name}/latest`, {
|
|
23
23
|
signal: controller.signal,
|
|
24
|
+
}).catch((err) => {
|
|
25
|
+
if (process.env.DEBUG)
|
|
26
|
+
console.error("Fetch error:", err);
|
|
27
|
+
return null;
|
|
24
28
|
});
|
|
25
29
|
clearTimeout(timeoutId);
|
|
26
|
-
if (!res.ok)
|
|
30
|
+
if (!res || !res.ok)
|
|
27
31
|
return null;
|
|
28
32
|
const data = await res.json();
|
|
29
33
|
const latestVersion = data.version;
|
|
@@ -52,8 +56,10 @@ export async function checkUpdate() {
|
|
|
52
56
|
╰${"─".repeat(width)}╯
|
|
53
57
|
`;
|
|
54
58
|
}
|
|
55
|
-
catch {
|
|
59
|
+
catch (err) {
|
|
56
60
|
// Ignore any network/parsing errors silently
|
|
61
|
+
if (process.env.DEBUG)
|
|
62
|
+
console.error("Update check failed:", err instanceof Error ? err.message : String(err));
|
|
57
63
|
return null;
|
|
58
64
|
}
|
|
59
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "periderm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"description": "Periderm CLI: A pre-launch checklist to catch user-losing bugs, legal liabilities, revenue leaks, runaway cloud bills and so many more before you ship.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"preferGlobal": true,
|