superjs-core 0.4.4 → 0.6.0

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
@@ -1018,7 +1018,7 @@ function truncate(str, maxLength, suffix = "...") {
1018
1018
  return str.slice(0, Math.max(0, maxLength - suffix.length)) + suffix;
1019
1019
  }
1020
1020
  function template(str, data) {
1021
- return str.replace(/\{\{(\w+)\}\}/g, (_, key) => {
1021
+ return str.replace(/\{\{(\w+)\}\}/g, (_2, key) => {
1022
1022
  const value = data[key];
1023
1023
  return value !== void 0 ? String(value) : `{{${key}}}`;
1024
1024
  });
@@ -1118,7 +1118,7 @@ function sleep(ms) {
1118
1118
  }
1119
1119
  async function timeout(promise, ms, errorMessage) {
1120
1120
  let timer;
1121
- const timeoutPromise = new Promise((_, reject) => {
1121
+ const timeoutPromise = new Promise((_2, reject) => {
1122
1122
  timer = setTimeout(() => reject(new Error(errorMessage ?? `Promise timed out after ${ms}ms`)), ms);
1123
1123
  });
1124
1124
  try {
@@ -1668,27 +1668,40 @@ async function scanProject(config) {
1668
1668
  }
1669
1669
 
1670
1670
  // src/dep-exray/reporter/index.ts
1671
- import pc from "picocolors";
1671
+ var _ = {
1672
+ reset: "\x1B[0m",
1673
+ bold: "\x1B[1m",
1674
+ dim: "\x1B[2m",
1675
+ red: "\x1B[31m",
1676
+ green: "\x1B[32m",
1677
+ yellow: "\x1B[33m",
1678
+ blue: "\x1B[34m",
1679
+ cyan: "\x1B[36m",
1680
+ white: "\x1B[37m"
1681
+ };
1682
+ function style(text, codes) {
1683
+ return codes.join("") + text + _.reset;
1684
+ }
1672
1685
  function severityColor(severity) {
1673
1686
  switch (severity) {
1674
1687
  case "critical":
1675
- return pc.bold(pc.red(severity.toUpperCase()));
1688
+ return style(severity.toUpperCase(), [_.bold, _.red]);
1676
1689
  case "high":
1677
- return pc.red(severity.toUpperCase());
1690
+ return style(severity.toUpperCase(), [_.red]);
1678
1691
  case "medium":
1679
- return pc.yellow(severity.toUpperCase());
1692
+ return style(severity.toUpperCase(), [_.yellow]);
1680
1693
  case "low":
1681
- return pc.dim(severity.toUpperCase());
1694
+ return style(severity.toUpperCase(), [_.dim]);
1682
1695
  }
1683
1696
  }
1684
1697
  function confidenceIcon(confidence) {
1685
1698
  switch (confidence) {
1686
1699
  case "high":
1687
- return pc.green("\u25CF");
1700
+ return style("\u25CF", [_.green]);
1688
1701
  case "medium":
1689
- return pc.yellow("\u25CF");
1702
+ return style("\u25CF", [_.yellow]);
1690
1703
  case "low":
1691
- return pc.red("\u25CF");
1704
+ return style("\u25CF", [_.red]);
1692
1705
  }
1693
1706
  }
1694
1707
  function generateReport(result, jsonOutput) {
@@ -1696,46 +1709,47 @@ function generateReport(result, jsonOutput) {
1696
1709
  return JSON.stringify(result, null, 2);
1697
1710
  }
1698
1711
  const lines = [];
1699
- lines.push(pc.bold(pc.cyan(`\u250C${"\u2500".repeat(58)}\u2510`)));
1700
- lines.push(pc.bold(pc.cyan(`\u2502${" ".repeat(18)}dep-exray Report${" ".repeat(21)}\u2502`)));
1701
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1702
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4E6} PROJECT:")} ${pc.bold(result.projectName)}${" ".repeat(Math.max(1, 47 - result.projectName.length))}\u2502`)));
1703
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4CA} DEPENDENCIES:")} ${pc.bold(String(result.directDeps))} direct + ${pc.bold(String(result.transitiveDeps))} transitive${" ".repeat(Math.max(1, 27 - String(result.transitiveDeps).length))}\u2502`)));
1704
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.white("\u{1F4BE} TOTAL SIZE:")} ${pc.bold(result.totalEstimatedSize)}${" ".repeat(Math.max(1, 42 - result.totalEstimatedSize.length))}\u2502`)));
1705
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1712
+ const t = (text, codes = [_.cyan]) => style(text, [_.bold, ...codes]);
1713
+ lines.push(t(`\u250C${"\u2500".repeat(58)}\u2510`));
1714
+ lines.push(t(`\u2502${" ".repeat(18)}dep-exray Report${" ".repeat(21)}\u2502`));
1715
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1716
+ lines.push(t(`\u2502 ${style("\u{1F4E6} PROJECT:", [_.white])} ${style(result.projectName, [_.bold])}${" ".repeat(Math.max(1, 47 - result.projectName.length))}\u2502`));
1717
+ lines.push(t(`\u2502 ${style("\u{1F4CA} DEPENDENCIES:", [_.white])} ${style(String(result.directDeps), [_.bold])} direct + ${style(String(result.transitiveDeps), [_.bold])} transitive${" ".repeat(Math.max(1, 27 - String(result.transitiveDeps).length))}\u2502`));
1718
+ lines.push(t(`\u2502 ${style("\u{1F4BE} TOTAL SIZE:", [_.white])} ${style(result.totalEstimatedSize, [_.bold])}${" ".repeat(Math.max(1, 42 - result.totalEstimatedSize.length))}\u2502`));
1719
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1706
1720
  if (result.highImpactReplacements.length > 0) {
1707
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.green("\u{1F7E2}")} ${pc.bold(pc.green("HIGH IMPACT REPLACEMENTS"))}${" ".repeat(23)}\u2502`)));
1721
+ lines.push(t(`\u2502 ${style("\u{1F7E2}", [_.green])} ${style("HIGH IMPACT REPLACEMENTS", [_.bold, _.green])}${" ".repeat(23)}\u2502`));
1708
1722
  for (const item of result.highImpactReplacements) {
1709
- const autoPr = item.autoPrReady ? pc.green("\u2713 Auto-PR ready") : pc.dim("Manual review needed");
1723
+ const autoPr = item.autoPrReady ? style("\u2713 Auto-PR ready", [_.green]) : style("Manual review needed", [_.dim]);
1710
1724
  const confIcon = confidenceIcon(item.confidence);
1711
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1712
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u2717")} ${pc.bold(item.packageName)} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`)));
1713
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${pc.cyan(item.replacement)}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`)));
1714
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2514\u2500")} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`)));
1725
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1726
+ lines.push(t(`\u2502 ${style("\u2717", [_.red])} ${style(item.packageName, [_.bold])} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`));
1727
+ lines.push(t(`\u2502 ${style("\u2192", [_.dim])} ${style(item.replacement, [_.cyan])}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`));
1728
+ lines.push(t(`\u2502 ${style("\u2514\u2500", [_.dim])} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`));
1715
1729
  }
