@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
@@ -0,0 +1,25 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type ExecuteResult = {
3
+ compiled: boolean;
4
+ success: boolean;
5
+ line: number;
6
+ column: number;
7
+ exceptionStackTrace: string;
8
+ compileProblem: string;
9
+ logs: string | undefined;
10
+ exceptionMessage: string;
11
+ };
12
+ export default class Run extends SfCommand<ExecuteResult> {
13
+ static readonly summary: string;
14
+ static readonly description: string;
15
+ static readonly examples: string[];
16
+ static aliases: string[];
17
+ static deprecateAliases: boolean;
18
+ static readonly flags: {
19
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
22
+ file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
23
+ };
24
+ run(): Promise<ExecuteResult>;
25
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2020, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * Licensed under the BSD 3-Clause license.
7
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+ const apex_node_1 = require("@salesforce/apex-node");
10
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
11
+ const core_1 = require("@salesforce/core");
12
+ const runReporter_1 = require("../../reporters/runReporter");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'run');
15
+ class Run extends sf_plugins_core_1.SfCommand {
16
+ async run() {
17
+ const { flags } = await this.parse(Run);
18
+ const conn = flags['target-org'].getConnection(flags['api-version']);
19
+ const exec = new apex_node_1.ExecuteService(conn);
20
+ const execAnonOptions = {
21
+ ...(flags.file ? { apexFilePath: flags.file } : { userInput: true }),
22
+ };
23
+ const result = await exec.executeAnonymous(execAnonOptions);
24
+ const formattedResult = runReporter_1.default.formatJson(result);
25
+ if (!result.compiled || !result.success) {
26
+ const err = !result.compiled
27
+ ? new core_1.SfError(messages.getMessage('executeCompileFailure'), 'executeCompileFailure')
28
+ : new core_1.SfError(messages.getMessage('executeRuntimeFailure'), 'executeRuntimeFailure');
29
+ err.setData(formattedResult);
30
+ throw err;
31
+ }
32
+ this.log(runReporter_1.default.formatDefault(result));
33
+ return formattedResult;
34
+ }
35
+ }
36
+ exports.default = Run;
37
+ Run.summary = messages.getMessage('summary');
38
+ Run.description = messages.getMessage('description');
39
+ Run.examples = messages.getMessages('examples');
40
+ Run.aliases = ['force:apex:execute'];
41
+ Run.deprecateAliases = true;
42
+ Run.flags = {
43
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
44
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
45
+ loglevel: sf_plugins_core_1.loglevel,
46
+ file: sf_plugins_core_1.Flags.file({
47
+ deprecateAliases: true,
48
+ aliases: ['apexcodefile'],
49
+ char: 'f',
50
+ summary: messages.getMessage('flags.file'),
51
+ }),
52
+ };
53
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/apex/run.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,qDAA2E;AAC3E,iEAMqC;AACrC,2CAAqD;AACrD,6DAAsD;AAEtD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAazE,MAAqB,GAAI,SAAQ,2BAAwB;IAmBhD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACrE,MAAM,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C7C,aAAa,EAAE,mDAAiC;IAChD,QAAQ,EAAR,0BAAQ;IACR,IAAI,EAAE,uBAAK,CAAC,IAAI,CAAC;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;KAC3C,CAAC;CACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export default class Log extends SfCommand<void> {
3
+ static readonly summary: string;
4
+ static readonly description: string;
5
+ static readonly examples: string[];
6
+ static readonly deprecateAliases = true;
7
+ static readonly aliases: string[];
8
+ static readonly flags: {
9
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ color: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ 'debug-level': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ 'skip-trace-flag': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ private color;
17
+ run(): Promise<void>;
18
+ logTailer(fullLog: string): Promise<void>;
19
+ /**
20
+ * for UT purposes
21
+ *
22
+ * @param conn : Connection to the org
23
+ * @private
24
+ */
25
+ private getLogService;
26
+ }
@@ -0,0 +1,81 @@
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 apex_node_1 = require("@salesforce/apex-node");
10
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
11
+ const core_1 = require("@salesforce/core");
12
+ const legacyColorization_1 = require("../../../legacyColorization");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'tail');
15
+ class Log extends sf_plugins_core_1.SfCommand {
16
+ async run() {
17
+ const { flags } = await this.parse(Log);
18
+ this.color = flags.color;
19
+ const conn = flags['target-org'].getConnection(flags['api-version']);
20
+ const logService = this.getLogService(conn);
21
+ if (!flags['skip-trace-flag']) {
22
+ await logService.prepareTraceFlag(flags['debug-level'] ?? '');
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
25
+ await logService.tail(flags['target-org'], this.logTailer.bind(this));
26
+ this.log(messages.getMessage('finishedTailing'));
27
+ }
28
+ async logTailer(fullLog) {
29
+ if (fullLog) {
30
+ if (this.jsonEnabled()) {
31
+ this.styledJSON({
32
+ status: process.exitCode,
33
+ result: fullLog,
34
+ });
35
+ }
36
+ else {
37
+ const output = this.color ? await (0, legacyColorization_1.colorizeLog)(fullLog) : fullLog;
38
+ this.log(output);
39
+ }
40
+ }
41
+ }
42
+ /**
43
+ * for UT purposes
44
+ *
45
+ * @param conn : Connection to the org
46
+ * @private
47
+ */
48
+ // eslint-disable-next-line class-methods-use-this
49
+ getLogService(conn) {
50
+ return new apex_node_1.LogService(conn);
51
+ }
52
+ }
53
+ exports.default = Log;
54
+ Log.summary = messages.getMessage('summary');
55
+ Log.description = messages.getMessage('description');
56
+ Log.examples = messages.getMessages('examples');
57
+ Log.deprecateAliases = true;
58
+ Log.aliases = ['force:apex:log:tail'];
59
+ Log.flags = {
60
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
61
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
62
+ loglevel: sf_plugins_core_1.loglevel,
63
+ color: sf_plugins_core_1.Flags.boolean({
64
+ char: 'c',
65
+ summary: messages.getMessage('flags.color.summary'),
66
+ }),
67
+ 'debug-level': sf_plugins_core_1.Flags.string({
68
+ deprecateAliases: true,
69
+ aliases: ['debuglevel'],
70
+ char: 'd',
71
+ summary: messages.getMessage('flags.debug-level.summary'),
72
+ exclusive: ['skip-trace-flag'],
73
+ }),
74
+ 'skip-trace-flag': sf_plugins_core_1.Flags.boolean({
75
+ deprecateAliases: true,
76
+ aliases: ['skiptraceflag'],
77
+ char: 's',
78
+ summary: messages.getMessage('flags.skip-trace-flag.summary'),
79
+ }),
80
+ };
81
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/commands/apex/tail/log.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,qDAAmD;AACnD,iEAMqC;AACrC,2CAAwD;AACxD,oEAA0D;AAE1D,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAE1E,MAAqB,GAAI,SAAQ,2BAAe;IA+BvC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAEzB,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAC7B,MAAM,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;SAC/D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,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;KACpD,CAAC;IACF,aAAa,EAAE,uBAAK,CAAC,MAAM,CAAC;QAC1B,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,YAAY,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;QACzD,SAAS,EAAE,CAAC,iBAAiB,CAAC;KAC/B,CAAC;IACF,iBAAiB,EAAE,uBAAK,CAAC,OAAO,CAAC;QAC/B,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,eAAe,CAAC;QAC1B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC;KAC9D,CAAC;CACH,CAAC"}
@@ -7,7 +7,6 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.colorizeLog = void 0;
10
- const tslib_1 = require("tslib");
11
10
  const chalk = require("chalk");
12
11
  const core_1 = require("@salesforce/core");
13
12
  const DEFAULT_COLOR_MAP = {
@@ -24,47 +23,46 @@ const DEFAULT_COLOR_MAP = {
24
23
  * @param log - full debug log retrieved from an org.
25
24
  * @returns colorized log
26
25
  */
27
- function colorizeLog(log) {
28
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
- const logger = yield core_1.Logger.child('apexLogApi', { tag: 'tail' });
30
- let colorMap = DEFAULT_COLOR_MAP;
31
- const localColorMapFile = process.env.SFDX_APEX_LOG_COLOR_MAP;
32
- if (localColorMapFile) {
33
- try {
34
- colorMap = require(localColorMapFile);
35
- }
36
- catch (err) {
37
- logger.warn(`Color registry not found: ${localColorMapFile}`);
38
- }
26
+ async function colorizeLog(log) {
27
+ const logger = await core_1.Logger.child('apexLogApi', { tag: 'tail' });
28
+ let colorMap = DEFAULT_COLOR_MAP;
29
+ const localColorMapFile = process.env.SFDX_APEX_LOG_COLOR_MAP;
30
+ if (localColorMapFile) {
31
+ try {
32
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
33
+ colorMap = require(localColorMapFile);
39
34
  }
40
- const logLines = log.split(/\n/g);
41
- if (!logLines || logLines.length < 1) {
42
- logger.warn('colorizeLog unable to split logLines');
43
- return log;
35
+ catch (err) {
36
+ logger.warn(`Color registry not found: ${localColorMapFile}`);
44
37
  }
45
- const line1 = chalk.bold(logLines.shift());
46
- return [
47
- line1,
48
- ...logLines.map((logLine) => {
49
- for (const [key, color] of Object.entries(colorMap)) {
50
- if (logLine.includes(`|${key}`)) {
51
- const colorFn = chalk.keyword(color);
52
- if (typeof colorFn !== 'function') {
53
- logger.warn(`Color ${color} is not supported`);
54
- return logLine;
55
- }
56
- const count = (logLine.match(/\|/g) || []).length;
57
- if (count === 1) {
58
- return colorFn(logLine);
59
- }
60
- const first = logLine.indexOf('|', logLine.indexOf('|') + 1);
61
- return `${colorFn(logLine.substring(0, first))}${logLine.substring(first)}`;
38
+ }
39
+ const logLines = log.split(/\n/g);
40
+ if (!logLines || logLines.length < 1) {
41
+ logger.warn('colorizeLog unable to split logLines');
42
+ return log;
43
+ }
44
+ const line1 = chalk.bold(logLines.shift());
45
+ return [
46
+ line1,
47
+ ...logLines.map((logLine) => {
48
+ for (const [key, color] of Object.entries(colorMap)) {
49
+ if (logLine.includes(`|${key}`)) {
50
+ const colorFn = chalk.keyword(color);
51
+ if (typeof colorFn !== 'function') {
52
+ logger.warn(`Color ${color} is not supported`);
53
+ return logLine;
62
54
  }
55
+ const count = (logLine.match(/\|/g) ?? []).length;
56
+ if (count === 1) {
57
+ return colorFn(logLine);
58
+ }
59
+ const first = logLine.indexOf('|', logLine.indexOf('|') + 1);
60
+ return `${colorFn(logLine.substring(0, first))}${logLine.substring(first)}`;
63
61
  }
64
- return logLine;
65
- }),
66
- ].join('\n');
67
- });
62
+ }
63
+ return logLine;
64
+ }),
65
+ ].join('\n');
68
66
  }
69
67
  exports.colorizeLog = colorizeLog;
70
68
  //# sourceMappingURL=legacyColorization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacyColorization.js","sourceRoot":"","sources":["../src/legacyColorization.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,+BAA+B;AAC/B,2CAA0C;AAE1C,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,SAAS;IACvB,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,UAAU;CACtB,CAAC;AAEF;;;;GAIG;AACH,SAAsB,WAAW,CAAC,GAAW;;QAC3C,MAAM,MAAM,GAAG,MAAM,aAAM,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,IAAI,QAAQ,GAAG,iBAAiB,CAAC;QAEjC,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;QAC9D,IAAI,iBAAiB,EAAE;YACrB,IAAI;gBACF,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;aACvC;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,IAAI,CAAC,6BAA6B,iBAAiB,EAAE,CAAC,CAAC;aAC/D;SACF;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACpC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YACpD,OAAO,GAAG,CAAC;SACZ;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QAE3C,OAAO;YACL,KAAK;YACL,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC1B,KAAK,MA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CAAC,CAAC;wBAC/C,OAAO,OAAO,CAAC;qBAChB;oBAED,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;oBAClD,IAAI,KAAK,KAAK,CAAC,EAAE;wBACf,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;qBACzB;oBACD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC7D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;iBAC7E;aACF;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AA7CD,kCA6CC"}
@@ -1,2 +1,2 @@
1
- export { JsonReporter, CliJsonFormat } from './jsonReporter';
2
- export { buildOutputDirConfig } from './util';
1
+ export { JsonReporter, RunResult } from './jsonReporter';
2
+ export { TestReporter } from './testReporter';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildOutputDirConfig = exports.JsonReporter = void 0;
3
+ exports.TestReporter = exports.JsonReporter = void 0;
4
4
  /*
5
5
  * Copyright (c) 2020, salesforce.com, inc.
6
6
  * All rights reserved.
@@ -9,6 +9,6 @@ exports.buildOutputDirConfig = exports.JsonReporter = void 0;
9
9
  */
10
10
  var jsonReporter_1 = require("./jsonReporter");
11
11
  Object.defineProperty(exports, "JsonReporter", { enumerable: true, get: function () { return jsonReporter_1.JsonReporter; } });
12
- var util_1 = require("./util");
13
- Object.defineProperty(exports, "buildOutputDirConfig", { enumerable: true, get: function () { return util_1.buildOutputDirConfig; } });
12
+ var testReporter_1 = require("./testReporter");
13
+ Object.defineProperty(exports, "TestReporter", { enumerable: true, get: function () { return testReporter_1.TestReporter; } });
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAA6D;AAApD,4GAAA,YAAY,OAAA;AACrB,+BAA8C;AAArC,4GAAA,oBAAoB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAAyD;AAAhD,4GAAA,YAAY,OAAA;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -1,10 +1,31 @@
1
1
  import { ApexTestResultOutcome, TestResult } from '@salesforce/apex-node';
2
- export declare type CliJsonFormat = {
3
- summary: object;
2
+ import { ApexTestRunResultStatus } from '@salesforce/apex-node/lib/src/tests/types';
3
+ export type RunResult = {
4
+ summary: Summary;
4
5
  tests: CliTestResult[];
5
6
  coverage?: CliCoverageResult;
6
7
  };
7
- declare type CliTestResult = {
8
+ type Summary = {
9
+ outcome: ApexTestRunResultStatus;
10
+ testsRan: number;
11
+ passing: number;
12
+ failing: number;
13
+ skipped: number;
14
+ passRate: string;
15
+ failRate: string;
16
+ testStartTime: string;
17
+ testExecutionTime: string;
18
+ testTotalTime: string;
19
+ commandTime: string;
20
+ hostname: string;
21
+ orgId: string;
22
+ username: string;
23
+ testRunId: string;
24
+ userId: string;
25
+ orgWideCoverage?: string;
26
+ testRunCoverage?: string;
27
+ };
28
+ type CliTestResult = {
8
29
  Id: string;
9
30
  QueueItemId: string;
10
31
  StackTrace: string;
@@ -20,15 +41,15 @@ declare type CliTestResult = {
20
41
  RunTime: number;
21
42
  FullName: string;
22
43
  };
23
- declare type ClassCoverage = {
44
+ type ClassCoverage = {
24
45
  id: string;
25
46
  name: string;
26
47
  totalLines: number;
27
- lines: {};
48
+ lines: Record<string, number>;
28
49
  totalCovered: number;
29
50
  coveredPercent: number;
30
51
  };
31
- declare type PerClassCoverage = {
52
+ type PerClassCoverage = {
32
53
  ApexTestClass: {
33
54
  Id: string;
34
55
  Name: string;
@@ -45,22 +66,18 @@ declare type PerClassCoverage = {
45
66
  };
46
67
  NumLinesUncovered: number;
47
68
  };
48
- declare type CliCoverageResult = {
69
+ type CliCoverageResult = {
49
70
  coverage: ClassCoverage[];
50
71
  records: PerClassCoverage[];
51
72
  summary: {
52
- totalLines: number;
53
- coveredLines: number;
54
- testRunCoverage: string;
55
- orgWideCoverage: string;
73
+ totalLines?: number;
74
+ coveredLines?: number;
75
+ testRunCoverage?: string;
76
+ orgWideCoverage?: string;
56
77
  };
57
78
  };
58
79
  export declare class JsonReporter {
59
- format(result: TestResult): {
60
- summary: object;
61
- tests: CliTestResult[];
62
- coverage?: CliCoverageResult;
63
- };
80
+ format(result: TestResult): RunResult;
64
81
  private formatSummary;
65
82
  private formatTestResults;
66
83
  private formatCoverage;
@@ -5,12 +5,17 @@ const skippedProperties = ['skipRate', 'coveredLines', 'totalLines'];
5
5
  const timeProperties = ['testExecutionTimeInMs', 'testTotalTimeInMs', 'commandTimeInMs'];
6
6
  class JsonReporter {
7
7
  format(result) {
8
- return Object.assign({ summary: this.formatSummary(result), tests: this.formatTestResults(result.tests) }, (result.codecoverage
9
- ? {
10
- coverage: this.formatCoverage(result),
11
- }
12
- : {}));
8
+ return {
9
+ summary: this.formatSummary(result),
10
+ tests: this.formatTestResults(result.tests),
11
+ ...(result.codecoverage
12
+ ? {
13
+ coverage: this.formatCoverage(result),
14
+ }
15
+ : {}),
16
+ };
13
17
  }
18
+ // eslint-disable-next-line class-methods-use-this
14
19
  formatSummary(testResult) {
15
20
  const summary = {};
16
21
  Object.entries(testResult.summary).forEach(([key, value]) => {
@@ -21,10 +26,11 @@ class JsonReporter {
21
26
  key = key.replace('InMs', '');
22
27
  value = `${value} ms`;
23
28
  }
24
- Object.assign(summary, { [key]: value });
29
+ return Object.assign(summary, { [key]: value });
25
30
  });
26
31
  return summary;
27
32
  }
33
+ // eslint-disable-next-line class-methods-use-this
28
34
  formatTestResults(testResults) {
29
35
  return testResults.map((test) => ({
30
36
  Id: test.id,
@@ -43,6 +49,7 @@ class JsonReporter {
43
49
  FullName: test.fullName,
44
50
  }));
45
51
  }
52
+ // eslint-disable-next-line class-methods-use-this
46
53
  formatCoverage(testResult) {
47
54
  const formattedCov = {
48
55
  coverage: [],
@@ -65,16 +72,23 @@ class JsonReporter {
65
72
  totalLines: cov.numLinesCovered + cov.numLinesUncovered,
66
73
  lines,
67
74
  totalCovered: cov.numLinesCovered,
68
- coveredPercent: parseInt(cov.percentage),
75
+ coveredPercent: parseInt(cov.percentage, 10),
69
76
  };
70
77
  });
71
78
  testResult.tests.forEach((test) => {
72
79
  if (test.perClassCoverage) {
73
80
  test.perClassCoverage.forEach((perClassCov) => {
74
- formattedCov.records.push(Object.assign(Object.assign({ ApexTestClass: { Id: test.id, Name: test.apexClass.name } }, (perClassCov.coverage ? { Coverage: perClassCov.coverage } : {})), { TestMethodName: test.methodName, NumLinesCovered: perClassCov.numLinesCovered, ApexClassOrTrigger: {
81
+ formattedCov.records.push({
82
+ ApexTestClass: { Id: test.id, Name: test.apexClass.name },
83
+ ...(perClassCov.coverage ? { Coverage: perClassCov.coverage } : {}),
84
+ TestMethodName: test.methodName,
85
+ NumLinesCovered: perClassCov.numLinesCovered,
86
+ ApexClassOrTrigger: {
75
87
  Id: perClassCov.apexClassOrTriggerId,
76
88
  Name: perClassCov.apexClassOrTriggerName,
77
- }, NumLinesUncovered: perClassCov.numLinesUncovered }));
89
+ },
90
+ NumLinesUncovered: perClassCov.numLinesUncovered,
91
+ });
78
92
  });
79
93
  }
80
94
  });
@@ -1 +1 @@
1
- {"version":3,"file":"jsonReporter.js","sourceRoot":"","sources":["../../src/reporters/jsonReporter.ts"],"names":[],"mappings":";;;AA8DA,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,cAAc,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'../commands/apex/run';
3
+ export default class RunReporter {
4
+ static formatDefault(response: ExecuteAnonymousResponse): string;
5
+ static formatJson(response: ExecuteAnonymousResponse): ExecuteResult;
6
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (c) 2023, salesforce.com, inc.
5
+ * All rights reserved.
6
+ * Licensed under the BSD 3-Clause license.
7
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
8
+ */
9
+ const os = require("os");
10
+ const core_1 = require("@salesforce/core");
11
+ const utils_1 = require("../utils");
12
+ core_1.Messages.importMessagesDirectory(__dirname);
13
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'run');
14
+ class RunReporter {
15
+ static formatDefault(response) {
16
+ const outputText = [];
17
+ if (response.success) {
18
+ outputText.push((0, utils_1.colorSuccess)(messages.getMessage('executeCompileSuccess')), (0, utils_1.colorSuccess)(messages.getMessage('executeRuntimeSuccess')), '', response.logs ?? '');
19
+ }
20
+ else {
21
+ if (!response.diagnostic) {
22
+ throw Error('No diagnostic property found on response.');
23
+ }
24
+ const diagnostic = response.diagnostic[0];
25
+ if (!response.compiled) {
26
+ outputText.push((0, utils_1.colorError)(`Error: Line: ${diagnostic.lineNumber}, Column: ${diagnostic.columnNumber}`), (0, utils_1.colorError)(`Error: ${diagnostic.compileProblem}\n`));
27
+ }
28
+ else {
29
+ outputText.push((0, utils_1.colorSuccess)(messages.getMessage('executeCompileSuccess')), (0, utils_1.colorError)(`Error: ${diagnostic.exceptionMessage}`), (0, utils_1.colorError)(`Error: ${diagnostic.exceptionStackTrace}`), '', response.logs ?? '');
30
+ }
31
+ }
32
+ return outputText.join(os.EOL);
33
+ }
34
+ static formatJson(response) {
35
+ return {
36
+ success: response.success,
37
+ compiled: response.compiled,
38
+ compileProblem: response.diagnostic?.[0].compileProblem ?? '',
39
+ exceptionMessage: response.diagnostic?.[0].exceptionMessage ?? '',
40
+ exceptionStackTrace: response.diagnostic?.[0].exceptionStackTrace ?? '',
41
+ line: response.diagnostic?.[0].lineNumber ?? -1,
42
+ column: response.diagnostic?.[0].columnNumber ?? -1,
43
+ logs: response.logs,
44
+ };
45
+ }
46
+ }
47
+ exports.default = RunReporter;
48
+ //# sourceMappingURL=runReporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runReporter.js","sourceRoot":"","sources":["../../src/reporters/runReporter.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,yBAAyB;AAEzB,2CAA4C;AAC5C,oCAAoD;AAGpD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAEzE,MAAqB,WAAW;IACvB,MAAM,CAAC,aAAa,CAAC,QAAkC;QAC5D,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,UAAU,CAAC,IAAI,CACb,IAAA,oBAAY,EAAC,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,EAC1D,IAAA,oBAAY,EAAC,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,EAC1D,EAAE,EACF,QAAQ,CAAC,IAAI,IAAI,EAAE,CACpB,CAAC;SACH;aAAM;YACL,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;gBACxB,MAAM,KAAK,CAAC,2CAA2C,CAAC,CAAC;aAC1D;YACD,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;gBACtB,UAAU,CAAC,IAAI,CACb,IAAA,kBAAU,EAAC,gBAAgB,UAAU,CAAC,UAAU,aAAa,UAAU,CAAC,YAAY,EAAE,CAAC,EACvF,IAAA,kBAAU,EAAC,UAAU,UAAU,CAAC,cAAc,IAAI,CAAC,CACpD,CAAC;aACH;iBAAM;gBACL,UAAU,CAAC,IAAI,CACb,IAAA,oBAAY,EAAC,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,EAC1D,IAAA,kBAAU,EAAC,UAAU,UAAU,CAAC,gBAAgB,EAAE,CAAC,EACnD,IAAA,kBAAU,EAAC,UAAU,UAAU,CAAC,mBAAmB,EAAE,CAAC,EACtD,EAAE,EACF,QAAQ,CAAC,IAAI,IAAI,EAAE,CACpB,CAAC;aACH;SACF;QACD,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,QAAkC;QACzD,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,cAAc,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,IAAI,EAAE;YAC7D,gBAAgB,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,IAAI,EAAE;YACjE,mBAAmB,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,mBAAmB,IAAI,EAAE;YACvE,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;YAC/C,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC;YACnD,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC;IACJ,CAAC;CACF;AA7CD,8BA6CC"}
@@ -0,0 +1,44 @@
1
+ import { TestResult } from '@salesforce/apex-node';
2
+ import { Ux } from '@salesforce/sf-plugins-core';
3
+ import { Connection } from '@salesforce/core';
4
+ import { Duration } from '@salesforce/kit';
5
+ import { RunResult } from './jsonReporter';
6
+ export declare class TestReporter {
7
+ private readonly ux;
8
+ private readonly connection;
9
+ private readonly bin;
10
+ /**
11
+ * Create a TestReporter that will format test results
12
+ *
13
+ * @param ux a new Ux instance based on if the command is in json mode
14
+ * @param connection a connection to the org the tests are being run against - used for getting username for hints
15
+ * @param bin the bin of the cli, used for providing suggestions in the users cli
16
+ */
17
+ constructor(ux: Ux, connection: Connection, bin: string);
18
+ report(result: TestResult, options: {
19
+ wait?: Duration;
20
+ 'output-dir'?: string;
21
+ 'result-format'?: string;
22
+ 'detailed-coverage'?: boolean;
23
+ synchronous?: boolean;
24
+ json?: boolean;
25
+ codeCoverage?: boolean;
26
+ }): Promise<RunResult>;
27
+ /**
28
+ * Builds output directory configuration with CLI format result files
29
+ *
30
+ * @param result Test results from async/sync test run
31
+ * @param jsonOutput JSON CLI format of test results
32
+ * @param outputDir Output directory for result files
33
+ * @param resultFormat Result format for output files
34
+ * @param detailedCoverage Boolean to control detailed coverage reporting
35
+ * @param synchronous Whether the test run was synchronous
36
+ * @returns Output directory configuration
37
+ */
38
+ private buildOutputDirConfig;
39
+ private formatResultInJson;
40
+ private logHuman;
41
+ private logTap;
42
+ private logJUnit;
43
+ private formatReportHint;
44
+ }