@nu-art/bug-report
Version:
49 lines (48 loc) • 2.29 kB
JavaScript
;
/*
* Allow the user to file a bug report directly from your app
*
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.JiraBugReportIntegrator = exports.JiraBugReportIntegrator_Class = void 0;
const ts_common_1 = require("@nu-art/ts-common");
const backend_1 = require("@nu-art/jira/backend");
const __1 = require("../..");
class JiraBugReportIntegrator_Class extends ts_common_1.Module {
constructor() {
super(...arguments);
this.parser = (name) => `Bug: ${name}`;
this.openTicket = async (bugReport, logs, reporter) => {
if (bugReport.platforms && !bugReport.platforms.includes(__1.Platform_Jira))
return;
if (!this.config.jiraProject)
throw new ts_common_1.ImplementationMissingException('missing Jira project in bug report configurations');
const description = logs.reduce((carry, log, i) => {
carry.push({ href: log.path, text: '\nClick to view logs (' + i + ')' });
return carry;
}, [bugReport.description]);
if (reporter)
description.push('\nReported by: ' + reporter);
const issue = await backend_1.JiraModule.issue.create(this.config.jiraProject, this.config.issueType, this.parser(bugReport.subject), description, this.config.label.label);
return { platform: __1.Platform_Jira, issueId: issue.url };
};
}
setIssueTitleProcessor(parser) {
this.parser = parser;
}
}
exports.JiraBugReportIntegrator_Class = JiraBugReportIntegrator_Class;
exports.JiraBugReportIntegrator = new JiraBugReportIntegrator_Class();