@riao/cli 3.0.0 → 4.0.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/LICENSE.md +20 -20
  3. package/README.md +5 -38
  4. package/bin/database-create-command.d.ts +21 -21
  5. package/bin/database-create-command.js +68 -82
  6. package/bin/database-create-command.js.map +1 -1
  7. package/bin/index.d.ts +2 -2
  8. package/bin/index.js +22 -22
  9. package/bin/index.js.map +1 -1
  10. package/bin/migration-create-command.d.ts +13 -13
  11. package/bin/migration-create-command.js +37 -51
  12. package/bin/migration-create-command.js.map +1 -1
  13. package/bin/migration-run-command.d.ts +14 -14
  14. package/bin/migration-run-command.js +19 -33
  15. package/bin/migration-run-command.js.map +1 -1
  16. package/bin/model-generate.d.ts +40 -0
  17. package/bin/model-generate.js +257 -0
  18. package/bin/model-generate.js.map +1 -0
  19. package/bin/schema-build-command.d.ts +12 -12
  20. package/bin/schema-build-command.js +17 -31
  21. package/bin/schema-build-command.js.map +1 -1
  22. package/bin/seed-create-command.d.ts +13 -13
  23. package/bin/seed-create-command.js +35 -49
  24. package/bin/seed-create-command.js.map +1 -1
  25. package/bin/seed-run-command.d.ts +15 -15
  26. package/bin/seed-run-command.js +28 -37
  27. package/bin/seed-run-command.js.map +1 -1
  28. package/index.d.ts +1 -1
  29. package/index.js +4 -4
  30. package/name-class-and-file.d.ts +10 -10
  31. package/name-class-and-file.js +33 -45
  32. package/name-class-and-file.js.map +1 -1
  33. package/options/database-option.d.ts +2 -2
  34. package/options/database-option.js +9 -9
  35. package/options/database-option.js.map +1 -1
  36. package/options/db-type-option.d.ts +13 -13
  37. package/options/db-type-option.js +57 -57
  38. package/options/db-type-option.js.map +1 -1
  39. package/options/direction-option.d.ts +2 -2
  40. package/options/direction-option.js +10 -10
  41. package/options/direction-option.js.map +1 -1
  42. package/options/index.d.ts +6 -6
  43. package/options/index.js +16 -16
  44. package/options/name-option.d.ts +2 -2
  45. package/options/name-option.js +8 -8
  46. package/options/name-option.js.map +1 -1
  47. package/options/seed-option.d.ts +2 -2
  48. package/options/seed-option.js +8 -8
  49. package/options/seed-option.js.map +1 -1
  50. package/options/steps-option.d.ts +2 -2
  51. package/options/steps-option.js +9 -9
  52. package/options/steps-option.js.map +1 -1
  53. package/package.json +7 -6
  54. package/utils/string-utils/to-pascal-case.d.ts +1 -0
  55. package/utils/string-utils/to-pascal-case.js +12 -0
  56. package/utils/string-utils/to-pascal-case.js.map +1 -0
  57. package/options/dry-run-option.d.ts +0 -2
  58. package/options/dry-run-option.js +0 -10
  59. package/options/dry-run-option.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- # riao-cli - Changelog
