@code-pushup/cli 0.11.0 → 0.11.2

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/index.js +131 -131
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1526,78 +1526,15 @@ var verboseUtils = (verbose) => ({
1526
1526
  exec: getExecVerbose(verbose)
1527
1527
  });
1528
1528
 
1529
- // packages/core/src/lib/implementation/persist.ts
1530
- import { mkdir as mkdir2, stat as stat2, writeFile } from "node:fs/promises";
1531
- import { join as join2 } from "node:path";
1532
- var PersistDirError = class extends Error {
1533
- constructor(outputDir) {
1534
- super(`outPath: ${outputDir} is no directory.`);
1535
- }
1536
- };
1537
- var PersistError = class extends Error {
1538
- constructor(reportPath) {
1539
- super(`fileName: ${reportPath} could not be saved.`);
1540
- }
1541
- };
1542
- async function persistReport(report, options2) {
1543
- const { outputDir, filename, format } = options2;
1544
- const sortedScoredReport = sortReport(scoreReport(report));
1545
- console.info(generateStdoutSummary(sortedScoredReport));
1546
- const results = await Promise.all(
1547
- format.map(async (reportType) => {
1548
- switch (reportType) {
1549
- case "json":
1550
- return {
1551
- format: "json",
1552
- content: JSON.stringify(report, null, 2)
1553
- };
1554
- case "md":
1555
- const commitData = await getLatestCommit();
1556
- validateCommitData(commitData);
1557
- return {
1558
- format: "md",
1559
- content: generateMdReport(sortedScoredReport, commitData)
1560
- };
1561
- }
1562
- })
1563
- );
1564
- if (!await directoryExists(outputDir)) {
1565
- try {
1566
- await mkdir2(outputDir, { recursive: true });
1567
- } catch (error) {
1568
- console.warn(error);
1569
- throw new PersistDirError(outputDir);
1570
- }
1571
- }
1572
- return Promise.allSettled(
1573
- results.map(
1574
- (result) => persistResult(
1575
- join2(outputDir, `${filename}.${result.format}`),
1576
- result.content
1577
- )
1578
- )
1579
- );
1580
- }
1581
- function validateCommitData(commitData) {
1582
- if (!commitData) {
1583
- console.warn("no commit data available");
1584
- }
1585
- }
1586
- async function persistResult(reportPath, content) {
1587
- return writeFile(reportPath, content).then(() => stat2(reportPath)).then((stats) => [reportPath, stats.size]).catch((error) => {
1588
- console.warn(error);
1589
- throw new PersistError(reportPath);
1590
- });
1591
- }
1592
- function logPersistedResults(persistResults) {
1593
- logMultipleFileResults(persistResults, "Generated reports");
1594
- }
1529
+ // packages/core/package.json
1530
+ var name = "@code-pushup/core";
1531
+ var version = "0.11.2";
1595
1532
 
1596
1533
  // packages/core/src/lib/implementation/execute-plugin.ts
1597
1534
  import chalk4 from "chalk";
1598
1535
 
1599
1536
  // packages/core/src/lib/implementation/runner.ts
1600
- import { join as join3 } from "node:path";
1537
+ import { join as join2 } from "node:path";
1601
1538
  async function executeRunnerConfig(cfg, onProgress) {
1602
1539
  const { args, command, outputFile, outputTransform } = cfg;
1603
1540
  const { duration, date } = await executeProcess({
@@ -1605,7 +1542,7 @@ async function executeRunnerConfig(cfg, onProgress) {
1605
1542
  args,
1606
1543
  observer: { onStdout: onProgress }
1607
1544
  });
1608
- const outputs = await readJsonFile(join3(process.cwd(), outputFile));
1545
+ const outputs = await readJsonFile(join2(process.cwd(), outputFile));
1609
1546
  const audits = outputTransform ? await outputTransform(outputs) : outputs;
1610
1547
  return {
1611
1548
  duration,
@@ -1703,10 +1640,6 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
1703
1640
  });
1704
1641
  }
1705
1642
 
1706
- // packages/core/package.json
1707
- var name = "@code-pushup/core";
1708
- var version = "0.11.0";
1709
-
1710
1643
  // packages/core/src/lib/implementation/collect.ts
1711
1644
  async function collect(options2) {
1712
1645
  const { plugins, categories } = options2;
@@ -1723,6 +1656,132 @@ async function collect(options2) {
1723
1656
  };
1724
1657
  }
