| 26 | export interface BaseCommand<CommandArgs extends BaseArgs = BaseArgs> extends CommandModule<BaseArgs, CommandArgs> {} |
| 27 | |
| 28 | function createBasicConfig(): Argv<{ config: string[] | undefined; contextName: string }> { |
| 29 | return yargs() |
| 30 | .scriptName('mikro-orm') |
| 31 | .usage('Usage: $0 <command> [options]') |
| 32 | .example('$0 debug', 'Show debugging information') |
| 33 | .example('$0 schema:update --run', 'Runs schema synchronization') |
| 34 | .option('config', { |
| 35 | type: 'string', |
| 36 | array: true, |
| 37 | desc: `Set path to the ORM configuration file`, |
| 38 | }) |
| 39 | .option('contextName', { |
| 40 | alias: 'context', |
| 41 | type: 'string', |
| 42 | desc: 'Set name of config to load out of the ORM configuration file. Used when config file exports an array or a function', |
| 43 | default: process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default', |
| 44 | }) |
| 45 | .alias('v', 'version') |
| 46 | .alias('h', 'help') |
| 47 | .recommendCommands() |
| 48 | .showHelpOnFail(true) |
| 49 | .demandCommand(1, '') |
| 50 | .strict(); |
| 51 | } |
| 52 | |
| 53 | export async function configure(): Promise<Argv<{ config: string[] | undefined; contextName: string }>> { |
| 54 | fs.checkPackageVersion(); |