@code-pushup/cli 0.10.7 → 0.11.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/README.md +4 -5
- package/index.js +72 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,10 +40,6 @@ _If you're looking for programmatic usage, then refer to the underlying [@code-p
|
|
|
40
40
|
|
|
41
41
|
```js
|
|
42
42
|
export default {
|
|
43
|
-
persist: {
|
|
44
|
-
outputDir: '.code-pushup',
|
|
45
|
-
format: ['json', 'md'],
|
|
46
|
-
},
|
|
47
43
|
plugins: [
|
|
48
44
|
// ...
|
|
49
45
|
],
|
|
@@ -154,7 +150,10 @@ Each example is fully tested to demonstrate best practices for plugin testing as
|
|
|
154
150
|
| ---------------- | --------- | ----------------------- | ---------------------------------------------------------------------- |
|
|
155
151
|
| **`--progress`** | `boolean` | `true` | Show progress bar in stdout. |
|
|
156
152
|
| **`--verbose`** | `boolean` | `false` | When true creates more verbose output. This is helpful when debugging. |
|
|
157
|
-
| **`--config`** | `string` | `code-pushup.config.
|
|
153
|
+
| **`--config`** | `string` | `code-pushup.config.ts` | Path to the config file, e.g. code-pushup.config.(ts\|mjs\|js) |
|
|
154
|
+
|
|
155
|
+
> [!NOTE]
|
|
156
|
+
> By default, the CLI loads `code-pushup.config.(ts|mjs|js)` if no config path is provided with `--config`.
|
|
158
157
|
|
|
159
158
|
### Common Command Options
|
|
160
159
|
|
package/index.js
CHANGED
|
@@ -6,16 +6,6 @@ import { hideBin } from "yargs/helpers";
|
|
|
6
6
|
// packages/cli/src/lib/autorun/autorun-command.ts
|
|
7
7
|
import chalk5 from "chalk";
|
|
8
8
|
|
|
9
|
-
// packages/core/src/lib/implementation/persist.ts
|
|
10
|
-
import { mkdir as mkdir2, stat as stat2, writeFile } from "node:fs/promises";
|
|
11
|
-
import { join as join2 } from "node:path";
|
|
12
|
-
|
|
13
|
-
// packages/utils/src/lib/execute-process.ts
|
|
14
|
-
import { spawn } from "node:child_process";
|
|
15
|
-
|
|
16
|
-
// packages/utils/src/lib/reports/utils.ts
|
|
17
|
-
import { join } from "node:path";
|
|
18
|
-
|
|
19
9
|
// packages/models/src/lib/audit.ts
|
|
20
10
|
import { z as z2 } from "zod";
|
|
21
11
|
|
|
@@ -502,6 +492,10 @@ var PERSIST_OUTPUT_DIR = ".code-pushup";
|
|
|
502
492
|
var PERSIST_FORMAT = ["json"];
|
|
503
493
|
var PERSIST_FILENAME = "report";
|
|
504
494
|
|
|
495
|
+
// packages/models/src/lib/implementation/configuration.ts
|
|
496
|
+
var CONFIG_FILE_NAME = "code-pushup.config";
|
|
497
|
+
var SUPPORTED_CONFIG_FILE_FORMATS = ["ts", "mjs", "js"];
|
|
498
|
+
|
|
505
499
|
// packages/models/src/lib/report.ts
|
|
506
500
|
import { z as z12 } from "zod";
|
|
507
501
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
@@ -564,6 +558,12 @@ var reportSchema = packageVersionSchema({
|
|
|
564
558
|
})
|
|
565
559
|
);
|
|
566
560
|
|
|
561
|
+
// packages/utils/src/lib/execute-process.ts
|
|
562
|
+
import { spawn } from "node:child_process";
|
|
563
|
+
|
|
564
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
565
|
+
import { join } from "node:path";
|
|
566
|
+
|
|
567
567
|
// packages/utils/src/lib/file-system.ts
|
|
568
568
|
import { bundleRequire } from "bundle-require";
|
|
569
569
|
import chalk from "chalk";
|
|
@@ -1527,6 +1527,8 @@ var verboseUtils = (verbose) => ({
|
|
|
1527
1527
|
});
|
|
1528
1528
|
|
|
1529
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";
|
|
1530
1532
|
var PersistDirError = class extends Error {
|
|
1531
1533
|
constructor(outputDir) {
|
|
1532
1534
|
super(`outPath: ${outputDir} is no directory.`);
|
|
@@ -1703,7 +1705,7 @@ function auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits)
|
|
|
1703
1705
|
|
|
1704
1706
|
// packages/core/package.json
|
|
1705
1707
|
var name = "@code-pushup/core";
|
|
1706
|
-
var version = "0.
|
|
1708
|
+
var version = "0.11.0";
|
|
1707
1709
|
|
|
1708
1710
|
// packages/core/src/lib/implementation/collect.ts
|
|
1709
1711
|
async function collect(options2) {
|
|
@@ -1856,29 +1858,80 @@ async function collectAndPersistReports(options2) {
|
|
|
1856
1858
|
});
|
|
1857
1859
|
}
|
|
1858
1860
|
|
|
1859
|
-
// packages/core/src/lib/implementation/read-
|
|
1861
|
+
// packages/core/src/lib/implementation/read-rc-file.ts
|
|
1862
|
+
import { join as join4 } from "node:path";
|
|
1860
1863
|
var ConfigPathError = class extends Error {
|
|
1861
1864
|
constructor(configPath) {
|
|
1862
1865
|
super(`Provided path '${configPath}' is not valid.`);
|
|
1863
1866
|
}
|
|
1864
1867
|
};
|
|
1865
|
-
async function
|
|
1868
|
+
async function readRcByPath(filepath) {
|
|
1869
|
+
if (filepath.length === 0) {
|
|
1870
|
+
throw new Error("The path to the configuration file is empty.");
|
|
1871
|
+
}
|
|
1866
1872
|
if (!await fileExists(filepath)) {
|
|
1867
1873
|
throw new ConfigPathError(filepath);
|
|
1868
1874
|
}
|
|
1869
|
-
|
|
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}`));
|
|
1870
1896
|
}
|
|
1871
1897
|
|
|
1872
1898
|
// packages/cli/src/lib/constants.ts
|
|
1873
1899
|
var CLI_NAME = "Code PushUp CLI";
|
|
1874
1900
|
var CLI_SCRIPT_NAME = "code-pushup";
|
|
1875
1901
|
|
|
1902
|
+
// packages/cli/src/lib/implementation/global.utils.ts
|
|
1903
|
+
function filterKebabCaseKeys(obj) {
|
|
1904
|
+
return Object.entries(obj).filter(([key]) => !key.includes("-")).reduce(
|
|
1905
|
+
(acc, [key, value]) => typeof value === "string" || typeof value === "object" && Array.isArray(obj[key]) ? { ...acc, [key]: value } : typeof value === "object" && !Array.isArray(value) && value != null ? {
|
|
1906
|
+
...acc,
|
|
1907
|
+
[key]: filterKebabCaseKeys(value)
|
|
1908
|
+
} : { ...acc, [key]: value },
|
|
1909
|
+
{}
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
function logErrorBeforeThrow(fn) {
|
|
1913
|
+
return async (...args) => {
|
|
1914
|
+
try {
|
|
1915
|
+
return await fn(...args);
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
console.error(error);
|
|
1918
|
+
await new Promise((resolve) => process.stdout.write("", resolve));
|
|
1919
|
+
throw error;
|
|
1920
|
+
}
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
function coerceArray(param = []) {
|
|
1924
|
+
return [
|
|
1925
|
+
...new Set(toArray(param).flatMap((f) => f.split(",")) || [])
|
|
1926
|
+
];
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1876
1929
|
// packages/cli/src/lib/implementation/only-plugins.options.ts
|
|
1877
1930
|
var onlyPluginsOption = {
|
|
1878
1931
|
describe: "List of plugins to run. If not set all plugins are run.",
|
|
1879
1932
|
type: "array",
|
|
1880
1933
|
default: [],
|
|
1881
|
-
coerce:
|
|
1934
|
+
coerce: coerceArray
|
|
1882
1935
|
};
|
|
1883
1936
|
function yargsOnlyPluginsOptionsDefinition() {
|
|
1884
1937
|
return {
|
|
@@ -1933,28 +1986,6 @@ function yargsCollectCommandObject() {
|
|
|
1933
1986
|
};
|
|
1934
1987
|
}
|
|
1935
1988
|
|
|
1936
|
-
// packages/cli/src/lib/implementation/global.utils.ts
|
|
1937
|
-
function filterKebabCaseKeys(obj) {
|
|
1938
|
-
return Object.entries(obj).filter(([key]) => !key.includes("-")).reduce(
|
|
1939
|
-
(acc, [key, value]) => typeof value === "string" || typeof value === "object" && Array.isArray(obj[key]) ? { ...acc, [key]: value } : typeof value === "object" && !Array.isArray(value) && value != null ? {
|
|
1940
|
-
...acc,
|
|
1941
|
-
[key]: filterKebabCaseKeys(value)
|
|
1942
|
-
} : { ...acc, [key]: value },
|
|
1943
|
-
{}
|
|
1944
|
-
);
|
|
1945
|
-
}
|
|
1946
|
-
function logErrorBeforeThrow(fn) {
|
|
1947
|
-
return async (...args) => {
|
|
1948
|
-
try {
|
|
1949
|
-
return await fn(...args);
|
|
1950
|
-
} catch (error) {
|
|
1951
|
-
console.error(error);
|
|
1952
|
-
await new Promise((resolve) => process.stdout.write("", resolve));
|
|
1953
|
-
throw error;
|
|
1954
|
-
}
|
|
1955
|
-
};
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
1989
|
// packages/cli/src/lib/print-config/print-config-command.ts
|
|
1959
1990
|
function yargsConfigCommandObject() {
|
|
1960
1991
|
const command = "print-config";
|
|
@@ -2012,12 +2043,12 @@ async function coreConfigMiddleware(processArgs) {
|
|
|
2012
2043
|
upload: cliUpload,
|
|
2013
2044
|
...remainingCliOptions
|
|
2014
2045
|
} = args;
|
|
2015
|
-
const
|
|
2046
|
+
const importedRc = config ? await readRcByPath(config) : await autoloadRc();
|
|
2016
2047
|
const {
|
|
2017
2048
|
persist: rcPersist,
|
|
2018
2049
|
upload: rcUpload,
|
|
2019
2050
|
...remainingRcConfig
|
|
2020
|
-
} =
|
|
2051
|
+
} = importedRc;
|
|
2021
2052
|
const parsedProcessArgs = {
|
|
2022
2053
|
config,
|
|
2023
2054
|
...remainingRcConfig,
|
|
@@ -2161,9 +2192,8 @@ function yargsGlobalOptionsDefinition() {
|
|
|
2161
2192
|
default: false
|
|
2162
2193
|
},
|
|
2163
2194
|
config: {
|
|
2164
|
-
describe: "Path the the config file, e.g. code-pushup.config.js",
|
|
2165
|
-
type: "string"
|
|
2166
|
-
default: "code-pushup.config.js"
|
|
2195
|
+
describe: "Path the the config file, e.g. code-pushup.config.ts. By default it loads code-pushup.config.(ts|mjs|js).",
|
|
2196
|
+
type: "string"
|
|
2167
2197
|
}
|
|
2168
2198
|
};
|
|
2169
2199
|
}
|