@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
60 lines (59 loc) • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.commandSecurityAuditCreate = void 0;
const defineCommand_1 = require("../../core/defineCommand");
const rest_1 = require("@gitbeaker/rest");
const createSecurityAuditMergeRequest_1 = require("../../security/createSecurityAuditMergeRequest");
const GITLAB_HOST = "https://git.panter.ch";
exports.commandSecurityAuditCreate = (0, defineCommand_1.defineCommand)({
name: "security audit create",
description: "Creates a MR with the latest security audit template document",
group: "security",
inputs: {
token: {
type: "string",
message: "GitLab token (api scope)",
positional: true
},
mainBranch: {
type: "string",
message: "main branch name",
positional: true
},
projectId: {
type: "string",
message: "GitLab project ID",
positional: true
},
userId: {
type: "string",
message: "GitLab user ID (assignee)",
positional: true
}
},
execute: async ctx => {
const token = await ctx.get("token");
const mainBranch = await ctx.get("mainBranch");
const projectId = await ctx.get("projectId");
const userId = await ctx.get("userId");
const api = new rest_1.Gitlab({
host: GITLAB_HOST,
token
});
const result = await (0, createSecurityAuditMergeRequest_1.createSecurityAuditMergeRequest)({
api,
mainBranch,
projectId,
userId: parseInt(userId)
});
if (result.isErr()) {
ctx.log(`could not create security audit merge request: ${result.error}`);
process.exitCode = 1;
} else {
ctx.log("security audit merge request created successfully");
ctx.log(`please finish the MR by updating SECURITY.md document: ${result.value.web_url}`);
}
}
});