UNPKG

zcatalyst-cli

Version:

Command Line Tool for CATALYST

59 lines (58 loc) 3.03 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 ansi_colors_1 = require("ansi-colors"); const apig_utils_1 = require("../../apig-utils"); const endpoints_1 = require("../../endpoints"); const index_js_1 = __importDefault(require("../../error/index.js")); const runtime_store_1 = __importDefault(require("../../runtime-store")); const config_1 = require("../../util_modules/config"); const constants_1 = require("../../util_modules/constants"); const index_1 = require("../../util_modules/logger/index"); exports.default = () => __awaiter(void 0, void 0, void 0, function* () { const api = yield (0, endpoints_1.apigAPI)(); const response = (yield api.getAPIGStatus()); if (response.scheduled) { (0, index_1.labeled)('apig', 'Skipping deploy since previous schedule is not over yet.').ERROR(); (0, index_1.labeled)('apig', 'You can deploy apig separately using "--only apig" option next time.').MESSAGE(); return; } if (config_1.apigConfig.enabled(null) === null) { throw new index_js_1.default('Skipping deploy, since unable to detect the status of API Gateway from ' + constants_1.FILENAME.config, { exit: 2 }); } if (!config_1.apigConfig.enabled()) { if (response.status) { yield api.updateAPIGStatus(false); (0, index_1.labeled)('apig', 'Disabled successfully').SUCCESS(); } throw new index_js_1.default('APIG not enabled locally', { errorId: 'APIG-1', arg: [(0, ansi_colors_1.bold)('catalyst apig:enable')], exit: 0 }); } if (config_1.apigConfig.enabled() && !response.status) { yield api.updateAPIGStatus(true); (0, index_1.labeled)('apig', 'Enabled successfully').SUCCESS(); } yield apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'deploy' }); yield apig_utils_1.apigUtils.validate(); const readStream = yield apig_utils_1.apigUtils.pack(); yield api.deploy(readStream); runtime_store_1.default.set('context.payload.apig.deploy', true); yield apig_utils_1.apigUtils.executeHook({ prefix: 'post', command: 'deploy' }); });