@backstage/integration 0.8.0 → 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 +12 -0
- package/config.d.ts +25 -0
- package/dist/index.cjs.js +70 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.esm.js +68 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
3
15
|
## 0.8.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
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
|
@@ -451,6 +451,69 @@ function getBitbucketRequestOptions(config) {
|
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
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
|
+
|
|
454
517
|
const GITHUB_HOST = "github.com";
|
|
455
518
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
456
519
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
@@ -949,6 +1012,7 @@ class ScmIntegrations {
|
|
|
949
1012
|
awsS3: AwsS3Integration.factory({ config }),
|
|
950
1013
|
azure: AzureIntegration.factory({ config }),
|
|
951
1014
|
bitbucket: BitbucketIntegration.factory({ config }),
|
|
1015
|
+
gerrit: GerritIntegration.factory({ config }),
|
|
952
1016
|
github: GitHubIntegration.factory({ config }),
|
|
953
1017
|
gitlab: GitLabIntegration.factory({ config })
|
|
954
1018
|
});
|
|
@@ -965,6 +1029,9 @@ class ScmIntegrations {
|
|
|
965
1029
|
get bitbucket() {
|
|
966
1030
|
return this.byType.bitbucket;
|
|
967
1031
|
}
|
|
1032
|
+
get gerrit() {
|
|
1033
|
+
return this.byType.gerrit;
|
|
1034
|
+
}
|
|
968
1035
|
get github() {
|
|
969
1036
|
return this.byType.github;
|
|
970
1037
|
}
|
|
@@ -1000,6 +1067,7 @@ exports.AwsS3Integration = AwsS3Integration;
|
|
|
1000
1067
|
exports.AzureIntegration = AzureIntegration;
|
|
1001
1068
|
exports.BitbucketIntegration = BitbucketIntegration;
|
|
1002
1069
|
exports.DefaultGithubCredentialsProvider = DefaultGithubCredentialsProvider;
|
|
1070
|
+
exports.GerritIntegration = GerritIntegration;
|
|
1003
1071
|
exports.GitHubIntegration = GitHubIntegration;
|
|
1004
1072
|
exports.GitLabIntegration = GitLabIntegration;
|
|
1005
1073
|
exports.GithubAppCredentialsMux = GithubAppCredentialsMux;
|
|
@@ -1024,6 +1092,8 @@ exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
|
|
|
1024
1092
|
exports.readAzureIntegrationConfigs = readAzureIntegrationConfigs;
|
|
1025
1093
|
exports.readBitbucketIntegrationConfig = readBitbucketIntegrationConfig;
|
|
1026
1094
|
exports.readBitbucketIntegrationConfigs = readBitbucketIntegrationConfigs;
|
|
1095
|
+
exports.readGerritIntegrationConfig = readGerritIntegrationConfig;
|
|
1096
|
+
exports.readGerritIntegrationConfigs = readGerritIntegrationConfigs;
|
|
1027
1097
|
exports.readGitHubIntegrationConfig = readGitHubIntegrationConfig;
|
|
1028
1098
|
exports.readGitHubIntegrationConfigs = readGitHubIntegrationConfigs;
|
|
1029
1099
|
exports.readGitLabIntegrationConfig = readGitLabIntegrationConfig;
|