apex-code-coverage-transformer 1.7.2 → 1.7.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/README.md CHANGED
@@ -10,16 +10,17 @@ This plugin supports code coverage metrics created for Apex Classes and Apex Tri
10
10
 
11
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.
12
12
 
13
- To create the code coverage JSON during a Salesforce CLI deployment/validation, append `--coverage-formatters json --results-dir coverage` to the `sf project deploy` command. This will create a coverage JSON in this relative path - `coverage/coverage/coverage.json`.
13
+ To create the code coverage JSON during a Salesforce CLI deployment/validation, append `--coverage-formatters json --results-dir "coverage"` to the `sf project deploy` command. This will create a coverage JSON in this relative path - `coverage/coverage/coverage.json`.
14
14
 
15
15
  ```
16
- sf project deploy [start/validate] -x manifest/package.xml -l RunSpecifiedTests -t {testclasses} --verbose --coverage-formatters json --results-dir coverage
16
+ sf project deploy [start/validate] --coverage-formatters json --results-dir "coverage"
17
17
  ```
18
18
 
19
- To create the code coverage JSON when running tests directly in the org, append `-c -r json` to the `sf apex run test` command.
19
+ To create the code coverage JSON when running tests directly in the org, append `--code-coverage --result-format json --output-dir "coverage"` to the `sf apex run test` or `sf apex get test` command. This will create the code coverage JSON in the a folder named "coverage".
20
20
 
21
21
  ```
22
- sf apex run test -c -r json
22
+ sf apex run test --code-coverage --result-format json --output-dir "coverage"
23
+ sf apex get test --test-run-id <test run id> --code-coverage --result-format json --output-dir "coverage"
23
24
  ```
24
25
 
25
26
  The code coverage JSONs created by the Salesforce CLI aren't accepted by SonarQube automatically for git-based Salesforce repositories and needs to be converted using this plugin.
@@ -65,7 +66,7 @@ EXAMPLES
65
66
 
66
67
  A post-run hook has been configured if you elect to use it.
67
68
 
68
- The post-run hook will automatically transform the code coverage JSON file into a generic test coverage report XML after every Salesforce CLI deployment (`sf project deploy start`, `sf project deploy validate`, `sf project deploy report`, `sf project deploy resume` commands) and test run (`sf apex run test` command) if the JSON is found.
69
+ The post-run hook will automatically transform the code coverage JSON file into a generic test coverage report XML after every Salesforce CLI deployment (`sf project deploy start`, `sf project deploy validate`, `sf project deploy report`, `sf project deploy resume` commands) and test run (`sf apex run test` and `sf apex get test` commands) if the JSON is found.
69
70
 
70
71
  The hook requires you to create this file in the root of your repo: `.apexcodecovtransformer.config.json`
71
72
 
@@ -73,12 +74,14 @@ The `.apexcodecovtransformer.config.json` should look like this:
73
74
 
74
75
  ```json
75
76
  {
76
- "coverageJsonPath": "coverage/coverage/coverage.json",
77
+ "deployCoverageJsonPath": "coverage/coverage/coverage.json",
78
+ "testCoverageJsonPath": "coverage/test-coverage.json",
77
79
  "coverageXmlPath": "coverage.xml"
78
80
  }
79
81
  ```
80
82
 
81
- - `coverageJsonPath` is required and should be the path to the code coverage JSON created by the Salesforce CLI. Recommend using a relative path.
83
+ - `deployCoverageJsonPath` is required to use the hook after deployments and should be the path to the code coverage JSON created by the Salesforce CLI deployment command. Recommend using a relative path.
84
+ - `testCoverageJsonPath` is required to use the hook after test runs and should be the path to the code coverage JSON created by the Salesforce CLI test command. Recommend using a relative path.
82
85
  - `coverageXmlPath` is optional and should be the path to the code coverage XML created by this plugin. Recommend using a relative path. If this isn't provided, it will default to `coverage.xml` in the working directory.
83
86
 
84
87
  If the `.apexcodecovtransformer.config.json` file isn't found, the hook will be skipped.
@@ -93,12 +96,12 @@ Warning: The file name AccountTrigger was not found in any package directory.
93
96
 
94
97
  Files not found in any package directory will not be added to the coverage XML. This includes Apex classes that originate from installed managed and unlocked packages when running all tests in your org.
