@salesforce/plugin-apex 1.5.1 → 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.
Files changed (74) hide show
  1. package/README.md +9 -9
  2. package/lib/commands/apex/get/log.d.ts +20 -0
  3. package/lib/commands/apex/get/log.js +73 -0
  4. package/lib/commands/apex/get/log.js.map +1 -0
  5. package/lib/commands/apex/get/test.d.ts +19 -0
  6. package/lib/commands/apex/get/test.js +74 -0
  7. package/lib/commands/apex/get/test.js.map +1 -0
  8. package/lib/commands/apex/list/log.d.ts +17 -0
  9. package/lib/commands/apex/list/log.js +76 -0
  10. package/lib/commands/apex/list/log.js.map +1 -0
  11. package/lib/commands/apex/run/test.d.ts +33 -0
  12. package/lib/commands/apex/run/test.js +198 -0
  13. package/lib/commands/apex/run/test.js.map +1 -0
  14. package/lib/commands/apex/run.d.ts +25 -0
  15. package/lib/commands/apex/run.js +53 -0
  16. package/lib/commands/apex/run.js.map +1 -0
  17. package/lib/commands/apex/tail/log.d.ts +26 -0
  18. package/lib/commands/apex/tail/log.js +81 -0
  19. package/lib/commands/apex/tail/log.js.map +1 -0
  20. package/lib/legacyColorization.js +36 -38
  21. package/lib/legacyColorization.js.map +1 -1
  22. package/lib/reporters/index.d.ts +2 -2
  23. package/lib/reporters/index.js +3 -3
  24. package/lib/reporters/index.js.map +1 -1
  25. package/lib/reporters/jsonReporter.d.ts +33 -16
  26. package/lib/reporters/jsonReporter.js +23 -9
  27. package/lib/reporters/jsonReporter.js.map +1 -1
  28. package/lib/reporters/runReporter.d.ts +6 -0
  29. package/lib/reporters/runReporter.js +48 -0
  30. package/lib/reporters/runReporter.js.map +1 -0
  31. package/lib/reporters/testReporter.d.ts +44 -0
  32. package/lib/reporters/testReporter.js +170 -0
  33. package/lib/reporters/testReporter.js.map +1 -0
  34. package/lib/utils.d.ts +0 -2
  35. package/lib/utils.js +2 -21
  36. package/lib/utils.js.map +1 -1
  37. package/messages/get.md +45 -0
  38. package/messages/list.md +63 -0
  39. package/messages/report.md +45 -0
  40. package/messages/run.md +48 -0
  41. package/messages/runtest.md +129 -0
  42. package/messages/tail.md +37 -0
  43. package/oclif.manifest.json +426 -800
  44. package/package.json +30 -30
  45. package/lib/commands/force/apex/execute.d.ts +0 -16
  46. package/lib/commands/force/apex/execute.js +0 -109
  47. package/lib/commands/force/apex/execute.js.map +0 -1
  48. package/lib/commands/force/apex/log/get.d.ts +0 -17
  49. package/lib/commands/force/apex/log/get.js +0 -103
  50. package/lib/commands/force/apex/log/get.js.map +0 -1
  51. package/lib/commands/force/apex/log/list.d.ts +0 -17
  52. package/lib/commands/force/apex/log/list.js +0 -151
  53. package/lib/commands/force/apex/log/list.js.map +0 -1
  54. package/lib/commands/force/apex/log/tail.d.ts +0 -17
  55. package/lib/commands/force/apex/log/tail.js +0 -96
  56. package/lib/commands/force/apex/log/tail.js.map +0 -1
  57. package/lib/commands/force/apex/test/report.d.ts +0 -25
  58. package/lib/commands/force/apex/test/report.js +0 -175
  59. package/lib/commands/force/apex/test/report.js.map +0 -1
  60. package/lib/commands/force/apex/test/run.d.ts +0 -40
  61. package/lib/commands/force/apex/test/run.js +0 -299
  62. package/lib/commands/force/apex/test/run.js.map +0 -1
  63. package/lib/reporters/util.d.ts +0 -14
  64. package/lib/reporters/util.js +0 -78
  65. package/lib/reporters/util.js.map +0 -1
  66. package/messages/execute.json +0 -9
  67. package/messages/get.json +0 -12
  68. package/messages/list.json +0 -18
  69. package/messages/messages.json +0 -22
  70. package/messages/org.json +0 -6
  71. package/messages/report.json +0 -23
  72. package/messages/run.json +0 -34
  73. package/messages/tail.json +0 -12
  74. package/yarn.lock +0 -8992
