@mikro-orm/cli 7.0.4 → 7.0.5-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,15 +6,14 @@ export type BaseArgs = Awaited<ReturnType<typeof createBasicConfig>['argv']>;
6
6
  /**
7
7
  * @internal
8
8
  */
9
- export interface BaseCommand<CommandArgs extends BaseArgs = BaseArgs> extends CommandModule<BaseArgs, CommandArgs> {}
9
+ export interface BaseCommand<CommandArgs extends BaseArgs = BaseArgs> extends CommandModule<BaseArgs, CommandArgs> {
10
+ }
10
11
  declare function createBasicConfig(): Argv<{
11
- config: string[] | undefined;
12
- contextName: string;
12
+ config: string[] | undefined;
13
+ contextName: string;
13
14
  }>;
14
- export declare function configure(): Promise<
15
- Argv<{
15
+ export declare function configure(): Promise<Argv<{
16
16
  config: string[] | undefined;
17
17
  contextName: string;
18
- }>
19
- >;
18
+ }>>;
20
19
  export {};
@@ -14,60 +14,60 @@ import { MigrationCommandFactory } from './commands/MigrationCommandFactory.js';
14
14
  import { SchemaCommandFactory } from './commands/SchemaCommandFactory.js';
15
15
  import { CLIHelper } from './CLIHelper.js';
