@backstage/integration
Version:
Helpers for managing integrations towards external systems
117 lines (113 loc) • 4.03 kB
JavaScript
'use strict';
var AwsS3Integration = require('./awsS3/AwsS3Integration.cjs.js');
var AwsCodeCommitIntegration = require('./awsCodeCommit/AwsCodeCommitIntegration.cjs.js');
var AzureIntegration = require('./azure/AzureIntegration.cjs.js');
var BitbucketCloudIntegration = require('./bitbucketCloud/BitbucketCloudIntegration.cjs.js');
var BitbucketIntegration = require('./bitbucket/BitbucketIntegration.cjs.js');
var BitbucketServerIntegration = require('./bitbucketServer/BitbucketServerIntegration.cjs.js');
var GerritIntegration = require('./gerrit/GerritIntegration.cjs.js');
var GithubIntegration = require('./github/GithubIntegration.cjs.js');
var GitLabIntegration = require('./gitlab/GitLabIntegration.cjs.js');
var helpers = require('./helpers.cjs.js');
var GiteaIntegration = require('./gitea/GiteaIntegration.cjs.js');
require('lodash');
var HarnessIntegration = require('./harness/HarnessIntegration.cjs.js');
var AzureBlobStorageIntegration = require('./azureBlobStorage/AzureBlobStorageIntegration.cjs.js');
require('@azure/identity');
class ScmIntegrations {
byType;
static fromConfig(config) {
return new ScmIntegrations({
awsS3: AwsS3Integration.AwsS3Integration.factory({ config }),
awsCodeCommit: AwsCodeCommitIntegration.AwsCodeCommitIntegration.factory({ config }),
azureBlobStorage: AzureBlobStorageIntegration.AzureBlobStorageIntergation.factory({ config }),
azure: AzureIntegration.AzureIntegration.factory({ config }),
bitbucket: BitbucketIntegration.BitbucketIntegration.factory({ config }),
bitbucketCloud: BitbucketCloudIntegration.BitbucketCloudIntegration.factory({ config }),
bitbucketServer: BitbucketServerIntegration.BitbucketServerIntegration.factory({ config }),
gerrit: GerritIntegration.GerritIntegration.factory({ config }),
github: GithubIntegration.GithubIntegration.factory({ config }),
gitlab: GitLabIntegration.GitLabIntegration.factory({ config }),
gitea: GiteaIntegration.GiteaIntegration.factory({ config }),
harness: HarnessIntegration.HarnessIntegration.factory({ config })
});
}
constructor(integrationsByType) {
this.byType = integrationsByType;
}
get awsS3() {
return this.byType.awsS3;
}
get awsCodeCommit() {
return this.byType.awsCodeCommit;
}
get azureBlobStorage() {
return this.byType.azureBlobStorage;
}
get azure() {
return this.byType.azure;
}
/**
* @deprecated in favor of `bitbucketCloud()` and `bitbucketServer()`
*/
get bitbucket() {
return this.byType.bitbucket;
}
get bitbucketCloud() {
return this.byType.bitbucketCloud;
}
get bitbucketServer() {
return this.byType.bitbucketServer;
}
get gerrit() {
return this.byType.gerrit;
}
get github() {
return this.byType.github;
}
get gitlab() {
return this.byType.gitlab;
}
get gitea() {
return this.byType.gitea;
}
get harness() {
return this.byType.harness;
}
list() {
return Object.values(this.byType).flatMap(
(i) => i.list()
);
}
byUrl(url) {
let candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean);
if (candidates.length > 1) {
const filteredCandidates = candidates.filter(
(x) => !(x instanceof BitbucketIntegration.BitbucketIntegration)
);
if (filteredCandidates.length !== 0) {
candidates = filteredCandidates;
}
}
return candidates[0];
}
byHost(host) {
return Object.values(this.byType).map((i) => i.byHost(host)).find(Boolean);
}
resolveUrl(options) {
const integration = this.byUrl(options.base);
if (!integration) {
return helpers.defaultScmResolveUrl(options);
}
return integration.resolveUrl(options);
}
resolveEditUrl(url) {
const integration = this.byUrl(url);
if (!integration) {
return url;
}
return integration.resolveEditUrl(url);
}
}
exports.ScmIntegrations = ScmIntegrations;
//# sourceMappingURL=ScmIntegrations.cjs.js.map