95
98
 
96
- If none of the files listed in the coverage JSON were found in a package directory, the plugin will fail with this error in addition to the above warnings:
99
+ If none of the files listed in the coverage JSON were found in a package directory, the plugin will print an additional warning stating no files were processed. In this case, the coverage XML generated will be an empty file.
97
100
 
98
101
  ```
99
102
  Warning: The file name AccountTrigger was not found in any package directory.
100
103
  Warning: The file name AccountProfile was not found in any package directory.
101
- Error (1): None of the files listed in the coverage JSON were processed.
104
+ Warning: None of the files listed in the coverage JSON were processed. The coverage XML will be empty.
102
105
  ```
103
106
 
104
107
  If the `sfdx-project.json` file was not found in your repository's root folder, the plugin will fail with:
@@ -115,7 +118,7 @@ Error (1): ENOENT: no such file or directory: {packageDirPath}
115
118
 
116
119
  ## Example
117
120
 
118
- This [code coverage JSON file](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/coverage_no_file_exts.json) created during a Salesforce CLI deployment will be transformed into:
121
+ This [code coverage JSON file](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/test/deploy_coverage_no_file_exts.json) created during a Salesforce CLI deployment will be transformed into:
119
122
 
120
123
  ```xml
121
124
  <?xml version="1.0"?>
@@ -63,10 +63,10 @@ export default class TransformerTransform extends SfCommand {
63
63
  });
64
64
  }
65
65
  if (filesProcessed === 0) {
66
- this.error('None of the files listed in the coverage JSON were processed.');
66
+ this.warn('None of the files listed in the coverage JSON were processed. The coverage XML will be empty.');
67
67
  }
68
68
  await writeFile(xmlFilePath, xmlData);
69
- this.log(`The XML data has been written to ${xmlFilePath}`);
69
+ this.log(`The coverage XML has been written to ${xmlFilePath}`);
70
70
  return { path: xmlFilePath };
71
71
  }
72
72
  }
@@ -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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{ resolve } from 'node:path';
6
- import { simpleGit } from 'simple-git';
6
+ import { getRepoRoot } from './getRepoRoot.js';
7
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();
8
+ const repoRoot = await getRepoRoot();
16
9
  const dxConfigPath = resolve(repoRoot, 'sfdx-project.json');
17
10
  if (!existsSync(dxConfigPath)) {
18
11
  throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
@@ -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,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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O,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAChH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function getRepoRoot(): Promise<string>;
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+ import { simpleGit } from 'simple-git';
3
+ export async function getRepoRoot() {
4
+ const gitOptions = {
5
+ baseDir: process.cwd(),
6
+ binary: 'git',
7
+ maxConcurrentProcesses: 6,
8
+ trimmed: true,
9
+ };
10
+ const git = simpleGit(gitOptions);
11
+ const repoRoot = (await git.revparse('--show-toplevel')).trim();
12
+ return repoRoot;
13
+ }
14
+ //# sourceMappingURL=getRepoRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/helpers/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,UAAU,GAA8B;QAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI;KACd,CAAC;IAEF,MAAM,GAAG,GAAc,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -13,7 +13,11 @@ export async function transformTestCoverageReport(testCoverageData) {
13
13
  testCoverageData = [testCoverageData];
14
14
  }
15
15
  for (const data of testCoverageData) {
16
- const { name, lines } = data;
16
+ const name = data?.name;
17
+ const lines = data?.lines;
18
+ if (!name || !lines) {
19
+ continue;
20
+ }
17
21
  const formattedFileName = name.replace(/no-map[\\/]+/, '');
18
22
  const relativeFilePath = await findFilePath(formattedFileName, packageDirectories, repoRoot);
19
23
  if (relativeFilePath === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"transformTestCoverageReport.js","sourceRoot":"","sources":["../../src/helpers/transformTestCoverageReport.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,gBAAoC;IAEpC,MAAM,WAAW,GAAmB,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC;IAChF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,cAAc,GAAW,CAAC,CAAC;IAC/B,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAEvE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrC,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;QACpC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC7B,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAC3D,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC7F,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,QAAQ,CAAC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,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"}
@@ -46,7 +46,8 @@ export interface CoverageObject {
46
46
  };
47
47
  }
48
48
  export interface ConfigFile {
49
- coverageJsonPath: string;
49
+ deployCoverageJsonPath: string;
50
+ testCoverageJsonPath: string;
50
51
  coverageXmlPath: string;
51
52
  }
52
53
  export {};
@@ -2,28 +2,22 @@
2
2
  import { existsSync } from 'node:fs';
3
3
  import { readFile } from 'node:fs/promises';
4
4
  import { resolve } from 'node:path';
5
- import { simpleGit } from 'simple-git';
6
5
  import TransformerTransform from '../commands/apex-code-coverage/transformer/transform.js';
6
+ import { getRepoRoot } from '../helpers/getRepoRoot.js';
7
7
  export const postrun = async function (options) {
8
8
  let commandType;
9
+ let coverageJson;
9
10
  if (['project:deploy:validate', 'project:deploy:start', 'project:deploy:report', 'project:deploy:resume'].includes(options.Command.id)) {
10
11
  commandType = 'deploy';
11
12
  }
12
- else if (['apex:run:test'].includes(options.Command.id)) {
13
+ else if (['apex:run:test', 'apex:get:test'].includes(options.Command.id)) {
13
14
  commandType = 'test';
14
15
  }
15
16
  else {
16
17
  return;
17
18
  }
18
19
  let configFile;
19
- const gitOptions = {
20
- baseDir: process.cwd(),
21
- binary: 'git',
22
- maxConcurrentProcesses: 6,
23
- trimmed: true,
24
- };
25
- const git = simpleGit(gitOptions);
26
- const repoRoot = (await git.revparse('--show-toplevel')).trim();
20
+ const repoRoot = await getRepoRoot();
27
21
  const configPath = resolve(repoRoot, '.apexcodecovtransformer.config.json');
28
22
  try {
29
23
  const jsonString = await readFile(configPath, 'utf-8');
@@ -32,8 +26,13 @@ export const postrun = async function (options) {
32
26
  catch (error) {
33
27
  return;
34
28
  }
35
- const coverageJson = configFile.coverageJsonPath || '.';
36
29
  const coverageXml = configFile.coverageXmlPath || 'coverage.xml';
30
+ if (commandType === 'deploy') {
31
+ coverageJson = configFile.deployCoverageJsonPath || '.';
32
+ }
33
+ else {
34
+ coverageJson = configFile.testCoverageJsonPath || '.';
35
+ }
37
36
  if (coverageJson.trim() === '.') {
38
37
  return;
39
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../src/hooks/postrun.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AACpE,OAAO,oBAAoB,MAAM,yDAAyD,CAAC;AAG3F,MAAM,CAAC,MAAM,OAAO,GAAoB,KAAK,WAAW,OAAO;IAC7D,IAAI,WAAmB,CAAC;IACxB,IACE,CAAC,yBAAyB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,QAAQ,CAC5G,OAAO,CAAC,OAAO,CAAC,EAAE,CACnB,EACD,CAAC;QACD,WAAW,GAAG,QAAQ,CAAC;IACzB,CAAC;SAAM,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC1D,WAAW,GAAG,MAAM,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO;IACT,CAAC;IACD,IAAI,UAAsB,CAAC;IAC3B,MAAM,UAAU,GAA8B;QAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EA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T,CAAC;IAED,MAAM,WAAW,GAAW,UAAU,CAAC,eAAe,IAAI,cAAc,CAAC;IAEzE,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC7B,YAAY,GAAG,UAAU,CAAC,sBAAsB,IAAI,GAAG,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,UAAU,CAAC,oBAAoB,IAAI,GAAG,CAAC;IACxD,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACpC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9B,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9B,MAAM,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "version": "1.7.2"
80
+ "version": "1.7.4"
81
81
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "apex-code-coverage-transformer",
3
- "description": "Transforms the Apex code coverage JSON created during Salesforce deployments into the Generic Test Coverage Format (XML).",
4
- "version": "1.7.2",
3
+ "description": "Transforms the Apex code coverage JSON created during Salesforce deployments and test runs into the Generic Test Coverage Format (XML) for SonarQube.",
4
+ "version": "1.7.4",
5
5
  "dependencies": {
6
6
  "@oclif/core": "^3.18.1",
7
7
  "@salesforce/core": "^6.4.7",