@mikro-orm/cli 7.0.0-dev.90 → 7.0.0-dev.92

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.
package/CLIHelper.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare class CLIHelper {
11
11
  * @param options Additional options to augment the final configuration with.
12
12
  */
13
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;
14
15
  static getORM<D extends IDatabaseDriver = IDatabaseDriver>(contextName?: string, configPaths?: string[], opts?: Partial<Options<D>>): Promise<MikroORM<D>>;
15
16
  static isDBConnected(config: Configuration, reason?: false): Promise<boolean>;
16
17
  static isDBConnected(config: Configuration, reason: true): Promise<true | string>;
package/CLIHelper.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { extname, join } from 'node:path';
2
- import { pathToFileURL } from 'node:url';
2
+ import { createRequire } from 'node:module';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
3
4
  import yargs from 'yargs';
4
5
  import { colors, Configuration, loadEnvironmentVars, lookupExtensions, MikroORM, Utils, } from '@mikro-orm/core';
5
6
  import { fs } from '@mikro-orm/core/fs-utils';
@@ -15,6 +16,7 @@ export class CLIHelper {
15
16
  * @param options Additional options to augment the final configuration with.
16
17
  */
17
18
  static async getConfiguration(contextName, paths, options = {}) {
19
+ this.commonJSCompat(options);
18
20
  paths ??= await this.getConfigPaths();
19
21
  const deps = fs.getORMPackages();
20
22
  if (!deps.has('@mikro-orm/cli') && !process.env.MIKRO_ORM_ALLOW_GLOBAL_CLI) {
@@ -81,8 +83,19 @@ export class CLIHelper {
81
83
  }
82
84
  }
83
85
  const esmConfigOptions = this.isESM() ? { entityGenerator: { esmImport: true } } : {};
86
+ await lookupExtensions(tmp);
84
87
  return new Configuration(Utils.mergeConfig({}, esmConfigOptions, tmp, options, env));
85
88
  }
89
+ static commonJSCompat(options) {
90
+ if (this.isESM()) {
91
+ return;
92
+ }
93
+ /* v8 ignore next */
94
+ options.dynamicImportProvider ??= id => {
95
+ id = fileURLToPath(id);
96
+ return createRequire(process.cwd())(id);
97
+ };
98
+ }
86
99
  static async getORM(contextName, configPaths, opts = {}) {
87
100
  const options = await this.getConfiguration(contextName, configPaths, opts);
88
101
  const settings = this.getSettings();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/cli",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.90",
4
+ "version": "7.0.0-dev.92",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -53,9 +53,9 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@mikro-orm/core": "7.0.0-dev.90",
57
- "@mikro-orm/knex": "7.0.0-dev.90",
58
- "mikro-orm": "7.0.0-dev.90",
56
+ "@mikro-orm/core": "7.0.0-dev.92",
57
+ "@mikro-orm/knex": "7.0.0-dev.92",
58
+ "mikro-orm": "7.0.0-dev.92",
59
59
  "yargs": "17.7.2"
60
60
  },
61
61
  "devDependencies": {