@mikro-orm/cli 6.3.14-dev.2 → 6.3.14-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/CLIConfigurator.d.ts +14 -2
- package/CLIConfigurator.js +20 -17
- package/cli +1 -1
- package/cli.js +1 -1
- package/commands/ClearCacheCommand.d.ts +4 -3
- package/commands/CreateDatabaseCommand.d.ts +4 -3
- package/commands/CreateSeederCommand.d.ts +8 -9
- package/commands/DatabaseSeedCommand.d.ts +9 -10
- package/commands/DebugCommand.d.ts +4 -3
- package/commands/DebugCommand.js +1 -1
- package/commands/GenerateCacheCommand.d.ts +5 -4
- package/commands/GenerateEntitiesCommand.d.ts +10 -9
- package/commands/ImportCommand.d.ts +4 -3
- package/commands/MigrationCommandFactory.d.ts +33 -13
- package/commands/MigrationCommandFactory.js +7 -4
- package/commands/SchemaCommandFactory.d.ts +42 -24
- package/commands/SchemaCommandFactory.js +1 -1
- package/esm +1 -1
- package/esm.js +1 -1
- package/package.json +3 -3
package/CLIConfigurator.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import yargs, { type CommandModule } from 'yargs';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export type BaseArgs = Awaited<ReturnType<typeof CLIConfigurator['createBasicConfig']>['argv']>;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseCommand<CommandArgs extends BaseArgs = BaseArgs> extends CommandModule<BaseArgs, CommandArgs> {
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* @internal
|
|
4
13
|
*/
|
|
5
14
|
export declare class CLIConfigurator {
|
|
6
|
-
static
|
|
15
|
+
private static createBasicConfig;
|
|
16
|
+
static configure(): yargs.Argv<{
|
|
17
|
+
config: string | undefined;
|
|
18
|
+
}>;
|
|
7
19
|
}
|
package/CLIConfigurator.js
CHANGED
|
@@ -4,9 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CLIConfigurator = void 0;
|
|
7
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
8
7
|
const core_1 = require("@mikro-orm/core");
|
|
8
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
9
9
|
const ClearCacheCommand_1 = require("./commands/ClearCacheCommand");
|
|
10
|
+
const CreateDatabaseCommand_1 = require("./commands/CreateDatabaseCommand");
|
|
11
|
+
const CreateSeederCommand_1 = require("./commands/CreateSeederCommand");
|
|
10
12
|
const DatabaseSeedCommand_1 = require("./commands/DatabaseSeedCommand");
|
|
11
13
|
const DebugCommand_1 = require("./commands/DebugCommand");
|
|
12
14
|
const GenerateCacheCommand_1 = require("./commands/GenerateCacheCommand");
|
|
@@ -14,13 +16,25 @@ const GenerateEntitiesCommand_1 = require("./commands/GenerateEntitiesCommand");
|
|
|
14
16
|
const ImportCommand_1 = require("./commands/ImportCommand");
|
|
15
17
|
const MigrationCommandFactory_1 = require("./commands/MigrationCommandFactory");
|
|
16
18
|
const SchemaCommandFactory_1 = require("./commands/SchemaCommandFactory");
|
|
17
|
-
const CreateSeederCommand_1 = require("./commands/CreateSeederCommand");
|
|
18
|
-
const CreateDatabaseCommand_1 = require("./commands/CreateDatabaseCommand");
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
class CLIConfigurator {
|
|
23
|
-
static
|
|
23
|
+
static createBasicConfig() {
|
|
24
|
+
return yargs_1.default
|
|
25
|
+
.scriptName('mikro-orm')
|
|
26
|
+
.usage('Usage: $0 <command> [options]')
|
|
27
|
+
.example('$0 schema:update --run', 'Runs schema synchronization')
|
|
28
|
+
.option('config', {
|
|
29
|
+
type: 'string',
|
|
30
|
+
desc: `Set path to the ORM configuration file`,
|
|
31
|
+
})
|
|
32
|
+
.alias('v', 'version')
|
|
33
|
+
.alias('h', 'help')
|
|
34
|
+
.recommendCommands()
|
|
35
|
+
.strict();
|
|
36
|
+
}
|
|
37
|
+
static configure() {
|
|
24
38
|
core_1.ConfigurationLoader.checkPackageVersion();
|
|
25
39
|
const settings = core_1.ConfigurationLoader.getSettings();
|
|
26
40
|
const version = core_1.Utils.getORMVersion();
|
|
@@ -31,17 +45,8 @@ class CLIConfigurator {
|
|
|
31
45
|
process.env.MIKRO_ORM_CLI_USE_TS_NODE ??= '0';
|
|
32
46
|
}
|
|
33
47
|
}
|
|
34
|
-
return
|
|
35
|
-
.scriptName('mikro-orm')
|
|
48
|
+
return CLIConfigurator.createBasicConfig()
|
|
36
49
|
.version(version)
|
|
37
|
-
.usage('Usage: $0 <command> [options]')
|
|
38
|
-
.example('$0 schema:update --run', 'Runs schema synchronization')
|
|
39
|
-
.option('config', {
|
|
40
|
-
type: 'string',
|
|
41
|
-
desc: `Set path to the ORM configuration file`,
|
|
42
|
-
})
|
|
43
|
-
.alias('v', 'version')
|
|
44
|
-
.alias('h', 'help')
|
|
45
50
|
.command(new ClearCacheCommand_1.ClearCacheCommand())
|
|
46
51
|
.command(new GenerateCacheCommand_1.GenerateCacheCommand())
|
|
47
52
|
.command(new GenerateEntitiesCommand_1.GenerateEntitiesCommand())
|
|
@@ -60,9 +65,7 @@ class CLIConfigurator {
|
|
|
60
65
|
.command(MigrationCommandFactory_1.MigrationCommandFactory.create('check'))
|
|
61
66
|
.command(MigrationCommandFactory_1.MigrationCommandFactory.create('pending'))
|
|
62
67
|
.command(MigrationCommandFactory_1.MigrationCommandFactory.create('fresh'))
|
|
63
|
-
.command(new DebugCommand_1.DebugCommand())
|
|
64
|
-
.recommendCommands()
|
|
65
|
-
.strict();
|
|
68
|
+
.command(new DebugCommand_1.DebugCommand());
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
exports.CLIConfigurator = CLIConfigurator;
|
package/cli
CHANGED
|
@@ -10,7 +10,7 @@ require('@jercle/yargonaut')
|
|
|
10
10
|
const CLIHelper_1 = require("./CLIHelper");
|
|
11
11
|
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
12
|
(async () => {
|
|
13
|
-
const argv =
|
|
13
|
+
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
14
|
const args = await argv.parse(process.argv.slice(2));
|
|
15
15
|
if (args._.length === 0) {
|
|
16
16
|
CLIHelper_1.CLIHelper.showHelp();
|
package/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ require('@jercle/yargonaut')
|
|
|
10
10
|
const CLIHelper_1 = require("./CLIHelper");
|
|
11
11
|
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
12
|
(async () => {
|
|
13
|
-
const argv =
|
|
13
|
+
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
14
|
const args = await argv.parse(process.argv.slice(2));
|
|
15
15
|
if (args._.length === 0) {
|
|
16
16
|
CLIHelper_1.CLIHelper.showHelp();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase
|
|
2
|
-
|
|
1
|
+
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
export declare class ClearCacheCommand implements BaseCommand {
|
|
3
4
|
command: string;
|
|
4
5
|
describe: string;
|
|
5
6
|
/**
|
|
6
7
|
* @inheritDoc
|
|
7
8
|
*/
|
|
8
|
-
handler(args: ArgumentsCamelCase): Promise<void>;
|
|
9
|
+
handler(args: ArgumentsCamelCase<BaseArgs>): Promise<void>;
|
|
9
10
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase
|
|
2
|
-
|
|
1
|
+
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
export declare class CreateDatabaseCommand implements BaseCommand {
|
|
3
4
|
command: string;
|
|
4
5
|
describe: string;
|
|
5
6
|
/**
|
|
6
7
|
* @inheritDoc
|
|
7
8
|
*/
|
|
8
|
-
handler(args: ArgumentsCamelCase): Promise<void>;
|
|
9
|
+
handler(args: ArgumentsCamelCase<BaseArgs>): Promise<void>;
|
|
9
10
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
2
|
-
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
type CreateSeederCommandArgs = BaseArgs & {
|
|
3
4
|
seeder: string;
|
|
4
|
-
}
|
|
5
|
+
};
|
|
6
|
+
export declare class CreateSeederCommand implements BaseCommand<CreateSeederCommandArgs> {
|
|
5
7
|
command: string;
|
|
6
8
|
describe: string;
|
|
7
|
-
builder: (args: Argv<
|
|
8
|
-
seeder: string;
|
|
9
|
-
}>;
|
|
9
|
+
builder: (args: Argv<BaseArgs>) => Argv<CreateSeederCommandArgs>;
|
|
10
10
|
/**
|
|
11
11
|
* @inheritDoc
|
|
12
12
|
*/
|
|
13
|
-
handler(args: ArgumentsCamelCase<
|
|
14
|
-
seeder?: string;
|
|
15
|
-
}>): Promise<void>;
|
|
13
|
+
handler(args: ArgumentsCamelCase<CreateSeederCommandArgs>): Promise<void>;
|
|
16
14
|
/**
|
|
17
15
|
* Will return a seeder name that is formatted like this EntitySeeder
|
|
18
16
|
*/
|
|
19
17
|
private static getSeederClassName;
|
|
20
18
|
}
|
|
19
|
+
export {};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
type DatabaseSeedArgs = BaseArgs & {
|
|
4
|
+
class?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class DatabaseSeedCommand implements BaseCommand<DatabaseSeedArgs> {
|
|
5
7
|
command: string;
|
|
6
8
|
describe: string;
|
|
7
|
-
builder: (args: Argv<
|
|
8
|
-
class: string;
|
|
9
|
-
}>;
|
|
9
|
+
builder: (args: Argv<BaseArgs>) => Argv<DatabaseSeedArgs>;
|
|
10
10
|
/**
|
|
11
11
|
* @inheritDoc
|
|
12
12
|
*/
|
|
13
|
-
handler(args: ArgumentsCamelCase<
|
|
14
|
-
class?: string;
|
|
15
|
-
}>): Promise<void>;
|
|
13
|
+
handler(args: ArgumentsCamelCase<DatabaseSeedArgs>): Promise<void>;
|
|
16
14
|
}
|
|
15
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
export declare class DebugCommand implements BaseCommand {
|
|
3
4
|
command: string;
|
|
4
5
|
describe: string;
|
|
5
6
|
/**
|
|
6
7
|
* @inheritDoc
|
|
7
8
|
*/
|
|
8
|
-
handler(): Promise<void>;
|
|
9
|
+
handler(args: ArgumentsCamelCase<BaseArgs>): Promise<void>;
|
|
9
10
|
private static checkPaths;
|
|
10
11
|
}
|
package/commands/DebugCommand.js
CHANGED
|
@@ -9,7 +9,7 @@ class DebugCommand {
|
|
|
9
9
|
/**
|
|
10
10
|
* @inheritDoc
|
|
11
11
|
*/
|
|
12
|
-
async handler() {
|
|
12
|
+
async handler(args) {
|
|
13
13
|
CLIHelper_1.CLIHelper.dump(`Current ${core_1.colors.cyan('MikroORM')} CLI configuration`);
|
|
14
14
|
await CLIHelper_1.CLIHelper.dumpDependencies();
|
|
15
15
|
const settings = core_1.ConfigurationLoader.getSettings();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
2
|
-
type
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
type CacheArgs = BaseArgs & {
|
|
3
4
|
ts?: boolean;
|
|
4
5
|
combined?: string;
|
|
5
6
|
};
|
|
6
|
-
export declare class GenerateCacheCommand
|
|
7
|
+
export declare class GenerateCacheCommand implements BaseCommand<CacheArgs> {
|
|
7
8
|
command: string;
|
|
8
9
|
describe: string;
|
|
9
|
-
builder: (args: Argv<
|
|
10
|
+
builder: (args: Argv<BaseArgs>) => Argv<CacheArgs>;
|
|
10
11
|
/**
|
|
11
12
|
* @inheritDoc
|
|
12
13
|
*/
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
export type GenerateEntitiesArgs = BaseArgs & {
|
|
4
|
+
dump?: boolean;
|
|
5
|
+
save?: boolean;
|
|
6
|
+
path?: string;
|
|
7
|
+
schema?: string;
|
|
7
8
|
};
|
|
8
|
-
export declare class GenerateEntitiesCommand
|
|
9
|
+
export declare class GenerateEntitiesCommand implements BaseCommand<GenerateEntitiesArgs> {
|
|
9
10
|
command: string;
|
|
10
11
|
describe: string;
|
|
11
12
|
/**
|
|
12
13
|
* @inheritDoc
|
|
13
14
|
*/
|
|
14
|
-
builder(args: Argv): Argv<
|
|
15
|
+
builder(args: Argv): Argv<GenerateEntitiesArgs>;
|
|
15
16
|
/**
|
|
16
17
|
* @inheritDoc
|
|
17
18
|
*/
|
|
18
|
-
handler(args: ArgumentsCamelCase<
|
|
19
|
+
handler(args: ArgumentsCamelCase<GenerateEntitiesArgs>): Promise<void>;
|
|
19
20
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase
|
|
2
|
-
|
|
1
|
+
import type { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import type { BaseArgs, BaseCommand } from '../CLIConfigurator';
|
|
3
|
+
export declare class ImportCommand implements BaseCommand {
|
|
3
4
|
command: string;
|
|
4
5
|
describe: string;
|
|
5
6
|
/**
|
|
6
7
|
* @inheritDoc
|
|
7
8
|
*/
|
|
8
|
-
handler(args: ArgumentsCamelCase): Promise<void>;
|
|
9
|
+
handler(args: ArgumentsCamelCase<BaseArgs>): Promise<void>;
|
|
9
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs } from '../CLIConfigurator';
|
|
2
3
|
export declare class MigrationCommandFactory {
|
|
3
4
|
static readonly DESCRIPTIONS: {
|
|
4
5
|
create: string;
|
|
@@ -9,11 +10,21 @@ export declare class MigrationCommandFactory {
|
|
|
9
10
|
pending: string;
|
|
10
11
|
fresh: string;
|
|
11
12
|
};
|
|
12
|
-
static create<
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
static create<const T extends MigratorMethod>(command: T): {
|
|
14
|
+
command: string;
|
|
15
|
+
describe: {
|
|
16
|
+
create: string;
|
|
17
|
+
up: string;
|
|
18
|
+
down: string;
|
|
19
|
+
list: string;
|
|
20
|
+
check: string;
|
|
21
|
+
pending: string;
|
|
22
|
+
fresh: string;
|
|
23
|
+
}[T];
|
|
24
|
+
builder: (args: Argv<BaseArgs>) => Argv<MigrationOptionsMap[T]>;
|
|
25
|
+
handler: (args: ArgumentsCamelCase<MigrationOptionsMap[T]>) => Promise<void>;
|
|
15
26
|
};
|
|
16
|
-
static configureMigrationCommand(args: Argv
|
|
27
|
+
static configureMigrationCommand<const T extends MigratorMethod>(args: Argv<BaseArgs>, method: T): Argv<MigrationOptionsMap[T]>;
|
|
17
28
|
private static configureUpDownCommand;
|
|
18
29
|
private static configureCreateCommand;
|
|
19
30
|
static handleMigrationCommand(args: ArgumentsCamelCase<Opts>, method: MigratorMethod): Promise<void>;
|
|
@@ -27,22 +38,31 @@ export declare class MigrationCommandFactory {
|
|
|
27
38
|
private static getUpDownOptions;
|
|
28
39
|
private static getUpDownSuccessMessage;
|
|
29
40
|
}
|
|
30
|
-
type
|
|
31
|
-
type CliUpDownOptions = {
|
|
41
|
+
type CliUpDownOptions = BaseArgs & {
|
|
32
42
|
to?: string | number;
|
|
33
43
|
from?: string | number;
|
|
34
44
|
only?: string;
|
|
35
45
|
};
|
|
36
|
-
type
|
|
37
|
-
|
|
46
|
+
type MigratorFreshOptions = BaseArgs & {
|
|
47
|
+
dropDb?: boolean;
|
|
48
|
+
seed?: string;
|
|
49
|
+
};
|
|
50
|
+
type MigratorCreateOptions = BaseArgs & {
|
|
38
51
|
blank?: boolean;
|
|
39
52
|
initial?: boolean;
|
|
40
53
|
path?: string;
|
|
41
|
-
|
|
42
|
-
seed: string;
|
|
54
|
+
dump?: boolean;
|
|
43
55
|
name?: string;
|
|
44
56
|
};
|
|
45
|
-
type
|
|
46
|
-
|
|
57
|
+
type MigrationOptionsMap = {
|
|
58
|
+
create: MigratorCreateOptions;
|
|
59
|
+
check: BaseArgs;
|
|
60
|
+
up: CliUpDownOptions;
|
|
61
|
+
down: CliUpDownOptions;
|
|
62
|
+
list: BaseArgs;
|
|
63
|
+
pending: BaseArgs;
|
|
64
|
+
fresh: MigratorFreshOptions;
|
|
47
65
|
};
|
|
66
|
+
type MigratorMethod = keyof MigrationOptionsMap;
|
|
67
|
+
type Opts = BaseArgs & MigratorCreateOptions & CliUpDownOptions & MigratorFreshOptions;
|
|
48
68
|
export {};
|
|
@@ -23,13 +23,13 @@ class MigrationCommandFactory {
|
|
|
23
23
|
}
|
|
24
24
|
static configureMigrationCommand(args, method) {
|
|
25
25
|
if (method === 'create') {
|
|
26
|
-
this.configureCreateCommand(args);
|
|
26
|
+
return this.configureCreateCommand(args);
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
29
|
-
this.configureUpDownCommand(args, method);
|
|
28
|
+
if (method === 'up' || method === 'down') {
|
|
29
|
+
return this.configureUpDownCommand(args, method);
|
|
30
30
|
}
|
|
31
31
|
if (method === 'fresh') {
|
|
32
|
-
this.configureFreshCommand(args);
|
|
32
|
+
return this.configureFreshCommand(args);
|
|
33
33
|
}
|
|
34
34
|
return args;
|
|
35
35
|
}
|
|
@@ -49,6 +49,7 @@ class MigrationCommandFactory {
|
|
|
49
49
|
type: 'string',
|
|
50
50
|
desc: 'Migrate only specified versions',
|
|
51
51
|
});
|
|
52
|
+
return args;
|
|
52
53
|
}
|
|
53
54
|
static configureCreateCommand(args) {
|
|
54
55
|
args.option('b', {
|
|
@@ -76,6 +77,7 @@ class MigrationCommandFactory {
|
|
|
76
77
|
type: 'string',
|
|
77
78
|
desc: 'Specify custom name for the file',
|
|
78
79
|
});
|
|
80
|
+
return args;
|
|
79
81
|
}
|
|
80
82
|
static async handleMigrationCommand(args, method) {
|
|
81
83
|
// to be able to run have a master transaction, but run marked migrations outside of it, we need a second connection
|
|
@@ -113,6 +115,7 @@ class MigrationCommandFactory {
|
|
|
113
115
|
type: 'boolean',
|
|
114
116
|
desc: 'Drop the whole database',
|
|
115
117
|
});
|
|
118
|
+
return args;
|
|
116
119
|
}
|
|
117
120
|
static async handleUpDownCommand(args, migrator, method) {
|
|
118
121
|
const opts = MigrationCommandFactory.getUpDownOptions(args);
|
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
import type { ArgumentsCamelCase, Argv
|
|
1
|
+
import type { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import type { BaseArgs } from '../CLIConfigurator';
|
|
2
3
|
export declare class SchemaCommandFactory {
|
|
3
4
|
static readonly DESCRIPTIONS: {
|
|
4
|
-
create:
|
|
5
|
-
update:
|
|
6
|
-
drop:
|
|
7
|
-
fresh:
|
|
5
|
+
readonly create: "Create database schema based on current metadata";
|
|
6
|
+
readonly update: "Update database schema based on current metadata";
|
|
7
|
+
readonly drop: "Drop database schema based on current metadata";
|
|
8
|
+
readonly fresh: "Drop and recreate database schema based on current metadata";
|
|
8
9
|
};
|
|
9
10
|
static readonly SUCCESS_MESSAGES: {
|
|
10
|
-
create:
|
|
11
|
-
update:
|
|
12
|
-
drop:
|
|
13
|
-
fresh:
|
|
11
|
+
readonly create: "Schema successfully created";
|
|
12
|
+
readonly update: "Schema successfully updated";
|
|
13
|
+
readonly drop: "Schema successfully dropped";
|
|
14
|
+
readonly fresh: "Schema successfully dropped and recreated";
|
|
14
15
|
};
|
|
15
|
-
static create<
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
static create<const T extends SchemaMethod>(command: T): {
|
|
17
|
+
command: string;
|
|
18
|
+
describe: "Create database schema based on current metadata" | "Update database schema based on current metadata" | "Drop database schema based on current metadata" | "Drop and recreate database schema based on current metadata";
|
|
19
|
+
builder: (args: Argv<BaseArgs>) => Argv<OptionsMap[T]>;
|
|
20
|
+
handler: (args: ArgumentsCamelCase<OptionsMap[T]>) => Promise<void>;
|
|
18
21
|
};
|
|
19
|
-
static configureSchemaCommand(args: Argv
|
|
22
|
+
static configureSchemaCommand<const T extends SchemaMethod>(args: Argv<BaseArgs>, command: T): Argv<OptionsMap[T]>;
|
|
20
23
|
static handleSchemaCommand(args: ArgumentsCamelCase<Options>, method: SchemaMethod, successMessage: string): Promise<void>;
|
|
21
24
|
}
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
run: boolean;
|
|
26
|
-
fkChecks: boolean;
|
|
27
|
-
dropMigrationsTable: boolean;
|
|
28
|
-
dropDb: boolean;
|
|
29
|
-
dropTables: boolean;
|
|
30
|
-
safe: boolean;
|
|
31
|
-
seed: string;
|
|
32
|
-
schema: string;
|
|
25
|
+
type SchemaOptions = BaseArgs & {
|
|
26
|
+
run?: boolean;
|
|
27
|
+
schema?: string;
|
|
33
28
|
};
|
|
29
|
+
type NonFreshOptions = SchemaOptions & {
|
|
30
|
+
dump?: boolean;
|
|
31
|
+
fkChecks?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type SchemaCreateOptions = NonFreshOptions & {
|
|
34
|
+
seed?: string;
|
|
35
|
+
};
|
|
36
|
+
export type SchemaUpdateOptions = NonFreshOptions & {
|
|
37
|
+
safe?: boolean;
|
|
38
|
+
dropTables?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type SchemaDropOptions = NonFreshOptions & {
|
|
41
|
+
dropDb?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type SchemaFreshOptions = SchemaOptions & Omit<SchemaCreateOptions & SchemaDropOptions, keyof NonFreshOptions>;
|
|
44
|
+
type OptionsMap = {
|
|
45
|
+
create: SchemaCreateOptions;
|
|
46
|
+
update: SchemaUpdateOptions;
|
|
47
|
+
drop: SchemaDropOptions;
|
|
48
|
+
fresh: SchemaFreshOptions;
|
|
49
|
+
};
|
|
50
|
+
type SchemaMethod = keyof OptionsMap;
|
|
51
|
+
export type Options = SchemaCreateOptions & SchemaUpdateOptions & SchemaDropOptions & SchemaFreshOptions;
|
|
34
52
|
export {};
|
|
@@ -105,7 +105,7 @@ class SchemaCommandFactory {
|
|
|
105
105
|
const m = method + 'Schema';
|
|
106
106
|
await generator[m](params);
|
|
107
107
|
}
|
|
108
|
-
if (args.seed !== undefined) {
|
|
108
|
+
if (typeof args.seed !== 'undefined') {
|
|
109
109
|
const seeder = orm.getSeeder();
|
|
110
110
|
await seeder.seedString(args.seed || orm.config.get('seeder').defaultSeeder);
|
|
111
111
|
}
|
package/esm
CHANGED
|
@@ -10,7 +10,7 @@ require('@jercle/yargonaut')
|
|
|
10
10
|
const CLIHelper_1 = require("./CLIHelper");
|
|
11
11
|
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
12
|
(async () => {
|
|
13
|
-
const argv =
|
|
13
|
+
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
14
|
const args = await argv.parse(process.argv.slice(2));
|
|
15
15
|
if (args._.length === 0) {
|
|
16
16
|
CLIHelper_1.CLIHelper.showHelp();
|
package/esm.js
CHANGED
|
@@ -10,7 +10,7 @@ require('@jercle/yargonaut')
|
|
|
10
10
|
const CLIHelper_1 = require("./CLIHelper");
|
|
11
11
|
const CLIConfigurator_1 = require("./CLIConfigurator");
|
|
12
12
|
(async () => {
|
|
13
|
-
const argv =
|
|
13
|
+
const argv = CLIConfigurator_1.CLIConfigurator.configure();
|
|
14
14
|
const args = await argv.parse(process.argv.slice(2));
|
|
15
15
|
if (args._.length === 0) {
|
|
16
16
|
CLIHelper_1.CLIHelper.showHelp();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/cli",
|
|
3
|
-
"version": "6.3.14-dev.
|
|
3
|
+
"version": "6.3.14-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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@jercle/yargonaut": "1.1.5",
|
|
66
|
-
"@mikro-orm/core": "6.3.14-dev.
|
|
67
|
-
"@mikro-orm/knex": "6.3.14-dev.
|
|
66
|
+
"@mikro-orm/core": "6.3.14-dev.21",
|
|
67
|
+
"@mikro-orm/knex": "6.3.14-dev.21",
|
|
68
68
|
"fs-extra": "11.2.0",
|
|
69
69
|
"tsconfig-paths": "4.2.0",
|
|
70
70
|
"yargs": "17.7.2"
|