import { CommandModule } from 'yargs'; import { registerPilet, validateArgs } from './register-pilet'; import { GetRegisterPiletOptions } from './register-pilet-options'; export const piletCommands: CommandModule = { builder: (yargs) => yargs .command( 'register', 'Register a pilet in Mosaic Micro Frontend Service.', piletRegister, ) .demandCommand(), handler: () => { console.log('Please pick an action related to hosting pilet command.'); }, }; const piletRegister: CommandModule = { builder: (yargs) => { return yargs .option('serviceId', { describe: 'Service ID the pilet should be registered to', alias: 'i', string: true, }) .option('mosaicHostingClientId', { describe: 'Client ID to authenticate', alias: 'c', string: true, }) .option('mosaicHostingClientSecret', { describe: 'Client Secret to authenticate', alias: 's', string: true, }) .option('piletArtifactPath', { describe: 'Path to the pilet artifact .tgz file or a directory containing the .tgz file', alias: 'p', string: true, }) .option('idServiceAuthBaseURL', { describe: 'ID Service Authentication Endpoint Base URL', alias: 'a', string: true, }) .option('microFrontendServiceBaseURL', { describe: 'Micro Frontend Service Base URL', alias: 'm', string: true, }) .option('overrideRegistration', { describe: 'Override registration', alias: 'o', default: false, boolean: true, }); }, handler: async (args) => { // Validate arguments and read any arguments that are coming from environment variables. const [validatedArgs, errorMessages] = validateArgs(args); if (errorMessages.length > 0) { console.log(errorMessages); } else { await registerPilet(validatedArgs); } }, };