@rankture/cli 0.1.1 → 0.1.3
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 +90 -22
- package/dist/cli.mjs +1145 -130
- package/dist/index.d.ts +236 -21
- package/dist/index.mjs +1546 -494
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Check result from an SEO check
|
|
3
5
|
*/
|
|
@@ -37,6 +39,8 @@ interface CheckSummary {
|
|
|
37
39
|
warning: number;
|
|
38
40
|
/** Total info messages */
|
|
39
41
|
info: number;
|
|
42
|
+
/** Percentage of all checks that passed */
|
|
43
|
+
score?: number;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Full report from a check run
|
|
@@ -52,6 +56,49 @@ interface CheckReport {
|
|
|
52
56
|
summary: CheckSummary;
|
|
53
57
|
/** All check results */
|
|
54
58
|
results: CheckResult[];
|
|
59
|
+
/** Git/CI context, when detectable */
|
|
60
|
+
ci?: CiMetadata;
|
|
61
|
+
/** Baseline suppression info, when a baseline was applied */
|
|
62
|
+
baseline?: {
|
|
63
|
+
/** Baseline file path */
|
|
64
|
+
file: string;
|
|
65
|
+
/** Number of known issues suppressed by the baseline */
|
|
66
|
+
suppressed: number;
|
|
67
|
+
/** Issues not covered by the baseline */
|
|
68
|
+
fresh: number;
|
|
69
|
+
};
|
|
70
|
+
/** Hosted run created by --sync */
|
|
71
|
+
sync?: {
|
|
72
|
+
runId: string;
|
|
73
|
+
websiteId?: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Git/CI context detected from standard environment variables
|
|
78
|
+
*/
|
|
79
|
+
interface CiMetadata {
|
|
80
|
+
/** CI provider slug, e.g. github-actions, gitlab-ci, vercel, or 'git' for local */
|
|
81
|
+
provider: string;
|
|
82
|
+
/** Commit SHA */
|
|
83
|
+
commit?: string;
|
|
84
|
+
/** Branch or ref name */
|
|
85
|
+
branch?: string;
|
|
86
|
+
/** Pull/merge request number */
|
|
87
|
+
pullRequest?: number;
|
|
88
|
+
/** Link to the CI build, when the provider exposes one */
|
|
89
|
+
buildUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
interface CheckThresholds {
|
|
92
|
+
titleLength?: {
|
|
93
|
+
min: number;
|
|
94
|
+
max: number;
|
|
95
|
+
};
|
|
96
|
+
descriptionLength?: {
|
|
97
|
+
min: number;
|
|
98
|
+
max: number;
|
|
99
|
+
};
|
|
100
|
+
maxImageSize?: number;
|
|
101
|
+
maxPageSize?: number;
|
|
55
102
|
}
|
|
56
103
|
/**
|
|
57
104
|
* Options for running checks
|
|
@@ -60,11 +107,11 @@ interface CheckOptions {
|
|
|
60
107
|
/** Path to check (directory or file) */
|
|
61
108
|
path: string;
|
|
62
109
|
/** Output format */
|
|
63
|
-
format: 'terminal' | 'json' | 'html';
|
|
110
|
+
format: 'terminal' | 'json' | 'html' | 'sarif' | 'markdown';
|
|
64
111
|
/** Output file path (optional) */
|
|
65
112
|
output?: string;
|
|
66
|
-
/** Fail threshold */
|
|
67
|
-
failOn: 'none' | 'critical' | 'warning' | 'any';
|
|
113
|
+
/** Fail threshold ('new' requires --baseline) */
|
|
114
|
+
failOn: 'none' | 'critical' | 'warning' | 'any' | 'new';
|
|
68
115
|
/** Glob patterns to ignore */
|
|
69
116
|
ignore: string[];
|
|
70
117
|
/** Config file path */
|
|
@@ -75,6 +122,36 @@ interface CheckOptions {
|
|
|
75
122
|
changed?: boolean;
|
|
76
123
|
/** Only check git staged files */
|
|
77
124
|
staged?: boolean;
|
|
125
|
+
/** Suppress non-essential output (spinner, passed counts, info results) */
|
|
126
|
+
quiet?: boolean;
|
|
127
|
+
/** Baseline file: known issues in it are suppressed */
|
|
128
|
+
baseline?: string;
|
|
129
|
+
/** Write/refresh the baseline file from this run's failures */
|
|
130
|
+
updateBaseline?: boolean;
|
|
131
|
+
/** Fail when warning count exceeds this (after baseline filtering) */
|
|
132
|
+
maxWarnings?: number;
|
|
133
|
+
/** Fail when critical count exceeds this (after baseline filtering) */
|
|
134
|
+
maxCritical?: number;
|
|
135
|
+
/** Fail when the overall score is below this percentage */
|
|
136
|
+
minScore?: number;
|
|
137
|
+
/** Emit GitHub Actions workflow-command annotations */
|
|
138
|
+
annotations?: boolean;
|
|
139
|
+
/** Disable ANSI colors */
|
|
140
|
+
noColor?: boolean;
|
|
141
|
+
/** Validate built-site links through an ephemeral local HTTP server */
|
|
142
|
+
serve?: boolean;
|
|
143
|
+
/** Preferred local server port (0 selects an available port) */
|
|
144
|
+
servePort?: number;
|
|
145
|
+
/** Open a generated HTML report in the system browser */
|
|
146
|
+
open?: boolean;
|
|
147
|
+
/** Upload this local report to Rankture */
|
|
148
|
+
sync?: boolean;
|
|
149
|
+
/** Website receiving the synced run */
|
|
150
|
+
websiteId?: string;
|
|
151
|
+
/** One-run API key override */
|
|
152
|
+
apiKey?: string;
|
|
153
|
+
/** Rankture API origin override */
|
|
154
|
+
apiUrl?: string;
|
|
78
155
|
}
|
|
79
156
|
/**
|
|
80
157
|
* Configuration file structure
|
|
@@ -87,22 +164,15 @@ interface RanktureConfig {
|
|
|
87
164
|
/** Severity overrides for specific checks */
|
|
88
165
|
rules?: Record<string, 'critical' | 'warning' | 'info'>;
|
|
89
166
|
/** 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
|
-
};
|
|
167
|
+
thresholds?: CheckThresholds;
|
|
102
168
|
/** API key for Pro features */
|
|
103
169
|
apiKey?: string;
|
|
104
170
|
/** Whether to sync results to dashboard */
|
|
105
171
|
sync?: boolean;
|
|
172
|
+
/** Default website association for synced runs */
|
|
173
|
+
websiteId?: string;
|
|
174
|
+
/** Rankture API origin override */
|
|
175
|
+
apiUrl?: string;
|
|
106
176
|
}
|
|
107
177
|
/**
|
|
108
178
|
* Parsed HTML page data for checks
|
|
@@ -112,6 +182,8 @@ interface ParsedPage {
|
|
|
112
182
|
filePath: string;
|
|
113
183
|
/** Raw HTML content */
|
|
114
184
|
html: string;
|
|
185
|
+
/** Original untransformed file contents used for source provenance */
|
|
186
|
+
sourceContent?: string;
|
|
115
187
|
/** Page title */
|
|
116
188
|
title?: string;
|
|
117
189
|
/** Meta description */
|
|
@@ -179,7 +251,7 @@ interface CheckRegistry {
|
|
|
179
251
|
name: string;
|
|
180
252
|
description: string;
|
|
181
253
|
severity: 'critical' | 'warning' | 'info';
|
|
182
|
-
run: (page: ParsedPage, allPages: ParsedPage[], basePath: string) => CheckResult[];
|
|
254
|
+
run: (page: ParsedPage, allPages: ParsedPage[], basePath: string, thresholds?: CheckThresholds) => CheckResult[];
|
|
183
255
|
}
|
|
184
256
|
/**
|
|
185
257
|
* All available checks
|
|
@@ -188,7 +260,7 @@ declare const checks: CheckRegistry[];
|
|
|
188
260
|
/**
|
|
189
261
|
* Run all enabled checks on a page
|
|
190
262
|
*/
|
|
191
|
-
declare function runChecks(page: ParsedPage, allPages: ParsedPage[], basePath: string, enabledChecks?: Set<string
|
|
263
|
+
declare function runChecks(page: ParsedPage, allPages: ParsedPage[], basePath: string, enabledChecks?: Set<string>, thresholds?: CheckThresholds): CheckResult[];
|
|
192
264
|
/**
|
|
193
265
|
* Get list of all available check IDs
|
|
194
266
|
*/
|
|
@@ -197,11 +269,11 @@ declare function getAvailableChecks(): string[];
|
|
|
197
269
|
/**
|
|
198
270
|
* Check for missing or problematic title tags
|
|
199
271
|
*/
|
|
200
|
-
declare function checkMetaTitle(page: ParsedPage, allPages: ParsedPage[]): CheckResult[];
|
|
272
|
+
declare function checkMetaTitle(page: ParsedPage, allPages: ParsedPage[], thresholds?: CheckThresholds): CheckResult[];
|
|
201
273
|
/**
|
|
202
274
|
* Check for missing or problematic meta descriptions
|
|
203
275
|
*/
|
|
204
|
-
declare function checkMetaDescription(page: ParsedPage, allPages: ParsedPage[]): CheckResult[];
|
|
276
|
+
declare function checkMetaDescription(page: ParsedPage, allPages: ParsedPage[], thresholds?: CheckThresholds): CheckResult[];
|
|
205
277
|
/**
|
|
206
278
|
* Check for missing viewport meta tag
|
|
207
279
|
* Note: Skipped for source files since viewport is typically in layouts
|
|
@@ -281,15 +353,146 @@ declare const defaultConfig: RanktureConfig;
|
|
|
281
353
|
* Find and load config file from directory
|
|
282
354
|
*/
|
|
283
355
|
declare function loadConfig(basePath: string, configPath?: string): Promise<RanktureConfig>;
|
|
356
|
+
/**
|
|
357
|
+
* Validate config structure
|
|
358
|
+
*/
|
|
359
|
+
declare function validateConfig(config: unknown): config is RanktureConfig;
|
|
360
|
+
/** Return every configuration problem so users can fix a file in one pass. */
|
|
361
|
+
declare function getConfigErrors(config: unknown): string[];
|
|
284
362
|
/**
|
|
285
363
|
* Get enabled checks from config
|
|
286
364
|
*/
|
|
287
365
|
declare function getEnabledChecks(config: RanktureConfig, allChecks: string[]): Set<string>;
|
|
288
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Baseline file: a committed snapshot of known issues so CI can fail only on
|
|
369
|
+
* newly introduced problems (`--baseline seo-baseline.json --fail-on new`).
|
|
370
|
+
*
|
|
371
|
+
* Issues are keyed by `checkId|relative-file-path` with an occurrence count.
|
|
372
|
+
* Counts matter: a file with 2 known image-alt issues fails again when a 3rd
|
|
373
|
+
* appears. Line numbers and messages are deliberately excluded from the key —
|
|
374
|
+
* they shift with unrelated edits and would make the baseline churn.
|
|
375
|
+
*/
|
|
376
|
+
interface BaselineFile {
|
|
377
|
+
version: 1;
|
|
378
|
+
createdAt: string;
|
|
379
|
+
issues: Record<string, number>;
|
|
380
|
+
}
|
|
381
|
+
interface BaselineResult {
|
|
382
|
+
/** Failures not covered by the baseline (still fail CI) */
|
|
383
|
+
fresh: CheckResult[];
|
|
384
|
+
/** Number of failures suppressed as already-known */
|
|
385
|
+
suppressed: number;
|
|
386
|
+
}
|
|
387
|
+
declare function buildBaseline(failures: CheckResult[], basePath: string, timestamp: string): BaselineFile;
|
|
388
|
+
declare function loadBaseline(filePath: string): BaselineFile;
|
|
389
|
+
declare function saveBaseline(filePath: string, baseline: BaselineFile): void;
|
|
390
|
+
/**
|
|
391
|
+
* Split failures into fresh (not in baseline, or exceeding the known count)
|
|
392
|
+
* and suppressed. Deterministic: the first N occurrences of a key are
|
|
393
|
+
* suppressed, where N is the baseline count.
|
|
394
|
+
*/
|
|
395
|
+
declare function applyBaseline(failures: CheckResult[], baseline: BaselineFile, basePath: string): BaselineResult;
|
|
396
|
+
|
|
397
|
+
type Env = Record<string, string | undefined>;
|
|
398
|
+
/**
|
|
399
|
+
* Detect git/CI context from standard environment variables so reports and
|
|
400
|
+
* sync payloads can be tied to a commit, branch, and PR. Falls back to local
|
|
401
|
+
* git when no CI provider is detected. Returns undefined when nothing is
|
|
402
|
+
* detectable (e.g. a plain directory outside a repo).
|
|
403
|
+
*/
|
|
404
|
+
declare function collectCiMetadata(env?: Env, cwd?: string): CiMetadata | undefined;
|
|
405
|
+
|
|
406
|
+
/** Attach exact locations only to findings that refer to syntax that exists. */
|
|
407
|
+
declare function locateFinding(page: ParsedPage, result: CheckResult): CheckResult;
|
|
408
|
+
|
|
409
|
+
interface StaticServer {
|
|
410
|
+
origin: string;
|
|
411
|
+
close: () => Promise<void>;
|
|
412
|
+
}
|
|
413
|
+
declare function startStaticServer(rootPath: string, port?: number): Promise<StaticServer>;
|
|
414
|
+
declare function pageUrlForFile(filePath: string, rootPath: string, origin: string): string;
|
|
415
|
+
|
|
416
|
+
interface StoredCredentials {
|
|
417
|
+
apiKey: string;
|
|
418
|
+
apiUrl: string;
|
|
419
|
+
}
|
|
420
|
+
declare function credentialFile(env?: NodeJS.ProcessEnv): string;
|
|
421
|
+
declare function saveCredentials(credentials: StoredCredentials, env?: NodeJS.ProcessEnv): string;
|
|
422
|
+
declare function loadCredentials(env?: NodeJS.ProcessEnv): StoredCredentials | undefined;
|
|
423
|
+
declare function clearCredentials(env?: NodeJS.ProcessEnv): boolean;
|
|
424
|
+
|
|
425
|
+
interface CliIdentity {
|
|
426
|
+
user: {
|
|
427
|
+
id: string;
|
|
428
|
+
email: string;
|
|
429
|
+
name?: string | null;
|
|
430
|
+
};
|
|
431
|
+
scopes: string[];
|
|
432
|
+
}
|
|
433
|
+
declare function cliApiRequest<T>(pathname: string, init?: RequestInit, override?: Partial<StoredCredentials>): Promise<T>;
|
|
434
|
+
declare const getIdentity: (override?: Partial<StoredCredentials>) => Promise<CliIdentity>;
|
|
435
|
+
declare const getWebsites: (override?: Partial<StoredCredentials>) => Promise<{
|
|
436
|
+
websites: Array<{
|
|
437
|
+
id: string;
|
|
438
|
+
name?: string;
|
|
439
|
+
url: string;
|
|
440
|
+
}>;
|
|
441
|
+
}>;
|
|
442
|
+
declare const syncCheckReport: (report: CheckReport, websiteId?: string, override?: Partial<StoredCredentials>) => Promise<{
|
|
443
|
+
success: true;
|
|
444
|
+
runId: string;
|
|
445
|
+
}>;
|
|
446
|
+
declare const startRemoteAudit: (url: string, options?: {
|
|
447
|
+
pages?: number;
|
|
448
|
+
}, override?: Partial<StoredCredentials>) => Promise<{
|
|
449
|
+
success: true;
|
|
450
|
+
auditId: string;
|
|
451
|
+
}>;
|
|
452
|
+
declare const getRemoteAudit: (auditId: string, override?: Partial<StoredCredentials>, full?: boolean) => Promise<Record<string, unknown>>;
|
|
453
|
+
|
|
454
|
+
declare function createMcpServer(rootPath?: string, cliEntry?: string): McpServer;
|
|
455
|
+
declare function startMcpServer(rootPath?: string): Promise<void>;
|
|
456
|
+
|
|
457
|
+
interface IntegrationOptions {
|
|
458
|
+
path?: string;
|
|
459
|
+
config?: string;
|
|
460
|
+
failOn?: CheckOptions['failOn'];
|
|
461
|
+
format?: CheckOptions['format'];
|
|
462
|
+
serve?: boolean;
|
|
463
|
+
quiet?: boolean;
|
|
464
|
+
runner?: (options: CheckOptions) => Promise<number>;
|
|
465
|
+
}
|
|
466
|
+
/** Astro integration: run after static build output has been written. */
|
|
467
|
+
declare function ranktureAstro(options?: IntegrationOptions): {
|
|
468
|
+
name: string;
|
|
469
|
+
hooks: {
|
|
470
|
+
'astro:build:done': ({ dir }: {
|
|
471
|
+
dir: URL;
|
|
472
|
+
}) => Promise<void>;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
/** Vite/Rollup plugin: run after the configured output directory is built. */
|
|
476
|
+
declare function ranktureVite(options?: IntegrationOptions): {
|
|
477
|
+
name: string;
|
|
478
|
+
apply: "build";
|
|
479
|
+
enforce: "post";
|
|
480
|
+
configResolved(config: {
|
|
481
|
+
root?: string;
|
|
482
|
+
build?: {
|
|
483
|
+
outDir?: string;
|
|
484
|
+
};
|
|
485
|
+
}): void;
|
|
486
|
+
closeBundle(): Promise<void>;
|
|
487
|
+
};
|
|
488
|
+
|
|
289
489
|
/**
|
|
290
490
|
* Format check results for terminal output
|
|
291
491
|
*/
|
|
292
|
-
declare function formatTerminal(report: CheckReport
|
|
492
|
+
declare function formatTerminal(report: CheckReport, opts?: {
|
|
493
|
+
quiet?: boolean;
|
|
494
|
+
noColor?: boolean;
|
|
495
|
+
}): string;
|
|
293
496
|
|
|
294
497
|
/**
|
|
295
498
|
* Format check results as JSON
|
|
@@ -301,12 +504,24 @@ declare function formatJson(report: CheckReport): string;
|
|
|
301
504
|
*/
|
|
302
505
|
declare function formatHtml(report: CheckReport): string;
|
|
303
506
|
|
|
507
|
+
/** Compact, actionable output intended for pull requests and coding agents. */
|
|
508
|
+
declare function formatMarkdown(report: CheckReport): string;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* SARIF 2.1.0 output for GitHub code scanning and other static-analysis
|
|
512
|
+
* consumers. Failures only; rule metadata is derived from the results so the
|
|
513
|
+
* rule list always matches what actually fired.
|
|
514
|
+
*/
|
|
515
|
+
declare function formatSarif(report: CheckReport, basePath: string): string;
|
|
516
|
+
|
|
304
517
|
interface ValidateResult {
|
|
305
518
|
valid: boolean;
|
|
306
519
|
errors: string[];
|
|
307
520
|
warnings: string[];
|
|
308
521
|
info: string[];
|
|
309
522
|
}
|
|
523
|
+
/** Validate a JSON-LD document or JSON-LD scripts embedded in HTML/source. */
|
|
524
|
+
declare function validateSchema(filePath: string): Promise<ValidateResult>;
|
|
310
525
|
/**
|
|
311
526
|
* Validate a robots.txt file
|
|
312
527
|
*/
|
|
@@ -336,4 +551,4 @@ interface PageCheckResult {
|
|
|
336
551
|
*/
|
|
337
552
|
declare function checkPage(html: string, url?: string, basePath?: string): PageCheckResult;
|
|
338
553
|
|
|
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 };
|
|
554
|
+
export { type BaselineFile, type BaselineResult, type CheckOptions, type CheckReport, type CheckResult, type CheckSummary, type CheckThresholds, type CiMetadata, type IntegrationOptions, type PageCheckResult, type ParsedPage, type RanktureConfig, SUPPORTED_EXTENSIONS, type ValidateResult, applyBaseline, buildBaseline, checkAccessibility, checkCanonical, checkColorContrast, checkFocusIndicators, checkH1, checkHeadingHierarchy, checkImageAlt, checkInternalLinks, checkLang, checkMetaDescription, checkMetaTitle, checkOpenGraph, checkPage, checkRobotsMeta, checkSchema, checkSchemaJsonValidity, checkTwitterCards, checkViewport, checks, clearCredentials, cliApiRequest, collectCiMetadata, createMcpServer, credentialFile, defaultConfig, formatHtml, formatJson, formatMarkdown, formatSarif, formatTerminal, getAvailableChecks, getConfigErrors, getEnabledChecks, getIdentity, getRemoteAudit, getWebsites, loadBaseline, loadConfig, loadCredentials, locateFinding, pageUrlForFile, parseHtml, parseSourceFile, ranktureAstro, ranktureVite, runChecks, saveBaseline, saveCredentials, startMcpServer, startRemoteAudit, startStaticServer, syncCheckReport, validateConfig, validateRobotsTxt, validateSchema, validateSitemap };
|