zcatalyst-cli
Version:
Command Line Tool for CATALYST
35 lines (34 loc) • 1.99 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const runtime_store_1 = __importDefault(require("../runtime-store"));
const constants_1 = require("../util_modules/constants");
const js_1 = require("../util_modules/js");
exports.default = (eventJson) => __awaiter(void 0, void 0, void 0, function* () {
const repoName = js_1.JS.randomString(5);
const displayName = runtime_store_1.default.get('user.Display_Name');
const data = {
archive_url: `https://api.github.com/repos/${displayName}/${repoName}/`,
full_name: `${displayName}/${repoName}`,
clone_url: `https://github.com/${displayName}/${repoName}.git`,
name: `${repoName}`,
created_at: Date.now(),
deployment_status: 'none',
default_branch: 'master',
id: js_1.JS.randomNumber(15)
};
eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.source_id, 'g'), 'NULL');
eventJson = eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.rule_id, 'g'), 'NULL');
return eventJson.replace(new RegExp(constants_1.PLACEHOLDER.event_data.data, 'g'), JSON.stringify(data));
});