1725
1658
 
1659
+ // packages/core/src/lib/implementation/persist.ts
1660
+ import { mkdir as mkdir2, stat as stat2, writeFile } from "node:fs/promises";
1661
+ import { join as join3 } from "node:path";
1662
+ var PersistDirError = class extends Error {
1663
+ constructor(outputDir) {
1664
+ super(`outPath: ${outputDir} is no directory.`);
1665
+ }
1666
+ };
1667
+ var PersistError = class extends Error {
1668
+ constructor(reportPath) {
1669
+ super(`fileName: ${reportPath} could not be saved.`);
1670
+ }
1671
+ };
1672
+ async function persistReport(report, options2) {
1673
+ const { outputDir, filename, format } = options2;
1674
+ const sortedScoredReport = sortReport(scoreReport(report));
1675
+ console.info(generateStdoutSummary(sortedScoredReport));
1676
+ const results = await Promise.all(
1677
+ format.map(async (reportType) => {
1678
+ switch (reportType) {
1679
+ case "json":
1680
+ return {
1681
+ format: "json",
1682
+ content: JSON.stringify(report, null, 2)
1683
+ };
1684
+ case "md":
1685
+ const commitData = await getLatestCommit();
1686
+ validateCommitData(commitData);
1687
+ return {
1688
+ format: "md",
1689
+ content: generateMdReport(sortedScoredReport, commitData)
1690
+ };
1691
+ }
1692
+ })
1693
+ );
1694
+ if (!await directoryExists(outputDir)) {
1695
+ try {
1696
+ await mkdir2(outputDir, { recursive: true });
1697
+ } catch (error) {
1698
+ console.warn(error);
1699
+ throw new PersistDirError(outputDir);
1700
+ }
1701
+ }
1702
+ return Promise.allSettled(
1703
+ results.map(
1704
+ (result) => persistResult(
1705
+ join3(outputDir, `${filename}.${result.format}`),
1706
+ result.content
1707
+ )
1708
+ )
1709
+ );
1710
+ }
1711
+ function validateCommitData(commitData) {
1712
+ if (!commitData) {
1713
+ console.warn("no commit data available");
1714
+ }
1715
+ }
1716
+ async function persistResult(reportPath, content) {
1717
+ return writeFile(reportPath, content).then(() => stat2(reportPath)).then((stats) => [reportPath, stats.size]).catch((error) => {
1718
+ console.warn(error);
1719
+ throw new PersistError(reportPath);
1720
+ });
1721
+ }
1722
+ function logPersistedResults(persistResults) {
1723
+ logMultipleFileResults(persistResults, "Generated reports");
1724
+ }
1725
+
1726
+ // packages/core/src/lib/normalize.ts
1727
+ var normalizePersistConfig = (cfg) => ({
1728
+ outputDir: PERSIST_OUTPUT_DIR,
1729
+ filename: PERSIST_FILENAME,
1730
+ format: PERSIST_FORMAT,
1731
+ ...cfg
1732
+ });
1733
+
1734
+ // packages/core/src/lib/collect-and-persist.ts
1735
+ async function collectAndPersistReports(options2) {
1736
+ const { exec } = verboseUtils(options2.verbose);
1737
+ const report = await collect(options2);
1738
+ const persist = normalizePersistConfig(options2.persist);
1739
+ const persistResults = await persistReport(report, persist);
1740
+ exec(() => {
1741
+ logPersistedResults(persistResults);
1742
+ });
1743
+ report.plugins.forEach((plugin) => {
1744
+ pluginReportSchema.parse(plugin);
1745
+ });
1746
+ }
1747
+
1748
+ // packages/core/src/lib/implementation/read-rc-file.ts
1749
+ import { join as join4 } from "node:path";
1750
+ var ConfigPathError = class extends Error {
1751
+ constructor(configPath) {
1752
+ super(`Provided path '${configPath}' is not valid.`);
1753
+ }
1754
+ };
1755
+ async function readRcByPath(filepath) {
1756
+ if (filepath.length === 0) {
1757
+ throw new Error("The path to the configuration file is empty.");
1758
+ }
1759
+ if (!await fileExists(filepath)) {
1760
+ throw new ConfigPathError(filepath);
1761
+ }
1762
+ const cfg = await importEsmModule({ filepath });
1763
+ return coreConfigSchema.parse(cfg);
1764
+ }
1765
+ async function autoloadRc() {
1766
+ let ext = "";
1767
+ for (const extension of SUPPORTED_CONFIG_FILE_FORMATS) {
1768
+ const path = `${CONFIG_FILE_NAME}.${extension}`;
1769
+ const exists2 = await fileExists(path);
1770
+ if (exists2) {
1771
+ ext = extension;
1772
+ break;
1773
+ }
1774
+ }
1775
+ if (!ext) {
1776
+ throw new Error(
1777
+ `No file ${CONFIG_FILE_NAME}.(${SUPPORTED_CONFIG_FILE_FORMATS.join(
1778
+ "|"
1779
+ )}) present in ${process.cwd()}`
1780
+ );
1781
+ }
1782
+ return readRcByPath(join4(process.cwd(), `${CONFIG_FILE_NAME}.${ext}`));
1783
+ }
1784
+
1726
1785
  // packages/core/src/lib/upload.ts
