sonamu 0.2.48 → 0.2.50

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.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env ts-node
@@ -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 packageJson = JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf-8"));
13
- return packageJson.type === "module";
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;AACxB,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,MAAI,WAAW,eAAe,GAAG;AAC/B,UAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AACrE,WAAO,YAAY,SAAS;AAAA,EAC9B;AACA,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 { 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 if (existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n return packageJson.type === \"module\";\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"]}
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"]}
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ts-node
2
+ const require = (await import('module')).createRequire(import.meta.url);
3
+ import {
4
+ __dirname
5
+ } from "../chunk-JXJTFHF7.mjs";
6
+
7
+ // src/bin/cli-wrapper.ts
8
+ import { spawnSync } from "child_process";
9
+ import { extname, resolve } from "path";
10
+ import { existsSync, readFileSync } from "fs";
11
+ var cjsPath = resolve(__dirname, "bin/cli.js");
12
+ var esmPath = resolve(__dirname, "bin/cli.mjs");
13
+ var isESM = () => {
14
+ const packageJsonPath = resolve(process.cwd(), "package.json");
15
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
16
+ if (packageJson.type === "module") {
17
+ return true;
18
+ }
19
+ if (process.env.USE_ESM === "true") {
20
+ return true;
21
+ }
22
+ if (existsSync(packageJsonPath)) {
23
+ const packageJson2 = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
24
+ return packageJson2.type === "module";
25
+ }
26
+ if (packageJson.main && extname(packageJson.main) === ".mjs") {
27
+ return true;
28
+ }
29
+ return false;
30
+ };
31
+ var scriptPath = isESM() ? esmPath : cjsPath;
32
+ if (!existsSync(scriptPath)) {
33
+ console.error(`Error: Script not found at ${scriptPath}`);
34
+ process.exit(1);
35
+ }
36
+ var result = spawnSync(
37
+ process.execPath,
38
+ [scriptPath, ...process.argv.slice(2)],
39
+ {
40
+ stdio: "inherit"
41
+ }
42
+ );
43
+ process.exit(result.status ?? 1);
44
+ //# sourceMappingURL=cli-wrapper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bin/cli-wrapper.ts"],"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"],"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;","names":["packageJson"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
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(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
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 _chunk76VBQWGEjs = require('../chunk-76VBQWGE.js');
14
+ var _chunk4EET56IEjs = require('../chunk-4EET56IE.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 (_chunk76VBQWGEjs.isEnumProp.call(void 0, prop)) {
57
+ if (_chunk4EET56IEjs.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) => _chunk76VBQWGEjs.isRelationProp.call(void 0, prop)).reduce((result, prop) => {
70
+ this.relations = props.filter((prop) => _chunk4EET56IEjs.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) => !_chunk76VBQWGEjs.isVirtualProp.call(void 0, this.propsDict[field])
115
+ (field) => !_chunk4EET56IEjs.isVirtualProp.call(void 0, this.propsDict[field])
116
116
  );
117
117
  const virtualFields = fields2.filter(
118
- (field) => _chunk76VBQWGEjs.isVirtualProp.call(void 0, this.propsDict[field])
118
+ (field) => _chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isOneToOneRelationProp.call(void 0, relation) || _chunk76VBQWGEjs.isBelongsToOneRelationProp.call(void 0, relation)) {
139
+ if (_chunk4EET56IEjs.isOneToOneRelationProp.call(void 0, relation) || _chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isOneToOneRelationProp.call(void 0, relation)) {
157
+ if (_chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isOneToOneRelationProp.call(void 0, relation)) {
187
+ if (_chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isHasManyRelationProp.call(void 0, relation) || _chunk76VBQWGEjs.isManyToManyRelationProp.call(void 0, relation)) {
226
+ } else if (_chunk4EET56IEjs.isHasManyRelationProp.call(void 0, relation) || _chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isHasManyRelationProp.call(void 0, relation)) {
232
+ if (_chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isManyToManyRelationProp.call(void 0, relation)) {
240
+ } else if (_chunk4EET56IEjs.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 (!_chunk76VBQWGEjs.isRelationProp.call(void 0, prop)) {
323
+ if (!_chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk76VBQWGEjs.isOneToOneRelationProp.call(void 0, prop)) {
327
+ if (_chunk4EET56IEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk4EET56IEjs.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 = _chunk76VBQWGEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk76VBQWGEjs.isOneToOneRelationProp.call(void 0, prop) ? "object" : "array";
342
+ const nodeType = _chunk4EET56IEjs.isBelongsToOneRelationProp.call(void 0, prop) || _chunk4EET56IEjs.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 (_chunk76VBQWGEjs.isRelationProp.call(void 0, prop)) {
356
+ if (_chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
396
+ _chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
413
+ _chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
457
+ _chunk4EET56IEjs.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 _chunk76VBQWGEjs.Sonamu.init(false, false);
553
+ await _chunk4EET56IEjs.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: _chunk76VBQWGEjs.EntityManager.getAllParentIds().map((entityId) => ({
560
+ choices: _chunk4EET56IEjs.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 _chunk76VBQWGEjs.FixtureManager.destory();
611
- await _chunk76VBQWGEjs.BaseModel.destroy();
610
+ await _chunk4EET56IEjs.FixtureManager.destory();
611
+ await _chunk4EET56IEjs.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, _chunk76VBQWGEjs.Migrator)({
616
+ migrator = new (0, _chunk4EET56IEjs.Migrator)({
617
617
  mode: "dev"
618
618
  });
619
619
  }
620
620
  async function setupFixtureManager() {
621
- _chunk76VBQWGEjs.FixtureManager.init();
621
+ _chunk4EET56IEjs.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 = _chunk76VBQWGEjs.Sonamu.dbConfig.development_master;
646
+ const srcConfig = _chunk4EET56IEjs.Sonamu.dbConfig.development_master;
647
647
  const targets = [
648
648
  {
649
649
  label: "(REMOTE) Fixture DB",
650
- config: _chunk76VBQWGEjs.Sonamu.dbConfig.fixture_remote
650
+ config: _chunk4EET56IEjs.Sonamu.dbConfig.fixture_remote
651
651
  },
652
652
  {
653
653
  label: "(LOCAL) Fixture DB",
654
- config: _chunk76VBQWGEjs.Sonamu.dbConfig.fixture_local,
654
+ config: _chunk4EET56IEjs.Sonamu.dbConfig.fixture_local,
655
655
  toSkip: (() => {
656
- const remoteConn = _chunk76VBQWGEjs.Sonamu.dbConfig.fixture_remote.connection;
657
- const localConn = _chunk76VBQWGEjs.Sonamu.dbConfig.fixture_local.connection;
656
+ const remoteConn = _chunk4EET56IEjs.Sonamu.dbConfig.fixture_remote.connection;
657
+ const localConn = _chunk4EET56IEjs.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: _chunk76VBQWGEjs.Sonamu.dbConfig.test
663
+ config: _chunk4EET56IEjs.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
- await Promise.all(
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 _chunk76VBQWGEjs.FixtureManager.importFixture(entityId, recordIds);
717
- await _chunk76VBQWGEjs.FixtureManager.sync();
708
+ await _chunk4EET56IEjs.FixtureManager.importFixture(entityId, recordIds);
709
+ await _chunk4EET56IEjs.FixtureManager.sync();
718
710
  }
719
711
  async function fixture_sync() {
720
712
  await setupFixtureManager();
721
- await _chunk76VBQWGEjs.FixtureManager.sync();
713
+ await _chunk4EET56IEjs.FixtureManager.sync();
722
714
  }
723
715
  async function stub_practice(name) {
724
- const practiceDir = _path2.default.join(_chunk76VBQWGEjs.Sonamu.apiRootPath, "src", "practices");
716
+ const practiceDir = _path2.default.join(_chunk4EET56IEjs.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 _chunk76VBQWGEjs.Sonamu.syncer.createEntity({ entityId });
759
+ await _chunk4EET56IEjs.Sonamu.syncer.createEntity({ entityId });
768
760
  }
769
761
  async function scaffold_model(entityId) {
770
- await _chunk76VBQWGEjs.Sonamu.syncer.generateTemplate("model", {
762
+ await _chunk4EET56IEjs.Sonamu.syncer.generateTemplate("model", {
771
763
  entityId
772
764
  });
773
765
  }
774
766
  async function scaffold_model_test(entityId) {
775
- await _chunk76VBQWGEjs.Sonamu.syncer.generateTemplate("model_test", {
767
+ await _chunk4EET56IEjs.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(_chunk76VBQWGEjs.Sonamu.apiRootPath);
774
+ sonamuUI.startServers(_chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
813
+ _chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
825
+ _chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
833
+ _chunk4EET56IEjs.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
- _chunk76VBQWGEjs.Sonamu.apiRootPath,
841
+ _chunk4EET56IEjs.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
- ..._chunk76VBQWGEjs.Sonamu.config.sync.targets.map(
862
- (target) => srcEnumsPath.replace(_chunk76VBQWGEjs.Sonamu.apiRootPath, _path2.default.join(_chunk76VBQWGEjs.Sonamu.appRootPath, target)).replace("/src/application/", "/src/services/")
853
+ ..._chunk4EET56IEjs.Sonamu.config.sync.targets.map(
854
+ (target) => srcEnumsPath.replace(_chunk4EET56IEjs.Sonamu.apiRootPath, _path2.default.join(_chunk4EET56IEjs.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
- _chunk76VBQWGEjs.EntityManager.isAutoloaded = false;
877
- await _chunk76VBQWGEjs.EntityManager.autoload();
878
- const entityIds = _chunk76VBQWGEjs.EntityManager.getAllParentIds();
868
+ _chunk4EET56IEjs.EntityManager.isAutoloaded = false;
869
+ await _chunk4EET56IEjs.EntityManager.autoload();
870
+ const entityIds = _chunk4EET56IEjs.EntityManager.getAllParentIds();
879
871
  for await (const entityId of entityIds) {
880
- await _chunk76VBQWGEjs.Sonamu.syncer.generateTemplate("generated", { entityId });
872
+ await _chunk4EET56IEjs.Sonamu.syncer.generateTemplate("generated", { entityId });
881
873
  }
882
874
  }
883
875
  //# sourceMappingURL=cli.js.map