@percy/cli-doctor 1.31.10-beta.1
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 +18 -0
- package/README.md +155 -0
- package/dist/checks/browser.js +704 -0
- package/dist/checks/connectivity.js +189 -0
- package/dist/checks/pac.js +419 -0
- package/dist/checks/proxy.js +451 -0
- package/dist/doctor.js +100 -0
- package/dist/index.js +6 -0
- package/dist/utils/helpers.js +382 -0
- package/dist/utils/http.js +252 -0
- package/dist/utils/reporter.js +120 -0
- package/package.json +52 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// ANSI colour helpers (stripped when NO_COLOR or non-TTY)
|
|
2
|
+
export const useColor = () => process.stdout.isTTY && !process.env.NO_COLOR;
|
|
3
|
+
const c = {
|
|
4
|
+
bold: s => useColor() ? `\x1b[1m${s}\x1b[0m` : s,
|
|
5
|
+
green: s => useColor() ? `\x1b[32m${s}\x1b[0m` : s,
|
|
6
|
+
yellow: s => useColor() ? `\x1b[33m${s}\x1b[0m` : s,
|
|
7
|
+
red: s => useColor() ? `\x1b[31m${s}\x1b[0m` : s,
|
|
8
|
+
cyan: s => useColor() ? `\x1b[36m${s}\x1b[0m` : s,
|
|
9
|
+
dim: s => useColor() ? `\x1b[2m${s}\x1b[0m` : s
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// Status icons
|
|
13
|
+
const ICON = {
|
|
14
|
+
pass: '✔',
|
|
15
|
+
warn: '⚠',
|
|
16
|
+
fail: '✖',
|
|
17
|
+
info: 'ℹ',
|
|
18
|
+
skip: '–'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render a section header for a check group.
|
|
23
|
+
* @param {string} title
|
|
24
|
+
*/
|
|
25
|
+
export function sectionHeader(title) {
|
|
26
|
+
return `\n${c.bold(c.cyan(`── ${title} `))}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Render a single check result line.
|
|
31
|
+
* @param {'pass'|'warn'|'fail'|'info'|'skip'} status
|
|
32
|
+
* @param {string} message
|
|
33
|
+
* @param {string} [detail] - indented secondary line
|
|
34
|
+
*/
|
|
35
|
+
export function checkLine(status, message, detail) {
|
|
36
|
+
const icon = ICON[status] ?? ICON.info;
|
|
37
|
+
const colorFn = {
|
|
38
|
+
pass: c.green,
|
|
39
|
+
warn: c.yellow,
|
|
40
|
+
fail: c.red,
|
|
41
|
+
info: c.cyan,
|
|
42
|
+
skip: c.dim
|
|
43
|
+
}[status] ?? (s => s);
|
|
44
|
+
let line = ` ${colorFn(icon)} ${message}`;
|
|
45
|
+
if (detail) line += `\n ${c.dim(detail)}`;
|
|
46
|
+
return line;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Render a bulleted suggestion list.
|
|
51
|
+
* @param {string[]} suggestions
|
|
52
|
+
*/
|
|
53
|
+
export function suggestionList(suggestions) {
|
|
54
|
+
if (!(suggestions !== null && suggestions !== void 0 && suggestions.length)) return '';
|
|
55
|
+
return suggestions.map(s => ` ${c.yellow('→')} ${c.cyan(s)}`).join('\n');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Render a final summary banner.
|
|
60
|
+
* @param {number} passed
|
|
61
|
+
* @param {number} warned
|
|
62
|
+
* @param {number} failed
|
|
63
|
+
*/
|
|
64
|
+
export function summaryBanner(passed, warned, failed) {
|
|
65
|
+
const total = passed + warned + failed;
|
|
66
|
+
let banner;
|
|
67
|
+
if (failed > 0) {
|
|
68
|
+
banner = c.red(c.bold(`\n✖ ${failed} check(s) failed`));
|
|
69
|
+
banner += c.dim(`, ${warned} warning(s), ${passed}/${total} passed`);
|
|
70
|
+
} else if (warned > 0) {
|
|
71
|
+
banner = c.yellow(c.bold(`\n⚠ ${warned} warning(s)`));
|
|
72
|
+
banner += c.dim(`, ${passed}/${total} checks passed`);
|
|
73
|
+
} else {
|
|
74
|
+
banner = c.green(c.bold(`\n✔ All ${total} checks passed`));
|
|
75
|
+
}
|
|
76
|
+
return banner + '\n';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Render a findings array to the logger and accumulate counts into a shared tally.
|
|
81
|
+
* Keeps doctor.js free of nested helper functions.
|
|
82
|
+
*
|
|
83
|
+
* @param {object[]} findings
|
|
84
|
+
* @param {import('@percy/logger').Logger} log
|
|
85
|
+
* @param {{ pass: number, warn: number, fail: number }} tally – mutated in-place
|
|
86
|
+
* @param {{ indent?: string }} [opts]
|
|
87
|
+
*/
|
|
88
|
+
export function renderFindings(findings, log, {
|
|
89
|
+
indent = ''
|
|
90
|
+
} = {}) {
|
|
91
|
+
for (const f of findings) {
|
|
92
|
+
var _f$suggestions;
|
|
93
|
+
print(log, indent + checkLine(f.status, f.message));
|
|
94
|
+
if ((_f$suggestions = f.suggestions) !== null && _f$suggestions !== void 0 && _f$suggestions.length) print(log, suggestionList(f.suggestions));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Derive the worst-case status across a findings array.
|
|
100
|
+
* @param {object[]} findings
|
|
101
|
+
* @returns {'pass'|'warn'|'fail'|'info'}
|
|
102
|
+
*/
|
|
103
|
+
export function sectionStatus(findings) {
|
|
104
|
+
if (findings.some(f => f.status === 'fail')) return 'fail';
|
|
105
|
+
if (findings.some(f => f.status === 'warn')) return 'warn';
|
|
106
|
+
if (findings.some(f => f.status === 'pass')) return 'pass';
|
|
107
|
+
return 'info';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Convenience: write lines to a logger's stdout.
|
|
112
|
+
* @param {import('@percy/logger').Logger} log
|
|
113
|
+
* @param {string} text
|
|
114
|
+
*/
|
|
115
|
+
export function print(log, text) {
|
|
116
|
+
if (text) {
|
|
117
|
+
// Use stdout write directly to preserve ANSI codes through Percy's logger
|
|
118
|
+
process.stdout.write(text + '\n');
|
|
119
|
+
}
|
|
120
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@percy/cli-doctor",
|
|
3
|
+
"version": "1.31.10-beta.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/cli-doctor"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"tag": "beta"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=14"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./src/utils/http.js": "./src/utils/http.js",
|
|
25
|
+
"./src/utils/reporter.js": "./src/utils/reporter.js",
|
|
26
|
+
"./src/utils/helpers.js": "./src/utils/helpers.js",
|
|
27
|
+
"./src/checks/connectivity.js": "./src/checks/connectivity.js",
|
|
28
|
+
"./src/checks/proxy.js": "./src/checks/proxy.js",
|
|
29
|
+
"./src/checks/pac.js": "./src/checks/pac.js",
|
|
30
|
+
"./src/checks/browser.js": "./src/checks/browser.js"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "node ../../scripts/build",
|
|
34
|
+
"lint": "eslint --ignore-path ../../.gitignore .",
|
|
35
|
+
"readme": "percy-cli-readme",
|
|
36
|
+
"test": "node ../../scripts/test",
|
|
37
|
+
"test:coverage": "yarn test --coverage"
|
|
38
|
+
},
|
|
39
|
+
"@percy/cli": {
|
|
40
|
+
"commands": [
|
|
41
|
+
"./dist/doctor.js"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@percy/cli-command": "1.31.10-beta.1",
|
|
46
|
+
"@percy/core": "1.31.10-beta.1",
|
|
47
|
+
"@percy/logger": "1.31.10-beta.1",
|
|
48
|
+
"minimatch": "^9.0.0",
|
|
49
|
+
"ws": "^8.17.1"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "ae5b74ac851df206e0793a8048f4aeda9784fde1"
|
|
52
|
+
}
|