@code-pushup/cli 0.16.5 → 0.16.7

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 +70 -51
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -190,7 +190,7 @@ var auditSchema = z2.object({
190
190
  );
191
191
  var pluginAuditsSchema = z2.array(auditSchema, {
192
192
  description: "List of audits maintained in a plugin"
193
- }).refine(
193
+ }).min(1).refine(
194
194
  (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
195
195
  (auditMetadata) => ({
196
196
  message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
@@ -509,7 +509,7 @@ var pluginReportSchema = pluginMetaSchema.merge(
509
509
  })
510
510
  ).merge(
511
511
  z12.object({
512
- audits: z12.array(auditReportSchema),
512
+ audits: z12.array(auditReportSchema).min(1),
513
513
  groups: z12.array(groupSchema).optional()
514
514
  })
515
515
  ).refine(
@@ -1564,7 +1564,7 @@ function link2(text) {
1564
1564
 
1565
1565
  // packages/core/package.json
1566
1566
  var name = "@code-pushup/core";
1567
- var version = "0.16.5";
1567
+ var version = "0.16.7";
1568
1568
 
1569
1569
  // packages/core/src/lib/implementation/execute-plugin.ts
1570
1570
  import chalk5 from "chalk";
@@ -1814,84 +1814,103 @@ async function autoloadRc() {
1814
1814
  }
1815
1815
 
1816
1816
  // packages/core/src/lib/upload.ts
1817
- import { uploadToPortal } from "@code-pushup/portal-client";
1817
+ import {
1818
+ uploadToPortal
1819
+ } from "@code-pushup/portal-client";
1818
1820
 
1819
- // packages/core/src/lib/implementation/json-to-gql.ts
1821
+ // packages/core/src/lib/implementation/report-to-gql.ts
1820
1822
  import {
1821
- CategoryConfigRefType,
1822
- IssueSourceType,
1823
- IssueSeverity as PortalIssueSeverity
1823
+ CategoryConfigRefType as PortalCategoryRefType,
1824
+ IssueSeverity as PortalIssueSeverity,
1825
+ IssueSourceType as PortalIssueSourceType
1824
1826
  } from "@code-pushup/portal-client";
1825
- function jsonReportToGql(report) {
1827
+ function reportToGQL(report) {
1826
1828
  return {
1827
1829
  packageName: report.packageName,
1828
1830
  packageVersion: report.version,
1829
1831
  commandStartDate: report.date,
1830
1832
  commandDuration: report.duration,
1831
- plugins: pluginReportsToGql(report.plugins),
1832
- categories: categoryConfigsToGql(toArray(report.categories))
1833
+ plugins: report.plugins.map(pluginToGQL),
1834
+ categories: report.categories.map(categoryToGQL)
1833
1835
  };
1834
1836
  }
1835
- function pluginReportsToGql(plugins) {
1836
- return plugins.map((plugin) => ({
1837
- audits: auditReportsToGql(plugin.audits),
1838
- description: plugin.description,
1839
- docsUrl: plugin.docsUrl,
1840
- groups: plugin.groups?.map((group) => ({
1841
- slug: group.slug,
1842
- title: group.title,
1843
- description: group.description,
1844
- refs: group.refs.map((ref) => ({ slug: ref.slug, weight: ref.weight }))
1845
- })),
1846
- icon: plugin.icon,
1837
+ function pluginToGQL(plugin) {
1838
+ return {
1847
1839
  slug: plugin.slug,
1848
1840
  title: plugin.title,
1841
+ icon: plugin.icon,
1842
+ description: plugin.description,
1843
+ docsUrl: plugin.docsUrl,
1844
+ audits: plugin.audits.map(auditToGQL),
1845
+ groups: plugin.groups?.map(groupToGQL),
1849
1846
  packageName: plugin.packageName,
1850
1847
  packageVersion: plugin.version,
1851
1848
  runnerDuration: plugin.duration,
1852
1849
  runnerStartDate: plugin.date
1853
- }));
1850
+ };
1854
1851
  }
1855
- function auditReportsToGql(audits) {
1856
- return audits.map((audit) => ({
1852
+ function groupToGQL(group) {
1853
+ return {
1854
+ slug: group.slug,
1855
+ title: group.title,
1856
+ description: group.description,
1857
+ refs: group.refs.map((ref) => ({ slug: ref.slug, weight: ref.weight }))
1858
+ };
1859
+ }
1860
+ function auditToGQL(audit) {
1861
+ return {
1862
+ slug: audit.slug,
1863
+ title: audit.title,
1857
1864
  description: audit.description,
1858
- details: {
1859
- issues: issuesToGql(audit.details?.issues)
1860
- },
1861
1865
  docsUrl: audit.docsUrl,
1862
- formattedValue: audit.displayValue,
1863
1866
  score: audit.score,
1864
- slug: audit.slug,
1865
- title: audit.title,
1866
- value: audit.value
1867
- }));
1867
+ value: audit.value,
1868
+ formattedValue: audit.displayValue,
1869
+ ...audit.details && {
1870
+ details: {
1871
+ ...audit.details.issues && {
1872
+ issues: audit.details.issues.map(issueToGQL)
1873
+ }
1874
+ }
1875
+ }
1876
+ };
1868
1877
  }
1869
- function issuesToGql(issues) {
1870
- return issues?.map((issue) => ({
1878
+ function issueToGQL(issue) {
1879
+ return {
1871
1880
  message: issue.message,
1872
- severity: transformSeverity(issue.severity),
1873
- sourceEndColumn: issue.source?.position?.endColumn,
1874
- sourceEndLine: issue.source?.position?.endLine,
1875
- sourceFilePath: issue.source?.file,
1876
- sourceStartColumn: issue.source?.position?.startColumn,
1877
- sourceStartLine: issue.source?.position?.startLine,
1878
- sourceType: IssueSourceType.SourceCode
1879
- })) ?? [];
1880
- }
1881
- function categoryConfigsToGql(categories) {
1882
- return categories.map((category) => ({
1881
+ severity: issueSeverityToGQL(issue.severity),
1882
+ ...issue.source?.file && {
1883
+ sourceType: PortalIssueSourceType.SourceCode,
1884
+ sourceFilePath: issue.source.file,
1885
+ sourceStartLine: issue.source.position?.startLine,
1886
+ sourceStartColumn: issue.source.position?.startColumn,
1887
+ sourceEndLine: issue.source.position?.endLine,
1888
+ sourceEndColumn: issue.source.position?.endColumn
1889
+ }
1890
+ };
1891
+ }
1892
+ function categoryToGQL(category) {
1893
+ return {
1883
1894
  slug: category.slug,
1884
1895
  title: category.title,
1885
1896
  description: category.description,
1886
1897
  refs: category.refs.map((ref) => ({
1887
1898
  plugin: ref.plugin,
1888
- type: ref.type === "audit" ? CategoryConfigRefType.Audit : CategoryConfigRefType.Group,
1899
+ type: categoryRefTypeToGQL(ref.type),
1889
1900
  weight: ref.weight,
1890
1901
  slug: ref.slug
1891
1902
  }))
1892
- }));
1903
+ };
1904
+ }
1905
+ function categoryRefTypeToGQL(type) {
1906
+ switch (type) {
1907
+ case "audit":
1908
+ return PortalCategoryRefType.Audit;
1909
+ case "group":
1910
+ return PortalCategoryRefType.Group;
1911
+ }
1893
1912
  }
1894
- function transformSeverity(severity) {
1913
+ function issueSeverityToGQL(severity) {
1895
1914
  switch (severity) {
1896
1915
  case "info":
1897
1916
  return PortalIssueSeverity.Info;
@@ -1921,7 +1940,7 @@ async function upload(options2, uploadFn = uploadToPortal) {
1921
1940
  organization,
1922
1941
  project,
1923
1942
  commit: commitData.hash,
1924
- ...jsonReportToGql(report)
1943
+ ...reportToGQL(report)
1925
1944
  };
1926
1945
  return uploadFn({ apiKey, server, data, timeout });
1927
1946
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/cli",
3
- "version": "0.16.5",
3
+ "version": "0.16.7",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "code-pushup": "index.js"