@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
@@ -0,0 +1,40 @@
1
+ import { Command, ParsedArguments, CommandOption } from 'ts-commands';
2
+ import { Database } from '@riao/dbal/database';
3
+ import { ColumnOptions } from '@riao/dbal';
4
+ interface Args extends ParsedArguments {
5
+ database: string;
6
+ out: string;
7
+ moduleDepth: number;
8
+ queryRepository: null | string;
9
+ }
10
+ export declare class ModelGenerateCommand extends Command {
11
+ key: string;
12
+ description: string;
13
+ positional: never[];
14
+ options: CommandOption[];
15
+ protected outDir: string;
16
+ protected moduleDepth: number;
17
+ protected queryRepository: string | null;
18
+ handle(args: Args): Promise<void>;
19
+ protected traverseMigrations(options: {
20
+ migrations: string[];
21
+ migrationsDir: string;
22
+ db: Database;
23
+ }): Promise<void>;
24
+ protected generateProperty(options: ColumnOptions): string;
25
+ protected generateInterface(options: {
26
+ interfaceName: string;
27
+ tableName: string;
28
+ columns: ColumnOptions[];
29
+ }): string;
30
+ protected generateQueryRepository(options: {
31
+ interfaceName: string;
32
+ tableName: string;
33
+ columns: ColumnOptions[];
34
+ db: Database;
35
+ }): string;
36
+ protected getInterfaceFilePath(tableName: string): string;
37
+ protected saveTypesToFile(types: string, filePath: string): void;
38
+ protected generateIndexFiles(dir: string): void;
39
+ }
40
+ export {};
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ /* eslint-disable no-console */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ModelGenerateCommand = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const fs = tslib_1.__importStar(require("fs"));
7
+ const path = tslib_1.__importStar(require("path"));
8
+ const ts_import_ts_1 = require("ts-import-ts");
9
+ const ts_commands_1 = require("ts-commands");
10
+ const database_1 = require("@riao/dbal/database");
11
+ const dbal_1 = require("@riao/dbal");
12
+ const options_1 = require("../options");
13
+ const to_pascal_case_1 = require("../utils/string-utils/to-pascal-case");
14
+ const outOption = {
15
+ key: 'out',
16
+ type: ts_commands_1.OptionType.string,
17
+ description: 'Output directory for generated types',
18
+ default: './src/models',
19
+ };
20
+ const moduleDepthOption = {
21
+ key: 'moduleDepth',
22
+ type: ts_commands_1.OptionType.number,
23
+ description: 'Number of parts in the table name to use as module path',
24
+ default: 1,
25
+ };
26
+ const queryRepositoryOption = {
27
+ key: 'queryRepository',
28
+ type: ts_commands_1.OptionType.string,
29
+ description: 'Path to output query repository files (optional)',
30
+ };
31
+ const typeMap = {
32
+ [dbal_1.ColumnType.TINYINT]: 'number',
33
+ [dbal_1.ColumnType.SMALLINT]: 'number',
34
+ [dbal_1.ColumnType.INT]: 'number',
35
+ [dbal_1.ColumnType.BIGINT]: 'BigInt',
36
+ [dbal_1.ColumnType.FLOAT]: 'number',
37
+ [dbal_1.ColumnType.DOUBLE]: 'number',
38
+ [dbal_1.ColumnType.DECIMAL]: 'number',
39
+ [dbal_1.ColumnType.BOOL]: 'boolean',
40
+ [dbal_1.ColumnType.DATE]: 'Date',
41
+ [dbal_1.ColumnType.TIMESTAMP]: 'Date',
42
+ [dbal_1.ColumnType.TIME]: 'string',
43
+ [dbal_1.ColumnType.BLOB]: 'Buffer',
44
+ [dbal_1.ColumnType.CHAR]: 'string',
45
+ [dbal_1.ColumnType.VARCHAR]: 'string',
46
+ [dbal_1.ColumnType.TEXT]: 'string',
47
+ [dbal_1.ColumnType.UUID]: 'string',
48
+ };
49
+ class MockDataDefinitionRepository extends dbal_1.DataDefinitionRepository {
50
+ tables = {};
51
+ constructor(ddlBuilderType) {
52
+ super({
53
+ ddlBuilderType,
54
+ });
55
+ }
56
+ async createTable(options) {
57
+ this.tables[options.name] = options.columns;
58
+ }
59
+ async dropTable(options) {
60
+ if (Array.isArray(options.tables)) {
61
+ for (const table of options.tables) {
62
+ delete this.tables[typeof table === 'string'
63
+ ? table
64
+ : table.name];
65
+ }
66
+ }
67
+ }
68
+ async addColumns(options) {
69
+ if (!this.tables[options.table]) {
70
+ this.tables[options.table] = [];
71
+ }
72
+ this.tables[options.table].push(...options.columns);
73
+ }
74
+ async dropColumn(options) {
75
+ if (!this.tables[options.table]) {
76
+ throw new Error(`Table ${options.table} does not exist`);
77
+ }
78
+ this.tables[options.table] = this.tables[options.table].filter((col) => col.name !== options.column);
79
+ }
80
+ }
81
+ class ModelGenerateCommand extends ts_commands_1.Command {
82
+ key = 'model:generate';
83
+ description = 'Generate typescript models from migrations';
84
+ positional = [];
85
+ options = [
86
+ options_1.databaseOption,
87
+ outOption,
88
+ moduleDepthOption,
89
+ queryRepositoryOption,
90
+ ];
91
+ outDir;
92
+ moduleDepth;
93
+ queryRepository = null;
94
+ async handle(args) {
95
+ this.outDir = path.resolve(process.cwd(), args.out);
96
+ fs.mkdirSync(this.outDir, { recursive: true });
97
+ this.queryRepository = args.queryRepository;
98
+ this.moduleDepth = args.moduleDepth;
99
+ const realDb = await (0, database_1.loadDatabase)(undefined, args.database);
100
+ const mockDdl = new MockDataDefinitionRepository(dbal_1.DataDefinitionBuilder);
101
+ realDb.ddl = mockDdl;
102
+ realDb.getDataDefinitionRepository = () => mockDdl;
103
+ const migrationsDir = path.resolve(process.cwd(), realDb.getMigrationsDirectory());
104
+ console.log('Processing migrations in:', migrationsDir);
105
+ if (fs.existsSync(migrationsDir)) {
106
+ const migrationsInPath = fs
107
+ .readdirSync(migrationsDir)
108
+ .filter((fname) => /\.ts$/.test(fname));
109
+ await this.traverseMigrations({
110
+ migrations: migrationsInPath,
111
+ migrationsDir: realDb.getMigrationsDirectory(),
112
+ db: realDb,
113
+ });
114
+ }
115
+ for (const [tableName, columns] of Object.entries(mockDdl.tables)) {
116
+ console.log(`Generating types for table: ${tableName}`);
117
+ const interfaceName = (0, to_pascal_case_1.toPascalCase)(`${tableName}Record`);
118
+ const interfaceFilePath = this.getInterfaceFilePath(tableName);
119
+ let interfaceFileContents = this.generateInterface({
120
+ interfaceName,
121
+ tableName,
122
+ columns,
123
+ });
124
+ if (this.queryRepository === 'inline') {
125
+ interfaceFileContents +=
126
+ '\n' +
127
+ this.generateQueryRepository({
128
+ interfaceName,
129
+ tableName,
130
+ columns,
131
+ db: realDb,
132
+ });
133
+ }
134
+ else if (this.queryRepository) {
135
+ const interfaceRelativeDir = path.dirname(path.relative(this.outDir, interfaceFilePath));
136
+ const interfaceFilename = path.basename(interfaceFilePath, '.ts');
137
+ const repoFilename = `${interfaceFilename}-repository.ts`;
138
+ const repoFilepath = path.join(this.queryRepository, interfaceRelativeDir, repoFilename);
139
+ let interfaceImportPath = path
140
+ .relative(path.dirname(repoFilepath), interfaceFilePath)
141
+ .replace(/\\/g, '/')
142
+ .replace(/\.ts$/, '');
143
+ if (!interfaceImportPath.startsWith('.')) {
144
+ interfaceImportPath = `./${interfaceImportPath}`;
145
+ }
146
+ const repoContent = `import { ${interfaceName} } from ` +
147
+ `'${interfaceImportPath}';\n\n` +
148
+ this.generateQueryRepository({
149
+ interfaceName,
150
+ tableName,
151
+ columns,
152
+ db: realDb,
153
+ });
154
+ this.saveTypesToFile(repoContent, repoFilepath);
155
+ }
156
+ this.saveTypesToFile(interfaceFileContents, interfaceFilePath);
157
+ }
158
+ this.generateIndexFiles(this.outDir);
159
+ if (this.queryRepository && this.queryRepository !== 'inline') {
160
+ this.generateIndexFiles(this.queryRepository);
161
+ }
162
+ console.log('Types generated successfully.');
163
+ }
164
+ async traverseMigrations(options) {
165
+ for (const filename of options.migrations) {
166
+ const fullPath = path.join(options.migrationsDir, filename);
167
+ console.log('Loading migration:', fullPath);
168
+ const migrationType = (0, ts_import_ts_1.tsimport)(fullPath);
169
+ const migration = new migrationType(options.db);
170
+ if ('package' in migration) {
171
+ const migs = await migration.getMigrations();
172
+ for (const [name, mig] of Object.entries(migs)) {
173
+ console.log(`Loading migration from package: ${name}`);
174
+ if (mig instanceof dbal_1.Migration) {
175
+ await mig.up();
176
+ }
177
+ else {
178
+ const instance = new mig(options.db, {});
179
+ await instance.up();
180
+ }
181
+ }
182
+ }
183
+ else if ('up' in migration) {
184
+ await migration.up();
185
+ }
186
+ else {
187
+ console.log('Invalid migration export:', migration);
188
+ throw new Error(`Invalid migration export in file: ${fullPath}`);
189
+ }
190
+ }
191
+ }
192
+ generateProperty(options) {
193
+ const tsType = typeMap[options.type] || 'any';
194
+ return `\t${options.name}${options.required ? '' : '?'}: ${tsType};`;
195
+ }
196
+ generateInterface(options) {
197
+ const properties = options.columns
198
+ .map((col) => this.generateProperty(col))
199
+ .join('\n');
200
+ return (`export interface ${options.interfaceName} ` +
201
+ `{\n${properties}\n}\n`);
202
+ }
203
+ generateQueryRepository(options) {
204
+ const className = (0, to_pascal_case_1.toPascalCase)(`${options.tableName}Repository`);
205
+ const idColumn = options.columns.find((col) => col.primaryKey);
206
+ const dbVar = options.db.name + 'db';
207
+ return (`import { ${dbVar} } from ` +
208
+ `'@/database/${options.db.name}';` +
209
+ '\n\n' +
210
+ `export const ${className} = ` +
211
+ `${dbVar}.getQueryRepository<${options.interfaceName}>` +
212
+ '({\n' +
213
+ `\ttable: '${options.tableName}',\n` +
214
+ `\tidentifiedBy: '${idColumn?.name}'\n` +
215
+ '});\n');
216
+ }
217
+ getInterfaceFilePath(tableName) {
218
+ const parts = tableName.split('_');
219
+ const splitIndex = Math.min(this.moduleDepth, Math.max(0, parts.length - 1));
220
+ const moduleParts = parts.slice(0, splitIndex);
221
+ const fileParts = parts.slice(splitIndex);
222
+ if (fileParts.length === 0) {
223
+ fileParts.push(moduleParts.pop() || 'index');
224
+ }
225
+ const fileName = `${fileParts.join('-')}.ts`;
226
+ return path.join(this.outDir, ...moduleParts, fileName);
227
+ }
228
+ saveTypesToFile(types, filePath) {
229
+ const dirPath = path.dirname(filePath);
230
+ fs.mkdirSync(dirPath, { recursive: true });
231
+ fs.writeFileSync(filePath, types, 'utf-8');
232
+ console.log(`Types saved to ${filePath}`);
233
+ }
234
+ generateIndexFiles(dir) {
235
+ if (!fs.existsSync(dir)) {
236
+ return;
237
+ }
238
+ const files = fs.readdirSync(dir);
239
+ const exports = [];
240
+ for (const file of files) {
241
+ const fullPath = path.join(dir, file);
242
+ if (fs.statSync(fullPath).isDirectory()) {
243
+ this.generateIndexFiles(fullPath);
244
+ exports.push(`export * from './${file}';`);
245
+ }
246
+ else if (file.endsWith('.ts') && file !== 'index.ts') {
247
+ const fileNameNoExt = file.replace(/\.ts$/, '');
248
+ exports.push(`export * from './${fileNameNoExt}';`);
249
+ }
250
+ }
251
+ if (exports.length > 0) {
252
+ fs.writeFileSync(path.join(dir, 'index.ts'), exports.join('\n') + '\n', 'utf-8');
253
+ }
254
+ }
255
+ }
256
+ exports.ModelGenerateCommand = ModelGenerateCommand;
257
+ //# sourceMappingURL=model-generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-generate.js","sourceRoot":"","sources":["../../../src/bin/model-generate.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;;AAE/B,+CAAyB;AACzB,mDAA6B;AAC7B,+CAAwC;AACxC,6CAKqB;AACrB,kDAA6D;AAC7D,qCAWoB;AACpB,wCAA4C;AAC5C,yEAAoE;AAEpE,MAAM,SAAS,GAAkB;IAChC,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,wBAAU,CAAC,MAAM;IACvB,WAAW,EAAE,sCAAsC;IACnD,OAAO,EAAE,cAAc;CACvB,CAAC;AAEF,MAAM,iBAAiB,GAAkB;IACxC,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,wBAAU,CAAC,MAAM;IACvB,WAAW,EAAE,yDAAyD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oB,IAAI,IAAI,CAAC,CAAC;YAC5C,CAAC;iBACI,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACtD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAChD,OAAO,CAAC,IAAI,CAAC,oBAAoB,aAAa,IAAI,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,EAC1B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EACzB,OAAO,CACP,CAAC;QACH,CAAC;IACF,CAAC;CACD;AAnQD,oDAmQC"}
@@ -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
- signature: string;
7
- description: string;
8
- positional: any[];
9
- options: import("ts-commands").CommandOptions[];
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
- 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.SchemaBuildCommand = void 0;
13
- const ts_commands_1 = require("ts-commands");
14
- const database_1 = require("@riao/dbal/database");
15
- const options_1 = require("../options");
16
- class SchemaBuildCommand extends ts_commands_1.Command {
17
- constructor() {
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":";;;;;;;;;;;;AAAA,6CAAsC;AACtC,kDAAmD;AACnD,wCAA4C;AAM5C,MAAa,kBAAmB,SAAQ,qBAAO;IAA/C;;QACC,cAAS,GAAG,cAAc,CAAC;QAC3B,gBAAW,GAAG,cAAc,CAAC;QAE7B,eAAU,GAAG,EAAE,CAAC;QAEhB,YAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IAM5B,CAAC;IAJM,MAAM,CAAC,IAAU;;YACtB,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAY,EAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnD,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC;KAAA;CACD;AAZD,gDAYC"}
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"}
@@ -1,13 +1,13 @@
1
- import { Command } from 'ts-commands';
2
- interface Args {
3
- name: string;
4
- database: string;
5
- }
6
- export declare class SeedCreateCommand 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 SeedCreateCommand 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,50 +1,36 @@
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.SeedCreateCommand = 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 SeedCreateCommand extends ts_commands_1.Command {
20
- constructor() {
21
- super(...arguments);
22
- this.signature = 'seed:create [name]';
23
- this.description = 'Create a new seed 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 { Seed } from \'@riao/dbal/seed\';',
32
- '',
33
- `export default class ${className} extends Seed {`,
34
- '\tpublic async up(): Promise<void> {',
35
- '\t}',
36
- '',
37
- '\tpublic async down(): Promise<void> {',
38
- '\t}',
39
- '}',
40
- '',
41
- ];
42
- const databaseDir = (0, database_1.getDatabasePath)();
43
- const db = yield (0, database_1.loadDatabase)(databaseDir, args.database);
44
- const path = (0, path_1.join)(db.getSeedsDirectory(), fileName);
45
- (0, fs_1.writeFileSync)(path, file.join('\n'));
46
- });
47
- }
48
- }
49
- exports.SeedCreateCommand = SeedCreateCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeedCreateCommand = 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 SeedCreateCommand extends ts_commands_1.Command {
11
+ key = 'seed:create';
12
+ description = 'Create a new seed 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 { Seed } from \'@riao/dbal/seed\';',
19
+ '',
20
+ `export default class ${className} extends Seed {`,
21
+ '\toverride async up(): Promise<void> {',
22
+ '\t}',
23
+ '',
24
+ '\toverride async down(): Promise<void> {',
25
+ '\t}',
26
+ '}',
27
+ '',
28
+ ];
29
+ const databaseDir = (0, database_1.getDatabasePath)();
30
+ const db = await (0, database_1.loadDatabase)(databaseDir, args.database);
31
+ const path = (0, path_1.join)(db.getSeedsDirectory(), fileName);
32
+ (0, fs_1.writeFileSync)(path, file.join('\n'));
33
+ }
34
+ }
35
+ exports.SeedCreateCommand = SeedCreateCommand;
50
36
  //# sourceMappingURL=seed-create-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"seed-create-command.js","sourceRoot":"","sources":["../../../src/bin/seed-create-command.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAwC;AACxC,2BAAmC;AACnC,kDAAoE;AACpE,wCAAwD;AACxD,6CAAkD;AAClD,gEAA0D;AAO1D,MAAa,iBAAkB,SAAQ,qBAAO;IAA9C;;QACC,cAAS,GAAG,oBAAoB,CAAC;QACjC,gBAAW,GAAG,wBAAwB,CAAC;QAEvC,eAAU,GAAG,CAAC,oBAAU,CAAC,CAAC;QAE1B,YAAO,GAAG,CAAC,wBAAc,CAAC,CAAC;IAyB5B,CAAC;IAvBM,MAAM,CAAC,IAAU;;YACtB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE5D,MAAM,I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,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,EAAC,EAAE,CAAC,iBAAiB,EAAE,EAAE,QAAQ,CAAC,CAAC;QAExD,IAAA,kBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;CACD;AA/BD,8CA+BC"}
