@slalom-salesforce/sf-pr-comments 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE.txt +12 -0
  2. package/README.md +147 -0
  3. package/lib/commands/azure/postcomments.d.ts +21 -0
  4. package/lib/commands/azure/postcomments.js +139 -0
  5. package/lib/commands/azure/postcomments.js.map +1 -0
  6. package/lib/commands/bitbucket/postcomments.d.ts +22 -0
  7. package/lib/commands/bitbucket/postcomments.js +141 -0
  8. package/lib/commands/bitbucket/postcomments.js.map +1 -0
  9. package/lib/commands/github/postcomments.d.ts +13 -0
  10. package/lib/commands/github/postcomments.js +39 -0
  11. package/lib/commands/github/postcomments.js.map +1 -0
  12. package/lib/helper/azureDevOps.d.ts +14 -0
  13. package/lib/helper/azureDevOps.js +151 -0
  14. package/lib/helper/azureDevOps.js.map +1 -0
  15. package/lib/helper/bitbucketDevOps.d.ts +17 -0
  16. package/lib/helper/bitbucketDevOps.js +206 -0
  17. package/lib/helper/bitbucketDevOps.js.map +1 -0
  18. package/lib/helper/utils.d.ts +20 -0
  19. package/lib/helper/utils.js +215 -0
  20. package/lib/helper/utils.js.map +1 -0
  21. package/lib/index.d.ts +2 -0
  22. package/lib/index.js +9 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib/interfaces/Comment.d.ts +10 -0
  25. package/lib/interfaces/Comment.js +3 -0
  26. package/lib/interfaces/Comment.js.map +1 -0
  27. package/lib/interfaces/CommentsByFile.d.ts +5 -0
  28. package/lib/interfaces/CommentsByFile.js +16 -0
  29. package/lib/interfaces/CommentsByFile.js.map +1 -0
  30. package/lib/interfaces/PrDiff.d.ts +5 -0
  31. package/lib/interfaces/PrDiff.js +3 -0
  32. package/lib/interfaces/PrDiff.js.map +1 -0
  33. package/lib/interfaces/ScannerResult.d.ts +6 -0
  34. package/lib/interfaces/ScannerResult.js +3 -0
  35. package/lib/interfaces/ScannerResult.js.map +1 -0
  36. package/lib/interfaces/Violation.d.ts +11 -0
  37. package/lib/interfaces/Violation.js +3 -0
  38. package/lib/interfaces/Violation.js.map +1 -0
  39. package/messages/azure.postcomments.md +51 -0
  40. package/messages/bitbucket.postcomments.md +55 -0
  41. package/messages/github.postcomments.md +16 -0
  42. package/oclif.manifest.json +209 -0
  43. package/package.json +218 -0
  44. package/schemas/hello-world.json +19 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2024, Salesforce.com, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ **NOTE: This template for sf plugins is not yet official. Please consult with the Platform CLI team before using this template.**
