@mikro-orm/core 7.0.0-dev.59 → 7.0.0-dev.60
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { globSync } from 'tinyglobby';
|
|
2
1
|
import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
3
2
|
import { Utils } from '../utils/Utils.js';
|
|
4
3
|
export class FileCacheAdapter {
|
|
@@ -53,7 +52,7 @@ export class FileCacheAdapter {
|
|
|
53
52
|
*/
|
|
54
53
|
clear() {
|
|
55
54
|
const path = this.path('*');
|
|
56
|
-
const files =
|
|
55
|
+
const files = Utils.glob(path);
|
|
57
56
|
files.forEach(file => unlinkSync(file));
|
|
58
57
|
this.cache = {};
|
|
59
58
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { basename } from 'node:path';
|
|
2
|
-
import { glob } from 'tinyglobby';
|
|
3
2
|
import { Utils } from '../utils/Utils.js';
|
|
4
3
|
import { MetadataStorage } from './MetadataStorage.js';
|
|
5
4
|
import { EntitySchema } from './EntitySchema.js';
|
|
@@ -27,7 +26,7 @@ async function getEntityClassOrSchema(filepath, allTargets, baseDir) {
|
|
|
27
26
|
export async function discoverEntities(paths, options) {
|
|
28
27
|
paths = Utils.asArray(paths).map(path => Utils.normalizePath(path));
|
|
29
28
|
const baseDir = options?.baseDir ?? process.cwd();
|
|
30
|
-
const files =
|
|
29
|
+
const files = Utils.glob(paths, Utils.normalizePath(baseDir));
|
|
31
30
|
const found = new Map();
|
|
32
31
|
for (const filepath of files) {
|
|
33
32
|
const filename = basename(filepath);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.60",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://mikro-orm.io",
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">= 22.
|
|
43
|
+
"node": ">= 22.17.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "yarn clean && yarn compile && yarn copy",
|
|
@@ -54,9 +54,8 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"dotenv": "17.2.3",
|
|
56
56
|
"esprima": "4.0.1",
|
|
57
|
-
"mikro-orm": "7.0.0-dev.
|
|
58
|
-
"reflect-metadata": "0.2.2"
|
|
59
|
-
"tinyglobby": "0.2.13"
|
|
57
|
+
"mikro-orm": "7.0.0-dev.60",
|
|
58
|
+
"reflect-metadata": "0.2.2"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
62
61
|
"dataloader": "2.2.3"
|
package/utils/Configuration.js
CHANGED
|
@@ -351,13 +351,13 @@ export class Configuration {
|
|
|
351
351
|
* break existing projects, only help with the new ones.
|
|
352
352
|
*/
|
|
353
353
|
detectSourceFolder(options) {
|
|
354
|
-
if (!Utils.
|
|
354
|
+
if (!Utils.pathExists(this.options.baseDir + '/src')) {
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
|
-
const migrationsPathExists = Utils.
|
|
358
|
-
const seedersPathExists = Utils.
|
|
359
|
-
const distDir = Utils.
|
|
360
|
-
const buildDir = Utils.
|
|
357
|
+
const migrationsPathExists = Utils.pathExists(this.options.baseDir + '/' + this.options.migrations.path);
|
|
358
|
+
const seedersPathExists = Utils.pathExists(this.options.baseDir + '/' + this.options.seeder.path);
|
|
359
|
+
const distDir = Utils.pathExists(this.options.baseDir + '/dist');
|
|
360
|
+
const buildDir = Utils.pathExists(this.options.baseDir + '/build');
|
|
361
361
|
// if neither `dist` nor `build` exist, we use the `src` folder as it might be a JS project without building, but with `src` folder
|
|
362
362
|
const path = distDir ? './dist' : (buildDir ? './build' : './src');
|
|
363
363
|
// only if the user did not provide any values and if the default path does not exist
|
|
@@ -80,7 +80,7 @@ export class ConfigurationLoader {
|
|
|
80
80
|
for (let path of paths) {
|
|
81
81
|
path = Utils.absolutePath(path);
|
|
82
82
|
path = Utils.normalizePath(path);
|
|
83
|
-
if (Utils.
|
|
83
|
+
if (Utils.pathExists(path)) {
|
|
84
84
|
const config = await Utils.dynamicImport(path);
|
|
85
85
|
/* v8 ignore next */
|
|
86
86
|
return [path, await (config.default ?? config)];
|
|
@@ -89,7 +89,7 @@ export class ConfigurationLoader {
|
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
static getPackageConfig(basePath = process.cwd()) {
|
|
92
|
-
if (Utils.
|
|
92
|
+
if (Utils.pathExists(`${basePath}/package.json`)) {
|
|
93
93
|
/* v8 ignore next 5 */
|
|
94
94
|
try {
|
|
95
95
|
return Utils.readJSONSync(`${basePath}/package.json`);
|
|
@@ -130,8 +130,8 @@ export class ConfigurationLoader {
|
|
|
130
130
|
paths.push('./src/mikro-orm.config.ts');
|
|
131
131
|
paths.push('./mikro-orm.config.ts');
|
|
132
132
|
}
|
|
133
|
-
const distDir = Utils.
|
|
134
|
-
const buildDir = Utils.
|
|
133
|
+
const distDir = Utils.pathExists(process.cwd() + '/dist');
|
|
134
|
+
const buildDir = Utils.pathExists(process.cwd() + '/build');
|
|
135
135
|
/* v8 ignore next */
|
|
136
136
|
const path = distDir ? 'dist' : (buildDir ? 'build' : 'src');
|
|
137
137
|
paths.push(`./${path}/mikro-orm.config.js`);
|
package/utils/Utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type GlobOptions } from 'tinyglobby';
|
|
2
1
|
import type { Dictionary, EntityData, EntityDictionary, EntityKey, EntityMetadata, EntityName, EntityProperty, IMetadataStorage, Primary } from '../typings.js';
|
|
3
2
|
import type { Collection } from '../entity/Collection.js';
|
|
4
3
|
import type { Platform } from '../platforms/Platform.js';
|
|
@@ -212,7 +211,8 @@ export declare class Utils {
|
|
|
212
211
|
static findDuplicates<T>(items: T[]): T[];
|
|
213
212
|
static removeDuplicates<T>(items: T[]): T[];
|
|
214
213
|
static randomInt(min: number, max: number): number;
|
|
215
|
-
static
|
|
214
|
+
static glob(input: string | string[], cwd?: string): string[];
|
|
215
|
+
static pathExists(path: string): boolean;
|
|
216
216
|
/**
|
|
217
217
|
* Extracts all possible values of a TS enum. Works with both string and numeric enums.
|
|
218
218
|
*/
|
|
@@ -239,7 +239,6 @@ export declare class Utils {
|
|
|
239
239
|
static dynamicImport<T = any>(id: string): Promise<T>;
|
|
240
240
|
static setDynamicImportProvider(provider: (id: string) => Promise<unknown>): void;
|
|
241
241
|
static ensureDir(path: string): void;
|
|
242
|
-
static pathExistsSync(path: string): boolean;
|
|
243
242
|
static readJSONSync(path: string): Dictionary;
|
|
244
243
|
static getORMVersion(): string;
|
|
245
244
|
static createFunction(context: Map<string, any>, code: string): any;
|
package/utils/Utils.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { glob, isDynamicPattern } from 'tinyglobby';
|
|
3
2
|
import { extname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
|
|
4
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { existsSync, globSync, statSync, mkdirSync, readFileSync } from 'node:fs';
|
|
6
5
|
import { createHash } from 'node:crypto';
|
|
7
6
|
import { tokenize } from 'esprima';
|
|
8
7
|
import { clone } from './clone.js';
|
|
@@ -819,12 +818,32 @@ export class Utils {
|
|
|
819
818
|
static randomInt(min, max) {
|
|
820
819
|
return Math.round(Math.random() * (max - min)) + min;
|
|
821
820
|
}
|
|
822
|
-
static
|
|
823
|
-
if (
|
|
824
|
-
|
|
821
|
+
static glob(input, cwd) {
|
|
822
|
+
if (Array.isArray(input)) {
|
|
823
|
+
return input.flatMap(paths => this.glob(paths, cwd));
|
|
824
|
+
}
|
|
825
|
+
const hasGlobChars = /[*?[\]]/.test(input);
|
|
826
|
+
if (!hasGlobChars) {
|
|
827
|
+
try {
|
|
828
|
+
const s = statSync(cwd ? Utils.normalizePath(cwd, input) : input);
|
|
829
|
+
if (s.isDirectory()) {
|
|
830
|
+
const files = globSync(join(input, '**'), { cwd, withFileTypes: true });
|
|
831
|
+
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
catch {
|
|
835
|
+
// ignore
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const files = globSync(input, { cwd, withFileTypes: true });
|
|
839
|
+
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
840
|
+
}
|
|
841
|
+
static pathExists(path) {
|
|
842
|
+
if (/[*?[\]]/.test(path)) {
|
|
843
|
+
const found = globSync(path);
|
|
825
844
|
return found.length > 0;
|
|
826
845
|
}
|
|
827
|
-
return
|
|
846
|
+
return existsSync(path);
|
|
828
847
|
}
|
|
829
848
|
/**
|
|
830
849
|
* Extracts all possible values of a TS enum. Works with both string and numeric enums.
|
|
@@ -917,9 +936,6 @@ export class Utils {
|
|
|
917
936
|
mkdirSync(path, { recursive: true });
|
|
918
937
|
}
|
|
919
938
|
}
|
|
920
|
-
static pathExistsSync(path) {
|
|
921
|
-
return existsSync(path);
|
|
922
|
-
}
|
|
923
939
|
static readJSONSync(path) {
|
|
924
940
|
const file = readFileSync(path);
|
|
925
941
|
return JSON.parse(file.toString());
|