@@ -1,15 +1,15 @@
1
- import { Command } from 'ts-commands';
2
- interface Args {
3
- database: string;
4
- direction: 'up' | 'down';
5
- seed: string;
6
- steps: number;
7
- }
8
- export declare class SeedRunCommand extends Command {
9
- signature: string;
10
- description: string;
11
- positional: any[];
12
- options: import("ts-commands").CommandOptions[];
13
- handle(args: Args): Promise<void>;
14
- }
15
- export {};
1
+ import { Command, ParsedArguments } from 'ts-commands';
2
+ interface Args extends ParsedArguments {
3
+ database: string;
4
+ direction: 'up' | 'down';
5
+ seed: string;
6
+ steps: number;
7
+ }
8
+ export declare class SeedRunCommand extends Command {
9
+ key: string;
10
+ description: string;
11
+ positional: never[];
12
+ options: import("ts-commands").CommandOption[];
13
+ handle(args: Args): Promise<void>;
14
+ }
15
+ export {};
@@ -1,38 +1,29 @@
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.SeedRunCommand = void 0;
13
- const ts_commands_1 = require("ts-commands");
14
- const seed_1 = require("@riao/dbal/seed");
15
- const database_1 = require("@riao/dbal/database");
16
- const options_1 = require("../options");
17
- class SeedRunCommand extends ts_commands_1.Command {
18
- constructor() {
19
- super(...arguments);
20
- this.signature = 'seed:run';
21
- this.description = 'Run seeds';
22
- this.positional = [];
23
- this.options = [options_1.databaseOption, options_1.directionOption, options_1.seedOption, 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 seed_1.SeedRunner(db);
29
- yield runner.run(undefined, undefined, args.direction, args.steps, args.seed
30
- ? args.seed.includes('.ts')
31
- ? args.seed
32
- : args.seed + '.ts'
33
- : undefined);
34
- });
35
- }
36
- }
37
- exports.SeedRunCommand = SeedRunCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeedRunCommand = void 0;
4
+ const ts_commands_1 = require("ts-commands");
5
+ const seed_1 = require("@riao/dbal/seed");
6
+ const database_1 = require("@riao/dbal/database");
7
+ const options_1 = require("../options");
8
+ class SeedRunCommand extends ts_commands_1.Command {
9
+ key = 'seed:run';
10
+ description = 'Run seeds';
11
+ positional = [];
12
+ options = [
13
+ options_1.databaseOption,
14
+ options_1.directionOption,
15
+ options_1.seedOption,
16
+ options_1.stepsOption
17
+ ];
18
+ async handle(args) {
19
+ const db = await (0, database_1.loadDatabase)(undefined, args.database);
20
+ const runner = new seed_1.SeedRunner(db);
21
+ await runner.run(undefined, undefined, args.direction, args.steps, args.seed
22
+ ? args.seed.includes('.ts')
23
+ ? args.seed
24
+ : args.seed + '.ts'
25
+ : undefined);
26
+ }
27
+ }
28
+ exports.SeedRunCommand = SeedRunCommand;
38
29
  //# sourceMappingURL=seed-run-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"seed-run-command.js","sourceRoot":"","sources":["../../../src/bin/seed-run-command.ts"],"names":[],"mappings":";;;;;;;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,MAAM,IAAA,uBAAY,EAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,IAAI,iBAAU,CAAC,EAAE,CAAC,CAAC;QAElC,MAAM,MAAM,CAAC,GAAG,CACf,SAAS,EACT,SAAS,EACT,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,IAAI;YACR,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,CAAC,IAAI;gBACX,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK;YACpB,CAAC,CAAC,SAAS,CACZ,CAAC;IACH,CAAC;CACD;AA7BD,wCA6BC"}
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const a = true;
1
+ export declare const a = true;