@backstage/integration
Version:
Helpers for managing integrations towards external systems
59 lines (55 loc) • 1.65 kB
JavaScript
;
var helpers = require('../helpers.cjs.js');
var config = require('./config.cjs.js');
class AwsCodeCommitIntegration {
constructor(integrationConfig) {
this.integrationConfig = integrationConfig;
}
static factory = ({
config: config$1
}) => {
const configs = config.readAwsCodeCommitIntegrationConfigs(
config$1.getOptionalConfigArray("integrations.awsCodeCommit") ?? []
);
return helpers.basicIntegrations(
configs.map((c) => new AwsCodeCommitIntegration(c)),
(i) => i.config.host
);
};
get type() {
return "awsCodeCommit";
}
get config() {
return this.integrationConfig;
}
get title() {
return this.integrationConfig.host;
}
resolveUrl(options) {
const resolved = helpers.defaultScmResolveUrl(options);
return resolved;
}
resolveEditUrl(url) {
const parsedUrl = new URL(url);
const pathMatch = parsedUrl.pathname.match(
/^\/codesuite\/codecommit\/repositories\/([^\/]+)\//
);
if (!pathMatch) {
throw new Error(``);
}
const [, repositoryName] = pathMatch;
return replaceCodeCommitUrlType(url, repositoryName);
}
}
function replaceCodeCommitUrlType(url, repositoryName, type) {
const newString = `files/edit` ;
return url.replace(
new RegExp(
`/codesuite/codecommit/repositories/${repositoryName}/(browse|files/edit)/`
),
`/codesuite/codecommit/repositories/${repositoryName}/${newString}/`
);
}
exports.AwsCodeCommitIntegration = AwsCodeCommitIntegration;
exports.replaceCodeCommitUrlType = replaceCodeCommitUrlType;
//# sourceMappingURL=AwsCodeCommitIntegration.cjs.js.map