@backstage/integration 0.7.4 → 1.0.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 +29 -1
- package/config.d.ts +25 -0
- package/dist/index.cjs.js +83 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +71 -6
- package/dist/index.esm.js +81 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/integration
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- b58c70c223: This package has been promoted to v1.0! To understand how this change affects the package, please check out our [versioning policy](https://backstage.io/docs/overview/versioning-policy).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 403837cbac: Added an integration for Gerrit
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/config@1.0.0
|
|
14
|
+
|
|
15
|
+
## 0.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 34af86517c: ensure `apiBaseUrl` being set for Bitbucket integrations, replace hardcoded defaults
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 33d5e79822: Fix Bitbucket Cloud and Bitbucket Server line number reference.
|
|
24
|
+
|
|
25
|
+
## 0.7.5
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 4e1384884f: Fixed bug in integration package where Self Hosted GitLab instances with custom ports weren't supported (because of the lack of an option to add the port in the integration configs. Now users can add the port directly in the host)
|
|
30
|
+
|
|
3
31
|
## 0.7.4
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -229,7 +257,7 @@
|
|
|
229
257
|
|
|
230
258
|
- 0fd4ea443: Updates the `GithubCredentialsProvider` to return the token type, it can either be `token` or `app` depending on the authentication method.
|
|
231
259
|
|
|
232
|
-
Update the `GithubOrgReaderProcessor` NOT to query for email addresses if GitHub Apps is used for authentication, this is due to inconsistencies in the GitHub API when using server to server communications and installation tokens. https://github.community/t/api-v4-unable-to-retrieve-email-resource-not-accessible-by-integration/13831/4 for more info.
|
|
260
|
+
Update the `GithubOrgReaderProcessor` NOT to query for email addresses if GitHub Apps is used for authentication, this is due to inconsistencies in the GitHub API when using server to server communications and installation tokens. See [this community discussion](https://github.community/t/api-v4-unable-to-retrieve-email-resource-not-accessible-by-integration/13831/4) for more info.
|
|
233
261
|
|
|
234
262
|
**Removes** deprecated GithubOrgReaderProcessor provider configuration(`catalog.processors.githubOrg`). If you're using the deprecated config section make sure to migrate to [integrations](https://backstage.io/docs/integrations/github/locations) instead.
|
|
235
263
|
|
package/config.d.ts
CHANGED
|
@@ -60,6 +60,31 @@ export interface Config {
|
|
|
60
60
|
appPassword?: string;
|
|
61
61
|
}>;
|
|
62
62
|
|
|
63
|
+
/** Integration configuration for Gerrit */
|
|
64
|
+
gerrit?: Array<{
|
|
65
|
+
/**
|
|
66
|
+
* The hostname of the given Gerrit instance
|
|
67
|
+
* @visibility frontend
|
|
68
|
+
*/
|
|
69
|
+
host: string;
|
|
70
|
+
/**
|
|
71
|
+
* The base url for the Gerrit instance.
|
|
72
|
+
* @visibility frontend
|
|
73
|
+
*/
|
|
74
|
+
baseUrl?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The username to use for authenticated requests.
|
|
77
|
+
* @visibility secret
|
|
78
|
+
*/
|
|
79
|
+
username?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Gerrit password used to authenticate requests. This can be either a password
|
|
82
|
+
* or a generated access token.
|
|
83
|
+
* @visibility secret
|
|
84
|
+
*/
|
|
85
|
+
password?: string;
|
|
86
|
+
}>;
|
|
87
|
+
|
|
63
88
|
/** Integration configuration for GitHub */
|
|
64
89
|
github?: Array<{
|
|
65
90
|
/**
|
package/dist/index.cjs.js
CHANGED
|
@@ -310,6 +310,8 @@ function readBitbucketIntegrationConfig(config) {
|
|
|
310
310
|
apiBaseUrl = lodash.trimEnd(apiBaseUrl, "/");
|
|
311
311
|
} else if (host === BITBUCKET_HOST) {
|
|
312
312
|
apiBaseUrl = BITBUCKET_API_BASE_URL;
|
|
313
|
+
} else {
|
|
314
|
+
apiBaseUrl = `https://${host}/rest/api/1.0`;
|
|
313
315
|
}
|
|
314
316
|
return {
|
|
315
317
|
host,
|
|
@@ -345,13 +347,16 @@ const _BitbucketIntegration = class {
|
|
|
345
347
|
}
|
|
346
348
|
resolveUrl(options) {
|
|
347
349
|
const resolved = defaultScmResolveUrl(options);
|
|
348
|
-
if (options.lineNumber) {
|
|
349
|
-
|
|
350
|
-
const filename = url.pathname.split("/").slice(-1)[0];
|
|
351
|
-
url.hash = `${filename}-${options.lineNumber}`;
|
|
352
|
-
return url.toString();
|
|
350
|
+
if (!options.lineNumber) {
|
|
351
|
+
return resolved;
|
|
353
352
|
}
|
|
354
|
-
|
|
353
|
+
const url = new URL(resolved);
|
|
354
|
+
if (this.integrationConfig.host === "bitbucket.org") {
|
|
355
|
+
url.hash = `lines-${options.lineNumber}`;
|
|
356
|
+
} else {
|
|
357
|
+
url.hash = `${options.lineNumber}`;
|
|
358
|
+
}
|
|
359
|
+
return url.toString();
|
|
355
360
|
}
|
|
356
361
|
resolveEditUrl(url) {
|
|
357
362
|
const urlData = parseGitUrl__default["default"](url);
|
|
@@ -446,6 +451,69 @@ function getBitbucketRequestOptions(config) {
|
|
|
446
451
|
};
|
|
447
452
|
}
|
|
448
453
|
|
|
454
|
+
function readGerritIntegrationConfig(config) {
|
|
455
|
+
const host = config.getString("host");
|
|
456
|
+
let baseUrl = config.getOptionalString("baseUrl");
|
|
457
|
+
const username = config.getOptionalString("username");
|
|
458
|
+
const password = config.getOptionalString("password");
|
|
459
|
+
if (!isValidHost(host)) {
|
|
460
|
+
throw new Error(`Invalid Gerrit integration config, '${host}' is not a valid host`);
|
|
461
|
+
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
462
|
+
throw new Error(`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`);
|
|
463
|
+
}
|
|
464
|
+
if (baseUrl) {
|
|
465
|
+
baseUrl = lodash.trimEnd(baseUrl, "/");
|
|
466
|
+
} else {
|
|
467
|
+
baseUrl = `https://${host}`;
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
host,
|
|
471
|
+
baseUrl,
|
|
472
|
+
username,
|
|
473
|
+
password
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function readGerritIntegrationConfigs(configs) {
|
|
477
|
+
return configs.map(readGerritIntegrationConfig);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const _GerritIntegration = class {
|
|
481
|
+
constructor(integrationConfig) {
|
|
482
|
+
this.integrationConfig = integrationConfig;
|
|
483
|
+
}
|
|
484
|
+
get type() {
|
|
485
|
+
return "gerrit";
|
|
486
|
+
}
|
|
487
|
+
get title() {
|
|
488
|
+
return this.integrationConfig.host;
|
|
489
|
+
}
|
|
490
|
+
get config() {
|
|
491
|
+
return this.integrationConfig;
|
|
492
|
+
}
|
|
493
|
+
resolveUrl(options) {
|
|
494
|
+
const { url, base, lineNumber } = options;
|
|
495
|
+
let updated;
|
|
496
|
+
if (url) {
|
|
497
|
+
updated = new URL(url, base);
|
|
498
|
+
} else {
|
|
499
|
+
updated = new URL(base);
|
|
500
|
+
}
|
|
501
|
+
if (lineNumber) {
|
|
502
|
+
updated.hash = lineNumber.toString();
|
|
503
|
+
}
|
|
504
|
+
return updated.toString();
|
|
505
|
+
}
|
|
506
|
+
resolveEditUrl(url) {
|
|
507
|
+
return url;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
let GerritIntegration = _GerritIntegration;
|
|
511
|
+
GerritIntegration.factory = ({ config }) => {
|
|
512
|
+
var _a;
|
|
513
|
+
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
514
|
+
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
515
|
+
};
|
|
516
|
+
|
|
449
517
|
const GITHUB_HOST = "github.com";
|
|
450
518
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
451
519
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
@@ -739,9 +807,7 @@ function readGitLabIntegrationConfig(config) {
|
|
|
739
807
|
} else {
|
|
740
808
|
baseUrl = `https://${host}`;
|
|
741
809
|
}
|
|
742
|
-
if (host
|
|
743
|
-
throw new Error(`Invalid GitLab integration config, host '${host}' should just be the host name (e.g. "github.com"), not a URL`);
|
|
744
|
-
} else if (!isValidHost(host)) {
|
|
810
|
+
if (!isValidHost(host)) {
|
|
745
811
|
throw new Error(`Invalid GitLab integration config, '${host}' is not a valid host`);
|
|
746
812
|
} else if (!apiBaseUrl || !isValidUrl(apiBaseUrl)) {
|
|
747
813
|
throw new Error(`Invalid GitLab integration config, '${apiBaseUrl}' is not a valid apiBaseUrl`);
|
|
@@ -815,7 +881,7 @@ async function getProjectId(target, config) {
|
|
|
815
881
|
}
|
|
816
882
|
try {
|
|
817
883
|
const repo = url.pathname.split("/-/blob/")[0];
|
|
818
|
-
const repoIDLookup = new URL(`${url.
|
|
884
|
+
const repoIDLookup = new URL(`${url.origin}/api/v4/projects/${encodeURIComponent(repo.replace(/^\//, ""))}`);
|
|
819
885
|
const response = await fetch__default["default"](repoIDLookup.toString(), getGitLabRequestOptions(config));
|
|
820
886
|
const data = await response.json();
|
|
821
887
|
if (!response.ok) {
|
|
@@ -946,6 +1012,7 @@ class ScmIntegrations {
|
|
|
946
1012
|
awsS3: AwsS3Integration.factory({ config }),
|
|
947
1013
|
azure: AzureIntegration.factory({ config }),
|
|
948
1014
|
bitbucket: BitbucketIntegration.factory({ config }),
|
|
1015
|
+
gerrit: GerritIntegration.factory({ config }),
|
|
949
1016
|
github: GitHubIntegration.factory({ config }),
|
|
950
1017
|
gitlab: GitLabIntegration.factory({ config })
|
|
951
1018
|
});
|
|
@@ -962,6 +1029,9 @@ class ScmIntegrations {
|
|
|
962
1029
|
get bitbucket() {
|
|
963
1030
|
return this.byType.bitbucket;
|
|
964
1031
|
}
|
|
1032
|
+
get gerrit() {
|
|
1033
|
+
return this.byType.gerrit;
|
|
1034
|
+
}
|
|
965
1035
|
get github() {
|
|
966
1036
|
return this.byType.github;
|
|
967
1037
|
}
|
|
@@ -997,6 +1067,7 @@ exports.AwsS3Integration = AwsS3Integration;
|
|
|
997
1067
|
exports.AzureIntegration = AzureIntegration;
|
|
998
1068
|
exports.BitbucketIntegration = BitbucketIntegration;
|
|
999
1069
|
exports.DefaultGithubCredentialsProvider = DefaultGithubCredentialsProvider;
|
|
1070
|
+
exports.GerritIntegration = GerritIntegration;
|
|
1000
1071
|
exports.GitHubIntegration = GitHubIntegration;
|
|
1001
1072
|
exports.GitLabIntegration = GitLabIntegration;
|
|
1002
1073
|
exports.GithubAppCredentialsMux = GithubAppCredentialsMux;
|
|
@@ -1021,6 +1092,8 @@ exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
|
|
|
1021
1092
|
exports.readAzureIntegrationConfigs = readAzureIntegrationConfigs;
|
|
1022
1093
|
exports.readBitbucketIntegrationConfig = readBitbucketIntegrationConfig;
|
|
1023
1094
|
exports.readBitbucketIntegrationConfigs = readBitbucketIntegrationConfigs;
|
|
1095
|
+
exports.readGerritIntegrationConfig = readGerritIntegrationConfig;
|
|
1096
|
+
exports.readGerritIntegrationConfigs = readGerritIntegrationConfigs;
|
|
1024
1097
|
exports.readGitHubIntegrationConfig = readGitHubIntegrationConfig;
|
|
1025
1098
|
exports.readGitHubIntegrationConfigs = readGitHubIntegrationConfigs;
|
|
1026
1099
|
exports.readGitLabIntegrationConfig = readGitLabIntegrationConfig;
|