1716
1730
  }
1717
1731
  if (result.mediumImpactReplacements.length > 0) {
1718
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1719
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.yellow("\u{1F7E1}")} ${pc.bold(pc.yellow("MEDIUM IMPACT REPLACEMENTS"))}${" ".repeat(20)}\u2502`)));
1732
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1733
+ lines.push(t(`\u2502 ${style("\u{1F7E1}", [_.yellow])} ${style("MEDIUM IMPACT REPLACEMENTS", [_.bold, _.yellow])}${" ".repeat(20)}\u2502`));
1720
1734
  for (const item of result.mediumImpactReplacements) {
1721
- const autoPr = item.autoPrReady ? pc.green("\u2713 Auto-PR ready") : pc.dim("Manual review needed");
1735
+ const autoPr = item.autoPrReady ? style("\u2713 Auto-PR ready", [_.green]) : style("Manual review needed", [_.dim]);
1722
1736
  const confIcon = confidenceIcon(item.confidence);
1723
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1724
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u2717")} ${pc.bold(item.packageName)} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`)));
1725
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${pc.cyan(item.replacement)}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`)));
1726
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2514\u2500")} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`)));
1737
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1738
+ lines.push(t(`\u2502 ${style("\u2717", [_.red])} ${style(item.packageName, [_.bold])} (${item.estimatedSizeReduction})${" ".repeat(Math.max(1, 38 - item.estimatedSizeReduction.length))}\u2502`));
1739
+ lines.push(t(`\u2502 ${style("\u2192", [_.dim])} ${style(item.replacement, [_.cyan])}${" ".repeat(Math.max(1, 51 - item.replacement.length))}\u2502`));
1740
+ lines.push(t(`\u2502 ${style("\u2514\u2500", [_.dim])} ${autoPr} ${confIcon} ${item.confidence}${" ".repeat(Math.max(1, 35))}\u2502`));
1727
1741
  }
1728
1742
  }
1729
1743
  if (result.securityIssues.length > 0) {
1730
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1731
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.red("\u{1F534}")} ${pc.bold(pc.red("SECURITY ISSUES"))}${" ".repeat(33)}\u2502`)));
1744
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1745
+ lines.push(t(`\u2502 ${style("\u{1F534}", [_.red])} ${style("SECURITY ISSUES", [_.bold, _.red])}${" ".repeat(33)}\u2502`));
1732
1746
  for (const issue of result.securityIssues) {
1733
- lines.push(pc.bold(pc.cyan(`\u251C${"\u2500".repeat(58)}\u2524`)));
1734
- lines.push(pc.bold(pc.cyan(`\u2502 ${severityColor(issue.severity)} ${pc.bold(issue.cveId)} in ${issue.packageName}${" ".repeat(Math.max(1, 40 - issue.packageName.length))}\u2502`)));
1735
- lines.push(pc.bold(pc.cyan(`\u2502 ${pc.dim("\u2192")} ${issue.fix}${" ".repeat(Math.max(1, 52 - issue.fix.length))}\u2502`)));
1747
+ lines.push(t(`\u251C${"\u2500".repeat(58)}\u2524`));
1748
+ lines.push(t(`\u2502 ${severityColor(issue.severity)} ${style(issue.cveId, [_.bold])} in ${issue.packageName}${" ".repeat(Math.max(1, 40 - issue.packageName.length))}\u2502`));
1749
+ lines.push(t(`\u2502 ${style("\u2192", [_.dim])} ${issue.fix}${" ".repeat(Math.max(1, 52 - issue.fix.length))}\u2502`));
1736
1750
  }
1737
1751
  }
1738
- lines.push(pc.bold(pc.cyan(`\u2514${"\u2500".repeat(58)}\u2518`)));
1752
+ lines.push(t(`\u2514${"\u2500".repeat(58)}\u2518`));
1739
1753
  return lines.join("\n");
1740
1754
  }
1741
1755