@code-pushup/cli 0.5.2 → 0.5.4
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
|
@@ -230,8 +230,7 @@ var persistConfigSchema = z3.object({
|
|
|
230
230
|
filename: fileNameSchema(
|
|
231
231
|
"Artifacts file name (without extension)"
|
|
232
232
|
).optional(),
|
|
233
|
-
format: z3.array(formatSchema).
|
|
234
|
-
// @TODO remove default or optional value and otherwise it will not set defaults.
|
|
233
|
+
format: z3.array(formatSchema).optional()
|
|
235
234
|
});
|
|
236
235
|
|
|
237
236
|
// packages/models/src/lib/plugin-config.ts
|
|
@@ -1385,6 +1384,9 @@ function withColor({ score, text }) {
|
|
|
1385
1384
|
}
|
|
1386
1385
|
|
|
1387
1386
|
// packages/utils/src/lib/transformation.ts
|
|
1387
|
+
function toArray(val) {
|
|
1388
|
+
return Array.isArray(val) ? val : [val];
|
|
1389
|
+
}
|
|
1388
1390
|
function deepClone(obj) {
|
|
1389
1391
|
if (obj == null || typeof obj !== "object") {
|
|
1390
1392
|
return obj;
|
|
@@ -1499,18 +1501,18 @@ var PersistError = class extends Error {
|
|
|
1499
1501
|
};
|
|
1500
1502
|
async function persistReport(report, options2) {
|
|
1501
1503
|
const { outputDir, filename, format } = options2;
|
|
1502
|
-
|
|
1504
|
+
const scoredReport = scoreReport(report);
|
|
1503
1505
|
console.info(reportToStdout(scoredReport));
|
|
1504
|
-
const results = [
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1506
|
+
const results = [];
|
|
1507
|
+
if (format.includes("json")) {
|
|
1508
|
+
results.push({
|
|
1509
|
+
format: "json",
|
|
1510
|
+
content: JSON.stringify(report, null, 2)
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1508
1513
|
if (format.includes("md")) {
|
|
1509
|
-
scoredReport = scoredReport || scoreReport(report);
|
|
1510
1514
|
const commitData = await getLatestCommit();
|
|
1511
|
-
|
|
1512
|
-
console.warn("no commit data available");
|
|
1513
|
-
}
|
|
1515
|
+
validateCommitData(commitData);
|
|
1514
1516
|
results.push({
|
|
1515
1517
|
format: "md",
|
|
1516
1518
|
content: reportToMd(scoredReport, commitData)
|
|
@@ -1537,6 +1539,11 @@ async function persistReport(report, options2) {
|
|
|
1537
1539
|
function logPersistedResults(persistResults) {
|
|
1538
1540
|
logMultipleFileResults(persistResults, "Generated reports");
|
|
1539
1541
|
}
|
|
1542
|
+
function validateCommitData(commitData) {
|
|
1543
|
+
if (!commitData) {
|
|
1544
|
+
console.warn("no commit data available");
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1540
1547
|
|
|
1541
1548
|
// packages/core/src/lib/implementation/execute-plugin.ts
|
|
1542
1549
|
import chalk4 from "chalk";
|
|
@@ -1653,7 +1660,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1653
1660
|
|
|
1654
1661
|
// packages/core/package.json
|
|
1655
1662
|
var name = "@code-pushup/core";
|
|
1656
|
-
var version = "0.5.
|
|
1663
|
+
var version = "0.5.4";
|
|
1657
1664
|
|
|
1658
1665
|
// packages/core/src/lib/implementation/collect.ts
|
|
1659
1666
|
async function collect(options2) {
|
|
@@ -1837,7 +1844,16 @@ function yargsAutorunCommandObject() {
|
|
|
1837
1844
|
console.info(chalk5.bold(CLI_NAME));
|
|
1838
1845
|
console.info(chalk5.gray(`Run ${command}...`));
|
|
1839
1846
|
const options2 = args;
|
|
1840
|
-
|
|
1847
|
+
const optionsWithFormat = {
|
|
1848
|
+
...options2,
|
|
1849
|
+
persist: {
|
|
1850
|
+
...options2.persist,
|
|
1851
|
+
format: [
|
|
1852
|
+
.../* @__PURE__ */ new Set([...options2.persist.format, "json"])
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1856
|
+
await collectAndPersistReports(optionsWithFormat);
|
|
1841
1857
|
if (!options2.upload) {
|
|
1842
1858
|
console.warn("Upload skipped because configuration is not set.");
|
|
1843
1859
|
} else {
|
|
@@ -1939,14 +1955,17 @@ function filterPluginsByOnlyPluginsOption(plugins, { onlyPlugins }) {
|
|
|
1939
1955
|
}
|
|
1940
1956
|
return plugins.filter((plugin) => onlyPlugins.includes(plugin.slug));
|
|
1941
1957
|
}
|
|
1942
|
-
function filterCategoryByOnlyPluginsOption(categories, {
|
|
1958
|
+
function filterCategoryByOnlyPluginsOption(categories, {
|
|
1959
|
+
onlyPlugins,
|
|
1960
|
+
verbose = false
|
|
1961
|
+
}) {
|
|
1943
1962
|
if (!onlyPlugins?.length) {
|
|
1944
1963
|
return categories;
|
|
1945
1964
|
}
|
|
1946
1965
|
return categories.filter(
|
|
1947
1966
|
(category) => category.refs.every((ref) => {
|
|
1948
1967
|
const isNotSkipped = onlyPlugins.includes(ref.slug);
|
|
1949
|
-
if (!isNotSkipped) {
|
|
1968
|
+
if (!isNotSkipped && verbose) {
|
|
1950
1969
|
console.info(
|
|
1951
1970
|
`${chalk8.yellow("\u26A0")} Category "${category.title}" is ignored because it references audits from skipped plugin "${ref.slug}"`
|
|
1952
1971
|
);
|
|
@@ -1955,9 +1974,12 @@ function filterCategoryByOnlyPluginsOption(categories, { onlyPlugins }) {
|
|
|
1955
1974
|
})
|
|
1956
1975
|
);
|
|
1957
1976
|
}
|
|
1958
|
-
function validateOnlyPluginsOption(plugins, {
|
|
1977
|
+
function validateOnlyPluginsOption(plugins, {
|
|
1978
|
+
onlyPlugins,
|
|
1979
|
+
verbose = false
|
|
1980
|
+
}) {
|
|
1959
1981
|
const missingPlugins = onlyPlugins?.length ? onlyPlugins.filter((plugin) => !plugins.some(({ slug }) => slug === plugin)) : [];
|
|
1960
|
-
if (missingPlugins.length > 0) {
|
|
1982
|
+
if (missingPlugins.length > 0 && verbose) {
|
|
1961
1983
|
console.warn(
|
|
1962
1984
|
`${chalk8.yellow(
|
|
1963
1985
|
"\u26A0"
|
|
@@ -1968,6 +1990,24 @@ function validateOnlyPluginsOption(plugins, { onlyPlugins }) {
|
|
|
1968
1990
|
}
|
|
1969
1991
|
}
|
|
1970
1992
|
|
|
1993
|
+
// packages/cli/src/lib/implementation/utils.ts
|
|
1994
|
+
function logErrorBeforeThrow(fn) {
|
|
1995
|
+
return async (...args) => {
|
|
1996
|
+
try {
|
|
1997
|
+
return await fn(...args);
|
|
1998
|
+
} catch (err) {
|
|
1999
|
+
console.error(err);
|
|
2000
|
+
await new Promise((resolve) => process.stdout.write("", resolve));
|
|
2001
|
+
throw err;
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
function coerceArray(param = []) {
|
|
2006
|
+
return [
|
|
2007
|
+
...new Set(toArray(param).flatMap((f) => f.split(",")) || [])
|
|
2008
|
+
];
|
|
2009
|
+
}
|
|
2010
|
+
|
|
1971
2011
|
// packages/cli/src/lib/implementation/config-middleware.ts
|
|
1972
2012
|
async function configMiddleware(processArgs) {
|
|
1973
2013
|
const args = processArgs;
|
|
@@ -1988,7 +2028,9 @@ async function configMiddleware(processArgs) {
|
|
|
1988
2028
|
persist: {
|
|
1989
2029
|
outputDir: cliOptions?.persist?.outputDir || importedRc?.persist?.outputDir || PERSIST_OUTPUT_DIR,
|
|
1990
2030
|
filename: cliOptions?.persist?.filename || importedRc?.persist?.filename || PERSIST_FILENAME,
|
|
1991
|
-
format:
|
|
2031
|
+
format: coerceArray(
|
|
2032
|
+
cliOptions?.persist?.format || importedRc?.persist?.format || PERSIST_FORMAT
|
|
2033
|
+
)
|
|
1992
2034
|
},
|
|
1993
2035
|
plugins: filterPluginsByOnlyPluginsOption(importedRc.plugins, cliOptions),
|
|
1994
2036
|
categories: filterCategoryByOnlyPluginsOption(
|
|
@@ -2083,21 +2125,6 @@ var options = {
|
|
|
2083
2125
|
// packages/cli/src/lib/yargs-cli.ts
|
|
2084
2126
|
import chalk9 from "chalk";
|
|
2085
2127
|
import yargs from "yargs";
|
|
2086
|
-
|
|
2087
|
-
// packages/cli/src/lib/implementation/utils.ts
|
|
2088
|
-
function logErrorBeforeThrow(fn) {
|
|
2089
|
-
return async (...args) => {
|
|
2090
|
-
try {
|
|
2091
|
-
return await fn(...args);
|
|
2092
|
-
} catch (err) {
|
|
2093
|
-
console.error(err);
|
|
2094
|
-
await new Promise((resolve) => process.stdout.write("", resolve));
|
|
2095
|
-
throw err;
|
|
2096
|
-
}
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
// packages/cli/src/lib/yargs-cli.ts
|
|
2101
2128
|
function yargsCli(argv, cfg) {
|
|
2102
2129
|
const { usageMessage, scriptName, noExitProcess } = cfg;
|
|
2103
2130
|
let { commands: commands2, options: options2, middlewares: middlewares2 } = cfg;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"bin": {
|
|
5
5
|
"code-pushup": "index.js"
|
|
6
6
|
},
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"@code-pushup/models": "*",
|
|
9
9
|
"@code-pushup/core": "*",
|
|
10
10
|
"yargs": "^17.7.2",
|
|
11
|
-
"chalk": "^5.3.0"
|
|
11
|
+
"chalk": "^5.3.0",
|
|
12
|
+
"@code-pushup/utils": "*"
|
|
12
13
|
},
|
|
13
14
|
"type": "module",
|
|
14
15
|
"main": "./index.js",
|
|
@@ -2,9 +2,11 @@ import { CoreConfig } from '@code-pushup/models';
|
|
|
2
2
|
export declare function filterPluginsByOnlyPluginsOption(plugins: CoreConfig['plugins'], { onlyPlugins }: {
|
|
3
3
|
onlyPlugins?: string[];
|
|
4
4
|
}): CoreConfig['plugins'];
|
|
5
|
-
export declare function filterCategoryByOnlyPluginsOption(categories: CoreConfig['categories'], { onlyPlugins }: {
|
|
5
|
+
export declare function filterCategoryByOnlyPluginsOption(categories: CoreConfig['categories'], { onlyPlugins, verbose, }: {
|
|
6
6
|
onlyPlugins?: string[];
|
|
7
|
+
verbose?: boolean;
|
|
7
8
|
}): CoreConfig['categories'];
|
|
8
|
-
export declare function validateOnlyPluginsOption(plugins: CoreConfig['plugins'], { onlyPlugins }: {
|
|
9
|
+
export declare function validateOnlyPluginsOption(plugins: CoreConfig['plugins'], { onlyPlugins, verbose, }: {
|
|
9
10
|
onlyPlugins?: string[];
|
|
11
|
+
verbose?: boolean;
|
|
10
12
|
}): void;
|
package/src/lib/options.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare const options: {
|
|
|
7
7
|
"upload.apiKey": import("yargs").Options;
|
|
8
8
|
"upload.server": import("yargs").Options;
|
|
9
9
|
progress: import("yargs").Options;
|
|
10
|
-
config: import("yargs").Options;
|
|
11
10
|
verbose: import("yargs").Options;
|
|
11
|
+
config: import("yargs").Options;
|
|
12
12
|
};
|