@backstage/integration 1.10.0-next.0 → 1.11.0-next.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.
- package/CHANGELOG.md +18 -0
- package/config.d.ts +18 -0
- package/dist/ScmIntegrations.esm.js +114 -0
- package/dist/ScmIntegrations.esm.js.map +1 -0
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js +63 -0
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js.map +1 -0
- package/dist/awsCodeCommit/config.esm.js +28 -0
- package/dist/awsCodeCommit/config.esm.js.map +1 -0
- package/dist/awsS3/AwsS3Integration.esm.js +44 -0
- package/dist/awsS3/AwsS3Integration.esm.js.map +1 -0
- package/dist/awsS3/config.esm.js +51 -0
- package/dist/awsS3/config.esm.js.map +1 -0
- package/dist/azure/AzureIntegration.esm.js +69 -0
- package/dist/azure/AzureIntegration.esm.js.map +1 -0
- package/dist/azure/AzureUrl.esm.js +191 -0
- package/dist/azure/AzureUrl.esm.js.map +1 -0
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js +80 -0
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js.map +1 -0
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js +76 -0
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js.map +1 -0
- package/dist/azure/config.esm.js +153 -0
- package/dist/azure/config.esm.js.map +1 -0
- package/dist/azure/core.esm.js +14 -0
- package/dist/azure/core.esm.js.map +1 -0
- package/dist/azure/deprecated.esm.js +25 -0
- package/dist/azure/deprecated.esm.js.map +1 -0
- package/dist/bitbucket/BitbucketIntegration.esm.js +67 -0
- package/dist/bitbucket/BitbucketIntegration.esm.js.map +1 -0
- package/dist/bitbucket/config.esm.js +45 -0
- package/dist/bitbucket/config.esm.js.map +1 -0
- package/dist/bitbucket/core.esm.js +85 -0
- package/dist/bitbucket/core.esm.js.map +1 -0
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js +56 -0
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js.map +1 -0
- package/dist/bitbucketCloud/config.esm.js +28 -0
- package/dist/bitbucketCloud/config.esm.js.map +1 -0
- package/dist/bitbucketCloud/core.esm.js +68 -0
- package/dist/bitbucketCloud/core.esm.js.map +1 -0
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js +54 -0
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js.map +1 -0
- package/dist/bitbucketServer/config.esm.js +34 -0
- package/dist/bitbucketServer/config.esm.js.map +1 -0
- package/dist/bitbucketServer/core.esm.js +63 -0
- package/dist/bitbucketServer/core.esm.js.map +1 -0
- package/dist/gerrit/GerritIntegration.esm.js +58 -0
- package/dist/gerrit/GerritIntegration.esm.js.map +1 -0
- package/dist/gerrit/config.esm.js +58 -0
- package/dist/gerrit/config.esm.js.map +1 -0
- package/dist/gerrit/core.esm.js +106 -0
- package/dist/gerrit/core.esm.js.map +1 -0
- package/dist/gitea/GiteaIntegration.esm.js +40 -0
- package/dist/gitea/GiteaIntegration.esm.js.map +1 -0
- package/dist/gitea/config.esm.js +33 -0
- package/dist/gitea/config.esm.js.map +1 -0
- package/dist/gitea/core.esm.js +53 -0
- package/dist/gitea/core.esm.js.map +1 -0
- package/dist/github/DefaultGithubCredentialsProvider.esm.js +52 -0
- package/dist/github/DefaultGithubCredentialsProvider.esm.js.map +1 -0
- package/dist/github/GithubIntegration.esm.js +56 -0
- package/dist/github/GithubIntegration.esm.js.map +1 -0
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js +222 -0
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js.map +1 -0
- package/dist/github/config.esm.js +53 -0
- package/dist/github/config.esm.js.map +1 -0
- package/dist/github/core.esm.js +38 -0
- package/dist/github/core.esm.js.map +1 -0
- package/dist/github/deprecated.esm.js +26 -0
- package/dist/github/deprecated.esm.js.map +1 -0
- package/dist/gitlab/DefaultGitlabCredentialsProvider.esm.js +28 -0
- package/dist/gitlab/DefaultGitlabCredentialsProvider.esm.js.map +1 -0
- package/dist/gitlab/GitLabIntegration.esm.js +46 -0
- package/dist/gitlab/GitLabIntegration.esm.js.map +1 -0
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js +29 -0
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js.map +1 -0
- package/dist/gitlab/config.esm.js +57 -0
- package/dist/gitlab/config.esm.js.map +1 -0
- package/dist/gitlab/core.esm.js +69 -0
- package/dist/gitlab/core.esm.js.map +1 -0
- package/dist/googleGcs/config.esm.js +14 -0
- package/dist/googleGcs/config.esm.js.map +1 -0
- package/dist/harness/HarnessIntegration.esm.js +40 -0
- package/dist/harness/HarnessIntegration.esm.js.map +1 -0
- package/dist/harness/config.esm.js +20 -0
- package/dist/harness/config.esm.js.map +1 -0
- package/dist/harness/core.esm.js +73 -0
- package/dist/harness/core.esm.js.map +1 -0
- package/dist/helpers.esm.js +62 -0
- package/dist/helpers.esm.js.map +1 -0
- package/dist/index.cjs.js +214 -85
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.esm.js +40 -2323
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,2324 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const { url, base, lineNumber } = options;
|
|
42
|
-
try {
|
|
43
|
-
new URL(url);
|
|
44
|
-
return url;
|
|
45
|
-
} catch {
|
|
46
|
-
}
|
|
47
|
-
let updated;
|
|
48
|
-
if (url.startsWith("/")) {
|
|
49
|
-
const { href, filepath } = parseGitUrl(base);
|
|
50
|
-
updated = new URL(href);
|
|
51
|
-
const repoRootPath = trimEnd(
|
|
52
|
-
updated.pathname.substring(0, updated.pathname.length - filepath.length),
|
|
53
|
-
"/"
|
|
54
|
-
);
|
|
55
|
-
updated.pathname = `${repoRootPath}${url}`;
|
|
56
|
-
} else {
|
|
57
|
-
updated = new URL(url, base);
|
|
58
|
-
}
|
|
59
|
-
updated.search = new URL(base).search;
|
|
60
|
-
if (lineNumber) {
|
|
61
|
-
updated.hash = `L${lineNumber}`;
|
|
62
|
-
}
|
|
63
|
-
return updated.toString();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const AMAZON_AWS_HOST = "amazonaws.com";
|
|
67
|
-
function readAwsS3IntegrationConfig(config) {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
const endpoint = config.getOptionalString("endpoint");
|
|
70
|
-
const s3ForcePathStyle = (_a = config.getOptionalBoolean("s3ForcePathStyle")) != null ? _a : false;
|
|
71
|
-
let host;
|
|
72
|
-
let pathname;
|
|
73
|
-
if (endpoint) {
|
|
74
|
-
try {
|
|
75
|
-
const url = new URL(endpoint);
|
|
76
|
-
host = url.host;
|
|
77
|
-
pathname = url.pathname;
|
|
78
|
-
} catch {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL`
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
if (pathname !== "/") {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
host = AMAZON_AWS_HOST;
|
|
90
|
-
}
|
|
91
|
-
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
92
|
-
const secretAccessKey = (_b = config.getOptionalString("secretAccessKey")) == null ? void 0 : _b.trim();
|
|
93
|
-
const roleArn = config.getOptionalString("roleArn");
|
|
94
|
-
const externalId = config.getOptionalString("externalId");
|
|
95
|
-
return {
|
|
96
|
-
host,
|
|
97
|
-
endpoint,
|
|
98
|
-
s3ForcePathStyle,
|
|
99
|
-
accessKeyId,
|
|
100
|
-
secretAccessKey,
|
|
101
|
-
roleArn,
|
|
102
|
-
externalId
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function readAwsS3IntegrationConfigs(configs) {
|
|
106
|
-
const result = configs.map(readAwsS3IntegrationConfig);
|
|
107
|
-
if (!result.some((c) => c.host === AMAZON_AWS_HOST)) {
|
|
108
|
-
result.push({
|
|
109
|
-
host: AMAZON_AWS_HOST
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
var __defProp$e = Object.defineProperty;
|
|
116
|
-
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
117
|
-
var __publicField$e = (obj, key, value) => {
|
|
118
|
-
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
119
|
-
return value;
|
|
120
|
-
};
|
|
121
|
-
const _AwsS3Integration = class _AwsS3Integration {
|
|
122
|
-
constructor(integrationConfig) {
|
|
123
|
-
this.integrationConfig = integrationConfig;
|
|
124
|
-
}
|
|
125
|
-
get type() {
|
|
126
|
-
return "awsS3";
|
|
127
|
-
}
|
|
128
|
-
get title() {
|
|
129
|
-
return this.integrationConfig.host;
|
|
130
|
-
}
|
|
131
|
-
get config() {
|
|
132
|
-
return this.integrationConfig;
|
|
133
|
-
}
|
|
134
|
-
resolveUrl(options) {
|
|
135
|
-
const resolved = defaultScmResolveUrl(options);
|
|
136
|
-
return resolved;
|
|
137
|
-
}
|
|
138
|
-
resolveEditUrl(url) {
|
|
139
|
-
return url;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
__publicField$e(_AwsS3Integration, "factory", ({ config }) => {
|
|
143
|
-
var _a;
|
|
144
|
-
const configs = readAwsS3IntegrationConfigs(
|
|
145
|
-
(_a = config.getOptionalConfigArray("integrations.awsS3")) != null ? _a : []
|
|
146
|
-
);
|
|
147
|
-
return basicIntegrations(
|
|
148
|
-
configs.map((c) => new _AwsS3Integration(c)),
|
|
149
|
-
(i) => i.config.host
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
let AwsS3Integration = _AwsS3Integration;
|
|
153
|
-
|
|
154
|
-
const AMAZON_AWS_CODECOMMIT_HOST = "console.aws.amazon.com";
|
|
155
|
-
function readAwsCodeCommitIntegrationConfig(config) {
|
|
156
|
-
var _a;
|
|
157
|
-
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
158
|
-
const secretAccessKey = (_a = config.getOptionalString("secretAccessKey")) == null ? void 0 : _a.trim();
|
|
159
|
-
const roleArn = config.getOptionalString("roleArn");
|
|
160
|
-
const externalId = config.getOptionalString("externalId");
|
|
161
|
-
const host = AMAZON_AWS_CODECOMMIT_HOST;
|
|
162
|
-
return {
|
|
163
|
-
host,
|
|
164
|
-
accessKeyId,
|
|
165
|
-
secretAccessKey,
|
|
166
|
-
roleArn,
|
|
167
|
-
externalId
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
function readAwsCodeCommitIntegrationConfigs(configs) {
|
|
171
|
-
const result = configs.map(readAwsCodeCommitIntegrationConfig);
|
|
172
|
-
if (!result.some((c) => c.host === AMAZON_AWS_CODECOMMIT_HOST)) {
|
|
173
|
-
result.push({
|
|
174
|
-
host: AMAZON_AWS_CODECOMMIT_HOST
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var __defProp$d = Object.defineProperty;
|
|
181
|
-
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
182
|
-
var __publicField$d = (obj, key, value) => {
|
|
183
|
-
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
184
|
-
return value;
|
|
185
|
-
};
|
|
186
|
-
const _AwsCodeCommitIntegration = class _AwsCodeCommitIntegration {
|
|
187
|
-
constructor(integrationConfig) {
|
|
188
|
-
this.integrationConfig = integrationConfig;
|
|
189
|
-
}
|
|
190
|
-
get type() {
|
|
191
|
-
return "awsCodeCommit";
|
|
192
|
-
}
|
|
193
|
-
get config() {
|
|
194
|
-
return this.integrationConfig;
|
|
195
|
-
}
|
|
196
|
-
get title() {
|
|
197
|
-
return this.integrationConfig.host;
|
|
198
|
-
}
|
|
199
|
-
resolveUrl(options) {
|
|
200
|
-
const resolved = defaultScmResolveUrl(options);
|
|
201
|
-
return resolved;
|
|
202
|
-
}
|
|
203
|
-
resolveEditUrl(url) {
|
|
204
|
-
const parsedUrl = new URL(url);
|
|
205
|
-
const pathMatch = parsedUrl.pathname.match(
|
|
206
|
-
/^\/codesuite\/codecommit\/repositories\/([^\/]+)\//
|
|
207
|
-
);
|
|
208
|
-
if (!pathMatch) {
|
|
209
|
-
throw new Error(``);
|
|
210
|
-
}
|
|
211
|
-
const [, repositoryName] = pathMatch;
|
|
212
|
-
return replaceCodeCommitUrlType(url, repositoryName, "edit");
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
__publicField$d(_AwsCodeCommitIntegration, "factory", ({
|
|
216
|
-
config
|
|
217
|
-
}) => {
|
|
218
|
-
var _a;
|
|
219
|
-
const configs = readAwsCodeCommitIntegrationConfigs(
|
|
220
|
-
(_a = config.getOptionalConfigArray("integrations.awsCodeCommit")) != null ? _a : []
|
|
221
|
-
);
|
|
222
|
-
return basicIntegrations(
|
|
223
|
-
configs.map((c) => new _AwsCodeCommitIntegration(c)),
|
|
224
|
-
(i) => i.config.host
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
let AwsCodeCommitIntegration = _AwsCodeCommitIntegration;
|
|
228
|
-
function replaceCodeCommitUrlType(url, repositoryName, type) {
|
|
229
|
-
const newString = type === "edit" ? `files/edit` : type;
|
|
230
|
-
return url.replace(
|
|
231
|
-
new RegExp(
|
|
232
|
-
`/codesuite/codecommit/repositories/${repositoryName}/(browse|files/edit)/`
|
|
233
|
-
),
|
|
234
|
-
`/codesuite/codecommit/repositories/${repositoryName}/${newString}/`
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
var __accessCheck = (obj, member, msg) => {
|
|
239
|
-
if (!member.has(obj))
|
|
240
|
-
throw TypeError("Cannot " + msg);
|
|
241
|
-
};
|
|
242
|
-
var __privateGet = (obj, member, getter) => {
|
|
243
|
-
__accessCheck(obj, member, "read from private field");
|
|
244
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
245
|
-
};
|
|
246
|
-
var __privateAdd = (obj, member, value) => {
|
|
247
|
-
if (member.has(obj))
|
|
248
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
249
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
250
|
-
};
|
|
251
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
252
|
-
__accessCheck(obj, member, "write to private field");
|
|
253
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
254
|
-
return value;
|
|
255
|
-
};
|
|
256
|
-
var _origin, _owner, _project, _repo, _path, _ref, _baseUrl;
|
|
257
|
-
const VERSION_PREFIX_GIT_BRANCH = "GB";
|
|
258
|
-
const _AzureUrl = class _AzureUrl {
|
|
259
|
-
constructor(origin, owner, project, repo, path, ref) {
|
|
260
|
-
__privateAdd(this, _origin, void 0);
|
|
261
|
-
__privateAdd(this, _owner, void 0);
|
|
262
|
-
__privateAdd(this, _project, void 0);
|
|
263
|
-
__privateAdd(this, _repo, void 0);
|
|
264
|
-
__privateAdd(this, _path, void 0);
|
|
265
|
-
__privateAdd(this, _ref, void 0);
|
|
266
|
-
__privateAdd(this, _baseUrl, (...parts) => {
|
|
267
|
-
const url = new URL(__privateGet(this, _origin));
|
|
268
|
-
url.pathname = parts.map((part) => encodeURIComponent(part)).join("/");
|
|
269
|
-
return url;
|
|
270
|
-
});
|
|
271
|
-
__privateSet(this, _origin, origin);
|
|
272
|
-
__privateSet(this, _owner, owner);
|
|
273
|
-
__privateSet(this, _project, project);
|
|
274
|
-
__privateSet(this, _repo, repo);
|
|
275
|
-
__privateSet(this, _path, path);
|
|
276
|
-
__privateSet(this, _ref, ref);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Parses an azure URL as copied from the browser address bar.
|
|
280
|
-
*
|
|
281
|
-
* Throws an error if the URL is not a valid azure repo URL.
|
|
282
|
-
*/
|
|
283
|
-
static fromRepoUrl(repoUrl) {
|
|
284
|
-
var _a;
|
|
285
|
-
const url = new URL(repoUrl);
|
|
286
|
-
let owner;
|
|
287
|
-
let project;
|
|
288
|
-
let repo;
|
|
289
|
-
const parts = url.pathname.split("/").map((part) => decodeURIComponent(part));
|
|
290
|
-
if (parts[2] === "_git") {
|
|
291
|
-
owner = parts[1];
|
|
292
|
-
project = repo = parts[3];
|
|
293
|
-
} else if (parts[3] === "_git") {
|
|
294
|
-
owner = parts[1];
|
|
295
|
-
project = parts[2];
|
|
296
|
-
repo = parts[4];
|
|
297
|
-
} else if (parts[4] === "_git") {
|
|
298
|
-
owner = `${parts[1]}/${parts[2]}`;
|
|
299
|
-
project = parts[3];
|
|
300
|
-
repo = parts[5];
|
|
301
|
-
}
|
|
302
|
-
if (!owner || !project || !repo) {
|
|
303
|
-
throw new Error("Azure URL must point to a git repository");
|
|
304
|
-
}
|
|
305
|
-
const path = (_a = url.searchParams.get("path")) != null ? _a : void 0;
|
|
306
|
-
let ref;
|
|
307
|
-
const version = url.searchParams.get("version");
|
|
308
|
-
if (version) {
|
|
309
|
-
const prefix = version.slice(0, 2);
|
|
310
|
-
if (prefix !== "GB") {
|
|
311
|
-
throw new Error("Azure URL version must point to a git branch");
|
|
312
|
-
}
|
|
313
|
-
ref = version.slice(2);
|
|
314
|
-
}
|
|
315
|
-
return new _AzureUrl(url.origin, owner, project, repo, path, ref);
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Returns a repo URL that can be used to navigate to the resource in azure.
|
|
319
|
-
*
|
|
320
|
-
* Throws an error if the URL is not a valid azure repo URL.
|
|
321
|
-
*/
|
|
322
|
-
toRepoUrl() {
|
|
323
|
-
let url;
|
|
324
|
-
if (__privateGet(this, _project) === __privateGet(this, _repo)) {
|
|
325
|
-
url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), "_git", __privateGet(this, _repo));
|
|
326
|
-
} else {
|
|
327
|
-
url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_git", __privateGet(this, _repo));
|
|
328
|
-
}
|
|
329
|
-
if (__privateGet(this, _path)) {
|
|
330
|
-
url.searchParams.set("path", __privateGet(this, _path));
|
|
331
|
-
}
|
|
332
|
-
if (__privateGet(this, _ref)) {
|
|
333
|
-
url.searchParams.set("version", VERSION_PREFIX_GIT_BRANCH + __privateGet(this, _ref));
|
|
334
|
-
}
|
|
335
|
-
return url.toString();
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Returns the file download URL for this azure resource.
|
|
339
|
-
*
|
|
340
|
-
* Throws an error if the URL does not point to a file.
|
|
341
|
-
*/
|
|
342
|
-
toFileUrl() {
|
|
343
|
-
if (!__privateGet(this, _path)) {
|
|
344
|
-
throw new Error(
|
|
345
|
-
"Azure URL must point to a specific path to be able to download a file"
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "items");
|
|
349
|
-
url.searchParams.set("api-version", "6.0");
|
|
350
|
-
url.searchParams.set("path", __privateGet(this, _path));
|
|
351
|
-
if (__privateGet(this, _ref)) {
|
|
352
|
-
url.searchParams.set("version", __privateGet(this, _ref));
|
|
353
|
-
}
|
|
354
|
-
return url.toString();
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Returns the archive download URL for this azure resource.
|
|
358
|
-
*
|
|
359
|
-
* Throws an error if the URL does not point to a repo.
|
|
360
|
-
*/
|
|
361
|
-
toArchiveUrl() {
|
|
362
|
-
const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "items");
|
|
363
|
-
url.searchParams.set("recursionLevel", "full");
|
|
364
|
-
url.searchParams.set("download", "true");
|
|
365
|
-
url.searchParams.set("api-version", "6.0");
|
|
366
|
-
if (__privateGet(this, _path)) {
|
|
367
|
-
url.searchParams.set("scopePath", __privateGet(this, _path));
|
|
368
|
-
}
|
|
369
|
-
if (__privateGet(this, _ref)) {
|
|
370
|
-
url.searchParams.set("version", __privateGet(this, _ref));
|
|
371
|
-
}
|
|
372
|
-
return url.toString();
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Returns the API url for fetching commits from a branch for this azure resource.
|
|
376
|
-
*
|
|
377
|
-
* Throws an error if the URL does not point to a commit.
|
|
378
|
-
*/
|
|
379
|
-
toCommitsUrl() {
|
|
380
|
-
const url = __privateGet(this, _baseUrl).call(this, __privateGet(this, _owner), __privateGet(this, _project), "_apis", "git", "repositories", __privateGet(this, _repo), "commits");
|
|
381
|
-
url.searchParams.set("api-version", "6.0");
|
|
382
|
-
if (__privateGet(this, _ref)) {
|
|
383
|
-
url.searchParams.set("searchCriteria.itemVersion.version", __privateGet(this, _ref));
|
|
384
|
-
}
|
|
385
|
-
return url.toString();
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Returns the name of the owner, a user or an organization.
|
|
389
|
-
*/
|
|
390
|
-
getOwner() {
|
|
391
|
-
return __privateGet(this, _owner);
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Returns the name of the project.
|
|
395
|
-
*/
|
|
396
|
-
getProject() {
|
|
397
|
-
return __privateGet(this, _project);
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Returns the name of the repo.
|
|
401
|
-
*/
|
|
402
|
-
getRepo() {
|
|
403
|
-
return __privateGet(this, _repo);
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Returns the file path within the repo if the URL contains one.
|
|
407
|
-
*/
|
|
408
|
-
getPath() {
|
|
409
|
-
return __privateGet(this, _path);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Returns the git ref in the repo if the URL contains one.
|
|
413
|
-
*/
|
|
414
|
-
getRef() {
|
|
415
|
-
return __privateGet(this, _ref);
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
_origin = new WeakMap();
|
|
419
|
-
_owner = new WeakMap();
|
|
420
|
-
_project = new WeakMap();
|
|
421
|
-
_repo = new WeakMap();
|
|
422
|
-
_path = new WeakMap();
|
|
423
|
-
_ref = new WeakMap();
|
|
424
|
-
_baseUrl = new WeakMap();
|
|
425
|
-
let AzureUrl = _AzureUrl;
|
|
426
|
-
|
|
427
|
-
const AZURE_HOST = "dev.azure.com";
|
|
428
|
-
const AzureDevOpsCredentialFields = [
|
|
429
|
-
"clientId",
|
|
430
|
-
"clientSecret",
|
|
431
|
-
"tenantId",
|
|
432
|
-
"personalAccessToken"
|
|
433
|
-
];
|
|
434
|
-
const AzureDevopsCredentialFieldMap = /* @__PURE__ */ new Map([
|
|
435
|
-
["ClientSecret", ["clientId", "clientSecret", "tenantId"]],
|
|
436
|
-
["ManagedIdentity", ["clientId"]],
|
|
437
|
-
["PersonalAccessToken", ["personalAccessToken"]]
|
|
438
|
-
]);
|
|
439
|
-
function asAzureDevOpsCredential(credential) {
|
|
440
|
-
for (const entry of AzureDevopsCredentialFieldMap.entries()) {
|
|
441
|
-
const [kind, requiredFields] = entry;
|
|
442
|
-
const forbiddenFields = AzureDevOpsCredentialFields.filter(
|
|
443
|
-
(field) => !requiredFields.includes(field)
|
|
444
|
-
);
|
|
445
|
-
if (requiredFields.every((field) => credential[field] !== void 0) && forbiddenFields.every((field) => credential[field] === void 0)) {
|
|
446
|
-
return {
|
|
447
|
-
kind,
|
|
448
|
-
organizations: credential.organizations,
|
|
449
|
-
...requiredFields.reduce((acc, field) => {
|
|
450
|
-
acc[field] = credential[field];
|
|
451
|
-
return acc;
|
|
452
|
-
}, {})
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
throw new Error("is not a valid credential");
|
|
457
|
-
}
|
|
458
|
-
function readAzureIntegrationConfig(config) {
|
|
459
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
460
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : AZURE_HOST;
|
|
461
|
-
let credentialConfigs = (_b = config.getOptionalConfigArray("credentials")) == null ? void 0 : _b.map((credential) => {
|
|
462
|
-
var _a2, _b2;
|
|
463
|
-
const result = {
|
|
464
|
-
organizations: credential.getOptionalStringArray("organizations"),
|
|
465
|
-
personalAccessToken: (_a2 = credential.getOptionalString("personalAccessToken")) == null ? void 0 : _a2.trim(),
|
|
466
|
-
tenantId: credential.getOptionalString("tenantId"),
|
|
467
|
-
clientId: credential.getOptionalString("clientId"),
|
|
468
|
-
clientSecret: (_b2 = credential.getOptionalString("clientSecret")) == null ? void 0 : _b2.trim()
|
|
469
|
-
};
|
|
470
|
-
return result;
|
|
471
|
-
});
|
|
472
|
-
const token = (_c = config.getOptionalString("token")) == null ? void 0 : _c.trim();
|
|
473
|
-
if (config.getOptional("credential") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
474
|
-
throw new Error(
|
|
475
|
-
`Invalid Azure integration config, 'credential' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
|
-
if (config.getOptional("token") !== void 0 && config.getOptional("credentials") !== void 0) {
|
|
479
|
-
throw new Error(
|
|
480
|
-
`Invalid Azure integration config, 'token' and 'credentials' cannot be used together. Use 'credentials' instead.`
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
if (token !== void 0) {
|
|
484
|
-
const mapped = [{ personalAccessToken: token }];
|
|
485
|
-
credentialConfigs = (_d = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _d : mapped;
|
|
486
|
-
}
|
|
487
|
-
if (config.getOptional("credential") !== void 0) {
|
|
488
|
-
const mapped = [
|
|
489
|
-
{
|
|
490
|
-
organizations: config.getOptionalStringArray(
|
|
491
|
-
"credential.organizations"
|
|
492
|
-
),
|
|
493
|
-
token: (_e = config.getOptionalString("credential.token")) == null ? void 0 : _e.trim(),
|
|
494
|
-
tenantId: config.getOptionalString("credential.tenantId"),
|
|
495
|
-
clientId: config.getOptionalString("credential.clientId"),
|
|
496
|
-
clientSecret: (_f = config.getOptionalString("credential.clientSecret")) == null ? void 0 : _f.trim()
|
|
497
|
-
}
|
|
498
|
-
];
|
|
499
|
-
credentialConfigs = (_g = credentialConfigs == null ? void 0 : credentialConfigs.concat(mapped)) != null ? _g : mapped;
|
|
500
|
-
}
|
|
501
|
-
if (!isValidHost(host)) {
|
|
502
|
-
throw new Error(
|
|
503
|
-
`Invalid Azure integration config, '${host}' is not a valid host`
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
let credentials = void 0;
|
|
507
|
-
if (credentialConfigs !== void 0) {
|
|
508
|
-
const errors = credentialConfigs == null ? void 0 : credentialConfigs.reduce((acc, credentialConfig, index) => {
|
|
509
|
-
let error = void 0;
|
|
510
|
-
try {
|
|
511
|
-
asAzureDevOpsCredential(credentialConfig);
|
|
512
|
-
} catch (e) {
|
|
513
|
-
error = e.message;
|
|
514
|
-
}
|
|
515
|
-
if (error !== void 0) {
|
|
516
|
-
acc.push(`credential at position ${index + 1} ${error}`);
|
|
517
|
-
}
|
|
518
|
-
return acc;
|
|
519
|
-
}, Array.of()).concat(
|
|
520
|
-
Object.entries(
|
|
521
|
-
credentialConfigs.filter(
|
|
522
|
-
(credential) => credential.organizations !== void 0 && credential.organizations.length > 0
|
|
523
|
-
).reduce((acc, credential, index) => {
|
|
524
|
-
var _a2;
|
|
525
|
-
(_a2 = credential.organizations) == null ? void 0 : _a2.forEach((organization) => {
|
|
526
|
-
if (!acc[organization]) {
|
|
527
|
-
acc[organization] = [];
|
|
528
|
-
}
|
|
529
|
-
acc[organization].push(index + 1);
|
|
530
|
-
});
|
|
531
|
-
return acc;
|
|
532
|
-
}, {})
|
|
533
|
-
).filter(([_, indexes]) => indexes.length > 1).reduce((acc, [org, indexes]) => {
|
|
534
|
-
acc.push(
|
|
535
|
-
`organization ${org} is specified multiple times in credentials at positions ${indexes.slice(0, indexes.length - 1).join(", ")} and ${indexes[indexes.length - 1]}`
|
|
536
|
-
);
|
|
537
|
-
return acc;
|
|
538
|
-
}, Array.of())
|
|
539
|
-
);
|
|
540
|
-
if ((errors == null ? void 0 : errors.length) > 0) {
|
|
541
|
-
throw new Error(
|
|
542
|
-
`Invalid Azure integration config for ${host}: ${errors.join("; ")}`
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
credentials = credentialConfigs.map(
|
|
546
|
-
(credentialConfig) => asAzureDevOpsCredential(credentialConfig)
|
|
547
|
-
);
|
|
548
|
-
if (credentials.some(
|
|
549
|
-
(credential) => credential.kind !== "PersonalAccessToken"
|
|
550
|
-
) && host !== AZURE_HOST) {
|
|
551
|
-
throw new Error(
|
|
552
|
-
`Invalid Azure integration config for ${host}, only personal access tokens can be used with hosts other than ${AZURE_HOST}`
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
if (credentials.filter(
|
|
556
|
-
(credential) => credential.organizations === void 0 || credential.organizations.length === 0
|
|
557
|
-
).length > 1) {
|
|
558
|
-
throw new Error(
|
|
559
|
-
`Invalid Azure integration config for ${host}, you cannot specify multiple credentials without organizations`
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return {
|
|
564
|
-
host,
|
|
565
|
-
credentials
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
function readAzureIntegrationConfigs(configs) {
|
|
569
|
-
const result = configs.map(readAzureIntegrationConfig);
|
|
570
|
-
if (!result.some((c) => c.host === AZURE_HOST)) {
|
|
571
|
-
result.push({ host: AZURE_HOST });
|
|
572
|
-
}
|
|
573
|
-
return result;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
var __defProp$c = Object.defineProperty;
|
|
577
|
-
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
578
|
-
var __publicField$c = (obj, key, value) => {
|
|
579
|
-
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
580
|
-
return value;
|
|
581
|
-
};
|
|
582
|
-
const _AzureIntegration = class _AzureIntegration {
|
|
583
|
-
constructor(integrationConfig) {
|
|
584
|
-
this.integrationConfig = integrationConfig;
|
|
585
|
-
}
|
|
586
|
-
get type() {
|
|
587
|
-
return "azure";
|
|
588
|
-
}
|
|
589
|
-
get title() {
|
|
590
|
-
return this.integrationConfig.host;
|
|
591
|
-
}
|
|
592
|
-
get config() {
|
|
593
|
-
return this.integrationConfig;
|
|
594
|
-
}
|
|
595
|
-
/*
|
|
596
|
-
* Azure repo URLs on the form with a `path` query param are treated specially.
|
|
597
|
-
*
|
|
598
|
-
* Example base URL: https://dev.azure.com/organization/project/_git/repository?path=%2Fcatalog-info.yaml
|
|
599
|
-
*/
|
|
600
|
-
resolveUrl(options) {
|
|
601
|
-
var _a;
|
|
602
|
-
const { url, base } = options;
|
|
603
|
-
if (isValidUrl(url)) {
|
|
604
|
-
return url;
|
|
605
|
-
}
|
|
606
|
-
try {
|
|
607
|
-
const azureUrl = AzureUrl.fromRepoUrl(base);
|
|
608
|
-
const newUrl = new URL(base);
|
|
609
|
-
const mockBaseUrl = new URL(`https://a.com${(_a = azureUrl.getPath()) != null ? _a : ""}`);
|
|
610
|
-
const updatedPath = new URL(url, mockBaseUrl).pathname;
|
|
611
|
-
newUrl.searchParams.set("path", updatedPath);
|
|
612
|
-
if (options.lineNumber) {
|
|
613
|
-
newUrl.searchParams.set("line", String(options.lineNumber));
|
|
614
|
-
newUrl.searchParams.set("lineEnd", String(options.lineNumber + 1));
|
|
615
|
-
newUrl.searchParams.set("lineStartColumn", "1");
|
|
616
|
-
newUrl.searchParams.set("lineEndColumn", "1");
|
|
617
|
-
}
|
|
618
|
-
return newUrl.toString();
|
|
619
|
-
} catch {
|
|
620
|
-
return new URL(url, base).toString();
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
resolveEditUrl(url) {
|
|
624
|
-
return url;
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
__publicField$c(_AzureIntegration, "factory", ({ config }) => {
|
|
628
|
-
var _a;
|
|
629
|
-
const configs = readAzureIntegrationConfigs(
|
|
630
|
-
(_a = config.getOptionalConfigArray("integrations.azure")) != null ? _a : []
|
|
631
|
-
);
|
|
632
|
-
return basicIntegrations(
|
|
633
|
-
configs.map((c) => new _AzureIntegration(c)),
|
|
634
|
-
(i) => i.config.host
|
|
635
|
-
);
|
|
636
|
-
});
|
|
637
|
-
let AzureIntegration = _AzureIntegration;
|
|
638
|
-
|
|
639
|
-
function getAzureFileFetchUrl(url) {
|
|
640
|
-
return AzureUrl.fromRepoUrl(url).toFileUrl();
|
|
641
|
-
}
|
|
642
|
-
function getAzureDownloadUrl(url) {
|
|
643
|
-
return AzureUrl.fromRepoUrl(url).toArchiveUrl();
|
|
644
|
-
}
|
|
645
|
-
function getAzureCommitsUrl(url) {
|
|
646
|
-
return AzureUrl.fromRepoUrl(url).toCommitsUrl();
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
var __defProp$b = Object.defineProperty;
|
|
650
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
651
|
-
var __publicField$b = (obj, key, value) => {
|
|
652
|
-
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
653
|
-
return value;
|
|
654
|
-
};
|
|
655
|
-
const tenMinutes = 1e3 * 60 * 10;
|
|
656
|
-
class CachedAzureDevOpsCredentialsProvider {
|
|
657
|
-
constructor(credential) {
|
|
658
|
-
this.credential = credential;
|
|
659
|
-
__publicField$b(this, "azureDevOpsScope", "499b84ac-1321-427f-aa17-267ca6975798/.default");
|
|
660
|
-
__publicField$b(this, "cached");
|
|
661
|
-
}
|
|
662
|
-
static fromAzureDevOpsCredential(credential) {
|
|
663
|
-
switch (credential.kind) {
|
|
664
|
-
case "PersonalAccessToken":
|
|
665
|
-
return CachedAzureDevOpsCredentialsProvider.fromPersonalAccessTokenCredential(
|
|
666
|
-
credential
|
|
667
|
-
);
|
|
668
|
-
case "ClientSecret":
|
|
669
|
-
return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(
|
|
670
|
-
new ClientSecretCredential(
|
|
671
|
-
credential.tenantId,
|
|
672
|
-
credential.clientId,
|
|
673
|
-
credential.clientSecret
|
|
674
|
-
)
|
|
675
|
-
);
|
|
676
|
-
case "ManagedIdentity":
|
|
677
|
-
return CachedAzureDevOpsCredentialsProvider.fromTokenCredential(
|
|
678
|
-
new ManagedIdentityCredential(credential.clientId)
|
|
679
|
-
);
|
|
680
|
-
default:
|
|
681
|
-
throw new Error(
|
|
682
|
-
`Credential kind '${credential.kind}' not supported`
|
|
683
|
-
);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
static fromTokenCredential(credential) {
|
|
687
|
-
return new CachedAzureDevOpsCredentialsProvider(credential);
|
|
688
|
-
}
|
|
689
|
-
static fromPersonalAccessTokenCredential(credential) {
|
|
690
|
-
return new CachedAzureDevOpsCredentialsProvider(
|
|
691
|
-
credential.personalAccessToken
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
async getCredentials() {
|
|
695
|
-
if (this.cached === void 0 || this.cached.expiresAt !== void 0 && Date.now() > this.cached.expiresAt) {
|
|
696
|
-
if (typeof this.credential === "string") {
|
|
697
|
-
this.cached = {
|
|
698
|
-
headers: {
|
|
699
|
-
Authorization: `Basic ${btoa(`:${this.credential}`)}`
|
|
700
|
-
},
|
|
701
|
-
type: "pat",
|
|
702
|
-
token: this.credential
|
|
703
|
-
};
|
|
704
|
-
} else {
|
|
705
|
-
const accessToken = await this.credential.getToken(
|
|
706
|
-
this.azureDevOpsScope
|
|
707
|
-
);
|
|
708
|
-
if (!accessToken) {
|
|
709
|
-
throw new Error("Failed to retrieve access token");
|
|
710
|
-
}
|
|
711
|
-
this.cached = {
|
|
712
|
-
expiresAt: accessToken.expiresOnTimestamp - tenMinutes,
|
|
713
|
-
headers: {
|
|
714
|
-
Authorization: `Bearer ${accessToken.token}`
|
|
715
|
-
},
|
|
716
|
-
type: "bearer",
|
|
717
|
-
token: accessToken.token
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
return this.cached;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
class DefaultAzureDevOpsCredentialsProvider {
|
|
726
|
-
constructor(providers) {
|
|
727
|
-
this.providers = providers;
|
|
728
|
-
}
|
|
729
|
-
static fromIntegrations(integrations) {
|
|
730
|
-
const providers = integrations.azure.list().reduce((acc, integration) => {
|
|
731
|
-
var _a;
|
|
732
|
-
(_a = integration.config.credentials) == null ? void 0 : _a.forEach((credential) => {
|
|
733
|
-
var _a2;
|
|
734
|
-
if (credential.organizations === void 0 || credential.organizations.length === 0) {
|
|
735
|
-
if (acc.get(integration.config.host) === void 0) {
|
|
736
|
-
acc.set(
|
|
737
|
-
integration.config.host,
|
|
738
|
-
CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
|
|
739
|
-
credential
|
|
740
|
-
)
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
} else {
|
|
744
|
-
const provider = CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
|
|
745
|
-
credential
|
|
746
|
-
);
|
|
747
|
-
(_a2 = credential.organizations) == null ? void 0 : _a2.forEach((organization) => {
|
|
748
|
-
acc.set(`${integration.config.host}/${organization}`, provider);
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
if (integration.config.host === "dev.azure.com" && acc.get(integration.config.host) === void 0) {
|
|
753
|
-
acc.set(
|
|
754
|
-
integration.config.host,
|
|
755
|
-
CachedAzureDevOpsCredentialsProvider.fromTokenCredential(
|
|
756
|
-
new DefaultAzureCredential()
|
|
757
|
-
)
|
|
758
|
-
);
|
|
759
|
-
}
|
|
760
|
-
return acc;
|
|
761
|
-
}, /* @__PURE__ */ new Map());
|
|
762
|
-
return new DefaultAzureDevOpsCredentialsProvider(providers);
|
|
763
|
-
}
|
|
764
|
-
forAzureDevOpsServerOrganization(url) {
|
|
765
|
-
const parts = url.pathname.split("/").filter((part) => part !== "");
|
|
766
|
-
if (url.host !== "dev.azure.com" && parts.length > 0) {
|
|
767
|
-
if (parts[0] !== "tfs") {
|
|
768
|
-
return this.providers.get(`${url.host}/${parts[0]}`);
|
|
769
|
-
} else if (parts[0] === "tfs" && parts.length > 1) {
|
|
770
|
-
return this.providers.get(`${url.host}/${parts[1]}`);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
return void 0;
|
|
774
|
-
}
|
|
775
|
-
forAzureDevOpsOrganization(url) {
|
|
776
|
-
const parts = url.pathname.split("/").filter((part) => part !== "");
|
|
777
|
-
if (url.host === "dev.azure.com" && parts.length > 0) {
|
|
778
|
-
return this.providers.get(`${url.host}/${parts[0]}`);
|
|
779
|
-
}
|
|
780
|
-
return void 0;
|
|
781
|
-
}
|
|
782
|
-
forHost(url) {
|
|
783
|
-
return this.providers.get(url.host);
|
|
784
|
-
}
|
|
785
|
-
async getCredentials(opts) {
|
|
786
|
-
var _a, _b;
|
|
787
|
-
const url = new URL(opts.url);
|
|
788
|
-
const provider = (_b = (_a = this.forAzureDevOpsOrganization(url)) != null ? _a : this.forAzureDevOpsServerOrganization(url)) != null ? _b : this.forHost(url);
|
|
789
|
-
if (provider === void 0) {
|
|
790
|
-
return void 0;
|
|
791
|
-
}
|
|
792
|
-
return provider.getCredentials(opts);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
async function getAzureRequestOptions(config, additionalHeaders) {
|
|
797
|
-
var _a;
|
|
798
|
-
const headers = additionalHeaders ? { ...additionalHeaders } : {};
|
|
799
|
-
const credentialConfig = (_a = config.credentials) == null ? void 0 : _a.filter(
|
|
800
|
-
(credential) => credential.organizations === void 0 || credential.organizations.length === 0
|
|
801
|
-
)[0];
|
|
802
|
-
if (credentialConfig) {
|
|
803
|
-
const credentialsProvider = CachedAzureDevOpsCredentialsProvider.fromAzureDevOpsCredential(
|
|
804
|
-
credentialConfig
|
|
805
|
-
);
|
|
806
|
-
const credentials = await credentialsProvider.getCredentials();
|
|
807
|
-
return {
|
|
808
|
-
headers: {
|
|
809
|
-
...credentials == null ? void 0 : credentials.headers,
|
|
810
|
-
...headers
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
return { headers };
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
const BITBUCKET_HOST = "bitbucket.org";
|
|
818
|
-
const BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
819
|
-
function readBitbucketIntegrationConfig(config) {
|
|
820
|
-
var _a, _b, _c;
|
|
821
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : BITBUCKET_HOST;
|
|
822
|
-
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
823
|
-
const token = (_b = config.getOptionalString("token")) == null ? void 0 : _b.trim();
|
|
824
|
-
const username = config.getOptionalString("username");
|
|
825
|
-
const appPassword = (_c = config.getOptionalString("appPassword")) == null ? void 0 : _c.trim();
|
|
826
|
-
if (!isValidHost(host)) {
|
|
827
|
-
throw new Error(
|
|
828
|
-
`Invalid Bitbucket integration config, '${host}' is not a valid host`
|
|
829
|
-
);
|
|
830
|
-
}
|
|
831
|
-
if (apiBaseUrl) {
|
|
832
|
-
apiBaseUrl = trimEnd(apiBaseUrl, "/");
|
|
833
|
-
} else if (host === BITBUCKET_HOST) {
|
|
834
|
-
apiBaseUrl = BITBUCKET_API_BASE_URL;
|
|
835
|
-
} else {
|
|
836
|
-
apiBaseUrl = `https://${host}/rest/api/1.0`;
|
|
837
|
-
}
|
|
838
|
-
return {
|
|
839
|
-
host,
|
|
840
|
-
apiBaseUrl,
|
|
841
|
-
token,
|
|
842
|
-
username,
|
|
843
|
-
appPassword
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
function readBitbucketIntegrationConfigs(configs) {
|
|
847
|
-
const result = configs.map(readBitbucketIntegrationConfig);
|
|
848
|
-
if (!result.some((c) => c.host === BITBUCKET_HOST)) {
|
|
849
|
-
result.push({
|
|
850
|
-
host: BITBUCKET_HOST,
|
|
851
|
-
apiBaseUrl: BITBUCKET_API_BASE_URL
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
return result;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
var __defProp$a = Object.defineProperty;
|
|
858
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
859
|
-
var __publicField$a = (obj, key, value) => {
|
|
860
|
-
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
861
|
-
return value;
|
|
862
|
-
};
|
|
863
|
-
const _BitbucketIntegration = class _BitbucketIntegration {
|
|
864
|
-
constructor(integrationConfig) {
|
|
865
|
-
this.integrationConfig = integrationConfig;
|
|
866
|
-
}
|
|
867
|
-
get type() {
|
|
868
|
-
return "bitbucket";
|
|
869
|
-
}
|
|
870
|
-
get title() {
|
|
871
|
-
return this.integrationConfig.host;
|
|
872
|
-
}
|
|
873
|
-
get config() {
|
|
874
|
-
return this.integrationConfig;
|
|
875
|
-
}
|
|
876
|
-
resolveUrl(options) {
|
|
877
|
-
const resolved = defaultScmResolveUrl(options);
|
|
878
|
-
if (!options.lineNumber) {
|
|
879
|
-
return resolved;
|
|
880
|
-
}
|
|
881
|
-
const url = new URL(resolved);
|
|
882
|
-
if (this.integrationConfig.host === "bitbucket.org") {
|
|
883
|
-
url.hash = `lines-${options.lineNumber}`;
|
|
884
|
-
} else {
|
|
885
|
-
url.hash = `${options.lineNumber}`;
|
|
886
|
-
}
|
|
887
|
-
return url.toString();
|
|
888
|
-
}
|
|
889
|
-
resolveEditUrl(url) {
|
|
890
|
-
const urlData = parseGitUrl(url);
|
|
891
|
-
const editUrl = new URL(url);
|
|
892
|
-
editUrl.searchParams.set("mode", "edit");
|
|
893
|
-
editUrl.searchParams.set("spa", "0");
|
|
894
|
-
editUrl.searchParams.set("at", urlData.ref);
|
|
895
|
-
return editUrl.toString();
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
__publicField$a(_BitbucketIntegration, "factory", ({
|
|
899
|
-
config
|
|
900
|
-
}) => {
|
|
901
|
-
var _a, _b, _c;
|
|
902
|
-
const configs = readBitbucketIntegrationConfigs(
|
|
903
|
-
(_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
|
|
904
|
-
// if integrations.bitbucket was not used assume the use was migrated to the new configs
|
|
905
|
-
// and backport for the deprecated integration to be usable for other parts of the system
|
|
906
|
-
// until these got migrated
|
|
907
|
-
...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
|
|
908
|
-
...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
|
|
909
|
-
]
|
|
910
|
-
);
|
|
911
|
-
return basicIntegrations(
|
|
912
|
-
configs.map((c) => new _BitbucketIntegration(c)),
|
|
913
|
-
(i) => i.config.host
|
|
914
|
-
);
|
|
915
|
-
});
|
|
916
|
-
let BitbucketIntegration = _BitbucketIntegration;
|
|
917
|
-
|
|
918
|
-
async function getBitbucketDefaultBranch(url, config) {
|
|
919
|
-
const { name: repoName, owner: project, resource } = parseGitUrl(url);
|
|
920
|
-
const isHosted = resource === "bitbucket.org";
|
|
921
|
-
let branchUrl = isHosted ? `${config.apiBaseUrl}/repositories/${project}/${repoName}` : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
|
|
922
|
-
let response = await fetch(branchUrl, getBitbucketRequestOptions(config));
|
|
923
|
-
if (response.status === 404 && !isHosted) {
|
|
924
|
-
branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
|
|
925
|
-
response = await fetch(branchUrl, getBitbucketRequestOptions(config));
|
|
926
|
-
}
|
|
927
|
-
if (!response.ok) {
|
|
928
|
-
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
929
|
-
throw new Error(message);
|
|
930
|
-
}
|
|
931
|
-
let defaultBranch;
|
|
932
|
-
if (isHosted) {
|
|
933
|
-
const repoInfo = await response.json();
|
|
934
|
-
defaultBranch = repoInfo.mainbranch.name;
|
|
935
|
-
} else {
|
|
936
|
-
const { displayId } = await response.json();
|
|
937
|
-
defaultBranch = displayId;
|
|
938
|
-
}
|
|
939
|
-
if (!defaultBranch) {
|
|
940
|
-
throw new Error(
|
|
941
|
-
`Failed to read default branch from ${branchUrl}. Response ${response.status} ${response.json()}`
|
|
942
|
-
);
|
|
943
|
-
}
|
|
944
|
-
return defaultBranch;
|
|
945
|
-
}
|
|
946
|
-
async function getBitbucketDownloadUrl(url, config) {
|
|
947
|
-
const {
|
|
948
|
-
name: repoName,
|
|
949
|
-
owner: project,
|
|
950
|
-
ref,
|
|
951
|
-
protocol,
|
|
952
|
-
resource,
|
|
953
|
-
filepath
|
|
954
|
-
} = parseGitUrl(url);
|
|
955
|
-
const isHosted = resource === "bitbucket.org";
|
|
956
|
-
let branch = ref;
|
|
957
|
-
if (!branch) {
|
|
958
|
-
branch = await getBitbucketDefaultBranch(url, config);
|
|
959
|
-
}
|
|
960
|
-
const path = filepath ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}` : "";
|
|
961
|
-
const archiveUrl = isHosted ? `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz` : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;
|
|
962
|
-
return archiveUrl;
|
|
963
|
-
}
|
|
964
|
-
function getBitbucketFileFetchUrl(url, config) {
|
|
965
|
-
try {
|
|
966
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
967
|
-
if (!owner || !name || filepathtype !== "browse" && filepathtype !== "raw" && filepathtype !== "src") {
|
|
968
|
-
throw new Error("Invalid Bitbucket URL or file path");
|
|
969
|
-
}
|
|
970
|
-
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
971
|
-
if (config.host === "bitbucket.org") {
|
|
972
|
-
if (!ref) {
|
|
973
|
-
throw new Error("Invalid Bitbucket URL or file path");
|
|
974
|
-
}
|
|
975
|
-
return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;
|
|
976
|
-
}
|
|
977
|
-
return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;
|
|
978
|
-
} catch (e) {
|
|
979
|
-
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
function getBitbucketRequestOptions(config) {
|
|
983
|
-
const headers = {};
|
|
984
|
-
if (config.token) {
|
|
985
|
-
headers.Authorization = `Bearer ${config.token}`;
|
|
986
|
-
} else if (config.username && config.appPassword) {
|
|
987
|
-
const buffer = Buffer.from(
|
|
988
|
-
`${config.username}:${config.appPassword}`,
|
|
989
|
-
"utf8"
|
|
990
|
-
);
|
|
991
|
-
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
992
|
-
}
|
|
993
|
-
return {
|
|
994
|
-
headers
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
const BITBUCKET_CLOUD_HOST = "bitbucket.org";
|
|
999
|
-
const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
1000
|
-
function readBitbucketCloudIntegrationConfig(config) {
|
|
1001
|
-
var _a;
|
|
1002
|
-
const host = BITBUCKET_CLOUD_HOST;
|
|
1003
|
-
const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
|
|
1004
|
-
const username = config.getString("username");
|
|
1005
|
-
const appPassword = (_a = config.getString("appPassword")) == null ? void 0 : _a.trim();
|
|
1006
|
-
return {
|
|
1007
|
-
host,
|
|
1008
|
-
apiBaseUrl,
|
|
1009
|
-
username,
|
|
1010
|
-
appPassword
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
function readBitbucketCloudIntegrationConfigs(configs) {
|
|
1014
|
-
const result = configs.map(readBitbucketCloudIntegrationConfig);
|
|
1015
|
-
if (result.length === 0) {
|
|
1016
|
-
result.push({
|
|
1017
|
-
host: BITBUCKET_CLOUD_HOST,
|
|
1018
|
-
apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
return result;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
var __defProp$9 = Object.defineProperty;
|
|
1025
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1026
|
-
var __publicField$9 = (obj, key, value) => {
|
|
1027
|
-
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1028
|
-
return value;
|
|
1029
|
-
};
|
|
1030
|
-
const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
1031
|
-
constructor(integrationConfig) {
|
|
1032
|
-
this.integrationConfig = integrationConfig;
|
|
1033
|
-
}
|
|
1034
|
-
get type() {
|
|
1035
|
-
return "bitbucketCloud";
|
|
1036
|
-
}
|
|
1037
|
-
get title() {
|
|
1038
|
-
return this.integrationConfig.host;
|
|
1039
|
-
}
|
|
1040
|
-
get config() {
|
|
1041
|
-
return this.integrationConfig;
|
|
1042
|
-
}
|
|
1043
|
-
resolveUrl(options) {
|
|
1044
|
-
const resolved = defaultScmResolveUrl(options);
|
|
1045
|
-
if (options.lineNumber) {
|
|
1046
|
-
const url = new URL(resolved);
|
|
1047
|
-
url.hash = `lines-${options.lineNumber}`;
|
|
1048
|
-
return url.toString();
|
|
1049
|
-
}
|
|
1050
|
-
return resolved;
|
|
1051
|
-
}
|
|
1052
|
-
resolveEditUrl(url) {
|
|
1053
|
-
const urlData = parseGitUrl(url);
|
|
1054
|
-
const editUrl = new URL(url);
|
|
1055
|
-
editUrl.searchParams.set("mode", "edit");
|
|
1056
|
-
editUrl.searchParams.set("at", urlData.ref);
|
|
1057
|
-
return editUrl.toString();
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
__publicField$9(_BitbucketCloudIntegration, "factory", ({
|
|
1061
|
-
config
|
|
1062
|
-
}) => {
|
|
1063
|
-
var _a;
|
|
1064
|
-
const configs = readBitbucketCloudIntegrationConfigs(
|
|
1065
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : []
|
|
1066
|
-
);
|
|
1067
|
-
return basicIntegrations(
|
|
1068
|
-
configs.map((c) => new _BitbucketCloudIntegration(c)),
|
|
1069
|
-
(i) => i.config.host
|
|
1070
|
-
);
|
|
1071
|
-
});
|
|
1072
|
-
let BitbucketCloudIntegration = _BitbucketCloudIntegration;
|
|
1073
|
-
|
|
1074
|
-
async function getBitbucketCloudDefaultBranch(url, config) {
|
|
1075
|
-
const { name: repoName, owner: project } = parseGitUrl(url);
|
|
1076
|
-
const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;
|
|
1077
|
-
const response = await fetch(
|
|
1078
|
-
branchUrl,
|
|
1079
|
-
getBitbucketCloudRequestOptions(config)
|
|
1080
|
-
);
|
|
1081
|
-
if (!response.ok) {
|
|
1082
|
-
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
1083
|
-
throw new Error(message);
|
|
1084
|
-
}
|
|
1085
|
-
const repoInfo = await response.json();
|
|
1086
|
-
const defaultBranch = repoInfo.mainbranch.name;
|
|
1087
|
-
if (!defaultBranch) {
|
|
1088
|
-
throw new Error(
|
|
1089
|
-
`Failed to read default branch from ${branchUrl}. Response ${response.status} ${response.json()}`
|
|
1090
|
-
);
|
|
1091
|
-
}
|
|
1092
|
-
return defaultBranch;
|
|
1093
|
-
}
|
|
1094
|
-
async function getBitbucketCloudDownloadUrl(url, config) {
|
|
1095
|
-
const {
|
|
1096
|
-
name: repoName,
|
|
1097
|
-
owner: project,
|
|
1098
|
-
ref,
|
|
1099
|
-
protocol,
|
|
1100
|
-
resource
|
|
1101
|
-
} = parseGitUrl(url);
|
|
1102
|
-
let branch = ref;
|
|
1103
|
-
if (!branch) {
|
|
1104
|
-
branch = await getBitbucketCloudDefaultBranch(url, config);
|
|
1105
|
-
}
|
|
1106
|
-
return `${protocol}://${resource}/${project}/${repoName}/get/${branch}.tar.gz`;
|
|
1107
|
-
}
|
|
1108
|
-
function getBitbucketCloudFileFetchUrl(url, config) {
|
|
1109
|
-
try {
|
|
1110
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
1111
|
-
if (!owner || !name || filepathtype !== "src" && filepathtype !== "raw") {
|
|
1112
|
-
throw new Error("Invalid Bitbucket Cloud URL or file path");
|
|
1113
|
-
}
|
|
1114
|
-
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
1115
|
-
if (!ref) {
|
|
1116
|
-
throw new Error("Invalid Bitbucket Cloud URL or file path");
|
|
1117
|
-
}
|
|
1118
|
-
return `${config.apiBaseUrl}/repositories/${owner}/${name}/src/${ref}/${pathWithoutSlash}`;
|
|
1119
|
-
} catch (e) {
|
|
1120
|
-
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
function getBitbucketCloudRequestOptions(config) {
|
|
1124
|
-
const headers = {};
|
|
1125
|
-
if (config.username && config.appPassword) {
|
|
1126
|
-
const buffer = Buffer.from(
|
|
1127
|
-
`${config.username}:${config.appPassword}`,
|
|
1128
|
-
"utf8"
|
|
1129
|
-
);
|
|
1130
|
-
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
1131
|
-
}
|
|
1132
|
-
return {
|
|
1133
|
-
headers
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
function readBitbucketServerIntegrationConfig(config) {
|
|
1138
|
-
var _a;
|
|
1139
|
-
const host = config.getString("host");
|
|
1140
|
-
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
1141
|
-
const token = (_a = config.getOptionalString("token")) == null ? void 0 : _a.trim();
|
|
1142
|
-
const username = config.getOptionalString("username");
|
|
1143
|
-
const password = config.getOptionalString("password");
|
|
1144
|
-
if (!isValidHost(host)) {
|
|
1145
|
-
throw new Error(
|
|
1146
|
-
`Invalid Bitbucket Server integration config, '${host}' is not a valid host`
|
|
1147
|
-
);
|
|
1148
|
-
}
|
|
1149
|
-
if (apiBaseUrl) {
|
|
1150
|
-
apiBaseUrl = trimEnd(apiBaseUrl, "/");
|
|
1151
|
-
} else {
|
|
1152
|
-
apiBaseUrl = `https://${host}/rest/api/1.0`;
|
|
1153
|
-
}
|
|
1154
|
-
return {
|
|
1155
|
-
host,
|
|
1156
|
-
apiBaseUrl,
|
|
1157
|
-
token,
|
|
1158
|
-
username,
|
|
1159
|
-
password
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
function readBitbucketServerIntegrationConfigs(configs) {
|
|
1163
|
-
return configs.map(readBitbucketServerIntegrationConfig);
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
var __defProp$8 = Object.defineProperty;
|
|
1167
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1168
|
-
var __publicField$8 = (obj, key, value) => {
|
|
1169
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1170
|
-
return value;
|
|
1171
|
-
};
|
|
1172
|
-
const _BitbucketServerIntegration = class _BitbucketServerIntegration {
|
|
1173
|
-
constructor(integrationConfig) {
|
|
1174
|
-
this.integrationConfig = integrationConfig;
|
|
1175
|
-
}
|
|
1176
|
-
get type() {
|
|
1177
|
-
return "bitbucketServer";
|
|
1178
|
-
}
|
|
1179
|
-
get title() {
|
|
1180
|
-
return this.integrationConfig.host;
|
|
1181
|
-
}
|
|
1182
|
-
get config() {
|
|
1183
|
-
return this.integrationConfig;
|
|
1184
|
-
}
|
|
1185
|
-
resolveUrl(options) {
|
|
1186
|
-
const resolved = defaultScmResolveUrl(options);
|
|
1187
|
-
if (options.lineNumber) {
|
|
1188
|
-
const url = new URL(resolved);
|
|
1189
|
-
url.hash = options.lineNumber.toString();
|
|
1190
|
-
return url.toString();
|
|
1191
|
-
}
|
|
1192
|
-
return resolved;
|
|
1193
|
-
}
|
|
1194
|
-
resolveEditUrl(url) {
|
|
1195
|
-
if (url.includes("?")) {
|
|
1196
|
-
return url.substring(0, url.indexOf("?"));
|
|
1197
|
-
}
|
|
1198
|
-
return url;
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
__publicField$8(_BitbucketServerIntegration, "factory", ({
|
|
1202
|
-
config
|
|
1203
|
-
}) => {
|
|
1204
|
-
var _a;
|
|
1205
|
-
const configs = readBitbucketServerIntegrationConfigs(
|
|
1206
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _a : []
|
|
1207
|
-
);
|
|
1208
|
-
return basicIntegrations(
|
|
1209
|
-
configs.map((c) => new _BitbucketServerIntegration(c)),
|
|
1210
|
-
(i) => i.config.host
|
|
1211
|
-
);
|
|
1212
|
-
});
|
|
1213
|
-
let BitbucketServerIntegration = _BitbucketServerIntegration;
|
|
1214
|
-
|
|
1215
|
-
async function getBitbucketServerDefaultBranch(url, config) {
|
|
1216
|
-
const { name: repoName, owner: project } = parseGitUrl(url);
|
|
1217
|
-
let branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
|
|
1218
|
-
let response = await fetch(
|
|
1219
|
-
branchUrl,
|
|
1220
|
-
getBitbucketServerRequestOptions(config)
|
|
1221
|
-
);
|
|
1222
|
-
if (response.status === 404) {
|
|
1223
|
-
branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
|
|
1224
|
-
response = await fetch(branchUrl, getBitbucketServerRequestOptions(config));
|
|
1225
|
-
}
|
|
1226
|
-
if (!response.ok) {
|
|
1227
|
-
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
1228
|
-
throw new Error(message);
|
|
1229
|
-
}
|
|
1230
|
-
const { displayId } = await response.json();
|
|
1231
|
-
const defaultBranch = displayId;
|
|
1232
|
-
if (!defaultBranch) {
|
|
1233
|
-
throw new Error(
|
|
1234
|
-
`Failed to read default branch from ${branchUrl}. Response ${response.status} ${response.json()}`
|
|
1235
|
-
);
|
|
1236
|
-
}
|
|
1237
|
-
return defaultBranch;
|
|
1238
|
-
}
|
|
1239
|
-
async function getBitbucketServerDownloadUrl(url, config) {
|
|
1240
|
-
const { name: repoName, owner: project, ref, filepath } = parseGitUrl(url);
|
|
1241
|
-
let branch = ref;
|
|
1242
|
-
if (!branch) {
|
|
1243
|
-
branch = await getBitbucketServerDefaultBranch(url, config);
|
|
1244
|
-
}
|
|
1245
|
-
const path = filepath ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}` : "";
|
|
1246
|
-
return `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;
|
|
1247
|
-
}
|
|
1248
|
-
function getBitbucketServerFileFetchUrl(url, config) {
|
|
1249
|
-
try {
|
|
1250
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
1251
|
-
if (!owner || !name || filepathtype !== "browse" && filepathtype !== "raw" && filepathtype !== "src") {
|
|
1252
|
-
throw new Error("Invalid Bitbucket Server URL or file path");
|
|
1253
|
-
}
|
|
1254
|
-
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
1255
|
-
return `${config.apiBaseUrl}/projects/${owner}/repos/${name}/raw/${pathWithoutSlash}?at=${ref}`;
|
|
1256
|
-
} catch (e) {
|
|
1257
|
-
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
function getBitbucketServerRequestOptions(config) {
|
|
1261
|
-
const headers = {};
|
|
1262
|
-
if (config.token) {
|
|
1263
|
-
headers.Authorization = `Bearer ${config.token}`;
|
|
1264
|
-
} else if (config.username && config.password) {
|
|
1265
|
-
const buffer = Buffer.from(`${config.username}:${config.password}`, "utf8");
|
|
1266
|
-
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
1267
|
-
}
|
|
1268
|
-
return {
|
|
1269
|
-
headers
|
|
1270
|
-
};
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
function readGerritIntegrationConfig(config) {
|
|
1274
|
-
var _a;
|
|
1275
|
-
const host = config.getString("host");
|
|
1276
|
-
let baseUrl = config.getOptionalString("baseUrl");
|
|
1277
|
-
let cloneUrl = config.getOptionalString("cloneUrl");
|
|
1278
|
-
let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
|
|
1279
|
-
const username = config.getOptionalString("username");
|
|
1280
|
-
const password = (_a = config.getOptionalString("password")) == null ? void 0 : _a.trim();
|
|
1281
|
-
if (!isValidHost(host)) {
|
|
1282
|
-
throw new Error(
|
|
1283
|
-
`Invalid Gerrit integration config, '${host}' is not a valid host`
|
|
1284
|
-
);
|
|
1285
|
-
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
1286
|
-
throw new Error(
|
|
1287
|
-
`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`
|
|
1288
|
-
);
|
|
1289
|
-
} else if (cloneUrl && !isValidUrl(cloneUrl)) {
|
|
1290
|
-
throw new Error(
|
|
1291
|
-
`Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`
|
|
1292
|
-
);
|
|
1293
|
-
} else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {
|
|
1294
|
-
throw new Error(
|
|
1295
|
-
`Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`
|
|
1296
|
-
);
|
|
1297
|
-
}
|
|
1298
|
-
if (baseUrl) {
|
|
1299
|
-
baseUrl = trimEnd(baseUrl, "/");
|
|
1300
|
-
} else {
|
|
1301
|
-
baseUrl = `https://${host}`;
|
|
1302
|
-
}
|
|
1303
|
-
if (gitilesBaseUrl) {
|
|
1304
|
-
gitilesBaseUrl = trimEnd(gitilesBaseUrl, "/");
|
|
1305
|
-
} else {
|
|
1306
|
-
gitilesBaseUrl = `https://${host}`;
|
|
1307
|
-
}
|
|
1308
|
-
if (cloneUrl) {
|
|
1309
|
-
cloneUrl = trimEnd(cloneUrl, "/");
|
|
1310
|
-
} else {
|
|
1311
|
-
cloneUrl = baseUrl;
|
|
1312
|
-
}
|
|
1313
|
-
return {
|
|
1314
|
-
host,
|
|
1315
|
-
baseUrl,
|
|
1316
|
-
cloneUrl,
|
|
1317
|
-
gitilesBaseUrl,
|
|
1318
|
-
username,
|
|
1319
|
-
password
|
|
1320
|
-
};
|
|
1321
|
-
}
|
|
1322
|
-
function readGerritIntegrationConfigs(configs) {
|
|
1323
|
-
return configs.map(readGerritIntegrationConfig);
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
const GERRIT_BODY_PREFIX = ")]}'";
|
|
1327
|
-
function parseGerritGitilesUrl(config, url) {
|
|
1328
|
-
const baseUrlParse = new URL(config.gitilesBaseUrl);
|
|
1329
|
-
const urlParse = new URL(url);
|
|
1330
|
-
const urlPath = urlParse.pathname.substring(urlParse.pathname.startsWith("/a/") ? 2 : 0).replace(baseUrlParse.pathname, "");
|
|
1331
|
-
const parts = urlPath.split("/").filter((p) => !!p);
|
|
1332
|
-
const projectEndIndex = parts.indexOf("+");
|
|
1333
|
-
if (projectEndIndex <= 0) {
|
|
1334
|
-
throw new Error(`Unable to parse project from url: ${url}`);
|
|
1335
|
-
}
|
|
1336
|
-
const project = trimStart(parts.slice(0, projectEndIndex).join("/"), "/");
|
|
1337
|
-
const branchIndex = parts.indexOf("heads");
|
|
1338
|
-
if (branchIndex <= 0) {
|
|
1339
|
-
throw new Error(`Unable to parse branch from url: ${url}`);
|
|
1340
|
-
}
|
|
1341
|
-
const branch = parts[branchIndex + 1];
|
|
1342
|
-
const filePath = parts.slice(branchIndex + 2).join("/");
|
|
1343
|
-
return {
|
|
1344
|
-
branch,
|
|
1345
|
-
filePath: filePath === "" ? "/" : filePath,
|
|
1346
|
-
project
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
1349
|
-
function buildGerritGitilesUrl(config, project, branch, filePath) {
|
|
1350
|
-
return `${config.gitilesBaseUrl}/${project}/+/refs/heads/${branch}/${trimStart(filePath, "/")}`;
|
|
1351
|
-
}
|
|
1352
|
-
function buildGerritGitilesArchiveUrl(config, project, branch, filePath) {
|
|
1353
|
-
const archiveName = filePath === "/" || filePath === "" ? ".tar.gz" : `/${filePath}.tar.gz`;
|
|
1354
|
-
return `${getGitilesAuthenticationUrl(
|
|
1355
|
-
config
|
|
1356
|
-
)}/${project}/+archive/refs/heads/${branch}${archiveName}`;
|
|
1357
|
-
}
|
|
1358
|
-
function getAuthenticationPrefix(config) {
|
|
1359
|
-
return config.password ? "/a/" : "/";
|
|
1360
|
-
}
|
|
1361
|
-
function getGitilesAuthenticationUrl(config) {
|
|
1362
|
-
if (!config.baseUrl || !config.gitilesBaseUrl) {
|
|
1363
|
-
throw new Error(
|
|
1364
|
-
"Unexpected Gerrit config values. baseUrl or gitilesBaseUrl not set."
|
|
1365
|
-
);
|
|
1366
|
-
}
|
|
1367
|
-
if (config.gitilesBaseUrl.startsWith(config.baseUrl)) {
|
|
1368
|
-
return config.gitilesBaseUrl.replace(
|
|
1369
|
-
config.baseUrl.concat("/"),
|
|
1370
|
-
config.baseUrl.concat(getAuthenticationPrefix(config))
|
|
1371
|
-
);
|
|
1372
|
-
}
|
|
1373
|
-
if (config.password) {
|
|
1374
|
-
throw new Error(
|
|
1375
|
-
"Since the baseUrl (Gerrit) is not part of the gitilesBaseUrl, an authentication URL could not be constructed."
|
|
1376
|
-
);
|
|
1377
|
-
}
|
|
1378
|
-
return config.gitilesBaseUrl;
|
|
1379
|
-
}
|
|
1380
|
-
function getGerritBranchApiUrl(config, url) {
|
|
1381
|
-
const { branch, project } = parseGerritGitilesUrl(config, url);
|
|
1382
|
-
return `${config.baseUrl}${getAuthenticationPrefix(
|
|
1383
|
-
config
|
|
1384
|
-
)}projects/${encodeURIComponent(project)}/branches/${branch}`;
|
|
1385
|
-
}
|
|
1386
|
-
function getGerritCloneRepoUrl(config, url) {
|
|
1387
|
-
const { project } = parseGerritGitilesUrl(config, url);
|
|
1388
|
-
return `${config.cloneUrl}${getAuthenticationPrefix(config)}${project}`;
|
|
1389
|
-
}
|
|
1390
|
-
function getGerritFileContentsApiUrl(config, url) {
|
|
1391
|
-
const { branch, filePath, project } = parseGerritGitilesUrl(config, url);
|
|
1392
|
-
return `${config.baseUrl}${getAuthenticationPrefix(
|
|
1393
|
-
config
|
|
1394
|
-
)}projects/${encodeURIComponent(
|
|
1395
|
-
project
|
|
1396
|
-
)}/branches/${branch}/files/${encodeURIComponent(filePath)}/content`;
|
|
1397
|
-
}
|
|
1398
|
-
function getGerritProjectsApiUrl(config) {
|
|
1399
|
-
return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/`;
|
|
1400
|
-
}
|
|
1401
|
-
function getGerritRequestOptions(config) {
|
|
1402
|
-
const headers = {};
|
|
1403
|
-
if (!config.password) {
|
|
1404
|
-
return headers;
|
|
1405
|
-
}
|
|
1406
|
-
const buffer = Buffer.from(`${config.username}:${config.password}`, "utf8");
|
|
1407
|
-
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
1408
|
-
return {
|
|
1409
|
-
headers
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
async function parseGerritJsonResponse(response) {
|
|
1413
|
-
const responseBody = await response.text();
|
|
1414
|
-
if (responseBody.startsWith(GERRIT_BODY_PREFIX)) {
|
|
1415
|
-
try {
|
|
1416
|
-
return JSON.parse(responseBody.slice(GERRIT_BODY_PREFIX.length));
|
|
1417
|
-
} catch (ex) {
|
|
1418
|
-
throw new Error(
|
|
1419
|
-
`Invalid response from Gerrit: ${responseBody.slice(0, 10)} - ${ex}`
|
|
1420
|
-
);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
throw new Error(
|
|
1424
|
-
`Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`
|
|
1425
|
-
);
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
var __defProp$7 = Object.defineProperty;
|
|
1429
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1430
|
-
var __publicField$7 = (obj, key, value) => {
|
|
1431
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1432
|
-
return value;
|
|
1433
|
-
};
|
|
1434
|
-
const _GerritIntegration = class _GerritIntegration {
|
|
1435
|
-
constructor(integrationConfig) {
|
|
1436
|
-
this.integrationConfig = integrationConfig;
|
|
1437
|
-
}
|
|
1438
|
-
get type() {
|
|
1439
|
-
return "gerrit";
|
|
1440
|
-
}
|
|
1441
|
-
get title() {
|
|
1442
|
-
return this.integrationConfig.host;
|
|
1443
|
-
}
|
|
1444
|
-
get config() {
|
|
1445
|
-
return this.integrationConfig;
|
|
1446
|
-
}
|
|
1447
|
-
resolveUrl(options) {
|
|
1448
|
-
const { url, base, lineNumber } = options;
|
|
1449
|
-
let updated;
|
|
1450
|
-
if (url.startsWith("/")) {
|
|
1451
|
-
const { branch, project } = parseGerritGitilesUrl(this.config, base);
|
|
1452
|
-
return buildGerritGitilesUrl(this.config, project, branch, url);
|
|
1453
|
-
}
|
|
1454
|
-
if (url) {
|
|
1455
|
-
updated = new URL(url, base);
|
|
1456
|
-
} else {
|
|
1457
|
-
updated = new URL(base);
|
|
1458
|
-
}
|
|
1459
|
-
if (lineNumber) {
|
|
1460
|
-
updated.hash = lineNumber.toString();
|
|
1461
|
-
}
|
|
1462
|
-
return updated.toString();
|
|
1463
|
-
}
|
|
1464
|
-
resolveEditUrl(url) {
|
|
1465
|
-
return url;
|
|
1466
|
-
}
|
|
1467
|
-
};
|
|
1468
|
-
__publicField$7(_GerritIntegration, "factory", ({ config }) => {
|
|
1469
|
-
var _a;
|
|
1470
|
-
const configs = readGerritIntegrationConfigs(
|
|
1471
|
-
(_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []
|
|
1472
|
-
);
|
|
1473
|
-
return basicIntegrations(
|
|
1474
|
-
configs.map((c) => new _GerritIntegration(c)),
|
|
1475
|
-
(i) => i.config.host
|
|
1476
|
-
);
|
|
1477
|
-
});
|
|
1478
|
-
let GerritIntegration = _GerritIntegration;
|
|
1479
|
-
|
|
1480
|
-
function readGiteaConfig(config) {
|
|
1481
|
-
var _a;
|
|
1482
|
-
const host = config.getString("host");
|
|
1483
|
-
let baseUrl = config.getOptionalString("baseUrl");
|
|
1484
|
-
const username = config.getOptionalString("username");
|
|
1485
|
-
const password = (_a = config.getOptionalString("password")) == null ? void 0 : _a.trim();
|
|
1486
|
-
if (!isValidHost(host)) {
|
|
1487
|
-
throw new Error(
|
|
1488
|
-
`Invalid Gitea integration config, '${host}' is not a valid host`
|
|
1489
|
-
);
|
|
1490
|
-
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
1491
|
-
throw new Error(
|
|
1492
|
-
`Invalid Gitea integration config, '${baseUrl}' is not a valid baseUrl`
|
|
1493
|
-
);
|
|
1494
|
-
}
|
|
1495
|
-
if (baseUrl) {
|
|
1496
|
-
baseUrl = trimEnd(baseUrl, "/");
|
|
1497
|
-
} else {
|
|
1498
|
-
baseUrl = `https://${host}`;
|
|
1499
|
-
}
|
|
1500
|
-
return {
|
|
1501
|
-
host,
|
|
1502
|
-
baseUrl,
|
|
1503
|
-
username,
|
|
1504
|
-
password
|
|
1505
|
-
};
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
function getGiteaEditContentsUrl(config, url) {
|
|
1509
|
-
const giteaUrl = parseGiteaUrl(config, url);
|
|
1510
|
-
return `${giteaUrl.url}/${giteaUrl.owner}/${giteaUrl.name}/_edit/${giteaUrl.ref}/${giteaUrl.path}`;
|
|
1511
|
-
}
|
|
1512
|
-
function getGiteaFileContentsUrl(config, url) {
|
|
1513
|
-
const giteaUrl = parseGiteaUrl(config, url);
|
|
1514
|
-
return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/contents/${giteaUrl.path}?ref=${giteaUrl.ref}`;
|
|
1515
|
-
}
|
|
1516
|
-
function getGiteaArchiveUrl(config, url) {
|
|
1517
|
-
const giteaUrl = parseGiteaUrl(config, url);
|
|
1518
|
-
return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/archive/${giteaUrl.ref}.tar.gz`;
|
|
1519
|
-
}
|
|
1520
|
-
function getGiteaLatestCommitUrl(config, url) {
|
|
1521
|
-
const giteaUrl = parseGiteaUrl(config, url);
|
|
1522
|
-
return `${giteaUrl.url}/api/v1/repos/${giteaUrl.owner}/${giteaUrl.name}/git/commits/${giteaUrl.ref}`;
|
|
1523
|
-
}
|
|
1524
|
-
function getGiteaRequestOptions(config) {
|
|
1525
|
-
const headers = {};
|
|
1526
|
-
const { username, password } = config;
|
|
1527
|
-
if (!password) {
|
|
1528
|
-
return headers;
|
|
1529
|
-
}
|
|
1530
|
-
if (username) {
|
|
1531
|
-
headers.Authorization = `basic ${Buffer.from(
|
|
1532
|
-
`${username}:${password}`
|
|
1533
|
-
).toString("base64")}`;
|
|
1534
|
-
} else {
|
|
1535
|
-
headers.Authorization = `token ${password}`;
|
|
1536
|
-
}
|
|
1537
|
-
return {
|
|
1538
|
-
headers
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
function parseGiteaUrl(config, url) {
|
|
1542
|
-
var _a;
|
|
1543
|
-
const baseUrl = (_a = config.baseUrl) != null ? _a : `https://${config.host}`;
|
|
1544
|
-
try {
|
|
1545
|
-
const [_blank, owner, name, _src, _branch, ref, ...path] = url.replace(baseUrl, "").split("/");
|
|
1546
|
-
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|
|
1547
|
-
return {
|
|
1548
|
-
url: baseUrl,
|
|
1549
|
-
owner,
|
|
1550
|
-
name,
|
|
1551
|
-
ref,
|
|
1552
|
-
path: pathWithoutSlash
|
|
1553
|
-
};
|
|
1554
|
-
} catch (e) {
|
|
1555
|
-
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
var __defProp$6 = Object.defineProperty;
|
|
1560
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1561
|
-
var __publicField$6 = (obj, key, value) => {
|
|
1562
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1563
|
-
return value;
|
|
1564
|
-
};
|
|
1565
|
-
const _GiteaIntegration = class _GiteaIntegration {
|
|
1566
|
-
constructor(config) {
|
|
1567
|
-
this.config = config;
|
|
1568
|
-
}
|
|
1569
|
-
get type() {
|
|
1570
|
-
return "gitea";
|
|
1571
|
-
}
|
|
1572
|
-
get title() {
|
|
1573
|
-
return this.config.host;
|
|
1574
|
-
}
|
|
1575
|
-
resolveUrl(options) {
|
|
1576
|
-
return defaultScmResolveUrl(options);
|
|
1577
|
-
}
|
|
1578
|
-
resolveEditUrl(url) {
|
|
1579
|
-
return getGiteaEditContentsUrl(this.config, url);
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
__publicField$6(_GiteaIntegration, "factory", ({ config }) => {
|
|
1583
|
-
var _a;
|
|
1584
|
-
const configs = (_a = config.getOptionalConfigArray("integrations.gitea")) != null ? _a : [];
|
|
1585
|
-
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
1586
|
-
return basicIntegrations(
|
|
1587
|
-
giteaConfigs.map((c) => new _GiteaIntegration(c)),
|
|
1588
|
-
(gitea) => gitea.config.host
|
|
1589
|
-
);
|
|
1590
|
-
});
|
|
1591
|
-
let GiteaIntegration = _GiteaIntegration;
|
|
1592
|
-
|
|
1593
|
-
const GITHUB_HOST = "github.com";
|
|
1594
|
-
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
1595
|
-
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
1596
|
-
function readGithubIntegrationConfig(config) {
|
|
1597
|
-
var _a, _b, _c;
|
|
1598
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : GITHUB_HOST;
|
|
1599
|
-
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
1600
|
-
let rawBaseUrl = config.getOptionalString("rawBaseUrl");
|
|
1601
|
-
const token = (_b = config.getOptionalString("token")) == null ? void 0 : _b.trim();
|
|
1602
|
-
const apps = (_c = config.getOptionalConfigArray("apps")) == null ? void 0 : _c.map((c) => ({
|
|
1603
|
-
appId: c.getNumber("appId"),
|
|
1604
|
-
clientId: c.getString("clientId"),
|
|
1605
|
-
clientSecret: c.getString("clientSecret"),
|
|
1606
|
-
webhookSecret: c.getString("webhookSecret"),
|
|
1607
|
-
privateKey: c.getString("privateKey"),
|
|
1608
|
-
allowedInstallationOwners: c.getOptionalStringArray(
|
|
1609
|
-
"allowedInstallationOwners"
|
|
1610
|
-
)
|
|
1611
|
-
}));
|
|
1612
|
-
if (!isValidHost(host)) {
|
|
1613
|
-
throw new Error(
|
|
1614
|
-
`Invalid GitHub integration config, '${host}' is not a valid host`
|
|
1615
|
-
);
|
|
1616
|
-
}
|
|
1617
|
-
if (apiBaseUrl) {
|
|
1618
|
-
apiBaseUrl = trimEnd(apiBaseUrl, "/");
|
|
1619
|
-
} else if (host === GITHUB_HOST) {
|
|
1620
|
-
apiBaseUrl = GITHUB_API_BASE_URL;
|
|
1621
|
-
}
|
|
1622
|
-
if (rawBaseUrl) {
|
|
1623
|
-
rawBaseUrl = trimEnd(rawBaseUrl, "/");
|
|
1624
|
-
} else if (host === GITHUB_HOST) {
|
|
1625
|
-
rawBaseUrl = GITHUB_RAW_BASE_URL;
|
|
1626
|
-
}
|
|
1627
|
-
return { host, apiBaseUrl, rawBaseUrl, token, apps };
|
|
1628
|
-
}
|
|
1629
|
-
function readGithubIntegrationConfigs(configs) {
|
|
1630
|
-
const result = configs.map(readGithubIntegrationConfig);
|
|
1631
|
-
if (!result.some((c) => c.host === GITHUB_HOST)) {
|
|
1632
|
-
result.push({
|
|
1633
|
-
host: GITHUB_HOST,
|
|
1634
|
-
apiBaseUrl: GITHUB_API_BASE_URL,
|
|
1635
|
-
rawBaseUrl: GITHUB_RAW_BASE_URL
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
return result;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
function getGithubFileFetchUrl(url, config, credentials) {
|
|
1642
|
-
try {
|
|
1643
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
1644
|
-
if (!owner || !name || !ref || // GitHub is automatically redirecting tree urls to blob urls so it's
|
|
1645
|
-
// fine to pass a tree url.
|
|
1646
|
-
filepathtype !== "blob" && filepathtype !== "raw" && filepathtype !== "tree") {
|
|
1647
|
-
throw new Error("Invalid GitHub URL or file path");
|
|
1648
|
-
}
|
|
1649
|
-
const pathWithoutSlash = filepath.replace(/^\//, "");
|
|
1650
|
-
if (chooseEndpoint(config, credentials) === "api") {
|
|
1651
|
-
return `${config.apiBaseUrl}/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;
|
|
1652
|
-
}
|
|
1653
|
-
return `${config.rawBaseUrl}/${owner}/${name}/${ref}/${pathWithoutSlash}`;
|
|
1654
|
-
} catch (e) {
|
|
1655
|
-
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
function getGitHubRequestOptions(config, credentials) {
|
|
1659
|
-
const headers = {};
|
|
1660
|
-
if (chooseEndpoint(config, credentials) === "api") {
|
|
1661
|
-
headers.Accept = "application/vnd.github.v3.raw";
|
|
1662
|
-
}
|
|
1663
|
-
if (credentials.token) {
|
|
1664
|
-
headers.Authorization = `token ${credentials.token}`;
|
|
1665
|
-
}
|
|
1666
|
-
return { headers };
|
|
1667
|
-
}
|
|
1668
|
-
function chooseEndpoint(config, credentials) {
|
|
1669
|
-
if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) {
|
|
1670
|
-
return "api";
|
|
1671
|
-
}
|
|
1672
|
-
return "raw";
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
var __defProp$5 = Object.defineProperty;
|
|
1676
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1677
|
-
var __publicField$5 = (obj, key, value) => {
|
|
1678
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1679
|
-
return value;
|
|
1680
|
-
};
|
|
1681
|
-
class Cache {
|
|
1682
|
-
constructor() {
|
|
1683
|
-
__publicField$5(this, "tokenCache", /* @__PURE__ */ new Map());
|
|
1684
|
-
__publicField$5(this, "isExpired", (date) => DateTime.local() > date);
|
|
1685
|
-
}
|
|
1686
|
-
async getOrCreateToken(owner, repo, supplier) {
|
|
1687
|
-
let existingInstallationData = this.tokenCache.get(owner);
|
|
1688
|
-
if (!existingInstallationData || this.isExpired(existingInstallationData.expiresAt)) {
|
|
1689
|
-
existingInstallationData = await supplier();
|
|
1690
|
-
existingInstallationData.expiresAt = existingInstallationData.expiresAt.minus({ minutes: 10 });
|
|
1691
|
-
this.tokenCache.set(owner, existingInstallationData);
|
|
1692
|
-
}
|
|
1693
|
-
if (!this.appliesToRepo(existingInstallationData, repo)) {
|
|
1694
|
-
throw new Error(
|
|
1695
|
-
`The Backstage GitHub application used in the ${owner} organization does not have access to a repository with the name ${repo}`
|
|
1696
|
-
);
|
|
1697
|
-
}
|
|
1698
|
-
return { accessToken: existingInstallationData.token };
|
|
1699
|
-
}
|
|
1700
|
-
appliesToRepo(tokenData, repo) {
|
|
1701
|
-
if (repo === void 0) {
|
|
1702
|
-
return true;
|
|
1703
|
-
}
|
|
1704
|
-
if (tokenData.repositories !== void 0) {
|
|
1705
|
-
return tokenData.repositories.includes(repo);
|
|
1706
|
-
}
|
|
1707
|
-
return true;
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
const HEADERS = {
|
|
1711
|
-
Accept: "application/vnd.github.machine-man-preview+json"
|
|
1712
|
-
};
|
|
1713
|
-
class GithubAppManager {
|
|
1714
|
-
// undefined allows all installations
|
|
1715
|
-
constructor(config, baseUrl) {
|
|
1716
|
-
__publicField$5(this, "appClient");
|
|
1717
|
-
__publicField$5(this, "baseUrl");
|
|
1718
|
-
__publicField$5(this, "baseAuthConfig");
|
|
1719
|
-
__publicField$5(this, "cache", new Cache());
|
|
1720
|
-
__publicField$5(this, "allowedInstallationOwners");
|
|
1721
|
-
this.allowedInstallationOwners = config.allowedInstallationOwners;
|
|
1722
|
-
this.baseUrl = baseUrl;
|
|
1723
|
-
this.baseAuthConfig = {
|
|
1724
|
-
appId: config.appId,
|
|
1725
|
-
privateKey: config.privateKey.replace(/\\n/gm, "\n")
|
|
1726
|
-
};
|
|
1727
|
-
this.appClient = new Octokit({
|
|
1728
|
-
baseUrl,
|
|
1729
|
-
headers: HEADERS,
|
|
1730
|
-
authStrategy: createAppAuth,
|
|
1731
|
-
auth: this.baseAuthConfig
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
async getInstallationCredentials(owner, repo) {
|
|
1735
|
-
var _a;
|
|
1736
|
-
if (this.allowedInstallationOwners) {
|
|
1737
|
-
if (!((_a = this.allowedInstallationOwners) == null ? void 0 : _a.includes(owner))) {
|
|
1738
|
-
return { accessToken: void 0 };
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
return this.cache.getOrCreateToken(owner, repo, async () => {
|
|
1742
|
-
var _a2;
|
|
1743
|
-
const { installationId, suspended } = await this.getInstallationData(
|
|
1744
|
-
owner
|
|
1745
|
-
);
|
|
1746
|
-
if (suspended) {
|
|
1747
|
-
throw new Error(`The GitHub application for ${owner} is suspended`);
|
|
1748
|
-
}
|
|
1749
|
-
const result = await this.appClient.apps.createInstallationAccessToken({
|
|
1750
|
-
installation_id: installationId,
|
|
1751
|
-
headers: HEADERS
|
|
1752
|
-
});
|
|
1753
|
-
let repositoryNames;
|
|
1754
|
-
if (result.data.repository_selection === "selected") {
|
|
1755
|
-
const installationClient = new Octokit({
|
|
1756
|
-
baseUrl: this.baseUrl,
|
|
1757
|
-
auth: result.data.token
|
|
1758
|
-
});
|
|
1759
|
-
const repos = await installationClient.paginate(
|
|
1760
|
-
installationClient.apps.listReposAccessibleToInstallation
|
|
1761
|
-
);
|
|
1762
|
-
const repositories = (_a2 = repos.repositories) != null ? _a2 : repos;
|
|
1763
|
-
repositoryNames = repositories.map((repository) => repository.name);
|
|
1764
|
-
}
|
|
1765
|
-
return {
|
|
1766
|
-
token: result.data.token,
|
|
1767
|
-
expiresAt: DateTime.fromISO(result.data.expires_at),
|
|
1768
|
-
repositories: repositoryNames
|
|
1769
|
-
};
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
getInstallations() {
|
|
1773
|
-
return this.appClient.paginate(this.appClient.apps.listInstallations);
|
|
1774
|
-
}
|
|
1775
|
-
async getInstallationData(owner) {
|
|
1776
|
-
const allInstallations = await this.getInstallations();
|
|
1777
|
-
const installation = allInstallations.find(
|
|
1778
|
-
(inst) => {
|
|
1779
|
-
var _a;
|
|
1780
|
-
return inst.account && "login" in inst.account && ((_a = inst.account.login) == null ? void 0 : _a.toLocaleLowerCase("en-US")) === owner.toLocaleLowerCase("en-US");
|
|
1781
|
-
}
|
|
1782
|
-
);
|
|
1783
|
-
if (installation) {
|
|
1784
|
-
return {
|
|
1785
|
-
installationId: installation.id,
|
|
1786
|
-
suspended: Boolean(installation.suspended_by)
|
|
1787
|
-
};
|
|
1788
|
-
}
|
|
1789
|
-
const notFoundError = new Error(
|
|
1790
|
-
`No app installation found for ${owner} in ${this.baseAuthConfig.appId}`
|
|
1791
|
-
);
|
|
1792
|
-
notFoundError.name = "NotFoundError";
|
|
1793
|
-
throw notFoundError;
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
class GithubAppCredentialsMux {
|
|
1797
|
-
constructor(config) {
|
|
1798
|
-
__publicField$5(this, "apps");
|
|
1799
|
-
var _a, _b;
|
|
1800
|
-
this.apps = (_b = (_a = config.apps) == null ? void 0 : _a.map((ac) => new GithubAppManager(ac, config.apiBaseUrl))) != null ? _b : [];
|
|
1801
|
-
}
|
|
1802
|
-
async getAllInstallations() {
|
|
1803
|
-
if (!this.apps.length) {
|
|
1804
|
-
return [];
|
|
1805
|
-
}
|
|
1806
|
-
const installs = await Promise.all(
|
|
1807
|
-
this.apps.map((app) => app.getInstallations())
|
|
1808
|
-
);
|
|
1809
|
-
return installs.flat();
|
|
1810
|
-
}
|
|
1811
|
-
async getAppToken(owner, repo) {
|
|
1812
|
-
if (this.apps.length === 0) {
|
|
1813
|
-
return void 0;
|
|
1814
|
-
}
|
|
1815
|
-
const results = await Promise.all(
|
|
1816
|
-
this.apps.map(
|
|
1817
|
-
(app) => app.getInstallationCredentials(owner, repo).then(
|
|
1818
|
-
(credentials) => ({ credentials, error: void 0 }),
|
|
1819
|
-
(error) => ({ credentials: void 0, error })
|
|
1820
|
-
)
|
|
1821
|
-
)
|
|
1822
|
-
);
|
|
1823
|
-
const result = results.find(
|
|
1824
|
-
(resultItem) => {
|
|
1825
|
-
var _a;
|
|
1826
|
-
return (_a = resultItem.credentials) == null ? void 0 : _a.accessToken;
|
|
1827
|
-
}
|
|
1828
|
-
);
|
|
1829
|
-
if (result) {
|
|
1830
|
-
return result.credentials.accessToken;
|
|
1831
|
-
}
|
|
1832
|
-
const errors = results.map((r) => r.error);
|
|
1833
|
-
const notNotFoundError = errors.find((err) => (err == null ? void 0 : err.name) !== "NotFoundError");
|
|
1834
|
-
if (notNotFoundError) {
|
|
1835
|
-
throw notNotFoundError;
|
|
1836
|
-
}
|
|
1837
|
-
return void 0;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
const _SingleInstanceGithubCredentialsProvider = class _SingleInstanceGithubCredentialsProvider {
|
|
1841
|
-
constructor(githubAppCredentialsMux, token) {
|
|
1842
|
-
this.githubAppCredentialsMux = githubAppCredentialsMux;
|
|
1843
|
-
this.token = token;
|
|
1844
|
-
}
|
|
1845
|
-
/**
|
|
1846
|
-
* Returns {@link GithubCredentials} for a given URL.
|
|
1847
|
-
*
|
|
1848
|
-
* @remarks
|
|
1849
|
-
*
|
|
1850
|
-
* Consecutive calls to this method with the same URL will return cached
|
|
1851
|
-
* credentials.
|
|
1852
|
-
*
|
|
1853
|
-
* The shortest lifetime for a token returned is 10 minutes.
|
|
1854
|
-
*
|
|
1855
|
-
* @example
|
|
1856
|
-
* ```ts
|
|
1857
|
-
* const { token, headers } = await getCredentials({
|
|
1858
|
-
* url: 'github.com/backstage/foobar'
|
|
1859
|
-
* })
|
|
1860
|
-
* ```
|
|
1861
|
-
*
|
|
1862
|
-
* @param opts - The organization or repository URL
|
|
1863
|
-
* @returns A promise of {@link GithubCredentials}.
|
|
1864
|
-
*/
|
|
1865
|
-
async getCredentials(opts) {
|
|
1866
|
-
const parsed = parseGitUrl(opts.url);
|
|
1867
|
-
const owner = parsed.owner || parsed.name;
|
|
1868
|
-
const repo = parsed.owner ? parsed.name : void 0;
|
|
1869
|
-
let type = "app";
|
|
1870
|
-
let token = await this.githubAppCredentialsMux.getAppToken(owner, repo);
|
|
1871
|
-
if (!token) {
|
|
1872
|
-
type = "token";
|
|
1873
|
-
token = this.token;
|
|
1874
|
-
}
|
|
1875
|
-
return {
|
|
1876
|
-
headers: token ? { Authorization: `Bearer ${token}` } : void 0,
|
|
1877
|
-
token,
|
|
1878
|
-
type
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
__publicField$5(_SingleInstanceGithubCredentialsProvider, "create", (config) => {
|
|
1883
|
-
return new _SingleInstanceGithubCredentialsProvider(
|
|
1884
|
-
new GithubAppCredentialsMux(config),
|
|
1885
|
-
config.token
|
|
1886
|
-
);
|
|
1887
|
-
});
|
|
1888
|
-
let SingleInstanceGithubCredentialsProvider = _SingleInstanceGithubCredentialsProvider;
|
|
1889
|
-
|
|
1890
|
-
class DefaultGithubCredentialsProvider {
|
|
1891
|
-
constructor(providers) {
|
|
1892
|
-
this.providers = providers;
|
|
1893
|
-
}
|
|
1894
|
-
static fromIntegrations(integrations) {
|
|
1895
|
-
const credentialsProviders = /* @__PURE__ */ new Map();
|
|
1896
|
-
integrations.github.list().forEach((integration) => {
|
|
1897
|
-
const credentialsProvider = SingleInstanceGithubCredentialsProvider.create(integration.config);
|
|
1898
|
-
credentialsProviders.set(integration.config.host, credentialsProvider);
|
|
1899
|
-
});
|
|
1900
|
-
return new DefaultGithubCredentialsProvider(credentialsProviders);
|
|
1901
|
-
}
|
|
1902
|
-
/**
|
|
1903
|
-
* Returns {@link GithubCredentials} for a given URL.
|
|
1904
|
-
*
|
|
1905
|
-
* @remarks
|
|
1906
|
-
*
|
|
1907
|
-
* Consecutive calls to this method with the same URL will return cached
|
|
1908
|
-
* credentials.
|
|
1909
|
-
*
|
|
1910
|
-
* The shortest lifetime for a token returned is 10 minutes.
|
|
1911
|
-
*
|
|
1912
|
-
* @example
|
|
1913
|
-
* ```ts
|
|
1914
|
-
* const { token, headers } = await getCredentials({
|
|
1915
|
-
* url: 'https://github.com/backstage/foobar'
|
|
1916
|
-
* })
|
|
1917
|
-
*
|
|
1918
|
-
* const { token, headers } = await getCredentials({
|
|
1919
|
-
* url: 'https://github.com/backstage'
|
|
1920
|
-
* })
|
|
1921
|
-
* ```
|
|
1922
|
-
*
|
|
1923
|
-
* @param opts - The organization or repository URL
|
|
1924
|
-
* @returns A promise of {@link GithubCredentials}.
|
|
1925
|
-
*/
|
|
1926
|
-
async getCredentials(opts) {
|
|
1927
|
-
const parsed = new URL(opts.url);
|
|
1928
|
-
const provider = this.providers.get(parsed.host);
|
|
1929
|
-
if (!provider) {
|
|
1930
|
-
throw new Error(
|
|
1931
|
-
`There is no GitHub integration that matches ${opts.url}. Please add a configuration for an integration.`
|
|
1932
|
-
);
|
|
1933
|
-
}
|
|
1934
|
-
return provider.getCredentials(opts);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
var __defProp$4 = Object.defineProperty;
|
|
1939
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1940
|
-
var __publicField$4 = (obj, key, value) => {
|
|
1941
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1942
|
-
return value;
|
|
1943
|
-
};
|
|
1944
|
-
const _GithubIntegration = class _GithubIntegration {
|
|
1945
|
-
constructor(integrationConfig) {
|
|
1946
|
-
this.integrationConfig = integrationConfig;
|
|
1947
|
-
}
|
|
1948
|
-
get type() {
|
|
1949
|
-
return "github";
|
|
1950
|
-
}
|
|
1951
|
-
get title() {
|
|
1952
|
-
return this.integrationConfig.host;
|
|
1953
|
-
}
|
|
1954
|
-
get config() {
|
|
1955
|
-
return this.integrationConfig;
|
|
1956
|
-
}
|
|
1957
|
-
resolveUrl(options) {
|
|
1958
|
-
return replaceGithubUrlType(defaultScmResolveUrl(options), "tree");
|
|
1959
|
-
}
|
|
1960
|
-
resolveEditUrl(url) {
|
|
1961
|
-
return replaceGithubUrlType(url, "edit");
|
|
1962
|
-
}
|
|
1963
|
-
parseRateLimitInfo(response) {
|
|
1964
|
-
return {
|
|
1965
|
-
isRateLimited: response.status === 429 || response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0"
|
|
1966
|
-
};
|
|
1967
|
-
}
|
|
1968
|
-
};
|
|
1969
|
-
__publicField$4(_GithubIntegration, "factory", ({ config }) => {
|
|
1970
|
-
var _a;
|
|
1971
|
-
const configs = readGithubIntegrationConfigs(
|
|
1972
|
-
(_a = config.getOptionalConfigArray("integrations.github")) != null ? _a : []
|
|
1973
|
-
);
|
|
1974
|
-
return basicIntegrations(
|
|
1975
|
-
configs.map((c) => new _GithubIntegration(c)),
|
|
1976
|
-
(i) => i.config.host
|
|
1977
|
-
);
|
|
1978
|
-
});
|
|
1979
|
-
let GithubIntegration = _GithubIntegration;
|
|
1980
|
-
function replaceGithubUrlType(url, type) {
|
|
1981
|
-
return url.replace(
|
|
1982
|
-
/\/\/([^/]+)\/([^/]+)\/([^/]+)\/(blob|tree|edit)\//,
|
|
1983
|
-
(_, host, owner, repo) => {
|
|
1984
|
-
return `//${host}/${owner}/${repo}/${type}/`;
|
|
1985
|
-
}
|
|
1986
|
-
);
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
var __defProp$3 = Object.defineProperty;
|
|
1990
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1991
|
-
var __publicField$3 = (obj, key, value) => {
|
|
1992
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1993
|
-
return value;
|
|
1994
|
-
};
|
|
1995
|
-
const getGitHubFileFetchUrl = getGithubFileFetchUrl;
|
|
1996
|
-
class GitHubIntegration extends GithubIntegration {
|
|
1997
|
-
constructor(integrationConfig) {
|
|
1998
|
-
super(integrationConfig);
|
|
1999
|
-
}
|
|
2000
|
-
get config() {
|
|
2001
|
-
return super.config;
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
__publicField$3(GitHubIntegration, "factory", GithubIntegration.factory);
|
|
2005
|
-
const readGitHubIntegrationConfig = readGithubIntegrationConfig;
|
|
2006
|
-
const readGitHubIntegrationConfigs = readGithubIntegrationConfigs;
|
|
2007
|
-
const replaceGitHubUrlType = replaceGithubUrlType;
|
|
2008
|
-
|
|
2009
|
-
const GITLAB_HOST = "gitlab.com";
|
|
2010
|
-
const GITLAB_API_BASE_URL = "https://gitlab.com/api/v4";
|
|
2011
|
-
function readGitLabIntegrationConfig(config) {
|
|
2012
|
-
var _a;
|
|
2013
|
-
const host = config.getString("host");
|
|
2014
|
-
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
2015
|
-
const token = (_a = config.getOptionalString("token")) == null ? void 0 : _a.trim();
|
|
2016
|
-
let baseUrl = config.getOptionalString("baseUrl");
|
|
2017
|
-
if (apiBaseUrl) {
|
|
2018
|
-
apiBaseUrl = trimEnd(apiBaseUrl, "/");
|
|
2019
|
-
} else if (host === GITLAB_HOST) {
|
|
2020
|
-
apiBaseUrl = GITLAB_API_BASE_URL;
|
|
2021
|
-
}
|
|
2022
|
-
if (baseUrl) {
|
|
2023
|
-
baseUrl = trimEnd(baseUrl, "/");
|
|
2024
|
-
} else {
|
|
2025
|
-
baseUrl = `https://${host}`;
|
|
2026
|
-
}
|
|
2027
|
-
if (!isValidHost(host)) {
|
|
2028
|
-
throw new Error(
|
|
2029
|
-
`Invalid GitLab integration config, '${host}' is not a valid host`
|
|
2030
|
-
);
|
|
2031
|
-
} else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {
|
|
2032
|
-
throw new Error(
|
|
2033
|
-
`Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`
|
|
2034
|
-
);
|
|
2035
|
-
} else if (!isValidUrl(baseUrl)) {
|
|
2036
|
-
throw new Error(
|
|
2037
|
-
`Invalid GitLab integration config, '${baseUrl}' is not a valid baseUrl`
|
|
2038
|
-
);
|
|
2039
|
-
}
|
|
2040
|
-
return { host, token, apiBaseUrl, baseUrl };
|
|
2041
|
-
}
|
|
2042
|
-
function readGitLabIntegrationConfigs(configs) {
|
|
2043
|
-
const result = configs.map(readGitLabIntegrationConfig);
|
|
2044
|
-
if (!result.some((c) => c.host === GITLAB_HOST)) {
|
|
2045
|
-
result.push({
|
|
2046
|
-
host: GITLAB_HOST,
|
|
2047
|
-
apiBaseUrl: GITLAB_API_BASE_URL,
|
|
2048
|
-
baseUrl: `https://${GITLAB_HOST}`
|
|
2049
|
-
});
|
|
2050
|
-
}
|
|
2051
|
-
return result;
|
|
2052
|
-
}
|
|
2053
|
-
function getGitLabIntegrationRelativePath(config) {
|
|
2054
|
-
let relativePath = "";
|
|
2055
|
-
if (config.host !== GITLAB_HOST) {
|
|
2056
|
-
relativePath = new URL(config.baseUrl).pathname;
|
|
2057
|
-
}
|
|
2058
|
-
return trimEnd(relativePath, "/");
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
async function getGitLabFileFetchUrl(url, config) {
|
|
2062
|
-
const projectID = await getProjectId(url, config);
|
|
2063
|
-
return buildProjectUrl(url, projectID, config).toString();
|
|
2064
|
-
}
|
|
2065
|
-
function getGitLabRequestOptions(config) {
|
|
2066
|
-
const { token = "" } = config;
|
|
2067
|
-
return {
|
|
2068
|
-
headers: {
|
|
2069
|
-
"PRIVATE-TOKEN": token
|
|
2070
|
-
}
|
|
2071
|
-
};
|
|
2072
|
-
}
|
|
2073
|
-
function buildProjectUrl(target, projectID, config) {
|
|
2074
|
-
try {
|
|
2075
|
-
const url = new URL(target);
|
|
2076
|
-
const branchAndFilePath = url.pathname.split("/blob/").slice(1).join("/blob/");
|
|
2077
|
-
const [branch, ...filePath] = branchAndFilePath.split("/");
|
|
2078
|
-
const relativePath = getGitLabIntegrationRelativePath(config);
|
|
2079
|
-
url.pathname = [
|
|
2080
|
-
...relativePath ? [relativePath] : [],
|
|
2081
|
-
"api/v4/projects",
|
|
2082
|
-
projectID,
|
|
2083
|
-
"repository/files",
|
|
2084
|
-
encodeURIComponent(decodeURIComponent(filePath.join("/"))),
|
|
2085
|
-
"raw"
|
|
2086
|
-
].join("/");
|
|
2087
|
-
url.search = `?ref=${branch}`;
|
|
2088
|
-
return url;
|
|
2089
|
-
} catch (e) {
|
|
2090
|
-
throw new Error(`Incorrect url: ${target}, ${e}`);
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
async function getProjectId(target, config) {
|
|
2094
|
-
const url = new URL(target);
|
|
2095
|
-
if (!url.pathname.includes("/blob/")) {
|
|
2096
|
-
throw new Error("Please provide full path to yaml file from GitLab");
|
|
2097
|
-
}
|
|
2098
|
-
try {
|
|
2099
|
-
let repo = url.pathname.split("/-/blob/")[0].split("/blob/")[0];
|
|
2100
|
-
const relativePath = getGitLabIntegrationRelativePath(config);
|
|
2101
|
-
if (relativePath) {
|
|
2102
|
-
repo = repo.replace(relativePath, "");
|
|
2103
|
-
}
|
|
2104
|
-
const repoIDLookup = new URL(
|
|
2105
|
-
`${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(
|
|
2106
|
-
repo.replace(/^\//, "")
|
|
2107
|
-
)}`
|
|
2108
|
-
);
|
|
2109
|
-
const response = await fetch(
|
|
2110
|
-
repoIDLookup.toString(),
|
|
2111
|
-
getGitLabRequestOptions(config)
|
|
2112
|
-
);
|
|
2113
|
-
const data = await response.json();
|
|
2114
|
-
if (!response.ok) {
|
|
2115
|
-
throw new Error(
|
|
2116
|
-
`GitLab Error '${data.error}', ${data.error_description}`
|
|
2117
|
-
);
|
|
2118
|
-
}
|
|
2119
|
-
return Number(data.id);
|
|
2120
|
-
} catch (e) {
|
|
2121
|
-
throw new Error(`Could not get GitLab project ID for: ${target}, ${e}`);
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
var __defProp$2 = Object.defineProperty;
|
|
2126
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2127
|
-
var __publicField$2 = (obj, key, value) => {
|
|
2128
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2129
|
-
return value;
|
|
2130
|
-
};
|
|
2131
|
-
const _GitLabIntegration = class _GitLabIntegration {
|
|
2132
|
-
constructor(integrationConfig) {
|
|
2133
|
-
this.integrationConfig = integrationConfig;
|
|
2134
|
-
}
|
|
2135
|
-
get type() {
|
|
2136
|
-
return "gitlab";
|
|
2137
|
-
}
|
|
2138
|
-
get title() {
|
|
2139
|
-
return this.integrationConfig.host;
|
|
2140
|
-
}
|
|
2141
|
-
get config() {
|
|
2142
|
-
return this.integrationConfig;
|
|
2143
|
-
}
|
|
2144
|
-
resolveUrl(options) {
|
|
2145
|
-
return defaultScmResolveUrl(options);
|
|
2146
|
-
}
|
|
2147
|
-
resolveEditUrl(url) {
|
|
2148
|
-
return replaceGitLabUrlType(url, "edit");
|
|
2149
|
-
}
|
|
2150
|
-
};
|
|
2151
|
-
__publicField$2(_GitLabIntegration, "factory", ({ config }) => {
|
|
2152
|
-
var _a;
|
|
2153
|
-
const configs = readGitLabIntegrationConfigs(
|
|
2154
|
-
(_a = config.getOptionalConfigArray("integrations.gitlab")) != null ? _a : []
|
|
2155
|
-
);
|
|
2156
|
-
return basicIntegrations(
|
|
2157
|
-
configs.map((c) => new _GitLabIntegration(c)),
|
|
2158
|
-
(i) => i.config.host
|
|
2159
|
-
);
|
|
2160
|
-
});
|
|
2161
|
-
let GitLabIntegration = _GitLabIntegration;
|
|
2162
|
-
function replaceGitLabUrlType(url, type) {
|
|
2163
|
-
return url.replace(/\/\-\/(blob|tree|edit)\//, `/-/${type}/`);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
var __defProp$1 = Object.defineProperty;
|
|
2167
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2168
|
-
var __publicField$1 = (obj, key, value) => {
|
|
2169
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2170
|
-
return value;
|
|
2171
|
-
};
|
|
2172
|
-
const _SingleInstanceGitlabCredentialsProvider = class _SingleInstanceGitlabCredentialsProvider {
|
|
2173
|
-
constructor(token) {
|
|
2174
|
-
this.token = token;
|
|
2175
|
-
}
|
|
2176
|
-
async getCredentials(_opts) {
|
|
2177
|
-
if (!this.token) {
|
|
2178
|
-
return {};
|
|
2179
|
-
}
|
|
2180
|
-
return {
|
|
2181
|
-
headers: {
|
|
2182
|
-
Authorization: `Bearer ${this.token}`
|
|
2183
|
-
},
|
|
2184
|
-
token: this.token
|
|
2185
|
-
};
|
|
2186
|
-
}
|
|
2187
|
-
};
|
|
2188
|
-
__publicField$1(_SingleInstanceGitlabCredentialsProvider, "create", (config) => {
|
|
2189
|
-
return new _SingleInstanceGitlabCredentialsProvider(config.token);
|
|
2190
|
-
});
|
|
2191
|
-
let SingleInstanceGitlabCredentialsProvider = _SingleInstanceGitlabCredentialsProvider;
|
|
2192
|
-
|
|
2193
|
-
class DefaultGitlabCredentialsProvider {
|
|
2194
|
-
constructor(providers) {
|
|
2195
|
-
this.providers = providers;
|
|
2196
|
-
}
|
|
2197
|
-
static fromIntegrations(integrations) {
|
|
2198
|
-
const credentialsProviders = /* @__PURE__ */ new Map();
|
|
2199
|
-
integrations.gitlab.list().forEach((integration) => {
|
|
2200
|
-
const credentialsProvider = SingleInstanceGitlabCredentialsProvider.create(integration.config);
|
|
2201
|
-
credentialsProviders.set(integration.config.host, credentialsProvider);
|
|
2202
|
-
});
|
|
2203
|
-
return new DefaultGitlabCredentialsProvider(credentialsProviders);
|
|
2204
|
-
}
|
|
2205
|
-
async getCredentials(opts) {
|
|
2206
|
-
const parsed = new URL(opts.url);
|
|
2207
|
-
const provider = this.providers.get(parsed.host);
|
|
2208
|
-
if (!provider) {
|
|
2209
|
-
throw new Error(
|
|
2210
|
-
`There is no GitLab integration that matches ${opts.url}. Please add a configuration for an integration.`
|
|
2211
|
-
);
|
|
2212
|
-
}
|
|
2213
|
-
return provider.getCredentials(opts);
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
|
|
2217
|
-
function readGoogleGcsIntegrationConfig(config) {
|
|
2218
|
-
if (!config) {
|
|
2219
|
-
return {};
|
|
2220
|
-
}
|
|
2221
|
-
if (!config.has("clientEmail") && !config.has("privateKey")) {
|
|
2222
|
-
return {};
|
|
2223
|
-
}
|
|
2224
|
-
const privateKey = config.getString("privateKey").split("\\n").join("\n");
|
|
2225
|
-
const clientEmail = config.getString("clientEmail");
|
|
2226
|
-
return { clientEmail, privateKey };
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
|
-
var __defProp = Object.defineProperty;
|
|
2230
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2231
|
-
var __publicField = (obj, key, value) => {
|
|
2232
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2233
|
-
return value;
|
|
2234
|
-
};
|
|
2235
|
-
class ScmIntegrations {
|
|
2236
|
-
constructor(integrationsByType) {
|
|
2237
|
-
__publicField(this, "byType");
|
|
2238
|
-
this.byType = integrationsByType;
|
|
2239
|
-
}
|
|
2240
|
-
static fromConfig(config) {
|
|
2241
|
-
return new ScmIntegrations({
|
|
2242
|
-
awsS3: AwsS3Integration.factory({ config }),
|
|
2243
|
-
awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),
|
|
2244
|
-
azure: AzureIntegration.factory({ config }),
|
|
2245
|
-
bitbucket: BitbucketIntegration.factory({ config }),
|
|
2246
|
-
bitbucketCloud: BitbucketCloudIntegration.factory({ config }),
|
|
2247
|
-
bitbucketServer: BitbucketServerIntegration.factory({ config }),
|
|
2248
|
-
gerrit: GerritIntegration.factory({ config }),
|
|
2249
|
-
github: GithubIntegration.factory({ config }),
|
|
2250
|
-
gitlab: GitLabIntegration.factory({ config }),
|
|
2251
|
-
gitea: GiteaIntegration.factory({ config })
|
|
2252
|
-
});
|
|
2253
|
-
}
|
|
2254
|
-
get awsS3() {
|
|
2255
|
-
return this.byType.awsS3;
|
|
2256
|
-
}
|
|
2257
|
-
get awsCodeCommit() {
|
|
2258
|
-
return this.byType.awsCodeCommit;
|
|
2259
|
-
}
|
|
2260
|
-
get azure() {
|
|
2261
|
-
return this.byType.azure;
|
|
2262
|
-
}
|
|
2263
|
-
/**
|
|
2264
|
-
* @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
|
|
2265
|
-
*/
|
|
2266
|
-
get bitbucket() {
|
|
2267
|
-
return this.byType.bitbucket;
|
|
2268
|
-
}
|
|
2269
|
-
get bitbucketCloud() {
|
|
2270
|
-
return this.byType.bitbucketCloud;
|
|
2271
|
-
}
|
|
2272
|
-
get bitbucketServer() {
|
|
2273
|
-
return this.byType.bitbucketServer;
|
|
2274
|
-
}
|
|
2275
|
-
get gerrit() {
|
|
2276
|
-
return this.byType.gerrit;
|
|
2277
|
-
}
|
|
2278
|
-
get github() {
|
|
2279
|
-
return this.byType.github;
|
|
2280
|
-
}
|
|
2281
|
-
get gitlab() {
|
|
2282
|
-
return this.byType.gitlab;
|
|
2283
|
-
}
|
|
2284
|
-
get gitea() {
|
|
2285
|
-
return this.byType.gitea;
|
|
2286
|
-
}
|
|
2287
|
-
list() {
|
|
2288
|
-
return Object.values(this.byType).flatMap(
|
|
2289
|
-
(i) => i.list()
|
|
2290
|
-
);
|
|
2291
|
-
}
|
|
2292
|
-
byUrl(url) {
|
|
2293
|
-
let candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean);
|
|
2294
|
-
if (candidates.length > 1) {
|
|
2295
|
-
const filteredCandidates = candidates.filter(
|
|
2296
|
-
(x) => !(x instanceof BitbucketIntegration)
|
|
2297
|
-
);
|
|
2298
|
-
if (filteredCandidates.length !== 0) {
|
|
2299
|
-
candidates = filteredCandidates;
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
return candidates[0];
|
|
2303
|
-
}
|
|
2304
|
-
byHost(host) {
|
|
2305
|
-
return Object.values(this.byType).map((i) => i.byHost(host)).find(Boolean);
|
|
2306
|
-
}
|
|
2307
|
-
resolveUrl(options) {
|
|
2308
|
-
const integration = this.byUrl(options.base);
|
|
2309
|
-
if (!integration) {
|
|
2310
|
-
return defaultScmResolveUrl(options);
|
|
2311
|
-
}
|
|
2312
|
-
return integration.resolveUrl(options);
|
|
2313
|
-
}
|
|
2314
|
-
resolveEditUrl(url) {
|
|
2315
|
-
const integration = this.byUrl(url);
|
|
2316
|
-
if (!integration) {
|
|
2317
|
-
return url;
|
|
2318
|
-
}
|
|
2319
|
-
return integration.resolveEditUrl(url);
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
export { AwsCodeCommitIntegration, AwsS3Integration, AzureIntegration, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, DefaultAzureDevOpsCredentialsProvider, DefaultGithubCredentialsProvider, DefaultGitlabCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GiteaIntegration, GithubAppCredentialsMux, GithubIntegration, ScmIntegrations, SingleInstanceGithubCredentialsProvider, buildGerritGitilesArchiveUrl, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, getGiteaArchiveUrl, getGiteaEditContentsUrl, getGiteaFileContentsUrl, getGiteaLatestCommitUrl, getGiteaRequestOptions, getGithubFileFetchUrl, parseGerritGitilesUrl, parseGerritJsonResponse, parseGiteaUrl, readAwsCodeCommitIntegrationConfig, readAwsCodeCommitIntegrationConfigs, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGiteaConfig, readGithubIntegrationConfig, readGithubIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType, replaceGithubUrlType };
|
|
1
|
+
export { AwsS3Integration } from './awsS3/AwsS3Integration.esm.js';
|
|
2
|
+
export { readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs } from './awsS3/config.esm.js';
|
|
3
|
+
export { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration.esm.js';
|
|
4
|
+
export { readAwsCodeCommitIntegrationConfig, readAwsCodeCommitIntegrationConfigs } from './awsCodeCommit/config.esm.js';
|
|
5
|
+
export { AzureIntegration } from './azure/AzureIntegration.esm.js';
|
|
6
|
+
export { readAzureIntegrationConfig, readAzureIntegrationConfigs } from './azure/config.esm.js';
|
|
7
|
+
export { getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl } from './azure/core.esm.js';
|
|
8
|
+
export { DefaultAzureDevOpsCredentialsProvider } from './azure/DefaultAzureDevOpsCredentialsProvider.esm.js';
|
|
9
|
+
export { getAzureRequestOptions } from './azure/deprecated.esm.js';
|
|
10
|
+
export { BitbucketIntegration } from './bitbucket/BitbucketIntegration.esm.js';
|
|
11
|
+
export { readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs } from './bitbucket/config.esm.js';
|
|
12
|
+
export { getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions } from './bitbucket/core.esm.js';
|
|
13
|
+
export { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration.esm.js';
|
|
14
|
+
export { readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs } from './bitbucketCloud/config.esm.js';
|
|
15
|
+
export { getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions } from './bitbucketCloud/core.esm.js';
|
|
16
|
+
export { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration.esm.js';
|
|
17
|
+
export { readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs } from './bitbucketServer/config.esm.js';
|
|
18
|
+
export { getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions } from './bitbucketServer/core.esm.js';
|
|
19
|
+
export { GerritIntegration } from './gerrit/GerritIntegration.esm.js';
|
|
20
|
+
export { readGerritIntegrationConfig, readGerritIntegrationConfigs } from './gerrit/config.esm.js';
|
|
21
|
+
export { buildGerritGitilesArchiveUrl, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse } from './gerrit/core.esm.js';
|
|
22
|
+
export { GiteaIntegration } from './gitea/GiteaIntegration.esm.js';
|
|
23
|
+
export { getGiteaArchiveUrl, getGiteaEditContentsUrl, getGiteaFileContentsUrl, getGiteaLatestCommitUrl, getGiteaRequestOptions, parseGiteaUrl } from './gitea/core.esm.js';
|
|
24
|
+
export { readGiteaConfig } from './gitea/config.esm.js';
|
|
25
|
+
export { readGithubIntegrationConfig, readGithubIntegrationConfigs } from './github/config.esm.js';
|
|
26
|
+
export { getGitHubRequestOptions, getGithubFileFetchUrl } from './github/core.esm.js';
|
|
27
|
+
export { DefaultGithubCredentialsProvider } from './github/DefaultGithubCredentialsProvider.esm.js';
|
|
28
|
+
export { GithubAppCredentialsMux, SingleInstanceGithubCredentialsProvider } from './github/SingleInstanceGithubCredentialsProvider.esm.js';
|
|
29
|
+
export { GithubIntegration, replaceGithubUrlType } from './github/GithubIntegration.esm.js';
|
|
30
|
+
export { GitHubIntegration, getGitHubFileFetchUrl, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, replaceGitHubUrlType } from './github/deprecated.esm.js';
|
|
31
|
+
export { getGitLabIntegrationRelativePath, readGitLabIntegrationConfig, readGitLabIntegrationConfigs } from './gitlab/config.esm.js';
|
|
32
|
+
export { getGitLabFileFetchUrl, getGitLabRequestOptions } from './gitlab/core.esm.js';
|
|
33
|
+
export { GitLabIntegration, replaceGitLabUrlType } from './gitlab/GitLabIntegration.esm.js';
|
|
34
|
+
export { DefaultGitlabCredentialsProvider } from './gitlab/DefaultGitlabCredentialsProvider.esm.js';
|
|
35
|
+
export { readGoogleGcsIntegrationConfig } from './googleGcs/config.esm.js';
|
|
36
|
+
export { HarnessIntegration } from './harness/HarnessIntegration.esm.js';
|
|
37
|
+
export { getHarnessFileContentsUrl, getHarnessRequestOptions } from './harness/core.esm.js';
|
|
38
|
+
export { readHarnessConfig } from './harness/config.esm.js';
|
|
39
|
+
export { defaultScmResolveUrl } from './helpers.esm.js';
|
|
40
|
+
export { ScmIntegrations } from './ScmIntegrations.esm.js';
|
|
2324
41
|
//# sourceMappingURL=index.esm.js.map
|