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/index.js CHANGED
@@ -112,23 +112,40 @@ function defineConfig(config) {
112
112
  import path from "path";
113
113
  import fs from "fs";
114
114
 
115
+ // src/utils/colors.ts
116
+ var enabled = process.env.NO_COLOR === void 0 && process.env.FORCE_COLOR !== "0" && process.stdout.isTTY !== false;
117
+ function wrap(open, close) {
118
+ return enabled ? (s) => `${open}${s}${close}` : (s) => s;
119
+ }
120
+ var c = {
121
+ bold: wrap("\x1B[1m", "\x1B[22m"),
122
+ dim: wrap("\x1B[2m", "\x1B[22m"),
123
+ red: wrap("\x1B[31m", "\x1B[39m"),
124
+ green: wrap("\x1B[32m", "\x1B[39m"),
125
+ yellow: wrap("\x1B[33m", "\x1B[39m"),
126
+ blue: wrap("\x1B[34m", "\x1B[39m"),
127
+ cyan: wrap("\x1B[36m", "\x1B[39m"),
128
+ gray: wrap("\x1B[90m", "\x1B[39m"),
129
+ bgRed: wrap("\x1B[41m", "\x1B[49m"),
130
+ bgGreen: wrap("\x1B[42m", "\x1B[49m")
131
+ };
132
+
115
133
  // src/utils/logger.ts
116
- import chalk from "chalk";
117
134
  var log = {
118
135
  info(msg) {
119
- console.log(chalk.blue("i"), msg);
136
+ console.log(c.blue("i"), msg);
120
137
  },
121
138
  success(msg) {
122
- console.log(chalk.green("\u2713"), msg);
139
+ console.log(c.green("\u2713"), msg);
123
140
  },
124
141
  warn(msg) {
125
- console.log(chalk.yellow("\u26A0"), msg);
142
+ console.log(c.yellow("\u26A0"), msg);
126
143
  },
127
144
  error(msg) {
128
- console.log(chalk.red("\u2717"), msg);
145
+ console.log(c.red("\u2717"), msg);
129
146
  },
130
147
  dim(msg) {
131
- console.log(chalk.dim(msg));
148
+ console.log(c.dim(msg));
132
149
  },
133
150
  plain(msg) {
134
151
  console.log(msg);
@@ -266,11 +283,11 @@ async function cookieInject(config, outputDir) {
266
283
  ensureDir(authDir);
267
284
  const storagePath = path5.join(authDir, "storageState.json");
268
285
  const storageState = {
269
- cookies: config.cookies.map((c) => ({
270
- name: c.name,
271
- value: c.value,
272
- domain: c.domain,
273
- path: c.path || "/",
286
+ cookies: config.cookies.map((c2) => ({
287
+ name: c2.name,
288
+ value: c2.value,
289
+ domain: c2.domain,
290
+ path: c2.path || "/",
274
291
  expires: -1,
275
292
  httpOnly: false,
276
293
  secure: true,
@@ -610,14 +627,14 @@ function getEnabledAudits(auditsConfig, pluginAudits = [], customAudits = []) {
610
627
  for (const audit of [...pluginAudits, ...customAudits]) {
611
628
  allAudits[audit.name] = audit;
612
629
  }
613
- const enabled = [];
630
+ const enabled2 = [];
614
631
  for (const [name, audit] of Object.entries(allAudits)) {
615
632
  const isEnabled = auditsConfig[name] ?? true;
616
633
  if (isEnabled) {
617
- enabled.push(audit);
634
+ enabled2.push(audit);
618
635
  }
619
636
  }
620
- return enabled;
637
+ return enabled2;
621
638
  }
622
639
 
623
640
  // src/runner/page-runner.ts
@@ -809,31 +826,30 @@ function reportJson(result, runDir) {
809
826
  }
810
827
 
811
828
  // src/reporters/terminal.ts
812
- import chalk2 from "chalk";
813
829
  function reportTerminal(result) {
814
830
  const { summary } = result;
815
831
  console.log("");
816
- console.log(chalk2.bold("\u2500".repeat(60)));
817
- console.log(chalk2.bold(" Summary"));
818
- console.log(chalk2.bold("\u2500".repeat(60)));
832
+ console.log(c.bold("\u2500".repeat(60)));
833
+ console.log(c.bold(" Summary"));
834
+ console.log(c.bold("\u2500".repeat(60)));
819
835
  console.log("");
820
836
  console.log(` Total audits: ${summary.totalAudits}`);
821
837
  console.log(
822
- ` ${chalk2.green("\u2713 Passed:")} ${summary.passed}`
838
+ ` ${c.green("\u2713 Passed:")} ${summary.passed}`
823
839
  );
824
840
  if (summary.failed > 0) {
825
841
  console.log(
826
- ` ${chalk2.red("\u2717 Failed:")} ${summary.failed}`
842
+ ` ${c.red("\u2717 Failed:")} ${summary.failed}`
827
843
  );
828
844
  }
829
845
  if (summary.warnings > 0) {
830
846
  console.log(
831
- ` ${chalk2.yellow("\u26A0 Warnings:")} ${summary.warnings}`
847
+ ` ${c.yellow("\u26A0 Warnings:")} ${summary.warnings}`
832
848
  );
833
849
  }
834
850
  if (summary.skipped > 0) {
835
851
  console.log(
836
- ` ${chalk2.dim("\u25CB Skipped:")} ${summary.skipped}`
852
+ ` ${c.dim("\u25CB Skipped:")} ${summary.skipped}`
837
853
  );
838
854
  }
839
855
  console.log(
@@ -844,24 +860,24 @@ function reportTerminal(result) {
844
860
  (p) => p.audits.filter((a) => a.severity === "fail")
845
861
  );
846
862
  if (failedAudits.length > 0) {
847
- console.log(chalk2.red.bold(" Failed Audits:"));
863
+ console.log(c.bold(c.red(" Failed Audits:")));
848
864
  for (const audit of failedAudits) {
849
865
  console.log(
850
- chalk2.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
866
+ c.red(` \u2717 ${audit.page} \u2192 ${audit.audit}: ${audit.message}`)
851
867
  );
852
868
  }
853
869
  console.log("");
854
870
  }
855
871
  if (summary.failed > 0) {
856
872
  console.log(
857
- chalk2.red.bold(` Result: FAIL (${summary.failed} failure(s))`)
873
+ c.bold(c.red(` Result: FAIL (${summary.failed} failure(s))`))
858
874
  );
859
875
  } else if (summary.warnings > 0) {
860
876
  console.log(
861
- chalk2.yellow.bold(` Result: PASS with ${summary.warnings} warning(s)`)
877
+ c.bold(c.yellow(` Result: PASS with ${summary.warnings} warning(s)`))
862
878
  );
863
879
  } else {
864
- console.log(chalk2.green.bold(" Result: PASS"));
880
+ console.log(c.bold(c.green(" Result: PASS")));
865
881
  }
866
882
  console.log("");
867
883
  }
@@ -1553,11 +1569,11 @@ function compareRuns(baseline, current) {
1553
1569
  currentTimestamp: current.timestamp,
1554
1570
  changes,
1555
1571
  summary: {
1556
- regressions: changes.filter((c) => c.type === "regression").length,
1557
- improvements: changes.filter((c) => c.type === "improvement").length,
1558
- unchanged: changes.filter((c) => c.type === "unchanged").length,
1559
- newAudits: changes.filter((c) => c.type === "new").length,
1560
- removedAudits: changes.filter((c) => c.type === "removed").length
1572
+ regressions: changes.filter((c2) => c2.type === "regression").length,
1573
+ improvements: changes.filter((c2) => c2.type === "improvement").length,
1574
+ unchanged: changes.filter((c2) => c2.type === "unchanged").length,
1575
+ newAudits: changes.filter((c2) => c2.type === "new").length,
1576
+ removedAudits: changes.filter((c2) => c2.type === "removed").length
1561
1577
  }
1562
1578
  };
1563
1579
  }