import { red, yellow } from 'chalk'; import { CommandModule } from 'yargs'; import { deployService, validateDeploymentArgs } from './service-deploy'; import { GetServiceDeployOptions } from './service-deploy-options'; export const serviceDeploy: CommandModule = { builder: (yargs) => { return yargs .option('name', { describe: 'Name of the Deployment', alias: 'n', string: true, demandOption: true, }) .option('serviceId', { describe: 'Service ID the deployment must be done for. (If a deployment manifest is found in the current directory, the serviceId will be derived from it.)', alias: 'i', string: true, }) .option('containerImageTag', { describe: 'Tag of the container image to be used in the deployment. i.e: It should be the from the container image format /:.', alias: 't', string: true, demandOption: true, }) .option('manifestName', { describe: 'Name of the deployment manifest', alias: 'm', string: true, demandOption: true, }) .option('pilets', { describe: 'Pilet(s) to be used in the deployment. The pilet name should match the format package-name@version => media-workflows@1.5.7', alias: 'p', array: true, string: true, }) .option('mosaicHostingClientId', { describe: 'Service Account Client ID to authenticate', alias: 'c', string: true, }) .option('mosaicHostingClientSecret', { describe: 'Service Account Client Secret to authenticate', alias: 's', string: true, }) .option('idServiceAuthBaseURL', { describe: 'ID Service Authentication Endpoint Base URL', alias: 'a', string: true, }) .option('hostingServiceBaseURL', { describe: 'Hosting Service Base URL', alias: 'h', string: true, }); }, handler: async (args) => { const [validatedArgs, errorMessages] = validateDeploymentArgs(args); if (errorMessages.length > 0) { console.log(red('Some required arguments are missing.')); console.log(yellow(errorMessages)); console.log(); } else { await deployService(validatedArgs); } }, };