ira-review 3.0.0 → 3.0.1
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/cli.js +47 -1
- package/dist/index.cjs +47 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +47 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1006,12 +1006,15 @@ var CommentTracker = class {
|
|
|
1006
1006
|
provider;
|
|
1007
1007
|
baseUrl;
|
|
1008
1008
|
headers;
|
|
1009
|
-
// Bitbucket
|
|
1009
|
+
// Bitbucket Cloud
|
|
1010
1010
|
workspace;
|
|
1011
1011
|
repoSlug;
|
|
1012
1012
|
// GitHub
|
|
1013
1013
|
owner;
|
|
1014
1014
|
repo;
|
|
1015
|
+
// Bitbucket Server
|
|
1016
|
+
project;
|
|
1017
|
+
bbServerRepoSlug;
|
|
1015
1018
|
constructor(config, provider = "bitbucket") {
|
|
1016
1019
|
this.provider = provider;
|
|
1017
1020
|
if (provider === "github") {
|
|
@@ -1024,6 +1027,15 @@ var CommentTracker = class {
|
|
|
1024
1027
|
Accept: "application/vnd.github.v3+json",
|
|
1025
1028
|
"Content-Type": "application/json"
|
|
1026
1029
|
};
|
|
1030
|
+
} else if (provider === "bitbucket-server") {
|
|
1031
|
+
const bbs = config;
|
|
1032
|
+
this.baseUrl = bbs.baseUrl.replace(/\/+$/, "");
|
|
1033
|
+
this.project = bbs.project;
|
|
1034
|
+
this.bbServerRepoSlug = bbs.repoSlug;
|
|
1035
|
+
this.headers = {
|
|
1036
|
+
Authorization: `Bearer ${bbs.token}`,
|
|
1037
|
+
"Content-Type": "application/json"
|
|
1038
|
+
};
|
|
1027
1039
|
} else {
|
|
1028
1040
|
const bb = config;
|
|
1029
1041
|
this.baseUrl = (bb.baseUrl ?? "https://api.bitbucket.org/2.0").replace(/\/+$/, "");
|
|
@@ -1039,6 +1051,9 @@ var CommentTracker = class {
|
|
|
1039
1051
|
if (this.provider === "github") {
|
|
1040
1052
|
return this.getGitHubIraComments(pullRequestId);
|
|
1041
1053
|
}
|
|
1054
|
+
if (this.provider === "bitbucket-server") {
|
|
1055
|
+
return this.getBitbucketServerIraComments(pullRequestId);
|
|
1056
|
+
}
|
|
1042
1057
|
return this.getBitbucketIraComments(pullRequestId);
|
|
1043
1058
|
}
|
|
1044
1059
|
async getBitbucketIraComments(pullRequestId) {
|
|
@@ -1098,6 +1113,37 @@ var CommentTracker = class {
|
|
|
1098
1113
|
}
|
|
1099
1114
|
return keys;
|
|
1100
1115
|
}
|
|
1116
|
+
async getBitbucketServerIraComments(pullRequestId) {
|
|
1117
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1118
|
+
let start = 0;
|
|
1119
|
+
while (true) {
|
|
1120
|
+
const url = `${this.baseUrl}/rest/api/1.0/projects/${this.project}/repos/${this.bbServerRepoSlug}/pull-requests/${pullRequestId}/comments?start=${start}&limit=100`;
|
|
1121
|
+
const data = await this.fetchBitbucketServerPage(url);
|
|
1122
|
+
for (const comment of data.values) {
|
|
1123
|
+
if (!comment.text.includes(IRA_MARKER)) continue;
|
|
1124
|
+
const meta = comment.text.match(IRA_META_RE);
|
|
1125
|
+
if (meta) {
|
|
1126
|
+
keys.add(`${meta[1]}:${meta[2]}:${meta[3]}`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (data.isLastPage) break;
|
|
1130
|
+
start = data.nextPageStart ?? start + 100;
|
|
1131
|
+
}
|
|
1132
|
+
return keys;
|
|
1133
|
+
}
|
|
1134
|
+
async fetchBitbucketServerPage(url) {
|
|
1135
|
+
return withRetry(async () => {
|
|
1136
|
+
const response = await fetchWithTimeout(url, { headers: this.headers });
|
|
1137
|
+
if (!response.ok) {
|
|
1138
|
+
const body = await response.text();
|
|
1139
|
+
throw new RetryableError(
|
|
1140
|
+
parseApiError(response.status, body, "Bitbucket Server"),
|
|
1141
|
+
response.status
|
|
1142
|
+
);
|
|
1143
|
+
}
|
|
1144
|
+
return await response.json();
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1101
1147
|
async fetchBitbucketPage(url) {
|
|
1102
1148
|
return withRetry(async () => {
|
|
1103
1149
|
const response = await fetchWithTimeout(url, { headers: this.headers });
|
package/dist/index.cjs
CHANGED
|
@@ -1796,12 +1796,15 @@ var CommentTracker = class {
|
|
|
1796
1796
|
provider;
|
|
1797
1797
|
baseUrl;
|
|
1798
1798
|
headers;
|
|
1799
|
-
// Bitbucket
|
|
1799
|
+
// Bitbucket Cloud
|
|
1800
1800
|
workspace;
|
|
1801
1801
|
repoSlug;
|
|
1802
1802
|
// GitHub
|
|
1803
1803
|
owner;
|
|
1804
1804
|
repo;
|
|
1805
|
+
// Bitbucket Server
|
|
1806
|
+
project;
|
|
1807
|
+
bbServerRepoSlug;
|
|
1805
1808
|
constructor(config, provider = "bitbucket") {
|
|
1806
1809
|
this.provider = provider;
|
|
1807
1810
|
if (provider === "github") {
|
|
@@ -1814,6 +1817,15 @@ var CommentTracker = class {
|
|
|
1814
1817
|
Accept: "application/vnd.github.v3+json",
|
|
1815
1818
|
"Content-Type": "application/json"
|
|
1816
1819
|
};
|
|
1820
|
+
} else if (provider === "bitbucket-server") {
|
|
1821
|
+
const bbs = config;
|
|
1822
|
+
this.baseUrl = bbs.baseUrl.replace(/\/+$/, "");
|
|
1823
|
+
this.project = bbs.project;
|
|
1824
|
+
this.bbServerRepoSlug = bbs.repoSlug;
|
|
1825
|
+
this.headers = {
|
|
1826
|
+
Authorization: `Bearer ${bbs.token}`,
|
|
1827
|
+
"Content-Type": "application/json"
|
|
1828
|
+
};
|
|
1817
1829
|
} else {
|
|
1818
1830
|
const bb = config;
|
|
1819
1831
|
this.baseUrl = (bb.baseUrl ?? "https://api.bitbucket.org/2.0").replace(/\/+$/, "");
|
|
@@ -1829,6 +1841,9 @@ var CommentTracker = class {
|
|
|
1829
1841
|
if (this.provider === "github") {
|
|
1830
1842
|
return this.getGitHubIraComments(pullRequestId);
|
|
1831
1843
|
}
|
|
1844
|
+
if (this.provider === "bitbucket-server") {
|
|
1845
|
+
return this.getBitbucketServerIraComments(pullRequestId);
|
|
1846
|
+
}
|
|
1832
1847
|
return this.getBitbucketIraComments(pullRequestId);
|
|
1833
1848
|
}
|
|
1834
1849
|
async getBitbucketIraComments(pullRequestId) {
|
|
@@ -1888,6 +1903,37 @@ var CommentTracker = class {
|
|
|
1888
1903
|
}
|
|
1889
1904
|
return keys;
|
|
1890
1905
|
}
|
|
1906
|
+
async getBitbucketServerIraComments(pullRequestId) {
|
|
1907
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1908
|
+
let start = 0;
|
|
1909
|
+
while (true) {
|
|
1910
|
+
const url = `${this.baseUrl}/rest/api/1.0/projects/${this.project}/repos/${this.bbServerRepoSlug}/pull-requests/${pullRequestId}/comments?start=${start}&limit=100`;
|
|
1911
|
+
const data = await this.fetchBitbucketServerPage(url);
|
|
1912
|
+
for (const comment of data.values) {
|
|
1913
|
+
if (!comment.text.includes(IRA_MARKER)) continue;
|
|
1914
|
+
const meta = comment.text.match(IRA_META_RE);
|
|
1915
|
+
if (meta) {
|
|
1916
|
+
keys.add(`${meta[1]}:${meta[2]}:${meta[3]}`);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
if (data.isLastPage) break;
|
|
1920
|
+
start = data.nextPageStart ?? start + 100;
|
|
1921
|
+
}
|
|
1922
|
+
return keys;
|
|
1923
|
+
}
|
|
1924
|
+
async fetchBitbucketServerPage(url) {
|
|
1925
|
+
return withRetry(async () => {
|
|
1926
|
+
const response = await fetchWithTimeout(url, { headers: this.headers });
|
|
1927
|
+
if (!response.ok) {
|
|
1928
|
+
const body = await response.text();
|
|
1929
|
+
throw new RetryableError(
|
|
1930
|
+
parseApiError(response.status, body, "Bitbucket Server"),
|
|
1931
|
+
response.status
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
return await response.json();
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1891
1937
|
async fetchBitbucketPage(url) {
|
|
1892
1938
|
return withRetry(async () => {
|
|
1893
1939
|
const response = await fetchWithTimeout(url, { headers: this.headers });
|