// Import config
import config from '../helpers/config';

// Import helpers
import showChooser from '../helpers/showChooser';

// Import shared types
import Deployment from '../types/Deployment';

/**
 * Ask user to choose a deployment
 * @author Gabe Abrams
 * @returns deployment instance
 */
const chooseDeployment = (): Deployment => {
  // Create options
  const options = config.deployments.map((deployment) => {
    return {
      description: deployment.name,
    };
  });

  // Show chooser
  const { index } = showChooser({
    question: 'Choose a deployment service:',
    options,
  });

  // Get the deployment from the list and return it
  return config.deployments[index];
};

export default chooseDeployment;