@@ -1,96 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2021, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const tslib_1 = require("tslib");
10
- const apex_node_1 = require("@salesforce/apex-node");
11
- const command_1 = require("@salesforce/command");
12
- const core_1 = require("@salesforce/core");
13
- const utils_1 = require("../../../../utils");
14
- const legacyColorization_1 = require("../../../../legacyColorization");
15
- core_1.Messages.importMessagesDirectory(__dirname);
16
- const messages = core_1.Messages.load('@salesforce/plugin-apex', 'tail', [
17
- 'colorDescription',
18
- 'commandDescription',
19
- 'debugLevelDescription',
20
- 'finishedTailing',
21
- 'jsonDescription',
22
- 'logLevelDescription',
23
- 'logLevelLongDescription',
24
- 'longDescription',
25
- 'skipTraceFlagDescription',
26
- ]);
27
- class Tail extends command_1.SfdxCommand {
28
- run() {
29
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
- try {
31
- if (this.org) {
32
- const conn = this.org.getConnection();
33
- const logService = new apex_node_1.LogService(conn);
34
- if (!this.flags.skiptraceflag) {
35
- yield logService.prepareTraceFlag(this.flags.debuglevel);
36
- }
37
- yield logService.tail(this.org, this.logTailer.bind(this));
38
- this.ux.log(messages.getMessage('finishedTailing'));
39
- }
40
- }
41
- catch (e) {
42
- return Promise.reject(e);
43
- }
44
- });
45
- }
46
- logTailer(fullLog) {
47
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
- if (fullLog) {
49
- if (this.flags.json) {
50
- this.ux.logJson({
51
- status: process.exitCode,
52
- result: fullLog,
53
- });
54
- }
55
- else {
56
- const output = this.flags.color ? yield (0, legacyColorization_1.colorizeLog)(fullLog) : fullLog;
57
- this.ux.log(output);
58
- }
59
- }
60
- });
61
- }
62
- }
63
- exports.default = Tail;
64
- Tail.requiresUsername = true;
65
- Tail.description = (0, utils_1.buildDescription)(messages.getMessage('commandDescription'), messages.getMessage('longDescription'));
66
- Tail.longDescription = messages.getMessage('longDescription');
67
- Tail.examples = [
68
- '$ sfdx force:apex:log:tail',
69
- '$ sfdx force:apex:log:tail --debuglevel MyDebugLevel',
70
- '$ sfdx force:apex:log:tail -c -s',
71
- ];
72
- Tail.flagsConfig = {
73
- json: command_1.flags.boolean({
74
- description: messages.getMessage('jsonDescription'),
75
- }),
76
- loglevel: command_1.flags.enum({
77
- description: messages.getMessage('logLevelDescription'),
78
- longDescription: messages.getMessage('logLevelLongDescription'),
79
- default: 'warn',
80
- options: utils_1.logLevels,
81
- }),
82
- apiversion: command_1.flags.builtin(),
83
- color: command_1.flags.boolean({
84
- char: 'c',
85
- description: messages.getMessage('colorDescription'),
86
- }),
87
- debuglevel: command_1.flags.string({
88
- char: 'd',
89
- description: messages.getMessage('debugLevelDescription'),
90
- }),
91
- skiptraceflag: command_1.flags.boolean({
92
- char: 's',
93
- description: messages.getMessage('skipTraceFlagDescription'),
94
- }),
95
- };
96
- //# sourceMappingURL=tail.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tail.js","sourceRoot":"","sources":["../../../../../src/commands/force/apex/log/tail.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qDAAmD;AACnD,iDAAyD;AACzD,2CAA4C;AAC5C,6CAAgE;AAChE,uEAA6D;AAE7D,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,yBAAyB,EAAE,MAAM,EAAE;IAChE,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;IACvB,iBAAiB;IACjB,iBAAiB;IACjB,qBAAqB;IACrB,yBAAyB;IACzB,iBAAiB;IACjB,0BAA0B;CAC3B,CAAC,CAAC;AAEH,MAAqB,IAAK,SAAQ,qBAAW;IAwC9B,GAAG;;YACd,IAAI;gBACF,IAAI,IAAI,CAAC,GAAG,EAAE;oBACZ,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;oBACtC,MAAM,UAAU,GAAG,IAAI,sBAAU,CAAC,IAAI,CAAC,CAAC;oBAExC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;w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GAAG;IACnC,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC;QAClB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC;KACpD,CAAC;IACF,QAAQ,EAAE,eAAK,CAAC,IAAI,CAAC;QACnB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;QACvD,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC;QAC/D,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,iBAAS;KACnB,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,OAAO,EAAE;IAC3B,KAAK,EAAE,eAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC;KACrD,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;KAC1D,CAAC;IACF,aAAa,EAAE,eAAK,CAAC,OAAO,CAAC;QAC3B,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;KAC7D,CAAC;CACH,CAAC"}
@@ -1,25 +0,0 @@
1
- import { flags, SfdxCommand } from '@salesforce/command';
2
- import { AnyJson } from '@salesforce/ts-types';
3
- export default class Report extends SfdxCommand {
4
- protected static requiresUsername: boolean;
5
- static description: string;
6
- static longDescription: string;
7
- static examples: string[];
8
- static readonly flagsConfig: {
9
- testrunid: flags.Discriminated<flags.String>;
10
- json: flags.Discriminated<flags.Boolean<boolean>>;
11
- loglevel: flags.Discriminated<flags.Enum<string>>;
12
- apiversion: flags.Builtin;
13
- codecoverage: flags.Discriminated<flags.Boolean<boolean>>;
14
- outputdir: flags.Discriminated<flags.String>;
15
- resultformat: flags.Discriminated<flags.Enum<string>>;
16
- wait: flags.Discriminated<flags.String>;
17
- verbose: flags.Builtin;
18
- };
19
- run(): Promise<AnyJson>;
20
- private logHuman;
21
- private logTap;
22
- private logJUnit;
23
- private formatResultInJson;
24
- private formatReportHint;
25
- }
@@ -1,175 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /*
5
- * Copyright (c) 2020, salesforce.com, inc.
6
- * All rights reserved.
7
- * Licensed under the BSD 3-Clause license.
8
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
- */
10
- const apex_node_1 = require("@salesforce/apex-node");
11
- const command_1 = require("@salesforce/command");
12
- const core_1 = require("@salesforce/core");
13
- const reporters_1 = require("../../../../reporters");
14
- const utils_1 = require("../../../../utils");
15
- core_1.Messages.importMessagesDirectory(__dirname);
16
- const messages = core_1.Messages.load('@salesforce/plugin-apex', 'report', [
17
- 'apexLibErr',
18
- 'apexTestReportFormatHint',
19
- 'codeCoverageDescription',
20
- 'commandDescription',
21
- 'jsonDescription',
22
- 'logLevelDescription',
23
- 'logLevelLongDescription',
24
- 'longDescription',
25
- 'outputDirectoryDescription',
26
- 'outputDirHint',
27
- 'resultFormatLongDescription',
28
- 'testResultProcessErr',
29
- 'testRunIdDescription',
30
- 'verboseDescription',
31
- 'waitDescription',
32
- 'warningMessage',
33
- ]);
34
- class Report extends command_1.SfdxCommand {
35
- run() {
36
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- if (this.flags.outputdir) {
38
- this.ux.warn(messages.getMessage('warningMessage'));
39
- }
40
- // add listener for errors
41
- process.on('uncaughtException', (err) => {
42
- const formattedErr = this.formatError(new core_1.SfError(messages.getMessage('apexLibErr', [err.message])));
43
- this.ux.error(...formattedErr);
44
- process.exit();
45
- });
46
- if (!this.org) {
47
- throw Error('Unable to get connection from Org.');
48
- }
49
- // org is guaranteed by requiresUsername field
50
- const conn = this.org.getConnection();
51
- const testService = new apex_node_1.TestService(conn);
52
- const result = yield testService.reportAsyncResults(this.flags.testrunid, this.flags.codecoverage);
53
- const jsonOutput = this.formatResultInJson(result);
54
- if (this.flags.outputdir) {
55
- const outputDirConfig = (0, reporters_1.buildOutputDirConfig)(result, jsonOutput, this.flags.outputdir, this.flags.resultformat, true);
56
- yield testService.writeResultFiles(result, outputDirConfig, this.flags.codecoverage);
57
- }
58
- try {
59
- if (result.summary.outcome === "Failed" /* Failed */) {
60
- process.exitCode = utils_1.FAILURE_EXIT_CODE;
61
- }
62
- switch (this.flags.resultformat) {
63
- case 'tap':
64
- this.logTap(result);
65
- break;
66
- case 'junit':
67
- this.logJUnit(result);
68
- break;
69
- case 'json':
70
- // when --json flag is specified, we should log CLI json format
71
- if (!this.flags.json) {
72
- this.ux.logJson({
73
- status: process.exitCode,
74
- result: jsonOutput,
75
- });
76
- }
77
- break;
78
- default:
79
- this.logHuman(result, true, this.flags.outputdir);
80
- }
81
- }
82
- catch (e) {
83
- this.ux.logJson(jsonOutput);
84
- const msg = messages.getMessage('testResultProcessErr', [e.message]);
85
- this.ux.error(msg);
86
- }
87
- return jsonOutput;
88
- });
89
- }
90
- logHuman(result, detailedCoverage, outputDir) {
91
- if (outputDir) {
92
- this.ux.log(messages.getMessage('outputDirHint', [outputDir]));
93
- }
94
- const humanReporter = new apex_node_1.HumanReporter();
95
- const output = humanReporter.format(result, detailedCoverage);
96
- this.ux.log(output);
97
- }
98
- logTap(result) {
99
- const reporter = new apex_node_1.TapReporter();
100
- const hint = this.formatReportHint(result);
101
- this.ux.log(reporter.format(result, [hint]));
102
- }
103
- logJUnit(result) {
104
- const reporter = new apex_node_1.JUnitReporter();
105
- this.ux.log(reporter.format(result));
106
- }
107
- formatResultInJson(result) {
108
- try {
109
- const reporter = new reporters_1.JsonReporter();
110
- return reporter.format(result);
111
- }
112
- catch (e) {
113
- this.ux.logJson(result);
114
- const msg = messages.getMessage('testResultProcessErr', [e.message]);
115
- this.ux.error(msg);
116
- throw e;
117
- }
118
- }
119
- formatReportHint(result) {
120
- let reportArgs = `-i ${result.summary.testRunId}`;
121
- if (this.flags.targetusername) {
122
- reportArgs += ` -u ${this.flags.targetusername}`;
123
- }
124
- const hint = messages.getMessage('apexTestReportFormatHint', [reportArgs]);
125
- return hint;
126
- }
127
- }
128
- exports.default = Report;
129
- Report.requiresUsername = true;
130
- Report.description = (0, utils_1.buildDescription)(messages.getMessage('commandDescription'), messages.getMessage('longDescription'));
131
- Report.longDescription = messages.getMessage('longDescription');
132
- Report.examples = [
133
- '$ sfdx force:apex:test:report -i <test run id>',
134
- '$ sfdx force:apex:test:report -i <test run id> -r junit',
135
- '$ sfdx force:apex:test:report -i <test run id> -c --json',
136
- '$ sfdx force:apex:test:report -i <test run id> -c -d <path to outputdir> -u me@myorg',
137
- ];
138
- Report.flagsConfig = {
139
- testrunid: command_1.flags.string({
140
- char: 'i',
141
- description: messages.getMessage('testRunIdDescription'),
142
- required: true,
143
- }),
144
- json: command_1.flags.boolean({
145
- description: messages.getMessage('jsonDescription'),
146
- }),
147
- loglevel: command_1.flags.enum({
148
- description: messages.getMessage('logLevelDescription'),
149
- longDescription: messages.getMessage('logLevelLongDescription'),
150
- default: 'warn',
151
- options: utils_1.logLevels,
152
- }),
153
- apiversion: command_1.flags.builtin(),
154
- codecoverage: command_1.flags.boolean({
155
- char: 'c',
156
- description: messages.getMessage('codeCoverageDescription'),
157
- }),
158
- outputdir: command_1.flags.string({
159
- char: 'd',
160
- description: messages.getMessage('outputDirectoryDescription'),
161
- }),
162
- resultformat: command_1.flags.enum({
163
- char: 'r',
164
- description: messages.getMessage('resultFormatLongDescription'),
165
- options: utils_1.resultFormat,
166
- }),
167
- wait: command_1.flags.string({
168
- char: 'w',
169
- description: messages.getMessage('waitDescription'),
170
- }),
171
- verbose: command_1.flags.builtin({
172
- description: messages.getMessage('verboseDescription'),
173
- }),
174
- };
175
- //# sourceMappingURL=report.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"report.js","sourceRoot":"","sources":["../../../../../src/commands/force/apex/test/report.ts"],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sB,CAAC;QACxD,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC;QAClB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC;KACpD,CAAC;IACF,QAAQ,EAAE,eAAK,CAAC,IAAI,CAAC;QACnB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;QACvD,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC;QAC/D,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,iBAAS;KACnB,CAAC;IACF,UAAU,EAAE,eAAK,CAAC,OAAO,EAAE;IAC3B,YAAY,EAAE,eAAK,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC;KAC5D,CAAC;IACF,SAAS,EAAE,eAAK,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC;KAC/D,CAAC;IACF,YAAY,EAAE,eAAK,CAAC,IAAI,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC/D,OAAO,EAAE,oBAAY;KACtB,CAAC;IACF,IAAI,EAAE,eAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC;KACpD,CAAC;IACF,OAAO,EAAE,eAAK,CAAC,OAAO,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;KACvD,CAAC;CACH,CAAC"}
@@ -1,40 +0,0 @@
1
- import { CancellationTokenSource } from '@salesforce/apex-node';
2
- import { flags, SfdxCommand } from '@salesforce/command';
3
- import { AnyJson } from '@salesforce/ts-types';
4
- export declare const TestLevelValues: string[];
5
- export default class Run extends SfdxCommand {
6
- protected static requiresUsername: boolean;
7
- protected cancellationTokenSource: CancellationTokenSource;
8
- static description: string;
9
- static longDescription: string;
10
- static examples: string[];
11
- static readonly flagsConfig: {
12
- json: flags.Discriminated<flags.Boolean<boolean>>;
13
- loglevel: flags.Discriminated<flags.Enum<string>>;
14
- apiversion: flags.Builtin;
15
- codecoverage: flags.Discriminated<flags.Boolean<boolean>>;
16
- outputdir: flags.Discriminated<flags.String>;
17
- testlevel: flags.Discriminated<flags.Enum<string>>;
18
- classnames: flags.Discriminated<flags.String>;
19
- resultformat: flags.Discriminated<flags.Enum<string>>;
20
- suitenames: flags.Discriminated<flags.String>;
21
- tests: flags.Discriminated<flags.String>;
22
- wait: flags.Discriminated<flags.String>;
23
- synchronous: flags.Discriminated<flags.Boolean<boolean>>;
24
- verbose: flags.Builtin;
25
- detailedcoverage: flags.Discriminated<flags.Boolean<boolean>>;
26
- };
27
- run(): Promise<AnyJson>;
28
- validateFlags(): Promise<void>;
29
- private getTestLevelfromFlags;
30
- private logHuman;
31
- private logTap;
32
- private logJUnit;
33
- private formatResultInJson;
34
- private formatReportHint;
35
- /**
36
- * Handles special exceptions where we don't want to return early
37
- * with the testRunId.
38
- **/
39
- private shouldImmediatelyReturn;
40
- }
@@ -1,299 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestLevelValues = void 0;
4
- const tslib_1 = require("tslib");
5
- /*
6
- * Copyright (c) 2020, salesforce.com, inc.
7
- * All rights reserved.
8
- * Licensed under the BSD 3-Clause license.
9
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
10
- */
11
- const apex_node_1 = require("@salesforce/apex-node");
12
- const command_1 = require("@salesforce/command");
13
- const core_1 = require("@salesforce/core");
14
- const reporters_1 = require("../../../../reporters");
15
- const utils_1 = require("../../../../utils");
16
- core_1.Messages.importMessagesDirectory(__dirname);
17
- const messages = core_1.Messages.load('@salesforce/plugin-apex', 'run', [
18
- 'apexLibErr',
19
- 'apexTestReportFormatHint',
20
- 'classNamesDescription',
21
- 'classSuiteTestErr',
22
- 'codeCoverageDescription',
23
- 'commandDescription',
24
- 'detailedCoverageDescription',
25
- 'jsonDescription',
26
- 'logLevelDescription',
27
- 'logLevelLongDescription',
28
- 'longDescription',
29
- 'missingReporterErr',
30
- 'outputDirectoryDescription',
31
- 'outputDirHint',
32
- 'resultFormatLongDescription',
33
- 'runTestReportCommand',
34
- 'suiteNamesDescription',
35
- 'syncClassErr',
36
- 'synchronousDescription',
37
- 'testLevelDescription',
38
- 'testLevelErr',
39
- 'testResultProcessErr',
40
- 'testsDescription',
41
- 'verboseDescription',
42
- 'waitDescription',
43
- 'warningMessage',
44
- ]);
45
- exports.TestLevelValues = ['RunLocalTests', 'RunAllTestsInOrg', 'RunSpecifiedTests'];
46
- class Run extends command_1.SfdxCommand {
47
- constructor() {
48
- super(...arguments);
49
- this.cancellationTokenSource = new apex_node_1.CancellationTokenSource();
50
- }
51
- run() {
52
- var _a;
53
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
- yield this.validateFlags();
55
- if (this.flags.outputdir) {
56
- this.ux.warn(messages.getMessage('warningMessage'));
57
- }
58
- // add listener for errors
59
- process.on('uncaughtException', (err) => {
60
- const formattedErr = this.formatError(new core_1.SfError(messages.getMessage('apexLibErr', [err.message])));
61
- this.ux.error(...formattedErr);
62
- process.exit();
63
- });
64
- // graceful shutdown
65
- const exitHandler = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
66
- yield this.cancellationTokenSource.asyncCancel();
67
- process.exit();
68
- });
69
- process.on('SIGINT', exitHandler);
70
- process.on('SIGTERM', exitHandler);
71
- const testLevel = this.getTestLevelfromFlags();
72
- // org is guaranteed by requiresUsername field
73
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
- const conn = this.org.getConnection();
75
- const testService = new apex_node_1.TestService(conn);
76
- let result;
77
- // NOTE: This is a *bug*. Synchronous test runs should throw an error when multiple test classes are specified
78
- // This was re-introduced due to https://github.com/forcedotcom/salesforcedx-vscode/issues/3154
79
- // Address with W-9163533
80
- if (this.flags.synchronous && testLevel === "RunSpecifiedTests" /* RunSpecifiedTests */) {
81
- const payload = yield testService.buildSyncPayload(testLevel, this.flags.tests, this.flags.classnames);
82
- payload.skipCodeCoverage = this.flags.codecoverage ? false : true;
83
- result = (yield testService.runTestSynchronous(payload, this.flags.codecoverage, this.cancellationTokenSource.token));
84
- }
85
- else {
86
- const payload = yield testService.buildAsyncPayload(testLevel, this.flags.tests, this.flags.classnames, this.flags.suitenames);
87
- payload.skipCodeCoverage = this.flags.codecoverage ? false : true;
88
- const reporter = undefined;
89
- result = yield testService.runTestAsynchronous(payload, this.flags.codecoverage, this.shouldImmediatelyReturn(), reporter, this.cancellationTokenSource.token);
90
- }
91
- if (this.cancellationTokenSource.token.isCancellationRequested) {
92
- return null;
93
- }
94
- if (this.flags.outputdir) {
95
- const jsonOutput = this.formatResultInJson(result);
96
- const outputDirConfig = (0, reporters_1.buildOutputDirConfig)(result, jsonOutput, this.flags.outputdir, this.flags.resultformat, this.flags.detailedcoverage, this.flags.synchronous);
97
- yield testService.writeResultFiles(result, outputDirConfig, this.flags.codecoverage);
98
- }
99
- try {
100
- if (result.hasOwnProperty('summary') &&
101
- result.summary.outcome === "Failed" /* Failed */) {
102
- process.exitCode = utils_1.FAILURE_EXIT_CODE;
103
- }
104
- switch (this.flags.resultformat) {
105
- case 'human':
106
- this.logHuman(result, this.flags.detailedcoverage, this.flags.outputdir);
107
- break;
108
- case 'tap':
109
- this.logTap(result);
110
- break;
111
- case 'junit':
112
- this.logJUnit(result);
113
- break;
114
- case 'json':
115
- // when --json flag is specified, we should log CLI json format
116
- if (!this.flags.json) {
117
- this.ux.logJson({
118
- status: process.exitCode,
119
- result: this.formatResultInJson(result),
120
- });
121
- }
122
- break;
123
- default:
124
- if (this.flags.synchronous || this.flags.wait) {
125
- this.logHuman(result, this.flags.detailedcoverage, this.flags.outputdir);
126
- }
127
- else {
128
- const id = result.testRunId;
129
- this.ux.log(messages.getMessage('runTestReportCommand', [id, (_a = this.org) === null || _a === void 0 ? void 0 : _a.getUsername()]));
130
- }
131
- }
132
- }
133
- catch (e) {
134
- this.ux.logJson(result);
135
- const msg = messages.getMessage('testResultProcessErr', [e.message]);
136
- this.ux.error(msg);
137
- }
138
- return this.formatResultInJson(result);
139
- });
140
- }
141
- validateFlags() {
142
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
143
- if (this.flags.codecoverage && !this.flags.resultformat) {
144
- return Promise.reject(new Error(messages.getMessage('missingReporterErr')));
145
- }
146
- if ((this.flags.classnames && (this.flags.suitenames || this.flags.tests)) ||
147
- (this.flags.suitenames && this.flags.tests)) {
148
- return Promise.reject(new Error(messages.getMessage('classSuiteTestErr')));
149
- }
150
- if (this.flags.synchronous &&
151
- (this.flags.suitenames || (this.flags.classnames && this.flags.classnames.split(',').length > 1))) {
152
- return Promise.reject(new Error(messages.getMessage('syncClassErr')));
153
- }
154
- if ((this.flags.tests || this.flags.classnames || this.flags.suitenames) &&
155
- this.flags.testlevel &&
156
- this.flags.testlevel !== 'RunSpecifiedTests') {
157
- return Promise.reject(new Error(messages.getMessage('testLevelErr')));
158
- }
159
- });
160
- }
161
- getTestLevelfromFlags() {
162
- let testLevel;
163
- if (this.flags.testlevel) {
164
- testLevel = this.flags.testlevel;
165
- }
166
- else if (this.flags.classnames || this.flags.suitenames || this.flags.tests) {
167
- testLevel = "RunSpecifiedTests" /* RunSpecifiedTests */;
168
- }
169
- else {
170
- testLevel = "RunLocalTests" /* RunLocalTests */;
171
- }
172
- return testLevel;
173
- }
174
- logHuman(result, detailedCoverage, outputDir) {
175
- if (outputDir) {
176
- this.ux.log(messages.getMessage('outputDirHint', [outputDir]));
177
- }
178
- const humanReporter = new apex_node_1.HumanReporter();
179
- const output = humanReporter.format(result, detailedCoverage);
180
- this.ux.log(output);
181
- }
182
- logTap(result) {
183
- const reporter = new apex_node_1.TapReporter();
184
- const hint = this.formatReportHint(result);
185
- this.ux.log(reporter.format(result, [hint]));
186
- }
187
- logJUnit(result) {
188
- const reporter = new apex_node_1.JUnitReporter();
189
- this.ux.log(reporter.format(result));
190
- }
191
- formatResultInJson(result) {
192
- try {
193
- const reporter = new reporters_1.JsonReporter();
194
- return result.hasOwnProperty('summary') ? reporter.format(result) : result;
195
- }
196
- catch (e) {
197
- this.ux.logJson(result);
198
- const msg = messages.getMessage('testResultProcessErr', [e.message]);
199
- this.ux.error(msg);
200
- throw e;
201
- }
202
- }
203
- formatReportHint(result) {
204
- let reportArgs = `-i ${result.summary.testRunId}`;
205
- if (this.flags.targetusername) {
206
- reportArgs += ` -u ${this.flags.targetusername}`;
207
- }
208
- const hint = messages.getMessage('apexTestReportFormatHint', [reportArgs]);
209
- return hint;
210
- }
211
- /**
212
- * Handles special exceptions where we don't want to return early
213
- * with the testRunId.
214
- **/
215
- shouldImmediatelyReturn() {
216
- if (this.flags.resultformat !== undefined) {
217
- return false;
218
- }
219
- // when the user has explictly asked to wait for results, but didn't give a format
220
- if (this.flags.wait) {
221
- return false;
222
- }
223
- // historical expectation to wait for results from a synchronous test run
224
- if (this.flags.synchronous && !this.flags.json) {
225
- return false;
226
- }
227
- return true;
228
- }
229
- }
230
- exports.default = Run;
231
- Run.requiresUsername = true;
232
- Run.description = (0, utils_1.buildDescription)(messages.getMessage('commandDescription'), messages.getMessage('longDescription'));
233
- Run.longDescription = messages.getMessage('longDescription');
234
- Run.examples = [
235
- '$ sfdx force:apex:test:run',
236
- '$ sfdx force:apex:test:run -n "MyClassTest,MyOtherClassTest" -r human',
237
- '$ sfdx force:apex:test:run -s "MySuite,MyOtherSuite" -c -v --json',
238
- '$ sfdx force:apex:test:run -t "MyClassTest.testCoolFeature,MyClassTest.testAwesomeFeature,AnotherClassTest,namespace.TheirClassTest.testThis" -r human',
239
- '$ sfdx force:apex:test:run -l RunLocalTests -d <path to outputdir> -u me@my.org',
240
- ];
241
- Run.flagsConfig = {
242
- json: command_1.flags.boolean({
243
- description: messages.getMessage('jsonDescription'),
244
- }),
245
- loglevel: command_1.flags.enum({
246
- description: messages.getMessage('logLevelDescription'),
247
- longDescription: messages.getMessage('logLevelLongDescription'),
248
- default: 'warn',
249
- options: utils_1.logLevels,
250
- }),
251
- apiversion: command_1.flags.builtin(),
252
- codecoverage: command_1.flags.boolean({
253
- char: 'c',
254
- description: messages.getMessage('codeCoverageDescription'),
255
- }),
256
- outputdir: command_1.flags.string({
257
- char: 'd',
258
- description: messages.getMessage('outputDirectoryDescription'),
259
- }),
260
- testlevel: command_1.flags.enum({
261
- char: 'l',
262
- description: messages.getMessage('testLevelDescription'),
263
- options: exports.TestLevelValues,
264
- }),
265
- classnames: command_1.flags.string({
266
- char: 'n',
267
- description: messages.getMessage('classNamesDescription'),
268
- }),
269
- resultformat: command_1.flags.enum({
270
- char: 'r',
271
- description: messages.getMessage('resultFormatLongDescription'),
272
- options: utils_1.resultFormat,
273
- }),
274
- suitenames: command_1.flags.string({
275
- char: 's',
276
- description: messages.getMessage('suiteNamesDescription'),
277
- }),
278
- tests: command_1.flags.string({
279
- char: 't',
280
- description: messages.getMessage('testsDescription'),
281
- }),
282
- wait: command_1.flags.string({
283
- char: 'w',
284
- description: messages.getMessage('waitDescription'),
285
- }),
286
- synchronous: command_1.flags.boolean({
287
- char: 'y',
288
- description: messages.getMessage('synchronousDescription'),
289
- }),
290
- verbose: command_1.flags.builtin({
291
- description: messages.getMessage('verboseDescription'),
292
- }),
293
- detailedcoverage: command_1.flags.boolean({
294
- char: 'v',
295
- description: messages.getMessage('detailedCoverageDescription'),
296
- dependsOn: ['codecoverage'],
297
- }),
298
- };
299
- //# sourceMappingURL=run.js.map