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.js CHANGED
@@ -17,28 +17,53 @@ var init_esm_shims = __esm({
17
17
  }
18
18
  });
19
19
 
20
+ // src/utils/colors.ts
21
+ function wrap(open, close) {
22
+ return enabled ? (s) => `${open}${s}${close}` : (s) => s;
23
+ }
24
+ var enabled, c;
25
+ var init_colors = __esm({
26
+ "src/utils/colors.ts"() {
27
+ "use strict";
28
+ init_esm_shims();
29
+ enabled = process.env.NO_COLOR === void 0 && process.env.FORCE_COLOR !== "0" && process.stdout.isTTY !== false;
30
+ c = {
31
+ bold: wrap("\x1B[1m", "\x1B[22m"),
32
+ dim: wrap("\x1B[2m", "\x1B[22m"),
33
+ red: wrap("\x1B[31m", "\x1B[39m"),
34
+ green: wrap("\x1B[32m", "\x1B[39m"),
35
+ yellow: wrap("\x1B[33m", "\x1B[39m"),
36
+ blue: wrap("\x1B[34m", "\x1B[39m"),
37
+ cyan: wrap("\x1B[36m", "\x1B[39m"),
38
+ gray: wrap("\x1B[90m", "\x1B[39m"),
39
+ bgRed: wrap("\x1B[41m", "\x1B[49m"),
40
+ bgGreen: wrap("\x1B[42m", "\x1B[49m")
41
+ };
42
+ }
43
+ });
44
+
20
45
  // src/utils/logger.ts
21
- import chalk from "chalk";
22
46
  var log;
