apex-code-coverage-transformer 1.6.8 → 1.7.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/README.md +22 -0
- package/lib/helpers/types.d.ts +4 -0
- package/lib/hooks/postrun.d.ts +2 -0
- package/lib/hooks/postrun.js +44 -0
- package/lib/hooks/postrun.js.map +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -56,6 +56,28 @@ EXAMPLES
|
|
|
56
56
|
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml"
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
## Hook
|
|
60
|
+
|
|
61
|
+
A post-run hook has been configured if you elect to use it.
|
|
62
|
+
|
|
63
|
+
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) if the JSON is found.
|
|
64
|
+
|
|
65
|
+
The hook requires you to create this file in the root of your repo: `.apexcodecovtransformer.config.json`
|
|
66
|
+
|
|
67
|
+
The `.apexcodecovtransformer.config.json` should look like this:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"coverageJsonPath": "coverage/coverage/coverage.json",
|
|
72
|
+
"coverageXmlPath": "coverage.xml"
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `coverageJsonPath` is required and should be the path to the code coverage JSON created by the Salesforce CLI. Recommend using a relative path.
|
|
77
|
+
- `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.
|
|
78
|
+
|
|
79
|
+
If the `.apexcodecovtransformer.config.json` file isn't found, the hook will be skipped.
|
|
80
|
+
|
|
59
81
|
## Errors and Warnings
|
|
60
82
|
|
|
61
83
|
Any file in the coverage JSON that isn't found in any package directory will result in this warning:
|
package/lib/helpers/types.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { simpleGit } from 'simple-git';
|
|
6
|
+
import TransformerTransform from '../commands/apex-code-coverage/transformer/transform.js';
|
|
7
|
+
export const postrun = async function (options) {
|
|
8
|
+
if (['project:deploy:validate', 'project:deploy:start', 'project:deploy:report', 'project:deploy:resume'].includes(options.Command.id)) {
|
|
9
|
+
let configFile;
|
|
10
|
+
const gitOptions = {
|
|
11
|
+
baseDir: process.cwd(),
|
|
12
|
+
binary: 'git',
|
|
13
|
+
maxConcurrentProcesses: 6,
|
|
14
|
+
trimmed: true,
|
|
15
|
+
};
|
|
16
|
+
const git = simpleGit(gitOptions);
|
|
17
|
+
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
18
|
+
const configPath = resolve(repoRoot, '.apexcodecovtransformer.config.json');
|
|
19
|
+
try {
|
|
20
|
+
const jsonString = await readFile(configPath, 'utf-8');
|
|
21
|
+
configFile = JSON.parse(jsonString);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const coverageJson = configFile.coverageJsonPath || '.';
|
|
27
|
+
const coverageXml = configFile.coverageXmlPath || 'coverage.xml';
|
|
28
|
+
if (coverageJson.trim() === '.') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const coverageJsonPath = resolve(coverageJson);
|
|
32
|
+
const coverageXmlPath = resolve(coverageXml);
|
|
33
|
+
if (!existsSync(coverageJsonPath)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const commandArgs = [];
|
|
37
|
+
commandArgs.push('--coverage-json');
|
|
38
|
+
commandArgs.push(coverageJsonPath);
|
|
39
|
+
commandArgs.push('--xml');
|
|
40
|
+
commandArgs.push(coverageXmlPath);
|
|
41
|
+
await TransformerTransform.run(commandArgs);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=postrun.js.map
|
|
@@ -0,0 +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,IACE,CAAC,yBAAyB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,QAAQ,CAC5G,OAAO,CAAC,OAAO,CAAC,EAAE,CACnB,EACD,CAAC;QACD,IAAI,UAAsB,CAAC;QAC3B,MAAM,UAAU,GAA8B;YAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;YACtB,MAAM,EAAE,KAAK;YACb,sBAAsB,EAAE,CAAC;YACzB,OAAO,EAAE,IAAI;SACd,CAAC;QAEF,MAAM,GAAG,GAAc,SAAS,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,qCAAqC,CAAC,CAAC;QAE5E,IAAI,CAAC;YACH,MAAM,UAAU,GAAW,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC/D,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAe,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAW,UAAU,CAAC,gBAAgB,IAAI,GAAG,CAAC;QAChE,MAAM,WAAW,GAAW,UAAU,CAAC,eAAe,IAAI,cAAc,CAAC;QAEzE,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAChC,OAAO;QACT,CAAC;QAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAE7C,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACpC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC,CAAC"}
|
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 into the Generic Test Coverage Format (XML).",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^3.18.1",
|
|
7
7
|
"@salesforce/core": "^6.4.7",
|
|
@@ -58,6 +58,9 @@
|
|
|
58
58
|
"commands": "./lib/commands",
|
|
59
59
|
"bin": "sf",
|
|
60
60
|
"topicSeparator": " ",
|
|
61
|
+
"hooks": {
|
|
62
|
+
"postrun": "./lib/hooks/postrun"
|
|
63
|
+
},
|
|
61
64
|
"devPlugins": [
|
|
62
65
|
"@oclif/plugin-help"
|
|
63
66
|
],
|