apex-code-coverage-transformer 2.5.2 → 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 CHANGED
@@ -5,6 +5,20 @@
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
+
15
+ ## [2.6.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.5.2...v2.6.0) (2025-01-12)
16
+
17
+
18
+ ### Features
19
+
20
+ * allow hook to run after hardis commands ([962847d](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/962847d640237bd8c6c16f7319e2756b005713ea))
21
+
8
22
  ## [2.5.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.5.1...v2.5.2) (2025-01-10)
9
23
 
10
24
 
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 a folder named "coverage".
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,25 +112,25 @@ EXAMPLES
105
112
 
106
113
  ## Hook
107
114
 
108
- A post-run hook has been configured if you elect to use it.
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
- The post-run hook will automatically transform the code coverage JSON file 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.
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
- The hook requires you to create this file in the root of your repo: `.apexcodecovtransformer.config.json`
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
- The `.apexcodecovtransformer.config.json` should look like this:
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
- ```json
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 deployments and should be the path to the code coverage JSON created by the Salesforce CLI deployment command. Recommend using a relative path.
126
- - `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.
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
 
@@ -7,10 +7,10 @@ import { getRepoRoot } from '../helpers/getRepoRoot.js';
7
7
  export const postrun = async function (options) {
8
8
  let commandType;
9
9
  let coverageJson;
10
- if (['project:deploy:validate', 'project:deploy:start', 'project:deploy:report', 'project:deploy:resume'].includes(options.Command.id)) {
10
+ if (['project:deploy:validate', 'project:deploy:start', 'project:deploy:report', 'project:deploy:resume', 'hardis:project:deploy:smart'].includes(options.Command.id)) {
11
11
  commandType = 'deploy';
12
12
  }
13
- else if (['apex:run:test', 'apex:get:test'].includes(options.Command.id)) {
13
+ else if (['apex:run:test', 'apex:get:test', 'hardis:org:test:apex'].includes(options.Command.id)) {
14
14
  commandType = 'test';
15
15
  }
16
16
  else {
@@ -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;AAGpC,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAoB,KAAK,WAAW,OAAO;IAC7D,IAAI,WAAmB,CAAC;IACxB,IAAI,YAAoB,CAAC;IACzB,IACE,CAAC,yBAAyB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,QAAQ,CAC5G,OAAO,CAAC,OAAO,CAAC,EAAE,CACnB,EACD,CAAC;QACD,WA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C,CAAC;IACpC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7B,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACjC,MAAM,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -85,5 +85,5 @@
85
85
  ]
86
86
  }
87
87
  },
88
- "version": "2.5.2"
88
+ "version": "2.6.1"
89
89
  }
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.5.2",
4
+ "version": "2.6.1",
5
5
  "dependencies": {
6
6
  "@oclif/core": "^4.0.37",
7
7
  "@salesforce/core": "^8.8.0",