@mikro-orm/cli 7.0.0-dev.1 → 7.0.0-dev.100
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/CLIConfigurator.d.ts +13 -13
- package/CLIConfigurator.js +68 -75
- package/CLIHelper.d.ts +36 -6
- package/CLIHelper.js +247 -47
- package/README.md +3 -2
- package/cli +7 -17
- package/cli.js +7 -17
- package/commands/ClearCacheCommand.d.ts +1 -1
- package/commands/ClearCacheCommand.js +6 -10
- package/commands/CreateDatabaseCommand.d.ts +1 -1
- package/commands/CreateDatabaseCommand.js +4 -9
- package/commands/CreateSeederCommand.d.ts +1 -1
- package/commands/CreateSeederCommand.js +6 -11
- package/commands/DatabaseSeedCommand.d.ts +1 -1
- package/commands/DatabaseSeedCommand.js +6 -10
- package/commands/DebugCommand.d.ts +1 -1
- package/commands/DebugCommand.js +35 -39
- package/commands/GenerateCacheCommand.d.ts +1 -1
- package/commands/GenerateCacheCommand.js +11 -15
- package/commands/GenerateEntitiesCommand.d.ts +1 -1
- package/commands/GenerateEntitiesCommand.js +5 -9
- package/commands/ImportCommand.d.ts +1 -1
- package/commands/ImportCommand.js +5 -9
- package/commands/MigrationCommandFactory.d.ts +1 -1
- package/commands/MigrationCommandFactory.js +38 -45
- package/commands/SchemaCommandFactory.d.ts +1 -1
- package/commands/SchemaCommandFactory.js +12 -20
- package/index.d.ts +2 -2
- package/index.js +2 -18
- package/package.json +8 -25
- package/esm +0 -18
- package/esm.cmd +0 -3
- package/esm.d.ts +0 -2
- package/esm.js +0 -18
- package/index.mjs +0 -5
package/cli
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
.errorsStyle('red');
|
|
10
|
-
const CLIHelper_1 = require("./CLIHelper");
|
|
11
|
-
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
|
-
void (async () => {
|
|
13
|
-
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
|
-
const args = await argv.parse(process.argv.slice(2));
|
|
15
|
-
if (args._.length === 0) {
|
|
16
|
-
CLIHelper_1.CLIHelper.showHelp();
|
|
17
|
-
}
|
|
18
|
-
})();
|
|
2
|
+
import { CLIHelper } from './CLIHelper.js';
|
|
3
|
+
import { configure } from './CLIConfigurator.js';
|
|
4
|
+
const argv = await configure();
|
|
5
|
+
const args = await argv.parse(process.argv.slice(2));
|
|
6
|
+
if (args._.length === 0) {
|
|
7
|
+
CLIHelper.showHelp();
|
|
8
|
+
}
|
package/cli.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
.errorsStyle('red');
|
|
10
|
-
const CLIHelper_1 = require("./CLIHelper");
|
|
11
|
-
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
|
-
void (async () => {
|
|
13
|
-
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
|
-
const args = await argv.parse(process.argv.slice(2));
|
|
15
|
-
if (args._.length === 0) {
|
|
16
|
-
CLIHelper_1.CLIHelper.showHelp();
|
|
17
|
-
}
|
|
18
|
-
})();
|
|
2
|
+
import { CLIHelper } from './CLIHelper.js';
|
|
3
|
+
import { configure } from './CLIConfigurator.js';
|
|
4
|
+
const argv = await configure();
|
|
5
|
+
const args = await argv.parse(process.argv.slice(2));
|
|
6
|
+
if (args._.length === 0) {
|
|
7
|
+
CLIHelper.showHelp();
|
|
8
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator.js';
|
|
3
3
|
export declare class ClearCacheCommand implements BaseCommand {
|
|
4
4
|
command: string;
|
|
5
5
|
describe: string;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class ClearCacheCommand {
|
|
1
|
+
import { colors } from '@mikro-orm/core';
|
|
2
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
3
|
+
export class ClearCacheCommand {
|
|
7
4
|
command = 'cache:clear';
|
|
8
5
|
describe = 'Clear metadata cache';
|
|
9
6
|
/**
|
|
10
7
|
* @inheritDoc
|
|
11
8
|
*/
|
|
12
9
|
async handler(args) {
|
|
13
|
-
const config = await
|
|
10
|
+
const config = await CLIHelper.getConfiguration(args.contextName, args.config);
|
|
14
11
|
if (!config.get('metadataCache').enabled) {
|
|
15
|
-
|
|
12
|
+
CLIHelper.dump(colors.red('Metadata cache is disabled in your configuration. Set cache.enabled to true to use this command.'));
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
15
|
const cache = config.getMetadataCacheAdapter();
|
|
19
16
|
await cache.clear();
|
|
20
|
-
|
|
17
|
+
CLIHelper.dump(colors.green('Metadata cache was successfully cleared'));
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
exports.ClearCacheCommand = ClearCacheCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator.js';
|
|
3
3
|
export declare class CreateDatabaseCommand implements BaseCommand {
|
|
4
4
|
command: string;
|
|
5
5
|
describe: string;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CreateDatabaseCommand = void 0;
|
|
4
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
5
|
-
class CreateDatabaseCommand {
|
|
1
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
2
|
+
export class CreateDatabaseCommand {
|
|
6
3
|
command = 'database:create';
|
|
7
4
|
describe = 'Create your database if it does not exist';
|
|
8
5
|
/**
|
|
9
6
|
* @inheritDoc
|
|
10
7
|
*/
|
|
11
8
|
async handler(args) {
|
|
12
|
-
const orm = await
|
|
13
|
-
|
|
14
|
-
await schemaGenerator.ensureDatabase();
|
|
9
|
+
const orm = await CLIHelper.getORM(args.contextName, args.config);
|
|
10
|
+
await orm.schema.ensureDatabase();
|
|
15
11
|
await orm.close(true);
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
|
-
exports.CreateDatabaseCommand = CreateDatabaseCommand;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class CreateSeederCommand {
|
|
1
|
+
import { colors } from '@mikro-orm/core';
|
|
2
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
3
|
+
export class CreateSeederCommand {
|
|
7
4
|
command = 'seeder:create <seeder>';
|
|
8
5
|
describe = 'Create a new seeder class';
|
|
9
6
|
builder = (args) => {
|
|
@@ -18,10 +15,9 @@ class CreateSeederCommand {
|
|
|
18
15
|
*/
|
|
19
16
|
async handler(args) {
|
|
20
17
|
const className = CreateSeederCommand.getSeederClassName(args.seeder);
|
|
21
|
-
const orm = await
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
CLIHelper_1.CLIHelper.dump(core_1.colors.green(`Seeder ${args.seeder} successfully created at ${path}`));
|
|
18
|
+
const orm = await CLIHelper.getORM(args.contextName, args.config);
|
|
19
|
+
const path = await orm.seeder.create(className);
|
|
20
|
+
CLIHelper.dump(colors.green(`Seeder ${args.seeder} successfully created at ${path}`));
|
|
25
21
|
await orm.close(true);
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
@@ -33,4 +29,3 @@ class CreateSeederCommand {
|
|
|
33
29
|
return parts.map(name => name.charAt(0).toUpperCase() + name.slice(1)).join('') + 'Seeder';
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
exports.CreateSeederCommand = CreateSeederCommand;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class DatabaseSeedCommand {
|
|
1
|
+
import { colors } from '@mikro-orm/core';
|
|
2
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
3
|
+
export class DatabaseSeedCommand {
|
|
7
4
|
command = 'seeder:run';
|
|
8
5
|
describe = 'Seed the database using the seeder class';
|
|
9
6
|
builder = (args) => {
|
|
@@ -18,11 +15,10 @@ class DatabaseSeedCommand {
|
|
|
18
15
|
* @inheritDoc
|
|
19
16
|
*/
|
|
20
17
|
async handler(args) {
|
|
21
|
-
const orm = await
|
|
18
|
+
const orm = await CLIHelper.getORM(args.contextName, args.config);
|
|
22
19
|
const className = args.class ?? orm.config.get('seeder').defaultSeeder;
|
|
23
|
-
await orm.
|
|
24
|
-
|
|
20
|
+
await orm.seeder.seedString(className);
|
|
21
|
+
CLIHelper.dump(colors.green(`Seeder ${className} successfully executed`));
|
|
25
22
|
await orm.close(true);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.DatabaseSeedCommand = DatabaseSeedCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator.js';
|
|
3
3
|
export declare class DebugCommand implements BaseCommand {
|
|
4
4
|
command: string;
|
|
5
5
|
describe: string;
|
package/commands/DebugCommand.js
CHANGED
|
@@ -1,84 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class DebugCommand {
|
|
1
|
+
import { colors, Utils } from '@mikro-orm/core';
|
|
2
|
+
import { fs } from '@mikro-orm/core/fs-utils';
|
|
3
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
4
|
+
export class DebugCommand {
|
|
7
5
|
command = 'debug';
|
|
8
6
|
describe = 'Debug CLI configuration';
|
|
9
7
|
/**
|
|
10
8
|
* @inheritDoc
|
|
11
9
|
*/
|
|
12
10
|
async handler(args) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const settings =
|
|
16
|
-
if (!process.versions.bun && settings.
|
|
17
|
-
|
|
11
|
+
CLIHelper.dump(`Current ${colors.cyan('MikroORM')} CLI configuration`);
|
|
12
|
+
CLIHelper.dumpDependencies();
|
|
13
|
+
const settings = CLIHelper.getSettings();
|
|
14
|
+
if (!process.versions.bun && settings.preferTs !== false) {
|
|
15
|
+
const loader = process.env.MIKRO_ORM_CLI_TS_LOADER ?? 'auto';
|
|
16
|
+
CLIHelper.dump(' - TypeScript support ' + colors.green(`enabled (${loader})`));
|
|
18
17
|
}
|
|
19
|
-
const configPaths = args.config ??
|
|
20
|
-
|
|
18
|
+
const configPaths = args.config ?? await CLIHelper.getConfigPaths();
|
|
19
|
+
CLIHelper.dump(' - searched config paths:');
|
|
21
20
|
await DebugCommand.checkPaths(configPaths, 'yellow');
|
|
22
|
-
|
|
21
|
+
CLIHelper.dump(` - searched for config name: ${colors.green(args.contextName)}`);
|
|
23
22
|
try {
|
|
24
|
-
const config = await
|
|
25
|
-
|
|
26
|
-
const drivers =
|
|
27
|
-
|
|
23
|
+
const config = await CLIHelper.getConfiguration(args.contextName, configPaths);
|
|
24
|
+
CLIHelper.dump(` - configuration ${colors.green('found')}`);
|
|
25
|
+
const drivers = CLIHelper.getDriverDependencies(config);
|
|
26
|
+
CLIHelper.dump(' - driver dependencies:');
|
|
28
27
|
for (const driver of drivers) {
|
|
29
|
-
|
|
28
|
+
CLIHelper.dump(` - ${driver} ${CLIHelper.getModuleVersion(driver)}`);
|
|
30
29
|
}
|
|
31
|
-
const isConnected = await
|
|
30
|
+
const isConnected = await CLIHelper.isDBConnected(config, true);
|
|
32
31
|
if (isConnected === true) {
|
|
33
|
-
|
|
32
|
+
CLIHelper.dump(` - ${colors.green('database connection successful')}`);
|
|
34
33
|
}
|
|
35
34
|
else {
|
|
36
|
-
|
|
35
|
+
CLIHelper.dump(` - ${colors.yellow(`database connection failed (${isConnected})`)}`);
|
|
37
36
|
}
|
|
38
37
|
const preferTs = config.get('preferTs');
|
|
39
38
|
if ([true, false].includes(preferTs)) {
|
|
40
39
|
const warning = preferTs ? ' (this value should be set to `false` when running compiled code!)' : '';
|
|
41
|
-
|
|
40
|
+
CLIHelper.dump(` - \`preferTs\` flag explicitly set to ${preferTs}, will use \`entities${preferTs ? 'Ts' : ''}\` array${warning}`);
|
|
42
41
|
}
|
|
43
42
|
const entities = config.get('entities', []);
|
|
44
43
|
if (entities.length > 0) {
|
|
45
|
-
const refs = entities.filter(p =>
|
|
46
|
-
const paths = entities.filter(p =>
|
|
44
|
+
const refs = entities.filter(p => typeof p !== 'string');
|
|
45
|
+
const paths = entities.filter(p => typeof p === 'string');
|
|
47
46
|
const will = !config.get('preferTs') ? 'will' : 'could';
|
|
48
|
-
|
|
47
|
+
CLIHelper.dump(` - ${will} use \`entities\` array (contains ${refs.length} references and ${paths.length} paths)`);
|
|
49
48
|
if (paths.length > 0) {
|
|
50
49
|
await DebugCommand.checkPaths(paths, 'red', config.get('baseDir'));
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
const entitiesTs = config.get('entitiesTs', []);
|
|
54
53
|
if (entitiesTs.length > 0) {
|
|
55
|
-
const refs = entitiesTs.filter(p =>
|
|
56
|
-
const paths = entitiesTs.filter(p =>
|
|
57
|
-
/*
|
|
54
|
+
const refs = entitiesTs.filter(p => typeof p !== 'string');
|
|
55
|
+
const paths = entitiesTs.filter(p => typeof p === 'string');
|
|
56
|
+
/* v8 ignore next */
|
|
58
57
|
const will = config.get('preferTs') ? 'will' : 'could';
|
|
59
|
-
|
|
60
|
-
/* istanbul ignore else */
|
|
58
|
+
CLIHelper.dump(` - ${will} use \`entitiesTs\` array (contains ${refs.length} references and ${paths.length} paths)`);
|
|
61
59
|
if (paths.length > 0) {
|
|
62
60
|
await DebugCommand.checkPaths(paths, 'red', config.get('baseDir'));
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
catch (e) {
|
|
67
|
-
|
|
65
|
+
CLIHelper.dump(`- configuration ${colors.red('not found')} ${colors.red(`(${e.message})`)}`);
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
static async checkPaths(paths, failedColor, baseDir) {
|
|
71
69
|
for (let path of paths) {
|
|
72
|
-
path =
|
|
73
|
-
path =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
CLIHelper_1.CLIHelper.dump(` - ${path} (${core_1.colors.green('found')})`);
|
|
70
|
+
path = Utils.absolutePath(path, baseDir);
|
|
71
|
+
path = Utils.normalizePath(path);
|
|
72
|
+
if (fs.pathExists(path)) {
|
|
73
|
+
CLIHelper.dump(` - ${path} (${colors.green('found')})`);
|
|
77
74
|
}
|
|
78
75
|
else {
|
|
79
|
-
|
|
76
|
+
CLIHelper.dump(` - ${path} (${colors[failedColor]('not found')})`);
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
exports.DebugCommand = DebugCommand;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class GenerateCacheCommand {
|
|
1
|
+
import { MetadataDiscovery, MetadataStorage, colors } from '@mikro-orm/core';
|
|
2
|
+
import { FileCacheAdapter } from '@mikro-orm/core/fs-utils';
|
|
3
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
4
|
+
export class GenerateCacheCommand {
|
|
7
5
|
command = 'cache:generate';
|
|
8
6
|
describe = 'Generate metadata cache';
|
|
9
7
|
builder = (args) => {
|
|
10
|
-
args.option('ts
|
|
11
|
-
alias: 'ts',
|
|
8
|
+
args.option('ts', {
|
|
12
9
|
type: 'boolean',
|
|
13
|
-
desc: `
|
|
10
|
+
desc: `Generate development cache for '.ts' files`,
|
|
14
11
|
});
|
|
15
12
|
args.option('combined', {
|
|
16
13
|
alias: 'c',
|
|
@@ -23,16 +20,15 @@ class GenerateCacheCommand {
|
|
|
23
20
|
*/
|
|
24
21
|
async handler(args) {
|
|
25
22
|
const options = args.combined ? { combined: './metadata.json' } : {};
|
|
26
|
-
const config = await
|
|
27
|
-
metadataCache: { enabled: true, adapter:
|
|
23
|
+
const config = await CLIHelper.getConfiguration(args.contextName, args.config, {
|
|
24
|
+
metadataCache: { enabled: true, adapter: FileCacheAdapter, options },
|
|
28
25
|
});
|
|
29
26
|
await config.getMetadataCacheAdapter().clear();
|
|
30
|
-
config.set('logger',
|
|
27
|
+
config.set('logger', CLIHelper.dump.bind(null));
|
|
31
28
|
config.set('debug', true);
|
|
32
|
-
const discovery = new
|
|
29
|
+
const discovery = new MetadataDiscovery(new MetadataStorage(), config.getDriver().getPlatform(), config);
|
|
33
30
|
await discovery.discover(args.ts ?? false);
|
|
34
31
|
const combined = args.combined && config.get('metadataCache').combined;
|
|
35
|
-
|
|
32
|
+
CLIHelper.dump(colors.green(`${combined ? 'Combined ' : ''}${args.ts ? 'TS' : 'JS'} metadata cache was successfully generated${combined ? ' to ' + combined : ''}`));
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.GenerateCacheCommand = GenerateCacheCommand;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
-
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator.js';
|
|
3
3
|
export type GenerateEntitiesArgs = BaseArgs & {
|
|
4
4
|
dump?: boolean;
|
|
5
5
|
save?: boolean;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GenerateEntitiesCommand = void 0;
|
|
4
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
5
|
-
class GenerateEntitiesCommand {
|
|
1
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
2
|
+
export class GenerateEntitiesCommand {
|
|
6
3
|
command = 'generate-entities';
|
|
7
4
|
describe = 'Generate entities based on current database schema';
|
|
8
5
|
/**
|
|
@@ -35,18 +32,17 @@ class GenerateEntitiesCommand {
|
|
|
35
32
|
*/
|
|
36
33
|
async handler(args) {
|
|
37
34
|
if (!args.save && !args.dump) {
|
|
38
|
-
return
|
|
35
|
+
return CLIHelper.showHelp();
|
|
39
36
|
}
|
|
40
|
-
const orm = await
|
|
37
|
+
const orm = await CLIHelper.getORM(args.contextName, args.config, { discovery: { warnWhenNoEntities: false } });
|
|
41
38
|
const dump = await orm.entityGenerator.generate({
|
|
42
39
|
save: args.save,
|
|
43
40
|
path: args.path,
|
|
44
41
|
schema: args.schema,
|
|
45
42
|
});
|
|
46
43
|
if (args.dump) {
|
|
47
|
-
|
|
44
|
+
CLIHelper.dump(dump.join('\n\n'));
|
|
48
45
|
}
|
|
49
46
|
await orm.close(true);
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
exports.GenerateEntitiesCommand = GenerateEntitiesCommand;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@mikro-orm/core");
|
|
5
|
-
const CLIHelper_1 = require("../CLIHelper");
|
|
6
|
-
class ImportCommand {
|
|
1
|
+
import { colors } from '@mikro-orm/core';
|
|
2
|
+
import { CLIHelper } from '../CLIHelper.js';
|
|
3
|
+
export class ImportCommand {
|
|
7
4
|
command = 'database:import <file>';
|
|
8
5
|
describe = 'Imports the SQL file to the database';
|
|
9
6
|
/**
|
|
10
7
|
* @inheritDoc
|
|
11
8
|
*/
|
|
12
9
|
async handler(args) {
|
|
13
|
-
const orm = await
|
|
10
|
+
const orm = await CLIHelper.getORM(args.contextName, args.config, { multipleStatements: true });
|
|
14
11
|
await orm.em.getConnection().loadFile(args.file);
|
|
15
|
-
|
|
12
|
+
CLIHelper.dump(colors.green(`File ${args.file} successfully imported`));
|
|
16
13
|
await orm.close(true);
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.ImportCommand = ImportCommand;
|