16
16
  function createBasicConfig() {
17
- return yargs()
18
- .scriptName('mikro-orm')
19
- .usage('Usage: $0 <command> [options]')
20
- .example('$0 debug', 'Show debugging information')
21
- .example('$0 schema:update --run', 'Runs schema synchronization')
22
- .option('config', {
23
- type: 'string',
24
- array: true,
25
- desc: `Set path to the ORM configuration file`,
17
+ return yargs()
18
+ .scriptName('mikro-orm')
19
+ .usage('Usage: $0 <command> [options]')
20
+ .example('$0 debug', 'Show debugging information')
21
+ .example('$0 schema:update --run', 'Runs schema synchronization')
22
+ .option('config', {
23
+ type: 'string',
24
+ array: true,
25
+ desc: `Set path to the ORM configuration file`,
26
26
  })
27
- .option('contextName', {
28
- alias: 'context',
29
- type: 'string',
30
- desc: 'Set name of config to load out of the ORM configuration file. Used when config file exports an array or a function',
31
- default: process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default',
27
+ .option('contextName', {
28
+ alias: 'context',
29
+ type: 'string',
30
+ desc: 'Set name of config to load out of the ORM configuration file. Used when config file exports an array or a function',
31
+ default: process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default',
32
32
  })
33
- .alias('v', 'version')
34
- .alias('h', 'help')
35
- .recommendCommands()
36
- .showHelpOnFail(true)
37
- .demandCommand(1, '')
38
- .strict();
33
+ .alias('v', 'version')
34
+ .alias('h', 'help')
35
+ .recommendCommands()
36
+ .showHelpOnFail(true)
37
+ .demandCommand(1, '')
38
+ .strict();
39
39
  }
40
40
  export async function configure() {
41
- fs.checkPackageVersion();
42
- const settings = CLIHelper.getSettings();
43
- const version = Utils.getORMVersion();
44
- if (settings.preferTs !== false) {
45
- const preferTs = await CLIHelper.registerTypeScriptSupport(settings.tsConfigPath, settings.tsLoader);
46
- /* v8 ignore next */
47
- if (!preferTs) {
48
- process.env.MIKRO_ORM_CLI_PREFER_TS ??= '0';
41
+ fs.checkPackageVersion();
42
+ const settings = CLIHelper.getSettings();
43
+ const version = Utils.getORMVersion();
44
+ if (settings.preferTs !== false) {
45
+ const preferTs = await CLIHelper.registerTypeScriptSupport(settings.tsConfigPath, settings.tsLoader);
46
+ /* v8 ignore next */
47
+ if (!preferTs) {
48
+ process.env.MIKRO_ORM_CLI_PREFER_TS ??= '0';
49
+ }
49
50
  }
50
- }
51
- return createBasicConfig()
52
- .version(version)
53
- .command(new ClearCacheCommand())
54
- .command(new GenerateCacheCommand())
55
- .command(new CompileCommand())
56
- .command(new GenerateEntitiesCommand())
57
- .command(new CreateDatabaseCommand())
58
- .command(new ImportCommand())
59
- .command(new DatabaseSeedCommand())
60
- .command(new CreateSeederCommand())
61
- .command(SchemaCommandFactory.create('create'))
62
- .command(SchemaCommandFactory.create('drop'))
63
- .command(SchemaCommandFactory.create('update'))
64
- .command(SchemaCommandFactory.create('fresh'))
65
- .command(MigrationCommandFactory.create('create'))
66
- .command(MigrationCommandFactory.create('up'))
67
- .command(MigrationCommandFactory.create('down'))
68
- .command(MigrationCommandFactory.create('list'))
69
- .command(MigrationCommandFactory.create('check'))
70
- .command(MigrationCommandFactory.create('pending'))
71
- .command(MigrationCommandFactory.create('fresh'))
72
- .command(new DebugCommand());
51
+ return createBasicConfig()
52
+ .version(version)
53
+ .command(new ClearCacheCommand())
54
+ .command(new GenerateCacheCommand())
55
+ .command(new CompileCommand())
56
+ .command(new GenerateEntitiesCommand())
57
+ .command(new CreateDatabaseCommand())
58
+ .command(new ImportCommand())
59
+ .command(new DatabaseSeedCommand())
60
+ .command(new CreateSeederCommand())
61
+ .command(SchemaCommandFactory.create('create'))
62
+ .command(SchemaCommandFactory.create('drop'))
63
+ .command(SchemaCommandFactory.create('update'))
64
+ .command(SchemaCommandFactory.create('fresh'))
65
+ .command(MigrationCommandFactory.create('create'))
66
+ .command(MigrationCommandFactory.create('up'))
67
+ .command(MigrationCommandFactory.create('down'))
68
+ .command(MigrationCommandFactory.create('list'))
69
+ .command(MigrationCommandFactory.create('check'))
70
+ .command(MigrationCommandFactory.create('pending'))
71
+ .command(MigrationCommandFactory.create('fresh'))
72
+ .command(new DebugCommand());
73
73
  }
package/CLIHelper.d.ts CHANGED
@@ -1,65 +1,52 @@
1
- import {
2
- Configuration,
3
- type EntityManager,
4
- type EntityManagerType,
5
- type IDatabaseDriver,
6
- MikroORM,
7
- type Options,
8
- } from '@mikro-orm/core';
1
+ import { Configuration, type EntityManager, type EntityManagerType, type IDatabaseDriver, MikroORM, type Options } from '@mikro-orm/core';
9
2
  /**
10
3
  * @internal
11
4
  */
12
5
  export declare class CLIHelper {
13
- /**
14
- * Gets a named configuration
15
- *
16
- * @param contextName Load a config with the given `contextName` value. Used when config file exports array or factory function. Setting it to "default" matches also config objects without `contextName` set.
17
- * @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link fs.getConfigPaths}.
18
- * @param options Additional options to augment the final configuration with.
19
- */
20
- static getConfiguration<
21
- D extends IDatabaseDriver = IDatabaseDriver,
22
- EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>,
23
- >(contextName?: string, paths?: string[], options?: Partial<Options<D>>): Promise<Configuration<D, EM>>;
24
- static commonJSCompat(options: Partial<Options>): void;
25
- static getORM<D extends IDatabaseDriver = IDatabaseDriver>(
26
- contextName?: string,
27
- configPaths?: string[],
28
- opts?: Partial<Options<D>>,
29
- ): Promise<MikroORM<D>>;
30
- static isDBConnected(config: Configuration, reason?: false): Promise<boolean>;
31
- static isDBConnected(config: Configuration, reason: true): Promise<true | string>;
32
- static getDriverDependencies(config: Configuration): string[];
33
- static dump(text: string, config?: Configuration): void;
34
- static getSettings(): Settings;
35
- static getConfigPaths(): Promise<string[]>;
36
- private static getConfigFile;
37
- private static loadEnvironmentVars;
38
- static dumpDependencies(): void;
39
- static getModuleVersion(name: string): string;
40
- /**
41
- * Resolve path to a module.
42
- * @param id The module to require
43
- * @param [from] Location to start the node resolution
44
- */
45
- private static resolveModulePath;
46
- static dumpTable(options: { columns: string[]; rows: string[][]; empty: string }): void;
47
- /**
48
- * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp
49
- * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
50
- * This method is used only in CLI context.
51
- */
52
- static registerTypeScriptSupport(
53
- configPath?: string,
54
- tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto',
55
- ): Promise<boolean>;
56
- static isESM(): boolean;
57
- static showHelp(): void;
6
+ /**
7
+ * Gets a named configuration
8
+ *
9
+ * @param contextName Load a config with the given `contextName` value. Used when config file exports array or factory function. Setting it to "default" matches also config objects without `contextName` set.
10
+ * @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link fs.getConfigPaths}.
11
+ * @param options Additional options to augment the final configuration with.
12
+ */
13
+ static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>>(contextName?: string, paths?: string[], options?: Partial<Options<D>>): Promise<Configuration<D, EM>>;
14
+ static commonJSCompat(options: Partial<Options>): void;
15
+ static getORM<D extends IDatabaseDriver = IDatabaseDriver>(contextName?: string, configPaths?: string[], opts?: Partial<Options<D>>): Promise<MikroORM<D>>;
16
+ static isDBConnected(config: Configuration, reason?: false): Promise<boolean>;
17
+ static isDBConnected(config: Configuration, reason: true): Promise<true | string>;
18
+ static getDriverDependencies(config: Configuration): string[];
19
+ static dump(text: string, config?: Configuration): void;
20
+ static getSettings(): Settings;
21
+ static getConfigPaths(): Promise<string[]>;
22
+ private static getConfigFile;
23
+ private static loadEnvironmentVars;
24
+ static dumpDependencies(): void;
25
+ static getModuleVersion(name: string): string;
26
+ /**
27
+ * Resolve path to a module.
28
+ * @param id The module to require
29
+ * @param [from] Location to start the node resolution
30
+ */
31
+ private static resolveModulePath;
32
+ static dumpTable(options: {
33
+ columns: string[];
34
+ rows: string[][];
35
+ empty: string;
36
+ }): void;
37
+ /**
38
+ * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp
39
+ * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
40
+ * This method is used only in CLI context.
41
+ */
42
+ static registerTypeScriptSupport(configPath?: string, tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto'): Promise<boolean>;
43
+ static isESM(): boolean;
44
+ static showHelp(): void;
58
45
  }
59
46
  export interface Settings {
60
- verbose?: boolean;
61
- preferTs?: boolean;
62
- tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto';
63
- tsConfigPath?: string;
64
- configPaths?: string[];
47
+ verbose?: boolean;
48
+ preferTs?: boolean;
49
+ tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto';
50
+ tsConfigPath?: string;
51
+ configPaths?: string[];
65
52
  }