dce-dev-wizard
Version:
Wizard for managing development apps at Harvard DCE.
88 lines (79 loc) • 2.28 kB
text/typescript
// Import libs
import clear from 'clear';
// Import shared types
import Deployment from './types/Deployment';
// Import screens
import chooseDeployment from './screens/chooseDeployment';
import showChooser from './helpers/showChooser';
import showModifyEnvVars from './screens/showModifyEnvVars';
import chooseTarget from './screens/chooseTarget';
import deployNow from './screens/deployNow';
import viewLogs from './screens/viewLogs';
import connectToDatabase from './screens/connectToDatabase';
import relatedClusters from './screens/relatedClusters';
/* eslint-disable no-console */
/**
* Show the wizard
* @author Gabe Abrams
*/
const showWizard = async () => {
// The current chosen deployment
let deployment: Deployment = chooseDeployment();
// Endless work loop
while (true) {
clear();
// Ask user to choose a menu option
const menuOption = showChooser({
question: 'What do you want to show/modify?',
options: [
{
description: 'Environment Vars',
tag: 'E',
},
{
description: 'Target of Deployment (version or branch)',
tag: 'T',
},
{
description: 'Deploy/Redeploy',
tag: 'D',
},
{
description: 'Switch Deployment',
tag: 'S',
},
{
description: 'Log Viewer (App Logs from Today)',
tag: 'L',
},
{
description: 'Related Clusters',
tag: 'R',
},
{
description: 'Connect to database',
tag: 'C',
},
],
title: `${deployment.name} | Main Menu`,
});
// Handle each case
if (menuOption.tag === 'E') {
await showModifyEnvVars(deployment);
} else if (menuOption.tag === 'T') {
await chooseTarget(deployment);
} else if (menuOption.tag === 'D') {
await deployNow(deployment);
} else if (menuOption.tag === 'S') {
deployment = await chooseDeployment();
} else if (menuOption.tag === 'L') {
await viewLogs(deployment);
} else if (menuOption.tag === 'R') {
await relatedClusters(deployment);
} else if (menuOption.tag === 'C') {
await connectToDatabase(deployment);
}
}
};
// Start
showWizard();