webguardx 0.1.0 → 0.1.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/dist/bin/cli.cjs +76 -51
- package/dist/bin/cli.cjs.map +1 -1
- package/dist/bin/cli.js +75 -50
- package/dist/bin/cli.js.map +1 -1
- package/dist/index.cjs +48 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/bin/cli.cjs
CHANGED
|
@@ -40,28 +40,53 @@ var init_cjs_shims = __esm({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
// src/utils/colors.ts
|
|
44
|
+
function wrap(open, close) {
|
|
45
|
+
return enabled ? (s) => `${open}${s}${close}` : (s) => s;
|
|
46
|
+
}
|
|
47
|
+
var enabled, c;
|
|
48
|
+
var init_colors = __esm({
|
|
49
|
+
"src/utils/colors.ts"() {
|
|
50
|
+
"use strict";
|
|
51
|
+
init_cjs_shims();
|
|
52
|
+
enabled = process.env.NO_COLOR === void 0 && process.env.FORCE_COLOR !== "0" && process.stdout.isTTY !== false;
|
|
53
|
+
c = {
|
|
54
|
+
bold: wrap("\x1B[1m", "\x1B[22m"),
|
|
55
|
+
dim: wrap("\x1B[2m", "\x1B[22m"),
|
|
56
|
+
red: wrap("\x1B[31m", "\x1B[39m"),
|
|
57
|
+
green: wrap("\x1B[32m", "\x1B[39m"),
|
|
58
|
+
yellow: wrap("\x1B[33m", "\x1B[39m"),
|
|
59
|
+
blue: wrap("\x1B[34m", "\x1B[39m"),
|
|
60
|
+
cyan: wrap("\x1B[36m", "\x1B[39m"),
|
|
61
|
+
gray: wrap("\x1B[90m", "\x1B[39m"),
|
|
62
|
+
bgRed: wrap("\x1B[41m", "\x1B[49m"),
|
|
63
|
+
bgGreen: wrap("\x1B[42m", "\x1B[49m")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
43
68
|
// src/utils/logger.ts
|
|
44
|
-
var
|
|
69
|
+
var log;
|
|
45
70
|
var init_logger = __esm({
|
|
46
71
|
"src/utils/logger.ts"() {
|
|
47
72
|
"use strict";
|
|
48
73
|
init_cjs_shims();
|
|
49
|
-
|
|
74
|
+
init_colors();
|
|
50
75
|
log = {
|
|
51
76
|
info(msg) {
|
|
52
|
-
console.log(
|
|
77
|
+
console.log(c.blue("i"), msg);
|
|
53
78
|
},
|
|
54
79
|
success(msg) {
|
|
55
|
-
console.log(
|
|
80
|
+
console.log(c.green("\u2713"), msg);
|
|
56
81
|
},
|
|
57
82
|
warn(msg) {
|
|
58
|
-
console.log(
|
|
83
|
+
console.log(c.yellow("\u26A0"), msg);
|
|
59
84
|
},
|
|
60
85
|
error(msg) {
|
|
61
|
-
console.log(
|
|
86
|
+
console.log(c.red("\u2717"), msg);
|
|
62
87
|
},
|
|
63
88
|
dim(msg) {
|
|
64
|
-
console.log(
|
|
89
|
+
console.log(c.dim(msg));
|
|
65
90
|
},
|
|
66
91
|
plain(msg) {
|
|
67
92
|
console.log(msg);
|
|
@@ -389,7 +414,7 @@ init_cjs_shims();
|
|
|
389
414
|
var import_commander = require("commander");
|
|
390
415
|
var import_path15 = __toESM(require("path"), 1);
|
|
391
416
|
var import_fs19 = __toESM(require("fs"), 1);
|
|
392
|
-
|
|
417
|
+
init_colors();
|
|
393
418
|
|
|
394
419
|
// src/config/loader.ts
|
|
395
420
|
init_cjs_shims();
|
|
@@ -624,11 +649,11 @@ async function cookieInject(config, outputDir) {
|
|
|
624
649
|
ensureDir(authDir);
|
|
625
650
|
const storagePath = import_path5.default.join(authDir, "storageState.json");
|
|
626
651
|
const storageState = {
|
|
627
|
-
cookies: config.cookies.map((
|
|
628
|
-
name:
|
|
629
|
-
value:
|
|
630
|
-
domain:
|
|
631
|
-
path:
|
|
652
|
+
cookies: config.cookies.map((c2) => ({
|
|
653
|
+
name: c2.name,
|
|
654
|
+
value: c2.value,
|
|
655
|
+
domain: c2.domain,
|
|
656
|
+
path: c2.path || "/",
|
|
632
657
|
expires: -1,
|
|
633
658
|
httpOnly: false,
|
|
634
659
|
secure: true,
|
|
@@ -983,14 +1008,14 @@ function getEnabledAudits(auditsConfig, pluginAudits = [], customAudits = []) {
|
|
|
983
1008
|
for (const audit of [...pluginAudits, ...customAudits]) {
|
|
984
1009
|
allAudits[audit.name] = audit;
|
|
985
1010
|
}
|
|
986
|
-
const
|
|
1011
|
+
const enabled2 = [];
|
|
987
1012
|
for (const [name, audit] of Object.entries(allAudits)) {
|
|
988
1013
|
const isEnabled = auditsConfig[name] ?? true;
|
|
989
1014
|
if (isEnabled) {
|
|
990
|
-
|
|
1015
|
+
enabled2.push(audit);
|
|
991
1016
|
}
|
|
992
1017
|
}
|
|
993
|
-
return
|
|
1018
|
+
return enabled2;
|
|
994
1019
|
}
|
|
995
1020
|
|
|
996
1021
|
// src/runner/page-runner.ts
|
|
@@ -1201,31 +1226,31 @@ function reportJson(result, runDir) {
|
|
|
1201
1226
|
|
|
1202
1227
|
// src/reporters/terminal.ts
|
|
1203
1228
|
init_cjs_shims();
|
|
1204
|
-
|
|
1229
|
+
init_colors();
|
|
1205
1230
|
function reportTerminal(result) {
|
|
1206
1231
|
const { summary } = result;
|
|
1207
1232
|
console.log("");
|
|
1208
|
-
console.log(
|
|
1209
|
-
console.log(
|
|
1210
|
-
console.log(
|
|
1233
|
+
console.log(c.bold("\u2500".repeat(60)));
|
|
1234
|
+
console.log(c.bold(" Summary"));
|
|
1235
|
+
console.log(c.bold("\u2500".repeat(60)));
|
|
1211
1236
|
console.log("");
|
|
1212
1237
|
console.log(` Total audits: ${summary.totalAudits}`);
|
|
1213
1238
|
console.log(
|
|
1214
|
-
` ${
|
|
1239
|
+
` ${c.green("\u2713 Passed:")} ${summary.passed}`
|
|
1215
1240
|
);
|
|
1216
1241
|
if (summary.failed > 0) {
|
|
1217
1242
|
console.log(
|
|
1218
|
-
` ${
|
|
1243
|
+
` ${c.red("\u2717 Failed:")} ${summary.failed}`
|
|
1219
1244
|
);
|
|
1220
1245
|
}
|
|
1221
1246
|
if (summary.warnings > 0) {
|
|
1222
1247
|
console.log(
|
|
1223
|
-
` ${
|
|
1248
|
+
` ${c.yellow("\u26A0 Warnings:")} ${summary.warnings}`
|
|
1224
1249
|
);
|
|
1225
1250
|
}
|
|
1226
1251
|
if (summary.skipped > 0) {
|
|
1227
1252
|
console.log(
|
|
1228
|
-
` ${
|
|
1253
|
+
` ${c.dim("\u25CB Skipped:")} ${summary.skipped}`
|
|
1229
1254
|
);
|
|
1230
1255
|
}
|
|
1231
1256
|
console.log(
|
|
@@ -1236,24 +1261,24 @@ function reportTerminal(result) {
|
|
|
1236
1261
|
(p) => p.audits.filter((a) => a.severity === "fail")
|
|
1237
1262
|
);
|
|
1238
1263
|
if (failedAudits.length > 0) {
|
|
1239
|
-
console.log(
|
|
1264
|
+
console.log(c.bold(c.red(" Failed Audits:")));
|
|
1240
1265
|
for (const audit of failedAudits) {
|
|
1241
1266
|
console.log(
|
|
1242
|
-
|
|
1267
|
+
c.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
|
|
1243
1268
|
);
|
|
1244
1269
|
}
|
|
1245
1270
|
console.log("");
|
|
1246
1271
|
}
|
|
1247
1272
|
if (summary.failed > 0) {
|
|
1248
1273
|
console.log(
|
|
1249
|
-
|
|
1274
|
+
c.bold(c.red(` Result: FAIL (${summary.failed} failure(s))`))
|
|
1250
1275
|
);
|
|
1251
1276
|
} else if (summary.warnings > 0) {
|
|
1252
1277
|
console.log(
|
|
1253
|
-
|
|
1278
|
+
c.bold(c.yellow(` Result: PASS with ${summary.warnings} warning(s)`))
|
|
1254
1279
|
);
|
|
1255
1280
|
} else {
|
|
1256
|
-
console.log(
|
|
1281
|
+
console.log(c.bold(c.green(" Result: PASS")));
|
|
1257
1282
|
}
|
|
1258
1283
|
console.log("");
|
|
1259
1284
|
}
|
|
@@ -1619,11 +1644,11 @@ function compareRuns(baseline, current) {
|
|
|
1619
1644
|
currentTimestamp: current.timestamp,
|
|
1620
1645
|
changes,
|
|
1621
1646
|
summary: {
|
|
1622
|
-
regressions: changes.filter((
|
|
1623
|
-
improvements: changes.filter((
|
|
1624
|
-
unchanged: changes.filter((
|
|
1625
|
-
newAudits: changes.filter((
|
|
1626
|
-
removedAudits: changes.filter((
|
|
1647
|
+
regressions: changes.filter((c2) => c2.type === "regression").length,
|
|
1648
|
+
improvements: changes.filter((c2) => c2.type === "improvement").length,
|
|
1649
|
+
unchanged: changes.filter((c2) => c2.type === "unchanged").length,
|
|
1650
|
+
newAudits: changes.filter((c2) => c2.type === "new").length,
|
|
1651
|
+
removedAudits: changes.filter((c2) => c2.type === "removed").length
|
|
1627
1652
|
}
|
|
1628
1653
|
};
|
|
1629
1654
|
}
|
|
@@ -1751,7 +1776,7 @@ program.command("run").description("Run all audits").option("-c, --config <path>
|
|
|
1751
1776
|
dotenv.config();
|
|
1752
1777
|
console.log("");
|
|
1753
1778
|
console.log(
|
|
1754
|
-
|
|
1779
|
+
c.bold(` webguard ${c.dim(`v${pkg.version}`)}`)
|
|
1755
1780
|
);
|
|
1756
1781
|
console.log("");
|
|
1757
1782
|
const config = await loadConfig(opts.config);
|
|
@@ -1765,16 +1790,16 @@ program.command("run").description("Run all audits").option("-c, --config <path>
|
|
|
1765
1790
|
const baseline = loadBaseline(outputDir);
|
|
1766
1791
|
if (baseline) {
|
|
1767
1792
|
const comparison = compareRuns(baseline, result);
|
|
1768
|
-
console.log(
|
|
1793
|
+
console.log(c.bold(" Baseline Comparison:"));
|
|
1769
1794
|
if (comparison.summary.regressions > 0) {
|
|
1770
|
-
console.log(
|
|
1795
|
+
console.log(c.red(` ${comparison.summary.regressions} regression(s)`));
|
|
1771
1796
|
}
|
|
1772
1797
|
if (comparison.summary.improvements > 0) {
|
|
1773
|
-
console.log(
|
|
1798
|
+
console.log(c.green(` ${comparison.summary.improvements} improvement(s)`));
|
|
1774
1799
|
}
|
|
1775
|
-
console.log(
|
|
1800
|
+
console.log(c.dim(` ${comparison.summary.unchanged} unchanged`));
|
|
1776
1801
|
if (comparison.summary.newAudits > 0) {
|
|
1777
|
-
console.log(
|
|
1802
|
+
console.log(c.blue(` ${comparison.summary.newAudits} new audit(s)`));
|
|
1778
1803
|
}
|
|
1779
1804
|
console.log("");
|
|
1780
1805
|
} else {
|
|
@@ -1910,29 +1935,29 @@ program.command("diff").description("Compare the latest run with the baseline").
|
|
|
1910
1935
|
const current = JSON.parse(import_fs19.default.readFileSync(jsonReport, "utf-8"));
|
|
1911
1936
|
const comparison = compareRuns(baseline, current);
|
|
1912
1937
|
console.log("");
|
|
1913
|
-
console.log(
|
|
1914
|
-
console.log(
|
|
1938
|
+
console.log(c.bold(" Baseline Comparison"));
|
|
1939
|
+
console.log(c.dim(` ${comparison.baselineTimestamp} \u2192 ${comparison.currentTimestamp}`));
|
|
1915
1940
|
console.log("");
|
|
1916
1941
|
if (comparison.summary.regressions > 0) {
|
|
1917
|
-
console.log(
|
|
1918
|
-
for (const
|
|
1919
|
-
console.log(
|
|
1942
|
+
console.log(c.bold(c.red(` Regressions: ${comparison.summary.regressions}`)));
|
|
1943
|
+
for (const ch of comparison.changes.filter((x) => x.type === "regression")) {
|
|
1944
|
+
console.log(c.red(` \u2717 ${ch.page} \u2192 ${ch.audit}: ${ch.baseline?.severity} \u2192 ${ch.current?.severity}`));
|
|
1920
1945
|
}
|
|
1921
1946
|
console.log("");
|
|
1922
1947
|
}
|
|
1923
1948
|
if (comparison.summary.improvements > 0) {
|
|
1924
|
-
console.log(
|
|
1925
|
-
for (const
|
|
1926
|
-
console.log(
|
|
1949
|
+
console.log(c.bold(c.green(` Improvements: ${comparison.summary.improvements}`)));
|
|
1950
|
+
for (const ch of comparison.changes.filter((x) => x.type === "improvement")) {
|
|
1951
|
+
console.log(c.green(` \u2713 ${ch.page} \u2192 ${ch.audit}: ${ch.baseline?.severity} \u2192 ${ch.current?.severity}`));
|
|
1927
1952
|
}
|
|
1928
1953
|
console.log("");
|
|
1929
1954
|
}
|
|
1930
|
-
console.log(
|
|
1955
|
+
console.log(c.dim(` Unchanged: ${comparison.summary.unchanged}`));
|
|
1931
1956
|
if (comparison.summary.newAudits > 0) {
|
|
1932
|
-
console.log(
|
|
1957
|
+
console.log(c.blue(` New audits: ${comparison.summary.newAudits}`));
|
|
1933
1958
|
}
|
|
1934
1959
|
if (comparison.summary.removedAudits > 0) {
|
|
1935
|
-
console.log(
|
|
1960
|
+
console.log(c.yellow(` Removed audits: ${comparison.summary.removedAudits}`));
|
|
1936
1961
|
}
|
|
1937
1962
|
console.log("");
|
|
1938
1963
|
} catch (err) {
|