@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
package/README.md CHANGED
@@ -44,7 +44,7 @@ $ NODE_OPTIONS=--inspect-brk bin/dev force:apex:log:list -u myOrg@example.com
44
44
  <br />
45
45
  ### Running the Test Suite
46
46
 
47
- Run the test suite locally by building the project first and then running the tests.
47
+ Test the test suite locally by building the project first and then running the tests.
48
48
 
49
49
  ```
50
50
  $ yarn build
@@ -136,7 +136,7 @@ EXAMPLES
136
136
  $ sfdx force:apex:log:get -d Users/Desktop/logs -n 2
137
137
  ```
138
138
 
139
- _See code: [force/apex/log/get.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/get.ts)_
139
+ _See code: [force/apex/log/log.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/get.ts)_
140
140
  <br /><br />
141
141
 
142
142
  ### `sfdx force:apex:log:list`
@@ -162,7 +162,7 @@ OPTIONS
162
162
  [default: warn] logging level for this command invocation
163
163
 
164
164
  DESCRIPTION
165
- Run this command in a project to list the IDs and general information for all debug logs
165
+ Test this command in a project to list the IDs and general information for all debug logs
166
166
  in your default org.
167
167
  To fetch a specific log from your org, obtain the ID from this command's output, then run
168
168
  the “sfdx force:apex:log:get” command.
@@ -172,7 +172,7 @@ EXAMPLES
172
172
  $ sfdx force:apex:log:list -u me@my.org
173
173
  ```
174
174
 
175
- _See code: [force/apex/log/list.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/list.ts)_
175
+ _See code: [force/apex/log/log.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/list.ts)_
176
176
  <br /><br />
177
177
 
178
178
  ### `sfdx force:apex:log:tail`
@@ -216,7 +216,7 @@ EXAMPLES
216
216
  $ sfdx force:apex:log:tail -c -s
217
217
  ```
218
218
 
219
- _See code: [force/apex/log/tail.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/tail.ts)_
219
+ _See code: [force/apex/log/log.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/log/tail.ts)_
220
220
  <br /><br />
221
221
 
222
222
  ### `sfdx force:apex:execute`
@@ -262,7 +262,7 @@ EXAMPLES
262
262
  finished.
263
263
  ```
264
264
 
265
- _See code: [force/apex/execute.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/execute.ts)_
265
+ _See code: [force/apex/test.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/execute.ts)_
266
266
  <br /><br />
267
267
 
268
268
  ### `sfdx force:apex:test:run`
@@ -355,7 +355,7 @@ EXAMPLES
355
355
  $ sfdx force:apex:test:run -l RunLocalTests -d <path to outputdir> -u me@my.org
356
356
  ```
357
357
 
358
- _See code: [force/apex/test/run.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/test/run.ts)_
358
+ _See code: [force/apex/test/test.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/test/run.ts)_
359
359
  <br /><br />
360
360
 
361
361
  ### `sfdx force:apex:test:report`
@@ -375,7 +375,7 @@ OPTIONS
375
375
  -d, --outputdir=outputdir
376
376
  directory to store test result files
377
377
 
378
- -i, --testrunid=testrunid
378
+ -i, --test-run-id=testrunid
379
379
  (required) the ID of the test run
380
380
 
381
381
  -r, --resultformat=(human|tap|junit|json)
@@ -414,6 +414,6 @@ EXAMPLES
414
414
  $ sfdx force:apex:test:report -i <test run id> -c -d <path to outputdir> -u me@myorg
