@mikro-orm/cli 7.2.0-dev.20 → 7.2.0-dev.21

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
@@ -37,18 +37,19 @@ export declare class CLIHelper {
37
37
  empty: string;
38
38
  }): void;
39
39
  /**
40
- * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp
40
+ * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp, nub
41
41
  * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
42
+ * `nub` is skipped when a custom tsconfig path is used, and it supports only the legacy decorators.
42
43
  * This method is used only in CLI context.
43
44
  */
44
- static registerTypeScriptSupport(configPath?: string, tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto'): Promise<boolean>;
45
+ static registerTypeScriptSupport(configPath?: string, tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'nub' | 'auto'): Promise<boolean>;
45
46
  static isESM(): boolean;
46
47
  static showHelp(): void;
47
48
  }
48
49
  export interface Settings {
49
50
  verbose?: boolean;
50
51
  preferTs?: boolean;
51
- tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'auto';
52
+ tsLoader?: 'oxc' | 'swc' | 'tsx' | 'jiti' | 'tsimp' | 'nub' | 'auto';
52
53
  tsConfigPath?: string;
53
54
  configPaths?: string[];
54
55
  }
package/CLIHelper.js CHANGED
@@ -265,8 +265,9 @@ export class CLIHelper {
265
265
  CLIHelper.dump(ret);
266
266
  }
267
267
  /**
268
- * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp
268
+ * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp, nub
269
269
  * Use `MIKRO_ORM_CLI_TS_LOADER` env var to set the loader explicitly.
270
+ * `nub` is skipped when a custom tsconfig path is used, and it supports only the legacy decorators.
270
271
  * This method is used only in CLI context.
271
272
  */
272
273
  static async registerTypeScriptSupport(configPath = 'tsconfig.json', tsLoader) {
@@ -278,18 +279,26 @@ export class CLIHelper {
278
279
  process.env.TSIMP_PROJECT ??= configPath;
279
280
  process.env.MIKRO_ORM_CLI_ALWAYS_ALLOW_TS ??= '1';
280
281
  const explicitLoader = tsLoader ?? process.env.MIKRO_ORM_CLI_TS_LOADER ?? 'auto';
282
+ const usesDefaultTsConfig = fs.absolutePath(configPath) === fs.absolutePath('tsconfig.json');
281
283
  const setEsmImportProvider = () => {
282
284
  return (globalThis.dynamicImportProvider = (id) => import(id).then(mod => mod?.default ?? mod));
283
285
  };
286
+ if (explicitLoader === 'nub' && !usesDefaultTsConfig) {
287
+ throw new Error('The `nub` loader does not support a custom tsconfig path. Use the project tsconfig.json or select another loader.');
288
+ }
284
289
  const loaders = {
285
290
  oxc: { esm: '@oxc-node/core/register', cjs: '@oxc-node/core/register' },
286
291
  swc: { esm: '@swc-node/register/esm-register', cjs: '@swc-node/register' },
287
292
  tsx: { esm: 'tsx/esm/api', cjs: 'tsx/cjs/api', cb: (tsx) => tsx.register({ tsconfig: configPath }) },
288
293
  jiti: { cjs: 'jiti/register', cb: setEsmImportProvider },
289
294
  tsimp: { cjs: 'tsimp/import', cb: setEsmImportProvider },
295
+ nub: { esm: '@nubjs/loader', cjs: '@nubjs/loader' },
290
296
  };
291
297
  const errors = [];
292
298
  for (const loader of Utils.keys(loaders)) {
299
+ if (loader === 'nub' && !usesDefaultTsConfig) {
300
+ continue;
301
+ }
293
302
  if (explicitLoader !== 'auto' && loader !== explicitLoader) {
294
303
  continue;
295
304
  }
@@ -320,8 +329,12 @@ export class CLIHelper {
320
329
  if (errors.length > 0) {
321
330
  throw new Error(errors.map(e => e.message).join('\n'), { cause: errors[0] });
322
331
  }
332
+ const loadersMessage = usesDefaultTsConfig
333
+ ? '`oxc`, `swc`, `tsx`, `jiti`, `tsimp` nor `nub`'
334
+ : '`oxc`, `swc`, `tsx`, `jiti` nor `tsimp`';
335
+ const nubHint = usesDefaultTsConfig ? '' : ' The `nub` loader was skipped as a custom tsconfig path is configured.';
323
336
  // eslint-disable-next-line no-console
324
- console.warn('Neither `oxc`, `swc`, `tsx`, `jiti` nor `tsimp` found in the project dependencies, support for working with TypeScript files might not work. To use `oxc`, install `@oxc-node/core`. To use `swc`, install both `@swc-node/register` and `@swc/core`.');
337
+ console.warn(`Neither ${loadersMessage} found in the project dependencies, support for working with TypeScript files might not work.${nubHint} To use \`oxc\`, install \`@oxc-node/core\`. To use \`swc\`, install both \`@swc-node/register\` and \`@swc/core\`.`);
325
338
  return false;
326
339
  }
327
340
  static isESM() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/cli",
3
- "version": "7.2.0-dev.20",
3
+ "version": "7.2.0-dev.21",
4
4
  "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.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -50,8 +50,8 @@
50
50
  "copy": "node ../../scripts/copy.mjs"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/core": "7.2.0-dev.20",
54
- "mikro-orm": "7.2.0-dev.20",
53
+ "@mikro-orm/core": "7.2.0-dev.21",
54
+ "mikro-orm": "7.2.0-dev.21",
55
55
  "yargs": "17.7.2"
56
56
  },
57
57
  "engines": {