UNPKG

@backstage/integration

Version:

Helpers for managing integrations towards external systems

104 lines (101 loc) 3.41 kB
import { AwsS3Integration } from './awsS3/AwsS3Integration.esm.js'; import { AwsCodeCommitIntegration } from './awsCodeCommit/AwsCodeCommitIntegration.esm.js'; import { AzureIntegration } from './azure/AzureIntegration.esm.js'; import { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegration.esm.js'; import { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration.esm.js'; import { GerritIntegration } from './gerrit/GerritIntegration.esm.js'; import { GithubIntegration } from './github/GithubIntegration.esm.js'; import { GitLabIntegration } from './gitlab/GitLabIntegration.esm.js'; import { defaultScmResolveUrl } from './helpers.esm.js'; import { GiteaIntegration } from './gitea/GiteaIntegration.esm.js'; import 'lodash'; import { HarnessIntegration } from './harness/HarnessIntegration.esm.js'; import { AzureBlobStorageIntegration } from './azureBlobStorage/AzureBlobStorageIntegration.esm.js'; import '@azure/identity'; import { GoogleGcsIntegration } from './googleGcs/GoogleGcsIntegration.esm.js'; class ScmIntegrations { byType; static fromConfig(config) { return new ScmIntegrations({ awsS3: AwsS3Integration.factory({ config }), awsCodeCommit: AwsCodeCommitIntegration.factory({ config }), azureBlobStorage: AzureBlobStorageIntegration.factory({ config }), azure: AzureIntegration.factory({ config }), bitbucketCloud: BitbucketCloudIntegration.factory({ config }), bitbucketServer: BitbucketServerIntegration.factory({ config }), gerrit: GerritIntegration.factory({ config }), github: GithubIntegration.factory({ config }), gitlab: GitLabIntegration.factory({ config }), gitea: GiteaIntegration.factory({ config }), googleGcs: GoogleGcsIntegration.factory({ config }), harness: 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; } 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 googleGcs() { return this.byType.googleGcs; } get harness() { return this.byType.harness; } list() { return Object.values(this.byType).flatMap( (i) => i.list() ); } byUrl(url) { const candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean); 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 defaultScmResolveUrl(options); } return integration.resolveUrl(options); } resolveEditUrl(url) { const integration = this.byUrl(url); if (!integration) { return url; } return integration.resolveEditUrl(url); } } export { ScmIntegrations }; //# sourceMappingURL=ScmIntegrations.esm.js.map