415
415
  ```
416
416
 
417
- _See code: [force/apex/test/report.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/test/report.ts)_
417
+ _See code: [force/apex/test/test.ts](https://github.com/salesforcecli/plugin-apex/blob/main/src/commands/force/apex/test/report.ts)_
418
418
 
419
419
  <!-- commandsstop -->
@@ -0,0 +1,20 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type LogGetResult = Array<{
3
+ log: string;
4
+ } | string>;
5
+ export default class Log extends SfCommand<LogGetResult> {
6
+ static readonly summary: string;
7
+ static readonly description: string;
8
+ static readonly examples: string[];
9
+ static readonly deprecateAliases = true;
10
+ static readonly aliases: string[];
11
+ static readonly flags: {
12
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ 'log-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ number: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ 'output-dir': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
18
+ };
19
+ run(): Promise<LogGetResult>;
20
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2020, 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 utils_1 = require("../../../utils");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'get');
15
+ class Log extends sf_plugins_core_1.SfCommand {
16
+ async run() {
17
+ const { flags } = await this.parse(Log);
18
+ const conn = flags['target-org'].getConnection(flags['api-version']);
19
+ const logService = new apex_node_1.LogService(conn);
20
+ const logResults = await logService.getLogs({
21
+ logId: flags['log-id'],
22
+ numberOfLogs: flags.number,
23
+ outputDir: flags['output-dir'],
24
+ });
25
+ if (logResults.length === 0) {
26
+ this.log(messages.getMessage('noResultsFound'));
27
+ return [];
28
+ }
29
+ if (flags['output-dir']) {
30
+ this.log(`Log files written to ${flags['output-dir']}`);
31
+ // TODO: look at this --outputdir will change what --json returns
32
+ return logResults.map((logResult) => logResult.log);
33
+ }
34
+ return logResults.map((logResult) => {
35
+ this.log((0, utils_1.colorLogs)(logResult.log));
36
+ return { log: logResult.log };
37
+ });
38
+ }
39
+ }
40
+ exports.default = Log;
41
+ Log.summary = messages.getMessage('summary');
42
+ Log.description = messages.getMessage('description');
43
+ Log.examples = messages.getMessages('examples');
44
+ Log.deprecateAliases = true;
45
+ Log.aliases = ['force:apex:log:get'];
46
+ Log.flags = {
47
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
48
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
49
+ loglevel: sf_plugins_core_1.loglevel,
50
+ 'log-id': sf_plugins_core_1.Flags.salesforceId({
51
+ deprecateAliases: true,
52
+ aliases: ['logid'],
53
+ char: 'i',
54
+ summary: messages.getMessage('flags.log-id.summary'),
55
+ startsWith: '07L',
56
+ length: 'both',
57
+ }),
58
+ number: sf_plugins_core_1.Flags.integer({
59
+ char: 'n',
60
+ min: 1,
61
+ default: 1,
62
+ max: 25,
63
+ summary: messages.getMessage('flags.number.summary'),
64
+ }),
65
+ 'output-dir': sf_plugins_core_1.Flags.directory({
66
+ aliases: ['outputdir', 'output-directory'],
67
+ deprecateAliases: true,
68
+ char: 'd',
69
+ summary: messages.getMessage('flags.output-dir.summary'),
70
+ description: messages.getMessage('flags.output-dir.description'),
71
+ }),
72
+ };
73
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/commands/apex/get/log.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,qDAAmD;AACnD,iEAMqC;AACrC,2CAA4C;AAC5C,0CAA2C;AAE3C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAIzE,MAAqB,GAAI,SAAQ,2BAAuB;IAmC/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CAAC,CAAC;AACjD,YAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAE5C,oBAAgB,GAAG,IAAI,CAAC;AACxB,WAAO,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACjC,SAAK,GAAG;IAC7B,YAAY,EAAE,iDAA+B;IAC7C,aAAa,EAAE,mDAAiC;IAChD,QAAQ,EAAR,0BAAQ;IACR,QAAQ,EAAE,uBAAK,CAAC,YAAY,CAAC;QAC3B,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,OAAO,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACpD,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,MAAM;KACf,CAAC;IACF,MAAM,EAAE,uBAAK,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;KACrD,CAAC;IACF,YAAY,EAAE,uBAAK,CAAC,SAAS,CAAC;QAC5B,OAAO,EAAE,CAAC,WAAW,EAAE,kBAAkB,CAAC;QAC1C,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;QACxD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;KACjE,CAAC;CACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import { RunResult } from '../../../reporters';
3
+ export default class Test extends SfCommand<RunResult> {
4
+ static readonly summary: string;
5
+ static readonly description: string;
6
+ static readonly examples: string[];
7
+ static readonly deprecateAliases = true;
8
+ static readonly aliases: string[];
9
+ static readonly flags: {
10
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ 'test-run-id': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ 'code-coverage': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ 'output-dir': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ 'result-format': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ };
18
+ run(): Promise<RunResult>;
19
+ }
@@ -0,0 +1,74 @@
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 reporters_1 = require("../../../reporters");
13
+ const utils_1 = require("../../../utils");
14
+ core_1.Messages.importMessagesDirectory(__dirname);
15
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'report');
16
+ class Test extends sf_plugins_core_1.SfCommand {
17
+ async run() {
18
+ const { flags } = await this.parse(Test);
19
+ // add listener for errors
20
+ process.on('uncaughtException', (err) => {
21
+ throw messages.createError('apexLibErr', [err.message]);
22
+ });
23
+ const conn = flags['target-org'].getConnection(flags['api-version']);
24
+ const testService = new apex_node_1.TestService(conn);
25
+ const result = await testService.reportAsyncResults(flags['test-run-id'], flags['code-coverage']);
26
+ const testReporter = new reporters_1.TestReporter(new sf_plugins_core_1.Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
27
+ return testReporter.report(result, {
28
+ 'output-dir': flags['output-dir'],
29
+ 'result-format': flags['result-format'],
30
+ json: flags.json,
31
+ codeCoverage: flags['code-coverage'],
32
+ });
33
+ }
34
+ }
35
+ exports.default = Test;
36
+ Test.summary = messages.getMessage('summary');
37
+ Test.description = messages.getMessage('description');
38
+ Test.examples = messages.getMessages('examples');
39
+ Test.deprecateAliases = true;
40
+ Test.aliases = ['force:apex:test:report'];
41
+ Test.flags = {
42
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
43
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
44
+ loglevel: sf_plugins_core_1.loglevel,
45
+ 'test-run-id': sf_plugins_core_1.Flags.salesforceId({
46
+ deprecateAliases: true,
47
+ aliases: ['testrunid'],
48
+ char: 'i',
49
+ summary: messages.getMessage('flags.test-run-id.summary'),
50
+ required: true,
51
+ startsWith: '707',
52
+ length: 'both',
53
+ }),
54
+ 'code-coverage': sf_plugins_core_1.Flags.boolean({
55
+ aliases: ['codecoverage'],
56
+ deprecateAliases: true,
57
+ char: 'c',
58
+ summary: messages.getMessage('flags.code-coverage.summary'),
59
+ }),
60
+ 'output-dir': sf_plugins_core_1.Flags.directory({
61
+ aliases: ['outputdir', 'output-directory'],
62
+ deprecateAliases: true,
63
+ char: 'd',
64
+ summary: messages.getMessage('flags.output-dir.summary'),
65
+ }),
66
+ 'result-format': sf_plugins_core_1.Flags.string({
67
+ deprecateAliases: true,
68
+ aliases: ['resultformat'],
69
+ char: 'r',
70
+ summary: messages.getMessage('flags.result-format.summary'),
71
+ options: utils_1.resultFormat,
72
+ }),
73
+ };
74
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../../src/comm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E,CAAC,cAAc,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC3D,OAAO,EAAE,oBAAY;KACtB,CAAC;CACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { LogRecord } from '@salesforce/apex-node';
2
+ import { SfCommand } from '@salesforce/sf-plugins-core';
3
+ export type LogListResult = LogRecord[];
4
+ export default class Log extends SfCommand<LogListResult> {
5
+ static readonly summary: string;
6
+ static readonly description: string;
7
+ static readonly examples: string[];
8
+ static readonly deprecateAliases = true;
9
+ static readonly aliases: string[];
10
+ static readonly flags: {
11
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ };
15
+ run(): Promise<LogListResult>;
16
+ private formatTime;
17
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2020, 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
+ core_1.Messages.importMessagesDirectory(__dirname);
13
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-apex', 'list');
14
+ class Log extends sf_plugins_core_1.SfCommand {
15
+ async run() {
16
+ const { flags } = await this.parse(Log);
17
+ const conn = flags['target-org'].getConnection(flags['api-version']);
18
+ const logService = new apex_node_1.LogService(conn);
19
+ const logRecords = await logService.getLogRecords();
20
+ if (logRecords.length === 0) {
21
+ this.log(messages.getMessage('noDebugLogsFound'));
22
+ return [];
23
+ }
24
+ logRecords.map((logRecord) => {
25
+ logRecord.StartTime = this.formatTime(logRecord.StartTime);
26
+ });
27
+ if (!flags.json) {
28
+ // while not required to prevent table output, save a few iterations if only printing json
29
+ const cleanLogs = logRecords.map((logRecord) => ({
30
+ app: logRecord.Application,
31
+ duration: String(logRecord.DurationMilliseconds),
32
+ id: logRecord.Id,
33
+ location: logRecord.Location,
34
+ size: String(logRecord.LogLength),
35
+ user: logRecord.LogUser.Name,
36
+ operation: logRecord.Operation,
37
+ request: logRecord.Request,
38
+ time: logRecord.StartTime,
39
+ status: logRecord.Status,
40
+ }));
41
+ this.table(cleanLogs, {
42
+ app: { header: messages.getMessage('appColHeader') },
43
+ duration: { header: messages.getMessage('durationColHeader') },
44
+ id: { header: messages.getMessage('idColHeader') },
45
+ location: { header: messages.getMessage('locationColHeader') },
46
+ size: { header: messages.getMessage('sizeColHeader') },
47
+ user: { header: messages.getMessage('userColHeader') },
48
+ operation: { header: messages.getMessage('operationColHeader') },
49
+ request: { header: messages.getMessage('requestColHeader') },
50
+ time: { header: messages.getMessage('timeColHeader') },
51
+ status: { header: messages.getMessage('statusColHeader') },
52
+ }, { 'no-truncate': true });
53
+ }
54
+ return logRecords;
55
+ }
56
+ // eslint-disable-next-line class-methods-use-this
57
+ formatTime(time) {
58
+ const milliIndex = time.indexOf('.');
59
+ if (milliIndex !== -1) {
60
+ return time.substring(0, milliIndex) + time.substring(milliIndex + 4);
61
+ }
62
+ return time;
63
+ }
64
+ }
65
+ exports.default = Log;
66
+ Log.summary = messages.getMessage('summary');
67
+ Log.description = messages.getMessage('description');
68
+ Log.examples = messages.getMessages('examples');
69
+ Log.deprecateAliases = true;
70
+ Log.aliases = ['force:apex:log:list'];
71
+ Log.flags = {
72
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
73
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
74
+ loglevel: sf_plugins_core_1.loglevel,
75
+ };
76
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/commands/apex/list/log.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,qDAA8D;AAC9D,iEAKqC;AACrC,2CAA4C;AAE5C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAI1E,MAAqB,GAAI,SAAQ,2BAAwB;IAahD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAExC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACrE,MAAM,UAAU,GAAG,IAAI,sBAAU,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;QAEpD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAClD,OAAO,EAAE,CAAC;SACX;QAED,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3B,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YACf,0FAA0F;YAC1F,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBAC/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;gBACtD,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;aAC3D,EACD,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAC;SACH;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,kDAAkD;IAC1C,UAAU,CAAC,IAAY;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;SACvE;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAxEH,sBAyEC;AAxEwB,WAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,eAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjD,YAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAC5C,oBAAgB,GAAG,IAAI,CAAC;AACxB,WAAO,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAElC,SAAK,GAAG;IAC7B,YAAY,EAAE,iDAA+B;IAC7C,aAAa,EAAE,mDAAiC;IAChD,QAAQ,EAAR,0BAAQ;CACT,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { CancellationTokenSource, TestLevel, TestRunIdResult } from '@salesforce/apex-node';
2
+ import { SfCommand } from '@salesforce/sf-plugins-core';
3
+ import { Duration } from '@salesforce/kit';
4
+ import { RunResult } from '../../../reporters';
5
+ export declare const TestLevelValues: string[];
6
+ export type RunCommandResult = RunResult | TestRunIdResult;
7
+ export default class Test extends SfCommand<RunCommandResult> {
8
+ static readonly summary: string;
9
+ static readonly description: string;
10
+ static readonly examples: string[];
11
+ static readonly deprecateAliases = true;
12
+ static readonly aliases: string[];
13
+ static readonly flags: {
14
+ 'target-org': import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ 'api-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ 'code-coverage': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
+ 'output-dir': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
19
+ 'test-level': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
+ 'class-names': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ 'result-format': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
22
+ 'suite-names': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
23
+ tests: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
24
+ wait: import("@oclif/core/lib/interfaces").OptionFlag<Duration | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
25
+ synchronous: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
+ 'detailed-coverage': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
27
+ };
28
+ protected cancellationTokenSource: CancellationTokenSource;
29
+ run(): Promise<RunCommandResult>;
30
+ validateFlags(codeCoverage?: boolean, resultFormatFlag?: string, classNames?: string, suiteNames?: string, tests?: string, synchronous?: boolean, testLevel?: TestLevel): Promise<TestLevel>;
31
+ private runTest;
32
+ private runTestAsynchronous;
33
+ }
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestLevelValues = void 0;
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 sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
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.loadMessages('@salesforce/plugin-apex', 'runtest');
17
+ exports.TestLevelValues = ['RunLocalTests', 'RunAllTestsInOrg', 'RunSpecifiedTests'];
18
+ class Test extends sf_plugins_core_1.SfCommand {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.cancellationTokenSource = new apex_node_1.CancellationTokenSource();
22
+ }
23
+ async run() {
24
+ const { flags } = await this.parse(Test);
25
+ const testLevel = await this.validateFlags(flags['code-coverage'], flags['result-format'], flags['class-names'], flags['suite-names'], flags.tests, flags.synchronous, flags['test-level']);
26
+ // add listener for errors
27
+ process.on('uncaughtException', (err) => {
28
+ throw messages.createError('apexLibErr', [err.message]);
29
+ });
30
+ // graceful shutdown
31
+ const exitHandler = async () => {
32
+ await this.cancellationTokenSource.asyncCancel();
33
+ process.exit();
34
+ };
35
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
36
+ process.on('SIGINT', exitHandler);
37
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
38
+ process.on('SIGTERM', exitHandler);
39
+ const conn = flags['target-org'].getConnection(flags['api-version']);
40
+ const testService = new apex_node_1.TestService(conn);
41
+ // NOTE: This is a *bug*. Synchronous test runs should throw an error when multiple test classes are specified
42
+ // This was re-introduced due to https://github.com/forcedotcom/salesforcedx-vscode/issues/3154
43
+ // Address with W-9163533
44
+ const result = flags.synchronous && testLevel === "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */
45
+ ? await this.runTest(testService, flags, testLevel)
46
+ : await this.runTestAsynchronous(testService, flags, testLevel);
47
+ if (this.cancellationTokenSource.token.isCancellationRequested) {
48
+ throw new core_1.SfError('Cancelled');
49
+ }
50
+ if ('summary' in result) {
51
+ const testReporter = new reporters_1.TestReporter(new sf_plugins_core_1.Ux({ jsonEnabled: this.jsonEnabled() }), conn, this.config.bin);
52
+ return testReporter.report(result, {
53
+ wait: flags.wait,
54
+ 'output-dir': flags['output-dir'],
55
+ 'result-format': flags['result-format'],
56
+ 'detailed-coverage': flags['detailed-coverage'],
57
+ synchronous: flags.synchronous,
58
+ json: flags.json,
59
+ codeCoverage: flags['code-coverage'],
60
+ });
61
+ }
62
+ else {
63
+ // async test run
64
+ this.log(messages.getMessage('runTestReportCommand', [this.config.bin, result.testRunId, conn.getUsername()]));
65
+ return result;
66
+ }
67
+ }
68
+ // eslint-disable-next-line class-methods-use-this,complexity
69
+ async validateFlags(codeCoverage, resultFormatFlag, classNames, suiteNames, tests, synchronous, testLevel) {
70
+ if (codeCoverage && !resultFormatFlag) {
71
+ return Promise.reject(new Error(messages.getMessage('missingReporterErr')));
72
+ }
73
+ if ((classNames && (suiteNames || tests)) || (suiteNames && tests)) {
74
+ return Promise.reject(new Error(messages.getMessage('classSuiteTestErr')));
75
+ }
76
+ if (synchronous && (suiteNames || (classNames && classNames.split(',').length > 1))) {
77
+ return Promise.reject(new Error(messages.getMessage('syncClassErr')));
78
+ }
79
+ if ((tests || classNames || suiteNames) && testLevel && testLevel !== 'RunSpecifiedTests') {
80
+ return Promise.reject(new Error(messages.getMessage('testLevelErr')));
81
+ }
82
+ let test;
83
+ if (testLevel) {
84
+ test = testLevel;
85
+ }
86
+ else if (classNames || suiteNames || tests) {
87
+ test = "RunSpecifiedTests" /* TestLevel.RunSpecifiedTests */;
88
+ }
89
+ else {
90
+ test = "RunLocalTests" /* TestLevel.RunLocalTests */;
91
+ }
92
+ return test;
93
+ }
94
+ async runTest(testService, flags, testLevel) {
95
+ const payload = {
96
+ ...(await testService.buildSyncPayload(testLevel, flags.tests, flags['class-names'])),
97
+ skipCodeCoverage: !flags['code-coverage'],
98
+ };
99
+ return (await testService.runTestSynchronous(payload, flags['code-coverage'], this.cancellationTokenSource.token));
100
+ }
101
+ async runTestAsynchronous(testService, flags, testLevel) {
102
+ const payload = {
103
+ ...(await testService.buildAsyncPayload(testLevel, flags.tests, flags['class-names'], flags['suite-names'])),
104
+ skipCodeCoverage: !flags['code-coverage'],
105
+ };
106
+ // cast as TestRunIdResult because we're building an async payload which will return an async result
107
+ return (await testService.runTestAsynchronous(payload, flags['code-coverage'], shouldImmediatelyReturn(flags.synchronous, flags['result-format'], flags.json, flags.wait), undefined, this.cancellationTokenSource.token));
108
+ }
109
+ }
110
+ exports.default = Test;
111
+ Test.summary = messages.getMessage('summary');
112
+ Test.description = messages.getMessage('description');
113
+ Test.examples = messages.getMessages('examples');
114
+ Test.deprecateAliases = true;
115
+ Test.aliases = ['force:apex:test:run'];
116
+ Test.flags = {
117
+ 'target-org': sf_plugins_core_1.requiredOrgFlagWithDeprecations,
118
+ 'api-version': sf_plugins_core_1.orgApiVersionFlagWithDeprecations,
119
+ loglevel: sf_plugins_core_1.loglevel,
120
+ 'code-coverage': sf_plugins_core_1.Flags.boolean({
121
+ aliases: ['codecoverage'],
122
+ deprecateAliases: true,
123
+ char: 'c',
124
+ summary: messages.getMessage('flags.code-coverage.summary'),
125
+ }),
126
+ 'output-dir': sf_plugins_core_1.Flags.directory({
127
+ aliases: ['outputdir', 'output-directory'],
128
+ deprecateAliases: true,
129
+ char: 'd',
130
+ summary: messages.getMessage('flags.output-dir.summary'),
131
+ }),
132
+ 'test-level': sf_plugins_core_1.Flags.string({
133
+ deprecateAliases: true,
134
+ aliases: ['testlevel'],
135
+ char: 'l',
136
+ summary: messages.getMessage('flags.test-level.summary'),
137
+ description: messages.getMessage('flags.test-level.description'),
138
+ options: exports.TestLevelValues,
139
+ }),
140
+ 'class-names': sf_plugins_core_1.Flags.string({
141
+ deprecateAliases: true,
142
+ aliases: ['classnames'],
143
+ char: 'n',
144
+ summary: messages.getMessage('flags.class-names.summary'),
145
+ description: messages.getMessage('flags.class-names.description'),
146
+ }),
147
+ 'result-format': sf_plugins_core_1.Flags.string({
148
+ deprecateAliases: true,
149
+ aliases: ['resultformat'],
150
+ char: 'r',
151
+ summary: messages.getMessage('flags.result-format.summary'),
152
+ options: utils_1.resultFormat,
153
+ }),
154
+ 'suite-names': sf_plugins_core_1.Flags.string({
155
+ deprecateAliases: true,
156
+ aliases: ['suitenames'],
157
+ char: 's',
158
+ summary: messages.getMessage('flags.suite-names.summary'),
159
+ description: messages.getMessage('flags.suite-names.description'),
160
+ }),
161
+ tests: sf_plugins_core_1.Flags.string({
162
+ char: 't',
163
+ summary: messages.getMessage('flags.tests.summary'),
164
+ description: messages.getMessage('flags.tests.description'),
165
+ }),
166
+ wait: sf_plugins_core_1.Flags.duration({
167
+ unit: 'minutes',
168
+ char: 'w',
169
+ summary: messages.getMessage('flags.wait.summary'),
170
+ }),
171
+ synchronous: sf_plugins_core_1.Flags.boolean({
172
+ char: 'y',
173
+ summary: messages.getMessage('flags.synchronous.summary'),
174
+ }),
175
+ 'detailed-coverage': sf_plugins_core_1.Flags.boolean({
176
+ deprecateAliases: true,
177
+ aliases: ['detailedcoverage'],
178
+ char: 'v',
179
+ summary: messages.getMessage('flags.detailed-coverage.summary'),
180
+ dependsOn: ['code-coverage'],
181
+ }),
182
+ };
183
+ /**
184
+ * Handles special exceptions where we don't want to return early
185
+ * with the testRunId.
186
+ **/
187
+ const shouldImmediatelyReturn = (synchronous, resultFormatFlag, json, wait) => {
188
+ if (resultFormatFlag !== undefined) {
189
+ return false;
190
+ }
191
+ // when the user has explictly asked to wait for results, but didn't give a format
192
+ if (wait) {
193
+ return false;
194
+ }
195
+ // historical expectation to wait for results from a synchronous test run
196
+ return !(synchronous && !json);
197
+ };
198
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../../src/commands/apex/run/test.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qDAAqH;AACrH,iEAOqC;AACrC,2CAAqD;AAGrD,kDAA6D;AAC7D,0CAA8C;AAE9C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEhE,QAAA,eAAe,GAAG,CAAC,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAE1F,MAAqB,IAAK,SAAQ,2BAA2B;IAA7D;;QA2EY,4BAAuB,GAAG,IAAI,mCAAuB,EAAE,CAAC;IAuJpE,CAAC;IArJQ,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CACxC,KAAK,CAAC,eAAe,CAAC,EACtB,KAAK,CAAC,eAAe,CAAC,EACtB,KAAK,CAAC,aAAa,CAAC,EACpB,KAAK,CAAC,aAAa,CAAC,EACpB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,YAAY,CAAc,CACjC,CAAC;QAEF,0BAA0B;QAC1B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;YACtC,MAAM,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,oBAAoB;QACpB,MAAM,WAAW,GAAG,KAAK,IAAmB,EAAE;YAC5C,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,EAAE,CAAC;YACjD,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