@mikro-orm/cli 7.0.0-dev.64 → 7.0.0-dev.66

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.
@@ -2,20 +2,20 @@ import { type CommandModule } from 'yargs';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export type BaseArgs = Awaited<ReturnType<typeof CLIConfigurator['createBasicConfig']>['argv']>;
5
+ export type BaseArgs = Awaited<ReturnType<typeof createBasicConfig>['argv']>;
6
6
  /**
7
7
  * @internal
8
8
  */
9
9
  export interface BaseCommand<CommandArgs extends BaseArgs = BaseArgs> extends CommandModule<BaseArgs, CommandArgs> {
10
10
  }
11
- /**
12
- * @internal
13
- */
14
- export declare class CLIConfigurator {
15
- private static createBasicConfig;
16
- static configure(): Promise<import("yargs").Argv<{
17
- config: string[] | undefined;
18
- } & {
19
- contextName: string;
20
- }>>;
21
- }
11
+ declare function createBasicConfig(): import("yargs").Argv<{
12
+ config: string[] | undefined;
13
+ } & {
14
+ contextName: string;
15
+ }>;
16
+ export declare function configure(): Promise<import("yargs").Argv<{
17
+ config: string[] | undefined;
18
+ } & {
19
+ contextName: string;
20
+ }>>;
21
+ export {};
@@ -10,65 +10,61 @@ import { GenerateEntitiesCommand } from './commands/GenerateEntitiesCommand.js';
10
10
  import { ImportCommand } from './commands/ImportCommand.js';
11
11
  import { MigrationCommandFactory } from './commands/MigrationCommandFactory.js';
12
12
  import { SchemaCommandFactory } from './commands/SchemaCommandFactory.js';
