@rankture/cli 0.1.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.
- package/LICENSE +21 -0
- package/README.md +637 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +2877 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.ts +339 -0
- package/dist/index.mjs +2648 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +72 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check result from an SEO check
|
|
3
|
+
*/
|
|
4
|
+
interface CheckResult {
|
|
5
|
+
/** Unique check identifier */
|
|
6
|
+
checkId: string;
|
|
7
|
+
/** Human-readable check name */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Severity level */
|
|
10
|
+
severity: 'critical' | 'warning' | 'info';
|
|
11
|
+
/** Whether the check passed */
|
|
12
|
+
passed: boolean;
|
|
13
|
+
/** File path where issue was found */
|
|
14
|
+
file?: string;
|
|
15
|
+
/** Description of the issue */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Line number if applicable */
|
|
18
|
+
line?: number;
|
|
19
|
+
/** Column number if applicable */
|
|
20
|
+
column?: number;
|
|
21
|
+
/** How to fix the issue */
|
|
22
|
+
fix?: string;
|
|
23
|
+
/** Additional details (e.g., list of images missing alt) */
|
|
24
|
+
details?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Summary of all check results
|
|
28
|
+
*/
|
|
29
|
+
interface CheckSummary {
|
|
30
|
+
/** Total files checked */
|
|
31
|
+
totalFiles: number;
|
|
32
|
+
/** Total checks that passed */
|
|
33
|
+
passed: number;
|
|
34
|
+
/** Total critical issues */
|
|
35
|
+
critical: number;
|
|
36
|
+
/** Total warnings */
|
|
37
|
+
warning: number;
|
|
38
|
+
/** Total info messages */
|
|
39
|
+
info: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Full report from a check run
|
|
43
|
+
*/
|
|
44
|
+
interface CheckReport {
|
|
45
|
+
/** CLI version */
|
|
46
|
+
version: string;
|
|
47
|
+
/** When the check was run */
|
|
48
|
+
timestamp: string;
|
|
49
|
+
/** Path that was checked */
|
|
50
|
+
path: string;
|
|
51
|
+
/** Summary statistics */
|
|
52
|
+
summary: CheckSummary;
|
|
53
|
+
/** All check results */
|
|
54
|
+
results: CheckResult[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for running checks
|
|
58
|
+
*/
|
|
59
|
+
interface CheckOptions {
|
|
60
|
+
/** Path to check (directory or file) */
|
|
61
|
+
path: string;
|
|
62
|
+
/** Output format */
|
|
63
|
+
format: 'terminal' | 'json' | 'html';
|
|
64
|
+
/** Output file path (optional) */
|
|
65
|
+
output?: string;
|
|
66
|
+
/** Fail threshold */
|
|
67
|
+
failOn: 'none' | 'critical' | 'warning' | 'any';
|
|
68
|
+
/** Glob patterns to ignore */
|
|
69
|
+
ignore: string[];
|
|
70
|
+
/** Config file path */
|
|
71
|
+
config?: string;
|
|
72
|
+
/** Watch mode */
|
|
73
|
+
watch?: boolean;
|
|
74
|
+
/** Only check git changed files (staged + unstaged) */
|
|
75
|
+
changed?: boolean;
|
|
76
|
+
/** Only check git staged files */
|
|
77
|
+
staged?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configuration file structure
|
|
81
|
+
*/
|
|
82
|
+
interface RanktureConfig {
|
|
83
|
+
/** Which checks to enable/disable */
|
|
84
|
+
checks?: Record<string, boolean>;
|
|
85
|
+
/** Paths to ignore */
|
|
86
|
+
ignore?: string[];
|
|
87
|
+
/** Severity overrides for specific checks */
|
|
88
|
+
rules?: Record<string, 'critical' | 'warning' | 'info'>;
|
|
89
|
+
/** Threshold settings */
|
|
90
|
+
thresholds?: {
|
|
91
|
+
titleLength?: {
|
|
92
|
+
min: number;
|
|
93
|
+
max: number;
|
|
94
|
+
};
|
|
95
|
+
descriptionLength?: {
|
|
96
|
+
min: number;
|
|
97
|
+
max: number;
|
|
98
|
+
};
|
|
99
|
+
maxImageSize?: number;
|
|
100
|
+
maxPageSize?: number;
|
|
101
|
+
};
|
|
102
|
+
/** API key for Pro features */
|
|
103
|
+
apiKey?: string;
|
|
104
|
+
/** Whether to sync results to dashboard */
|
|
105
|
+
sync?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parsed HTML page data for checks
|
|
109
|
+
*/
|
|
110
|
+
interface ParsedPage {
|
|
111
|
+
/** File path */
|
|
112
|
+
filePath: string;
|
|
113
|
+
/** Raw HTML content */
|
|
114
|
+
html: string;
|
|
115
|
+
/** Page title */
|
|
116
|
+
title?: string;
|
|
117
|
+
/** Meta description */
|
|
118
|
+
metaDescription?: string;
|
|
119
|
+
/** Canonical URL */
|
|
120
|
+
canonical?: string;
|
|
121
|
+
/** Viewport meta tag */
|
|
122
|
+
viewport?: string;
|
|
123
|
+
/** HTML lang attribute */
|
|
124
|
+
lang?: string;
|
|
125
|
+
/** All H1 tags */
|
|
126
|
+
h1s: string[];
|
|
127
|
+
/** All headings in order */
|
|
128
|
+
headings: {
|
|
129
|
+
level: number;
|
|
130
|
+
text: string;
|
|
131
|
+
}[];
|
|
132
|
+
/** All images */
|
|
133
|
+
images: {
|
|
134
|
+
src: string;
|
|
135
|
+
alt?: string;
|
|
136
|
+
line?: number;
|
|
137
|
+
}[];
|
|
138
|
+
/** All internal links */
|
|
139
|
+
internalLinks: {
|
|
140
|
+
href: string;
|
|
141
|
+
text: string;
|
|
142
|
+
}[];
|
|
143
|
+
/** All external links */
|
|
144
|
+
externalLinks: {
|
|
145
|
+
href: string;
|
|
146
|
+
text: string;
|
|
147
|
+
}[];
|
|
148
|
+
/** JSON-LD structured data */
|
|
149
|
+
jsonLd: object[];
|
|
150
|
+
/** Open Graph tags */
|
|
151
|
+
ogTags: Record<string, string>;
|
|
152
|
+
/** Twitter Card tags */
|
|
153
|
+
twitterTags: Record<string, string>;
|
|
154
|
+
/** Robots meta tag */
|
|
155
|
+
robots?: string;
|
|
156
|
+
/** Whether this is a source file (not built HTML) */
|
|
157
|
+
isSourceFile?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Supported file extensions by category
|
|
162
|
+
*/
|
|
163
|
+
declare const SUPPORTED_EXTENSIONS: {
|
|
164
|
+
html: string[];
|
|
165
|
+
source: string[];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Parse an HTML file and extract SEO-relevant data
|
|
169
|
+
*/
|
|
170
|
+
declare function parseHtml(filePath: string, html: string): ParsedPage;
|
|
171
|
+
/**
|
|
172
|
+
* Parse source files (JSX, TSX, Astro, Vue, Svelte, MD, MDX, Nunjucks, EJS, etc.)
|
|
173
|
+
* Extracts HTML-like content for SEO checking
|
|
174
|
+
*/
|
|
175
|
+
declare function parseSourceFile(filePath: string, content: string): ParsedPage;
|
|
176
|
+
|
|
177
|
+
interface CheckRegistry {
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
description: string;
|
|
181
|
+
severity: 'critical' | 'warning' | 'info';
|
|
182
|
+
run: (page: ParsedPage, allPages: ParsedPage[], basePath: string) => CheckResult[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* All available checks
|
|
186
|
+
*/
|
|
187
|
+
declare const checks: CheckRegistry[];
|
|
188
|
+
/**
|
|
189
|
+
* Run all enabled checks on a page
|
|
190
|
+
*/
|
|
191
|
+
declare function runChecks(page: ParsedPage, allPages: ParsedPage[], basePath: string, enabledChecks?: Set<string>): CheckResult[];
|
|
192
|
+
/**
|
|
193
|
+
* Get list of all available check IDs
|
|
194
|
+
*/
|
|
195
|
+
declare function getAvailableChecks(): string[];
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Check for missing or problematic title tags
|
|
199
|
+
*/
|
|
200
|
+
declare function checkMetaTitle(page: ParsedPage, allPages: ParsedPage[]): CheckResult[];
|
|
201
|
+
/**
|
|
202
|
+
* Check for missing or problematic meta descriptions
|
|
203
|
+
*/
|
|
204
|
+
declare function checkMetaDescription(page: ParsedPage, allPages: ParsedPage[]): CheckResult[];
|
|
205
|
+
/**
|
|
206
|
+
* Check for missing viewport meta tag
|
|
207
|
+
* Note: Skipped for source files since viewport is typically in layouts
|
|
208
|
+
*/
|
|
209
|
+
declare function checkViewport(page: ParsedPage): CheckResult[];
|
|
210
|
+
/**
|
|
211
|
+
* Check for missing lang attribute
|
|
212
|
+
* Note: Skipped for source files since lang is typically in layouts
|
|
213
|
+
*/
|
|
214
|
+
declare function checkLang(page: ParsedPage): CheckResult[];
|
|
215
|
+
/**
|
|
216
|
+
* Check for canonical URL issues
|
|
217
|
+
* Note: Skipped for source files since canonical is typically set dynamically
|
|
218
|
+
*/
|
|
219
|
+
declare function checkCanonical(page: ParsedPage): CheckResult[];
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Check for missing or multiple H1 tags
|
|
223
|
+
*/
|
|
224
|
+
declare function checkH1(page: ParsedPage): CheckResult[];
|
|
225
|
+
/**
|
|
226
|
+
* Check heading hierarchy (no skipped levels)
|
|
227
|
+
*/
|
|
228
|
+
declare function checkHeadingHierarchy(page: ParsedPage): CheckResult[];
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Check for images missing alt text
|
|
232
|
+
*/
|
|
233
|
+
declare function checkImageAlt(page: ParsedPage): CheckResult[];
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Check for broken internal links (links to files that don't exist)
|
|
237
|
+
*/
|
|
238
|
+
declare function checkInternalLinks(page: ParsedPage, allPages: ParsedPage[], basePath: string): CheckResult[];
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Check JSON-LD structured data for validity
|
|
242
|
+
*/
|
|
243
|
+
declare function checkSchema(page: ParsedPage): CheckResult[];
|
|
244
|
+
/**
|
|
245
|
+
* Validate JSON-LD syntax by attempting to find invalid scripts
|
|
246
|
+
* This runs on the raw HTML to catch JSON parse errors
|
|
247
|
+
*/
|
|
248
|
+
declare function checkSchemaJsonValidity(page: ParsedPage): CheckResult[];
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Check for Open Graph meta tags
|
|
252
|
+
*/
|
|
253
|
+
declare function checkOpenGraph(page: ParsedPage): CheckResult[];
|
|
254
|
+
/**
|
|
255
|
+
* Check for Twitter Card meta tags
|
|
256
|
+
*/
|
|
257
|
+
declare function checkTwitterCards(page: ParsedPage): CheckResult[];
|
|
258
|
+
/**
|
|
259
|
+
* Check for robots meta issues
|
|
260
|
+
*/
|
|
261
|
+
declare function checkRobotsMeta(page: ParsedPage): CheckResult[];
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Check for ARIA and accessibility issues
|
|
265
|
+
*/
|
|
266
|
+
declare function checkAccessibility(page: ParsedPage): CheckResult[];
|
|
267
|
+
/**
|
|
268
|
+
* Check color contrast (basic check - looks for common anti-patterns)
|
|
269
|
+
*/
|
|
270
|
+
declare function checkColorContrast(page: ParsedPage): CheckResult[];
|
|
271
|
+
/**
|
|
272
|
+
* Check for focus visibility issues
|
|
273
|
+
*/
|
|
274
|
+
declare function checkFocusIndicators(page: ParsedPage): CheckResult[];
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Default configuration
|
|
278
|
+
*/
|
|
279
|
+
declare const defaultConfig: RanktureConfig;
|
|
280
|
+
/**
|
|
281
|
+
* Find and load config file from directory
|
|
282
|
+
*/
|
|
283
|
+
declare function loadConfig(basePath: string, configPath?: string): Promise<RanktureConfig>;
|
|
284
|
+
/**
|
|
285
|
+
* Get enabled checks from config
|
|
286
|
+
*/
|
|
287
|
+
declare function getEnabledChecks(config: RanktureConfig, allChecks: string[]): Set<string>;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Format check results for terminal output
|
|
291
|
+
*/
|
|
292
|
+
declare function formatTerminal(report: CheckReport): string;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Format check results as JSON
|
|
296
|
+
*/
|
|
297
|
+
declare function formatJson(report: CheckReport): string;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Generate HTML report from check results
|
|
301
|
+
*/
|
|
302
|
+
declare function formatHtml(report: CheckReport): string;
|
|
303
|
+
|
|
304
|
+
interface ValidateResult {
|
|
305
|
+
valid: boolean;
|
|
306
|
+
errors: string[];
|
|
307
|
+
warnings: string[];
|
|
308
|
+
info: string[];
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Validate a robots.txt file
|
|
312
|
+
*/
|
|
313
|
+
declare function validateRobotsTxt(filePath: string): Promise<ValidateResult>;
|
|
314
|
+
/**
|
|
315
|
+
* Validate a sitemap.xml file
|
|
316
|
+
*/
|
|
317
|
+
declare function validateSitemap(filePath: string): Promise<ValidateResult>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Page check result for programmatic API
|
|
321
|
+
*/
|
|
322
|
+
interface PageCheckResult {
|
|
323
|
+
url: string;
|
|
324
|
+
results: CheckResult[];
|
|
325
|
+
summary: {
|
|
326
|
+
total: number;
|
|
327
|
+
passed: number;
|
|
328
|
+
failed: number;
|
|
329
|
+
critical: number;
|
|
330
|
+
warnings: number;
|
|
331
|
+
score: number;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Run checks on a single HTML file/string programmatically
|
|
336
|
+
*/
|
|
337
|
+
declare function checkPage(html: string, url?: string, basePath?: string): PageCheckResult;
|
|
338
|
+
|
|
339
|
+
export { type CheckOptions, type CheckReport, type CheckResult, type CheckSummary, type PageCheckResult, type ParsedPage, type RanktureConfig, SUPPORTED_EXTENSIONS, type ValidateResult, checkAccessibility, checkCanonical, checkColorContrast, checkFocusIndicators, checkH1, checkHeadingHierarchy, checkImageAlt, checkInternalLinks, checkLang, checkMetaDescription, checkMetaTitle, checkOpenGraph, checkPage, checkRobotsMeta, checkSchema, checkSchemaJsonValidity, checkTwitterCards, checkViewport, checks, defaultConfig, formatHtml, formatJson, formatTerminal, getAvailableChecks, getEnabledChecks, loadConfig, parseHtml, parseSourceFile, runChecks, validateRobotsTxt, validateSitemap };
|