@wzyjs/cli 0.3.18 → 0.3.20

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.
Files changed (2) hide show
  1. package/dist/index.js +266 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1396,7 +1396,6 @@ var walker = (object, identities, superJson, dedupe, path2 = [], objectsInThisPa
1396
1396
  }
1397
1397
  return result;
1398
1398
  };
1399
-
1400
1399
  // ../../node_modules/is-what/dist/getType.js
1401
1400
  function getType2(payload) {
1402
1401
  return Object.prototype.toString.call(payload).slice(8, -1);
@@ -1534,7 +1533,7 @@ var registerSymbol = SuperJSON.registerSymbol;
1534
1533
  var allowErrorProps = SuperJSON.allowErrorProps;
1535
1534
 
1536
1535
  // src/commands/scrap/juejin.ts
1537
- var url = "http://localhost:3000";
1536
+ var url = "https://app.zhenyu.pro";
1538
1537
  var juejin_default = async (procedure, data) => {
1539
1538
  if (!procedure) {
1540
1539
  console.error("\u274C \u7F3A\u5C11 procedure \u53C2\u6570");
@@ -1604,7 +1603,7 @@ var juejin_default = async (procedure, data) => {
1604
1603
 
1605
1604
  // src/commands/scrap/rss.ts
1606
1605
  import { fetch as fetch2 } from "undici";
1607
- var url2 = "http://localhost:3000";
1606
+ var url2 = "https://app.zhenyu.pro";
1608
1607
  var rss_default = async (procedure, data) => {
1609
1608
  if (!procedure) {
1610
1609
  console.error("\u274C \u7F3A\u5C11 procedure \u53C2\u6570");
@@ -1695,11 +1694,275 @@ var scrap_default = (cli) => {
1695
1694
  });
1696
1695
  };
1697
1696
 
1697
+ // src/commands/ts-error/script.ts
1698
+ import { exec as exec2 } from "child_process";
1699
+ import path2 from "path";
1700
+ import fs2 from "fs";
1701
+ function execCommand2(command, cwd) {
1702
+ return new Promise((resolve, reject) => {
1703
+ exec2(command, { cwd }, (err, stdout, stderr) => {
1704
+ if (err) {
1705
+ resolve(stderr || stdout);
1706
+ return;
1707
+ }
1708
+ resolve(stdout);
1709
+ });
1710
+ });
1711
+ }
1712
+ function filterGeneratedErrors(output) {
1713
+ const lines = output.split(`
1714
+ `).filter((line) => line.trim());
1715
+ const filterPatterns = [
1716
+ "src/api/generated/",
1717
+ "node_modules/"
1718
+ ];
1719
+ const errors = [];
1720
+ for (const line of lines) {
1721
+ const shouldFilter = filterPatterns.some((pattern) => line.includes(pattern));
1722
+ if (shouldFilter) {
1723
+ continue;
1724
+ }
1725
+ const match = line.match(/^(.+?)\((\d+),(\d+)\):\s*error\s+(\w+):\s*(.+)$/m);
1726
+ if (match) {
1727
+ errors.push({
1728
+ file: match[1],
1729
+ line: parseInt(match[2]),
1730
+ column: parseInt(match[3]),
1731
+ code: match[4],
1732
+ message: match[5]
1733
+ });
1734
+ }
1735
+ }
1736
+ return errors;
1737
+ }
1738
+ function escapeHtml(text) {
1739
+ const map = {
1740
+ "&": "&",
1741
+ "<": "&lt;",
1742
+ ">": "&gt;",
1743
+ '"': "&quot;",
1744
+ "'": "&#039;"
1745
+ };
1746
+ return text.replace(/[&<>"']/g, (m) => map[m]);
1747
+ }
1748
+ function generateHTML(errors, projectName) {
1749
+ const errorsHTML = errors.map((error, index) => `
1750
+ <div class="error-item">
1751
+ <div class="error-location">
1752
+ <span class="file-path">${escapeHtml(error.file)}</span>
1753
+ <span class="line-col">\u884C ${error.line}, \u5217 ${error.column}</span>
1754
+ </div>
1755
+ <div class="error-code">${escapeHtml(error.code)}</div>
1756
+ <div class="error-message">${escapeHtml(error.message)}</div>
1757
+ </div>
1758
+ `).join("");
1759
+ const statusClass = errors.length > 0 ? "has-errors" : "no-errors";
1760
+ const statusText = errors.length > 0 ? `\u53D1\u73B0 ${errors.length} \u4E2A\u9519\u8BEF` : "\u672A\u53D1\u73B0 TypeScript \u9519\u8BEF";
1761
+ return `<!DOCTYPE html>
1762
+ <html lang="zh-CN">
1763
+ <head>
1764
+ <meta charset="UTF-8">
1765
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1766
+ <title>TypeScript \u9519\u8BEF - ${escapeHtml(projectName)}</title>
1767
+ <style>
1768
+ * {
1769
+ margin: 0;
1770
+ padding: 0;
1771
+ box-sizing: border-box;
1772
+ }
1773
+
1774
+ body {
1775
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
1776
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
1777
+ min-height: 100vh;
1778
+ padding: 40px 20px;
1779
+ }
1780
+
1781
+ .container {
1782
+ max-width: 1200px;
1783
+ margin: 0 auto;
1784
+ }
1785
+
1786
+ .header {
1787
+ background: white;
1788
+ border-radius: 16px;
1789
+ padding: 30px;
1790
+ margin-bottom: 30px;
1791
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
1792
+ }
1793
+
1794
+ .status {
1795
+ display: flex;
1796
+ align-items: center;
1797
+ gap: 15px;
1798
+ margin-bottom: 20px;
1799
+ }
1800
+
1801
+ .status-icon {
1802
+ font-size: 48px;
1803
+ }
1804
+
1805
+ .status-text {
1806
+ font-size: 28px;
1807
+ font-weight: bold;
1808
+ color: #2c3e50;
1809
+ }
1810
+
1811
+ .error-count {
1812
+ color: #7f8c8d;
1813
+ font-size: 16px;
1814
+ margin-top: 5px;
1815
+ }
1816
+
1817
+ .error-list {
1818
+ display: flex;
1819
+ flex-direction: column;
1820
+ gap: 15px;
1821
+ }
1822
+
1823
+ .error-item {
1824
+ background: white;
1825
+ border-radius: 12px;
1826
+ padding: 20px;
1827
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
1828
+ border-left: 4px solid #e74c3c;
1829
+ transition: transform 0.2s, box-shadow 0.2s;
1830
+ }
1831
+
1832
+ .error-item:hover {
1833
+ transform: translateY(-2px);
1834
+ box-shadow: 0 6px 30px rgba(0, 0, 0, 0.15);
1835
+ }
1836
+
1837
+ .error-location {
1838
+ display: flex;
1839
+ justify-content: space-between;
1840
+ align-items: center;
1841
+ margin-bottom: 10px;
1842
+ padding-bottom: 10px;
1843
+ border-bottom: 1px solid #ecf0f1;
1844
+ }
1845
+
1846
+ .file-path {
1847
+ font-weight: 600;
1848
+ color: #2c3e50;
1849
+ font-size: 14px;
1850
+ }
1851
+
1852
+ .line-col {
1853
+ background: #ecf0f1;
1854
+ padding: 4px 10px;
1855
+ border-radius: 6px;
1856
+ font-size: 12px;
1857
+ color: #7f8c8d;
1858
+ }
1859
+
1860
+ .error-code {
1861
+ display: inline-block;
1862
+ background: #e74c3c;
1863
+ color: white;
1864
+ padding: 4px 12px;
1865
+ border-radius: 6px;
1866
+ font-size: 12px;
1867
+ font-weight: 600;
1868
+ margin-bottom: 10px;
1869
+ }
1870
+
1871
+ .error-message {
1872
+ color: #34495e;
1873
+ line-height: 1.6;
1874
+ font-size: 14px;
1875
+ }
1876
+
1877
+ .no-errors .status-icon {
1878
+ color: #27ae60;
1879
+ }
1880
+
1881
+ .has-errors .status-icon {
1882
+ color: #e74c3c;
1883
+ }
1884
+
1885
+ .project-name {
1886
+ color: #7f8c8d;
1887
+ font-size: 14px;
1888
+ margin-top: 10px;
1889
+ }
1890
+ </style>
1891
+ </head>
1892
+ <body>
1893
+ <div class="container">
1894
+ <div class="header">
1895
+ <div class="status ${statusClass}">
1896
+ <span class="status-icon">${errors.length > 0 ? "\u274C" : "\u2705"}</span>
1897
+ <div>
1898
+ <div class="status-text">${statusText}</div>
1899
+ <div class="project-name">${escapeHtml(projectName)}</div>
1900
+ </div>
1901
+ </div>
1902
+ </div>
1903
+
1904
+ ${errors.length > 0 ? `
1905
+ <div class="error-list">
1906
+ ${errorsHTML}
1907
+ </div>
1908
+ ` : `
1909
+ <div class="error-item no-errors">
1910
+ <div class="error-message">\uD83C\uDF89 \u5E72\u5F97\u597D\uFF01\u9879\u76EE\u4E2D\u6CA1\u6709 TypeScript \u9519\u8BEF</div>
1911
+ </div>
1912
+ `}
1913
+ </div>
1914
+ </body>
1915
+ </html>`;
1916
+ }
1917
+ var script_default3 = async (options) => {
1918
+ const cwd = process.cwd();
1919
+ const tsconfigPath = path2.join(cwd, "tsconfig.json");
1920
+ if (!fs2.existsSync(tsconfigPath)) {
1921
+ console.log("\u672A\u627E\u5230 tsconfig.json \u6587\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5728\u9879\u76EE\u6839\u76EE\u5F55\u6267\u884C\u6B64\u547D\u4EE4");
1922
+ return;
1923
+ }
1924
+ const isHtmlMode = options?.html || options?.web;
1925
+ console.log(`\u6B63\u5728\u68C0\u67E5 TypeScript \u62A5\u9519...
1926
+ `);
1927
+ const output = await execCommand2("tsc --noEmit", cwd);
1928
+ if (isHtmlMode) {
1929
+ const projectName = path2.basename(cwd);
1930
+ const outputPath = path2.join(cwd, "ts-errors.html");
1931
+ const errors = filterGeneratedErrors(output);
1932
+ const html = generateHTML(errors, projectName);
1933
+ fs2.writeFileSync(outputPath, html, "utf-8");
1934
+ console.log(`\u2705 \u5DF2\u751F\u6210\u9519\u8BEF\u62A5\u544A: ${outputPath}`);
1935
+ } else {
1936
+ if (!output) {
1937
+ console.log("\u2705 \u672A\u53D1\u73B0 TypeScript \u9519\u8BEF");
1938
+ return;
1939
+ }
1940
+ const errors = filterGeneratedErrors(output);
1941
+ if (errors.length === 0) {
1942
+ console.log("\u2705 \u672A\u53D1\u73B0 TypeScript \u9519\u8BEF\uFF08\u5DF2\u8FC7\u6EE4\u81EA\u52A8\u751F\u6210\u76EE\u5F55\uFF09");
1943
+ return;
1944
+ }
1945
+ console.log(`\u274C \u53D1\u73B0 ${errors.length} \u4E2A TypeScript \u9519\u8BEF\uFF1A
1946
+ `);
1947
+ errors.forEach((error, index) => {
1948
+ console.log(`${index + 1}. ${error.file}:${error.line}:${error.column}`);
1949
+ console.log(` ${error.code}: ${error.message}`);
1950
+ console.log();
1951
+ });
1952
+ }
1953
+ };
1954
+
1955
+ // src/commands/ts-error/index.ts
1956
+ var ts_error_default = (cli) => {
1957
+ cli.command("ts-error", "\u83B7\u53D6\u5F53\u524D\u9879\u76EE\u7684 TypeScript \u62A5\u9519").option("--html", "\u751F\u6210 HTML \u7F51\u9875\u62A5\u544A").option("--web", "\u751F\u6210 HTML \u7F51\u9875\u62A5\u544A\uFF08--html \u7684\u522B\u540D\uFF09").action(script_default3);
1958
+ };
1959
+
1698
1960
  // src/index.ts
1699
1961
  var cli = dist_default();
1700
1962
  merge_default(cli);
1701
1963
  summary_default(cli);
1702
1964
  scrap_default(cli);
1965
+ ts_error_default(cli);
1703
1966
  cli.help();
1704
1967
  cli.version("0.0.5");
1705
1968
  cli.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/cli",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "main": "index.js",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "cac": "^6.7.14",
21
- "fs-extra": "^10.1.0",
21
+ "fs-extra": "^11.3.4",
22
22
  "superjson": "^2.2.6",
23
23
  "undici": "^6.0.0"
24
24
  },
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "10e941a36df74182a45c73e7e074fc0c5ed5b669"
31
+ "gitHead": "75ecd6752ea11d3e5d51ef76cd4393dca75c358b"
32
32
  }