13
- /**
14
- * @internal
15
- */
16
- export class CLIConfigurator {
17
- static createBasicConfig() {
18
- return yargs()
19
- .scriptName('mikro-orm')
20
- .usage('Usage: $0 <command> [options]')
21
- .example('$0 debug', 'Show debugging information')
22
- .example('$0 schema:update --run', 'Runs schema synchronization')
23
- .option('config', {
24
- type: 'string',
25
- array: true,
26
- desc: `Set path to the ORM configuration file`,
27
- })
28
- .option('contextName', {
29
- alias: 'context',
30
- type: 'string',
31
- desc: 'Set name of config to load out of the ORM configuration file. Used when config file exports an array or a function',
32
- default: process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default',
33
- })
34
- .alias('v', 'version')
35
- .alias('h', 'help')
36
- .recommendCommands()
37
- .showHelpOnFail(true)
38
- .demandCommand(1, '')
39
- .strict();
40
- }
41
- static async configure() {
42
- ConfigurationLoader.checkPackageVersion();
43
- const settings = ConfigurationLoader.getSettings();
44
- const version = Utils.getORMVersion();
45
- if (settings.preferTs !== false) {
46
- const preferTs = await ConfigurationLoader.registerTypeScriptSupport(settings.tsConfigPath, settings.tsLoader);
47
- /* v8 ignore next 3 */
48
- if (!preferTs) {
49
- process.env.MIKRO_ORM_CLI_PREFER_TS ??= '0';
50
- }
13
+ import { CLIHelper } from './CLIHelper.js';
14
+ function createBasicConfig() {
15
+ return yargs()
16
+ .scriptName('mikro-orm')
17
+ .usage('Usage: $0 <command> [options]')
18
+ .example('$0 debug', 'Show debugging information')
19
+ .example('$0 schema:update --run', 'Runs schema synchronization')
20
+ .option('config', {
21
+ type: 'string',
22
+ array: true,
23
+ desc: `Set path to the ORM configuration file`,
24
+ })
25
+ .option('contextName', {
26
+ alias: 'context',
27
+ type: 'string',
28
+ desc: 'Set name of config to load out of the ORM configuration file. Used when config file exports an array or a function',
29
+ default: process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default',
30
+ })
31
+ .alias('v', 'version')
32
+ .alias('h', 'help')
33
+ .recommendCommands()
34
+ .showHelpOnFail(true)
35
+ .demandCommand(1, '')
36
+ .strict();
37
+ }
38
+ export async function configure() {
39
+ ConfigurationLoader.checkPackageVersion();
40
+ const settings = CLIHelper.getSettings();
41
+ const version = Utils.getORMVersion();
42
+ if (settings.preferTs !== false) {
43
+ const preferTs = await CLIHelper.registerTypeScriptSupport(settings.tsConfigPath, settings.tsLoader);
44
+ /* v8 ignore next 3 */
45
+ if (!preferTs) {
46
+ process.env.MIKRO_ORM_CLI_PREFER_TS ??= '0';
51
47
  }
52
- return CLIConfigurator.createBasicConfig()
53
- .version(version)
54
- .command(new ClearCacheCommand())
55
- .command(new GenerateCacheCommand())
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
48
  }
49
+ return createBasicConfig()
50
+ .version(version)
51
+ .command(new ClearCacheCommand())
52
+ .command(new GenerateCacheCommand())
53
+ .command(new GenerateEntitiesCommand())
54
+ .command(new CreateDatabaseCommand())
55
+ .command(new ImportCommand())
56
+ .command(new DatabaseSeedCommand())
57
+ .command(new CreateSeederCommand())
58
+ .command(SchemaCommandFactory.create('create'))
59
+ .command(SchemaCommandFactory.create('drop'))
60
+ .command(SchemaCommandFactory.create('update'))
61
+ .command(SchemaCommandFactory.create('fresh'))
62
+ .command(MigrationCommandFactory.create('create'))
63
+ .command(MigrationCommandFactory.create('up'))
64
+ .command(MigrationCommandFactory.create('down'))
65
+ .command(MigrationCommandFactory.create('list'))
66
+ .command(MigrationCommandFactory.create('check'))
67
+ .command(MigrationCommandFactory.create('pending'))
68
+ .command(MigrationCommandFactory.create('fresh'))
69
+ .command(new DebugCommand());
74
70
  }
package/CLIHelper.d.ts CHANGED
@@ -1,16 +1,26 @@
1
- import { MikroORM, type Configuration, type IDatabaseDriver, type Options } from '@mikro-orm/core';
1
+ import { type EntityManagerType, type EntityManager, MikroORM, Configuration, type IDatabaseDriver, type Options } from '@mikro-orm/core';
2
2
  /**
3
3
  * @internal
4
4
  */
5
5
  export declare class CLIHelper {
6
- static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver>(contextName?: string, configPaths?: string[], options?: Partial<Options<D>>): Promise<Configuration<D>>;
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 ConfigurationLoader.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>>;
7
14
  static getORM<D extends IDatabaseDriver = IDatabaseDriver>(contextName?: string, configPaths?: string[], opts?: Partial<Options<D>>): Promise<MikroORM<D>>;
8
15
  static isDBConnected(config: Configuration, reason?: false): Promise<boolean>;
9
16
  static isDBConnected(config: Configuration, reason: true): Promise<true | string>;
10
17
  static getNodeVersion(): string;
11
18
  static getDriverDependencies(config: Configuration): string[];
12
19
  static dump(text: string, config?: Configuration): void;
20
+ static getSettings(): Settings;
13
21
  static getConfigPaths(): string[];
22
+ private static getConfigFile;
23
+ private static loadEnvironmentVars;
14
24
  static dumpDependencies(): Promise<void>;
15
25
  static getModuleVersion(name: string): Promise<string>;
16
26
  static dumpTable(options: {
@@ -18,5 +28,19 @@ export declare class CLIHelper {
18
28
  rows: string[][];
19
29
  empty: string;
20
30
  }): void;
31
+ /**
32
+ * Tries to register TS support in the following order: swc, tsx, jiti, tsimp
33
+ * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
34
+ * This method is used only in CLI context.
35
+ */
36
+ static registerTypeScriptSupport(configPath?: string, tsLoader?: 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto'): Promise<boolean>;
37
+ static isESM(): boolean;
21
38
  static showHelp(): void;
22
39
  }
40
+ export interface Settings {
41
+ verbose?: boolean;
42
+ preferTs?: boolean;
43
+ tsLoader?: 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto';
44
+ tsConfigPath?: string;
45
+ configPaths?: string[];
46
+ }
package/CLIHelper.js CHANGED
@@ -1,22 +1,87 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import yargs from 'yargs';
3
- import { colors, ConfigurationLoader, MikroORM, Utils } from '@mikro-orm/core';
3
+ import { colors, ConfigurationLoader, MikroORM, Utils, Configuration, } from '@mikro-orm/core';
4
4
  /**
5
5
  * @internal
6
6
  */
7
7
  export class CLIHelper {
8
- static async getConfiguration(contextName, configPaths, options = {}) {
8
+ /**
9
+ * Gets a named configuration
10
+ *
11
+ * @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.
12
+ * @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 ConfigurationLoader.getConfigPaths}.
13
+ * @param options Additional options to augment the final configuration with.
14
+ */
15
+ static async getConfiguration(contextName, paths = this.getConfigPaths(), options = {}) {
9
16
  const deps = ConfigurationLoader.getORMPackages();
10
17
  if (!deps.has('@mikro-orm/cli') && !process.env.MIKRO_ORM_ALLOW_GLOBAL_CLI) {
11
18
  throw new Error('@mikro-orm/cli needs to be installed as a local dependency!');
12
19
  }
13
- configPaths ??= ConfigurationLoader.getConfigPaths();
14
20
  contextName ??= process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default';
15
- return ConfigurationLoader.getConfiguration(contextName, configPaths, options);
21
+ const env = await this.loadEnvironmentVars();
22
+ const configFinder = (cfg) => {
23
+ return typeof cfg === 'object' && cfg !== null && ('contextName' in cfg ? cfg.contextName === contextName : (contextName === 'default'));
24
+ };
25
+ const isValidConfigFactoryResult = (cfg) => {
26
+ return typeof cfg === 'object' && cfg !== null && (!('contextName' in cfg) || cfg.contextName === contextName);
27
+ };
28
+ const result = await this.getConfigFile(paths);
29
+ if (!result[0]) {
30
+ if (Utils.hasObjectKeys(env)) {
31
+ return new Configuration(Utils.mergeConfig({ contextName }, options, env));
32
+ }
33
+ throw new Error(`MikroORM config file not found in ['${paths.join(`', '`)}']`);
34
+ }
35
+ const path = result[0];
36
+ let tmp = result[1];
37
+ if (Array.isArray(tmp)) {
38
+ const tmpFirstIndex = tmp.findIndex(configFinder);
39
+ if (tmpFirstIndex === -1) {
40
+ // Static config not found. Try factory functions
41
+ let configCandidate;
42
+ for (let i = 0, l = tmp.length; i < l; ++i) {
43
+ const f = tmp[i];
44
+ if (typeof f !== 'function') {
45
+ continue;
46
+ }
47
+ configCandidate = await f(contextName);
48
+ if (!isValidConfigFactoryResult(configCandidate)) {
49
+ continue;
50
+ }
51
+ tmp = configCandidate;
52
+ break;
53
+ }
54
+ if (Array.isArray(tmp)) {
55
+ throw new Error(`MikroORM config '${contextName}' was not found within the config file '${path}'. Either add a config with this name to the array, or add a function that when given this name will return a configuration object without a name, or with name set to this name.`);
56
+ }
57
+ }
58
+ else {
59
+ const tmpLastIndex = tmp.findLastIndex(configFinder);
60
+ if (tmpLastIndex !== tmpFirstIndex) {
61
+ throw new Error(`MikroORM config '${contextName}' is not unique within the array exported by '${path}' (first occurrence index: ${tmpFirstIndex}; last occurrence index: ${tmpLastIndex})`);
62
+ }
63
+ tmp = tmp[tmpFirstIndex];
64
+ }
65
+ }
66
+ else {
67
+ if (tmp instanceof Function) {
68
+ tmp = await tmp(contextName);
69
+ if (!isValidConfigFactoryResult(tmp)) {
70
+ throw new Error(`MikroORM config '${contextName}' was not what the function exported from '${path}' provided. Ensure it returns a config object with no name, or name matching the requested one.`);
71
+ }
72
+ }
73
+ else {
74
+ if (!configFinder(tmp)) {
75
+ throw new Error(`MikroORM config '${contextName}' was not what the default export from '${path}' provided.`);
76
+ }
77
+ }
78
+ }
79
+ const esmConfigOptions = this.isESM() ? { entityGenerator: { esmImport: true } } : {};
80
+ return new Configuration(Utils.mergeConfig({}, esmConfigOptions, tmp, options, env));
16
81
  }
17
82
  static async getORM(contextName, configPaths, opts = {}) {
18
- const options = await CLIHelper.getConfiguration(contextName, configPaths, opts);
19
- const settings = ConfigurationLoader.getSettings();
83
+ const options = await this.getConfiguration(contextName, configPaths, opts);
84
+ const settings = this.getSettings();
20
85
  options.set('allowGlobalContext', true);
21
86
  options.set('debug', !!settings.verbose);
22
87
  options.getLogger().setDebugMode(!!settings.verbose);
@@ -59,8 +124,70 @@ export class CLIHelper {
59
124
  // eslint-disable-next-line no-console
60
125
  console.log(text);
61
126
  }
127
+ static getSettings() {
128
+ const config = ConfigurationLoader.getPackageConfig();
129
+ const settings = { ...config['mikro-orm'] };
130
+ const bool = (v) => ['true', 't', '1'].includes(v.toLowerCase());
131
+ settings.preferTs = process.env.MIKRO_ORM_CLI_PREFER_TS != null ? bool(process.env.MIKRO_ORM_CLI_PREFER_TS) : settings.preferTs;
132
+ settings.tsLoader = process.env.MIKRO_ORM_CLI_TS_LOADER ?? settings.tsLoader;
133
+ settings.tsConfigPath = process.env.MIKRO_ORM_CLI_TS_CONFIG_PATH ?? settings.tsConfigPath;
134
+ settings.verbose = process.env.MIKRO_ORM_CLI_VERBOSE != null ? bool(process.env.MIKRO_ORM_CLI_VERBOSE) : settings.verbose;
135
+ if (process.env.MIKRO_ORM_CLI_CONFIG?.endsWith('.ts')) {
136
+ settings.preferTs = true;
137
+ }
138
+ return settings;
139
+ }
62
140
  static getConfigPaths() {
63
- return ConfigurationLoader.getConfigPaths();
141
+ const settings = this.getSettings();
142
+ const typeScriptSupport = settings.preferTs ?? Utils.detectTypeScriptSupport();
143
+ const paths = [];
144
+ if (process.env.MIKRO_ORM_CLI_CONFIG) {
145
+ paths.push(process.env.MIKRO_ORM_CLI_CONFIG);
146
+ }
147
+ paths.push(...(settings.configPaths || []));
148
+ if (typeScriptSupport) {
149
+ paths.push('./src/mikro-orm.config.ts');
150
+ paths.push('./mikro-orm.config.ts');
151
+ }
152
+ const distDir = Utils.pathExists(process.cwd() + '/dist');
153
+ const buildDir = Utils.pathExists(process.cwd() + '/build');
154
+ /* v8 ignore next */
155
+ const path = distDir ? 'dist' : (buildDir ? 'build' : 'src');
156
+ paths.push(`./${path}/mikro-orm.config.js`);
157
+ paths.push('./mikro-orm.config.js');
158
+ /* v8 ignore next */
159
+ return Utils.unique(paths).filter(p => !p.match(/\.[mc]?ts$/) || typeScriptSupport);
160
+ }
161
+ static async getConfigFile(paths) {
162
+ for (let path of paths) {
163
+ path = Utils.absolutePath(path);
164
+ path = Utils.normalizePath(path);
165
+ if (Utils.pathExists(path)) {
166
+ const config = await Utils.dynamicImport(path);
167
+ /* v8 ignore next */
168
+ return [path, await (config.default ?? config)];
169
+ }
170
+ }
171
+ return [];
172
+ }
173
+ static async loadEnvironmentVars() {
174
+ const ret = ConfigurationLoader.loadEnvironmentVars();
175
+ // only to keep some sort of back compatibility with those using env vars only, to support `MIKRO_ORM_TYPE`
176
+ const PLATFORMS = {
177
+ mongo: { className: 'MongoDriver', module: '@mikro-orm/mongodb' },
178
+ mysql: { className: 'MySqlDriver', module: '@mikro-orm/mysql' },
179
+ mssql: { className: 'MsSqlDriver', module: '@mikro-orm/mssql' },
180
+ mariadb: { className: 'MariaDbDriver', module: '@mikro-orm/mariadb' },
181
+ postgresql: { className: 'PostgreSqlDriver', module: '@mikro-orm/postgresql' },
182
+ sqlite: { className: 'SqliteDriver', module: '@mikro-orm/sqlite' },
183
+ libsql: { className: 'LibSqlDriver', module: '@mikro-orm/libsql' },
184
+ };
185
+ if (process.env.MIKRO_ORM_TYPE) {
186
+ const val = process.env.MIKRO_ORM_TYPE;
187
+ const driver = await import(PLATFORMS[val].module);
188
+ ret.driver = driver[PLATFORMS[val].className];
189
+ }
190
+ return ret;
64
191
  }
65
192
  static async dumpDependencies() {
66
193
  const version = Utils.getORMVersion();
@@ -118,6 +245,52 @@ export class CLIHelper {
118
245
  ret += colors.grey('└' + lengths.map(length => '─'.repeat(length)).join('┴') + '┘');
119
246
  CLIHelper.dump(ret);
120
247
  }
248
+ /**
249
+ * Tries to register TS support in the following order: swc, tsx, jiti, tsimp
250
+ * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
251
+ * This method is used only in CLI context.
252
+ */
253
+ static async registerTypeScriptSupport(configPath = 'tsconfig.json', tsLoader) {
254
+ /* v8 ignore next 3 */
255
+ if (process.versions.bun) {
256
+ return true;
257
+ }
258
+ process.env.SWC_NODE_PROJECT ??= configPath;
259
+ process.env.TSIMP_PROJECT ??= configPath;
260
+ process.env.MIKRO_ORM_CLI_ALWAYS_ALLOW_TS ??= '1';
261
+ const isEsm = this.isESM();
262
+ /* v8 ignore next */
263
+ const importMethod = isEsm ? 'tryImport' : 'tryRequire';
264
+ const explicitLoader = tsLoader ?? process.env.MIKRO_ORM_CLI_TS_LOADER ?? 'auto';
265
+ const loaders = {
266
+ swc: { esm: '@swc-node/register/esm-register', cjs: '@swc-node/register' },
267
+ tsx: { esm: 'tsx/esm/api', cjs: 'tsx/cjs/api', cb: (tsx) => tsx.register({ tsconfig: configPath }) },
268
+ jiti: { esm: 'jiti/register', cjs: 'jiti/register', cb: () => Utils.dynamicImportProvider = id => import(id).then(mod => mod?.default ?? mod) },
269
+ tsimp: { esm: 'tsimp/import', cjs: 'tsimp/import' },
270
+ };
271
+ for (const loader of Utils.keys(loaders)) {
272
+ if (explicitLoader !== 'auto' && loader !== explicitLoader) {
273
+ continue;
274
+ }
275
+ const { esm, cjs, cb } = loaders[loader];
276
+ /* v8 ignore next */
277
+ const module = isEsm ? esm : cjs;
278
+ const mod = await Utils[importMethod]({ module });
279
+ if (mod) {
280
+ cb?.(mod);
281
+ process.env.MIKRO_ORM_CLI_TS_LOADER = loader;
282
+ return true;
283
+ }
284
+ }
285
+ // eslint-disable-next-line no-console
286
+ console.warn('Neither `swc`, `tsx`, `jiti` nor `tsimp` found in the project dependencies, support for working with TypeScript files might not work. To use `swc`, you need to install both `@swc-node/register` and `@swc/core`.');
287
+ return false;
288
+ }
289
+ static isESM() {
290
+ const config = ConfigurationLoader.getPackageConfig();
291
+ const type = config?.type ?? '';
292
+ return type === 'module';
293
+ }
121
294
  /* v8 ignore next 3 */
122
295
  static showHelp() {
123
296
  yargs(process.argv.slice(2)).showHelp();
package/cli CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { CLIHelper } from './CLIHelper.js';
3
- import { CLIConfigurator } from './CLIConfigurator.js';
4
- const argv = await CLIConfigurator.configure();
3
+ import { configure } from './CLIConfigurator.js';
4
+ const argv = await configure();
5
5
  const args = await argv.parse(process.argv.slice(2));
6
6
  if (args._.length === 0) {
7
7
  CLIHelper.showHelp();
package/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { CLIHelper } from './CLIHelper.js';
3
- import { CLIConfigurator } from './CLIConfigurator.js';
4
- const argv = await CLIConfigurator.configure();
3
+ import { configure } from './CLIConfigurator.js';
4
+ const argv = await configure();
5
5
  const args = await argv.parse(process.argv.slice(2));
6
6
  if (args._.length === 0) {
7
7
  CLIHelper.showHelp();
@@ -1,4 +1,4 @@
1
- import { colors, ConfigurationLoader, Utils } from '@mikro-orm/core';
1
+ import { colors, Utils } from '@mikro-orm/core';
2
2
  import { CLIHelper } from '../CLIHelper.js';
3
3
  export class DebugCommand {
4
4
  command = 'debug';
@@ -9,7 +9,7 @@ export class DebugCommand {
9
9
  async handler(args) {
10
10
  CLIHelper.dump(`Current ${colors.cyan('MikroORM')} CLI configuration`);
11
11
  await CLIHelper.dumpDependencies();
12
- const settings = ConfigurationLoader.getSettings();
12
+ const settings = CLIHelper.getSettings();
13
13
  if (!process.versions.bun && settings.preferTs !== false) {
14
14
  const loader = process.env.MIKRO_ORM_CLI_TS_LOADER ?? 'auto';
15
15
  CLIHelper.dump(' - TypeScript support ' + colors.green(`enabled (${loader})`));
@@ -40,8 +40,8 @@ export class DebugCommand {
40
40
  }
41
41
  const entities = config.get('entities', []);
42
42
  if (entities.length > 0) {
43
- const refs = entities.filter(p => !Utils.isString(p));
44
- const paths = entities.filter(p => Utils.isString(p));
43
+ const refs = entities.filter(p => typeof p !== 'string');
44
+ const paths = entities.filter(p => typeof p === 'string');
45
45
  const will = !config.get('preferTs') ? 'will' : 'could';
46
46
  CLIHelper.dump(` - ${will} use \`entities\` array (contains ${refs.length} references and ${paths.length} paths)`);
47
47
  if (paths.length > 0) {
@@ -50,8 +50,8 @@ export class DebugCommand {
50
50
  }
51
51
  const entitiesTs = config.get('entitiesTs', []);
52
52
  if (entitiesTs.length > 0) {
53
- const refs = entitiesTs.filter(p => !Utils.isString(p));
54
- const paths = entitiesTs.filter(p => Utils.isString(p));
53
+ const refs = entitiesTs.filter(p => typeof p !== 'string');
54
+ const paths = entitiesTs.filter(p => typeof p === 'string');
55
55
  /* v8 ignore next */
56
56
  const will = config.get('preferTs') ? 'will' : 'could';
57
57
  CLIHelper.dump(` - ${will} use \`entitiesTs\` array (contains ${refs.length} references and ${paths.length} paths)`);
@@ -25,7 +25,7 @@ export class GenerateCacheCommand {
25
25
  await config.getMetadataCacheAdapter().clear();
26
26
  config.set('logger', CLIHelper.dump.bind(null));
27
27
  config.set('debug', true);
28
- const discovery = new MetadataDiscovery(MetadataStorage.init(), config.getDriver().getPlatform(), config);
28
+ const discovery = new MetadataDiscovery(new MetadataStorage(), config.getDriver().getPlatform(), config);
29
29
  await discovery.discover(args.ts ?? false);
30
30
  const combined = args.combined && config.get('metadataCache').combined;
31
31
  CLIHelper.dump(colors.green(`${combined ? 'Combined ' : ''}${args.ts ? 'TS' : 'JS'} metadata cache was successfully generated${combined ? ' to ' + combined : ''}`));
@@ -203,7 +203,7 @@ export class MigrationCommandFactory {
203
203
  if (method === 'up' && Utils.isEmpty(options)) {
204
204
  return msg + ' to the latest version';
205
205
  }
206
- if (Utils.isString(options.to)) {
206
+ if (typeof options.to === 'string') {
207
207
  return msg + ' to version ' + options.to;
208
208
  }
209
209
  if (options.migrations?.length === 1) {
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.64",
4
+ "version": "7.0.0-dev.66",
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,8 +53,8 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@mikro-orm/core": "7.0.0-dev.64",
57
- "@mikro-orm/knex": "7.0.0-dev.64",
56
+ "@mikro-orm/core": "7.0.0-dev.66",
57
+ "@mikro-orm/knex": "7.0.0-dev.66",
58
58
  "yargs": "17.7.2"
59
59
  },
60
60
  "devDependencies": {