@schemasentry/cli 0.4.0 → 0.6.0

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.
Files changed (3) hide show
  1. package/README.md +138 -12
  2. package/dist/index.js +1836 -1182
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -9,6 +9,17 @@ pnpm add -D @schemasentry/cli
9
9
  npm install -D @schemasentry/cli
10
10
  ```
11
11
 
12
+ ## Important: Zero False Positives!
13
+
14
+ Schema Sentry v0.6.0+ validates **actual built HTML output**, not just JSON configuration files. This eliminates the false positives common in other tools.
15
+
16
+ **The workflow:**
17
+ 1. `init` → Create starter files
18
+ 2. `scaffold` → See what code to add (shows copy-paste examples!)
19
+ 3. Add Schema components to your pages
20
+ 4. `next build` → Build your app
21
+ 5. `validate` → Check actual HTML (catches missing schema!)
22
+
12
23
  ## Commands
13
24
 
14
25
  ### `init`
@@ -25,14 +36,37 @@ With route scanning:
25
36
  pnpm schemasentry init --scan
26
37
  ```
27
38
 
28
- ### `validate`
39
+ ### `validate` (Reality Check)
40
+
41
+ ⚠️ **BREAKING CHANGE in v0.6.0**: Now validates actual HTML output instead of JSON files!
42
+
43
+ Validate schema by checking built HTML output:
44
+
45
+ ```bash
46
+ # Build your app first
47
+ next build
48
+
49
+ # Then validate (catches missing schema with zero false positives!)
50
+ pnpm schemasentry validate \
51
+ --manifest ./schema-sentry.manifest.json \
52
+ --root ./.next/server/app
53
+ ```
29
54
 
30
- Check schema coverage and validation:
55
+ Check static export:
31
56
 
32
57
  ```bash
33
- pnpm schemasentry validate --manifest ./schema-sentry.manifest.json --data ./schema-sentry.data.json
58
+ pnpm schemasentry validate \
59
+ --manifest ./schema-sentry.manifest.json \
60
+ --root ./out
34
61
  ```
35
62
 
63
+ **What it validates:**
64
+ - ✅ Routes with Schema components in source code
65
+ - ✅ Actual JSON-LD rendered in built HTML
66
+ - ✅ Schema types match manifest expectations
67
+ - ❌ Ghost routes (manifest expects schema but no component in source)
68
+ - ❌ Missing schema (component exists but not in HTML - forgot to build?)
69
+
36
70
  With GitHub annotations:
37
71
 
38
72
  ```bash
@@ -41,24 +75,75 @@ pnpm schemasentry validate --annotations github
41
75
 
42
76
  ### `audit`
43
77
 
44
- Analyze site-wide schema health:
78
+ Analyze site-wide schema health and detect ghost routes:
45
79
 
46
80
  ```bash
47
- pnpm schemasentry audit --data ./schema-sentry.data.json --manifest ./schema-sentry.manifest.json
81
+ pnpm schemasentry audit \
82
+ --manifest ./schema-sentry.manifest.json \
83
+ --root ./app
48
84
  ```
49
85
 
50
- With HTML report:
86
+ **Ghost routes** are routes in your manifest that don't have Schema components in the source code. They cause false positives in other tools!
87
+
88
+ With source scanning:
51
89
 
52
90
  ```bash
