@mikro-orm/cli 7.2.12-dev.1 → 7.2.12-dev.11
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,5 +1,5 @@
|
|
|
1
1
|
import { writeFileSync, mkdirSync } from 'node:fs';
|
|
2
|
-
import { resolve, dirname } from 'node:path';
|
|
2
|
+
import { resolve, dirname, basename, extname } from 'node:path';
|
|
3
3
|
import { MetadataDiscovery, MetadataStorage, Utils, EntityComparator, ObjectHydrator, colors, } from '@mikro-orm/core';
|
|
4
4
|
import { fs } from '@mikro-orm/core/fs-utils';
|
|
5
5
|
import { CLIHelper } from '../CLIHelper.js';
|
|
@@ -39,13 +39,14 @@ export class CompileCommand {
|
|
|
39
39
|
const indentedCode = code.replace(/\n/g, '\n ');
|
|
40
40
|
return ` '${key}': function(${params}) {\n ${indentedCode}\n }`;
|
|
41
41
|
});
|
|
42
|
-
const
|
|
42
|
+
const outPath = args.out ?? resolve(process.cwd(), 'compiled-functions.js');
|
|
43
|
+
const ext = extname(outPath);
|
|
44
|
+
const esm = ext === '.mjs' || (ext !== '.cjs' && CLIHelper.isESM());
|
|
43
45
|
const version = Utils.getORMVersion();
|
|
44
46
|
const output = esm
|
|
45
47
|
? `export default {\n __version: '${version}',\n${entries.join(',\n')}\n};\n`
|
|
46
48
|
: `'use strict';\nmodule.exports = {\n __version: '${version}',\n${entries.join(',\n')}\n};\n`;
|
|
47
|
-
const
|
|
48
|
-
const dtsPath = outPath.replace(/\.js$/, '.d.ts');
|
|
49
|
+
const dtsPath = /\.[mc]?js$/.test(outPath) ? outPath.replace(/\.([mc]?)js$/, '.d.$1ts') : `${outPath}.d.ts`;
|
|
49
50
|
const dts = esm
|
|
50
51
|
? `import type { CompiledFunctions } from '@mikro-orm/core';\ndeclare const compiledFunctions: CompiledFunctions;\nexport default compiledFunctions;\n`
|
|
51
52
|
: `import type { CompiledFunctions } from '@mikro-orm/core';\ndeclare const compiledFunctions: CompiledFunctions;\nexport = compiledFunctions;\n`;
|
|
@@ -57,7 +58,7 @@ export class CompileCommand {
|
|
|
57
58
|
}
|
|
58
59
|
CLIHelper.info(colors.green(`Compiled functions generated to ${outPath} (${captured.length} functions)`));
|
|
59
60
|
CLIHelper.info(`\nExample usage in your ORM config:\n`);
|
|
60
|
-
const importPath = esm ?
|
|
61
|
+
const importPath = `./${esm ? basename(outPath) : basename(outPath).replace(/\.js$/, '')}`;
|
|
61
62
|
CLIHelper.info(` ${esm ? 'import' : 'const'} compiledFunctions ${esm ? 'from ' : '= require('}${colors.cyan(`'${importPath}'`)}${esm ? '' : ')'};`);
|
|
62
63
|
CLIHelper.info('');
|
|
63
64
|
CLIHelper.info(` export default defineConfig({ compiledFunctions });\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/cli",
|
|
3
|
-
"version": "7.2.12-dev.
|
|
3
|
+
"version": "7.2.12-dev.11",
|
|
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.12-dev.
|
|
54
|
-
"mikro-orm": "7.2.12-dev.
|
|
53
|
+
"@mikro-orm/core": "7.2.12-dev.11",
|
|
54
|
+
"mikro-orm": "7.2.12-dev.11",
|
|
55
55
|
"yargs": "18.2.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|