apex-code-coverage-transformer 2.6.0 → 2.6.1
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/CHANGELOG.md +7 -0
- package/README.md +22 -23
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## [2.6.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.6.0...v2.6.1) (2025-01-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fix default test command path in doc and provide defaults ([c8dc711](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/c8dc71177d3ed9cae8dc7a41b7843fdc9d09ad5d))
|
|
14
|
+
|
|
8
15
|
## [2.6.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.5.2...v2.6.0) (2025-01-12)
|
|
9
16
|
|
|
10
17
|
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- [Install](#install)
|
|
10
10
|
- [Who is the Plugin For?](#who-is-the-plugin-for)
|
|
11
11
|
- [Creating Code Coverage Files with the Salesforce CLI](#creating-code-coverage-files-with-the-salesforce-cli)
|
|
12
|
+
- [Creating Code Coverage Files with SFDX Hardis](#creating-code-coverage-files-with-sfdx-hardis)
|
|
12
13
|
- [What this Plugin fixes in the Salesforce CLI Coverage Reports](#what-this-plugin-fixes-in-the-salesforce-cli-coverage-reports)
|
|
13
14
|
- [Command](#command)
|
|
14
15
|
- [`sf acc-transformer transform`](#sf-acc-transformer-transform)
|
|
@@ -45,7 +46,7 @@ To create the code coverage JSON when deploying or validating, append `--coverag
|
|
|
45
46
|
sf project deploy [start/validate] --coverage-formatters json --results-dir "coverage"
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
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
|
|
49
|
+
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 this relative path - `coverage/test-result-codecoverage.json`
|
|
49
50
|
|
|
50
51
|
```
|
|
51
52
|
sf apex run test --code-coverage --result-format json --output-dir "coverage"
|
|
@@ -54,6 +55,12 @@ sf apex get test --test-run-id <test run id> --code-coverage --result-format jso
|
|
|
54
55
|
|
|
55
56
|
The code coverage JSONs created by the Salesforce CLI aren't accepted automatically for Salesforce DX repositories and needs to be converted using this plugin.
|
|
56
57
|
|
|
58
|
+
## Creating Code Coverage Files with SFDX Hardis
|
|
59
|
+
|
|
60
|
+
This plugin can be used after running [sfdx-hardis](https://github.com/hardisgroupcom/sfdx-hardis) commands `hardis:project:deploy:smart` (only if `COVERAGE_FORMATTER_JSON=true` environment variable is defined) and `hardis:org:test:apex` assuming you have sfdx-hardis and this plugin installed.
|
|
61
|
+
|
|
62
|
+
Both hardis commands will create the code coverage JSON to transform here: `hardis-report/apex-coverage-results.json`. Provide this relative path as the `--coverage-json`/`-j` input for this plugin.
|
|
63
|
+
|
|
57
64
|
## What this Plugin fixes in the Salesforce CLI Coverage Reports
|
|
58
65
|
|
|
59
66
|
1. The coverage reports created by this plugin will add correct file-paths per your Salesforce DX repository. Salesforce CLI coverage reports have the `no-map/` prefix hard-coded into their coverage reports. The coverage report created in this plugin will only contain Apex coverage results against files found in your Salesforce DX repository, allowing you to use these reports in external code quality tools like SonarQube.
|
|
@@ -105,38 +112,30 @@ EXAMPLES
|
|
|
105
112
|
|
|
106
113
|
## Hook
|
|
107
114
|
|
|
108
|
-
A post-run hook has been configured if you
|
|
115
|
+
A post-run hook has been configured if you opt into using it by creating a `.apexcodecovtransformer.config.json` config file in the root of your repo. If the config file is found, the post-run hook will automatically run after the following commands:
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
- `sf project deploy start`
|
|
118
|
+
- `sf project deploy validate`
|
|
119
|
+
- `sf project deploy report`
|
|
120
|
+
- `sf project deploy resume`
|
|
121
|
+
- `sf apex run test`
|
|
122
|
+
- `sf apex get test`
|
|
123
|
+
- `hardis:project:deploy:smart` (only if sfdx-hardis is installed and `COVERAGE_FORMATTER_JSON=true` environment variable is defined)
|
|
124
|
+
- `hardis:org:test:apex` (only if sfdx-hardis is installed)
|
|
111
125
|
|
|
112
|
-
|
|
126
|
+
You can copy the sample [Salesforce CLI .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/salesforce-cli/.apexcodecovtransformer.config.json), which assumes you are running the Salesforce CLI commands and specifying the `--results-dir`/`--output-dir` directory as "coverage". Update this sample with your desired output report path and format.
|
|
113
127
|
|
|
114
|
-
|
|
128
|
+
You can copy the sample [SFDX Hardis .apexcodecovtransformer.config.json](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/defaults/sfdx-hardis/.apexcodecovtransformer.config.json), which assumes you are running the SFDX Hardis commands. Update this sample with your desired output report path and format.
|
|
115
129
|
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
"deployCoverageJsonPath": "coverage/coverage/coverage.json",
|
|
119
|
-
"testCoverageJsonPath": "coverage/test-coverage.json",
|
|
120
|
-
"outputReportPath": "coverage.xml",
|
|
121
|
-
"format": "sonar"
|
|
122
|
-
}
|
|
123
|
-
```
|
|
130
|
+
The `.apexcodecovtransformer.config.json` follows this structure:
|
|
124
131
|
|
|
125
|
-
- `deployCoverageJsonPath` is required to use the hook after
|
|
126
|
-
- `testCoverageJsonPath` is required to use the hook after test
|
|
132
|
+
- `deployCoverageJsonPath` is required to use the hook after deploy commands and should be the path to the code coverage JSON created by the Salesforce CLI/SFDX Hardis deploy command. Recommend using a relative path.
|
|
133
|
+
- `testCoverageJsonPath` is required to use the hook after test commands and should be the path to the code coverage JSON created by the Salesforce CLI/SFDX Hardis test command. Recommend using a relative path.
|
|
127
134
|
- `outputReportPath` is optional and should be the path to the code coverage file created by this plugin. Recommend using a relative path. If this isn't provided, it will default to `coverage.[xml/info]` in the working directory.
|
|
128
135
|
- `format` is optional and should be the intended output format for the code coverage file created by this plugin. Options are "sonar", "clover", "lcovonly", or "cobertura". If this isn't provided, it will default to "sonar".
|
|
129
136
|
|
|
130
137
|
If the `.apexcodecovtransformer.config.json` file isn't found, the hook will be skipped.
|
|
131
138
|
|
|
132
|
-
The post-run hook can also run after the [sfdx-hardis](https://github.com/hardisgroupcom/sfdx-hardis) commands `hardis:project:deploy:smart` (only if `COVERAGE_FORMATTER_JSON=true` environment variable is defined) and `hardis:org:test:apex` assuming you:
|
|
133
|
-
|
|
134
|
-
- Install both plugins, apex-code-coverage-transformer and sfdx-hardis, with the Salesforce CLI
|
|
135
|
-
- Create the `.apexcodecovtransformer.config.json` file in the root of your repo
|
|
136
|
-
- Set `deployCoverageJsonPath` and `testCoverageJsonPath` in `.apexcodecovtransformer.config.json` to `hardis-report/apex-coverage-results.json`
|
|
137
|
-
|
|
138
|
-
Since sfdx-hardis invokes Salesforce CLI commands, the hooks will fire twice per hardis command, once after the Salesforce CLI command and once after the sfdx-hardis command. The hook will end early without errors after the Salesforce CLI command and will run successfully after the sfdx-hardis command assuming the hardis report is found.
|
|
139
|
-
|
|
140
139
|
## Errors and Warnings
|
|
141
140
|
|
|
142
141
|
Any file in the coverage JSON that isn't found in any package directory will result in this warning:
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apex-code-coverage-transformer",
|
|
3
3
|
"description": "Transforms the Apex code coverage JSON created during Salesforce deployments and test runs into SonarQube, Clover, LCovOnly, or Cobertura format.",
|
|
4
|
-
"version": "2.6.
|
|
4
|
+
"version": "2.6.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^4.0.37",
|
|
7
7
|
"@salesforce/core": "^8.8.0",
|