53
- pnpm schemasentry audit \
54
- --data ./schema-sentry.data.json \
55
- --format html \
56
- --output ./report.html
91
+ pnpm schemasentry audit --manifest ./schema-sentry.manifest.json --root ./app --scan
92
+ ```
93
+
94
+ ### `scaffold`
95
+
96
+ See what schema code you need to add to your pages (shows copy-paste examples):
97
+
98
+ ```bash
99
+ pnpm schemasentry scaffold --root ./app
57
100
  ```
58
101
 
102
+ Example output:
103
+ ```
104
+ 📄 /blog/[slug]
105
+ File: app/blog/[slug]/page.tsx
106
+ Types: BlogPosting
107
+
108
+ Add this code to your page:
109
+ ─────────────────────────────────────────
110
+ import { Schema, BlogPosting } from "@schemasentry/next";
111
+
112
+ const blogPosting = BlogPosting({
113
+ headline: "Blog Post Title",
114
+ authorName: "Author Name",
115
+ datePublished: "2026-02-12",
116
+ url: "https://yoursite.com/blog/[slug]"
117
+ });
118
+
119
+ export default function Page() {
120
+ return (
121
+ <>
122
+ <Schema data={[blogPosting]} />
123
+ {/* Your existing content */}
124
+ </>
125
+ );
126
+ }
127
+ ─────────────────────────────────────────
128
+ ```
129
+
130
+ Apply scaffolded schema to JSON files:
131
+
132
+ ```bash
133
+ pnpm schemasentry scaffold --root ./app --write
134
+ ```
135
+
136
+ **Pattern-based auto-detection** infers schema types from URL patterns:
137
+ - `/blog/*` → BlogPosting
138
+ - `/products/*` → Product
139
+ - `/faq` → FAQPage
140
+ - `/events/*` → Event
141
+ - `/howto/*` → HowTo
142
+ - and more...
143
+
59
144
  ### `collect`
60
145
 
61
- Collect JSON-LD blocks from built HTML output and emit schema data JSON:
146
+ Collect JSON-LD blocks from built HTML output:
62
147
 
63
148
  ```bash
64
149
  pnpm schemasentry collect --root ./out --output ./schema-sentry.data.json
@@ -88,12 +173,53 @@ pnpm schemasentry collect \
88
173
  | `--format json\|html` | Output format |
89
174
  | `--annotations none\|github` | CI annotations |
90
175
  | `-o, --output <path>` | Write output to file |
91
- | `--root <path>` | Root directory to scan for HTML output (`collect`) |
176
+ | `--root <path>` | Root directory (built output for validate/collect, app dir for scaffold/audit) |
177
+ | `--app-dir <path>` | Path to Next.js app directory (default: ./app) |
92
178
  | `--routes <routes...>` | Collect only specific routes (`collect`) |
93
179
  | `--strict-routes` | Fail when any route passed to `--routes` is missing (`collect`) |
94
180
  | `--check` | Compare collected output with existing data and fail on drift (`collect`) |
181
+ | `--write` | Apply scaffolded changes to files (`scaffold`) |
182
+ | `--force` | Skip confirmation prompts (`scaffold`) |
95
183
  | `--recommended / --no-recommended` | Enable recommended field checks |
96
184
 
185
+ ## CI/CD Example
186
+
187
+ ```yaml
188
+ # .github/workflows/schema-check.yml
189
+ name: Schema Check
190
+
191
+ on: [push, pull_request]
192
+
193
+ jobs:
194
+ validate:
195
+ runs-on: ubuntu-latest
196
+ steps:
197
+ - uses: actions/checkout@v3
198
+ - uses: pnpm/action-setup@v2
199
+ - run: pnpm install
200
+ - run: pnpm build
201
+ - run: pnpm schemasentry validate \
202
+ --manifest ./schema-sentry.manifest.json \
203
+ --root ./.next/server/app \
204
+ --annotations github
205
+ ```
206
+
207
+ ## Migration from v0.5.0
208
+
209
+ **OLD (v0.5.0 - JSON validation - FALSE POSITIVES):**
210
+ ```bash
211
+ schemasentry validate --manifest ./manifest.json --data ./data.json
212
+ ```
213
+
214
+ **NEW (v0.6.0 - Reality check - NO FALSE POSITIVES):**
215
+ ```bash
216
+ # 1. Build your app first
217
+ next build
218
+
219
+ # 2. Validate actual HTML
220
+ schemasentry validate --manifest ./manifest.json --root ./.next/server/app
221
+ ```
222
+
97
223
  ## Documentation
98
224
 
99
225
  See [Schema Sentry Docs](https://github.com/arindamdawn/schema-sentry#readme)