UNPKG

dce-dev-wizard

Version:

Wizard for managing development apps at Harvard DCE.

70 lines 3.25 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 clear_1 = __importDefault(require("clear")); // Import helpers const getDeploymentConfig_1 = __importDefault(require("../operations/getDeploymentConfig")); const print_1 = __importDefault(require("../helpers/print")); const prompt_1 = __importDefault(require("../helpers/prompt")); const exec_1 = __importDefault(require("../helpers/exec")); /** * Choose the number of instances (tasks) for the deployment * @author Gabe Abrams * @param deployment the currently selected deployment */ const setNumInstances = (deployment) => __awaiter(void 0, void 0, void 0, function* () { var _a; // Show loading indicator (0, clear_1.default)(); console.log('Loading chosen number of instances...\n'); // Get environment variables const deployConfig = (0, getDeploymentConfig_1.default)(deployment); // Check the number of instances const taskCount = (_a = deployConfig.taskCount) !== null && _a !== void 0 ? _a : 1; // Print status (0, clear_1.default)(); print_1.default.subtitle('Num Tasks for Deployment:'); console.log(`Current num tasks to deploy: ${taskCount}`); console.log(''); console.log('New num tasks (leave empty to leave as-is):'); const newTaskCount = String((0, prompt_1.default)('> ', true)).trim(); // Immediately go back if no new value if (newTaskCount.length === 0) { return; } // Check that it's a valid number const newTaskCountNum = Number.parseInt(newTaskCount, 10); if (Number.isNaN(newTaskCountNum) || newTaskCountNum < 0) { (0, clear_1.default)(); print_1.default.title('Invalid Number of Tasks'); console.log(''); print_1.default.enterToContinue(); return; } // Update the configuration (0, clear_1.default)(); console.log('Updating config...\n'); (0, exec_1.default)(`./node_modules/.bin/caccl-deploy update --profile ${deployment.profile} --app ${deployment.app} taskCount "${newTaskCountNum}"`, true); // Wait extra for caccl deploy yield new Promise((resolve) => { setTimeout(resolve, 2000); }); // Confirm success (0, clear_1.default)(); print_1.default.title(`Number of Tasks Updated Successfully`); console.log(''); print_1.default.enterToContinue(); }); exports.default = setNumInstances; //# sourceMappingURL=setNumInstances.js.map