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 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 import_chalk, log;
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
- import_chalk = __toESM(require("chalk"), 1);
74
+ init_colors();
50
75
  log = {
51
76
  info(msg) {
52
- console.log(import_chalk.default.blue("i"), msg);
77
+ console.log(c.blue("i"), msg);
53
78
  },
54
79
  success(msg) {
55
- console.log(import_chalk.default.green("\u2713"), msg);
80
+ console.log(c.green("\u2713"), msg);
56
81
  },
57
82
  warn(msg) {
58
- console.log(import_chalk.default.yellow("\u26A0"), msg);
83
+ console.log(c.yellow("\u26A0"), msg);
59
84
  },
60
85
  error(msg) {
61
- console.log(import_chalk.default.red("\u2717"), msg);
86
+ console.log(c.red("\u2717"), msg);
62
87
  },
63
88
  dim(msg) {
64
- console.log(import_chalk.default.dim(msg));
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
- var import_chalk3 = __toESM(require("chalk"), 1);
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((c) => ({
628
- name: c.name,
629
- value: c.value,
630
- domain: c.domain,
631
- path: c.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 enabled = [];
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
- enabled.push(audit);
1015
+ enabled2.push(audit);
991
1016
  }
992
1017
  }
993
- return enabled;
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
- var import_chalk2 = __toESM(require("chalk"), 1);
1229
+ init_colors();
1205
1230
  function reportTerminal(result) {
1206
1231
  const { summary } = result;
1207
1232
  console.log("");
1208
- console.log(import_chalk2.default.bold("\u2500".repeat(60)));
1209
- console.log(import_chalk2.default.bold(" Summary"));
1210
- console.log(import_chalk2.default.bold("\u2500".repeat(60)));
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
- ` ${import_chalk2.default.green("\u2713 Passed:")} ${summary.passed}`
1239
+ ` ${c.green("\u2713 Passed:")} ${summary.passed}`
1215
1240
  );
1216
1241
  if (summary.failed > 0) {
1217
1242
  console.log(
1218
- ` ${import_chalk2.default.red("\u2717 Failed:")} ${summary.failed}`
1243
+ ` ${c.red("\u2717 Failed:")} ${summary.failed}`
1219
1244
  );
1220
1245
  }
1221
1246
  if (summary.warnings > 0) {
1222
1247
  console.log(
1223
- ` ${import_chalk2.default.yellow("\u26A0 Warnings:")} ${summary.warnings}`
1248
+ ` ${c.yellow("\u26A0 Warnings:")} ${summary.warnings}`
1224
1249
  );
1225
1250
  }
1226
1251
  if (summary.skipped > 0) {
1227
1252
  console.log(
1228
- ` ${import_chalk2.default.dim("\u25CB Skipped:")} ${summary.skipped}`
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(import_chalk2.default.red.bold(" Failed Audits:"));
1264
+ console.log(c.bold(c.red(" Failed Audits:")));
1240
1265
  for (const audit of failedAudits) {
1241
1266
  console.log(
1242
- import_chalk2.default.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
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
- import_chalk2.default.red.bold(` Result: FAIL (${summary.failed} failure(s))`)
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
- import_chalk2.default.yellow.bold(` Result: PASS with ${summary.warnings} warning(s)`)
1278
+ c.bold(c.yellow(` Result: PASS with ${summary.warnings} warning(s)`))
1254
1279
  );
1255
1280
  } else {
1256
- console.log(import_chalk2.default.green.bold(" Result: PASS"));
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((c) => c.type === "regression").length,
1623
- improvements: changes.filter((c) => c.type === "improvement").length,
1624
- unchanged: changes.filter((c) => c.type === "unchanged").length,
1625
- newAudits: changes.filter((c) => c.type === "new").length,
1626
- removedAudits: changes.filter((c) => c.type === "removed").length
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
- import_chalk3.default.bold(` webguard ${import_chalk3.default.dim(`v${pkg.version}`)}`)
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(import_chalk3.default.bold(" Baseline Comparison:"));
1793
+ console.log(c.bold(" Baseline Comparison:"));
1769
1794
  if (comparison.summary.regressions > 0) {
1770
- console.log(import_chalk3.default.red(` ${comparison.summary.regressions} regression(s)`));
1795
+ console.log(c.red(` ${comparison.summary.regressions} regression(s)`));
1771
1796
  }
1772
1797
  if (comparison.summary.improvements > 0) {
1773
- console.log(import_chalk3.default.green(` ${comparison.summary.improvements} improvement(s)`));
1798
+ console.log(c.green(` ${comparison.summary.improvements} improvement(s)`));
1774
1799
  }
1775
- console.log(import_chalk3.default.dim(` ${comparison.summary.unchanged} unchanged`));
1800
+ console.log(c.dim(` ${comparison.summary.unchanged} unchanged`));
1776
1801
  if (comparison.summary.newAudits > 0) {
1777
- console.log(import_chalk3.default.blue(` ${comparison.summary.newAudits} new audit(s)`));
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(import_chalk3.default.bold(" Baseline Comparison"));
1914
- console.log(import_chalk3.default.dim(` ${comparison.baselineTimestamp} \u2192 ${comparison.currentTimestamp}`));
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(import_chalk3.default.red.bold(` Regressions: ${comparison.summary.regressions}`));
1918
- for (const c of comparison.changes.filter((x) => x.type === "regression")) {
1919
- console.log(import_chalk3.default.red(` \u2717 ${c.page} \u2192 ${c.audit}: ${c.baseline?.severity} \u2192 ${c.current?.severity}`));
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(import_chalk3.default.green.bold(` Improvements: ${comparison.summary.improvements}`));
1925
- for (const c of comparison.changes.filter((x) => x.type === "improvement")) {
1926
- console.log(import_chalk3.default.green(` \u2713 ${c.page} \u2192 ${c.audit}: ${c.baseline?.severity} \u2192 ${c.current?.severity}`));
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(import_chalk3.default.dim(` Unchanged: ${comparison.summary.unchanged}`));
1955
+ console.log(c.dim(` Unchanged: ${comparison.summary.unchanged}`));
1931
1956
  if (comparison.summary.newAudits > 0) {
1932
- console.log(import_chalk3.default.blue(` New audits: ${comparison.summary.newAudits}`));
1957
+ console.log(c.blue(` New audits: ${comparison.summary.newAudits}`));
1933
1958
  }
1934
1959
  if (comparison.summary.removedAudits > 0) {
1935
- console.log(import_chalk3.default.yellow(` Removed audits: ${comparison.summary.removedAudits}`));
1960
+ console.log(c.yellow(` Removed audits: ${comparison.summary.removedAudits}`));
1936
1961
  }
1937
1962
  console.log("");
1938
1963
  } catch (err) {