UNPKG

zcatalyst-cli

Version:

Command Line Tool for CATALYST

45 lines (44 loc) 2.28 kB
'use strict'; 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 index_js_1 = __importDefault(require("../error/index.js")); const runtime_store_1 = __importDefault(require("../runtime-store")); const index_1 = require("../util_modules/logger/index"); const features_1 = __importDefault(require("./features")); function deploy({ feature = '', error = [] } = {}) { return __awaiter(this, void 0, void 0, function* () { const deployTargets = runtime_store_1.default.get('context.targets', feature ? [feature] : []); if (deployTargets.length === 0) { return error; } const currentTarget = deployTargets.shift(); if (currentTarget === undefined) { return deploy({ error }); } const featureModule = features_1.default[currentTarget]; try { runtime_store_1.default.set('context.payload.targets', runtime_store_1.default.get('context.payload.targets', []).concat(currentTarget)); yield featureModule(feature ? true : false); } catch (e) { const err = index_js_1.default.getErrorInstance(e); (0, index_1.debug)(`${currentTarget} deploy unsuccessful, reason : ${err.stack}`); (0, index_1.labeled)(currentTarget, err.message).WARN(); error.push(err); return deploy({ error }); } return deploy({ error }); }); } exports.default = deploy;