mobbdev 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +174 -55
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -614,8 +614,12 @@ var GitReferenceDocument = `
|
|
|
614
614
|
}
|
|
615
615
|
`;
|
|
616
616
|
var AutoPrAnalysisDocument = `
|
|
617
|
-
mutation autoPrAnalysis($analysisId: String!, $commitDirectly: Boolean) {
|
|
618
|
-
autoPrAnalysis(
|
|
617
|
+
mutation autoPrAnalysis($analysisId: String!, $commitDirectly: Boolean, $prId: Int) {
|
|
618
|
+
autoPrAnalysis(
|
|
619
|
+
analysisId: $analysisId
|
|
620
|
+
sameBranchCommit: $commitDirectly
|
|
621
|
+
prId: $prId
|
|
622
|
+
) {
|
|
619
623
|
__typename
|
|
620
624
|
... on AutoPrSuccess {
|
|
621
625
|
status
|
|
@@ -4303,6 +4307,26 @@ async function getAdoSdk(params) {
|
|
|
4303
4307
|
}
|
|
4304
4308
|
return parsedPullRequestStatus.data;
|
|
4305
4309
|
},
|
|
4310
|
+
async addCommentToAdoPullRequest({
|
|
4311
|
+
repoUrl,
|
|
4312
|
+
prNumber,
|
|
4313
|
+
markdownComment
|
|
4314
|
+
}) {
|
|
4315
|
+
const { repo, projectName } = parseAdoOwnerAndRepo(repoUrl);
|
|
4316
|
+
const git = await api2.getGitApi();
|
|
4317
|
+
const comment = {
|
|
4318
|
+
comments: [
|
|
4319
|
+
{
|
|
4320
|
+
parentCommentId: 0,
|
|
4321
|
+
// Root comment
|
|
4322
|
+
content: markdownComment,
|
|
4323
|
+
commentType: 1
|
|
4324
|
+
// Default type
|
|
4325
|
+
}
|
|
4326
|
+
]
|
|
4327
|
+
};
|
|
4328
|
+
await git.createThread(comment, repo, prNumber, projectName);
|
|
4329
|
+
},
|
|
4306
4330
|
async getAdoIsRemoteBranch({
|
|
4307
4331
|
repoUrl,
|
|
4308
4332
|
branch
|
|
@@ -4618,7 +4642,8 @@ var CommitToSameBranchParamsZ = BaseSubmitToScmMessageZ.merge(
|
|
|
4618
4642
|
branch: z19.string(),
|
|
4619
4643
|
commitMessages: z19.array(z19.string()),
|
|
4620
4644
|
commitDescriptions: z19.array(z19.string().nullish()),
|
|
4621
|
-
githubCommentId: z19.number().nullish()
|
|
4645
|
+
githubCommentId: z19.number().nullish(),
|
|
4646
|
+
prId: z19.number().nullish()
|
|
4622
4647
|
})
|
|
4623
4648
|
);
|
|
4624
4649
|
var SubmitFixesToDifferentBranchParamsZ = z19.object({
|
|
@@ -4677,7 +4702,8 @@ var GitCommitZ = z19.object({
|
|
|
4677
4702
|
var SubmitFixesToSameBranchResponseMessageZ = z19.object({
|
|
4678
4703
|
type: z19.literal(submitToScmMessageType.commitToSameBranch),
|
|
4679
4704
|
githubCommentId: z19.number().nullish(),
|
|
4680
|
-
commits: z19.array(GitCommitZ)
|
|
4705
|
+
commits: z19.array(GitCommitZ),
|
|
4706
|
+
prId: z19.number().nullish()
|
|
4681
4707
|
}).merge(SubmitFixesBaseResponseMessageZ);
|
|
4682
4708
|
var SubmitFixesToDifferentBranchResponseMessageZ = z19.object({
|
|
4683
4709
|
type: z19.literal(submitToScmMessageType.submitFixesForDifferentBranch),
|
|
@@ -4932,16 +4958,16 @@ var AdoSCMLib = class extends SCMLib {
|
|
|
4932
4958
|
repoUrl: this.url
|
|
4933
4959
|
});
|
|
4934
4960
|
}
|
|
4935
|
-
async
|
|
4961
|
+
async getSubmitRequestUrl(submitRequestIdNumber) {
|
|
4936
4962
|
this._validateUrl();
|
|
4937
4963
|
const adoSdk = await this.getAdoSdk();
|
|
4938
4964
|
return adoSdk.getAdoPrUrl({
|
|
4939
4965
|
url: this.url,
|
|
4940
|
-
prNumber
|
|
4966
|
+
prNumber: submitRequestIdNumber
|
|
4941
4967
|
});
|
|
4942
4968
|
}
|
|
4943
|
-
async
|
|
4944
|
-
const match =
|
|
4969
|
+
async getSubmitRequestId(submitRequestUrl) {
|
|
4970
|
+
const match = submitRequestUrl.match(/\/pullrequest\/(\d+)/);
|
|
4945
4971
|
return match?.[1] || "";
|
|
4946
4972
|
}
|
|
4947
4973
|
async getCommitUrl(commitId) {
|
|
@@ -4952,6 +4978,15 @@ var AdoSCMLib = class extends SCMLib {
|
|
|
4952
4978
|
commitId
|
|
4953
4979
|
});
|
|
4954
4980
|
}
|
|
4981
|
+
async addCommentToSubmitRequest(scmSubmitRequestId, comment) {
|
|
4982
|
+
this._validateAccessTokenAndUrl();
|
|
4983
|
+
const adoSdk = await this.getAdoSdk();
|
|
4984
|
+
await adoSdk.addCommentToAdoPullRequest({
|
|
4985
|
+
repoUrl: this.url,
|
|
4986
|
+
prNumber: Number(scmSubmitRequestId),
|
|
4987
|
+
markdownComment: comment
|
|
4988
|
+
});
|
|
4989
|
+
}
|
|
4955
4990
|
};
|
|
4956
4991
|
|
|
4957
4992
|
// src/features/analysis/scm/bitbucket/bitbucket.ts
|
|
@@ -4993,7 +5028,7 @@ function parseBitbucketOrganizationAndRepo(bitbucketUrl) {
|
|
|
4993
5028
|
const validatedBitbucketResult = BitbucketParseResultZ.parse(parsingResult);
|
|
4994
5029
|
return {
|
|
4995
5030
|
workspace: validatedBitbucketResult.organization,
|
|
4996
|
-
|
|
5031
|
+
repo_slug: validatedBitbucketResult.repoName
|
|
4997
5032
|
};
|
|
4998
5033
|
}
|
|
4999
5034
|
function getBitbucketIntance(params) {
|
|
@@ -5033,11 +5068,11 @@ function getBitbucketSdk(params) {
|
|
|
5033
5068
|
}));
|
|
5034
5069
|
},
|
|
5035
5070
|
async getBranchList(params2) {
|
|
5036
|
-
const { workspace,
|
|
5071
|
+
const { workspace, repo_slug } = parseBitbucketOrganizationAndRepo(
|
|
5037
5072
|
params2.repoUrl
|
|
5038
5073
|
);
|
|
5039
5074
|
const res = await bitbucketClient.refs.listBranches({
|
|
5040
|
-
repo_slug
|
|
5075
|
+
repo_slug,
|
|
5041
5076
|
workspace,
|
|
5042
5077
|
pagelen: 100,
|
|
5043
5078
|
//It seems to not work with very large numbers like 1000 (MAX_BRANCHES_FETCH) and returns a bad request response
|
|
@@ -5050,8 +5085,8 @@ function getBitbucketSdk(params) {
|
|
|
5050
5085
|
},
|
|
5051
5086
|
async getIsUserCollaborator(params2) {
|
|
5052
5087
|
const { repoUrl } = params2;
|
|
5053
|
-
const {
|
|
5054
|
-
const fullRepoName = `${workspace}/${
|
|
5088
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
|
|
5089
|
+
const fullRepoName = `${workspace}/${repo_slug}`;
|
|
5055
5090
|
const res = await bitbucketClient.user.listPermissionsForRepos({
|
|
5056
5091
|
q: `repository.full_name~"${fullRepoName}"`
|
|
5057
5092
|
});
|
|
@@ -5060,11 +5095,11 @@ function getBitbucketSdk(params) {
|
|
|
5060
5095
|
) ?? false;
|
|
5061
5096
|
},
|
|
5062
5097
|
async createPullRequest(params2) {
|
|
5063
|
-
const {
|
|
5098
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5064
5099
|
params2.repoUrl
|
|
5065
5100
|
);
|
|
5066
5101
|
const res = await bitbucketClient.pullrequests.create({
|
|
5067
|
-
repo_slug
|
|
5102
|
+
repo_slug,
|
|
5068
5103
|
workspace,
|
|
5069
5104
|
_body: {
|
|
5070
5105
|
type: "pullrequest",
|
|
@@ -5087,43 +5122,43 @@ function getBitbucketSdk(params) {
|
|
|
5087
5122
|
return res.data;
|
|
5088
5123
|
},
|
|
5089
5124
|
async getDownloadlink(params2) {
|
|
5090
|
-
const {
|
|
5125
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5091
5126
|
params2.repoUrl
|
|
5092
5127
|
);
|
|
5093
5128
|
const res = await bitbucketClient.downloads.list({
|
|
5094
|
-
repo_slug
|
|
5129
|
+
repo_slug,
|
|
5095
5130
|
workspace
|
|
5096
5131
|
});
|
|
5097
5132
|
return res.data;
|
|
5098
5133
|
},
|
|
5099
5134
|
async getBranch(params2) {
|
|
5100
|
-
const {
|
|
5135
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5101
5136
|
params2.repoUrl
|
|
5102
5137
|
);
|
|
5103
5138
|
const res = await bitbucketClient.refs.getBranch({
|
|
5104
5139
|
name: params2.branchName,
|
|
5105
|
-
repo_slug
|
|
5140
|
+
repo_slug,
|
|
5106
5141
|
workspace
|
|
5107
5142
|
});
|
|
5108
5143
|
return res.data;
|
|
5109
5144
|
},
|
|
5110
5145
|
async getRepo(params2) {
|
|
5111
|
-
const {
|
|
5146
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5112
5147
|
params2.repoUrl
|
|
5113
5148
|
);
|
|
5114
5149
|
const res = await bitbucketClient.repositories.get({
|
|
5115
|
-
repo_slug
|
|
5150
|
+
repo_slug,
|
|
5116
5151
|
workspace
|
|
5117
5152
|
});
|
|
5118
5153
|
return res.data;
|
|
5119
5154
|
},
|
|
5120
5155
|
async getCommit(params2) {
|
|
5121
|
-
const {
|
|
5156
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5122
5157
|
params2.repoUrl
|
|
5123
5158
|
);
|
|
5124
5159
|
const res = await bitbucketClient.commits.get({
|
|
5125
5160
|
commit: params2.commitSha,
|
|
5126
|
-
repo_slug
|
|
5161
|
+
repo_slug,
|
|
5127
5162
|
workspace
|
|
5128
5163
|
});
|
|
5129
5164
|
return res.data;
|
|
@@ -5152,9 +5187,9 @@ function getBitbucketSdk(params) {
|
|
|
5152
5187
|
},
|
|
5153
5188
|
async getTagRef(params2) {
|
|
5154
5189
|
const { tagName, repoUrl } = params2;
|
|
5155
|
-
const {
|
|
5190
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(repoUrl);
|
|
5156
5191
|
const tagRes = await bitbucketClient.refs.getTag({
|
|
5157
|
-
repo_slug
|
|
5192
|
+
repo_slug,
|
|
5158
5193
|
workspace,
|
|
5159
5194
|
name: tagName
|
|
5160
5195
|
});
|
|
@@ -5187,12 +5222,31 @@ function getBitbucketSdk(params) {
|
|
|
5187
5222
|
return `${parsedRepoUrl}/get/${sha}.zip`;
|
|
5188
5223
|
},
|
|
5189
5224
|
async getPullRequest(params2) {
|
|
5190
|
-
const {
|
|
5225
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(
|
|
5191
5226
|
params2.url
|
|
5192
5227
|
);
|
|
5193
5228
|
const res = await bitbucketClient.pullrequests.get({
|
|
5194
5229
|
pull_request_id: params2.prNumber,
|
|
5195
|
-
repo_slug
|
|
5230
|
+
repo_slug,
|
|
5231
|
+
workspace
|
|
5232
|
+
});
|
|
5233
|
+
return res.data;
|
|
5234
|
+
},
|
|
5235
|
+
async addCommentToPullRequest({
|
|
5236
|
+
url,
|
|
5237
|
+
prNumber,
|
|
5238
|
+
markdownComment
|
|
5239
|
+
}) {
|
|
5240
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(url);
|
|
5241
|
+
const res = await bitbucketClient.pullrequests.createComment({
|
|
5242
|
+
//@ts-expect-error tyep requires _body.type, but it its uses api fails
|
|
5243
|
+
_body: {
|
|
5244
|
+
content: {
|
|
5245
|
+
raw: markdownComment
|
|
5246
|
+
}
|
|
5247
|
+
},
|
|
5248
|
+
pull_request_id: prNumber,
|
|
5249
|
+
repo_slug,
|
|
5196
5250
|
workspace
|
|
5197
5251
|
});
|
|
5198
5252
|
return res.data;
|
|
@@ -5462,24 +5516,32 @@ var BitbucketSCMLib = class extends SCMLib {
|
|
|
5462
5516
|
const repoRes = await this.bitbucketSdk.getRepo({ repoUrl: this.url });
|
|
5463
5517
|
return z23.string().parse(repoRes.mainbranch?.name);
|
|
5464
5518
|
}
|
|
5465
|
-
|
|
5519
|
+
getSubmitRequestUrl(submitRequestId) {
|
|
5466
5520
|
this._validateUrl();
|
|
5467
|
-
const {
|
|
5521
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
|
|
5468
5522
|
return Promise.resolve(
|
|
5469
|
-
`https://bitbucket.org/${workspace}/${
|
|
5523
|
+
`https://bitbucket.org/${workspace}/${repo_slug}/pull-requests/${submitRequestId}`
|
|
5470
5524
|
);
|
|
5471
5525
|
}
|
|
5472
|
-
async
|
|
5473
|
-
const match =
|
|
5526
|
+
async getSubmitRequestId(submitRequestUrl) {
|
|
5527
|
+
const match = submitRequestUrl.match(/\/pull-requests\/(\d+)/);
|
|
5474
5528
|
return match?.[1] || "";
|
|
5475
5529
|
}
|
|
5476
5530
|
getCommitUrl(commitId) {
|
|
5477
5531
|
this._validateUrl();
|
|
5478
|
-
const {
|
|
5532
|
+
const { repo_slug, workspace } = parseBitbucketOrganizationAndRepo(this.url);
|
|
5479
5533
|
return Promise.resolve(
|
|
5480
|
-
`https://bitbucket.org/${workspace}/${
|
|
5534
|
+
`https://bitbucket.org/${workspace}/${repo_slug}/commits/${commitId}`
|
|
5481
5535
|
);
|
|
5482
5536
|
}
|
|
5537
|
+
async addCommentToSubmitRequest(submitRequestId, comment) {
|
|
5538
|
+
this._validateUrl();
|
|
5539
|
+
await this.bitbucketSdk.addCommentToPullRequest({
|
|
5540
|
+
prNumber: Number(submitRequestId),
|
|
5541
|
+
url: this.url,
|
|
5542
|
+
markdownComment: comment
|
|
5543
|
+
});
|
|
5544
|
+
}
|
|
5483
5545
|
};
|
|
5484
5546
|
|
|
5485
5547
|
// src/features/analysis/scm/github/GithubSCMLib.ts
|
|
@@ -5640,6 +5702,14 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
5640
5702
|
prNumber: Number(scmSubmitRequestId)
|
|
5641
5703
|
});
|
|
5642
5704
|
}
|
|
5705
|
+
async addCommentToSubmitRequest(submitRequestId, comment) {
|
|
5706
|
+
this._validateAccessTokenAndUrl();
|
|
5707
|
+
await this.githubSdk.createMarkdownCommentOnPullRequest({
|
|
5708
|
+
repoUrl: this.url,
|
|
5709
|
+
prNumber: Number(submitRequestId),
|
|
5710
|
+
markdownComment: comment
|
|
5711
|
+
});
|
|
5712
|
+
}
|
|
5643
5713
|
async getRepoBlameRanges(ref, path9) {
|
|
5644
5714
|
this._validateUrl();
|
|
5645
5715
|
return await this.githubSdk.getGithubBlameRanges({
|
|
@@ -5665,18 +5735,18 @@ var GithubSCMLib = class extends SCMLib {
|
|
|
5665
5735
|
this._validateUrl();
|
|
5666
5736
|
return await this.githubSdk.getGithubRepoDefaultBranch(this.url);
|
|
5667
5737
|
}
|
|
5668
|
-
async
|
|
5738
|
+
async getSubmitRequestUrl(submitRequestUrl) {
|
|
5669
5739
|
this._validateAccessTokenAndUrl();
|
|
5670
5740
|
const { owner, repo } = parseGithubOwnerAndRepo(this.url);
|
|
5671
5741
|
const getPrRes = await this.githubSdk.getPr({
|
|
5672
5742
|
owner,
|
|
5673
5743
|
repo,
|
|
5674
|
-
pull_number:
|
|
5744
|
+
pull_number: submitRequestUrl
|
|
5675
5745
|
});
|
|
5676
5746
|
return getPrRes.data.html_url;
|
|
5677
5747
|
}
|
|
5678
|
-
async
|
|
5679
|
-
const match =
|
|
5748
|
+
async getSubmitRequestId(submitRequestUrl) {
|
|
5749
|
+
const match = submitRequestUrl.match(/\/pull\/(\d+)/);
|
|
5680
5750
|
return match?.[1] || "";
|
|
5681
5751
|
}
|
|
5682
5752
|
async getCommitUrl(commitId) {
|
|
@@ -5853,6 +5923,16 @@ async function getGitlabMergeRequestStatus({
|
|
|
5853
5923
|
throw new Error(`unknown merge request state ${res.state}`);
|
|
5854
5924
|
}
|
|
5855
5925
|
}
|
|
5926
|
+
async function createMarkdownCommentOnPullRequest({
|
|
5927
|
+
markdownComment,
|
|
5928
|
+
accessToken,
|
|
5929
|
+
repoUrl,
|
|
5930
|
+
mrNumber
|
|
5931
|
+
}) {
|
|
5932
|
+
const { projectPath } = parseGitlabOwnerAndRepo(repoUrl);
|
|
5933
|
+
const api2 = getGitBeaker({ url: repoUrl, gitlabAuthToken: accessToken });
|
|
5934
|
+
return api2.MergeRequestNotes.create(projectPath, mrNumber, markdownComment);
|
|
5935
|
+
}
|
|
5856
5936
|
async function getGitlabIsRemoteBranch({
|
|
5857
5937
|
accessToken,
|
|
5858
5938
|
repoUrl,
|
|
@@ -6203,6 +6283,15 @@ var GitlabSCMLib = class extends SCMLib {
|
|
|
6203
6283
|
throw new Error(`unknown state ${state}`);
|
|
6204
6284
|
}
|
|
6205
6285
|
}
|
|
6286
|
+
async addCommentToSubmitRequest(submitRequestId, comment) {
|
|
6287
|
+
this._validateAccessTokenAndUrl();
|
|
6288
|
+
await createMarkdownCommentOnPullRequest({
|
|
6289
|
+
accessToken: this.accessToken,
|
|
6290
|
+
repoUrl: this.url,
|
|
6291
|
+
mrNumber: Number(submitRequestId),
|
|
6292
|
+
markdownComment: comment
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
6206
6295
|
async getRepoBlameRanges(ref, path9) {
|
|
6207
6296
|
this._validateUrl();
|
|
6208
6297
|
return await getGitlabBlameRanges(
|
|
@@ -6230,17 +6319,17 @@ var GitlabSCMLib = class extends SCMLib {
|
|
|
6230
6319
|
gitlabAuthToken: this.accessToken
|
|
6231
6320
|
});
|
|
6232
6321
|
}
|
|
6233
|
-
async
|
|
6322
|
+
async getSubmitRequestUrl(submitRequestUrl) {
|
|
6234
6323
|
this._validateAccessTokenAndUrl();
|
|
6235
6324
|
const res = await getGitlabMergeRequest({
|
|
6236
6325
|
url: this.url,
|
|
6237
|
-
prNumber,
|
|
6326
|
+
prNumber: submitRequestUrl,
|
|
6238
6327
|
accessToken: this.accessToken
|
|
6239
6328
|
});
|
|
6240
6329
|
return res.web_url;
|
|
6241
6330
|
}
|
|
6242
|
-
async
|
|
6243
|
-
const match =
|
|
6331
|
+
async getSubmitRequestId(submitRequestUrl) {
|
|
6332
|
+
const match = submitRequestUrl.match(/\/merge_requests\/(\d+)/);
|
|
6244
6333
|
return match?.[1] || "";
|
|
6245
6334
|
}
|
|
6246
6335
|
async getCommitUrl(commitId) {
|
|
@@ -6325,12 +6414,12 @@ var StubSCMLib = class extends SCMLib {
|
|
|
6325
6414
|
console.warn("getRepoDefaultBranch() returning empty string");
|
|
6326
6415
|
return "";
|
|
6327
6416
|
}
|
|
6328
|
-
async
|
|
6329
|
-
console.warn("
|
|
6417
|
+
async getSubmitRequestUrl(_submitRequestIdNumber) {
|
|
6418
|
+
console.warn("getSubmitRequestUrl() returning empty string");
|
|
6330
6419
|
return "";
|
|
6331
6420
|
}
|
|
6332
|
-
async
|
|
6333
|
-
console.warn("
|
|
6421
|
+
async getSubmitRequestId(_submitRequestUrl) {
|
|
6422
|
+
console.warn("getSubmitRequestId() returning empty string");
|
|
6334
6423
|
return "";
|
|
6335
6424
|
}
|
|
6336
6425
|
async getCommitUrl(_commitId) {
|
|
@@ -6341,6 +6430,9 @@ var StubSCMLib = class extends SCMLib {
|
|
|
6341
6430
|
console.warn("_getUsernameForAuthUrl() returning empty string");
|
|
6342
6431
|
return "";
|
|
6343
6432
|
}
|
|
6433
|
+
async addCommentToSubmitRequest(_submitRequestId, _comment) {
|
|
6434
|
+
console.warn("addCommentToSubmitRequest() no-op");
|
|
6435
|
+
}
|
|
6344
6436
|
};
|
|
6345
6437
|
|
|
6346
6438
|
// src/features/analysis/scm/scmFactory.ts
|
|
@@ -6566,6 +6658,16 @@ function getGithubSdk(params = {}) {
|
|
|
6566
6658
|
}
|
|
6567
6659
|
return res.data.state;
|
|
6568
6660
|
},
|
|
6661
|
+
async createMarkdownCommentOnPullRequest(params2) {
|
|
6662
|
+
const { repoUrl, prNumber, markdownComment } = params2;
|
|
6663
|
+
const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
|
|
6664
|
+
return octokit.rest.issues.createComment({
|
|
6665
|
+
owner,
|
|
6666
|
+
repo,
|
|
6667
|
+
issue_number: prNumber,
|
|
6668
|
+
body: markdownComment
|
|
6669
|
+
});
|
|
6670
|
+
},
|
|
6569
6671
|
async getGithubIsRemoteBranch(params2) {
|
|
6570
6672
|
const { repoUrl, branch } = params2;
|
|
6571
6673
|
const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
|
|
@@ -7302,7 +7404,7 @@ async function addFixCommentsForPr({
|
|
|
7302
7404
|
import Debug9 from "debug";
|
|
7303
7405
|
var debug9 = Debug9("mobbdev:handleAutoPr");
|
|
7304
7406
|
async function handleAutoPr(params) {
|
|
7305
|
-
const { gqlClient, analysisId, commitDirectly, createSpinner: createSpinner5 } = params;
|
|
7407
|
+
const { gqlClient, analysisId, commitDirectly, prId, createSpinner: createSpinner5 } = params;
|
|
7306
7408
|
const createAutoPrSpinner = createSpinner5(
|
|
7307
7409
|
"\u{1F504} Waiting for the analysis to finish before initiating automatic pull request creation"
|
|
7308
7410
|
).start();
|
|
@@ -7313,7 +7415,8 @@ async function handleAutoPr(params) {
|
|
|
7313
7415
|
callback: async (analysisId2) => {
|
|
7314
7416
|
const autoPrAnalysisRes = await gqlClient.autoPrAnalysis(
|
|
7315
7417
|
analysisId2,
|
|
7316
|
-
commitDirectly
|
|
7418
|
+
commitDirectly,
|
|
7419
|
+
prId
|
|
7317
7420
|
);
|
|
7318
7421
|
debug9("auto pr analysis res %o", autoPrAnalysisRes);
|
|
7319
7422
|
if (autoPrAnalysisRes.autoPrAnalysis?.__typename === "AutoPrError") {
|
|
@@ -7771,10 +7874,11 @@ var GQLClient = class {
|
|
|
7771
7874
|
}
|
|
7772
7875
|
return res.analysis;
|
|
7773
7876
|
}
|
|
7774
|
-
async autoPrAnalysis(analysisId, commitDirectly) {
|
|
7877
|
+
async autoPrAnalysis(analysisId, commitDirectly, prId) {
|
|
7775
7878
|
return this._clientSdk.autoPrAnalysis({
|
|
7776
7879
|
analysisId,
|
|
7777
|
-
commitDirectly
|
|
7880
|
+
commitDirectly,
|
|
7881
|
+
prId
|
|
7778
7882
|
});
|
|
7779
7883
|
}
|
|
7780
7884
|
async getFixes(fixIds) {
|
|
@@ -8445,7 +8549,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8445
8549
|
command,
|
|
8446
8550
|
organizationId: userOrganizationId,
|
|
8447
8551
|
autoPr,
|
|
8448
|
-
commitDirectly
|
|
8552
|
+
commitDirectly,
|
|
8553
|
+
pullRequest
|
|
8449
8554
|
} = params;
|
|
8450
8555
|
debug16("start %s %s", dirname, repo);
|
|
8451
8556
|
const { createSpinner: createSpinner5 } = Spinner2({ ci });
|
|
@@ -8585,6 +8690,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8585
8690
|
gqlClient,
|
|
8586
8691
|
analysisId: reportUploadInfo.fixReportId,
|
|
8587
8692
|
commitDirectly,
|
|
8693
|
+
prId: pullRequest,
|
|
8588
8694
|
createSpinner: createSpinner5
|
|
8589
8695
|
});
|
|
8590
8696
|
}
|
|
@@ -8758,6 +8864,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
|
|
|
8758
8864
|
gqlClient,
|
|
8759
8865
|
analysisId: reportUploadInfo.fixReportId,
|
|
8760
8866
|
commitDirectly,
|
|
8867
|
+
prId: pullRequest,
|
|
8761
8868
|
createSpinner: createSpinner5
|
|
8762
8869
|
});
|
|
8763
8870
|
}
|
|
@@ -8864,7 +8971,8 @@ async function analyze({
|
|
|
8864
8971
|
mobbProjectName,
|
|
8865
8972
|
organizationId,
|
|
8866
8973
|
autoPr,
|
|
8867
|
-
commitDirectly
|
|
8974
|
+
commitDirectly,
|
|
8975
|
+
pullRequest
|
|
8868
8976
|
}, { skipPrompts = false } = {}) {
|
|
8869
8977
|
!ci && await showWelcomeMessage(skipPrompts);
|
|
8870
8978
|
await runAnalysis(
|
|
@@ -8880,7 +8988,8 @@ async function analyze({
|
|
|
8880
8988
|
organizationId,
|
|
8881
8989
|
command: "analyze",
|
|
8882
8990
|
autoPr,
|
|
8883
|
-
commitDirectly
|
|
8991
|
+
commitDirectly,
|
|
8992
|
+
pullRequest
|
|
8884
8993
|
},
|
|
8885
8994
|
{ skipPrompts }
|
|
8886
8995
|
);
|
|
@@ -9198,7 +9307,12 @@ function analyzeBuilder(yargs2) {
|
|
|
9198
9307
|
alias: "commit-hash",
|
|
9199
9308
|
describe: chalk8.bold("Hash of the commit"),
|
|
9200
9309
|
type: "string"
|
|
9201
|
-
}).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("org", organizationIdOptions).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).option("auto-pr", autoPrOption).option("commit-directly", commitDirectlyOption).
|
|
9310
|
+
}).option("mobb-project-name", mobbProjectNameOption).option("y", yesOption).option("ci", ciOption).option("org", organizationIdOptions).option("api-key", apiKeyOption).option("commit-hash", commitHashOption).option("auto-pr", autoPrOption).option("commit-directly", commitDirectlyOption).option("pull-request", {
|
|
9311
|
+
alias: ["pr", "pr-number", "pr-id"],
|
|
9312
|
+
describe: chalk8.bold("Number of the pull request"),
|
|
9313
|
+
type: "number",
|
|
9314
|
+
demandOption: false
|
|
9315
|
+
}).example(
|
|
9202
9316
|
"npx mobbdev@latest analyze -r https://github.com/WebGoat/WebGoat -f <your_vulnerability_report_path>",
|
|
9203
9317
|
"analyze an existing repository"
|
|
9204
9318
|
).help();
|
|
@@ -9223,6 +9337,11 @@ Can't access ${chalk8.bold(argv.f)}`);
|
|
|
9223
9337
|
"--commit-directly flag requires --auto-pr to be provided as well"
|
|
9224
9338
|
);
|
|
9225
9339
|
}
|
|
9340
|
+
if (argv.pullRequest && !argv["commit-directly"]) {
|
|
9341
|
+
throw new CliError(
|
|
9342
|
+
"--pull-request flag requires --commit-directly to be provided as well"
|
|
9343
|
+
);
|
|
9344
|
+
}
|
|
9226
9345
|
validateReportFileFormat(argv.f);
|
|
9227
9346
|
}
|
|
9228
9347
|
async function analyzeHandler(args) {
|
|
@@ -9251,7 +9370,7 @@ function reviewBuilder(yargs2) {
|
|
|
9251
9370
|
type: "string",
|
|
9252
9371
|
demandOption: true
|
|
9253
9372
|
}).option("pull-request", {
|
|
9254
|
-
alias: "pr",
|
|
9373
|
+
alias: ["pr", "pr-number", "pr-id"],
|
|
9255
9374
|
describe: chalk9.bold("Number of the pull request"),
|
|
9256
9375
|
type: "number",
|
|
9257
9376
|
demandOption: true
|