2
-
3
- ## [1.0.0] Initial Release
1
+ # riao-cli - Changelog
2
+
3
+ ## [1.0.0] Initial Release
package/LICENSE.md CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2022 riao-cli and others
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2022 riao-cli and others
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,38 +1,5 @@
1
- # riao-cli - Readme
2
-
3
- ## Development
4
-
5
- Run a dev test with `npm start`.
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`
1
+ # riao-cli - Readme
2
+
3
+ ## Contributing & Development
4
+
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, OptionType } from 'ts-commands';
2
- import { DbDrivers } from '../options';
3
- interface Args {
4
- name: string;
5
- driver: DbDrivers;
6
- }
7
- export declare class DatabaseCreateCommand extends Command {
8
- signature: string;
9
- description: string;
10
- positional: {
11
- default: string;
12
- key: string;
13
- type: OptionType;
14
- alias?: string;
15
- description?: string;
16
- choices?: string[] | number[];
17
- }[];
18
- options: import("ts-commands").CommandOptions[];
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DatabaseCreateCommand = void 0;
13
- const path_1 = require("path");
14
- const fs_1 = require("fs");
15
- const database_1 = require("@riao/dbal/database");
16
- const options_1 = require("../options");
17
- const ts_commands_1 = require("ts-commands");
18
- const name_class_and_file_1 = require("../name-class-and-file");
19
- const options_2 = require("../options");
20
- const child_process_1 = require("child_process");
21
- class DatabaseCreateCommand extends ts_commands_1.Command {
22
- constructor() {
23
- super(...arguments);
24
- this.signature = 'db:create [name]';
25
- this.description = 'Create a new database';
26
- this.positional = [Object.assign(Object.assign({}, options_1.nameOption), { default: 'main' })];
27
- this.options = [options_2.dbDriverOption];
28
- }
29
- handle(args) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- let { fileName, className } = (0, name_class_and_file_1.nameClassAndFile)(args.name);
32
- const folderName = fileName.replace('.ts', '');
33
- const constName = className.replace(/(?:^|\s)\S/, (a) => a.toLowerCase()) + 'db';
34
- className += 'Database';
35
- const rootDir = (0, database_1.getDatabasePath)();
36
- const databaseDir = (0, path_1.join)(rootDir, folderName);
37
- const migrationsDir = (0, path_1.join)(databaseDir, 'migrations');
38
- const seedsDir = (0, path_1.join)(databaseDir, 'seeds');
39
- const dbTypeProperties = options_2.dbDriverProperties[args.driver];
40
- const baseClassName = dbTypeProperties.className;
41
- const baseClassPackage = dbTypeProperties.package;
42
- if ((0, fs_1.existsSync)(databaseDir)) {
43
- throw new Error('Database ' + folderName + ' already exists!');
44
- }
45
- (0, fs_1.mkdirSync)(databaseDir, { recursive: true });
46
- // Create index file
47
- const indexFilePath = (0, path_1.join)(databaseDir, 'index.ts');
48
- const indexFile = [
49
- `import { ${baseClassName} } from \'${baseClassPackage}\';`,
50
- '',
51
- `export default class ${className} extends ${baseClassName} {`,
52
- `\tname = '${folderName}';`,
53
- '}',
54
- '',
55
- `export const ${constName} = new ${className}();`,
56
- '',
57
- ];
58
- (0, fs_1.writeFileSync)(indexFilePath, indexFile.join('\n'));
59
- // Create .env example
60
- const envFileName = folderName + '.db.env';
61
- const envFilePath = (0, path_1.join)(databaseDir, envFileName);
62
- const envFile = [
63
- 'host="localhost"',
64
- `port=${dbTypeProperties.port}`,
65
- 'username=""',
66
- 'password=""',
67
- 'database=""',
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":";;;;;;;;;;;;A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AAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,IAAA,kBAAa,EAAC,WAAW,GAAG,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE5D,wBAAwB;QACxB,IAAA,cAAS,EAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,IAAA,kBAAa,EAAC,IAAA,WAAQ,EAAC,aAAa,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QAEzD,mBAAmB;QACnB,IAAA,cAAS,EAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,IAAA,kBAAa,EAAC,IAAA,WAAQ,EAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QAEpD,mBAAmB;QACnB,IAAA,wBAAQ,EAAC,QAAQ,GAAG,gBAAgB,CAAC,CAAC;IACvC,CAAC;CACD;AAxED,sDAwEC"}
package/bin/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #! /usr/bin/env ts-node
2
- export {};
1
+ #! /usr/bin/env ts-node
2
+ export {};
package/bin/index.js CHANGED
@@ -1,23 +1,23 @@
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
- (0, ts_commands_1.registerCommands)({
12
- name: 'riao-cli',
13
- commands: [
14
- database_create_command_1.DatabaseCreateCommand,
15
- migration_create_command_1.MigrationCreateCommand,
16
- migration_run_command_1.MigrationRunCommand,
17
- schema_build_command_1.SchemaBuildCommand,
18
- seed_create_command_1.SeedCreateCommand,
19
- seed_run_command_1.SeedRunCommand,
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
+ const model_generate_1 = require("./model-generate");
12
+ new ts_commands_1.CommandDispatcher({
13
+ commands: [
14
+ database_create_command_1.DatabaseCreateCommand,
15
+ migration_create_command_1.MigrationCreateCommand,
16
+ migration_run_command_1.MigrationRunCommand,
17
+ model_generate_1.ModelGenerateCommand,
18
+ schema_build_command_1.SchemaBuildCommand,
19
+ seed_create_command_1.SeedCreateCommand,
20
+ seed_run_command_1.SeedRunCommand,
21
+ ],
22
+ }).run();
23
23
  //# 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,6CAA+C;AAE/C,uEAAkE;AAClE,yEAAoE;AACpE,mEAA8D;AAC9D,iEAA4D;AAC5D,+DAA0D;AAC1D,yDAAoD;AAEpD,IAAA,8BAAgB,EAAC;IAChB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE;QACT,+CAAqB;QACrB,iDAAsB;QACtB,2CAAmB;QACnB,yCAAkB;QAClB,uCAAiB;QACjB,iCAAc;KACd;IACD,SAAS,EAAE,IAAI;CACf,CAAC,CAAC"}
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;AACpD,qDAAwD;AAExD,IAAI,+BAAiB,CAAC;IACrB,QAAQ,EAAE;QACT,+CAAqB;QACrB,iDAAsB;QACtB,2CAAmB;QACnB,qCAAoB;QACpB,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
- signature: string;
8
- description: string;
9
- positional: import("ts-commands").CommandOptions[];
10
- options: import("ts-commands").CommandOptions[];
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MigrationCreateCommand = void 0;
13
- const path_1 = require("path");
14
- const fs_1 = require("fs");
15
- const database_1 = require("@riao/dbal/database");
16
- const options_1 = require("../options");
17
- const ts_commands_1 = require("ts-commands");
18
- const name_class_and_file_1 = require("../name-class-and-file");
19
- class MigrationCreateCommand extends ts_commands_1.Command {
20
- constructor() {
21
- super(...arguments);
22
- this.signature = 'migration:create [name]';
23
- this.description = 'Create a new migration file';
24
- this.positional = [options_1.nameOption];
25
- this.options = [options_1.databaseOption];
26
- }
27
- handle(args) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const { fileName, className } = (0, name_class_and_file_1.nameClassAndFile)(args.name);
30
- const file = [
31
- 'import { Migration } from \'@riao/dbal\';',
32
- '',
33
- `export default class ${className} extends Migration {`,
34
- '\tasync up() {',
35
- '\t\t',
36
- '\t}',
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":";;;;;;;;;;;;AAAA,+BAAwC;AACxC,2BAAmC;AACnC,kDAAoE;AACpE,wCAAwD;AACxD,6CAAkD;AAClD,gEAA0D;AAO1D,MAAa,sBAAuB,SAAQ,qBAAO;IAAnD;;QACC,cAAS,GAAG,yBAAyB,CAAC;QACtC,gBAAW,GAAG,6BAA6B,CAAC;QAE5C,eAAU,GAAG,CAAC,oBAAU,CAAC,CAAC;QAE1B,YAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IA8B5B,CAAC;IA5BM,MAAM,CAAC,IAAU;;YACtB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE5D,MAAM,IAAI,GAAG;gBACZ,2CAA2C;gBAC3C,EAAE;gBACF,wBAAwB,SAAS,sBAAsB;gBACvD,gBAAgB;gBAChB,MAAM;gBACN,KAAK;gBACL,EAAE;gBACF,kBAAkB;gBAClB,MAAM;gBACN,KAAK;gBACL,GAAG;gBACH,EAAE;aACF,CAAC;YAEF,MAAM,WAAW,GAAG,IAAA,0BAAe,GAAE,CAAC;YACtC,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAE1D,MAAM,IAAI,GAAG,IAAA,WAAQ,EACpB,EAAE,CAAC,sBAAsB,EAAE,EAC3B,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAC3B,CAAC;YAEF,IAAA,kBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;KAAA;CACD;AApCD,wDAoCC"}
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
- signature: string;
9
- description: string;
10
- positional: any[];
11
- options: import("ts-commands").CommandOptions[];
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MigrationRunCommand = void 0;
13
- const ts_commands_1 = require("ts-commands");
14
- const migration_1 = require("@riao/dbal/migration");
15
- const database_1 = require("@riao/dbal/database");
16
- const options_1 = require("../options");
17
- class MigrationRunCommand extends ts_commands_1.Command {
18
- constructor() {
19
- super(...arguments);
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":";;;;;;;;;;;;AAAA,6CAAkD;AAClD,oDAAuD;AACvD,kDAAmD;AACnD,wCAA0E;AAQ1E,MAAa,mBAAoB,SAAQ,qBAAO;IAAhD;;QACC,cAAS,GAAG,eAAe,CAAC;QAC5B,gBAAW,GAAG,gBAAgB,CAAC;QAE/B,eAAU,GAAG,EAAE,CAAC;QAEhB,YAAO,GAAG,CAAC,wBAAc,EAAE,yBAAe,EAAE,qBAAW,CAAC,CAAC;IAQ1D,CAAC;IANM,MAAM,CAAC,IAAU;;YACtB,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,IAAI,2BAAe,CAAC,EAAE,CAAC,CAAC;YAEvC,MAAM,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SA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