@schemasentry/cli 0.5.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 +135 -45
  2. package/dist/index.js +1654 -1288
  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,96 +36,136 @@ With route scanning:
25
36
  pnpm schemasentry init --scan
26
37
  ```
27
38
 
28
- ### `validate`
39
+ ### `validate` (Reality Check)
29
40
 
30
- Check schema coverage and validation:
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:
31
44
 
32
45
  ```bash
33
- pnpm schemasentry validate --manifest ./schema-sentry.manifest.json --data ./schema-sentry.data.json
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
34
53
  ```
35
54
 
36
- With GitHub annotations:
55
+ Check static export:
37
56
 
38
57
  ```bash
39
- pnpm schemasentry validate --annotations github
58
+ pnpm schemasentry validate \
59
+ --manifest ./schema-sentry.manifest.json \
60
+ --root ./out
40
61
  ```
41
62
 
42
- ### `audit`
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?)
43
69
 
44
- Analyze site-wide schema health:
70
+ With GitHub annotations:
45
71
 
46
72
  ```bash
47
- pnpm schemasentry audit --data ./schema-sentry.data.json --manifest ./schema-sentry.manifest.json
73
+ pnpm schemasentry validate --annotations github
48
74
  ```
49
75
 
50
- With HTML report:
76
+ ### `audit`
77
+
78
+ Analyze site-wide schema health and detect ghost routes:
51
79
 
52
80
  ```bash
53
81
  pnpm schemasentry audit \
54
- --data ./schema-sentry.data.json \
55
- --format html \
56
- --output ./report.html
82
+ --manifest ./schema-sentry.manifest.json \
83
+ --root ./app
57
84
  ```
58
85
 
59
- ### `collect`
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!
60
87
 
61
- Collect JSON-LD blocks from built HTML output and emit schema data JSON:
88
+ With source scanning:
62
89
 
63
90
  ```bash
64
- pnpm schemasentry collect --root ./out --output ./schema-sentry.data.json
91
+ pnpm schemasentry audit --manifest ./schema-sentry.manifest.json --root ./app --scan
65
92
  ```
66
93
 
67
- Check collected output against your current data file (CI drift guard):
68
-
69
- ```bash
70
- pnpm schemasentry collect --root ./out --check --data ./schema-sentry.data.json
71
- ```
94
+ ### `scaffold`
72
95
 
73
- Collect and compare only selected routes, failing if any required route is missing:
96
+ See what schema code you need to add to your pages (shows copy-paste examples):
74
97
 
75
98
  ```bash
76
- pnpm schemasentry collect \
77
- --root ./out \
78
- --routes / /blog /faq \
79
- --strict-routes \
80
- --check \
81
- --data ./schema-sentry.data.json
99
+ pnpm schemasentry scaffold --root ./app
82
100
  ```
83
101
 
84
- ### `scaffold`
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
+ ```
85
129
 
86
- Auto-generate schema stubs for routes without schema (dry-run by default):
130
+ Apply scaffolded schema to JSON files:
87
131
 
88
132
  ```bash
89
- pnpm schemasentry scaffold --manifest ./schema-sentry.manifest.json --data ./schema-sentry.data.json
133
+ pnpm schemasentry scaffold --root ./app --write
90
134
  ```
91
135
 
92
- Preview what would be generated without writing files:
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
+
144
+ ### `collect`
145
+
146
+ Collect JSON-LD blocks from built HTML output:
93
147
 
94
148
  ```bash
95
- pnpm schemasentry scaffold
149
+ pnpm schemasentry collect --root ./out --output ./schema-sentry.data.json
96
150
  ```
97
151
 
98
- Apply scaffolded schema to your files:
152
+ Check collected output against your current data file (CI drift guard):
99
153
 
100
154
  ```bash
101
- pnpm schemasentry scaffold --write
155
+ pnpm schemasentry collect --root ./out --check --data ./schema-sentry.data.json
102
156
  ```
103
157
 
104
- Skip confirmation prompts:
158
+ Collect and compare only selected routes, failing if any required route is missing:
105
159
 
106
160
  ```bash
107
- pnpm schemasentry scaffold --write --force
161
+ pnpm schemasentry collect \
162
+ --root ./out \
163
+ --routes / /blog /faq \
164
+ --strict-routes \
165
+ --check \
166
+ --data ./schema-sentry.data.json
108
167
  ```
109
168
 
110
- **Pattern-based auto-detection** infers schema types from URL patterns:
111
- - `/blog/*` → BlogPosting
112
- - `/products/*` → Product
113
- - `/faq` → FAQPage
114
- - `/events/*` → Event
115
- - `/howto/*` → HowTo
116
- - and more...
117
-
118
169
  ## Options
119
170
 
120
171
  | Option | Description |
@@ -122,7 +173,8 @@ pnpm schemasentry scaffold --write --force
122
173
  | `--format json\|html` | Output format |
123
174
  | `--annotations none\|github` | CI annotations |
124
175
  | `-o, --output <path>` | Write output to file |
125
- | `--root <path>` | Root directory to scan (`collect`, `scaffold`) |
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) |
126
178
  | `--routes <routes...>` | Collect only specific routes (`collect`) |
127
179
  | `--strict-routes` | Fail when any route passed to `--routes` is missing (`collect`) |
128
180
  | `--check` | Compare collected output with existing data and fail on drift (`collect`) |
@@ -130,6 +182,44 @@ pnpm schemasentry scaffold --write --force
130
182
  | `--force` | Skip confirmation prompts (`scaffold`) |
131
183
  | `--recommended / --no-recommended` | Enable recommended field checks |
132
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
+
133
223
  ## Documentation
134
224
 
135
225
  See [Schema Sentry Docs](https://github.com/arindamdawn/schema-sentry#readme)