@code-pushup/core 0.84.0 → 0.85.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core business logic for the used by the Code PushUp CLI",
|
|
6
6
|
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/core#readme",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@code-pushup/models": "0.
|
|
43
|
-
"@code-pushup/utils": "0.
|
|
42
|
+
"@code-pushup/models": "0.85.0",
|
|
43
|
+
"@code-pushup/utils": "0.85.0",
|
|
44
44
|
"ansis": "^3.3.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { collectAndPersistReports, type CollectAndPersistReportsOptions, } from './lib/collect-and-persist.js';
|
|
2
2
|
export { compareReportFiles, compareReports, type CompareOptions, } from './lib/compare.js';
|
|
3
|
-
export { getRunnerOutputsPath, type
|
|
3
|
+
export { getRunnerOutputsPath, type RunnerResult, } from './lib/implementation/runner.js';
|
|
4
4
|
export { history, type HistoryOnlyOptions, type HistoryOptions, } from './lib/history.js';
|
|
5
5
|
export { collect, type CollectOptions } from './lib/implementation/collect.js';
|
|
6
6
|
export type { ReportsToCompare } from './lib/implementation/compare-scorables.js';
|
|
7
7
|
export { executePlugin, executePlugins, } from './lib/implementation/execute-plugin.js';
|
|
8
|
-
export { AuditOutputsMissingAuditError } from './lib/implementation/runner.js';
|
|
9
8
|
export { PersistDirError, PersistError, persistReport, } from './lib/implementation/persist.js';
|
|
10
9
|
export { autoloadRc, ConfigPathError, readRcByPath, } from './lib/implementation/read-rc-file.js';
|
|
10
|
+
export { AuditOutputsMissingAuditError } from './lib/implementation/runner.js';
|
|
11
11
|
export { mergeDiffs } from './lib/merge-diffs.js';
|
|
12
12
|
export type { GlobalOptions } from './lib/types.js';
|
|
13
13
|
export { upload, type UploadOptions } from './lib/upload.js';
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,9 @@ export { getRunnerOutputsPath, } from './lib/implementation/runner.js';
|
|
|
4
4
|
export { history, } from './lib/history.js';
|
|
5
5
|
export { collect } from './lib/implementation/collect.js';
|
|
6
6
|
export { executePlugin, executePlugins, } from './lib/implementation/execute-plugin.js';
|
|
7
|
-
export { AuditOutputsMissingAuditError } from './lib/implementation/runner.js';
|
|
8
7
|
export { PersistDirError, PersistError, persistReport, } from './lib/implementation/persist.js';
|
|
9
8
|
export { autoloadRc, ConfigPathError, readRcByPath, } from './lib/implementation/read-rc-file.js';
|
|
9
|
+
export { AuditOutputsMissingAuditError } from './lib/implementation/runner.js';
|
|
10
10
|
export { mergeDiffs } from './lib/merge-diffs.js';
|
|
11
11
|
export { upload } from './lib/upload.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,OAAO,GAGR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAuB,MAAM,iCAAiC,CAAC;AAE/E,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,wCAAwC,CAAC;AAChD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,OAAO,GAGR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAuB,MAAM,iCAAiC,CAAC;AAE/E,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,UAAU,EACV,eAAe,EACf,YAAY,GACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAsB,MAAM,iBAAiB,CAAC"}
|
|
@@ -2,22 +2,17 @@ import { type AuditOutputs, type PluginConfig, type RunnerArgs, type RunnerConfi
|
|
|
2
2
|
export type RunnerResult = {
|
|
3
3
|
date: string;
|
|
4
4
|
duration: number;
|
|
5
|
-
audits: unknown;
|
|
6
|
-
};
|
|
7
|
-
export type ValidatedRunnerResult = Omit<RunnerResult, 'audits'> & {
|
|
8
5
|
audits: AuditOutputs;
|
|
9
6
|
};
|
|
10
|
-
export declare function executeRunnerConfig(config: RunnerConfig, args: RunnerArgs): Promise<
|
|
11
|
-
export declare function executeRunnerFunction(runner: RunnerFunction, args: RunnerArgs): Promise<
|
|
7
|
+
export declare function executeRunnerConfig(config: RunnerConfig, args: RunnerArgs): Promise<unknown>;
|
|
8
|
+
export declare function executeRunnerFunction(runner: RunnerFunction, args: RunnerArgs): Promise<unknown>;
|
|
12
9
|
/**
|
|
13
10
|
* Error thrown when plugin output is invalid.
|
|
14
11
|
*/
|
|
15
12
|
export declare class AuditOutputsMissingAuditError extends Error {
|
|
16
13
|
constructor(auditSlug: string);
|
|
17
14
|
}
|
|
18
|
-
export declare function executePluginRunner(pluginConfig: Pick<PluginConfig, 'audits' | 'runner'>, args: RunnerArgs): Promise<
|
|
19
|
-
audits: AuditOutputs;
|
|
20
|
-
}>;
|
|
15
|
+
export declare function executePluginRunner(pluginConfig: Pick<PluginConfig, 'audits' | 'runner'>, args: RunnerArgs): Promise<RunnerResult>;
|
|
21
16
|
export declare function getRunnerOutputsPath(pluginSlug: string, outputDir: string): string;
|
|
22
17
|
/**
|
|
23
18
|
* Save audit outputs to a file to be able to cache the results
|
|
@@ -25,5 +20,5 @@ export declare function getRunnerOutputsPath(pluginSlug: string, outputDir: stri
|
|
|
25
20
|
* @param pluginSlug
|
|
26
21
|
* @param outputDir
|
|
27
22
|
*/
|
|
28
|
-
export declare function writeRunnerResults(pluginSlug: string, outputDir: string, runnerResult:
|
|
29
|
-
export declare function readRunnerResults(pluginSlug: string, outputDir: string): Promise<
|
|
23
|
+
export declare function writeRunnerResults(pluginSlug: string, outputDir: string, runnerResult: RunnerResult): Promise<void>;
|
|
24
|
+
export declare function readRunnerResults(pluginSlug: string, outputDir: string): Promise<RunnerResult | null>;
|
|
@@ -2,21 +2,13 @@ import { bold } from 'ansis';
|
|
|
2
2
|
import { writeFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { auditOutputsSchema, } from '@code-pushup/models';
|
|
5
|
-
import { calcDuration, ensureDirectoryExists, executeProcess, fileExists,
|
|
5
|
+
import { calcDuration, ensureDirectoryExists, executeProcess, fileExists, readJsonFile, removeDirectoryIfExists, runnerArgsToEnv, } from '@code-pushup/utils';
|
|
6
6
|
import { normalizeAuditOutputs } from '../normalize.js';
|
|
7
7
|
export async function executeRunnerConfig(config, args) {
|
|
8
8
|
const { outputFile, outputTransform } = config;
|
|
9
|
-
|
|
9
|
+
await executeProcess({
|
|
10
10
|
command: config.command,
|
|
11
11
|
args: config.args,
|
|
12
|
-
observer: {
|
|
13
|
-
onStdout: stdout => {
|
|
14
|
-
if (isVerbose()) {
|
|
15
|
-
ui().logger.log(stdout);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
onStderr: stderr => ui().logger.error(stderr),
|
|
19
|
-
},
|
|
20
12
|
env: { ...process.env, ...runnerArgsToEnv(args) },
|
|
21
13
|
});
|
|
22
14
|
// read process output from the file system and parse it
|
|
@@ -25,24 +17,12 @@ export async function executeRunnerConfig(config, args) {
|
|
|
25
17
|
await removeDirectoryIfExists(path.dirname(outputFile));
|
|
26
18
|
// transform unknownAuditOutputs to auditOutputs
|
|
27
19
|
const audits = outputTransform ? await outputTransform(outputs) : outputs;
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
duration,
|
|
31
|
-
date,
|
|
32
|
-
audits,
|
|
33
|
-
};
|
|
20
|
+
return audits;
|
|
34
21
|
}
|
|
35
22
|
export async function executeRunnerFunction(runner, args) {
|
|
36
|
-
const date = new Date().toISOString();
|
|
37
|
-
const start = performance.now();
|
|
38
23
|
// execute plugin runner
|
|
39
24
|
const audits = await runner(args);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
date,
|
|
43
|
-
duration: calcDuration(start),
|
|
44
|
-
audits,
|
|
45
|
-
};
|
|
25
|
+
return audits;
|
|
46
26
|
}
|
|
47
27
|
/**
|
|
48
28
|
* Error thrown when plugin output is invalid.
|
|
@@ -54,10 +34,12 @@ export class AuditOutputsMissingAuditError extends Error {
|
|
|
54
34
|
}
|
|
55
35
|
export async function executePluginRunner(pluginConfig, args) {
|
|
56
36
|
const { audits: pluginConfigAudits, runner } = pluginConfig;
|
|
57
|
-
const
|
|
37
|
+
const date = new Date().toISOString();
|
|
38
|
+
const start = performance.now();
|
|
39
|
+
const unvalidatedAuditOutputs = typeof runner === 'object'
|
|
58
40
|
? await executeRunnerConfig(runner, args)
|
|
59
41
|
: await executeRunnerFunction(runner, args);
|
|
60
|
-
const
|
|
42
|
+
const duration = calcDuration(start);
|
|
61
43
|
const result = auditOutputsSchema.safeParse(unvalidatedAuditOutputs);
|
|
62
44
|
if (!result.success) {
|
|
63
45
|
throw new Error(`Audit output is invalid: ${result.error.message}`);
|
|
@@ -65,7 +47,8 @@ export async function executePluginRunner(pluginConfig, args) {
|
|
|
65
47
|
const auditOutputs = result.data;
|
|
66
48
|
auditOutputsCorrelateWithPluginOutput(auditOutputs, pluginConfigAudits);
|
|
67
49
|
return {
|
|
68
|
-
|
|
50
|
+
date,
|
|
51
|
+
duration,
|
|
69
52
|
audits: await normalizeAuditOutputs(auditOutputs),
|
|
70
53
|
};
|
|
71
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../src/lib/implementation/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAML,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../src/lib/implementation/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAML,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,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