import { CommandModule } from 'yargs'; import { uploadDeploymentManifest, validateArgs } from './upload-manifest'; import { GetUploadManifestOptions } from './upload-manifest-options'; export const manifestCommands: CommandModule = { builder: (yargs) => yargs .command( 'upload', 'Upload a Deployment Manifest against a Service ID to the Hosting Service.', manifestUpload, ) .demandCommand(), handler: () => { console.log('Please pick an action related to hosting manifest command.'); }, }; const manifestUpload: CommandModule = { builder: (yargs) => { return yargs .option('name', { describe: 'Name of the Deployment Manifest', alias: 'n', string: true, demandOption: true, }) .option('serviceId', { describe: 'Service ID the Deployment Manifest should be registered to', alias: 'i', 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('deploymentManifestPath', { describe: 'Deployment Manifest Path', alias: 'p', string: true, default: './mosaic-hosting-deployment-manifest.yaml', }) .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] = validateArgs(args); if (errorMessages.length > 0) { console.log(errorMessages); } else { await uploadDeploymentManifest(validatedArgs); } }, };