tspace-mysql 1.5.0-beta.1 → 1.5.0-beta.2

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/README.md CHANGED
@@ -7,7 +7,7 @@ tspace-mysql is an Object-Relational Mapping (ORM) tool designed to run seamless
7
7
 
8
8
  ## Features
9
9
 
10
- ```
10
+ ```js
11
11
  - Connection pooling.
12
12
  - Powerful QueryBuilder.
13
13
  - Left , Right and inner joins.
@@ -3,7 +3,7 @@
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const make_1 = __importDefault(require("./models/make"));
@@ -25,7 +25,7 @@ const commands = {
25
25
  'dump:db': db_1.default,
26
26
  'dump:table': table_1.default,
27
27
  'migrations:models': make_5.default,
28
- '--help': () => {
28
+ 'help': () => {
29
29
  console.log(`
30
30
  \x1b[31m
31
31
  tspace-mysql make:model User --m --dir=app/Models
@@ -36,12 +36,11 @@ const commands = {
36
36
  tspace-mysql generate:models --dir=app/Models --env=development --decorators
37
37
  tspace-mysql dump:db "database" --dir=app/db --v --env=development
38
38
  tspace-mysql dump:table "table" --dir=app/table --v --env=development
39
- tspace-mysql :migrations:models --dir=migrations --env=development --generate
40
- tspace-mysql :migrations:models --dir=migrations --env=development --push
39
+ tspace-mysql :migrations:models --dir=migrations --models=src/models --generate
40
+ tspace-mysql :migrations:models --dir=migrations --models=src/models --push
41
41
  \x1b[0m
42
42
  `);
43
43
  console.log(`Read more https://www.npmjs.com/package/tspace-mysql`);
44
- process.exit(0);
45
44
  }
46
45
  };
47
46
  try {
@@ -53,30 +52,34 @@ try {
53
52
  const dir = (_j = (_h = (_g = process.argv.slice(2)) === null || _g === void 0 ? void 0 : _g.find(data => {
54
53
  return data === null || data === void 0 ? void 0 : data.includes('--dir=');
55
54
  })) === null || _h === void 0 ? void 0 : _h.replace('--dir=', '/')) !== null && _j !== void 0 ? _j : null;
56
- const db = (_m = (_l = (_k = process.argv.slice(2)) === null || _k === void 0 ? void 0 : _k.find(data => {
55
+ const models = (_m = (_l = (_k = process.argv.slice(2)) === null || _k === void 0 ? void 0 : _k.find(data => {
56
+ return data === null || data === void 0 ? void 0 : data.includes('--models=');
57
+ })) === null || _l === void 0 ? void 0 : _l.replace('--models=', '/')) !== null && _m !== void 0 ? _m : null;
58
+ const db = (_q = (_p = (_o = process.argv.slice(2)) === null || _o === void 0 ? void 0 : _o.find(data => {
57
59
  return data === null || data === void 0 ? void 0 : data.includes('--db=');
58
- })) === null || _l === void 0 ? void 0 : _l.replace('--db=', '')) !== null && _m !== void 0 ? _m : null;
59
- const table = (_q = (_p = (_o = process.argv.slice(2)) === null || _o === void 0 ? void 0 : _o.find(data => {
60
+ })) === null || _p === void 0 ? void 0 : _p.replace('--db=', '')) !== null && _q !== void 0 ? _q : null;
61
+ const table = (_t = (_s = (_r = process.argv.slice(2)) === null || _r === void 0 ? void 0 : _r.find(data => {
60
62
  return data === null || data === void 0 ? void 0 : data.includes('--table=');
61
- })) === null || _p === void 0 ? void 0 : _p.replace('--table=', '')) !== null && _q !== void 0 ? _q : null;
62
- let type = ((_t = (_s = (_r = process.argv.slice(2)) === null || _r === void 0 ? void 0 : _r.find(data => {
63
+ })) === null || _s === void 0 ? void 0 : _s.replace('--table=', '')) !== null && _t !== void 0 ? _t : null;
64
+ let type = ((_w = (_v = (_u = process.argv.slice(2)) === null || _u === void 0 ? void 0 : _u.find(data => {
63
65
  return data === null || data === void 0 ? void 0 : data.includes('--type=');
64
- })) === null || _s === void 0 ? void 0 : _s.replace('--type=', '.')) !== null && _t !== void 0 ? _t : '.ts');
66
+ })) === null || _v === void 0 ? void 0 : _v.replace('--type=', '.')) !== null && _w !== void 0 ? _w : '.ts');
65
67
  type = ['.js', '.ts'].includes(type) ? type : '.ts';
66
- const file = (_u = process.argv.slice(3)[0]) !== null && _u !== void 0 ? _u : '';
67
- const env = (_x = (_w = (_v = process.argv.slice(2)) === null || _v === void 0 ? void 0 : _v.find(data => {
68
+ const file = (_x = process.argv.slice(3)[0]) !== null && _x !== void 0 ? _x : '';
69
+ const env = (_0 = (_z = (_y = process.argv.slice(2)) === null || _y === void 0 ? void 0 : _y.find(data => {
68
70
  return data === null || data === void 0 ? void 0 : data.includes('--env=');
69
- })) === null || _w === void 0 ? void 0 : _w.replace('--env=', '')) !== null && _x !== void 0 ? _x : null;
70
- const values = (_0 = (((_y = process.argv.slice(2)) === null || _y === void 0 ? void 0 : _y.includes('--values')) || ((_z = process.argv.slice(2)) === null || _z === void 0 ? void 0 : _z.includes('--v')))) !== null && _0 !== void 0 ? _0 : false;
71
- const decorator = (_3 = (((_1 = process.argv.slice(2)) === null || _1 === void 0 ? void 0 : _1.includes('--decorator')) || ((_2 = process.argv.slice(2)) === null || _2 === void 0 ? void 0 : _2.includes('--decorators')))) !== null && _3 !== void 0 ? _3 : false;
72
- const push = (_5 = (_4 = process.argv.slice(2)) === null || _4 === void 0 ? void 0 : _4.includes('--push')) !== null && _5 !== void 0 ? _5 : false;
73
- const generate = (_7 = (_6 = process.argv.slice(2)) === null || _6 === void 0 ? void 0 : _6.includes('--generate')) !== null && _7 !== void 0 ? _7 : false;
71
+ })) === null || _z === void 0 ? void 0 : _z.replace('--env=', '')) !== null && _0 !== void 0 ? _0 : null;
72
+ const values = (_3 = (((_1 = process.argv.slice(2)) === null || _1 === void 0 ? void 0 : _1.includes('--values')) || ((_2 = process.argv.slice(2)) === null || _2 === void 0 ? void 0 : _2.includes('--v')))) !== null && _3 !== void 0 ? _3 : false;
73
+ const decorator = (_6 = (((_4 = process.argv.slice(2)) === null || _4 === void 0 ? void 0 : _4.includes('--decorator')) || ((_5 = process.argv.slice(2)) === null || _5 === void 0 ? void 0 : _5.includes('--decorators')))) !== null && _6 !== void 0 ? _6 : false;
74
+ const push = (_8 = (_7 = process.argv.slice(2)) === null || _7 === void 0 ? void 0 : _7.includes('--push')) !== null && _8 !== void 0 ? _8 : false;
75
+ const generate = (_10 = (_9 = process.argv.slice(2)) === null || _9 === void 0 ? void 0 : _9.includes('--generate')) !== null && _10 !== void 0 ? _10 : false;
74
76
  if (env != null)
75
77
  process.env.NODE_ENV = env;
76
78
  const cmd = {
77
79
  name,
78
80
  file,
79
81
  dir,
82
+ models,
80
83
  migrate,
81
84
  type,
82
85
  cwd: process.cwd(),
@@ -94,20 +97,5 @@ try {
94
97
  commands[process.argv[2]](cmd);
95
98
  }
96
99
  catch (err) {
97
- console.log(`
98
- \x1b[31m
99
- tspace-mysql make:model User --m --dir=app/Models
100
- tspace-mysql make:migration users --dir=app/Models/Migrations
101
- tspace-mysql migrate --dir=App/Models/Migrations --type=js
102
- tspace-mysql query "SELECT * FROM users" --env=development
103
- tspace-mysql generate:models --dir=app/Models --env=development
104
- tspace-mysql generate:models --dir=app/Models --env=development --decorators
105
- tspace-mysql dump:db "database" --dir=app/db --v --env=development
106
- tspace-mysql dump:table "table" --dir=app/table --v --env=development
107
- tspace-mysql :migrations:models --dir=migrations --env=development --generate
108
- tspace-mysql :migrations:models --dir=migrations --env=development --push
109
- \x1b[0m
110
- `);
111
- console.log(`Read more https://www.npmjs.com/package/tspace-mysql`);
112
- process.exit(0);
100
+ console.log(err);
113
101
  }
@@ -39,7 +39,9 @@ const lib_1 = require("../../lib");
39
39
  const sql_formatter_1 = require("sql-formatter");
40
40
  const path_1 = __importDefault(require("path"));
41
41
  exports.default = (cmd) => {
42
- const { dir, cwd, fs, generate, push, env } = cmd;
42
+ const { dir, cwd, fs, generate, push, models, env } = cmd;
43
+ if (models == null)
44
+ throw new Error("Cannot find directory to your models please specify the directory : '--models=src/app/models'");
43
45
  if (dir == null)
44
46
  throw new Error("Cannot find directory please specify the directory : '--dir=${directory}'");
45
47
  try {
@@ -130,6 +132,12 @@ exports.default = (cmd) => {
130
132
  return sql;
131
133
  }
132
134
  };
135
+ console.log({
136
+ push,
137
+ generate,
138
+ models,
139
+ dir
140
+ });
133
141
  if (push) {
134
142
  const filePath = `${dir}/migrations.sql`;
135
143
  const sqlString = fs.readFileSync(filePath, 'utf8');
@@ -155,7 +163,7 @@ exports.default = (cmd) => {
155
163
  return;
156
164
  }
157
165
  if (generate) {
158
- migrations(dir)
166
+ migrations(`${cwd}/${models}`)
159
167
  .then(_ => console.log(`Migrations are migrating successfully`))
160
168
  .catch(e => console.log(`Failed to migrate errors: '${e.message}'`))
161
169
  .finally(() => process.exit(0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tspace-mysql",
3
- "version": "1.5.0-beta.1",
3
+ "version": "1.5.0-beta.2",
4
4
  "description": "mysql query builder object relational mapping",
5
5
  "main": "build/lib/index.js",
6
6
  "types": "build/lib/index.d.ts",