apex-code-coverage-transformer 1.7.2-beta.1 → 1.7.2
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 +3 -3
- package/lib/hooks/postrun.js +43 -33
- package/lib/hooks/postrun.js.map +1 -1
- package/messages/transformer.transform.md +2 -6
- package/oclif.manifest.json +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ USAGE
|
|
|
47
47
|
$ sf apex-code-coverage transformer transform -j <value> -x <value> -c <value> [--json]
|
|
48
48
|
|
|
49
49
|
FLAGS
|
|
50
|
-
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment command.
|
|
50
|
+
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment or test command.
|
|
51
51
|
-x, --xml=<value> [default: "coverage.xml"] Path to code coverage XML file that will be created by this plugin.
|
|
52
52
|
-c, --command=<value> [default: "deploy"] The type of Salesforce CLI command you are running. Valid options: "deploy" or "test".
|
|
53
53
|
|
|
@@ -55,7 +55,7 @@ GLOBAL FLAGS
|
|
|
55
55
|
--json Format output as json.
|
|
56
56
|
|
|
57
57
|
DESCRIPTION
|
|
58
|
-
This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments into an XML accepted by tools like SonarQube.
|
|
58
|
+
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.
|
|
59
59
|
|
|
60
60
|
EXAMPLES
|
|
61
61
|
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy"
|
|
@@ -65,7 +65,7 @@ EXAMPLES
|
|
|
65
65
|
|
|
66
66
|
A post-run hook has been configured if you elect to use it.
|
|
67
67
|
|
|
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) if the JSON is found.
|
|
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
69
|
|
|
70
70
|
The hook requires you to create this file in the root of your repo: `.apexcodecovtransformer.config.json`
|
|
71
71
|
|
package/lib/hooks/postrun.js
CHANGED
|
@@ -5,40 +5,50 @@ import { resolve } from 'node:path';
|
|
|
5
5
|
import { simpleGit } from 'simple-git';
|
|
6
6
|
import TransformerTransform from '../commands/apex-code-coverage/transformer/transform.js';
|
|
7
7
|
export const postrun = async function (options) {
|
|
8
|
+
let commandType;
|
|
8
9
|
if (['project:deploy:validate', 'project:deploy:start', 'project:deploy:report', 'project:deploy:resume'].includes(options.Command.id)) {
|
|
9
|
-
|
|
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);
|
|
10
|
+
commandType = 'deploy';
|
|
42
11
|
}
|
|
12
|
+
else if (['apex:run:test'].includes(options.Command.id)) {
|
|
13
|
+
commandType = 'test';
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
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();
|
|
27
|
+
const configPath = resolve(repoRoot, '.apexcodecovtransformer.config.json');
|
|
28
|
+
try {
|
|
29
|
+
const jsonString = await readFile(configPath, 'utf-8');
|
|
30
|
+
configFile = JSON.parse(jsonString);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const coverageJson = configFile.coverageJsonPath || '.';
|
|
36
|
+
const coverageXml = configFile.coverageXmlPath || 'coverage.xml';
|
|
37
|
+
if (coverageJson.trim() === '.') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const coverageJsonPath = resolve(coverageJson);
|
|
41
|
+
const coverageXmlPath = resolve(coverageXml);
|
|
42
|
+
if (!existsSync(coverageJsonPath)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const commandArgs = [];
|
|
46
|
+
commandArgs.push('--coverage-json');
|
|
47
|
+
commandArgs.push(coverageJsonPath);
|
|
48
|
+
commandArgs.push('--xml');
|
|
49
|
+
commandArgs.push(coverageXmlPath);
|
|
50
|
+
commandArgs.push('--command');
|
|
51
|
+
commandArgs.push(commandType);
|
|
52
|
+
await TransformerTransform.run(commandArgs);
|
|
43
53
|
};
|
|
44
54
|
//# sourceMappingURL=postrun.js.map
|
package/lib/hooks/postrun.js.map
CHANGED
|
@@ -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,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;
|
|
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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AAC,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"}
|
|
@@ -4,7 +4,7 @@ Transforms the Code Coverage JSON into the Generic Test Coverage Format (XML).
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments into an XML accepted by tools like SonarQube.
|
|
7
|
+
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.
|
|
8
8
|
|
|
9
9
|
# examples
|
|
10
10
|
|
|
@@ -12,11 +12,7 @@ This plugin will convert the code coverage JSON file created by the Salesforce C
|
|
|
12
12
|
|
|
13
13
|
# flags.coverage-json.summary
|
|
14
14
|
|
|
15
|
-
Path to the code coverage JSON file created by the Salesforce CLI deployment command.
|
|
16
|
-
|
|
17
|
-
# flags.xml.summary
|
|
18
|
-
|
|
19
|
-
Path to code coverage XML file that will be created by this plugin.
|
|
15
|
+
Path to the code coverage JSON file created by the Salesforce CLI deployment or test command.
|
|
20
16
|
|
|
21
17
|
# flags.xml.summary
|
|
22
18
|
|
package/oclif.manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"apex-code-coverage:transformer:transform": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments into an XML accepted by tools like SonarQube.",
|
|
6
|
+
"description": "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.",
|
|
7
7
|
"examples": [
|
|
8
8
|
"`sf apex-code-coverage transformer transform -j \"coverage.json\" -x \"coverage.xml\" -c \"deploy\"`"
|
|
9
9
|
],
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"char": "j",
|
|
20
20
|
"name": "coverage-json",
|
|
21
21
|
"required": true,
|
|
22
|
-
"summary": "Path to the code coverage JSON file created by the Salesforce CLI deployment command.",
|
|
22
|
+
"summary": "Path to the code coverage JSON file created by the Salesforce CLI deployment or test command.",
|
|
23
23
|
"hasDynamicHelp": false,
|
|
24
24
|
"multiple": false,
|
|
25
25
|
"type": "option"
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
]
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
"version": "1.7.2
|
|
80
|
+
"version": "1.7.2"
|
|
81
81
|
}
|
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.7.2
|
|
4
|
+
"version": "1.7.2",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^3.18.1",
|
|
7
7
|
"@salesforce/core": "^6.4.7",
|