sonamu 0.2.48 → 0.2.49
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-wrapper.js +12 -2
- package/dist/bin/cli-wrapper.js.map +1 -1
- package/dist/bin/cli.js +54 -62
- package/dist/bin/cli.js.map +1 -1
- package/dist/{chunk-76VBQWGE.js → chunk-HATLA54Z.js} +167 -97
- package/dist/chunk-HATLA54Z.js.map +1 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/api/sonamu.ts +3 -2
- package/src/bin/cli-wrapper.ts +20 -1
- package/src/bin/cli.ts +5 -15
- package/src/database/_batch_update.ts +29 -14
- package/src/database/upsert-builder.ts +56 -42
- package/src/testing/fixture-manager.ts +122 -36
- package/src/types/types.ts +3 -2
- package/src/utils/utils.ts +15 -13
- package/dist/chunk-76VBQWGE.js.map +0 -1
package/dist/bin/cli-wrapper.js
CHANGED
|
@@ -8,9 +8,19 @@ var cjsPath = _path.resolve.call(void 0, __dirname, "bin/cli.js");
|
|
|
8
8
|
var esmPath = _path.resolve.call(void 0, __dirname, "bin/cli.mjs");
|
|
9
9
|
var isESM = () => {
|
|
10
10
|
const packageJsonPath = _path.resolve.call(void 0, process.cwd(), "package.json");
|
|
11
|
+
const packageJson = JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf-8"));
|
|
12
|
+
if (packageJson.type === "module") {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (process.env.USE_ESM === "true") {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
11
18
|
if (_fs.existsSync.call(void 0, packageJsonPath)) {
|
|
12
|
-
const
|
|
13
|
-
return
|
|
19
|
+
const packageJson2 = JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf-8"));
|
|
20
|
+
return packageJson2.type === "module";
|
|
21
|
+
}
|
|
22
|
+
if (packageJson.main && _path.extname.call(void 0, packageJson.main) === ".mjs") {
|
|
23
|
+
return true;
|
|
14
24
|
}
|
|
15
25
|
return false;
|
|
16
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/cli-wrapper.ts"],"names":[],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../src/bin/cli-wrapper.ts"],"names":["packageJson"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,eAAe;AACjC,SAAS,YAAY,oBAAoB;AAEzC,IAAM,UAAU,QAAQ,WAAW,YAAY;AAC/C,IAAM,UAAU,QAAQ,WAAW,aAAa;AAEhD,IAAM,QAAQ,MAAM;AAClB,QAAM,kBAAkB,QAAQ,QAAQ,IAAI,GAAG,cAAc;AAC7D,QAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AAGrE,MAAI,YAAY,SAAS,UAAU;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,QAAQ,IAAI,YAAY,QAAQ;AAClC,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,eAAe,GAAG;AAC/B,UAAMA,eAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AACrE,WAAOA,aAAY,SAAS;AAAA,EAC9B;AAGA,MAAI,YAAY,QAAQ,QAAQ,YAAY,IAAI,MAAM,QAAQ;AAC5D,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,IAAM,aAAa,MAAM,IAAI,UAAU;AAEvC,IAAI,CAAC,WAAW,UAAU,GAAG;AAC3B,UAAQ,MAAM,8BAA8B,UAAU,EAAE;AACxD,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,SAAS;AAAA,EACb,QAAQ;AAAA,EACR,CAAC,YAAY,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAC;AAAA,EACrC;AAAA,IACE,OAAO;AAAA,EACT;AACF;AAEA,QAAQ,KAAK,OAAO,UAAU,CAAC","sourcesContent":["#!/usr/bin/env ts-node\n\nimport { spawnSync } from \"child_process\";\nimport { extname, resolve } from \"path\";\nimport { existsSync, readFileSync } from \"fs\";\n\nconst cjsPath = resolve(__dirname, \"bin/cli.js\");\nconst esmPath = resolve(__dirname, \"bin/cli.mjs\");\n\nconst isESM = () => {\n const packageJsonPath = resolve(process.cwd(), \"package.json\");\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n\n // package.json에 \"type\": \"module\" 설정 확인\n if (packageJson.type === \"module\") {\n return true;\n }\n\n // 환경 변수에서 ESM 여부 확인\n if (process.env.USE_ESM === \"true\") {\n return true;\n }\n\n // package.json에 \"type\": \"module\" 설정\n if (existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n return packageJson.type === \"module\";\n }\n\n // main 필드가 .mjs로 끝나는지 확인\n if (packageJson.main && extname(packageJson.main) === \".mjs\") {\n return true;\n }\n\n return false;\n};\n\nconst scriptPath = isESM() ? esmPath : cjsPath;\n\nif (!existsSync(scriptPath)) {\n console.error(`Error: Script not found at ${scriptPath}`);\n process.exit(1);\n}\n\nconst result = spawnSync(\n process.execPath,\n [scriptPath, ...process.argv.slice(2)],\n {\n stdio: \"inherit\",\n }\n);\n\nprocess.exit(result.status ?? 1);\n"]}
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkHATLA54Zjs = require('../chunk-HATLA54Z.js');
|
|
15
15
|
|
|
16
16
|
// src/bin/cli.ts
|
|
17
17
|
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
|
|
@@ -54,7 +54,7 @@ var SMD = class {
|
|
|
54
54
|
this.table = _nullishCoalesce(table, () => ( _inflection2.default.underscore(_inflection2.default.pluralize(id))));
|
|
55
55
|
if (props) {
|
|
56
56
|
this.props = props.map((prop) => {
|
|
57
|
-
if (
|
|
57
|
+
if (_chunkHATLA54Zjs.isEnumProp.call(void 0, prop)) {
|
|
58
58
|
if (prop.id.includes("$Model")) {
|
|
59
59
|
prop.id = prop.id.replace("$Model", id);
|
|
60
60
|
}
|
|
@@ -67,7 +67,7 @@ var SMD = class {
|
|
|
67
67
|
[prop.name]: prop
|
|
68
68
|
};
|
|
69
69
|
}, {});
|
|
70
|
-
this.relations = props.filter((prop) =>
|
|
70
|
+
this.relations = props.filter((prop) => _chunkHATLA54Zjs.isRelationProp.call(void 0, prop)).reduce((result, prop) => {
|
|
71
71
|
return {
|
|
72
72
|
...result,
|
|
73
73
|
[prop.name]: prop
|
|
@@ -112,10 +112,10 @@ var SMD = class {
|
|
|
112
112
|
const fields2 = subsetGroup[groupKey];
|
|
113
113
|
if (groupKey === "") {
|
|
114
114
|
const realFields = fields2.filter(
|
|
115
|
-
(field) => !
|
|
115
|
+
(field) => !_chunkHATLA54Zjs.isVirtualProp.call(void 0, this.propsDict[field])
|
|
116
116
|
);
|
|
117
117
|
const virtualFields = fields2.filter(
|
|
118
|
-
(field) =>
|
|
118
|
+
(field) => _chunkHATLA54Zjs.isVirtualProp.call(void 0, this.propsDict[field])
|
|
119
119
|
);
|
|
120
120
|
if (prefix === "") {
|
|
121
121
|
r.select = r.select.concat(
|
|
@@ -136,7 +136,7 @@ var SMD = class {
|
|
|
136
136
|
throw new Error(`\uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 relation \uCC38\uC870 ${groupKey}`);
|
|
137
137
|
}
|
|
138
138
|
const relSMD = SMDManager.get(relation.with);
|
|
139
|
-
if (
|
|
139
|
+
if (_chunkHATLA54Zjs.isOneToOneRelationProp.call(void 0, relation) || _chunkHATLA54Zjs.isBelongsToOneRelationProp.call(void 0, relation)) {
|
|
140
140
|
const relFields = fields2.map(
|
|
141
141
|
(field) => field.split(".").slice(1).join(".")
|
|
142
142
|
);
|
|
@@ -154,7 +154,7 @@ var SMD = class {
|
|
|
154
154
|
if (isAlreadyOuterJoined) {
|
|
155
155
|
return "outer";
|
|
156
156
|
}
|
|
157
|
-
if (
|
|
157
|
+
if (_chunkHATLA54Zjs.isOneToOneRelationProp.call(void 0, relation)) {
|
|
158
158
|
if (relation.hasJoinColumn === true && (_nullishCoalesce(relation.nullable, () => ( false))) === false) {
|
|
159
159
|
return "inner";
|
|
160
160
|
} else {
|
|
@@ -184,7 +184,7 @@ var SMD = class {
|
|
|
184
184
|
};
|
|
185
185
|
} else {
|
|
186
186
|
let from, to;
|
|
187
|
-
if (
|
|
187
|
+
if (_chunkHATLA54Zjs.isOneToOneRelationProp.call(void 0, relation)) {
|
|
188
188
|
if (relation.hasJoinColumn) {
|
|
189
189
|
from = `${fromTable}.${relation.name}_id`;
|
|
190
190
|
to = `${joinAs}.id`;
|
|
@@ -223,13 +223,13 @@ var SMD = class {
|
|
|
223
223
|
r.loaders = [...r.loaders, ...convertedLoaders];
|
|
224
224
|
}
|
|
225
225
|
r.joins = r.joins.concat(relSubsetQuery.joins);
|
|
226
|
-
} else if (
|
|
226
|
+
} else if (_chunkHATLA54Zjs.isHasManyRelationProp.call(void 0, relation) || _chunkHATLA54Zjs.isManyToManyRelationProp.call(void 0, relation)) {
|
|
227
227
|
const relFields = fields2.map(
|
|
228
228
|
(field) => field.split(".").slice(1).join(".")
|
|
229
229
|
);
|
|
230
230
|
const relSubsetQuery = relSMD.resolveSubsetQuery("", relFields);
|
|
231
231
|
let manyJoin;
|
|
232
|
-
if (
|
|
232
|
+
if (_chunkHATLA54Zjs.isHasManyRelationProp.call(void 0, relation)) {
|
|
233
233
|
manyJoin = {
|
|
234
234
|
fromTable: this.table,
|
|
235
235
|
fromCol: "id",
|
|
@@ -237,7 +237,7 @@ var SMD = class {
|
|
|
237
237
|
toTable: relSMD.table,
|
|
238
238
|
toCol: relation.joinColumn
|
|
239
239
|
};
|
|
240
|
-
} else if (
|
|
240
|
+
} else if (_chunkHATLA54Zjs.isManyToManyRelationProp.call(void 0, relation)) {
|
|
241
241
|
const [table1, table2] = relation.joinTable.split("__");
|
|
242
242
|
manyJoin = {
|
|
243
243
|
fromTable: this.table,
|
|
@@ -320,11 +320,11 @@ var SMD = class {
|
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
322
|
const prop = smd.propsDict[key];
|
|
323
|
-
if (!
|
|
323
|
+
if (!_chunkHATLA54Zjs.isRelationProp.call(void 0, prop)) {
|
|
324
324
|
throw new Error(`\uC798\uBABB\uB41C FieldExpr ${key}.${group[0]}`);
|
|
325
325
|
}
|
|
326
326
|
const relSMD = SMDManager.get(prop.with);
|
|
327
|
-
if (
|
|
327
|
+
if (_chunkHATLA54Zjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkHATLA54Zjs.isOneToOneRelationProp.call(void 0, prop)) {
|
|
328
328
|
if (group.length == 1 && (group[0] === "id" || group[0] == "id?")) {
|
|
329
329
|
const idProp = relSMD.propsDict.id;
|
|
330
330
|
return {
|
|
@@ -339,7 +339,7 @@ var SMD = class {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
const children = this.fieldExprsToPropNodes(group, relSMD);
|
|
342
|
-
const nodeType =
|
|
342
|
+
const nodeType = _chunkHATLA54Zjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunkHATLA54Zjs.isOneToOneRelationProp.call(void 0, prop) ? "object" : "array";
|
|
343
343
|
return {
|
|
344
344
|
prop,
|
|
345
345
|
children,
|
|
@@ -353,7 +353,7 @@ var SMD = class {
|
|
|
353
353
|
if (propName === prefix) {
|
|
354
354
|
return null;
|
|
355
355
|
}
|
|
356
|
-
if (
|
|
356
|
+
if (_chunkHATLA54Zjs.isRelationProp.call(void 0, prop)) {
|
|
357
357
|
if (maxDepth < 0) {
|
|
358
358
|
return null;
|
|
359
359
|
}
|
|
@@ -393,7 +393,7 @@ var SMD = class {
|
|
|
393
393
|
}
|
|
394
394
|
const typesModulePath = `${basePath}/${this.names.fs}.types`;
|
|
395
395
|
const typesFileDistPath = _path2.default.join(
|
|
396
|
-
|
|
396
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
397
397
|
`dist/application/${typesModulePath}.js`
|
|
398
398
|
);
|
|
399
399
|
if (_fsextra2.default.existsSync(typesFileDistPath)) {
|
|
@@ -410,7 +410,7 @@ var SMD = class {
|
|
|
410
410
|
}
|
|
411
411
|
const enumsModulePath = `${basePath}/${this.names.fs}.enums`;
|
|
412
412
|
const enumsFileDistPath = _path2.default.join(
|
|
413
|
-
|
|
413
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
414
414
|
`/dist/application/${enumsModulePath}.js`
|
|
415
415
|
);
|
|
416
416
|
if (_fsextra2.default.existsSync(enumsFileDistPath)) {
|
|
@@ -454,7 +454,7 @@ var SMDManagerClass = class {
|
|
|
454
454
|
return;
|
|
455
455
|
}
|
|
456
456
|
const pathPattern = _path2.default.join(
|
|
457
|
-
|
|
457
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
458
458
|
"/dist/application/**/*.smd.js"
|
|
459
459
|
);
|
|
460
460
|
!doSilent && console.log(_chalk2.default.yellow(`autoload ${pathPattern}`));
|
|
@@ -550,14 +550,14 @@ console.log(_chalk2.default.bgBlue(`BEGIN ${/* @__PURE__ */ new Date()}`));
|
|
|
550
550
|
_dotenv2.default.config();
|
|
551
551
|
var migrator;
|
|
552
552
|
async function bootstrap() {
|
|
553
|
-
await
|
|
553
|
+
await _chunkHATLA54Zjs.Sonamu.init(false, false);
|
|
554
554
|
await _tsicli.tsicli.call(void 0, _process2.default.argv, {
|
|
555
555
|
types: {
|
|
556
556
|
"#entityId": {
|
|
557
557
|
type: "autocomplete",
|
|
558
558
|
name: "#entityId",
|
|
559
559
|
message: "Please input #entityId",
|
|
560
|
-
choices:
|
|
560
|
+
choices: _chunkHATLA54Zjs.EntityManager.getAllParentIds().map((entityId) => ({
|
|
561
561
|
title: entityId,
|
|
562
562
|
value: entityId
|
|
563
563
|
}))
|
|
@@ -607,18 +607,18 @@ bootstrap().finally(async () => {
|
|
|
607
607
|
if (migrator) {
|
|
608
608
|
await migrator.destroy();
|
|
609
609
|
}
|
|
610
|
-
await
|
|
611
|
-
await
|
|
610
|
+
await _chunkHATLA54Zjs.FixtureManager.destory();
|
|
611
|
+
await _chunkHATLA54Zjs.BaseModel.destroy();
|
|
612
612
|
console.log(_chalk2.default.bgBlue(`END ${/* @__PURE__ */ new Date()}
|
|
613
613
|
`));
|
|
614
614
|
});
|
|
615
615
|
async function setupMigrator() {
|
|
616
|
-
migrator = new (0,
|
|
616
|
+
migrator = new (0, _chunkHATLA54Zjs.Migrator)({
|
|
617
617
|
mode: "dev"
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
620
|
async function setupFixtureManager() {
|
|
621
|
-
|
|
621
|
+
_chunkHATLA54Zjs.FixtureManager.init();
|
|
622
622
|
}
|
|
623
623
|
async function migrate_run() {
|
|
624
624
|
await setupMigrator();
|
|
@@ -643,32 +643,36 @@ async function migrate_reset() {
|
|
|
643
643
|
await migrator.resetAll();
|
|
644
644
|
}
|
|
645
645
|
async function fixture_init() {
|
|
646
|
-
const srcConfig =
|
|
646
|
+
const srcConfig = _chunkHATLA54Zjs.Sonamu.dbConfig.development_master;
|
|
647
647
|
const targets = [
|
|
648
648
|
{
|
|
649
649
|
label: "(REMOTE) Fixture DB",
|
|
650
|
-
config:
|
|
650
|
+
config: _chunkHATLA54Zjs.Sonamu.dbConfig.fixture_remote
|
|
651
651
|
},
|
|
652
652
|
{
|
|
653
653
|
label: "(LOCAL) Fixture DB",
|
|
654
|
-
config:
|
|
654
|
+
config: _chunkHATLA54Zjs.Sonamu.dbConfig.fixture_local,
|
|
655
655
|
toSkip: (() => {
|
|
656
|
-
const remoteConn =
|
|
657
|
-
const localConn =
|
|
656
|
+
const remoteConn = _chunkHATLA54Zjs.Sonamu.dbConfig.fixture_remote.connection;
|
|
657
|
+
const localConn = _chunkHATLA54Zjs.Sonamu.dbConfig.fixture_local.connection;
|
|
658
658
|
return remoteConn.host === localConn.host && remoteConn.database === localConn.database;
|
|
659
659
|
})()
|
|
660
660
|
},
|
|
661
661
|
{
|
|
662
662
|
label: "(LOCAL) Testing DB",
|
|
663
|
-
config:
|
|
663
|
+
config: _chunkHATLA54Zjs.Sonamu.dbConfig.test
|
|
664
664
|
}
|
|
665
665
|
];
|
|
666
666
|
console.log("DUMP...");
|
|
667
667
|
const dumpFilename = `/tmp/sonamu-fixture-init-${Date.now()}.sql`;
|
|
668
668
|
const srcConn = srcConfig.connection;
|
|
669
|
+
const migrationsDump = `/tmp/sonamu-fixture-init-migrations-${Date.now()}.sql`;
|
|
669
670
|
_child_process.execSync.call(void 0,
|
|
670
671
|
`mysqldump -h${srcConn.host} -u${srcConn.user} -p${srcConn.password} --single-transaction -d --no-create-db --triggers ${srcConn.database} > ${dumpFilename}`
|
|
671
672
|
);
|
|
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}`
|
|
675
|
+
);
|
|
672
676
|
for await (const { label, config, toSkip } of targets) {
|
|
673
677
|
const conn = config.connection;
|
|
674
678
|
if (toSkip === true) {
|
|
@@ -695,33 +699,21 @@ async function fixture_init() {
|
|
|
695
699
|
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'DROP DATABASE IF EXISTS \`${conn.database}\`'`);
|
|
696
700
|
_child_process.execSync.call(void 0, `${mysqlCmd} -e 'CREATE DATABASE \`${conn.database}\`'`);
|
|
697
701
|
_child_process.execSync.call(void 0, `${mysqlCmd} ${conn.database} < ${dumpFilename}`);
|
|
698
|
-
|
|
699
|
-
["knex_migrations", "knex_migrations_lock"].map(async (tableName) => {
|
|
700
|
-
const [table] = await db.raw(
|
|
701
|
-
`SHOW TABLES FROM \`${srcConn.database}\` LIKE '${tableName}'`
|
|
702
|
-
);
|
|
703
|
-
if (_optionalChain([table, 'optionalAccess', _2 => _2.length])) {
|
|
704
|
-
await db.raw(
|
|
705
|
-
`INSERT INTO \`${conn.database}\`.${tableName}
|
|
706
|
-
SELECT * FROM \`${srcConn.database}\`.${tableName}`
|
|
707
|
-
);
|
|
708
|
-
}
|
|
709
|
-
})
|
|
710
|
-
);
|
|
702
|
+
_child_process.execSync.call(void 0, `${mysqlCmd} ${conn.database} < ${migrationsDump}`);
|
|
711
703
|
await db.destroy();
|
|
712
704
|
}
|
|
713
705
|
}
|
|
714
706
|
async function fixture_import(entityId, recordIds) {
|
|
715
707
|
await setupFixtureManager();
|
|
716
|
-
await
|
|
717
|
-
await
|
|
708
|
+
await _chunkHATLA54Zjs.FixtureManager.importFixture(entityId, recordIds);
|
|
709
|
+
await _chunkHATLA54Zjs.FixtureManager.sync();
|
|
718
710
|
}
|
|
719
711
|
async function fixture_sync() {
|
|
720
712
|
await setupFixtureManager();
|
|
721
|
-
await
|
|
713
|
+
await _chunkHATLA54Zjs.FixtureManager.sync();
|
|
722
714
|
}
|
|
723
715
|
async function stub_practice(name) {
|
|
724
|
-
const practiceDir = _path2.default.join(
|
|
716
|
+
const practiceDir = _path2.default.join(_chunkHATLA54Zjs.Sonamu.apiRootPath, "src", "practices");
|
|
725
717
|
const fileNames = _fsextra2.default.readdirSync(practiceDir);
|
|
726
718
|
const maxSeqNo = (() => {
|
|
727
719
|
if (_fsextra2.default.existsSync(practiceDir) === false) {
|
|
@@ -764,22 +756,22 @@ async function stub_practice(name) {
|
|
|
764
756
|
_child_process.execSync.call(void 0, `echo "${runCode}" | pbcopy`);
|
|
765
757
|
}
|
|
766
758
|
async function stub_entity(entityId) {
|
|
767
|
-
await
|
|
759
|
+
await _chunkHATLA54Zjs.Sonamu.syncer.createEntity({ entityId });
|
|
768
760
|
}
|
|
769
761
|
async function scaffold_model(entityId) {
|
|
770
|
-
await
|
|
762
|
+
await _chunkHATLA54Zjs.Sonamu.syncer.generateTemplate("model", {
|
|
771
763
|
entityId
|
|
772
764
|
});
|
|
773
765
|
}
|
|
774
766
|
async function scaffold_model_test(entityId) {
|
|
775
|
-
await
|
|
767
|
+
await _chunkHATLA54Zjs.Sonamu.syncer.generateTemplate("model_test", {
|
|
776
768
|
entityId
|
|
777
769
|
});
|
|
778
770
|
}
|
|
779
771
|
async function ui() {
|
|
780
772
|
try {
|
|
781
773
|
const sonamuUI = await Promise.resolve().then(() => _interopRequireWildcard(require("@sonamu-kit/ui")));
|
|
782
|
-
sonamuUI.startServers(
|
|
774
|
+
sonamuUI.startServers(_chunkHATLA54Zjs.Sonamu.apiRootPath);
|
|
783
775
|
} catch (e) {
|
|
784
776
|
if (e instanceof Error && e.message.includes("isn't declared")) {
|
|
785
777
|
console.log(`You need to install ${_chalk2.default.blue(`@sonamu-kit/ui`)} first.`);
|
|
@@ -818,7 +810,7 @@ async function smd_migration() {
|
|
|
818
810
|
const parentNames = SMDManager.getNamesFromId(_nullishCoalesce(smd.parentId, () => ( smd.id)));
|
|
819
811
|
const names = SMDManager.getNamesFromId(smd.id);
|
|
820
812
|
const dstPath = _path2.default.join(
|
|
821
|
-
|
|
813
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
822
814
|
"src",
|
|
823
815
|
"application",
|
|
824
816
|
parentNames.fs,
|
|
@@ -830,7 +822,7 @@ async function smd_migration() {
|
|
|
830
822
|
_fsextra2.default.writeFileSync(dstPath, formatted);
|
|
831
823
|
console.log(_chalk2.default.blue(`CREATED: ${dstPath}`));
|
|
832
824
|
const srcSmdPath = _path2.default.join(
|
|
833
|
-
|
|
825
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
834
826
|
"src",
|
|
835
827
|
"application",
|
|
836
828
|
parentNames.fs,
|
|
@@ -838,7 +830,7 @@ async function smd_migration() {
|
|
|
838
830
|
);
|
|
839
831
|
const dstSmdPath = srcSmdPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
|
|
840
832
|
const srcEnumsPath = _path2.default.join(
|
|
841
|
-
|
|
833
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
842
834
|
"src",
|
|
843
835
|
"application",
|
|
844
836
|
parentNames.fs,
|
|
@@ -846,7 +838,7 @@ async function smd_migration() {
|
|
|
846
838
|
);
|
|
847
839
|
const dstEnumsPath = srcEnumsPath.replace("/src/", "/dist/").replace(/\.ts$/, ".js");
|
|
848
840
|
const srcGeneratedPath = _path2.default.join(
|
|
849
|
-
|
|
841
|
+
_chunkHATLA54Zjs.Sonamu.apiRootPath,
|
|
850
842
|
"src",
|
|
851
843
|
"application",
|
|
852
844
|
parentNames.fs,
|
|
@@ -858,8 +850,8 @@ async function smd_migration() {
|
|
|
858
850
|
dstSmdPath,
|
|
859
851
|
srcEnumsPath,
|
|
860
852
|
dstEnumsPath,
|
|
861
|
-
...
|
|
862
|
-
(target) => srcEnumsPath.replace(
|
|
853
|
+
..._chunkHATLA54Zjs.Sonamu.config.sync.targets.map(
|
|
854
|
+
(target) => srcEnumsPath.replace(_chunkHATLA54Zjs.Sonamu.apiRootPath, _path2.default.join(_chunkHATLA54Zjs.Sonamu.appRootPath, target)).replace("/src/application/", "/src/services/")
|
|
863
855
|
),
|
|
864
856
|
srcGeneratedPath,
|
|
865
857
|
dstGeneratedPath
|
|
@@ -873,11 +865,11 @@ async function smd_migration() {
|
|
|
873
865
|
});
|
|
874
866
|
}
|
|
875
867
|
console.log("Entity\uB85C \uB2E4\uC2DC \uB85C\uB4DC\uD569\uB2C8\uB2E4.");
|
|
876
|
-
|
|
877
|
-
await
|
|
878
|
-
const entityIds =
|
|
868
|
+
_chunkHATLA54Zjs.EntityManager.isAutoloaded = false;
|
|
869
|
+
await _chunkHATLA54Zjs.EntityManager.autoload();
|
|
870
|
+
const entityIds = _chunkHATLA54Zjs.EntityManager.getAllParentIds();
|
|
879
871
|
for await (const entityId of entityIds) {
|
|
880
|
-
await
|
|
872
|
+
await _chunkHATLA54Zjs.Sonamu.syncer.generateTemplate("generated", { entityId });
|
|
881
873
|
}
|
|
882
874
|
}
|
|
883
875
|
//# sourceMappingURL=cli.js.map
|