apex-code-coverage-transformer 2.0.0 → 2.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,197 @@
1
+ <!-- markdownlint-disable MD024 MD025 -->
2
+ <!-- markdown-link-check-disable -->
3
+
4
+ # Changelog
5
+
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
+
8
+ ## [2.2.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.1.0...v2.2.0) (2024-10-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * remove dependency on git repos ([c2bc72d](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/c2bc72d72de00da8b52f3f1ae0a6b8805316b20f))
14
+
15
+ ## [2.1.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v2.0.0...v2.1.0) (2024-10-22)
16
+
17
+
18
+ ### Features
19
+
20
+ * remove command flag by adding type guard functions ([be380bf](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/be380bf2400cb217a3769d6272668d6ba277a6a4))
21
+
22
+ ## [2.0.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.6...v2.0.0) (2024-10-21)
23
+
24
+
25
+ ### ⚠ BREAKING CHANGES
26
+
27
+ * shorten command to acc-transformer
28
+
29
+ ### Features
30
+
31
+ * shorten command to acc-transformer ([686cdc6](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/686cdc6960f8f73e7796e6b97928a8294a6b450b))
32
+
33
+ ## [1.7.6](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.5...v1.7.6) (2024-07-28)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * refactor fs import ([d246c28](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/d246c28f70f5cd2ac40110b2d376ad0bac59384d))
39
+
40
+ ## [1.7.5](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.4...v1.7.5) (2024-07-28)
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * switch to isomorphic-git ([2da1fcc](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/2da1fcc2f55cf76296d1b7cd033daedba1bf496d))
46
+
47
+ ## [1.7.4](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.3...v1.7.4) (2024-06-10)
48
+
49
+ ### Bug Fixes
50
+
51
+ - include `apex get test` command in the hook ([34718f0](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/34718f0c146dbf51efe04c81d994c0c724e84a0c))
52
+ - update the hook to allow 2 different JSON paths based on command ([f6159be](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/f6159be3fe12801a00c06f44a5304cab2d02697e))
53
+
54
+ ## [1.7.3](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.2...v1.7.3) (2024-05-15)
55
+
56
+ ### Bug Fixes
57
+
58
+ - fix handling of an empty JSON from the test run command ([48ef6df](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/48ef6df77eda762006a78e1d2eb66936d57ee418))
59
+ - warn instead of fail when no files in the JSON are processed ([7809843](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/780984332c279ed7142695cbf262e67f69e916c0))
60
+
61
+ ## [1.7.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.1...v1.7.2) (2024-05-10)
62
+
63
+ ### Bug Fixes
64
+
65
+ - add support for coverage JSONs created by `sf apex run test` ([5f48b77](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/5f48b777f1ccd003d650c50ef87a0b24e2b4a73f))
66
+
67
+ ## [1.7.2-beta.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.1...v1.7.2-beta.1) (2024-05-09)
68
+
69
+ ### Bug Fixes
70
+
71
+ - add support for coverage JSONs created by `sf apex run test` ([5f48b77](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/5f48b777f1ccd003d650c50ef87a0b24e2b4a73f))
72
+
73
+ ## [1.7.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.7.0...v1.7.1) (2024-04-30)
74
+
75
+ ### Bug Fixes
76
+
77
+ - fix no-map replacement for windows-style paths ([e6d4fef](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/e6d4fef16266a8075c01601b3f5a838a058c5fa2))
78
+
79
+ # [1.7.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.8...v1.7.0) (2024-04-30)
80
+
81
+ ### Features
82
+
83
+ - add a post run hook for post deployments ([894a4cd](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/894a4cdb14f6367b3e9248e757b1463e3134ae83))
84
+
85
+ ## [1.6.8](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.7...v1.6.8) (2024-04-23)
86
+
87
+ ### Bug Fixes
88
+
89
+ - get package directories and repo root before looping through files ([b630002](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/b6300020d650e02928c3b5700b05aa0c4bda050e))
90
+
91
+ ## [1.6.7](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.6...v1.6.7) (2024-04-23)
92
+
93
+ ### Bug Fixes
94
+
95
+ - remove `--sfdx-configuration` flag and get `sfdx-project.json` path using `simple-git` ([87d92f3](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/87d92f39fdd4f404887dc2c931940ea3221d7606))
96
+
97
+ ## [1.6.6](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.5...v1.6.6) (2024-04-22)
98
+
99
+ ### Bug Fixes
100
+
101
+ - fix path resolution when running in non-root directories ([c16fe7d](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/c16fe7d09898b857c68c2cc73a1ac2bcc8665f1e))
102
+
103
+ ## [1.6.5](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.4...v1.6.5) (2024-04-18)
104
+
105
+ ### Bug Fixes
106
+
107
+ - build XML using xmlbuilder2 and normalize path building using posix ([c6d6d94](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/c6d6d944e2675eb6be0dd90e972d67e6311f6738))
108
+
109
+ ## [1.6.4](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.3...v1.6.4) (2024-04-09)
110
+
111
+ ### Bug Fixes
112
+
113
+ - switch to promises/async and refactor imports ([2577692](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/2577692672aeb9271151f67e8347ef8a09a07b37))
114
+
115
+ ## [1.6.3](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.2...v1.6.3) (2024-03-27)
116
+
117
+ ### Bug Fixes
118
+
119
+ - remove flow logic ([dd3db2a](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/dd3db2ab60614dd21bdc844b78c8e882814c43a8))
120
+
121
+ ## [1.6.2](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.1...v1.6.2) (2024-03-26)
122
+
123
+ ### Bug Fixes
124
+
125
+ - warn if a file isn't found and fail if no files are found ([6b9e8ea](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/6b9e8ea80f9101429f82eed7fb3539c71dc613f4))
126
+
127
+ ## [1.6.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.0...v1.6.1) (2024-03-22)
128
+
129
+ ### Bug Fixes
130
+
131
+ - search the directories recursively without hard-coding the sub-folder names ([8880ab3](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/8880ab3e3c9097b8e7927230395eae32560ae55a))
132
+
133
+ ## [1.6.1-beta.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.6.0...v1.6.1-beta.1) (2024-03-22)
134
+
135
+ ### Bug Fixes
136
+
137
+ - search the directories recursively without hard-coding the sub-folder names ([8880ab3](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/8880ab3e3c9097b8e7927230395eae32560ae55a))
138
+
139
+ # [1.6.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.5.0...v1.6.0) (2024-03-21)
140
+
141
+ ### Features
142
+
143
+ - add `covered` lines, renumbering out-of-range lines numbers ([1733b09](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/1733b09063eac28f0e627e66080dcd24d7c74bf9))
144
+
145
+ # [1.6.0-beta.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.5.0...v1.6.0-beta.1) (2024-03-20)
146
+
147
+ ### Features
148
+
149
+ - add `covered` lines, renumbering out-of-range lines numbers ([1733b09](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/1733b09063eac28f0e627e66080dcd24d7c74bf9))
150
+
151
+ # [1.5.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.4.0...v1.5.0) (2024-03-20)
152
+
153
+ ### Features
154
+
155
+ - support multiple package directories via the sfdx-project.json ([52c1a12](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/52c1a12ff5fbfb10c215a41e010ee7fc6c0370de))
156
+
157
+ # [1.4.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.3.1...v1.4.0) (2024-02-27)
158
+
159
+ ### Features
160
+
161
+ - if coverage JSON includes file extensions, use that to determine paths ([efc1fa6](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/efc1fa61ce21cff394bbc696afce88c4d57894ea))
162
+
163
+ ## [1.3.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.3.0...v1.3.1) (2024-02-26)
164
+
165
+ ### Bug Fixes
166
+
167
+ - dx-directory should be an existing directory and fix flag in messages ([38fb20b](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/38fb20b8a107c203ba78266cb05d133805135ce4))
168
+
169
+ # [1.3.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.2.0...v1.3.0) (2024-02-07)
170
+
171
+ ### Features
172
+
173
+ - add support for flows ([6bf0da1](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/6bf0da14a39871dc3b7d50565416c2d24fba7524))
174
+
175
+ # [1.2.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.1.1...v1.2.0) (2024-02-07)
176
+
177
+ ### Features
178
+
179
+ - check if file name is an apex class or apex trigger using the dx directory flag ([215e41e](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/215e41eab0c41e2861d86370b0bddae2b2e487f0))
180
+
181
+ ## [1.1.1](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.1.0...v1.1.1) (2024-02-07)
182
+
183
+ ### Bug Fixes
184
+
185
+ - resolve path to xml ([cc75e96](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/cc75e96ef26120f86cff8588256e4f55e79d5473))
186
+
187
+ # [1.1.0](https://github.com/mcarvin8/apex-code-coverage-transformer/compare/v1.0.0...v1.1.0) (2024-02-07)
188
+
189
+ ### Features
190
+
191
+ - update json flag name to ensure it's unique from the global flag and import path module ([d03c567](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/d03c567a7549e5ada291d82525c78e19a1b8fcba))
192
+
193
+ # 1.0.0 (2024-02-07)
194
+
195
+ ### Features
196
+
197
+ - init release ([504b4cf](https://github.com/mcarvin8/apex-code-coverage-transformer/commit/504b4cfb028fc14241b892e1cc872adadec736d7))
package/README.md CHANGED
@@ -2,11 +2,27 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/apex-code-coverage-transformer.svg?label=apex-code-coverage-transformer)](https://www.npmjs.com/package/apex-code-coverage-transformer) [![Downloads/week](https://img.shields.io/npm/dw/apex-code-coverage-transformer.svg)](https://npmjs.org/package/apex-code-coverage-transformer) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md)
4
4
 
5
+ <!-- TABLE OF CONTENTS -->
6
+ <details>
7
+ <summary>Table of Contents</summary>
8
+
9
+ - [Install](#install)
10
+ - [Command](#command)
11
+ - [`sf acc-transformer transform`](#sf-acc-transformer-transform)
12
+ - [Hook](#hook)
13
+ - [Errors and Warnings](#errors-and-warnings)
14
+ - [Example](#example)
15
+ - [Issues](#issues)
16
+ - [License](#license)
17
+ </details>
18
+
5
19
  The `apex-code-coverage-transformer` is a Salesforce CLI plugin to transform the Apex Code Coverage JSON files created during deployments and test runs into the Generic Test Coverage Format (XML). This format is accepted by static code analysis tools like SonarQube.
6
20
 
7
21
  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
22
 
9
- 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.
23
+ This plugin is intended for users who deploy their Apex codebase from a Salesforce DX repository and use SonarQube for code quality. This plugin is intended to work for any Salesforce DX repository with a `sfdx-project.json` file, not just git-based repositories. 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.
24
+
25
+ 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 Salesforce DX 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 repository. See [Errors and Warnings](https://github.com/mcarvin8/apex-code-coverage-transformer?tab=readme-ov-file#errors-and-warnings) for more information.
10
26
 
11
27
  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`.
12
28
 
@@ -14,14 +30,14 @@ To create the code coverage JSON during a Salesforce CLI deployment/validation,
14
30
  sf project deploy [start/validate] --coverage-formatters json --results-dir "coverage"
15
31
  ```
16
32
 
17
- 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".
33
+ 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".
18
34
 
19
35
  ```
20
36
  sf apex run test --code-coverage --result-format json --output-dir "coverage"
21
37
  sf apex get test --test-run-id <test run id> --code-coverage --result-format json --output-dir "coverage"
22
38
  ```
23
39
 
24
- 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.
40
+ The code coverage JSONs created by the Salesforce CLI aren't accepted by SonarQube automatically for Salesforce DX repositories and needs to be converted using this plugin.
25
41
 
26
42
  **Disclaimer**: Due to existing bugs with how the Salesforce CLI reports covered lines during deployments (see [5511](https://github.com/forcedotcom/salesforcedx-vscode/issues/5511) and [1568](https://github.com/forcedotcom/cli/issues/1568)), to add support for covered lines in this plugin for deployment coverage files, I had to add a function to re-number out-of-range covered lines the CLI may report (ex: line 100 in a 98-line Apex Class is reported back as covered by the Salesforce CLI deploy command). Salesforce's coverage result may also include extra lines as covered (ex: 120 lines are included in the coverage report for a 100 line file), so the coverage percentage may vary based on how many lines the API returns in the coverage report. Once Salesforce fixes the API to correctly return covered lines in the deploy command, this function will be removed.
27
43
 
@@ -37,18 +53,17 @@ The `apex-code-coverage-transformer` has 1 command:
37
53
 
38
54
  - `sf acc-transformer transform`
39
55
 
40
- 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.
56
+ This command needs to be ran somewhere inside your Salesforce DX 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.
41
57
 
42
58
  ## `sf acc-transformer transform`
43
59
 
44
60
  ```
45
61
  USAGE
46
- $ sf acc-transformer transform -j <value> -x <value> -c <value> [--json]
62
+ $ sf acc-transformer transform -j <value> -x <value> [--json]
47
63
 
48
64
  FLAGS
49
65
  -j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment or test command.
50
66
  -x, --xml=<value> [default: "coverage.xml"] Path to code coverage XML file that will be created by this plugin.
51
- -c, --command=<value> [default: "deploy"] The type of Salesforce CLI command you are running. Valid options: "deploy" or "test".
52
67
 
53
68
  GLOBAL FLAGS
54
69
  --json Format output as json.
@@ -57,7 +72,7 @@ DESCRIPTION
57
72
  This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments and test runs into an XML accepted by tools like SonarQube.
58
73
 
59
74
  EXAMPLES
60
- $ sf acc-transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy"
75
+ $ sf acc-transformer transform -j "coverage.json" -x "coverage.xml"
61
76
  ```
62
77
 
63
78
  ## Hook
@@ -102,10 +117,16 @@ Warning: The file name AccountProfile was not found in any package directory.
102
117
  Warning: None of the files listed in the coverage JSON were processed. The coverage XML will be empty.
103
118
  ```
104
119
 
120
+ The code coverage JSON files created by the Salesforce CLI deployment commands follow a different format than the code coverage files created by the test commands. If the code coverage JSON file provided does not match one of the 2 expected coverage data types, the plugin will fail with:
121
+
122
+ ```
123
+ Error (1): The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.
124
+ ```
125
+
105
126
  If the `sfdx-project.json` file was not found in your repository's root folder, the plugin will fail with:
106
127
 
107
128
  ```
108
- Error (1): Salesforce DX Config File does not exist in this path: {filePath}
129
+ Error (1): sfdx-project.json not found in any parent directory.
109
130
  ```
110
131
 
111
132
  Any ENOENT failures indicate that the plugin had issues finding one of the package directories in the `sfdx-project.json` file:
@@ -189,3 +210,11 @@ This [code coverage JSON file](https://raw.githubusercontent.com/mcarvin8/apex-c
189
210
  </file>
190
211
  </coverage>
191
212
  ```
213
+
214
+ ## Issues
215
+
216
+ If you encounter any issues, please create an issue in the repository's [issue tracker](https://github.com/mcarvin8/apex-code-coverage-transformer/issues). Please also create issues to suggest any new features.
217
+
218
+ ## License
219
+
220
+ This project is licensed under the MIT license. Please see the [LICENSE](https://raw.githubusercontent.com/mcarvin8/apex-code-coverage-transformer/main/LICENSE.md) file for details.
@@ -7,7 +7,6 @@ export default class TransformerTransform extends SfCommand<TransformerTransform
7
7
  static readonly flags: {
8
8
  'coverage-json': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
9
  xml: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
- command: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
10
  };
12
11
  run(): Promise<TransformerTransformResult>;
13
12
  }
@@ -5,6 +5,7 @@ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
5
5
  import { Messages } from '@salesforce/core';
6
6
  import { transformDeployCoverageReport } from '../../helpers/transformDeployCoverageReport.js';
7
7
  import { transformTestCoverageReport } from '../../helpers/transformTestCoverageReport.js';
8
+ import { checkCoverageDataType } from '../../helpers/setCoverageDataType.js';
8
9
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
9
10
  const messages = Messages.loadMessages('apex-code-coverage-transformer', 'transformer.transform');
10
11
  export default class TransformerTransform extends SfCommand {
@@ -25,37 +26,33 @@ export default class TransformerTransform extends SfCommand {
25
26
  exists: false,
26
27
  default: 'coverage.xml',
27
28
  }),
28
- command: Flags.string({
29
- summary: messages.getMessage('flags.command.summary'),
30
- char: 'c',
31
- required: true,
32
- default: 'deploy',
33
- options: ['deploy', 'test'],
34
- }),
35
29
  };
36
30
  async run() {
37
31
  const { flags } = await this.parse(TransformerTransform);
38
32
  const jsonFilePath = resolve(flags['coverage-json']);
39
33
  const xmlFilePath = resolve(flags['xml']);
40
- const commandType = flags['command'];
41
34
  const jsonData = await readFile(jsonFilePath, 'utf-8');
42
35
  let xmlData;
43
36
  let warnings = [];
44
37
  let filesProcessed = 0;
45
- if (commandType === 'test') {
46
- const coverageData = JSON.parse(jsonData);
47
- const result = await transformTestCoverageReport(coverageData);
38
+ const parsedData = JSON.parse(jsonData);
39
+ const commandType = checkCoverageDataType(parsedData);
40
+ // Determine the type of coverage data using type guards
41
+ if (commandType === 'TestCoverageData') {
42
+ const result = await transformTestCoverageReport(parsedData);
48
43
  xmlData = result.xml;
49
44
  warnings = result.warnings;
50
45
  filesProcessed = result.filesProcessed;
51
46
  }
52
- else {
53
- const coverageData = JSON.parse(jsonData);
54
- const result = await transformDeployCoverageReport(coverageData);
47
+ else if (commandType === 'DeployCoverageData') {
48
+ const result = await transformDeployCoverageReport(parsedData);
55
49
  xmlData = result.xml;
56
50
  warnings = result.warnings;
57
51
  filesProcessed = result.filesProcessed;
58
52
  }
53
+ else {
54
+ this.error('The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.');
55
+ }
59
56
  // Print warnings if any
60
57
  if (warnings.length > 0) {
61
58
  warnings.forEach((warning) => {
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/commands/acc-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,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CA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GAAG,MAAM,6BAA6B,CAAC,UAAgC,CAAC,CAAC;YACrF,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;YACrB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;YAC3B,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CACR,2GAA2G,CAC5G,CAAC;QACJ,CAAC;QAED,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,IAAI,CAAC,+FAA+F,CAAC,CAAC;QAC7G,CAAC;QAED,MAAM,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,wCAAwC,WAAW,EAAE,CAAC,CAAC;QAChE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC"}
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
- /* eslint-disable no-await-in-loop */
3
- import { existsSync } from 'node:fs';
4
2
  import { readFile } from 'node:fs/promises';
5
3
  import { resolve } from 'node:path';
6
4
  import { getRepoRoot } from './getRepoRoot.js';
7
5
  export async function getPackageDirectories() {
8
- const repoRoot = await getRepoRoot();
9
- const dxConfigPath = resolve(repoRoot, 'sfdx-project.json');
10
- if (!existsSync(dxConfigPath)) {
11
- throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
6
+ const { repoRoot, dxConfigFilePath } = await getRepoRoot();
7
+ if (!repoRoot || !dxConfigFilePath) {
8
+ throw new Error('Failed to retrieve repository root or sfdx-project.json path.');
12
9
  }
13
- const sfdxProjectRaw = await readFile(dxConfigPath, 'utf-8');
10
+ const sfdxProjectRaw = await readFile(dxConfigFilePath, 'utf-8');
14
11
  const sfdxProject = JSON.parse(sfdxProjectRaw);
15
12
  const packageDirectories = sfdxProject.packageDirectories.map((directory) => resolve(repoRoot, directory.path));
16
13
  return { repoRoot, packageDirectories };
@@ -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;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;IACrC,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"}
1
+ {"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/helpers/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;IAE3D,IAAI,CAAC,QAAQ,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,cAAc,GAAW,MAAM,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACzE,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"}
@@ -1 +1,4 @@
1
- export declare function getRepoRoot(): Promise<string>;
1
+ export declare function getRepoRoot(): Promise<{
2
+ repoRoot: string | undefined;
3
+ dxConfigFilePath: string | undefined;
4
+ }>;
@@ -1,12 +1,31 @@
1
1
  'use strict';
2
- import { promises as fsPromises, readFile, stat, readdir } from 'node:fs';
3
- import git from 'isomorphic-git';
2
+ /* eslint-disable no-await-in-loop */
3
+ import { access } from 'node:fs/promises';
4
+ import { join, dirname } from 'node:path';
4
5
  export async function getRepoRoot() {
5
- const fs = { promises: fsPromises, readFile, stat, readdir };
6
- const repoRoot = await git.findRoot({
7
- fs,
8
- filepath: process.cwd(),
9
- });
10
- return repoRoot;
6
+ let currentDir = process.cwd();
7
+ let found = false;
8
+ let dxConfigFilePath;
9
+ let repoRoot;
10
+ do {
11
+ const filePath = join(currentDir, 'sfdx-project.json');
12
+ try {
13
+ // Check if sfdx-project.json exists in the current directory
14
+ await access(filePath);
15
+ dxConfigFilePath = filePath;
16
+ repoRoot = currentDir;
17
+ found = true;
18
+ }
19
+ catch {
20
+ // If file not found, move up one directory level
21
+ const parentDir = dirname(currentDir);
22
+ if (currentDir === parentDir) {
23
+ // Reached the root without finding the file, throw an error
24
+ throw new Error('sfdx-project.json not found in any parent directory.');
25
+ }
26
+ currentDir = parentDir;
27
+ }
28
+ } while (!found);
29
+ return { repoRoot, dxConfigFilePath };
11
30
  }
12
31
  //# sourceMappingURL=getRepoRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/helpers/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,GAAG,MAAM,gBAAgB,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC;QAClC,EAAE;QACF,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE;KACxB,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/helpers/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,gBAAoC,CAAC;IACzC,IAAI,QAA4B,CAAC;IAEjC,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QAEvD,IAAI,CAAC;YACH,6DAA6D;YAC7D,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvB,gBAAgB,GAAG,QAAQ,CAAC;YAC5B,QAAQ,GAAG,UAAU,CAAC;YACtB,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,iDAAiD;YACjD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,4DAA4D;gBAC5D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YAC1E,CAAC;YACD,UAAU,GAAG,SAAS,CAAC;QACzB,CAAC;IACH,CAAC,QAAQ,CAAC,KAAK,EAAE;IACjB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { DeployCoverageData, TestCoverageData } from './types.js';
2
+ export declare function checkCoverageDataType(data: DeployCoverageData | TestCoverageData[]): 'DeployCoverageData' | 'TestCoverageData' | 'Unknown';
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+ // Type guard for DeployCoverageData
3
+ function isDeployCoverageData(data) {
4
+ if (typeof data !== 'object' || data === null)
5
+ return false;
6
+ return Object.entries(data).every(([, item]) => {
7
+ if (typeof item !== 'object' || item === null)
8
+ return false;
9
+ const { path, fnMap, branchMap, f, b, s, statementMap } = item;
10
+ if (typeof path !== 'string' ||
11
+ typeof fnMap !== 'object' ||
12
+ typeof branchMap !== 'object' ||
13
+ typeof f !== 'object' ||
14
+ typeof b !== 'object' ||
15
+ typeof s !== 'object' ||
16
+ typeof statementMap !== 'object' ||
17
+ statementMap === null) {
18
+ return false;
19
+ }
20
+ return Object.values(statementMap).every((statement) => {
21
+ if (typeof statement !== 'object' || statement === null)
22
+ return false;
23
+ const { start, end } = statement;
24
+ return (typeof start === 'object' &&
25
+ start !== null &&
26
+ typeof start.line === 'number' &&
27
+ typeof start.column === 'number' &&
28
+ typeof end === 'object' &&
29
+ end !== null &&
30
+ typeof end.line === 'number' &&
31
+ typeof end.column === 'number');
32
+ });
33
+ });
34
+ }
35
+ // Type guard for a single TestCoverageData
36
+ function isSingleTestCoverageData(data) {
37
+ return (typeof data === 'object' &&
38
+ data !== null &&
39
+ typeof data.id === 'string' &&
40
+ typeof data.name === 'string' &&
41
+ typeof data.totalLines === 'number' &&
42
+ typeof data.lines === 'object' &&
43
+ typeof data.totalCovered === 'number' &&
44
+ typeof data.coveredPercent === 'number' &&
45
+ Object.values(data.lines).every((line) => typeof line === 'number'));
46
+ }
47
+ // Type guard for TestCoverageData array
48
+ function isTestCoverageDataArray(data) {
49
+ return Array.isArray(data) && data.every(isSingleTestCoverageData);
50
+ }
51
+ export function checkCoverageDataType(data) {
52
+ if (isDeployCoverageData(data)) {
53
+ return 'DeployCoverageData';
54
+ }
55
+ else if (isTestCoverageDataArray(data)) {
56
+ return 'TestCoverageData';
57
+ }
58
+ return 'Unknown';
59
+ }
60
+ //# sourceMappingURL=setCoverageDataType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setCoverageDataType.js","sourceRoot":"","sources":["../../src/helpers/setCoverageDataType.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,oCAAoC;AACpC,SAAS,oBAAoB,CAAC,IAAa;IACzC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAE5D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,C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a;IAC7C,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,OAAQ,IAAyB,CAAC,EAAE,KAAK,QAAQ;QACjD,OAAQ,IAAyB,CAAC,IAAI,KAAK,QAAQ;QACnD,OAAQ,IAAyB,CAAC,UAAU,KAAK,QAAQ;QACzD,OAAQ,IAAyB,CAAC,KAAK,KAAK,QAAQ;QACpD,OAAQ,IAAyB,CAAC,YAAY,KAAK,QAAQ;QAC3D,OAAQ,IAAyB,CAAC,cAAc,KAAK,QAAQ;QAC7D,MAAM,CAAC,MAAM,CAAE,IAAyB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CACnG,CAAC;AACJ,CAAC;AAED,wCAAwC;AACxC,SAAS,uBAAuB,CAAC,IAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAA6C;IAE7C,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,oBAAoB,CAAC;IAC9B,CAAC;SAAM,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -17,7 +17,10 @@ export const postrun = async function (options) {
17
17
  return;
18
18
  }
19
19
  let configFile;
20
- const repoRoot = await getRepoRoot();
20
+ const { repoRoot } = await getRepoRoot();
21
+ if (!repoRoot) {
22
+ return;
23
+ }
21
24
  const configPath = resolve(repoRoot, '.apexcodecovtransformer.config.json');
22
25
  try {
23
26
  const jsonString = await readFile(configPath, 'utf-8');
@@ -46,8 +49,6 @@ export const postrun = async function (options) {
46
49
  commandArgs.push(coverageJsonPath);
47
50
  commandArgs.push('--xml');
48
51
  commandArgs.push(coverageXmlPath);
49
- commandArgs.push('--command');
50
- commandArgs.push(commandType);
51
52
  await TransformerTransform.run(commandArgs);
52
53
  };
53
54
  //# sourceMappingURL=postrun.js.map
@@ -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,WAAW,GAAG,QAAQ,CAAC;IACzB,CAAC;SAAM,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC3E,WAAW,GAAG,MAAM,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO;IACT,CAAC;IACD,IAAI,UAAsB,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,qCAAqC,CAAC,CAAC;IAE5E,IAAI,CAAC;QACH,MAAM,UAAU,GAAW,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC/D,UAAU,GAAG,IAAI,CAA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N,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,MAAM,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC,CAAC"}
@@ -8,7 +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 acc-transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy"`
11
+ - `sf acc-transformer transform -j "coverage.json" -x "coverage.xml"`
12
12
 
13
13
  # flags.coverage-json.summary
14
14
 
@@ -17,7 +17,3 @@ Path to the code coverage JSON file created by the Salesforce CLI deployment or
17
17
  # flags.xml.summary
18
18
 
19
19
  Path to code coverage XML file that will be created by this plugin.
20
-
21
- # flags.command.summary
22
-
23
- The type of Salesforce CLI command you are running.