2
+
3
+ # sf-pr-comments
4
+
5
+ [![NPM](https://img.shields.io/npm/v/@salesforce/sf-pr-comments.svg?label=@salesforce/sf-pr-comments)](https://www.npmjs.com/package/@salesforce/sf-pr-comments) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/sf-pr-comments.svg)](https://npmjs.org/package/@salesforce/sf-pr-comments) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/sf-pr-comments/main/LICENSE.txt)
6
+
7
+ ## Using the template
8
+
9
+ This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
10
+
11
+ 1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
12
+ 2. Generate your plugin:
13
+
14
+ ```
15
+ sf plugins install dev
16
+ sf dev generate plugin
17
+
18
+ git init -b main
19
+ git add . && git commit -m "chore: initial commit"
20
+ ```
21
+
22
+ 3. Create your plugin's repo in the salesforcecli github org
23
+ 4. When you're ready, replace the contents of this README with the information you want.
24
+
25
+ ## Learn about `sf` plugins
26
+
27
+ Salesforce CLI plugins are based on the [oclif plugin framework](<(https://oclif.io/docs/introduction.html)>). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
28
+
29
+ This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards.
30
+
31
+ Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.
32
+
33
+ ### Tooling
34
+
35
+ - [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
36
+ - [@salesforce/kit](https://github.com/forcedotcom/kit)
37
+ - [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
38
+ - [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
39
+ - [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
40
+ - [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
41
+ - [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)
42
+
43
+ ### Hooks
44
+
45
+ For cross clouds commands, e.g. `sf env list`, we utilize [oclif hooks](https://oclif.io/docs/hooks) to get the relevant information from installed plugins.
46
+
47
+ This plugin includes sample hooks in the [src/hooks directory](src/hooks). You'll just need to add the appropriate logic. You can also delete any of the hooks if they aren't required for your plugin.
48
+
49
+ # Everything past here is only a suggestion as to what should be in your specific plugin's description
50
+
51
+ This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
52
+
53
+ We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ sf plugins install @salesforce/sf-pr-comments@x.y.z
59
+ ```
60
+
61
+ ## Issues
62
+
63
+ Please report any issues at https://github.com/forcedotcom/cli/issues
64
+
65
+ ## Contributing
66
+
67
+ 1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
68
+ 2. Create a new issue before starting your project so that we can keep track of
69
+ what you are trying to add/fix. That way, we can also offer suggestions or
70
+ let you know if there is already an effort in progress.
71
+ 3. Fork this repository.
72
+ 4. [Build the plugin locally](#build)
73
+ 5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
74
+ 6. Edit the code in your fork.
75
+ 7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
76
+ 8. Sign CLA (see [CLA](#cla) below).
77
+ 9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
78
+
79
+ ### CLA
80
+
81
+ External contributors will be required to sign a Contributor's License
82
+ Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
83
+
84
+ ### Build
85
+
86
+ To build the plugin locally, make sure to have yarn installed and run the following commands:
87
+
88
+ ```bash
89
+ # Clone the repository
90
+ git clone git@github.com:salesforcecli/sf-pr-comments
91
+
92
+ # Install the dependencies and compile
93
+ yarn && yarn build
94
+ ```
95
+
96
+ To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
97
+
98
+ ```bash
99
+ # Run using local run file.
100
+ ./bin/dev hello world
101
+ ```
102
+
103
+ There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
104
+
105
+ ```bash
106
+ # Link your plugin to the sf cli
107
+ sf plugins link .
108
+ # To verify
109
+ sf plugins
110
+ ```
111
+
112
+ ## Commands
113
+
114
+ <!-- commands -->
115
+
116
+ - [`sf hello world`](#sf-hello-world)
117
+
118
+ ## `sf hello world`
119
+
120
+ Say hello either to the world or someone you know.
121
+
122
+ ```
123
+ USAGE
124
+ $ sf hello world [--json] [-n <value>]
125
+
126
+ FLAGS
127
+ -n, --name=<value> [default: World] The name of the person you'd like to say hello to.
128
+
129
+ GLOBAL FLAGS
130
+ --json Format output as json.
131
+
132
+ DESCRIPTION
133
+ Say hello either to the world or someone you know.
134
+
135
+ Say hello either to the world or someone you know.
136
+
137
+ EXAMPLES
138
+ Say hello to the world:
139
+
140
+ $ sf hello world
141
+
142
+ Say hello to someone you know:
143
+
144
+ $ sf hello world --name Astro
145
+ ```
146
+
147
+ <!-- commandsstop -->
@@ -0,0 +1,21 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type CommentsResult = {
3
+ existingCommentsCount: number;
4
+ newCommentsPosted: number;
5
+ link: string;
6
+ };
7
+ export default class PostComments extends SfCommand<CommentsResult> {
8
+ static readonly summary: string;
9
+ static readonly examples: string[];
10
+ static readonly flags: {
11
+ authtoken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ azureorgname: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ azureprojectname: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ azurereponame: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ azureprid: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ foldernamefordiff: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ reviewresultjsonfile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
18
+ gitfoldername: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
19
+ };
20
+ run(): Promise<CommentsResult>;
21
+ }
@@ -0,0 +1,139 @@
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 sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
10
+ const core_1 = require("@salesforce/core");
11
+ const azureDevOps_1 = require("../../helper/azureDevOps");
12
+ const utils_1 = require("../../helper/utils");
13
+ core_1.Messages.importMessagesDirectory(__dirname);
14
+ const messages = core_1.Messages.load('@slalom-salesforce/sf-pr-comments', 'azure.postcomments', [
15
+ 'commandDescription',
16
+ 'errorAuthFailed',
17
+ 'errorPermissionIssue',
18
+ 'authtokenDescription',
19
+ 'reviewresultjsonfileDescription',
20
+ 'dataDescription',
21
+ 'azurereponameDescription',
22
+ 'azureprojectnameDescription',
23
+ 'azureorgnameDescription',
24
+ 'azurepridDescription',
25
+ 'foldernamefordiffDescription',
26
+ 'gitfoldernameDescription',
27
+ 'examples',
28
+ ]);
29
+ class PostComments extends sf_plugins_core_1.SfCommand {
30
+ async run() {
31
+ const { flags } = await this.parse(PostComments);
32
+ const log = await core_1.Logger.child(this.ctor.name);
33
+ // get current logger level for better console logs
34
+ const logLevel = log.getLevel();
35
+ // Azure DevOps related functionality is abstracted to AzureDevOps class
36
+ const azure = new azureDevOps_1.default(flags.authtoken, flags.azureorgname);
37
+ // maintains count of comments that already have been posted to the PR under consideration
38
+ let countExistingComments = 0;
39
+ // maintains count of net new comments that is posted through current execution
40
+ let countNewCommentsPosted = 0;
41
+ // get web url for PR
42
+ const pullRequestUrl = await azure.getPrUrl(flags.azureprid, flags.azureprojectname);
43
+ // reads static code analyzer output thats in JSON
44
+ const scannerResults = (0, utils_1.getCodeReviewFromFile)(flags.reviewresultjsonfile);
45
+ // transforms Scanner results into a cannonical model - CommentsByFile
46
+ const CodeReviewCommentsByFiles = (0, utils_1.parseScannerOutput)(scannerResults, flags.foldernamefordiff);
47
+ (0, utils_1.printMessage)(`CodeReviewCommentsByFiles -->
48
+ ${JSON.stringify(CodeReviewCommentsByFiles, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
49
+ // gets lines that have been updated in the current PR
50
+ // this helps to filter comments to post only comments on lines that have been updated
51
+ // since scanner reviews the entire file for issues
52
+ const diffFilesLinesadded = await azure.getPrDiff(flags.azureprojectname, flags.azureprid, flags.gitfoldername);
53
+ // fetch existing comments from PR into the cannonical model - CommentsByFile
54
+ const existingCommentsByFiles = await azure.fetchPrComments(flags.azureprojectname, flags.azurereponame, flags.azureprid);
55
+ (0, utils_1.printMessage)(`existingCommentsByFiles -->
56
+ ${JSON.stringify(existingCommentsByFiles, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
57
+ // gets count of existing comments
58
+ if (existingCommentsByFiles && existingCommentsByFiles.length > 0) {
59
+ countExistingComments = existingCommentsByFiles.length;
60
+ }
61
+ // compares code scanner results vs repository comments and returns array of just the net new files with file comments
62
+ const newCommentsByFilesToPost = (0, utils_1.filterToNewCommentsToPost)(CodeReviewCommentsByFiles, existingCommentsByFiles);
63
+ if (newCommentsByFilesToPost && newCommentsByFilesToPost.length > 0) {
64
+ // returns filtered list of comments that are only applicable to the diff (lines that changed)
65
+ const newCommentsByFilesToPostFilteredToDiff = (0, utils_1.filterCommentsToDiff)(diffFilesLinesadded, newCommentsByFilesToPost);
66
+ (0, utils_1.printMessage)(`newCommentsByFilesToPostFilteredToDiff -->
67
+ ${JSON.stringify(newCommentsByFilesToPostFilteredToDiff, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
68
+ if (newCommentsByFilesToPostFilteredToDiff && newCommentsByFilesToPostFilteredToDiff.length > 0) {
69
+ // creating thread
70
+ void azure.postPrComment(flags.azureprojectname, flags.azurereponame, flags.azureprid, newCommentsByFilesToPostFilteredToDiff);
71
+ // aggregate the count of comments across all files
72
+ countNewCommentsPosted = newCommentsByFilesToPostFilteredToDiff
73
+ .map((eachFile) => eachFile.comments.length)
74
+ .reduce((previousValue, currentValue) => previousValue + currentValue, 0);
75
+ (0, utils_1.printMessage)(`Posted ${countNewCommentsPosted} new comments to pr`, utils_1.MessageType.Success, logLevel);
76
+ }
77
+ else {
78
+ (0, utils_1.printMessage)('No new code comments found to post', utils_1.MessageType.Warn, logLevel);
79
+ }
80
+ }
81
+ else {
82
+ (0, utils_1.printMessage)('No new code comments found to post', utils_1.MessageType.Warn, logLevel);
83
+ }
84
+ // Return an object to be displayed with --json
85
+ return {
86
+ existingCommentsCount: countExistingComments,
87
+ newCommentsPosted: countNewCommentsPosted,
88
+ link: pullRequestUrl,
89
+ };
90
+ }
91
+ }
92
+ exports.default = PostComments;
93
+ PostComments.summary = messages.getMessage('commandDescription');
94
+ PostComments.examples = messages.getMessages('examples');
95
+ // public static readonly args = [{ name: 'file' }];
96
+ // input flags for command
97
+ PostComments.flags = {
98
+ authtoken: sf_plugins_core_1.Flags.string({
99
+ char: 't',
100
+ summary: messages.getMessage('authtokenDescription'),
101
+ required: true,
102
+ }),
103
+ azureorgname: sf_plugins_core_1.Flags.string({
104
+ char: 'o',
105
+ summary: messages.getMessage('azureorgnameDescription'),
106
+ required: true,
107
+ }),
108
+ azureprojectname: sf_plugins_core_1.Flags.string({
109
+ char: 'p',
110
+ summary: messages.getMessage('azureprojectnameDescription'),
111
+ required: true,
112
+ }),
113
+ azurereponame: sf_plugins_core_1.Flags.string({
114
+ char: 'r',
115
+ summary: messages.getMessage('azurereponameDescription'),
116
+ required: true,
117
+ }),
118
+ azureprid: sf_plugins_core_1.Flags.integer({
119
+ char: 'i',
120
+ summary: messages.getMessage('azurepridDescription'),
121
+ required: true,
122
+ }),
123
+ foldernamefordiff: sf_plugins_core_1.Flags.directory({
124
+ char: 'd',
125
+ summary: messages.getMessage('foldernamefordiffDescription'),
126
+ required: true,
127
+ }),
128
+ reviewresultjsonfile: sf_plugins_core_1.Flags.file({
129
+ char: 'F',
130
+ summary: messages.getMessage('reviewresultjsonfileDescription'),
131
+ required: true,
132
+ }),
133
+ gitfoldername: sf_plugins_core_1.Flags.directory({
134
+ char: 'g',
135
+ summary: messages.getMessage('gitfoldernameDescription'),
136
+ required: true,
137
+ }),
138
+ };
139
+ //# sourceMappingURL=postcomments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcomments.js","sourceRoot":"","sources":["../../../src/commands/azure/postcomments.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,iEAA+D;AAC/D,2CAAiE;AAGjE,0DAAmD;AAEnD,8CAO4B;AAG5B,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,mCAAmC,EAAE,oBAAoB,EAAE;IACxF,oBAA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AI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC3D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,aAAa,EAAE,uBAAK,CAAC,MAAM,CAAC;QAC1B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;QACxD,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,SAAS,EAAE,uBAAK,CAAC,OAAO,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;QACpD,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,iBAAiB,EAAE,uBAAK,CAAC,SAAS,CAAC;QACjC,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;QAC5D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,oBAAoB,EAAE,uBAAK,CAAC,IAAI,CAAC;QAC/B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,iCAAiC,CAAC;QAC/D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,aAAa,EAAE,uBAAK,CAAC,SAAS,CAAC;QAC7B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;QACxD,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type CommentsResult = {
3
+ existingCommentsCount: number;
4
+ newCommentsPosted: number;
5
+ link: string;
6
+ };
7
+ export default class PostComments extends SfCommand<CommentsResult> {
8
+ static readonly PAGELENGTH: number;
9
+ static readonly summary: string;
10
+ static readonly examples: string[];
11
+ static readonly flags: {
12
+ username: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ authtoken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ bitbucketworkspace: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ bitbucketreposlug: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ bitbucketprid: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ foldernamefordiff: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
18
+ gitfoldername: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
19
+ reviewresultjsonfile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
+ };
21
+ run(): Promise<CommentsResult>;
22
+ }
@@ -0,0 +1,141 @@
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 sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
10
+ const core_1 = require("@salesforce/core");
11
+ const bitbucketDevOps_1 = require("../../helper/bitbucketDevOps");
12
+ const utils_1 = require("../../helper/utils");
13
+ // Initialize Messages with the current plugin directory
14
+ core_1.Messages.importMessagesDirectory(__dirname);
15
+ const messages = core_1.Messages.load('@slalom-salesforce/sf-pr-comments', 'bitbucket.postcomments', [
16
+ 'summary',
17
+ 'examples',
18
+ 'flags.username.summary',
19
+ 'flags.authtoken.summary',
20
+ 'flags.bitbucketworkspace.summary',
21
+ 'flags.bitbucketreposlug.summary',
22
+ 'flags.bitbucketprid.summary',
23
+ 'flags.foldernamefordiff.summary',
24
+ 'flags.gitfoldername.summary',
25
+ 'flags.reviewresultjsonfile.summary',
26
+ 'error.AuthFailed',
27
+ 'error.PermissionIssue',
28
+ 'error.CodeReviewInput',
29
+ 'error.CodeReviewFile',
30
+ ]);
31
+ class PostComments extends sf_plugins_core_1.SfCommand {
32
+ async run() {
33
+ const { flags } = await this.parse(PostComments);
34
+ const log = await core_1.Logger.child(this.ctor.name);
35
+ // get current logger level for better console logs
36
+ const logLevel = log.getLevel();
37
+ // printMessage(`flags -->${JSON.stringify(flags)}`, MessageType.Debug, logLevel);
38
+ // Bitbucket related functionality is abstracted to BitbucketDevOps class
39
+ const bitbucket = new bitbucketDevOps_1.default(flags.username, flags.authtoken, flags.bitbucketworkspace);
40
+ // maintains count of comments that already have been posted to the PR under consideration
41
+ let countExistingComments = 0;
42
+ // maintains count of net new comments that is posted through current execution
43
+ let countNewCommentsPosted = 0;
44
+ (0, utils_1.printMessage)('fetching review comments from file', utils_1.MessageType.Debug, logLevel);
45
+ const scannerResults = (0, utils_1.getCodeReviewFromFile)(flags.reviewresultjsonfile);
46
+ // reads static code analyzer output thats in JSON
47
+ (0, utils_1.printMessage)('parse scanner results', utils_1.MessageType.Debug, logLevel);
48
+ // transforms Scanner results into a cannonical model - CommentsByFile
49
+ const CodeReviewCommentsByFiles = (0, utils_1.parseScannerOutput)(scannerResults, flags.foldernamefordiff);
50
+ (0, utils_1.printMessage)(`CodeReviewCommentsByFiles -->
51
+ ${JSON.stringify(CodeReviewCommentsByFiles, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
52
+ // gets lines that have been updated in the current PR
53
+ // this helps to filter comments to post only comments on lines that have been updated
54
+ // since scanner reviews the entire file for issues
55
+ const diffFilesLinesadded = await bitbucket.getPrDiff(flags.bitbucketreposlug, flags.bitbucketprid, flags.gitfoldername);
56
+ // fetch existing comments from PR into the cannonical model - CommentsByFile
57
+ const existingCommentsByFiles = await bitbucket.fetchPrComments(flags.bitbucketreposlug, flags.bitbucketprid);
58
+ (0, utils_1.printMessage)(`existingCommentsByFiles -->
59
+ ${JSON.stringify(existingCommentsByFiles, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
60
+ // gets count of existing comments
61
+ if (existingCommentsByFiles && existingCommentsByFiles.length > 0) {
62
+ countExistingComments = existingCommentsByFiles.length;
63
+ }
64
+ // compares code scanner results vs repository comments and returns array of just the net new files with file comments
65
+ const newCommentsByFilesToPost = (0, utils_1.filterToNewCommentsToPost)(CodeReviewCommentsByFiles, existingCommentsByFiles);
66
+ (0, utils_1.printMessage)(`diffFilesLinesadded -->
67
+ ${JSON.stringify(diffFilesLinesadded, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
68
+ if (newCommentsByFilesToPost && newCommentsByFilesToPost.length > 0) {
69
+ const newCommentsByFilesToPostFilteredToDiff = (0, utils_1.filterCommentsToDiff)(diffFilesLinesadded, newCommentsByFilesToPost);
70
+ (0, utils_1.printMessage)(`newCommentsByFilesToPostFilteredToDiff -->
71
+ ${JSON.stringify(newCommentsByFilesToPostFilteredToDiff, undefined, 4)}`, utils_1.MessageType.Debug, logLevel);
72
+ if (newCommentsByFilesToPostFilteredToDiff && newCommentsByFilesToPostFilteredToDiff.length > 0) {
73
+ void bitbucket.postPrComment(flags.bitbucketreposlug, flags.bitbucketprid, newCommentsByFilesToPostFilteredToDiff);
74
+ // aggregate the count of comments across all files
75
+ countNewCommentsPosted = newCommentsByFilesToPostFilteredToDiff
76
+ .map((eachFile) => eachFile.comments.length)
77
+ .reduce((previousValue, currentValue) => previousValue + currentValue, 0);
78
+ (0, utils_1.printMessage)(`Posted ${countNewCommentsPosted} new comments to ${newCommentsByFilesToPostFilteredToDiff.length} files on pr ${bitbucketDevOps_1.default.BITBUCKET_WEBAPP_URL}/${flags.bitbucketworkspace}/${flags.bitbucketreposlug}/pull-requests/${flags.bitbucketprid}`, utils_1.MessageType.Success, logLevel);
79
+ }
80
+ else {
81
+ (0, utils_1.printMessage)('No new code comments found to post', utils_1.MessageType.Warn, logLevel);
82
+ }
83
+ }
84
+ else {
85
+ (0, utils_1.printMessage)('No new code comments found to post', utils_1.MessageType.Warn, logLevel);
86
+ }
87
+ return {
88
+ existingCommentsCount: countExistingComments,
89
+ newCommentsPosted: countNewCommentsPosted,
90
+ link: `${bitbucketDevOps_1.default.BITBUCKET_WEBAPP_URL}/${flags.bitbucketworkspace}/${flags.bitbucketreposlug}/pull-requests/${flags.bitbucketprid}`,
91
+ };
92
+ }
93
+ }
94
+ exports.default = PostComments;
95
+ PostComments.PAGELENGTH = 50;
96
+ PostComments.summary = messages.getMessage('summary');
97
+ PostComments.examples = messages.getMessages('examples');
98
+ PostComments.flags = {
99
+ // flag with a value (-N, --username=VALUE)
100
+ username: sf_plugins_core_1.Flags.string({
101
+ char: 'N',
102
+ summary: messages.getMessage('flags.username.summary'),
103
+ required: true,
104
+ }),
105
+ authtoken: sf_plugins_core_1.Flags.string({
106
+ char: 't',
107
+ summary: messages.getMessage('flags.authtoken.summary'),
108
+ required: true,
109
+ }),
110
+ bitbucketworkspace: sf_plugins_core_1.Flags.string({
111
+ char: 'w',
112
+ summary: messages.getMessage('flags.bitbucketworkspace.summary'),
113
+ required: true,
114
+ }),
115
+ bitbucketreposlug: sf_plugins_core_1.Flags.string({
116
+ char: 'r',
117
+ summary: messages.getMessage('flags.bitbucketreposlug.summary'),
118
+ required: true,
119
+ }),
120
+ bitbucketprid: sf_plugins_core_1.Flags.integer({
121
+ char: 'i',
122
+ summary: messages.getMessage('flags.bitbucketprid.summary'),
123
+ required: true,
124
+ }),
125
+ foldernamefordiff: sf_plugins_core_1.Flags.directory({
126
+ char: 'd',
127
+ summary: messages.getMessage('flags.foldernamefordiff.summary'),
128
+ required: true,
129
+ }),
130
+ gitfoldername: sf_plugins_core_1.Flags.directory({
131
+ char: 'g',
132
+ summary: messages.getMessage('flags.gitfoldername.summary'),
133
+ required: true,
134
+ }),
135
+ reviewresultjsonfile: sf_plugins_core_1.Flags.file({
136
+ char: 'F',
137
+ summary: messages.getMessage('flags.reviewresultjsonfile.summary'),
138
+ required: true,
139
+ }),
140
+ };
141
+ //# sourceMappingURL=postcomments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcomments.js","sourceRoot":"","sources":["../../../src/commands/bitbucket/postcomments.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,iEAA+D;AAC/D,2CAAiE;AACjE,kEAA2D;AAI3D,8CAO4B;AAE5B,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,mCAAmC,EAAE,wBAAwB,EAAE;IAC5F,SAAS;IACT,UAAU;IACV,wBAAwB;IACxB,yBAAyB;IACzB,kCAAkC;IAClC,iCAAiC;IACjC,6BAA6B;IAC7B,iCAAiC;IACjC,6BAA6B;IAC7B,oCAAoC;IACpC,kBAAkB;IAClB,uBAAuB;IACvB,uBAAuB;IACvB,sBAAsB;CACvB,CAAC,CAAC;AAQH,MAAqB,YAAa,SAAQ,2BAAyB;IAkD1D,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,MAAM,aAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,mDAAmD;QACnD,MAAM,QAAQ,GAAgB,GAAG,CAAC,QAAQ,EAAE,CAAC;QAE7C,kFAAkF;QAClF,yEAAyE;QACzE,MAAM,SAAS,GAAG,IAAI,yBAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAEjG,0FAA0F;QAC1F,IAAI,qBAAqB,GAAG,CAAC,CAAC;QAC9B,+EAA+E;QAC/E,IAAI,sBAAsB,GAAG,CAAC,CAAC;QAE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C,6BAA6B,CAAC;QAC3D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,iBAAiB,EAAE,uBAAK,CAAC,SAAS,CAAC;QACjC,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,iCAAiC,CAAC;QAC/D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,aAAa,EAAE,uBAAK,CAAC,SAAS,CAAC;QAC7B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;QAC3D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,oBAAoB,EAAE,uBAAK,CAAC,IAAI,CAAC;QAC/B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oCAAoC,CAAC;QAClE,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type GithubPostcommentsResult = {
3
+ path: string;
4
+ };
5
+ export default class GithubPostcomments extends SfCommand<GithubPostcommentsResult> {
6
+ static readonly summary: string;
7
+ static readonly description: string;
8
+ static readonly examples: string[];
9
+ static readonly flags: {
10
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ };
12
+ run(): Promise<GithubPostcommentsResult>;
13
+ }
@@ -0,0 +1,39 @@
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 sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
10
+ const core_1 = require("@salesforce/core");
11
+ core_1.Messages.importMessagesDirectory(__dirname);
12
+ const messages = core_1.Messages.load('@slalom-salesforce/sf-pr-comments', 'github.postcomments', [
13
+ 'summary',
14
+ 'description',
15
+ 'examples',
16
+ 'flags.name.summary',
17
+ ]);
18
+ class GithubPostcomments extends sf_plugins_core_1.SfCommand {
19
+ async run() {
20
+ const { flags } = await this.parse(GithubPostcomments);
21
+ const name = flags.name ?? 'world';
22
+ this.log(`hello ${name} from /Users/fayas.mansoor/Documents/coderepo/sf-pr-comments/src/commands/github/postcomments.ts`);
23
+ return {
24
+ path: '/Users/fayas.mansoor/Documents/coderepo/sf-pr-comments/src/commands/github/postcomments.ts',
25
+ };
26
+ }
27
+ }
28
+ exports.default = GithubPostcomments;
29
+ GithubPostcomments.summary = messages.getMessage('summary');
30
+ GithubPostcomments.description = messages.getMessage('description');
31
+ GithubPostcomments.examples = messages.getMessages('examples');
32
+ GithubPostcomments.flags = {
33
+ name: sf_plugins_core_1.Flags.string({
34
+ summary: messages.getMessage('flags.name.summary'),
35
+ char: 'n',
36
+ required: false,
37
+ }),
38
+ };
39
+ //# sourceMappingURL=postcomments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcomments.js","sourceRoot":"","sources":["../../../src/commands/github/postcomments.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,iEAA+D;AAC/D,2CAA4C;AAE5C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,mCAAmC,EAAE,qBAAqB,EAAE;IACzF,SAAS;IACT,aAAa;IACb,UAAU;IACV,oBAAoB;CACrB,CAAC,CAAC;AAMH,MAAqB,kBAAmB,SAAQ,2BAAmC;IAa1E,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAEvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC;QACnC,IAAI,CAAC,GAAG,CACN,SAAS,IAAI,kGAAkG,CAChH,CAAC;QACF,OAAO;YACL,IAAI,EAAE,4FAA4F;SACnG,CAAC;IACJ,CAAC;;AAvBH,qCAwBC;AAvBwB,0BAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,8BAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACjD,2BAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAE5C,wBAAK,GAAG;IAC7B,IAAI,EAAE,uBAAK,CAAC,MAAM,CAAC;QACjB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,KAAK;KAChB,CAAC;CACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { CommentsByFile } from '../interfaces/CommentsByFile';
2
+ import { PrDiff } from '../interfaces/PrDiff';
3
+ export default class AzureDevOps {
4
+ private authorizationToken;
5
+ private organizationName;
6
+ private orgUrl;
7
+ private connection;
8
+ constructor(authorizationToken: string, organizationName: string);
9
+ getPrUrl(prId: number, projectName: string): Promise<string>;
10
+ fetchPrComments(projectName: string, repoName: string, prId: number): Promise<CommentsByFile[]>;
11
+ postPrComment(projectName: string, repoName: string, prId: number, commentsPerFiles: CommentsByFile[]): Promise<any>;
12
+ sendRequestPostPRComments(repoName: string, prId: number, projectName: string, commentsPerFile: CommentsByFile): Promise<any[]>;
13
+ getPrDiff(projectName: string, prId: number, gitFolderPath?: string): Promise<PrDiff[]>;
14
+ }