@code-pushup/lighthouse-plugin 0.44.4 → 0.45.1

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
@@ -110,6 +110,7 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
110
110
  }).min(1, { message: "file name is invalid" });
111
111
  var positiveIntSchema = z.number().int().positive();
112
112
  var nonnegativeIntSchema = z.number().int().nonnegative();
113
+ var nonnegativeNumberSchema = z.number().nonnegative();
113
114
  function packageVersionSchema(options) {
114
115
  const { versionDescription = "NPM version of the package", required } = options ?? {};
115
116
  const packageSchema = z.string({ description: "NPM package name" });
@@ -122,7 +123,7 @@ function packageVersionSchema(options) {
122
123
  { description: "NPM package name and version of a published package" }
123
124
  );
124
125
  }
125
- var weightSchema = nonnegativeIntSchema.describe(
126
+ var weightSchema = nonnegativeNumberSchema.describe(
126
127
  "Coefficient for the given score (use weight 0 if only for display)"
127
128
  );
128
129
  function weightedRefSchema(description, slugDescription) {
@@ -264,7 +265,7 @@ var tableObjectSchema = tableSharedSchema.merge(
264
265
  var tableSchema = (description = "Table information") => z4.union([tablePrimitiveSchema, tableObjectSchema], { description });
265
266
 
266
267
  // packages/models/src/lib/audit-output.ts
267
- var auditValueSchema = nonnegativeIntSchema.describe("Raw numeric value");
268
+ var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
268
269
  var auditDisplayValueSchema = z5.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
269
270
  var auditDetailsSchema = z5.object(
270
271
  {
@@ -708,6 +709,79 @@ var LIGHTHOUSE_OUTPUT_PATH = join(
708
709
  // packages/plugin-lighthouse/src/lib/normalize-flags.ts
709
710
  import chalk6 from "chalk";
710
711
 
712
+ // packages/utils/src/lib/file-system.ts
713
+ import { bundleRequire } from "bundle-require";
714
+ import chalk2 from "chalk";
715
+ import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
716
+
717
+ // packages/utils/src/lib/logging.ts
718
+ import isaacs_cliui from "@isaacs/cliui";
719
+ import { cliui } from "@poppinss/cliui";
720
+ import chalk from "chalk";
721
+
722
+ // packages/utils/src/lib/reports/constants.ts
723
+ var TERMINAL_WIDTH = 80;
724
+
725
+ // packages/utils/src/lib/logging.ts
726
+ var singletonUiInstance;
727
+ function ui() {
728
+ if (singletonUiInstance === void 0) {
729
+ singletonUiInstance = cliui();
730
+ }
731
+ return {
732
+ ...singletonUiInstance,
733
+ row: (args) => {
734
+ logListItem(args);
735
+ }
736
+ };
737
+ }
738
+ var singletonisaacUi;
739
+ function logListItem(args) {
740
+ if (singletonisaacUi === void 0) {
741
+ singletonisaacUi = isaacs_cliui({ width: TERMINAL_WIDTH });
742
+ }
743
+ singletonisaacUi.div(...args);
744
+ const content = singletonisaacUi.toString();
745
+ singletonisaacUi.rows = [];
746
+ singletonUiInstance?.logger.log(content);
747
+ }
748
+
749
+ // packages/utils/src/lib/file-system.ts
750
+ async function readTextFile(path) {
751
+ const buffer = await readFile(path);
752
+ return buffer.toString();
753
+ }
754
+ async function readJsonFile(path) {
755
+ const text = await readTextFile(path);
756
+ return JSON.parse(text);
757
+ }
758
+ async function ensureDirectoryExists(baseDir) {
759
+ try {
760
+ await mkdir(baseDir, { recursive: true });
761
+ return;
762
+ } catch (error) {
763
+ ui().logger.info(error.message);
764
+ if (error.code !== "EEXIST") {
765
+ throw error;
766
+ }
767
+ }
768
+ }
769
+ var NoExportError = class extends Error {
770
+ constructor(filepath) {
771
+ super(`No default export found in ${filepath}`);
772
+ }
773
+ };
774
+ async function importEsmModule(options) {
775
+ const { mod } = await bundleRequire({
776
+ format: "esm",
777
+ ...options
778
+ });
779
+ if (!("default" in mod)) {
780
+ throw new NoExportError(options.filepath);
781
+ }
782
+ return mod.default;
783
+ }
784
+
711
785
  // packages/utils/src/lib/text-formats/constants.ts
712
786
  var NEW_LINE = "\n";
713
787
  var TAB = " ";
@@ -983,79 +1057,6 @@ var html = {
983
1057
  table
984
1058
  };
985
1059
 
986
- // packages/utils/src/lib/file-system.ts
987
- import { bundleRequire } from "bundle-require";
988
- import chalk2 from "chalk";
989
- import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
990
-
991
- // packages/utils/src/lib/logging.ts
992
- import isaacs_cliui from "@isaacs/cliui";
993
- import { cliui } from "@poppinss/cliui";
994
- import chalk from "chalk";
995
-
996
- // packages/utils/src/lib/reports/constants.ts
997
- var TERMINAL_WIDTH = 80;
998
-
999
- // packages/utils/src/lib/logging.ts
1000
- var singletonUiInstance;
1001
- function ui() {
1002
- if (singletonUiInstance === void 0) {
1003
- singletonUiInstance = cliui();
1004
- }
1005
- return {
1006
- ...singletonUiInstance,
1007
- row: (args) => {
1008
- logListItem(args);
1009
- }
1010
- };
1011
- }
1012
- var singletonisaacUi;
1013
- function logListItem(args) {
1014
- if (singletonisaacUi === void 0) {
1015
- singletonisaacUi = isaacs_cliui({ width: TERMINAL_WIDTH });
1016
- }
1017
- singletonisaacUi.div(...args);
1018
- const content = singletonisaacUi.toString();
1019
- singletonisaacUi.rows = [];
1020
- singletonUiInstance?.logger.log(content);
1021
- }
1022
-
1023
- // packages/utils/src/lib/file-system.ts
1024
- async function readTextFile(path2) {
1025
- const buffer = await readFile(path2);
1026
- return buffer.toString();
1027
- }
1028
- async function readJsonFile(path2) {
1029
- const text = await readTextFile(path2);
1030
- return JSON.parse(text);
1031
- }
1032
- async function ensureDirectoryExists(baseDir) {
1033
- try {
1034
- await mkdir(baseDir, { recursive: true });
1035
- return;
1036
- } catch (error) {
1037
- ui().logger.info(error.message);
1038
- if (error.code !== "EEXIST") {
1039
- throw error;
1040
- }
1041
- }
1042
- }
1043
- var NoExportError = class extends Error {
1044
- constructor(filepath) {
1045
- super(`No default export found in ${filepath}`);
1046
- }
1047
- };
1048
- async function importEsmModule(options) {
1049
- const { mod } = await bundleRequire({
1050
- format: "esm",
1051
- ...options
1052
- });
1053
- if (!("default" in mod)) {
1054
- throw new NoExportError(options.filepath);
1055
- }
1056
- return mod.default;
1057
- }
1058
-
1059
1060
  // packages/utils/src/lib/reports/utils.ts
1060
1061
  var { image: image2, bold: boldMd } = md;
1061
1062
 
@@ -1156,8 +1157,8 @@ async function loadLighthouseAudit(value) {
1156
1157
  if (typeof value === "function") {
1157
1158
  return value;
1158
1159
  }
1159
- const path2 = typeof value === "string" ? value : value.path;
1160
- const module = await import(`lighthouse/core/audits/${path2}.js`);
1160
+ const path = typeof value === "string" ? value : value.path;
1161
+ const module = await import(`lighthouse/core/audits/${path}.js`);
1161
1162
  return module.default;
1162
1163
  }
1163
1164
  var LIGHTHOUSE_REPORT_NAME = "lighthouse-report.json";
@@ -1177,7 +1178,6 @@ var DEFAULT_CLI_FLAGS = {
1177
1178
  onlyAudits: [],
1178
1179
  skipAudits: [],
1179
1180
  onlyCategories: [],
1180
- budgets: [],
1181
1181
  output: ["json"],
1182
1182
  outputPath: join2(LIGHTHOUSE_OUTPUT_PATH, LIGHTHOUSE_REPORT_NAME)
1183
1183
  };
@@ -1188,7 +1188,6 @@ import log from "lighthouse-logger";
1188
1188
  import desktopConfig from "lighthouse/core/config/desktop-config.js";
1189
1189
  import experimentalConfig from "lighthouse/core/config/experimental-config.js";
1190
1190
  import perfConfig from "lighthouse/core/config/perf-config.js";
1191
- import path from "node:path";
1192
1191
  function normalizeAuditOutputs(auditOutputs, flags = { skipAudits: [] }) {
1193
1192
  const toSkip = new Set(flags.skipAudits ?? []);
1194
1193
  return auditOutputs.filter(({ slug }) => {
@@ -1296,14 +1295,6 @@ async function getConfig(options = {}) {
1296
1295
  }
1297
1296
  return void 0;
1298
1297
  }
1299
- async function getBudgets(budgetPath) {
1300
- if (budgetPath) {
1301
- return await readJsonFile(
1302
- path.resolve(process.cwd(), budgetPath)
1303
- );
1304
- }
1305
- return [];
1306
- }
1307
1298
 
1308
1299
  // packages/plugin-lighthouse/src/lib/runner/runner.ts
1309
1300
  function createRunnerFunction(urlUnderTest, flags = DEFAULT_CLI_FLAGS) {
@@ -1311,21 +1302,17 @@ function createRunnerFunction(urlUnderTest, flags = DEFAULT_CLI_FLAGS) {
1311
1302
  const {
1312
1303
  configPath,
1313
1304
  preset,
1314
- budgetPath,
1315
- budgets,
1316
1305
  outputPath,
1317
1306
  ...parsedFlags
1318
1307
  } = flags;
1319
1308
  setLogLevel(parsedFlags);
1320
1309
  const config = await getConfig({ configPath, preset });
1321
- const budgetsJson = budgetPath ? await getBudgets(budgetPath) : budgets;
1322
- if (typeof outputPath === "string") {
1310
+ if (outputPath) {
1323
1311
  await ensureDirectoryExists(dirname(outputPath));
1324
1312
  }
1325
1313
  const enrichedFlags = {
1326
1314
  ...parsedFlags,
1327
- outputPath,
1328
- budgets: budgetsJson
1315
+ outputPath
1329
1316
  };
1330
1317
  const runnerResult = await runLighthouse(
1331
1318
  urlUnderTest,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@code-pushup/lighthouse-plugin",
3
- "version": "0.44.4",
3
+ "version": "0.45.1",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@code-pushup/models": "0.44.4",
7
- "lighthouse": "^11.0.0",
8
- "@code-pushup/utils": "0.44.4",
6
+ "@code-pushup/models": "0.45.1",
7
+ "lighthouse": "^12.0.0",
8
+ "@code-pushup/utils": "0.45.1",
9
9
  "lighthouse-logger": "2.0.1",
10
10
  "chalk": "^5.3.0"
11
11
  },
@@ -12,7 +12,6 @@ export declare const DEFAULT_LIGHTHOUSE_OPTIONS: {
12
12
  channel: string;
13
13
  onlyAudits: never[];
14
14
  skipAudits: never[];
15
- budgets: never[];
16
15
  output: "json"[];
17
16
  outputPath: string;
18
17
  };
@@ -15,7 +15,6 @@ export declare const DEFAULT_CLI_FLAGS: {
15
15
  onlyAudits: never[];
16
16
  skipAudits: never[];
17
17
  onlyCategories: never[];
18
- budgets: never[];
19
18
  output: "json"[];
20
19
  outputPath: string;
21
20
  };
@@ -1,10 +1,8 @@
1
- import type { Budget } from 'lighthouse';
2
1
  import type { LighthouseOptions } from '../types';
3
2
  export type NormalizedFlags = {
4
3
  chromeFlags: string[];
5
4
  onlyAudits: string[];
6
5
  onlyCategories: string[];
7
6
  skipAudits: string[];
8
- budgets: Budget[];
9
7
  };
10
8
  export type LighthouseCliFlags = Omit<LighthouseOptions, keyof NormalizedFlags> & NormalizedFlags;
@@ -1,4 +1,4 @@
1
- import type { Budget, Config } from 'lighthouse';
1
+ import type { Config } from 'lighthouse';
2
2
  import { Result } from 'lighthouse/types/lhr/audit-result';
3
3
  import { AuditOutputs } from '@code-pushup/models';
4
4
  import type { LighthouseOptions } from '../types';
@@ -17,4 +17,3 @@ export declare function setLogLevel({ verbose, quiet, }?: {
17
17
  }): void;
18
18
  export type ConfigOptions = Partial<Pick<LighthouseCliFlags, 'configPath' | 'preset'>>;
19
19
  export declare function getConfig(options?: ConfigOptions): Promise<Config | undefined>;
20
- export declare function getBudgets(budgetPath?: string): Promise<Budget[]>;