import * as yargs from 'yargs'; import { applyTemplates } from '../commands/apply-templates'; import { createExtensionConfigCommand, getExtensions, } from '../commands/create-extension-config'; import { createSolutionCommand } from '../commands/create/command'; import { getAccessToken } from '../commands/get-access-token'; import { graphqlDiff } from '../commands/graphql-diff'; import { hosting } from '../commands/hosting'; import { msgCodegen } from '../commands/msg-codegen'; import { msgDiff } from '../commands/msg-diff'; import { pgDump } from '../commands/pg-dump'; import { publishSchemaToDb } from '../commands/publish-schema-to-db'; import { service } from '../commands/service'; import { unpublishPilet } from '../commands/unpublish-pilet'; export const run = async (): Promise => { yargs .scriptName('mosaic') .env() .command(applyTemplates) .command(getAccessToken) .command(publishSchemaToDb) .command(pgDump) .command(msgCodegen) .command(msgDiff) .command(createExtensionConfigCommand) .command(graphqlDiff) .command(hosting) .command(unpublishPilet) .command(service) .command(createSolutionCommand); //adding cli extensions: await Promise.all( getExtensions().map(async (library) => { try { const { cliExtension } = await import(library); if (cliExtension) { cliExtension().map((cmd) => { yargs.command(cmd); }); } } catch (error) { //package is either not installed, or doesn't have cli extension } }), ); yargs .demandCommand() .help() .epilog(`For more information, visit https://portal.axinom.com.`).argv; };