@code-pushup/cli 0.53.1 → 0.55.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/index.js CHANGED
@@ -37,7 +37,7 @@ function exists(value) {
37
37
  return value != null;
38
38
  }
39
39
  function getMissingRefsForCategories(categories, plugins) {
40
- if (categories.length === 0) {
40
+ if (!categories || categories.length === 0) {
41
41
  return false;
42
42
  }
43
43
  const auditRefsFromCategory = categories.flatMap(
@@ -114,7 +114,6 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
114
114
  message: `The filename has to be valid`
115
115
  }).min(1, { message: "file name is invalid" });
116
116
  var positiveIntSchema = z.number().int().positive();
117
- var nonnegativeIntSchema = z.number().int().nonnegative();
118
117
  var nonnegativeNumberSchema = z.number().nonnegative();
119
118
  function packageVersionSchema(options2) {
120
119
  const { versionDescription = "NPM version of the package", required } = options2 ?? {};
@@ -537,12 +536,9 @@ var unrefinedCoreConfigSchema = z14.object({
537
536
  var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
538
537
  function refineCoreConfig(schema) {
539
538
  return schema.refine(
540
- (coreCfg) => !getMissingRefsForCategories(coreCfg.categories ?? [], coreCfg.plugins),
541
- (coreCfg) => ({
542
- message: missingRefsForCategoriesErrorMsg(
543
- coreCfg.categories ?? [],
544
- coreCfg.plugins
545
- )
539
+ ({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
540
+ ({ categories, plugins }) => ({
541
+ message: missingRefsForCategoriesErrorMsg(categories, plugins)
546
542
  })
547
543
  );
548
544
  }
@@ -603,19 +599,16 @@ var reportSchema = packageVersionSchema({
603
599
  ).merge(
604
600
  z15.object(
605
601
  {
606
- categories: z15.array(categoryConfigSchema),
607
602
  plugins: z15.array(pluginReportSchema).min(1),
603
+ categories: z15.array(categoryConfigSchema).optional(),
608
604
  commit: commitSchema.describe("Git commit for which report was collected").nullable()
609
605
  },
610
606
  { description: "Collect output data" }
611
607
  )
612
608
  ).refine(
613
- (report) => !getMissingRefsForCategories(report.categories, report.plugins),
614
- (report) => ({
615
- message: missingRefsForCategoriesErrorMsg(
616
- report.categories,
617
- report.plugins
618
- )
609
+ ({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
610
+ ({ categories, plugins }) => ({
611
+ message: missingRefsForCategoriesErrorMsg(categories, plugins)
619
612
  })
620
613
  );
621
614
 
@@ -667,7 +660,7 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
667
660
  z16.object({
668
661
  values: makeComparisonSchema(auditValueSchema).merge(
669
662
  z16.object({
670
- diff: z16.number().int().describe("Value change (`values.after - values.before`)")
663
+ diff: z16.number().describe("Value change (`values.after - values.before`)")
671
664
  })
672
665
  ).describe("Audit `value` comparison"),
673
666
  displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
@@ -1013,6 +1006,7 @@ function executeProcess(cfg) {
1013
1006
  return new Promise((resolve, reject) => {
1014
1007
  const spawnedProcess = spawn(command2, args ?? [], {
1015
1008
  shell: true,
1009
+ windowsHide: true,
1016
1010
  ...options2
1017
1011
  });
1018
1012
  let stdout = "";
@@ -1781,7 +1775,7 @@ function getSortableGroupByRef({ plugin, slug, weight }, plugins) {
1781
1775
  }
1782
1776
  function sortReport(report) {
1783
1777
  const { categories, plugins } = report;
1784
- const sortedCategories = categories.map((category) => {
1778
+ const sortedCategories = categories?.map((category) => {
1785
1779
  const { audits, groups: groups2 } = category.refs.reduce(
1786
1780
  (acc, ref) => ({
1787
1781
  ...acc,
@@ -1921,14 +1915,15 @@ function auditDetailsAuditValue({
1921
1915
  String(displayValue ?? value)
1922
1916
  )} (score: ${formatReportScore(score)})`;
1923
1917
  }
1918
+ function hasCategories(report) {
1919
+ return !!report.categories && report.categories.length > 0;
1920
+ }
1924
1921
  function generateMdReport(report, options2) {
1925
- return new MarkdownDocument3().heading(HIERARCHY.level_1, REPORT_HEADLINE_TEXT).$if(
1926
- report.categories.length > 0,
1927
- (doc) => doc.$concat(
1928
- categoriesOverviewSection(report),
1929
- categoriesDetailsSection(report)
1930
- )
1931
- ).$concat(auditsSection(report, options2), aboutSection(report)).rule().paragraph(md4`${FOOTER_PREFIX} ${md4.link(README_LINK, "Code PushUp")}`).toString();
1922
+ return new MarkdownDocument3().heading(HIERARCHY.level_1, REPORT_HEADLINE_TEXT).$concat(
1923
+ ...hasCategories(report) ? [categoriesOverviewSection(report), categoriesDetailsSection(report)] : [],
1924
+ auditsSection(report, options2),
1925
+ aboutSection(report)
1926
+ ).rule().paragraph(md4`${FOOTER_PREFIX} ${md4.link(README_LINK, "Code PushUp")}`).toString();
1932
1927
  }
1933
1928
  function auditDetailsIssues(issues = [], options2) {
1934
1929
  if (issues.length === 0) {
@@ -2030,7 +2025,7 @@ function reportMetaTable({
2030
2025
  md4.code(version3),
2031
2026
  formatDuration(duration),
2032
2027
  plugins.length.toString(),
2033
- categories.length.toString(),
2028
+ (categories?.length ?? 0).toString(),
2034
2029
  plugins.reduce((acc, { audits }) => acc + audits.length, 0).toString()
2035
2030
  ]
2036
2031
  ]
@@ -2362,24 +2357,26 @@ function log(msg = "") {
2362
2357
  ui().logger.log(msg);
2363
2358
  }
2364
2359
  function logStdoutSummary(report, verbose = false) {
2365
- const printCategories = report.categories.length > 0;
2366
- log(reportToHeaderSection(report));
2360
+ const { plugins, categories, packageName, version: version3 } = report;
2361
+ log(reportToHeaderSection({ packageName, version: version3 }));
2367
2362
  log();
2368
- logPlugins(report.plugins, verbose);
2369
- if (printCategories) {
2370
- logCategories(report);
2363
+ logPlugins(plugins, verbose);
2364
+ if (categories && categories.length > 0) {
2365
+ logCategories({ plugins, categories });
2371
2366
  }
2372
2367
  log(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
2373
2368
  log();
2374
2369
  }
2375
- function reportToHeaderSection(report) {
2376
- const { packageName, version: version3 } = report;
2370
+ function reportToHeaderSection({
2371
+ packageName,
2372
+ version: version3
2373
+ }) {
2377
2374
  return `${bold4(REPORT_HEADLINE_TEXT)} - ${packageName}@${version3}`;
2378
2375
  }
2379
2376
  function logPlugins(plugins, verbose) {
2380
2377
  plugins.forEach((plugin) => {
2381
2378
  const { title, audits } = plugin;
2382
- const filteredAudits = verbose ? audits : audits.filter(({ score }) => score !== 1);
2379
+ const filteredAudits = verbose || audits.length === 1 ? audits : audits.filter(({ score }) => score !== 1);
2383
2380
  const diff = audits.length - filteredAudits.length;
2384
2381
  logAudits(title, filteredAudits);
2385
2382
  if (diff > 0) {
@@ -2419,7 +2416,10 @@ function logRow(score, title, value) {
2419
2416
  ] : []
2420
2417
  ]);
2421
2418
  }
2422
- function logCategories({ categories, plugins }) {
2419
+ function logCategories({
2420
+ plugins,
2421
+ categories
2422
+ }) {
2423
2423
  const hAlign = (idx) => idx === 0 ? "left" : "right";
2424
2424
  const rows = categories.map(({ title, score, refs, isBinary }) => [
2425
2425
  title,
@@ -2501,7 +2501,7 @@ function scoreReport(report) {
2501
2501
  }
2502
2502
  return item.score;
2503
2503
  }
2504
- const scoredCategories = report.categories.map((category) => ({
2504
+ const scoredCategories = report.categories?.map((category) => ({
2505
2505
  ...category,
2506
2506
  score: calculateScore(category.refs, catScoreFn)
2507
2507
  }));
@@ -2564,7 +2564,7 @@ var verboseUtils = (verbose = false) => ({
2564
2564
 
2565
2565
  // packages/core/package.json
2566
2566
  var name = "@code-pushup/core";
2567
- var version = "0.53.1";
2567
+ var version = "0.55.0";
2568
2568
 
2569
2569
  // packages/core/src/lib/implementation/execute-plugin.ts
2570
2570
  import { bold as bold5 } from "ansis";
@@ -2828,8 +2828,8 @@ import { join as join5 } from "node:path";
2828
2828
  // packages/core/src/lib/implementation/compare-scorables.ts
2829
2829
  function compareCategories(reports) {
2830
2830
  const { pairs, added, removed } = matchArrayItemsByKey({
2831
- before: reports.before.categories,
2832
- after: reports.after.categories,
2831
+ before: reports.before.categories ?? [],
2832
+ after: reports.after.categories ?? [],
2833
2833
  key: "slug"
2834
2834
  });
2835
2835
  const { changed, unchanged } = comparePairs(
@@ -3070,7 +3070,7 @@ function reportToGQL(report) {
3070
3070
  commandStartDate: report.date,
3071
3071
  commandDuration: report.duration,
3072
3072
  plugins: report.plugins.map(pluginToGQL),
3073
- categories: report.categories.map(categoryToGQL)
3073
+ categories: (report.categories ?? []).map(categoryToGQL)
3074
3074
  };
3075
3075
  }
3076
3076
  function pluginToGQL(plugin) {
@@ -3407,7 +3407,7 @@ function yargsAutorunCommandObject() {
3407
3407
  };
3408
3408
  await collectAndPersistReports(optionsWithFormat);
3409
3409
  collectSuccessfulLog();
3410
- if (options2.categories.length === 0) {
3410
+ if (!options2.categories || options2.categories.length === 0) {
3411
3411
  renderConfigureCategoriesHint();
3412
3412
  }
3413
3413
  if (options2.upload) {
@@ -3436,7 +3436,7 @@ function yargsCollectCommandObject() {
3436
3436
  ui().logger.info(gray5(`Run ${command2}...`));
3437
3437
  await collectAndPersistReports(options2);
3438
3438
  collectSuccessfulLog();
3439
- if (options2.categories.length === 0) {
3439
+ if (!options2.categories || options2.categories.length === 0) {
3440
3440
  renderConfigureCategoriesHint();
3441
3441
  }
3442
3442
  const { upload: upload2 = {} } = args;
@@ -3521,7 +3521,7 @@ import yargs from "yargs";
3521
3521
  // packages/cli/src/lib/implementation/validate-filter-options.utils.ts
3522
3522
  var OptionValidationError = class extends Error {
3523
3523
  };
3524
- function validateFilterOption(option, { plugins, categories }, { itemsToFilter, verbose }) {
3524
+ function validateFilterOption(option, { plugins, categories = [] }, { itemsToFilter, verbose }) {
3525
3525
  const itemsToFilterSet = new Set(itemsToFilter);
3526
3526
  const validItems = isCategoryOption(option) ? categories : isPluginOption(option) ? plugins : [];
3527
3527
  const invalidItems = itemsToFilter.filter(
@@ -3549,8 +3549,8 @@ function validateFilterOption(option, { plugins, categories }, { itemsToFilter,
3549
3549
  }
3550
3550
  }
3551
3551
  function validateFinalState(filteredItems, originalItems) {
3552
- const { categories: filteredCategories, plugins: filteredPlugins } = filteredItems;
3553
- const { categories: originalCategories, plugins: originalPlugins } = originalItems;
3552
+ const { categories: filteredCategories = [], plugins: filteredPlugins } = filteredItems;
3553
+ const { categories: originalCategories = [], plugins: originalPlugins } = originalItems;
3554
3554
  if (filteredCategories.length === 0 && filteredPlugins.length === 0 && (originalPlugins.length > 0 || originalCategories.length > 0)) {
3555
3555
  const availablePlugins = originalPlugins.map((p) => p.slug).join(", ") || "none";
3556
3556
  const availableCategories = originalCategories.map((c) => c.slug).join(", ") || "none";
@@ -3889,7 +3889,6 @@ async function coreConfigMiddleware(processArgs) {
3889
3889
  const {
3890
3890
  persist: rcPersist,
3891
3891
  upload: rcUpload,
3892
- categories: rcCategories,
3893
3892
  ...remainingRcConfig
3894
3893
  } = importedRc;
3895
3894
  const upload2 = rcUpload == null && cliUpload == null ? void 0 : uploadConfigSchema.parse({
@@ -3906,7 +3905,6 @@ async function coreConfigMiddleware(processArgs) {
3906
3905
  )
3907
3906
  },
3908
3907
  ...upload2 != null && { upload: upload2 },
3909
- categories: rcCategories ?? [],
3910
3908
  ...remainingRcConfig,
3911
3909
  ...remainingCliOptions
3912
3910
  };
@@ -3917,7 +3915,7 @@ var normalizeFormats = (formats) => (formats ?? []).flatMap((format) => format.s
3917
3915
  function filterMiddleware(originalProcessArgs) {
3918
3916
  const {
3919
3917
  plugins,
3920
- categories = [],
3918
+ categories,
3921
3919
  skipCategories = [],
3922
3920
  onlyCategories = [],
3923
3921
  skipPlugins = [],
@@ -3925,7 +3923,7 @@ function filterMiddleware(originalProcessArgs) {
3925
3923
  verbose = false
3926
3924
  } = originalProcessArgs;
3927
3925
  if (skipCategories.length === 0 && onlyCategories.length === 0 && skipPlugins.length === 0 && onlyPlugins.length === 0) {
3928
- return { ...originalProcessArgs, categories };
3926
+ return originalProcessArgs;
3929
3927
  }
3930
3928
  handleConflictingOptions("categories", onlyCategories, skipCategories);
3931
3929
  handleConflictingOptions("plugins", onlyPlugins, skipPlugins);
@@ -3941,10 +3939,10 @@ function filterMiddleware(originalProcessArgs) {
3941
3939
  onlyPlugins,
3942
3940
  verbose
3943
3941
  );
3944
- const finalCategories = filterItemRefsBy(
3942
+ const finalCategories = filteredCategories ? filterItemRefsBy(
3945
3943
  filteredCategories,
3946
3944
  (ref) => filteredPlugins.some((plugin) => plugin.slug === ref.plugin)
3947
- );
3945
+ ) : filteredCategories;
3948
3946
  validateFinalState(
3949
3947
  { categories: finalCategories, plugins: filteredPlugins },
3950
3948
  { categories, plugins }
@@ -3962,7 +3960,7 @@ function applyFilters(items, skipItems, onlyItems, key) {
3962
3960
  });
3963
3961
  }
3964
3962
  function applyCategoryFilters({ categories, plugins }, skipCategories, onlyCategories, verbose) {
3965
- if (skipCategories.length === 0 && onlyCategories.length === 0) {
3963
+ if (skipCategories.length === 0 && onlyCategories.length === 0 || !categories || categories.length === 0) {
3966
3964
  return categories;
3967
3965
  }
3968
3966
  validateFilterOption(
@@ -4001,10 +3999,13 @@ function filterPluginsFromCategories({
4001
3999
  categories,
4002
4000
  plugins
4003
4001
  }) {
4002
+ if (!categories || categories.length === 0) {
4003
+ return plugins;
4004
+ }
4004
4005
  const validPluginSlugs = new Set(
4005
4006
  categories.flatMap((category) => category.refs.map((ref) => ref.plugin))
4006
4007
  );
4007
- return categories.length > 0 ? plugins.filter((plugin) => validPluginSlugs.has(plugin.slug)) : plugins;
4008
+ return plugins.filter((plugin) => validPluginSlugs.has(plugin.slug));
4008
4009
  }
4009
4010
 
4010
4011
  // packages/cli/src/lib/middlewares.ts
@@ -4107,7 +4108,7 @@ import { blue, dim as dim2, green as green4 } from "ansis";
4107
4108
  import yargs2 from "yargs";
4108
4109
 
4109
4110
  // packages/cli/package.json
4110
- var version2 = "0.53.1";
4111
+ var version2 = "0.55.0";
4111
4112
 
4112
4113
  // packages/cli/src/lib/implementation/formatting.ts
4113
4114
  import { bold as bold13, dim, green as green3 } from "ansis";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/cli",
3
- "version": "0.53.1",
3
+ "version": "0.55.0",
4
4
  "license": "MIT",
5
5
  "description": "A CLI to run all kinds of code quality measurements to align your team with company goals",
6
6
  "homepage": "https://code-pushup.dev",
@@ -44,9 +44,9 @@
44
44
  "code-pushup": "index.js"
45
45
  },
46
46
  "dependencies": {
47
- "@code-pushup/models": "0.53.1",
48
- "@code-pushup/core": "0.53.1",
49
- "@code-pushup/utils": "0.53.1",
47
+ "@code-pushup/models": "0.55.0",
48
+ "@code-pushup/core": "0.55.0",
49
+ "@code-pushup/utils": "0.55.0",
50
50
  "yargs": "^17.7.2",
51
51
  "ansis": "^3.3.0",
52
52
  "simple-git": "^3.20.0"
@@ -1,9 +1,6 @@
1
1
  import type { GlobalOptions } from '@code-pushup/core';
2
- import type { CategoryConfig, CoreConfig, PluginConfig } from '@code-pushup/models';
2
+ import type { CoreConfig } from '@code-pushup/models';
3
3
  export type FilterOptions = Partial<GlobalOptions> & Pick<CoreConfig, 'categories' | 'plugins'> & FilterCliOptions;
4
4
  export type FilterCliOptions = Partial<Record<FilterOptionType, string[]>>;
5
5
  export type FilterOptionType = 'skipCategories' | 'onlyCategories' | 'skipPlugins' | 'onlyPlugins';
6
- export type Filterables = {
7
- categories: CategoryConfig[];
8
- plugins: PluginConfig[];
9
- };
6
+ export type Filterables = Pick<CoreConfig, 'plugins' | 'categories'>;