sonamu 0.2.55 → 0.2.56
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/dist/bin/cli.js +89 -118
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/cli.mjs +45 -74
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/{chunk-ZFLQLW37.mjs → chunk-RHSTOLSM.mjs} +5568 -5243
- package/dist/chunk-RHSTOLSM.mjs.map +1 -0
- package/dist/{chunk-WJGRXAXE.js → chunk-V6CWU5VD.js} +5577 -5252
- package/dist/chunk-V6CWU5VD.js.map +1 -0
- package/dist/index.d.mts +931 -226
- package/dist/index.d.ts +931 -226
- package/dist/index.js +26 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/base-model-BzMJ2E_I.d.mts +0 -43
- package/dist/base-model-CWRKUX49.d.ts +0 -43
- package/dist/chunk-4K2F3SOM.mjs +0 -231
- package/dist/chunk-4K2F3SOM.mjs.map +0 -1
- package/dist/chunk-6SP5N5ND.mjs +0 -1579
- package/dist/chunk-6SP5N5ND.mjs.map +0 -1
- package/dist/chunk-EUP6N7EK.js +0 -1579
- package/dist/chunk-EUP6N7EK.js.map +0 -1
- package/dist/chunk-HVVCQLAU.mjs +0 -280
- package/dist/chunk-HVVCQLAU.mjs.map +0 -1
- package/dist/chunk-N6N3LENC.js +0 -231
- package/dist/chunk-N6N3LENC.js.map +0 -1
- package/dist/chunk-UAG3SKFM.js +0 -280
- package/dist/chunk-UAG3SKFM.js.map +0 -1
- package/dist/chunk-WJGRXAXE.js.map +0 -1
- package/dist/chunk-ZFLQLW37.mjs.map +0 -1
- package/dist/database/drivers/knex/base-model.d.mts +0 -16
- package/dist/database/drivers/knex/base-model.d.ts +0 -16
- package/dist/database/drivers/knex/base-model.js +0 -55
- package/dist/database/drivers/knex/base-model.js.map +0 -1
- package/dist/database/drivers/knex/base-model.mjs +0 -56
- package/dist/database/drivers/knex/base-model.mjs.map +0 -1
- package/dist/database/drivers/kysely/base-model.d.mts +0 -22
- package/dist/database/drivers/kysely/base-model.d.ts +0 -22
- package/dist/database/drivers/kysely/base-model.js +0 -64
- package/dist/database/drivers/kysely/base-model.js.map +0 -1
- package/dist/database/drivers/kysely/base-model.mjs +0 -65
- package/dist/database/drivers/kysely/base-model.mjs.map +0 -1
- package/dist/model-CAH_4oQh.d.mts +0 -1042
- package/dist/model-CAH_4oQh.d.ts +0 -1042
package/dist/bin/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkEUP6N7EKjs = require('../chunk-EUP6N7EK.js');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
|
|
@@ -12,10 +11,7 @@ var _chunkEUP6N7EKjs = require('../chunk-EUP6N7EK.js');
|
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkWJGRXAXEjs = require('../chunk-WJGRXAXE.js');
|
|
14
|
+
var _chunkV6CWU5VDjs = require('../chunk-V6CWU5VD.js');
|
|
19
15
|
|
|
20
16
|
// src/bin/cli.ts
|
|
21
17
|
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
|
|
@@ -24,10 +20,9 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
24
20
|
var _tsicli = require('tsicli');
|
|
25
21
|
var _child_process = require('child_process');
|
|
26
22
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
23
|
+
var _knex = require('knex'); var _knex2 = _interopRequireDefault(_knex);
|
|
27
24
|
var _inflection = require('inflection'); var _inflection2 = _interopRequireDefault(_inflection);
|
|
28
25
|
var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_prettier);
|
|
29
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
30
|
-
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
31
26
|
|
|
32
27
|
// src/smd/smd-manager.ts
|
|
33
28
|
|
|
@@ -36,24 +31,11 @@ var _glob = require('glob'); var _glob2 = _interopRequireDefault(_glob);
|
|
|
36
31
|
|
|
37
32
|
|
|
38
33
|
// src/smd/smd.ts
|
|
34
|
+
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
39
35
|
|
|
40
36
|
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
var SMD = (_class = class {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
__init() {this.types = {}}
|
|
55
|
-
__init2() {this.enums = {}}
|
|
56
|
-
__init3() {this.enumLabels = {}}
|
|
38
|
+
var SMD = class {
|
|
57
39
|
constructor({
|
|
58
40
|
id,
|
|
59
41
|
parentId,
|
|
@@ -62,14 +44,17 @@ var SMD = (_class = class {
|
|
|
62
44
|
props,
|
|
63
45
|
indexes,
|
|
64
46
|
subsets
|
|
65
|
-
}) {
|
|
47
|
+
}) {
|
|
48
|
+
this.types = {};
|
|
49
|
+
this.enums = {};
|
|
50
|
+
this.enumLabels = {};
|
|
66
51
|
this.id = id;
|
|
67
52
|
this.parentId = parentId;
|
|
68
53
|
this.title = _nullishCoalesce(title, () => ( this.id));
|
|
69
54
|
this.table = _nullishCoalesce(table, () => ( _inflection2.default.underscore(_inflection2.default.pluralize(id))));
|
|
70
55
|
if (props) {
|
|
71
56
|
this.props = props.map((prop) => {
|
|
72
|
-
if (
|
|
57
|
+
if (_chunkV6CWU5VDjs.isEnumProp.call(void 0, prop)) {
|
|
73
58
|
if (prop.id.includes("$Model")) {
|
|
74
59
|
prop.id = prop.id.replace("$Model", id);
|
|
75
60
|
}
|
|
@@ -82,7 +67,7 @@ var SMD = (_class = class {
|
|
|
82
67
|
[prop.name]: prop
|
|
83
68
|
};
|
|
84
69
|
}, {});
|
|
85
|
-
this.relations = props.filter((prop) =>
|
|
70
|
+
this.relations = props.filter((prop) => _chunkV6CWU5VDjs.isRelationProp.call(void 0, prop)).reduce((result, prop) => {
|
|
86
71
|
return {
|
|
87
72
|
...result,
|
|
88
73
|
[prop.name]: prop
|
|
@@ -127,10 +112,10 @@ var SMD = (_class = class {
|
|
|
127
112
|
const fields2 = subsetGroup[groupKey];
|
|
128
113
|
if (groupKey === "") {
|
|
129
114
|
const realFields = fields2.filter(
|
|
130
|
-
(field) => !
|
|
115
|
+
(field) => !_chunkV6CWU5VDjs.isVirtualProp.call(void 0, this.propsDict[field])
|
|
131
116
|
);
|
|
132
117
|
const virtualFields = fields2.filter(
|
|
133
|
-
(field) =>
|
|
118
|
+
(field) => _chunkV6CWU5VDjs.isVirtualProp.call(void 0, this.propsDict[field])
|
|
134
119
|
);
|
|
135
120
|
if (prefix === "") {
|
|
136
121
|
r.select = r.select.concat(
|
|
@@ -151,7 +136,7 @@ var SMD = (_class = class {
|
|
|
151
136
|
throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 relation \uCC38\uC870 ${groupKey}`);
|
|
152
137
|
}
|
|
153
138
|
const relSMD = SMDManager.get(relation.with);
|
|
154
|
-
if (
|
|
139
|
+
if (_chunkV6CWU5VDjs.isOneToOneRelationProp.call(void 0, relation) || _chunkV6CWU5VDjs.isBelongsToOneRelationProp.call(void 0, relation)) {
|
|
155
140
|
const relFields = fields2.map(
|
|
156
141
|
(field) => field.split(".").slice(1).join(".")
|
|
157
142
|
);
|
|
@@ -169,7 +154,7 @@ var SMD = (_class = class {
|
|
|
169
154
|
if (isAlreadyOuterJoined) {
|
|
170
155
|
return "outer";
|
|
171
156
|
}
|
|
172
|
-
if (
|
|
157
|
+
if (_chunkV6CWU5VDjs.isOneToOneRelationProp.call(void 0, relation)) {
|
|
173
158
|
if (relation.hasJoinColumn === true && (_nullishCoalesce(relation.nullable, () => ( false))) === false) {
|
|
174
159
|
return "inner";
|
|
175
160
|
} else {
|
|
@@ -199,7 +184,7 @@ var SMD = (_class = class {
|
|
|
199
184
|
};
|
|
200
185
|
} else {
|
|
201
186
|
let from, to;
|
|
202
|
-
if (
|
|
187
|
+
if (_chunkV6CWU5VDjs.isOneToOneRelationProp.call(void 0, relation)) {
|
|
203
188
|
if (relation.hasJoinColumn) {
|
|
204
189
|
from = `${fromTable}.${relation.name}_id`;
|
|
205
190
|
to = `${joinAs}.id`;
|
|
@@ -238,13 +223,13 @@ var SMD = (_class = class {
|
|
|
238
223
|
r.loaders = [...r.loaders, ...convertedLoaders];
|
|
239
224
|
}
|
|
240
225
|
r.joins = r.joins.concat(relSubsetQuery.joins);
|
|
241
|
-
} else if (
|
|
226
|
+
} else if (_chunkV6CWU5VDjs.isHasManyRelationProp.call(void 0, relation) || _chunkV6CWU5VDjs.isManyToManyRelationProp.call(void 0, relation)) {
|
|
242
227
|
const relFields = fields2.map(
|
|
243
228
|
(field) => field.split(".").slice(1).join(".")
|
|
244
229
|
);
|
|
245
230
|
const relSubsetQuery = relSMD.resolveSubsetQuery("", relFields);
|
|
246
231
|
let manyJoin;
|
|
247
|
-
if (
|
|
232
|
+
if (_chunkV6CWU5VDjs.isHasManyRelationProp.call(void 0, relation)) {
|
|
248
233
|
manyJoin = {
|
|
249
234
|
fromTable: this.table,
|
|
250
235
|
fromCol: "id",
|
|
@@ -252,7 +237,7 @@ var SMD = (_class = class {
|
|
|
252
237
|
toTable: relSMD.table,
|
|
253
238
|
toCol: relation.joinColumn
|
|
254
239
|
};
|
|
255
|
-
} else if (
|
|
240
|
+
} else if (_chunkV6CWU5VDjs.isManyToManyRelationProp.call(void 0, relation)) {
|
|
256
241
|
const [table1, table2] = relation.joinTable.split("__");
|
|
257
242
|
manyJoin = {
|
|
258
243
|
fromTable: this.table,
|
|
@@ -335,11 +320,11 @@ var SMD = (_class = class {
|
|
|
335
320
|
});
|
|
336
321
|
}
|
|
337
322
|
const prop = smd.propsDict[key];
|
|
338
|
-
if (!
|
|
323
|
+
if (!_chunkV6CWU5VDjs.isRelationProp.call(void 0, prop)) {
|
|
339
324
|
throw new Error(`\uC798\uBABB\uB41C FieldExpr ${key}.${group[0]}`);
|
|
340
325
|
}
|
|
341
326
|
const relSMD = SMDManager.get(prop.with);
|
|
342
|
-
if (
|
|
327
|
+
if (_chunkV6CWU5VDjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkV6CWU5VDjs.isOneToOneRelationProp.call(void 0, prop)) {
|
|
343
328
|
if (group.length == 1 && (group[0] === "id" || group[0] == "id?")) {
|
|
344
329
|
const idProp = relSMD.propsDict.id;
|
|
345
330
|
return {
|
|
@@ -354,7 +339,7 @@ var SMD = (_class = class {
|
|
|
354
339
|
}
|
|
355
340
|
}
|
|
356
341
|
const children = this.fieldExprsToPropNodes(group, relSMD);
|
|
357
|
-
const nodeType =
|
|
342
|
+
const nodeType = _chunkV6CWU5VDjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkV6CWU5VDjs.isOneToOneRelationProp.call(void 0, prop) ? "object" : "array";
|
|
358
343
|
return {
|
|
359
344
|
prop,
|
|
360
345
|
children,
|
|
@@ -368,7 +353,7 @@ var SMD = (_class = class {
|
|
|
368
353
|
if (propName === prefix) {
|
|
369
354
|
return null;
|
|
370
355
|
}
|
|
371
|
-
if (
|
|
356
|
+
if (_chunkV6CWU5VDjs.isRelationProp.call(void 0, prop)) {
|
|
372
357
|
if (maxDepth < 0) {
|
|
373
358
|
return null;
|
|
374
359
|
}
|
|
@@ -408,7 +393,7 @@ var SMD = (_class = class {
|
|
|
408
393
|
}
|
|
409
394
|
const typesModulePath = `${basePath}/${this.names.fs}.types`;
|
|
410
395
|
const typesFileDistPath = _path2.default.join(
|
|
411
|
-
|
|
396
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
412
397
|
`dist/application/${typesModulePath}.js`
|
|
413
398
|
);
|
|
414
399
|
if (_fsextra2.default.existsSync(typesFileDistPath)) {
|
|
@@ -425,7 +410,7 @@ var SMD = (_class = class {
|
|
|
425
410
|
}
|
|
426
411
|
const enumsModulePath = `${basePath}/${this.names.fs}.enums`;
|
|
427
412
|
const enumsFileDistPath = _path2.default.join(
|
|
428
|
-
|
|
413
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
429
414
|
`/dist/application/${enumsModulePath}.js`
|
|
430
415
|
);
|
|
431
416
|
if (_fsextra2.default.existsSync(enumsFileDistPath)) {
|
|
@@ -453,21 +438,23 @@ var SMD = (_class = class {
|
|
|
453
438
|
uniqueColumns
|
|
454
439
|
});
|
|
455
440
|
}
|
|
456
|
-
}
|
|
441
|
+
};
|
|
457
442
|
|
|
458
443
|
// src/smd/smd-manager.ts
|
|
459
|
-
var SMDManagerClass =
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
444
|
+
var SMDManagerClass = class {
|
|
445
|
+
constructor() {
|
|
446
|
+
this.SMDs = /* @__PURE__ */ new Map();
|
|
447
|
+
this.modulePaths = /* @__PURE__ */ new Map();
|
|
448
|
+
this.tableSpecs = /* @__PURE__ */ new Map();
|
|
449
|
+
this.isAutoloaded = false;
|
|
450
|
+
}
|
|
464
451
|
// 경로 전달받아 모든 SMD 파일 로드
|
|
465
452
|
async autoload(doSilent = false) {
|
|
466
453
|
if (this.isAutoloaded) {
|
|
467
454
|
return;
|
|
468
455
|
}
|
|
469
456
|
const pathPattern = _path2.default.join(
|
|
470
|
-
|
|
457
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
471
458
|
"/dist/application/**/*.smd.js"
|
|
472
459
|
);
|
|
473
460
|
!doSilent && console.log(_chalk2.default.yellow(`autoload ${pathPattern}`));
|
|
@@ -554,22 +541,23 @@ var SMDManagerClass = (_class2 = class {constructor() { _class2.prototype.__init
|
|
|
554
541
|
constant: _inflection2.default.underscore(smdId).toUpperCase()
|
|
555
542
|
};
|
|
556
543
|
}
|
|
557
|
-
}
|
|
544
|
+
};
|
|
558
545
|
var SMDManager = new SMDManagerClass();
|
|
559
546
|
|
|
560
547
|
// src/bin/cli.ts
|
|
548
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
561
549
|
console.log(_chalk2.default.bgBlue(`BEGIN ${/* @__PURE__ */ new Date()}`));
|
|
562
550
|
_dotenv2.default.config();
|
|
563
551
|
var migrator;
|
|
564
552
|
async function bootstrap() {
|
|
565
|
-
await
|
|
553
|
+
await _chunkV6CWU5VDjs.Sonamu.init(false, false);
|
|
566
554
|
await _tsicli.tsicli.call(void 0, _process2.default.argv, {
|
|
567
555
|
types: {
|
|
568
556
|
"#entityId": {
|
|
569
557
|
type: "autocomplete",
|
|
570
558
|
name: "#entityId",
|
|
571
559
|
message: "Please input #entityId",
|
|
572
|
-
choices:
|
|
560
|
+
choices: _chunkV6CWU5VDjs.EntityManager.getAllParentIds().map((entityId) => ({
|
|
573
561
|
title: entityId,
|
|
574
562
|
value: entityId
|
|
575
563
|
}))
|
|
@@ -586,7 +574,6 @@ async function bootstrap() {
|
|
|
586
574
|
["migrate", "rollback"],
|
|
587
575
|
["migrate", "reset"],
|
|
588
576
|
["migrate", "clear"],
|
|
589
|
-
["migrate", "status"],
|
|
590
577
|
["stub", "practice", "#name"],
|
|
591
578
|
["stub", "entity", "#name"],
|
|
592
579
|
["scaffold", "model", "#entityId"],
|
|
@@ -602,7 +589,6 @@ async function bootstrap() {
|
|
|
602
589
|
migrate_rollback,
|
|
603
590
|
migrate_clear,
|
|
604
591
|
migrate_reset,
|
|
605
|
-
migrate_status,
|
|
606
592
|
fixture_init,
|
|
607
593
|
fixture_import,
|
|
608
594
|
fixture_sync,
|
|
@@ -621,17 +607,18 @@ bootstrap().finally(async () => {
|
|
|
621
607
|
if (migrator) {
|
|
622
608
|
await migrator.destroy();
|
|
623
609
|
}
|
|
624
|
-
await
|
|
610
|
+
await _chunkV6CWU5VDjs.FixtureManager.destory();
|
|
611
|
+
await _chunkV6CWU5VDjs.BaseModel.destroy();
|
|
625
612
|
console.log(_chalk2.default.bgBlue(`END ${/* @__PURE__ */ new Date()}
|
|
626
613
|
`));
|
|
627
614
|
});
|
|
628
615
|
async function setupMigrator() {
|
|
629
|
-
migrator = new (0,
|
|
616
|
+
migrator = new (0, _chunkV6CWU5VDjs.Migrator)({
|
|
630
617
|
mode: "dev"
|
|
631
618
|
});
|
|
632
619
|
}
|
|
633
620
|
async function setupFixtureManager() {
|
|
634
|
-
|
|
621
|
+
_chunkV6CWU5VDjs.FixtureManager.init();
|
|
635
622
|
}
|
|
636
623
|
async function migrate_run() {
|
|
637
624
|
await setupMigrator();
|
|
@@ -643,11 +630,6 @@ async function migrate_check() {
|
|
|
643
630
|
await migrator.cleanUpDist();
|
|
644
631
|
await migrator.check();
|
|
645
632
|
}
|
|
646
|
-
async function migrate_status() {
|
|
647
|
-
await setupMigrator();
|
|
648
|
-
const status = await migrator.getStatus();
|
|
649
|
-
console.log(status);
|
|
650
|
-
}
|
|
651
633
|
async function migrate_rollback() {
|
|
652
634
|
await setupMigrator();
|
|
653
635
|
await migrator.rollback();
|
|
@@ -661,88 +643,77 @@ async function migrate_reset() {
|
|
|
661
643
|
await migrator.resetAll();
|
|
662
644
|
}
|
|
663
645
|
async function fixture_init() {
|
|
664
|
-
const
|
|
665
|
-
const srcConn = _db.connectionInfo;
|
|
646
|
+
const srcConfig = _chunkV6CWU5VDjs.Sonamu.dbConfig.development_master;
|
|
666
647
|
const targets = [
|
|
667
648
|
{
|
|
668
649
|
label: "(REMOTE) Fixture DB",
|
|
669
|
-
|
|
650
|
+
config: _chunkV6CWU5VDjs.Sonamu.dbConfig.fixture_remote
|
|
670
651
|
},
|
|
671
652
|
{
|
|
672
653
|
label: "(LOCAL) Fixture DB",
|
|
673
|
-
|
|
654
|
+
config: _chunkV6CWU5VDjs.Sonamu.dbConfig.fixture_local,
|
|
655
|
+
toSkip: (() => {
|
|
656
|
+
const remoteConn = _chunkV6CWU5VDjs.Sonamu.dbConfig.fixture_remote.connection;
|
|
657
|
+
const localConn = _chunkV6CWU5VDjs.Sonamu.dbConfig.fixture_local.connection;
|
|
658
|
+
return remoteConn.host === localConn.host && remoteConn.database === localConn.database;
|
|
659
|
+
})()
|
|
674
660
|
},
|
|
675
661
|
{
|
|
676
662
|
label: "(LOCAL) Testing DB",
|
|
677
|
-
|
|
663
|
+
config: _chunkV6CWU5VDjs.Sonamu.dbConfig.test
|
|
678
664
|
}
|
|
679
665
|
];
|
|
680
666
|
console.log("DUMP...");
|
|
681
667
|
const dumpFilename = `/tmp/sonamu-fixture-init-${Date.now()}.sql`;
|
|
668
|
+
const srcConn = srcConfig.connection;
|
|
682
669
|
const migrationsDump = `/tmp/sonamu-fixture-init-migrations-${Date.now()}.sql`;
|
|
683
670
|
_child_process.execSync.call(void 0,
|
|
684
|
-
`mysqldump -h${srcConn.host} -
|
|
671
|
+
`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction -d --no-create-db --triggers ${srcConn.database} > ${dumpFilename}`
|
|
685
672
|
);
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
const [migrations] = await _db.raw(
|
|
689
|
-
"SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = ? AND table_name = ?",
|
|
690
|
-
[srcConn.database, migrationTable]
|
|
673
|
+
_child_process.execSync.call(void 0,
|
|
674
|
+
`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction --no-create-db --triggers ${srcConn.database} knex_migrations knex_migrations_lock > ${migrationsDump}`
|
|
691
675
|
);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
for await (const { label, connKey } of targets) {
|
|
698
|
-
const config = _chunkWJGRXAXEjs.DB.connectionInfo[connKey];
|
|
699
|
-
if (label === "(LOCAL) Fixture DB" && targets.find(
|
|
700
|
-
(t) => t.label === "(REMOTE) Fixture DB" && _chunkWJGRXAXEjs.DB.connectionInfo[t.connKey].host === config.host && _chunkWJGRXAXEjs.DB.connectionInfo[t.connKey].database === config.database
|
|
701
|
-
)) {
|
|
676
|
+
for await (const { label, config, toSkip } of targets) {
|
|
677
|
+
const conn = config.connection;
|
|
678
|
+
if (toSkip === true) {
|
|
702
679
|
console.log(_chalk2.default.red(`${label}: Skipped!`));
|
|
703
680
|
continue;
|
|
704
681
|
}
|
|
705
|
-
const db = (
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
} else {
|
|
711
|
-
const config2 = _lodash2.default.cloneDeep(_chunkWJGRXAXEjs.DB.fullConfig[connKey]);
|
|
712
|
-
config2.database = void 0;
|
|
713
|
-
return new (0, _chunkWJGRXAXEjs.KyselyClient)(config2);
|
|
682
|
+
const db = _knex2.default.call(void 0, {
|
|
683
|
+
...config,
|
|
684
|
+
connection: {
|
|
685
|
+
..._nullishCoalesce(config.connection, () => ( {})),
|
|
686
|
+
database: void 0
|
|
714
687
|
}
|
|
715
|
-
})
|
|
716
|
-
const [row] = await db.raw(`SHOW DATABASES LIKE "${
|
|
688
|
+
});
|
|
689
|
+
const [[row]] = await db.raw(`SHOW DATABASES LIKE "${conn.database}"`);
|
|
717
690
|
if (row) {
|
|
718
691
|
console.log(
|
|
719
|
-
_chalk2.default.yellow(`${label}: Database "${
|
|
692
|
+
_chalk2.default.yellow(`${label}: Database "${conn.database}" Already exists`)
|
|
720
693
|
);
|
|
721
694
|
await db.destroy();
|
|
722
695
|
continue;
|
|
723
696
|
}
|
|
724
697
|
console.log(`SYNC to ${label}...`);
|
|
725
|
-
const mysqlCmd = `mysql -h${
|
|
726
|
-
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${
|
|
727
|
-
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'CREATE DATABASE \`${
|
|
728
|
-
_child_process.execSync.call(void 0, `${mysqlCmd} ${
|
|
729
|
-
|
|
730
|
-
_child_process.execSync.call(void 0, `${mysqlCmd} ${config.database} < ${migrationsDump}`);
|
|
731
|
-
}
|
|
698
|
+
const mysqlCmd = `mysql -h${conn.host} -u${conn.user} -p${conn.password}`;
|
|
699
|
+
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${conn.database}\`'`);
|
|
700
|
+
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'CREATE DATABASE \`${conn.database}\`'`);
|
|
701
|
+
_child_process.execSync.call(void 0, `${mysqlCmd} ${conn.database} < ${dumpFilename}`);
|
|
702
|
+
_child_process.execSync.call(void 0, `${mysqlCmd} ${conn.database} < ${migrationsDump}`);
|
|
732
703
|
await db.destroy();
|
|
733
704
|
}
|
|
734
705
|
}
|
|
735
706
|
async function fixture_import(entityId, recordIds) {
|
|
736
707
|
await setupFixtureManager();
|
|
737
|
-
await
|
|
738
|
-
await
|
|
708
|
+
await _chunkV6CWU5VDjs.FixtureManager.importFixture(entityId, recordIds);
|
|
709
|
+
await _chunkV6CWU5VDjs.FixtureManager.sync();
|
|
739
710
|
}
|
|
740
711
|
async function fixture_sync() {
|
|
741
712
|
await setupFixtureManager();
|
|
742
|
-
await
|
|
713
|
+
await _chunkV6CWU5VDjs.FixtureManager.sync();
|
|
743
714
|
}
|
|
744
715
|
async function stub_practice(name) {
|
|
745
|
-
const practiceDir = _path2.default.join(
|
|
716
|
+
const practiceDir = _path2.default.join(_chunkV6CWU5VDjs.Sonamu.apiRootPath, "src", "practices");
|
|
746
717
|
const fileNames = _fsextra2.default.readdirSync(practiceDir);
|
|
747
718
|
const maxSeqNo = (() => {
|
|
748
719
|
if (_fsextra2.default.existsSync(practiceDir) === false) {
|
|
@@ -785,22 +756,22 @@ async function stub_practice(name) {
|
|
|
785
756
|
_child_process.execSync.call(void 0, `echo "${runCode}" | pbcopy`);
|
|
786
757
|
}
|
|
787
758
|
async function stub_entity(entityId) {
|
|
788
|
-
await
|
|
759
|
+
await _chunkV6CWU5VDjs.Sonamu.syncer.createEntity({ entityId });
|
|
789
760
|
}
|
|
790
761
|
async function scaffold_model(entityId) {
|
|
791
|
-
await
|
|
762
|
+
await _chunkV6CWU5VDjs.Sonamu.syncer.generateTemplate("model", {
|
|
792
763
|
entityId
|
|
793
764
|
});
|
|
794
765
|
}
|
|
795
766
|
async function scaffold_model_test(entityId) {
|
|
796
|
-
await
|
|
767
|
+
await _chunkV6CWU5VDjs.Sonamu.syncer.generateTemplate("model_test", {
|
|
797
768
|
entityId
|
|
798
769
|
});
|
|
799
770
|
}
|
|
800
771
|
async function ui() {
|
|
801
772
|
try {
|
|
802
773
|
const sonamuUI = await Promise.resolve().then(() => _interopRequireWildcard(require("@sonamu-kit/ui")));
|
|
803
|
-
sonamuUI.startServers(
|
|
774
|
+
sonamuUI.startServers(_chunkV6CWU5VDjs.Sonamu.apiRootPath);
|
|
804
775
|
} catch (e) {
|
|
805
776
|
if (e instanceof Error && e.message.includes("isn't declared")) {
|
|
806
777
|
console.log(`You need to install ${_chalk2.default.blue(`@sonamu-kit/ui`)} first.`);
|
|
@@ -839,7 +810,7 @@ async function smd_migration() {
|
|
|
839
810
|
const parentNames = SMDManager.getNamesFromId(_nullishCoalesce(smd.parentId, () => ( smd.id)));
|
|
840
811
|
const names = SMDManager.getNamesFromId(smd.id);
|
|
841
812
|
const dstPath = _path2.default.join(
|
|
842
|
-
|
|
813
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
843
814
|
"src",
|
|
844
815
|
"application",
|
|
845
816
|
parentNames.fs,
|
|
@@ -851,7 +822,7 @@ async function smd_migration() {
|
|
|
851
822
|
_fsextra2.default.writeFileSync(dstPath, formatted);
|
|
852
823
|
console.log(_chalk2.default.blue(`CREATED: ${dstPath}`));
|
|
853
824
|
const srcSmdPath = _path2.default.join(
|
|
854
|
-
|
|
825
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
855
826
|
"src",
|
|
856
827
|
"application",
|
|
857
828
|
parentNames.fs,
|
|
@@ -859,7 +830,7 @@ async function smd_migration() {
|
|
|
859
830
|
);
|
|
860
831
|
const dstSmdPath = srcSmdPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
|
|
861
832
|
const srcEnumsPath = _path2.default.join(
|
|
862
|
-
|
|
833
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
863
834
|
"src",
|
|
864
835
|
"application",
|
|
865
836
|
parentNames.fs,
|
|
@@ -867,7 +838,7 @@ async function smd_migration() {
|
|
|
867
838
|
);
|
|
868
839
|
const dstEnumsPath = srcEnumsPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
|
|
869
840
|
const srcGeneratedPath = _path2.default.join(
|
|
870
|
-
|
|
841
|
+
_chunkV6CWU5VDjs.Sonamu.apiRootPath,
|
|
871
842
|
"src",
|
|
872
843
|
"application",
|
|
873
844
|
parentNames.fs,
|
|
@@ -879,8 +850,8 @@ async function smd_migration() {
|
|
|
879
850
|
dstSmdPath,
|
|
880
851
|
srcEnumsPath,
|
|
881
852
|
dstEnumsPath,
|
|
882
|
-
...
|
|
883
|
-
(target) => srcEnumsPath.replace(
|
|
853
|
+
..._chunkV6CWU5VDjs.Sonamu.config.sync.targets.map(
|
|
854
|
+
(target) => srcEnumsPath.replace(_chunkV6CWU5VDjs.Sonamu.apiRootPath, _path2.default.join(_chunkV6CWU5VDjs.Sonamu.appRootPath, target)).replace("/src/application/", "/src/services/")
|
|
884
855
|
),
|
|
885
856
|
srcGeneratedPath,
|
|
886
857
|
dstGeneratedPath
|
|
@@ -894,11 +865,11 @@ async function smd_migration() {
|
|
|
894
865
|
});
|
|
895
866
|
}
|
|
896
867
|
console.log("Entity\uB85C \uB2E4\uC2DC \uB85C\uB4DC\uD569\uB2C8\uB2E4.");
|
|
897
|
-
|
|
898
|
-
await
|
|
899
|
-
const entityIds =
|
|
868
|
+
_chunkV6CWU5VDjs.EntityManager.isAutoloaded = false;
|
|
869
|
+
await _chunkV6CWU5VDjs.EntityManager.autoload();
|
|
870
|
+
const entityIds = _chunkV6CWU5VDjs.EntityManager.getAllParentIds();
|
|
900
871
|
for await (const entityId of entityIds) {
|
|
901
|
-
await
|
|
872
|
+
await _chunkV6CWU5VDjs.Sonamu.syncer.generateTemplate("generated", { entityId });
|
|
902
873
|
}
|
|
903
874
|
}
|
|
904
875
|
//# sourceMappingURL=cli.js.map
|