UNPKG

dce-dev-wizard

Version:

Wizard for managing development apps at Harvard DCE.

55 lines 2.57 kB
"use strict"; 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")); /** * Show and/or modify the deployed branch name or version number * @author Gabe Abrams * @param deployment the currently selected deployment */ const chooseBranch = (deployment) => { // Show loading indicator (0, clear_1.default)(); console.log('Loading current target of deployment...\n'); // Get environment variables const deployConfig = (0, getDeploymentConfig_1.default)(deployment); // Get last part of the app image const parts = deployConfig.appImage.split(':'); const branchOrVersion = parts[parts.length - 1]; const appImagePrefix = deployConfig.appImage.substring(0, deployConfig.appImage.length - branchOrVersion.length); // Check type const isVersion = branchOrVersion.includes('.'); // Process branch name const processedBranchName = branchOrVersion.replace('-', '/'); // Print status (0, clear_1.default)(); print_1.default.subtitle('Target of Deployment:'); console.log(`Current deployment target: ${isVersion ? `version "${branchOrVersion}" on main branch` : `"${processedBranchName}" branch`}`); console.log(''); console.log('Enter a new branch name or version number (leave empty to go back):'); const newBranchOrVersion = String((0, prompt_1.default)('> ', true)).trim().replace('/', '-'); // Immediately go back if no new branch name if (newBranchOrVersion.length === 0) { return; } // Build a new app image const newAppImage = `${appImagePrefix}${newBranchOrVersion}`; // Update the configuration (0, clear_1.default)(); console.log('Working...\n'); (0, exec_1.default)(`./node_modules/.bin/caccl-deploy update --profile ${deployment.profile} --app ${deployment.app} appImage "${newAppImage}"`, true); // Confirmation (0, clear_1.default)(); print_1.default.title('Target of Deployment Updated Successfully'); console.log(''); print_1.default.enterToContinue(); }; exports.default = chooseBranch; //# sourceMappingURL=chooseTarget.js.map