apex-code-coverage-transformer 1.6.6 → 1.6.8
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 +6 -5
- package/lib/commands/apex-code-coverage/transformer/transform.d.ts +0 -1
- package/lib/commands/apex-code-coverage/transformer/transform.js +1 -9
- package/lib/commands/apex-code-coverage/transformer/transform.js.map +1 -1
- package/lib/helpers/convertToGenericCoverageReport.d.ts +1 -1
- package/lib/helpers/convertToGenericCoverageReport.js +4 -2
- package/lib/helpers/convertToGenericCoverageReport.js.map +1 -1
- package/lib/helpers/findFilePath.d.ts +1 -4
- package/lib/helpers/findFilePath.js +2 -4
- package/lib/helpers/findFilePath.js.map +1 -1
- package/lib/helpers/getPackageDirectories.d.ts +1 -1
- package/lib/helpers/getPackageDirectories.js +15 -6
- package/lib/helpers/getPackageDirectories.js.map +1 -1
- package/messages/transformer.transform.md +1 -5
- package/oclif.lock +21 -0
- package/oclif.manifest.json +2 -12
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
The `apex-code-coverage-transformer` is a Salesforce CLI plugin to transform the Apex Code Coverage JSON files created during deployments into the Generic Test Coverage Format (XML). This format is accepted by static code analysis tools like SonarQube.
|
|
6
6
|
|
|
7
|
+
This plugin requires [git](https://git-scm.com/downloads) to be installed and that it can be called using the command `git`.
|
|
8
|
+
|
|
7
9
|
This plugin supports code coverage metrics created for Apex Classes and Apex Triggers. This also supports multiple package directories as listed in your project's `sfdx-project.json` configuration, assuming unique file-names are used in your package directories.
|
|
8
10
|
|
|
9
11
|
This plugin is intended for users who deploy their Apex codebase from a git-based repository and use SonarQube for code quality. This plugin will work if you run local tests or run all tests in an org, including tests that originate from installed managed and unlocked packages. SonarQube relies on file-paths to map code coverage to the files in their file explorer interface. Since files from managed and unlocked packages aren't retrieved into git-based Salesforce repositories, these files cannot be included in your SonarQube scans. If your Apex code coverage JSON output includes managed/unlocked package files, they will not be added to the coverage XML created by this plugin. A warning will be printed for each file not found in a package directory in your git repository. See [Errors and Warnings](https://github.com/mcarvin8/apex-code-coverage-transformer?tab=readme-ov-file#errors-and-warnings) for more information.
|
|
@@ -32,18 +34,17 @@ The `apex-code-coverage-transformer` has 1 command:
|
|
|
32
34
|
|
|
33
35
|
- `sf apex-code-coverage transformer transform`
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
This command needs to be ran somewhere inside your Salesforce DX git repository, whether in the root folder (recommended) or in a subfolder. This plugin will determine the root folder of this repository and read the `sfdx-project.json` file in the root folder. All package directories listed in the `sfdx-project.json` file will be processed when running this plugin.
|
|
36
38
|
|
|
37
39
|
## `sf apex-code-coverage transformer transform`
|
|
38
40
|
|
|
39
41
|
```
|
|
40
42
|
USAGE
|
|
41
|
-
$ sf apex-code-coverage transformer transform -j <value> -x <value>
|
|
43
|
+
$ sf apex-code-coverage transformer transform -j <value> -x <value> [--json]
|
|
42
44
|
|
|
43
45
|
FLAGS
|
|
44
46
|
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment command.
|
|
45
47
|
-x, --xml=<value> [default: coverage.xml] Path to code coverage XML file that will be created by this plugin.
|
|
46
|
-
-c, --sfdx-configuration=<value> [default: 'sfdx-project.json'] Path to your project's Salesforce DX configuration file.
|
|
47
48
|
|
|
48
49
|
GLOBAL FLAGS
|
|
49
50
|
--json Format output as json.
|
|
@@ -52,7 +53,7 @@ DESCRIPTION
|
|
|
52
53
|
This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments into an XML accepted by tools like SonarQube.
|
|
53
54
|
|
|
54
55
|
EXAMPLES
|
|
55
|
-
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml"
|
|
56
|
+
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml"
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
## Errors and Warnings
|
|
@@ -73,7 +74,7 @@ Warning: The file name AccountProfile was not found in any package directory.
|
|
|
73
74
|
Error (1): None of the files listed in the coverage JSON were processed.
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
If the `sfdx-project.json` file was not found, the plugin will fail with:
|
|
77
|
+
If the `sfdx-project.json` file was not found in your repository's root folder, the plugin will fail with:
|
|
77
78
|
|
|
78
79
|
```
|
|
79
80
|
Error (1): Salesforce DX Config File does not exist in this path: {filePath}
|
|
@@ -7,7 +7,6 @@ export default class TransformerTransform extends SfCommand<TransformerTransform
|
|
|
7
7
|
static readonly description: string;
|
|
8
8
|
static readonly examples: string[];
|
|
9
9
|
static readonly flags: {
|
|
10
|
-
'sfdx-configuration': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
10
|
'coverage-json': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
11
|
xml: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
12
|
};
|
|
@@ -11,13 +11,6 @@ export default class TransformerTransform extends SfCommand {
|
|
|
11
11
|
static description = messages.getMessage('description');
|
|
12
12
|
static examples = messages.getMessages('examples');
|
|
13
13
|
static flags = {
|
|
14
|
-
'sfdx-configuration': Flags.file({
|
|
15
|
-
summary: messages.getMessage('flags.sfdx-configuration.summary'),
|
|
16
|
-
char: 'c',
|
|
17
|
-
required: true,
|
|
18
|
-
exists: true,
|
|
19
|
-
default: 'sfdx-project.json',
|
|
20
|
-
}),
|
|
21
14
|
'coverage-json': Flags.file({
|
|
22
15
|
summary: messages.getMessage('flags.coverage-json.summary'),
|
|
23
16
|
char: 'j',
|
|
@@ -36,10 +29,9 @@ export default class TransformerTransform extends SfCommand {
|
|
|
36
29
|
const { flags } = await this.parse(TransformerTransform);
|
|
37
30
|
const jsonFilePath = resolve(flags['coverage-json']);
|
|
38
31
|
const xmlFilePath = resolve(flags['xml']);
|
|
39
|
-
const sfdxConfigFile = resolve(flags['sfdx-configuration']);
|
|
40
32
|
const jsonData = await readFile(jsonFilePath, 'utf-8');
|
|
41
33
|
const coverageData = JSON.parse(jsonData);
|
|
42
|
-
const { xml: xmlData, warnings, filesProcessed
|
|
34
|
+
const { xml: xmlData, warnings, filesProcessed } = await convertToGenericCoverageReport(coverageData);
|
|
43
35
|
// Print warnings if any
|
|
44
36
|
if (warnings.length > 0) {
|
|
45
37
|
warnings.forEach((warning) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../src/commands/apex-code-coverage/transformer/transform.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AAEpG,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,gCAAgC,EAAE,uBAAuB,CAAC,CAAC;AAMlG,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,SAAqC;IAC9E,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,
|
|
1
|
+
{"version":3,"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C;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAE1C,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAiB,CAAC;QAC1D,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,8BAA8B,CAAC,YAAY,CAAC,CAAC;QAEtG,wBAAwB;QACxB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,cAAc,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;QAC5D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CoverageData } from './types.js';
|
|
2
|
-
export declare function convertToGenericCoverageReport(data: CoverageData
|
|
2
|
+
export declare function convertToGenericCoverageReport(data: CoverageData): Promise<{
|
|
3
3
|
xml: string;
|
|
4
4
|
warnings: string[];
|
|
5
5
|
filesProcessed: number;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* eslint-disable no-await-in-loop */
|
|
3
3
|
import { create } from 'xmlbuilder2';
|
|
4
|
+
import { getPackageDirectories } from './getPackageDirectories.js';
|
|
4
5
|
import { findFilePath } from './findFilePath.js';
|
|
5
6
|
import { setCoveredLines } from './setCoveredLines.js';
|
|
6
7
|
import { normalizePathToUnix } from './normalizePathToUnix.js';
|
|
7
|
-
export async function convertToGenericCoverageReport(data
|
|
8
|
+
export async function convertToGenericCoverageReport(data) {
|
|
8
9
|
const coverageObj = { coverage: { '@version': '1', file: [] } };
|
|
9
10
|
const warnings = [];
|
|
10
11
|
let filesProcessed = 0;
|
|
12
|
+
const { repoRoot, packageDirectories } = await getPackageDirectories();
|
|
11
13
|
for (const fileName in data) {
|
|
12
14
|
if (!Object.hasOwn(data, fileName))
|
|
13
15
|
continue;
|
|
14
16
|
const fileInfo = data[fileName];
|
|
15
17
|
const formattedFileName = fileName.replace('no-map/', '');
|
|
16
|
-
const
|
|
18
|
+
const relativeFilePath = await findFilePath(formattedFileName, packageDirectories, repoRoot);
|
|
17
19
|
if (relativeFilePath === undefined) {
|
|
18
20
|
warnings.push(`The file name ${formattedFileName} was not found in any package directory.`);
|
|
19
21
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertToGenericCoverageReport.js","sourceRoot":"","sources":["../../src/helpers/convertToGenericCoverageReport.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,IAAkB
|
|
1
|
+
{"version":3,"file":"conv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AAQ,CAAC,CAAC,CAAC;aAC3C,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aACpD,GAAG,CAAC,MAAM,CAAC,CAAC;QACf,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aACzC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aACpD,GAAG,CAAC,MAAM,CAAC,CAAC;QAEf,MAAM,OAAO,GAAe;YAC1B,OAAO,EAAE,mBAAmB,CAAC,gBAAgB,CAAC;YAC9C,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,UAAkB,EAAE,EAAE,CAAC,CAAC;gBACvD,aAAa,EAAE,UAAU;gBACzB,UAAU,EAAE,OAAO;aACpB,CAAC,CAAC;SACJ,CAAC;QAEF,gGAAgG;QAChG,MAAM,eAAe,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACzF,cAAc,EAAE,CAAC;QACjB,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export declare function findFilePath(fileName: string,
|
|
2
|
-
repoRoot: string;
|
|
3
|
-
relativeFilePath: string | undefined;
|
|
4
|
-
}>;
|
|
1
|
+
export declare function findFilePath(fileName: string, packageDirectories: string[], repoRoot: string): Promise<string | undefined>;
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
/* eslint-disable no-await-in-loop */
|
|
3
3
|
import { readdir, stat } from 'node:fs/promises';
|
|
4
4
|
import { join, relative } from 'node:path';
|
|
5
|
-
|
|
6
|
-
export async function findFilePath(fileName, dxConfigFile) {
|
|
7
|
-
const { repoRoot, packageDirectories } = await getPackageDirectories(dxConfigFile);
|
|
5
|
+
export async function findFilePath(fileName, packageDirectories, repoRoot) {
|
|
8
6
|
let relativeFilePath;
|
|
9
7
|
for (const directory of packageDirectories) {
|
|
10
8
|
relativeFilePath = await findFilePathinDirectory(fileName, directory, repoRoot);
|
|
@@ -12,7 +10,7 @@ export async function findFilePath(fileName, dxConfigFile) {
|
|
|
12
10
|
break;
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
return
|
|
13
|
+
return relativeFilePath;
|
|
16
14
|
}
|
|
17
15
|
async function searchRecursively(fileName, dxDirectory) {
|
|
18
16
|
const files = await readdir(dxDirectory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findFilePath.js","sourceRoot":"","sources":["../../src/helpers/findFilePath.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"findFilePath.js","sourceRoot":"","sources":["../../src/helpers/findFilePath.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,kBAA4B,EAC5B,QAAgB;IAEhB,IAAI,gBAAoC,CAAC;IACzC,KAA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AK,SAAS;YAAE,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAC9F,CAAC;SAAM,CAAC;QACN,+DAA+D;QAC/D,MAAM,QAAQ,GAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,GAAG,QAAQ,IAAI,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;YACpF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;gBACxD,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
/* eslint-disable no-await-in-loop */
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { simpleGit } from 'simple-git';
|
|
7
|
+
export async function getPackageDirectories() {
|
|
8
|
+
const options = {
|
|
9
|
+
baseDir: process.cwd(),
|
|
10
|
+
binary: 'git',
|
|
11
|
+
maxConcurrentProcesses: 6,
|
|
12
|
+
trimmed: true,
|
|
13
|
+
};
|
|
14
|
+
const git = simpleGit(options);
|
|
15
|
+
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
16
|
+
const dxConfigPath = resolve(repoRoot, 'sfdx-project.json');
|
|
17
|
+
if (!existsSync(dxConfigPath)) {
|
|
18
|
+
throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
|
|
9
19
|
}
|
|
10
|
-
const sfdxProjectRaw = await readFile(
|
|
20
|
+
const sfdxProjectRaw = await readFile(dxConfigPath, 'utf-8');
|
|
11
21
|
const sfdxProject = JSON.parse(sfdxProjectRaw);
|
|
12
|
-
const repoRoot = dirname(dxConfigFile);
|
|
13
22
|
const packageDirectories = sfdxProject.packageDirectories.map((directory) => resolve(repoRoot, directory.path));
|
|
14
23
|
return { repoRoot, packageDirectories };
|
|
15
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/helpers/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/helpers/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AAIpE,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,OAAO,GAA8B;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI;KACd,CAAC;IACF,MAAM,GAAG,GAAc,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IAC5D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,CAAC,0DAA0D,YAAY,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,cAAc,GAAW,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrE,MAAM,WAAW,GAAgB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAgB,CAAC;IAC3E,MAAM,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAChH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -8,11 +8,7 @@ This plugin will convert the code coverage JSON file created by the Salesforce C
|
|
|
8
8
|
|
|
9
9
|
# examples
|
|
10
10
|
|
|
11
|
-
- `sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml"
|
|
12
|
-
|
|
13
|
-
# flags.sfdx-configuration.summary
|
|
14
|
-
|
|
15
|
-
Path to your project's Salesforce DX configuration file.
|
|
11
|
+
- `sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml"`
|
|
16
12
|
|
|
17
13
|
# flags.coverage-json.summary
|
|
18
14
|
|
package/oclif.lock
CHANGED
|
@@ -1382,6 +1382,18 @@
|
|
|
1382
1382
|
"@jridgewell/resolve-uri" "^3.0.3"
|
|
1383
1383
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
|
1384
1384
|
|
|
1385
|
+
"@kwsites/file-exists@^1.1.1":
|
|
1386
|
+
version "1.1.1"
|
|
1387
|
+
resolved "https://registry.yarnpkg.com/@kwsites/file-exists/-/file-exists-1.1.1.tgz#ad1efcac13e1987d8dbaf235ef3be5b0d96faa99"
|
|
1388
|
+
integrity sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==
|
|
1389
|
+
dependencies:
|
|
1390
|
+
debug "^4.1.1"
|
|
1391
|
+
|
|
1392
|
+
"@kwsites/promise-deferred@^1.1.1":
|
|
1393
|
+
version "1.1.1"
|
|
1394
|
+
resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919"
|
|
1395
|
+
integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==
|
|
1396
|
+
|
|
1385
1397
|
"@nodelib/fs.scandir@2.1.5":
|
|
1386
1398
|
version "2.1.5"
|
|
1387
1399
|
resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz"
|
|
@@ -10634,6 +10646,15 @@ sigstore@^2.2.0:
|
|
|
10634
10646
|
"@sigstore/tuf" "^2.3.0"
|
|
10635
10647
|
"@sigstore/verify" "^0.1.0"
|
|
10636
10648
|
|
|
10649
|
+
simple-git@^3.24.0:
|
|
10650
|
+
version "3.24.0"
|
|
10651
|
+
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.24.0.tgz#33a8c88dc6fa74e53eaf3d6bfc27d0182a49ec00"
|
|
10652
|
+
integrity sha512-QqAKee9Twv+3k8IFOFfPB2hnk6as6Y6ACUpwCtQvRYBAes23Wv3SZlHVobAzqcE8gfsisCvPw3HGW3HYM+VYYw==
|
|
10653
|
+
dependencies:
|
|
10654
|
+
"@kwsites/file-exists" "^1.1.1"
|
|
10655
|
+
"@kwsites/promise-deferred" "^1.1.1"
|
|
10656
|
+
debug "^4.3.4"
|
|
10657
|
+
|
|
10637
10658
|
simple-swizzle@^0.2.2:
|
|
10638
10659
|
version "0.2.2"
|
|
10639
10660
|
resolved "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz"
|
package/oclif.manifest.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"args": {},
|
|
6
6
|
"description": "This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments into an XML accepted by tools like SonarQube.",
|
|
7
7
|
"examples": [
|
|
8
|
-
"`sf apex-code-coverage transformer transform -j \"coverage.json\" -x \"coverage.xml\"
|
|
8
|
+
"`sf apex-code-coverage transformer transform -j \"coverage.json\" -x \"coverage.xml\"`"
|
|
9
9
|
],
|
|
10
10
|
"flags": {
|
|
11
11
|
"json": {
|
|
@@ -15,16 +15,6 @@
|
|
|
15
15
|
"allowNo": false,
|
|
16
16
|
"type": "boolean"
|
|
17
17
|
},
|
|
18
|
-
"sfdx-configuration": {
|
|
19
|
-
"char": "c",
|
|
20
|
-
"name": "sfdx-configuration",
|
|
21
|
-
"required": true,
|
|
22
|
-
"summary": "Path to your project's Salesforce DX configuration file.",
|
|
23
|
-
"default": "sfdx-project.json",
|
|
24
|
-
"hasDynamicHelp": false,
|
|
25
|
-
"multiple": false,
|
|
26
|
-
"type": "option"
|
|
27
|
-
},
|
|
28
18
|
"coverage-json": {
|
|
29
19
|
"char": "j",
|
|
30
20
|
"name": "coverage-json",
|
|
@@ -73,5 +63,5 @@
|
|
|
73
63
|
]
|
|
74
64
|
}
|
|
75
65
|
},
|
|
76
|
-
"version": "1.6.
|
|
66
|
+
"version": "1.6.8"
|
|
77
67
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apex-code-coverage-transformer",
|
|
3
3
|
"description": "Transforms the Apex code coverage JSON created during Salesforce deployments into the Generic Test Coverage Format (XML).",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.8",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^3.18.1",
|
|
7
7
|
"@salesforce/core": "^6.4.7",
|
|
8
8
|
"@salesforce/sf-plugins-core": "^7.1.3",
|
|
9
|
+
"simple-git": "^3.24.0",
|
|
9
10
|
"xmlbuilder2": "^3.1.1"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
@@ -49,7 +50,8 @@
|
|
|
49
50
|
"json",
|
|
50
51
|
"sonarqube",
|
|
51
52
|
"apex",
|
|
52
|
-
"coverage"
|
|
53
|
+
"coverage",
|
|
54
|
+
"git"
|
|
53
55
|
],
|
|
54
56
|
"license": "MIT",
|
|
55
57
|
"oclif": {
|