@riao/cli 3.0.0 → 3.0.1
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/README.md +2 -35
- package/bin/database-create-command.d.ts +21 -21
- package/bin/database-create-command.js +68 -82
- package/bin/database-create-command.js.map +1 -1
- package/bin/index.d.ts +2 -2
- package/bin/index.js +20 -22
- package/bin/index.js.map +1 -1
- package/bin/migration-create-command.d.ts +13 -13
- package/bin/migration-create-command.js +37 -51
- package/bin/migration-create-command.js.map +1 -1
- package/bin/migration-run-command.d.ts +14 -14
- package/bin/migration-run-command.js +19 -33
- package/bin/migration-run-command.js.map +1 -1
- package/bin/schema-build-command.d.ts +12 -12
- package/bin/schema-build-command.js +17 -31
- package/bin/schema-build-command.js.map +1 -1
- package/bin/seed-create-command.d.ts +13 -13
- package/bin/seed-create-command.js +35 -49
- package/bin/seed-create-command.js.map +1 -1
- package/bin/seed-run-command.d.ts +15 -15
- package/bin/seed-run-command.js +28 -37
- package/bin/seed-run-command.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/name-class-and-file.d.ts +10 -10
- package/name-class-and-file.js +45 -45
- package/name-class-and-file.js.map +1 -1
- package/options/database-option.d.ts +2 -2
- package/options/database-option.js +9 -9
- package/options/database-option.js.map +1 -1
- package/options/db-type-option.d.ts +13 -13
- package/options/db-type-option.js +57 -57
- package/options/db-type-option.js.map +1 -1
- package/options/direction-option.d.ts +2 -2
- package/options/direction-option.js +10 -10
- package/options/direction-option.js.map +1 -1
- package/options/index.d.ts +6 -6
- package/options/index.js +16 -16
- package/options/name-option.d.ts +2 -2
- package/options/name-option.js +8 -8
- package/options/name-option.js.map +1 -1
- package/options/seed-option.d.ts +2 -2
- package/options/seed-option.js +8 -8
- package/options/seed-option.js.map +1 -1
- package/options/steps-option.d.ts +2 -2
- package/options/steps-option.js +9 -9
- package/options/steps-option.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
1
|
# riao-cli - Readme
|
|
2
2
|
|
|
3
|
-
## Development
|
|
3
|
+
## Contributing & Development
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Running Tests
|
|
8
|
-
|
|
9
|
-
To run unit tests, `npm run test`
|
|
10
|
-
|
|
11
|
-
## Scripts
|
|
12
|
-
|
|
13
|
-
You can write custom scripts in the `script/` directory. See `script/example.ts` as an example.
|
|
14
|
-
|
|
15
|
-
Run your script with `npm run script -- example`
|
|
16
|
-
|
|
17
|
-
## Compiling
|
|
18
|
-
|
|
19
|
-
### Debug Builds
|
|
20
|
-
|
|
21
|
-
To compile a debug build, run `npm run build`. The build output will appear in the `./dist` folder.
|
|
22
|
-
|
|
23
|
-
### Prod Builds
|
|
24
|
-
|
|
25
|
-
To compile a production build, run `npm run lint:prod && npm run build`. The build output will appear in the `./dist` folder.
|
|
26
|
-
|
|
27
|
-
## More
|
|
28
|
-
|
|
29
|
-
### Generating Docs
|
|
30
|
-
|
|
31
|
-
`npm run doc` and browse docs/index.html!
|
|
32
|
-
|
|
33
|
-
### Deploying to npm
|
|
34
|
-
|
|
35
|
-
1. Did you bump your version?
|
|
36
|
-
2. `npm run publish`
|
|
37
|
-
|
|
38
|
-
You can test your build by running `npm run script -- pack`
|
|
5
|
+
See [contributing.md](docs/contributing/contributing.md) for information on how to develop or contribute to this project!
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Command,
|
|
2
|
-
import { DbDrivers } from '../options';
|
|
3
|
-
interface Args {
|
|
4
|
-
name: string;
|
|
5
|
-
driver: DbDrivers;
|
|
6
|
-
}
|
|
7
|
-
export declare class DatabaseCreateCommand extends Command {
|
|
8
|
-
|
|
9
|
-
description: string;
|
|
10
|
-
positional: {
|
|
11
|
-
default: string;
|
|
12
|
-
key: string;
|
|
13
|
-
type
|
|
14
|
-
alias?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
choices?: string[] | number[];
|
|
17
|
-
}[];
|
|
18
|
-
options: import("ts-commands").
|
|
19
|
-
handle(args: Args): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
1
|
+
import { Command, ParsedArguments } from 'ts-commands';
|
|
2
|
+
import { DbDrivers } from '../options';
|
|
3
|
+
interface Args extends ParsedArguments {
|
|
4
|
+
name: string;
|
|
5
|
+
driver: DbDrivers;
|
|
6
|
+
}
|
|
7
|
+
export declare class DatabaseCreateCommand extends Command {
|
|
8
|
+
key: string;
|
|
9
|
+
description: string;
|
|
10
|
+
positional: {
|
|
11
|
+
default: string;
|
|
12
|
+
key: string;
|
|
13
|
+
type?: import("ts-commands").OptionType | undefined;
|
|
14
|
+
alias?: string | undefined;
|
|
15
|
+
description?: string | undefined;
|
|
16
|
+
choices?: string[] | number[] | undefined;
|
|
17
|
+
}[];
|
|
18
|
+
options: import("ts-commands").CommandOption[];
|
|
19
|
+
handle(args: Args): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -1,83 +1,69 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(0, fs_1.writeFileSync)(envFilePath, envFile.join('\n'));
|
|
70
|
-
(0, fs_1.writeFileSync)(envFilePath + '.example', envFile.join('\n'));
|
|
71
|
-
// Create migrations dir
|
|
72
|
-
(0, fs_1.mkdirSync)(migrationsDir, { recursive: true });
|
|
73
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(migrationsDir, '.gitignore'), '');
|
|
74
|
-
// Create seeds dir
|
|
75
|
-
(0, fs_1.mkdirSync)(seedsDir, { recursive: true });
|
|
76
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(seedsDir, '.gitignore'), '');
|
|
77
|
-
// Install database
|
|
78
|
-
(0, child_process_1.execSync)('npm i ' + baseClassPackage);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.DatabaseCreateCommand = DatabaseCreateCommand;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseCreateCommand = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const database_1 = require("@riao/dbal/database");
|
|
7
|
+
const options_1 = require("../options");
|
|
8
|
+
const ts_commands_1 = require("ts-commands");
|
|
9
|
+
const name_class_and_file_1 = require("../name-class-and-file");
|
|
10
|
+
const options_2 = require("../options");
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
class DatabaseCreateCommand extends ts_commands_1.Command {
|
|
13
|
+
key = 'db:create';
|
|
14
|
+
description = 'Create a new database';
|
|
15
|
+
positional = [{ ...options_1.nameOption, default: 'main' }];
|
|
16
|
+
options = [options_2.dbDriverOption];
|
|
17
|
+
async handle(args) {
|
|
18
|
+
let { fileName, className } = (0, name_class_and_file_1.nameClassAndFile)(args.name);
|
|
19
|
+
const folderName = fileName.replace('.ts', '');
|
|
20
|
+
const constName = className.replace(/(?:^|\s)\S/, (a) => a.toLowerCase()) + 'db';
|
|
21
|
+
className += 'Database';
|
|
22
|
+
const rootDir = (0, database_1.getDatabasePath)();
|
|
23
|
+
const databaseDir = (0, path_1.join)(rootDir, folderName);
|
|
24
|
+
const migrationsDir = (0, path_1.join)(databaseDir, 'migrations');
|
|
25
|
+
const seedsDir = (0, path_1.join)(databaseDir, 'seeds');
|
|
26
|
+
const dbTypeProperties = options_2.dbDriverProperties[args.driver];
|
|
27
|
+
const baseClassName = dbTypeProperties.className;
|
|
28
|
+
const baseClassPackage = dbTypeProperties.package;
|
|
29
|
+
if ((0, fs_1.existsSync)(databaseDir)) {
|
|
30
|
+
throw new Error('Database ' + folderName + ' already exists!');
|
|
31
|
+
}
|
|
32
|
+
(0, fs_1.mkdirSync)(databaseDir, { recursive: true });
|
|
33
|
+
// Create index file
|
|
34
|
+
const indexFilePath = (0, path_1.join)(databaseDir, 'index.ts');
|
|
35
|
+
const indexFile = [
|
|
36
|
+
`import { ${baseClassName} } from \'${baseClassPackage}\';`,
|
|
37
|
+
'',
|
|
38
|
+
`export default class ${className} extends ${baseClassName} {`,
|
|
39
|
+
`\toverride name = '${folderName}';`,
|
|
40
|
+
'}',
|
|
41
|
+
'',
|
|
42
|
+
`export const ${constName} = new ${className}();`,
|
|
43
|
+
'',
|
|
44
|
+
];
|
|
45
|
+
(0, fs_1.writeFileSync)(indexFilePath, indexFile.join('\n'));
|
|
46
|
+
// Create .env example
|
|
47
|
+
const envFileName = folderName + '.db.env';
|
|
48
|
+
const envFilePath = (0, path_1.join)(databaseDir, envFileName);
|
|
49
|
+
const envFile = [
|
|
50
|
+
'host="localhost"',
|
|
51
|
+
`port=${dbTypeProperties.port}`,
|
|
52
|
+
'username=""',
|
|
53
|
+
'password=""',
|
|
54
|
+
'database=""',
|
|
55
|
+
];
|
|
56
|
+
(0, fs_1.writeFileSync)(envFilePath, envFile.join('\n'));
|
|
57
|
+
(0, fs_1.writeFileSync)(envFilePath + '.example', envFile.join('\n'));
|
|
58
|
+
// Create migrations dir
|
|
59
|
+
(0, fs_1.mkdirSync)(migrationsDir, { recursive: true });
|
|
60
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(migrationsDir, '.gitignore'), '');
|
|
61
|
+
// Create seeds dir
|
|
62
|
+
(0, fs_1.mkdirSync)(seedsDir, { recursive: true });
|
|
63
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(seedsDir, '.gitignore'), '');
|
|
64
|
+
// Install database
|
|
65
|
+
(0, child_process_1.execSync)('npm i ' + baseClassPackage);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.DatabaseCreateCommand = DatabaseCreateCommand;
|
|
83
69
|
//# sourceMappingURL=database-create-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-create-command.js","sourceRoot":"","sources":["../../../src/bin/database-create-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"database-create-command.js","sourceRoot":"","sources":["../../../src/bin/database-create-command.ts"],"names":[],"mappings":";;;AAAA,+BAAwC;AACxC,2BAA0D;AAC1D,kDAAoE;AACpE,wCAAwD;AACxD,6CAAuD;AACvD,gEAA0D;AAC1D,wCAA2E;AAC3E,iDAAyC;AAOzC,MAAa,qBAAsB,SAAQ,qBAAO;IACxC,GAAG,GAAG,WAAW,CAAC;IAClB,WAAW,GAAG,uBAAuB,CAAC;IAEtC,UAAU,GAAG,CAAC,EAAE,GAAG,oBAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAElD,OAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IAE3B,KAAK,CAAC,MAAM,CAAC,IAAU;QAC/B,IAAI,EAAE,QAAQ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};
|
package/bin/index.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
#! /usr/bin/env ts-node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const ts_commands_1 = require("ts-commands");
|
|
5
|
-
const database_create_command_1 = require("./database-create-command");
|
|
6
|
-
const migration_create_command_1 = require("./migration-create-command");
|
|
7
|
-
const migration_run_command_1 = require("./migration-run-command");
|
|
8
|
-
const schema_build_command_1 = require("./schema-build-command");
|
|
9
|
-
const seed_create_command_1 = require("./seed-create-command");
|
|
10
|
-
const seed_run_command_1 = require("./seed-run-command");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
forceExit: true,
|
|
22
|
-
});
|
|
1
|
+
#! /usr/bin/env ts-node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const ts_commands_1 = require("ts-commands");
|
|
5
|
+
const database_create_command_1 = require("./database-create-command");
|
|
6
|
+
const migration_create_command_1 = require("./migration-create-command");
|
|
7
|
+
const migration_run_command_1 = require("./migration-run-command");
|
|
8
|
+
const schema_build_command_1 = require("./schema-build-command");
|
|
9
|
+
const seed_create_command_1 = require("./seed-create-command");
|
|
10
|
+
const seed_run_command_1 = require("./seed-run-command");
|
|
11
|
+
new ts_commands_1.CommandDispatcher({
|
|
12
|
+
commands: [
|
|
13
|
+
database_create_command_1.DatabaseCreateCommand,
|
|
14
|
+
migration_create_command_1.MigrationCreateCommand,
|
|
15
|
+
migration_run_command_1.MigrationRunCommand,
|
|
16
|
+
schema_build_command_1.SchemaBuildCommand,
|
|
17
|
+
seed_create_command_1.SeedCreateCommand,
|
|
18
|
+
seed_run_command_1.SeedRunCommand,
|
|
19
|
+
],
|
|
20
|
+
}).run();
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
package/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bin/index.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bin/index.ts"],"names":[],"mappings":";;;AAEA,6CAAgD;AAEhD,uEAAkE;AAClE,yEAAoE;AACpE,mEAA8D;AAC9D,iEAA4D;AAC5D,+DAA0D;AAC1D,yDAAoD;AAEpD,IAAI,+BAAiB,CAAC;IACrB,QAAQ,EAAE;QACT,+CAAqB;QACrB,iDAAsB;QACtB,2CAAmB;QACnB,yCAAkB;QAClB,uCAAiB;QACjB,iCAAc;KACd;CACD,CAAC,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Command } from 'ts-commands';
|
|
2
|
-
interface Args {
|
|
3
|
-
name: string;
|
|
4
|
-
database: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class MigrationCreateCommand extends Command {
|
|
7
|
-
|
|
8
|
-
description: string;
|
|
9
|
-
positional: import("ts-commands").
|
|
10
|
-
options: import("ts-commands").
|
|
11
|
-
handle(args: Args): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
1
|
+
import { Command, ParsedArguments } from 'ts-commands';
|
|
2
|
+
interface Args extends ParsedArguments {
|
|
3
|
+
name: string;
|
|
4
|
+
database: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class MigrationCreateCommand extends Command {
|
|
7
|
+
key: string;
|
|
8
|
+
description: string;
|
|
9
|
+
positional: import("ts-commands").CommandOption[];
|
|
10
|
+
options: import("ts-commands").CommandOption[];
|
|
11
|
+
handle(args: Args): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'\tasync down() {',
|
|
39
|
-
'\t\t',
|
|
40
|
-
'\t}',
|
|
41
|
-
'}',
|
|
42
|
-
'',
|
|
43
|
-
];
|
|
44
|
-
const databaseDir = (0, database_1.getDatabasePath)();
|
|
45
|
-
const db = yield (0, database_1.loadDatabase)(databaseDir, args.database);
|
|
46
|
-
const path = (0, path_1.join)(db.getMigrationsDirectory(), `${Date.now()}-${fileName}`);
|
|
47
|
-
(0, fs_1.writeFileSync)(path, file.join('\n'));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.MigrationCreateCommand = MigrationCreateCommand;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MigrationCreateCommand = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const database_1 = require("@riao/dbal/database");
|
|
7
|
+
const options_1 = require("../options");
|
|
8
|
+
const ts_commands_1 = require("ts-commands");
|
|
9
|
+
const name_class_and_file_1 = require("../name-class-and-file");
|
|
10
|
+
class MigrationCreateCommand extends ts_commands_1.Command {
|
|
11
|
+
key = 'migration:create';
|
|
12
|
+
description = 'Create a new migration file';
|
|
13
|
+
positional = [options_1.nameOption];
|
|
14
|
+
options = [options_1.databaseOption];
|
|
15
|
+
async handle(args) {
|
|
16
|
+
const { fileName, className } = (0, name_class_and_file_1.nameClassAndFile)(args.name);
|
|
17
|
+
const file = [
|
|
18
|
+
'import { Migration } from \'@riao/dbal\';',
|
|
19
|
+
'',
|
|
20
|
+
`export default class ${className} extends Migration {`,
|
|
21
|
+
'\toverride async up() {',
|
|
22
|
+
'\t\t',
|
|
23
|
+
'\t}',
|
|
24
|
+
'',
|
|
25
|
+
'\toverride async down() {',
|
|
26
|
+
'\t\t',
|
|
27
|
+
'\t}',
|
|
28
|
+
'}',
|
|
29
|
+
'',
|
|
30
|
+
];
|
|
31
|
+
const databaseDir = (0, database_1.getDatabasePath)();
|
|
32
|
+
const db = await (0, database_1.loadDatabase)(databaseDir, args.database);
|
|
33
|
+
const path = (0, path_1.join)(db.getMigrationsDirectory(), `${Date.now()}-${fileName}`);
|
|
34
|
+
(0, fs_1.writeFileSync)(path, file.join('\n'));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.MigrationCreateCommand = MigrationCreateCommand;
|
|
52
38
|
//# sourceMappingURL=migration-create-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-create-command.js","sourceRoot":"","sources":["../../../src/bin/migration-create-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-create-command.js","sourceRoot":"","sources":["../../../src/bin/migration-create-command.ts"],"names":[],"mappings":";;;AAAA,+BAAwC;AACxC,2BAAmC;AACnC,kDAAoE;AACpE,wCAAwD;AACxD,6CAAuD;AACvD,gEAA0D;AAO1D,MAAa,sBAAuB,SAAQ,qBAAO;IACzC,GAAG,GAAG,kBAAkB,CAAC;IACzB,WAAW,GAAG,6BAA6B,CAAC;IAE5C,UAAU,GAAG,CAAC,oBAAU,CAAC,CAAC;IAE1B,OAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IAE3B,KAAK,CAAC,MAAM,CAAC,IAAU;QAC/B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5D,MAAM,IAAI,GAAG;YACZ,2CAA2C;YAC3C,EAAE;YACF,wBAAwB,SAAS,sBAAsB;YACvD,yBAAyB;YACzB,MAAM;YACN,KAAK;YACL,EAAE;YACF,2BAA2B;YAC3B,MAAM;YACN,KAAK;YACL,GAAG;YACH,EAAE;SACF,CAAC;QAEF,MAAM,WAAW,GAAG,IAAA,0BAAe,GAAE,CAAC;QACtC,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1D,MAAM,IAAI,GAAG,IAAA,WAAQ,EACpB,EAAE,CAAC,sBAAsB,EAAE,EAC3B,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAC3B,CAAC;QAEF,IAAA,kBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;CACD;AApCD,wDAoCC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Command } from 'ts-commands';
|
|
2
|
-
interface Args {
|
|
3
|
-
database: string;
|
|
4
|
-
direction: 'up' | 'down';
|
|
5
|
-
steps: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class MigrationRunCommand extends Command {
|
|
8
|
-
|
|
9
|
-
description: string;
|
|
10
|
-
positional:
|
|
11
|
-
options: import("ts-commands").
|
|
12
|
-
handle(args: Args): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
1
|
+
import { Command, ParsedArguments } from 'ts-commands';
|
|
2
|
+
interface Args extends ParsedArguments {
|
|
3
|
+
database: string;
|
|
4
|
+
direction: 'up' | 'down';
|
|
5
|
+
steps: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class MigrationRunCommand extends Command {
|
|
8
|
+
key: string;
|
|
9
|
+
description: string;
|
|
10
|
+
positional: never[];
|
|
11
|
+
options: import("ts-commands").CommandOption[];
|
|
12
|
+
handle(args: Args): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.signature = 'migration:run';
|
|
21
|
-
this.description = 'Run migrations';
|
|
22
|
-
this.positional = [];
|
|
23
|
-
this.options = [options_1.databaseOption, options_1.directionOption, options_1.stepsOption];
|
|
24
|
-
}
|
|
25
|
-
handle(args) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const db = yield (0, database_1.loadDatabase)(null, args.database);
|
|
28
|
-
const runner = new migration_1.MigrationRunner(db);
|
|
29
|
-
yield runner.run(undefined, undefined, args.direction, args.steps);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.MigrationRunCommand = MigrationRunCommand;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MigrationRunCommand = void 0;
|
|
4
|
+
const ts_commands_1 = require("ts-commands");
|
|
5
|
+
const migration_1 = require("@riao/dbal/migration");
|
|
6
|
+
const database_1 = require("@riao/dbal/database");
|
|
7
|
+
const options_1 = require("../options");
|
|
8
|
+
class MigrationRunCommand extends ts_commands_1.Command {
|
|
9
|
+
key = 'migration:run';
|
|
10
|
+
description = 'Run migrations';
|
|
11
|
+
positional = [];
|
|
12
|
+
options = [options_1.databaseOption, options_1.directionOption, options_1.stepsOption];
|
|
13
|
+
async handle(args) {
|
|
14
|
+
const db = await (0, database_1.loadDatabase)(undefined, args.database);
|
|
15
|
+
const runner = new migration_1.MigrationRunner(db);
|
|
16
|
+
await runner.run(undefined, undefined, args.direction, args.steps);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.MigrationRunCommand = MigrationRunCommand;
|
|
34
20
|
//# sourceMappingURL=migration-run-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-run-command.js","sourceRoot":"","sources":["../../../src/bin/migration-run-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-run-command.js","sourceRoot":"","sources":["../../../src/bin/migration-run-command.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,oDAAuD;AACvD,kDAAmD;AACnD,wCAA0E;AAQ1E,MAAa,mBAAoB,SAAQ,qBAAO;IACtC,GAAG,GAAG,eAAe,CAAC;IACtB,WAAW,GAAG,gBAAgB,CAAC;IAE/B,UAAU,GAAG,EAAE,CAAC;IAEhB,OAAO,GAAG,CAAC,wBAAc,EAAE,yBAAe,EAAE,qBAAW,CAAC,CAAC;IAEzD,KAAK,CAAC,MAAM,CAAC,IAAU;QAC/B,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,2BAAe,CAAC,EAAE,CAAC,CAAC;QAEvC,MAAM,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CACD;AAdD,kDAcC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Command } from 'ts-commands';
|
|
2
|
-
interface Args {
|
|
3
|
-
database: string;
|
|
4
|
-
}
|
|
5
|
-
export declare class SchemaBuildCommand extends Command {
|
|
6
|
-
|
|
7
|
-
description: string;
|
|
8
|
-
positional:
|
|
9
|
-
options: import("ts-commands").
|
|
10
|
-
handle(args: Args): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
1
|
+
import { Command, ParsedArguments } from 'ts-commands';
|
|
2
|
+
interface Args extends ParsedArguments {
|
|
3
|
+
database: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class SchemaBuildCommand extends Command {
|
|
6
|
+
key: string;
|
|
7
|
+
description: string;
|
|
8
|
+
positional: never[];
|
|
9
|
+
options: import("ts-commands").CommandOption[];
|
|
10
|
+
handle(args: Args): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.signature = 'schema:build';
|
|
20
|
-
this.description = 'Build schema';
|
|
21
|
-
this.positional = [];
|
|
22
|
-
this.options = [options_1.databaseOption];
|
|
23
|
-
}
|
|
24
|
-
handle(args) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const db = yield (0, database_1.loadDatabase)(null, args.database);
|
|
27
|
-
yield db.buildSchema();
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.SchemaBuildCommand = SchemaBuildCommand;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaBuildCommand = void 0;
|
|
4
|
+
const ts_commands_1 = require("ts-commands");
|
|
5
|
+
const database_1 = require("@riao/dbal/database");
|
|
6
|
+
const options_1 = require("../options");
|
|
7
|
+
class SchemaBuildCommand extends ts_commands_1.Command {
|
|
8
|
+
key = 'schema:build';
|
|
9
|
+
description = 'Build schema';
|
|
10
|
+
positional = [];
|
|
11
|
+
options = [options_1.databaseOption];
|
|
12
|
+
async handle(args) {
|
|
13
|
+
const db = await (0, database_1.loadDatabase)(undefined, args.database);
|
|
14
|
+
await db.buildSchema();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SchemaBuildCommand = SchemaBuildCommand;
|
|
32
18
|
//# sourceMappingURL=schema-build-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-build-command.js","sourceRoot":"","sources":["../../../src/bin/schema-build-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-build-command.js","sourceRoot":"","sources":["../../../src/bin/schema-build-command.ts"],"names":[],"mappings":";;;AAAA,6CAAuD;AACvD,kDAAmD;AACnD,wCAA4C;AAM5C,MAAa,kBAAmB,SAAQ,qBAAO;IACrC,GAAG,GAAG,cAAc,CAAC;IACrB,WAAW,GAAG,cAAc,CAAC;IAE7B,UAAU,GAAG,EAAE,CAAC;IAEhB,OAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IAE3B,KAAK,CAAC,MAAM,CAAC,IAAU;QAC/B,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;CACD;AAZD,gDAYC"}
|