@mikro-orm/cli 7.0.0-dev.71 → 7.0.0-dev.72
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 +6 -0
- package/CLIHelper.js +18 -1
- package/package.json +4 -4
package/CLIHelper.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export declare class CLIHelper {
|
|
|
23
23
|
private static loadEnvironmentVars;
|
|
24
24
|
static dumpDependencies(): Promise<void>;
|
|
25
25
|
static getModuleVersion(name: string): Promise<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;
|
|
26
32
|
static dumpTable(options: {
|
|
27
33
|
columns: string[];
|
|
28
34
|
rows: string[][];
|
package/CLIHelper.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { extname, join, resolve } from 'node:path';
|
|
2
4
|
import yargs from 'yargs';
|
|
3
5
|
import { colors, ConfigurationLoader, MikroORM, Utils, Configuration, } from '@mikro-orm/core';
|
|
4
6
|
/**
|
|
@@ -215,7 +217,7 @@ export class CLIHelper {
|
|
|
215
217
|
}
|
|
216
218
|
catch {
|
|
217
219
|
try {
|
|
218
|
-
const path = `${
|
|
220
|
+
const path = `${this.resolveModulePath(name)}/package.json`;
|
|
219
221
|
const pkg = await readFile(path, { encoding: 'utf8' });
|
|
220
222
|
return colors.green(JSON.parse(pkg).version);
|
|
221
223
|
}
|
|
@@ -224,6 +226,21 @@ export class CLIHelper {
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Resolve path to a module.
|
|
231
|
+
* @param id The module to require
|
|
232
|
+
* @param [from] Location to start the node resolution
|
|
233
|
+
*/
|
|
234
|
+
static resolveModulePath(id, from = process.cwd()) {
|
|
235
|
+
if (!extname(from)) {
|
|
236
|
+
from = join(from, '__fake.js');
|
|
237
|
+
}
|
|
238
|
+
const path = Utils.normalizePath(createRequire(resolve(from)).resolve(id));
|
|
239
|
+
const parts = path.split('/');
|
|
240
|
+
const idx = parts.lastIndexOf(id) + 1;
|
|
241
|
+
parts.splice(idx, parts.length - idx);
|
|
242
|
+
return parts.join('/');
|
|
243
|
+
}
|
|
227
244
|
static dumpTable(options) {
|
|
228
245
|
if (options.rows.length === 0) {
|
|
229
246
|
return CLIHelper.dump(options.empty);
|
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.
|
|
4
|
+
"version": "7.0.0-dev.72",
|
|
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.
|
|
57
|
-
"@mikro-orm/knex": "7.0.0-dev.
|
|
58
|
-
"mikro-orm": "7.0.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.0.0-dev.72",
|
|
57
|
+
"@mikro-orm/knex": "7.0.0-dev.72",
|
|
58
|
+
"mikro-orm": "7.0.0-dev.72",
|
|
59
59
|
"yargs": "17.7.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|