frontend-guardian 0.1.16 → 0.1.18
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 +9 -31
- package/dist/cli.js +3 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
Scan engine for Frontend Guardian.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
What is Frontend Guardian? It helps frontend teams keep UIs consistent. After you ship, spacing, borders, colors, and components often drift. This tool scans your code (Tailwind, JSX/TSX) and flags inconsistent spacing, arbitrary colors, mixed border-radius, duplicate components, and similar issues so you can fix them before they pile up.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use this package only if you want to run the scanner from your own Node code (programmatic use).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npx frontend-guardian . # scan current dir
|
|
9
|
-
npx frontend-guardian ./src # scan ./src
|
|
10
|
-
npx frontend-guardian . --fail-on-score 70 # exit 1 if score < 70 (for CI)
|
|
11
|
-
npx frontend-guardian . --json # output JSON
|
|
12
|
-
npx frontend-guardian . --suggest # AI fix suggestions (hosted API or GEMINI_API_KEY)
|
|
13
|
-
npx frontend-guardian init # add .github/workflows/frontend-guardian.yml to repo
|
|
14
|
-
```
|
|
7
|
+
Most users: run the CLI instead (no install):
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
npx frontend-guardian .
|
|
10
|
+
npx frontend-guardian init # add GitHub Actions workflow to your repo
|
|
11
|
+
npx frontend-guardian . --suggest # AI fix suggestions (hosted API or GEMINI_API_KEY)
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
pnpm run build:packages
|
|
20
|
-
pnpm cli .
|
|
21
|
-
# or
|
|
22
|
-
node packages/cli/dist/cli.js .
|
|
23
|
-
```
|
|
13
|
+
Install (optional) — only if you're embedding the scanner in your app:
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
From repo root:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
pnpm run build:packages
|
|
31
|
-
cd packages/core && npm publish --access public
|
|
32
|
-
cd packages/cli && npm publish --access public
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Output
|
|
36
|
-
|
|
37
|
-
Score (0–100), warnings (spacing, radius, colors, buttons, unused imports), duplicate components.
|
|
15
|
+
npm i @justinmoto/frontend-guardian-core
|
package/dist/cli.js
CHANGED
|
@@ -351,7 +351,7 @@ const DEFAULT_SUGGEST_API = "https://frontend-guardian.vercel.app/api/suggest";
|
|
|
351
351
|
async function getGeminiSuggestion(apiKey, issueTitle, detected) {
|
|
352
352
|
const ai = new GoogleGenAI({ apiKey });
|
|
353
353
|
const prompt = `Frontend Guardian found this issue: "${issueTitle}". Detected: ${detected.slice(0, 500)}. Give a brief concrete fix suggestion in 1-2 sentences. No preamble.`;
|
|
354
|
-
const res = await ai.models.generateContent({ model: "gemini-
|
|
354
|
+
const res = await ai.models.generateContent({ model: "gemini-1.5-flash", contents: prompt });
|
|
355
355
|
const text = res.text;
|
|
356
356
|
return (text ?? "").trim();
|
|
357
357
|
}
|
|
@@ -473,11 +473,8 @@ async function main() {
|
|
|
473
473
|
}
|
|
474
474
|
spinner.succeed("Done.");
|
|
475
475
|
}
|
|
476
|
-
catch
|
|
477
|
-
spinner.fail("AI
|
|
478
|
-
if (!apiKey)
|
|
479
|
-
console.error(chalk.yellow(" (Hosted API may be down. Set GEMINI_API_KEY to use your own key.)"));
|
|
480
|
-
console.error(chalk.red(e instanceof Error ? e.message : String(e)));
|
|
476
|
+
catch {
|
|
477
|
+
spinner.fail("AI suggestions not available at the moment.");
|
|
481
478
|
}
|
|
482
479
|
}
|
|
483
480
|
if (failOnScore != null && result.score < failOnScore) {
|