1727
1786
  import { uploadToPortal } from "@code-pushup/portal-client";
1728
1787
 
@@ -1812,14 +1871,6 @@ function transformSeverity(severity) {
1812
1871
  }
1813
1872
  }
1814
1873
 
1815
- // packages/core/src/lib/normalize.ts
1816
- var normalizePersistConfig = (cfg) => ({
1817
- outputDir: PERSIST_OUTPUT_DIR,
1818
- filename: PERSIST_FILENAME,
1819
- format: PERSIST_FORMAT,
1820
- ...cfg
1821
- });
1822
-
1823
1874
  // packages/core/src/lib/upload.ts
1824
1875
  async function upload(options2, uploadFn = uploadToPortal) {
1825
1876
  const persist = normalizePersistConfig(options2.persist);
@@ -1844,57 +1895,6 @@ async function upload(options2, uploadFn = uploadToPortal) {
1844
1895
  return uploadFn({ apiKey, server, data, timeout });
1845
1896
  }
1846
1897
 
1847
- // packages/core/src/lib/collect-and-persist.ts
1848
- async function collectAndPersistReports(options2) {
1849
- const { exec } = verboseUtils(options2.verbose);
1850
- const report = await collect(options2);
1851
- const persist = normalizePersistConfig(options2.persist);
1852
- const persistResults = await persistReport(report, persist);
1853
- exec(() => {
1854
- logPersistedResults(persistResults);
1855
- });
1856
- report.plugins.forEach((plugin) => {
1857
- pluginReportSchema.parse(plugin);
1858
- });
1859
- }
1860
-
1861
- // packages/core/src/lib/implementation/read-rc-file.ts
1862
- import { join as join4 } from "node:path";
1863
- var ConfigPathError = class extends Error {
1864
- constructor(configPath) {
1865
- super(`Provided path '${configPath}' is not valid.`);
1866
- }
1867
- };
1868
- async function readRcByPath(filepath) {
1869
- if (filepath.length === 0) {
1870
- throw new Error("The path to the configuration file is empty.");
1871
- }
1872
- if (!await fileExists(filepath)) {
1873
- throw new ConfigPathError(filepath);
1874
- }
1875
- const cfg = await importEsmModule({ filepath });
1876
- return coreConfigSchema.parse(cfg);
1877
- }
1878
- async function autoloadRc() {
1879
- let ext = "";
1880
- for (const extension of SUPPORTED_CONFIG_FILE_FORMATS) {
1881
- const path = `${CONFIG_FILE_NAME}.${extension}`;
1882
- const exists2 = await fileExists(path);
1883
- if (exists2) {
1884
- ext = extension;
1885
- break;
1886
- }
1887
- }
1888
- if (!ext) {
1889
- throw new Error(
1890
- `No file ${CONFIG_FILE_NAME}.(${SUPPORTED_CONFIG_FILE_FORMATS.join(
1891
- "|"
1892
- )}) present in ${process.cwd()}`
1893
- );
1894
- }
1895
- return readRcByPath(join4(process.cwd(), `${CONFIG_FILE_NAME}.${ext}`));
1896
- }
1897
-
1898
1898
  // packages/cli/src/lib/constants.ts
1899
1899
  var CLI_NAME = "Code PushUp CLI";
1900
1900
  var CLI_SCRIPT_NAME = "code-pushup";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "code-pushup": "index.js"