zcatalyst-cli
Version:
Command Line Tool for CATALYST
47 lines (46 loc) • 2.3 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 ansi_colors_1 = require("ansi-colors");
const endpoints_1 = require("../../endpoints");
const index_js_1 = __importDefault(require("../../error/index.js"));
const command_1 = __importDefault(require("../../internal/command"));
const runtime_store_1 = __importDefault(require("../../runtime-store"));
const scopes_js_1 = __importDefault(require("../../authentication/constants/scopes.js"));
const index_1 = require("../../util_modules/logger/index");
exports.default = new command_1.default('apig:enable')
.description('Enable API Gateway for your project')
.needs('auth', [scopes_js_1.default.projects])
.needs('config')
.needs('rc')
.action(() => __awaiter(void 0, void 0, void 0, function* () {
const api = yield (0, endpoints_1.apigAPI)();
const response = (yield api.getAPIGStatus());
(0, index_1.info)();
if (response.scheduled) {
throw new index_js_1.default('Scheduler in progress', {
exit: 0,
errorId: 'EN-1',
arg: [(0, ansi_colors_1.bold)('catalyst apig:status')]
});
}
if (!response.status) {
yield api.updateAPIGStatus(true);
}
const config = runtime_store_1.default.get('config');
(0, index_1.info)('Updating local config');
config.set('apig.enabled', true);
yield config.save();
(0, index_1.success)('Catalyst API Gateway successfully enabled!');
}));