23
47
  var init_logger = __esm({
24
48
  "src/utils/logger.ts"() {
25
49
  "use strict";
26
50
  init_esm_shims();
51
+ init_colors();
27
52
  log = {
28
53
  info(msg) {
29
- console.log(chalk.blue("i"), msg);
54
+ console.log(c.blue("i"), msg);
30
55
  },
31
56
  success(msg) {
32
- console.log(chalk.green("\u2713"), msg);
57
+ console.log(c.green("\u2713"), msg);
33
58
  },
34
59
  warn(msg) {
35
- console.log(chalk.yellow("\u26A0"), msg);
60
+ console.log(c.yellow("\u26A0"), msg);
36
61
  },
37
62
  error(msg) {
38
- console.log(chalk.red("\u2717"), msg);
63
+ console.log(c.red("\u2717"), msg);
39
64
  },
40
65
  dim(msg) {
41
- console.log(chalk.dim(msg));
66
+ console.log(c.dim(msg));
42
67
  },
43
68
  plain(msg) {
44
69
  console.log(msg);
@@ -361,10 +386,10 @@ var init_html = __esm({
361
386
 
362
387
  // src/bin/cli.ts
363
388
  init_esm_shims();
389
+ init_colors();
364
390
  import { Command } from "commander";
365
391
  import path16 from "path";
366
392
  import fs8 from "fs";
367
- import chalk3 from "chalk";
368
393
 
369
394
  // src/config/loader.ts
370
395
  init_esm_shims();
@@ -599,11 +624,11 @@ async function cookieInject(config, outputDir) {
599
624
  ensureDir(authDir);
600
625
  const storagePath = path6.join(authDir, "storageState.json");
601
626
  const storageState = {
602
- cookies: config.cookies.map((c) => ({
603
- name: c.name,
604
- value: c.value,
605
- domain: c.domain,
606
- path: c.path || "/",
627
+ cookies: config.cookies.map((c2) => ({
628
+ name: c2.name,
629
+ value: c2.value,
630
+ domain: c2.domain,
631
+ path: c2.path || "/",
607
632
  expires: -1,
608
633
  httpOnly: false,
609
634
  secure: true,
@@ -958,14 +983,14 @@ function getEnabledAudits(auditsConfig, pluginAudits = [], customAudits = []) {
958
983
  for (const audit of [...pluginAudits, ...customAudits]) {
959
984
  allAudits[audit.name] = audit;
960
985
  }
961
- const enabled = [];
986
+ const enabled2 = [];
962
987
  for (const [name, audit] of Object.entries(allAudits)) {
963
988
  const isEnabled = auditsConfig[name] ?? true;
964
989
  if (isEnabled) {
965
- enabled.push(audit);
990
+ enabled2.push(audit);
966
991
  }
967
992
  }
968
- return enabled;
993
+ return enabled2;
969
994
  }
970
995
 
971
996
  // src/runner/page-runner.ts
@@ -1176,31 +1201,31 @@ function reportJson(result, runDir) {
1176
1201
 
1177
1202
  // src/reporters/terminal.ts
1178
1203
  init_esm_shims();
1179
- import chalk2 from "chalk";
1204
+ init_colors();
1180
1205
  function reportTerminal(result) {
1181
1206
  const { summary } = result;
1182
1207
  console.log("");
1183
- console.log(chalk2.bold("\u2500".repeat(60)));
1184
- console.log(chalk2.bold(" Summary"));
1185
- console.log(chalk2.bold("\u2500".repeat(60)));
1208
+ console.log(c.bold("\u2500".repeat(60)));
1209
+ console.log(c.bold(" Summary"));
1210
+ console.log(c.bold("\u2500".repeat(60)));
1186
1211
  console.log("");
1187
1212
  console.log(` Total audits: ${summary.totalAudits}`);
1188
1213
  console.log(
1189
- ` ${chalk2.green("\u2713 Passed:")} ${summary.passed}`
1214
+ ` ${c.green("\u2713 Passed:")} ${summary.passed}`
1190
1215
  );
1191
1216
  if (summary.failed > 0) {
1192
1217
  console.log(
1193
- ` ${chalk2.red("\u2717 Failed:")} ${summary.failed}`
1218
+ ` ${c.red("\u2717 Failed:")} ${summary.failed}`
1194
1219
  );
1195
1220
  }
1196
1221
  if (summary.warnings > 0) {
1197
1222
  console.log(
1198
- ` ${chalk2.yellow("\u26A0 Warnings:")} ${summary.warnings}`
1223
+ ` ${c.yellow("\u26A0 Warnings:")} ${summary.warnings}`
1199
1224
  );
1200
1225
  }
1201
1226
  if (summary.skipped > 0) {
1202
1227
  console.log(
1203
- ` ${chalk2.dim("\u25CB Skipped:")} ${summary.skipped}`
1228
+ ` ${c.dim("\u25CB Skipped:")} ${summary.skipped}`
1204
1229
  );
1205
1230
  }
1206
1231
  console.log(
@@ -1211,24 +1236,24 @@ function reportTerminal(result) {
1211
1236
  (p) => p.audits.filter((a) => a.severity === "fail")
1212
1237
  );
1213
1238
  if (failedAudits.length > 0) {
1214
- console.log(chalk2.red.bold(" Failed Audits:"));
1239
+ console.log(c.bold(c.red(" Failed Audits:")));
1215
1240
  for (const audit of failedAudits) {
1216
1241
  console.log(
1217
- chalk2.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
1242
+ c.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
1218
1243
  );
1219
1244
  }
1220
1245
  console.log("");
1221
1246
  }
1222
1247
  if (summary.failed > 0) {
1223
1248
  console.log(
1224
- chalk2.red.bold(` Result: FAIL (${summary.failed} failure(s))`)
1249
+ c.bold(c.red(` Result: FAIL (${summary.failed} failure(s))`))
1225
1250
  );
1226
1251
  } else if (summary.warnings > 0) {
1227
1252
  console.log(
1228
- chalk2.yellow.bold(` Result: PASS with ${summary.warnings} warning(s)`)
1253
+ c.bold(c.yellow(` Result: PASS with ${summary.warnings} warning(s)`))
1229
1254
  );
1230
1255
  } else {
1231
- console.log(chalk2.green.bold(" Result: PASS"));
1256
+ console.log(c.bold(c.green(" Result: PASS")));
1232
1257
  }
1233
1258
  console.log("");
1234
1259
  }
@@ -1594,11 +1619,11 @@ function compareRuns(baseline, current) {
1594
1619
  currentTimestamp: current.timestamp,
1595
1620
  changes,
1596
1621
  summary: {
1597
- regressions: changes.filter((c) => c.type === "regression").length,
1598
- improvements: changes.filter((c) => c.type === "improvement").length,
1599
- unchanged: changes.filter((c) => c.type === "unchanged").length,
1600
- newAudits: changes.filter((c) => c.type === "new").length,
1601
- removedAudits: changes.filter((c) => c.type === "removed").length
1622
+ regressions: changes.filter((c2) => c2.type === "regression").length,
1623
+ improvements: changes.filter((c2) => c2.type === "improvement").length,
1624
+ unchanged: changes.filter((c2) => c2.type === "unchanged").length,
1625
+ newAudits: changes.filter((c2) => c2.type === "new").length,
1626
+ removedAudits: changes.filter((c2) => c2.type === "removed").length
1602
1627
  }
1603
1628
  };
1604
1629
  }
@@ -1726,7 +1751,7 @@ program.command("run").description("Run all audits").option("-c, --config <path>
1726
1751
  dotenv.config();
1727
1752
  console.log("");
1728
1753
  console.log(
1729
- chalk3.bold(` webguard ${chalk3.dim(`v${pkg.version}`)}`)
1754
+ c.bold(` webguard ${c.dim(`v${pkg.version}`)}`)
1730
1755
  );
1731
1756
  console.log("");
1732
1757
  const config = await loadConfig(opts.config);
@@ -1740,16 +1765,16 @@ program.command("run").description("Run all audits").option("-c, --config <path>
1740
1765
  const baseline = loadBaseline(outputDir);
1741
1766
  if (baseline) {
1742
1767
  const comparison = compareRuns(baseline, result);
1743
- console.log(chalk3.bold(" Baseline Comparison:"));
1768
+ console.log(c.bold(" Baseline Comparison:"));
1744
1769
  if (comparison.summary.regressions > 0) {
1745
- console.log(chalk3.red(` ${comparison.summary.regressions} regression(s)`));
1770
+ console.log(c.red(` ${comparison.summary.regressions} regression(s)`));
1746
1771
  }
1747
1772
  if (comparison.summary.improvements > 0) {
1748
- console.log(chalk3.green(` ${comparison.summary.improvements} improvement(s)`));
1773
+ console.log(c.green(` ${comparison.summary.improvements} improvement(s)`));
1749
1774
  }
1750
- console.log(chalk3.dim(` ${comparison.summary.unchanged} unchanged`));
1775
+ console.log(c.dim(` ${comparison.summary.unchanged} unchanged`));
1751
1776
  if (comparison.summary.newAudits > 0) {
1752
- console.log(chalk3.blue(` ${comparison.summary.newAudits} new audit(s)`));
1777
+ console.log(c.blue(` ${comparison.summary.newAudits} new audit(s)`));
1753
1778
  }
1754
1779
  console.log("");
1755
1780
  } else {
@@ -1885,29 +1910,29 @@ program.command("diff").description("Compare the latest run with the baseline").
1885
1910
  const current = JSON.parse(fs8.readFileSync(jsonReport, "utf-8"));
1886
1911
  const comparison = compareRuns(baseline, current);
1887
1912
  console.log("");
1888
- console.log(chalk3.bold(" Baseline Comparison"));
1889
- console.log(chalk3.dim(` ${comparison.baselineTimestamp} \u2192 ${comparison.currentTimestamp}`));
1913
+ console.log(c.bold(" Baseline Comparison"));
1914
+ console.log(c.dim(` ${comparison.baselineTimestamp} \u2192 ${comparison.currentTimestamp}`));
1890
1915
  console.log("");
1891
1916
  if (comparison.summary.regressions > 0) {
1892
- console.log(chalk3.red.bold(` Regressions: ${comparison.summary.regressions}`));
1893
- for (const c of comparison.changes.filter((x) => x.type === "regression")) {
1894
- console.log(chalk3.red(` \u2717 ${c.page} \u2192 ${c.audit}: ${c.baseline?.severity} \u2192 ${c.current?.severity}`));
1917
+ console.log(c.bold(c.red(` Regressions: ${comparison.summary.regressions}`)));
1918
+ for (const ch of comparison.changes.filter((x) => x.type === "regression")) {
1919
+ console.log(c.red(` \u2717 ${ch.page} \u2192 ${ch.audit}: ${ch.baseline?.severity} \u2192 ${ch.current?.severity}`));
1895
1920
  }
1896
1921
  console.log("");
1897
1922
  }
1898
1923
  if (comparison.summary.improvements > 0) {
1899
- console.log(chalk3.green.bold(` Improvements: ${comparison.summary.improvements}`));
1900
- for (const c of comparison.changes.filter((x) => x.type === "improvement")) {
1901
- console.log(chalk3.green(` \u2713 ${c.page} \u2192 ${c.audit}: ${c.baseline?.severity} \u2192 ${c.current?.severity}`));
1924
+ console.log(c.bold(c.green(` Improvements: ${comparison.summary.improvements}`)));
1925
+ for (const ch of comparison.changes.filter((x) => x.type === "improvement")) {
1926
+ console.log(c.green(` \u2713 ${ch.page} \u2192 ${ch.audit}: ${ch.baseline?.severity} \u2192 ${ch.current?.severity}`));
1902
1927
  }
1903
1928
  console.log("");
1904
1929
  }
1905
- console.log(chalk3.dim(` Unchanged: ${comparison.summary.unchanged}`));
1930
+ console.log(c.dim(` Unchanged: ${comparison.summary.unchanged}`));
1906
1931
  if (comparison.summary.newAudits > 0) {
1907
- console.log(chalk3.blue(` New audits: ${comparison.summary.newAudits}`));
1932
+ console.log(c.blue(` New audits: ${comparison.summary.newAudits}`));
1908
1933
  }
1909
1934
  if (comparison.summary.removedAudits > 0) {
1910
- console.log(chalk3.yellow(` Removed audits: ${comparison.summary.removedAudits}`));
1935
+ console.log(c.yellow(` Removed audits: ${comparison.summary.removedAudits}`));
1911
1936
  }
1912
1937
  console.log("");
1913
1938
  } catch (err) {