@icjia/contrastcap 0.1.0 → 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/package.json +1 -1
- package/src/cli.js +12 -8
- package/src/server.js +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icjia/contrastcap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "MCP server for automated WCAG contrast auditing via pixel-level analysis — resolves axe-core 'needs review' items by sampling actual rendered pixels in headless Chromium",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/server.js",
|
package/src/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { program } from 'commander';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
import { execFile } from 'child_process';
|
|
6
|
+
import { createRequire } from 'module';
|
|
6
7
|
import { setVerbosity, CONFIG } from './config.js';
|
|
7
8
|
import { closeBrowser } from './browser.js';
|
|
8
9
|
import { checkPageContrast } from './tools/checkPageContrast.js';
|
|
@@ -10,8 +11,17 @@ import { checkElementContrast } from './tools/checkElementContrast.js';
|
|
|
10
11
|
import { getContrastSummary } from './tools/getContrastSummary.js';
|
|
11
12
|
import { sanitizeError } from './utils/sanitizeError.js';
|
|
12
13
|
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
13
15
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));
|
|
14
16
|
|
|
17
|
+
function readPkgVersion(specifier) {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(require.resolve(`${specifier}/package.json`), 'utf8')).version;
|
|
20
|
+
} catch {
|
|
21
|
+
return 'unknown';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
program
|
|
16
26
|
.name('contrastcap')
|
|
17
27
|
.description('WCAG contrast auditor — pixel-level resolution of axe-core "needs review" items')
|
|
@@ -74,14 +84,8 @@ program
|
|
|
74
84
|
.command('status')
|
|
75
85
|
.description('Show version info')
|
|
76
86
|
.action(async () => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
axeVersion = JSON.parse(readFileSync(new URL('../node_modules/axe-core/package.json', import.meta.url))).version;
|
|
81
|
-
} catch { /* ignore */ }
|
|
82
|
-
try {
|
|
83
|
-
playwrightVersion = JSON.parse(readFileSync(new URL('../node_modules/playwright/package.json', import.meta.url))).version;
|
|
84
|
-
} catch { /* ignore */ }
|
|
87
|
+
const axeVersion = readPkgVersion('axe-core');
|
|
88
|
+
const playwrightVersion = readPkgVersion('playwright');
|
|
85
89
|
|
|
86
90
|
let latest = 'unknown';
|
|
87
91
|
try {
|
package/src/server.js
CHANGED
|
@@ -2,9 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import { execFile } from 'child_process';
|
|
5
|
+
import { createRequire } from 'module';
|
|
5
6
|
import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server';
|
|
6
7
|
import * as z from 'zod/v4';
|
|
7
8
|
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
function readPkgVersion(specifier) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(readFileSync(require.resolve(`${specifier}/package.json`), 'utf8')).version;
|
|
14
|
+
} catch {
|
|
15
|
+
return 'unknown';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
import { CONFIG, log, setVerbosity } from './config.js';
|
|
9
20
|
import { closeBrowser } from './browser.js';
|
|
10
21
|
import { sanitizeError } from './utils/sanitizeError.js';
|
|
@@ -20,14 +31,8 @@ if (process.argv.includes('--quiet')) setVerbosity('quiet');
|
|
|
20
31
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));
|
|
21
32
|
const serverVersion = pkg.version;
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
axeVersion = JSON.parse(readFileSync(new URL('../node_modules/axe-core/package.json', import.meta.url))).version;
|
|
27
|
-
} catch { /* ignore */ }
|
|
28
|
-
try {
|
|
29
|
-
playwrightVersion = JSON.parse(readFileSync(new URL('../node_modules/playwright/package.json', import.meta.url))).version;
|
|
30
|
-
} catch { /* ignore */ }
|
|
34
|
+
const axeVersion = readPkgVersion('axe-core');
|
|
35
|
+
const playwrightVersion = readPkgVersion('playwright');
|
|
31
36
|
|
|
32
37
|
let _latestVersion = null;
|
|
33
38
|
const _latestPromise = new Promise((resolve) => {
|