tspace-mysql 1.0.6 → 1.0.7

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 (45) hide show
  1. package/README.md +315 -200
  2. package/dist/cli/index.js +9 -3
  3. package/dist/cli/migrate/make.d.ts +1 -1
  4. package/dist/cli/migrate/make.js +2 -2
  5. package/dist/cli/models/make.d.ts +1 -1
  6. package/dist/cli/models/make.js +2 -2
  7. package/dist/cli/models/model.js +1 -1
  8. package/dist/cli/tables/make.d.ts +1 -1
  9. package/dist/cli/tables/make.js +2 -2
  10. package/dist/cli/tables/table.js +1 -1
  11. package/dist/lib/config/env.js +7 -11
  12. package/dist/lib/connection/index.d.ts +27 -0
  13. package/dist/lib/connection/index.js +79 -0
  14. package/dist/lib/constants/index.d.ts +3 -3
  15. package/dist/lib/constants/index.js +89 -8
  16. package/dist/lib/tspace/AbstractDB.d.ts +1 -1
  17. package/dist/lib/tspace/AbstractDB.js +2 -0
  18. package/dist/lib/tspace/AbstractDatabase.d.ts +20 -16
  19. package/dist/lib/tspace/AbstractDatabase.js +9 -19
  20. package/dist/lib/tspace/AbstractModel.d.ts +5 -4
  21. package/dist/lib/tspace/AbstractModel.js +2 -0
  22. package/dist/lib/tspace/Blueprint.d.ts +65 -0
  23. package/dist/lib/tspace/Blueprint.js +195 -0
  24. package/dist/lib/tspace/DB.d.ts +15 -10
  25. package/dist/lib/tspace/DB.js +41 -106
  26. package/dist/lib/tspace/Database.d.ts +568 -100
  27. package/dist/lib/tspace/Database.js +1629 -394
  28. package/dist/lib/tspace/Interface.d.ts +63 -9
  29. package/dist/lib/tspace/Logger.d.ts +8 -1
  30. package/dist/lib/tspace/Logger.js +46 -30
  31. package/dist/lib/tspace/Model.d.ts +392 -119
  32. package/dist/lib/tspace/Model.js +1349 -743
  33. package/dist/lib/tspace/ProxyHandler.d.ts +5 -4
  34. package/dist/lib/tspace/ProxyHandler.js +15 -11
  35. package/dist/lib/tspace/Schema.d.ts +4 -41
  36. package/dist/lib/tspace/Schema.js +12 -137
  37. package/dist/lib/tspace/index.d.ts +2 -1
  38. package/dist/lib/tspace/index.js +6 -5
  39. package/dist/lib/utils/index.d.ts +1 -3
  40. package/dist/lib/utils/index.js +4 -85
  41. package/package.json +4 -7
  42. package/dist/lib/connections/index.d.ts +0 -2
  43. package/dist/lib/connections/index.js +0 -42
  44. package/dist/lib/connections/options.d.ts +0 -4
  45. package/dist/lib/connections/options.js +0 -32
package/README.md CHANGED
@@ -1,9 +1,10 @@
1
- # tspace-mysql
1
+ ## tspace-mysql
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/tspace-mysql.svg)](https://www.npmjs.com)
4
4
  [![NPM downloads](https://img.shields.io/npm/dm/tspace-mysql.svg)](https://www.npmjs.com)
5
5
 
6
- Query builder object relation mapping
6
+ TspaceMySQL is an ORM that can run in NodeJs and can be used with TypeScript.
7
+ Its goal is to always support the latest TypeScript and JavaScript features and provide additional features that help you to develop.
7
8
 
8
9
  ## Install
9
10
 
@@ -13,8 +14,18 @@ Install with [npm](https://www.npmjs.com/):
13
14
  npm install tspace-mysql --save
14
15
 
15
16
  ```
16
- ## Setup
17
- .env
17
+ ## Basic Usage
18
+ - [Configuration](#configuration)
19
+ - [Running Queries](#running-queryies)
20
+ - [Database Transactions](#database-transactions)
21
+ - [Accessing Connections](#accessing-connections)
22
+ - [Query Logging](#query-logging)
23
+ - [Generating Model Classes](#generating-model-classes)
24
+ - [Model Conventions](#model-conventions)
25
+ - [Relationships](#relationships)
26
+
27
+ ## Configuration
28
+ Created your environment variables is to use a .env file, you may establish a connection is this:
18
29
  ```js
19
30
  DB_HOST = localhost
20
31
  DB_PORT = 3306
@@ -22,180 +33,276 @@ DB_USERNAME = root
22
33
  DB_PASSWORD = password
23
34
  DB_DATABASE = database
24
35
  ```
25
- ## Getting Started
26
- queries data
36
+ ## Running Queries
37
+ Once you have configured your database connection, you may run queries is this :
27
38
  ```js
39
+ +-------------+--------------+----------------------------+
40
+ | table users |
41
+ +-------------+--------------+----------------------------+
42
+ | id | username | email |
43
+ |-------------|--------------|----------------------------|
44
+ | 1 | tspace | tspace@gmail.com |
45
+ | 2 | tspace2 | tspace2@gmail.com |
46
+ +-------------+--------------+----------------------------+
47
+
28
48
  import { DB } from 'tspace-mysql'
29
49
  (async () => {
30
- await new DB().raw('SELECT * FROM users')
31
- await new DB().table('users').findMany()
32
- await new DB().table('users').select('id').where('id',1).findOne()
33
- await new DB().table('users').select('id').whereIn('id',[1,2,3]).findMany()
50
+ await new DB('users').findMany() // SELECT * FROM users => Array
51
+ await new DB('users').findOne() // SELECT * FROM users LIMIT 1 => Object
34
52
  })()
35
53
  ```
36
- create data
37
-
54
+ Running A Select Query
38
55
  ```js
39
- import { DB } from 'tspace-mysql'
40
- (async () => {
41
- *ex pattern 1
42
- const user = await new DB().table('users').create({
43
- name : 'tspace',
44
- email : 'tspace@gmail.com'
45
- }).save()
46
-
47
- console.log(user)
48
-
49
- *ex pattern 2
50
- const u = new DB().table('users')
51
- u.name = 'tspace'
52
- u.email = 'tspace@gmail.com'
53
- await u.save()
54
- const { result : user } = u
55
- /* or const user = await u.save() */
56
- console.log(user)
57
- })()
56
+ const selectQuery = await new DB('users').select('id','username').findOne()
57
+ // selectQuery => { id : 1, username : 'tspace'}
58
+ const selectQueries = await new DB('users').select('id','username').findMany()
59
+ // selectQueries => [{ id : 1, username : 'tspace' } , { id : 2, username : 'tspace2'}]
58
60
  ```
59
-
60
- update data
61
+ Running A Where Query
61
62
  ```js
62
- import { DB } from 'tspace-mysql'
63
- (async () => {
64
- *ex pattern 1
65
- const user = await new DB().table('users').update({
66
- name : 'tspace',
67
- email : 'tspace@gmail.com'
68
- })
69
- .where('id',1)
70
- .save()
71
-
72
- console.log(user)
73
-
74
- *ex pattern 2
75
- const u = new DB().table('users').where('id',1)
76
- u.name = 'tspace'
77
- u.email = 'tspace@gmail.com'
78
- await u.save()
79
- const { result : user } = u
80
- /* or const user = await u.save() */
81
- console.log(user)
82
- })()
63
+ const user = await new DB('users').where('id',1).findOne()
64
+ // user => { id : 1 , username : 'tspace', email : 'tspace@gmail.com'}
65
+ const users = await new DB('users').where('id','!=',1).findMany()
66
+ // users => [{ id : 2 , username : 'tspace2' , email : 'tspace2@gmail.com' }]
67
+ ```
68
+ Running A Insert Query
69
+ ```js
70
+ const user = await new DB('users').create({
71
+ name : 'tspace3',
72
+ email : 'tspace3@gmail.com'
73
+ }).save()
74
+ // user => { id : 3 , username : 'tspace3', email : 'tspace3@gmail.com'}
75
+ +----------------------------------------------------------------------------------+
76
+ const reposity = new DB('users')
77
+ reposity.name = 'tspace4'
78
+ reposity.email = 'tspace4@gmail.com'
79
+ await reposity.save()
80
+ const { result } = reposity
81
+ // result => { id : 4 , username : 'tspace4', email : 'tspace4@gmail.com'}
82
+ ```
83
+ Running A Update Query
84
+ ```js
85
+ const user = await new DB('users').where('id',1)
86
+ .update({
87
+ name : 'tspace1**',
88
+ email : 'tspace1@gmail.com'
89
+ }).save()
90
+ // user => { id : 1 , username : 'tspace1**', email : 'tspace1@gmail.com'}
91
+ +----------------------------------------------------------------------------------+
92
+ const reposity = new DB('users').where('id',1)
93
+ reposity.name = 'tspace1++'
94
+ reposity.email = 'tspace1++@gmail.com'
95
+ await reposity.save()
96
+ const { result } = reposity
97
+ // result => { id : 1 , username : 'tspace1++', email : 'tspace1++@gmail.com'}
83
98
  ```
84
- delete data
99
+ Running A Delete Query
85
100
  ```js
86
- import { DB } from 'tspace-mysql'
87
- (async () => {
88
- await new User().where('id',1).delete()
89
- })()
101
+ const deleted = await new DB('users').where('id',1).delete()
102
+ // deleted => true
90
103
  ```
91
-
92
- ## Transactions & Rollback
104
+ ## Database Transactions
105
+ Within a database transaction, you may use the:
93
106
  ```js
94
- import { DB } from 'tspace-mysql'
95
- (async () => {
96
- const transaction = await new DB().beginTransaction()
97
- try {
98
- const user = await new User().create({
99
- name : 'tspace',
100
- email : 'tspace@gmail.com'
101
- })
102
- .save(transaction)
103
-
104
- const posts = await new Post().createMultiple([
105
- {
106
- user_id : user.id,
107
- title : 'tspace post'
108
- },
109
- {
110
- user_id : user.id,
111
- title : 'tspace post second'
112
- }
113
- ])
114
- .save(transaction)
115
-
116
- throw new Error('try to transaction')
117
-
118
- } catch (err) {
119
- const rollback = await transaction.rollback()
120
- console.log(rollback ,'rollback !')
121
- }
122
- })()
107
+ const transaction = await new DB().beginTransaction()
108
+ try {
109
+ const user = await new DB('users').create({
110
+ name : 'tspace5',
111
+ email : 'tspace5@gmail.com'
112
+ })
113
+ .save(transaction)
114
+ // user => { id : 5 , username : 'tspace5', email : 'tspace5@gmail.com'}
115
+
116
+ const userSecond = await new DB('users').create({
117
+ name : 'tspace6',
118
+ email : 'tspace6@gmail.com'
119
+ })
120
+ .save(transaction)
121
+ // userSecond => { id : 6 , username : 'tspace6', email : 'tspace6@gmail.com'}
122
+
123
+ throw new Error('try to using transaction')
124
+
125
+ } catch (err) {
126
+ const rollback = await transaction.rollback()
127
+ // rollback => true
128
+ // * rollback data user, userSecond in your database
129
+ }
130
+ ```
131
+ ## Generating Model Classes
132
+ To get started, let's install npm install tspace-mysql -g
133
+ you may use the make:model command to generate a new model:
134
+
135
+ ```sh
136
+ npm install tspace-mysql -g
137
+ tspace-mysql make:model <model name> --dir=<directory>
138
+
139
+ # tspace-mysql make:model User --dir=App/Models
140
+ # => App/Models/User.ts
123
141
  ```
124
-
125
142
  ## Model Conventions
126
- basic model class and discuss some relations:
143
+ Models generated by the make:model command will be placed in the specific directory.
144
+ Let's examine a basic model class:
127
145
 
128
146
  ```js
129
147
  import { Model } from 'tspace-mysql'
130
- import Post from '../Post'
131
- import Comment from '../Comment'
132
- import User from '../User'
133
-
134
- /**
135
- Folder directory example
136
- - App
137
- - Model
138
- Post.ts
139
- User.ts
140
- Comment.ts
141
- */
142
-
143
- (async () => {
144
- const users = await new User()
145
- .with('posts','comments') /* relations -> hasMany: posts & comments */
146
- .withQuery('posts', (query) => query.with('user')) /* relation -> belongsTo: post by user */
147
- .withQuery('comments', (query) => query.with('user','post')) /* relation -> belongsTo: comment by user? & comment in post*/
148
- .findMany()
149
-
150
- console.log(users)
151
- })()
148
+ class User extends Model {
149
+ constructor(){
150
+ super()
151
+ this.useTimestamp()
152
+ /*
153
+ * the "snake case", plural name of the class will be used as the table name
154
+ *
155
+ * @param {string} name The table associated with the model.
156
+ */
157
+ this.useTable('users')
158
+ }
159
+ }
160
+ export { User }
161
+ export default User
162
+ ```
163
+ ## Relationships
164
+ Relationships are defined as methods on your Model classes
165
+ Let's examine a basic relations :
152
166
 
153
- /**
154
- *
155
- * User.ts
156
- */
167
+ ## One To One
168
+ A one-to-one relationship is used to define relationships where a single model is the parent to one child models
169
+ ```js
157
170
  import { Model } from 'tspace-mysql'
171
+ import Phone from '../Phone'
158
172
  class User extends Model {
159
173
  constructor(){
160
174
  super()
161
- this.hasMany({name : 'posts', model: Post })
162
- this.hasMany({name : 'comments', model: Comment })
175
+ this.useTimestamp()
176
+ /**
177
+ *
178
+ * @hasOne Get the phone associated with the user.
179
+ * @relationship users.id -> phones.user_id
180
+ */
181
+ this.hasOne({ name : 'phone' , model : Phone })
182
+ }
183
+ /**
184
+ * @hasOneQuery Get the phone associated with the user. using function callback
185
+ * @function
186
+ */
187
+ phone (callback ?: Function) {
188
+ return this.hasOneQuery({ model : Phone }, (query) => {
189
+ return callback ? callback(query) : query
190
+ })
163
191
  }
164
- }
192
+ }
165
193
  export default User
166
- /**
167
- *
168
- * Post.ts
169
- */
170
- import { Model } from 'tspace-mysql'
194
+ +----------------------------------------------------------------------------------+
195
+ import User from '../User'
196
+ const user = await new User().with('brand').findOne()
197
+ // user?.phone => {...}
198
+ const userUsingFunction = await new User().phone().findOne()
199
+ // userUsingFunction?.phone => {...}
200
+ ```
171
201
 
202
+ ## One To Many
203
+ A one-to-many relationship is used to define relationships where a single model is the parent to one or more child models.
204
+ ```js
205
+ import { Model } from 'tspace-mysql'
206
+ import Comment from '../Comment'
172
207
  class Post extends Model {
173
208
  constructor(){
174
209
  super()
175
- this.belongsTo({name : 'user', model: User })
210
+ this.useTimestamp()
211
+ /**
212
+ *
213
+ * @hasMany Get the comments for the post.
214
+ * @relationship posts.id -> comments.post_id
215
+ */
176
216
  this.hasMany({ name : 'comments' , model : Comment })
177
217
  }
178
- }
218
+ /**
219
+ * @hasManyQuery Get the comments for the post. using function callback
220
+ * @function
221
+ */
222
+ comments (callback ?: Function) {
223
+ return this.hasManyQuery({ model : Comment }, (query) => {
224
+ return callback ? callback(query) : query
225
+ })
226
+ }
227
+ }
179
228
  export default Post
229
+ +----------------------------------------------------------------------------------+
230
+ import Post from '../Post'
231
+ const posts = await new Post().with('comments').findOne()
232
+ // posts?.comments => [{...}]
233
+ const postsUsingFunction = await new Post().comments().findOne()
234
+ // postsUsingFunction?.comments => [{...}]
235
+ ```
180
236
 
181
- /**
182
- *
183
- * Comment.ts
184
- */
185
-
237
+ ## One To One & One To Many (Inverse) / Belongs To
238
+ ```js
186
239
  import { Model } from 'tspace-mysql'
187
-
188
- class Comment extends Model {
240
+ import User from '../User'
241
+ class Phone extends Model {
189
242
  constructor(){
190
243
  super()
191
- this.belongsTo({name : 'user', model: User })
192
- this.belongsTo({name : 'post', model: Post })
244
+ this.useTimestamp()
245
+ /**
246
+ *
247
+ * @belongsTo Get the user that owns the phone.
248
+ * @relationship phones.user_id -> users.id
249
+ */
250
+ this.belognsTo({ name : 'user' , model : User })
193
251
  }
194
- }
195
- export default Comment
252
+ /**
253
+ * @belongsToQuery Get the user that owns the phone.. using function callback
254
+ * @function
255
+ */
256
+ user (callback ?: Function) {
257
+ return this.belongsToQuery({ model : User }, (query) => {
258
+ return callback ? callback(query) : query
259
+ })
260
+ }
261
+ }
262
+ export default Phone
263
+ +----------------------------------------------------------------------------------+
264
+ import Phone from '../Phone'
265
+ const phone = await new Phone().with('user').findOne()
266
+ // phone?.user => {...}
267
+ const phoneUsingFunction = await new Phone().user().findOne()
268
+ // phoneUsingFunction?.user => {...}
196
269
  ```
197
270
 
198
- ## Method chaining
271
+ ## Many To Many
272
+ Many-to-many relations are slightly more complicated than hasOne and hasMany relationships.
273
+ ```js
274
+ import { Model } from 'tspace-mysql'
275
+ import Role from '../Role'
276
+ class User extends Model {
277
+ constructor(){
278
+ super()
279
+ this.useTimestamp()
280
+ /**
281
+ *
282
+ * @belongsToMany Get The roles that belong to the user.
283
+ * @relationship users.id , roles.id => role_user.user_id , role_user.role_id
284
+ */
285
+ this.belognsToMany({ name : 'roles' , model : Role })
286
+ }
287
+ /**
288
+ * @belongsToQuery Get the user that owns the phone.. using function callback
289
+ * @function
290
+ */
291
+ roles (callback ?: Function) {
292
+ return this.belongsToManyQuery({ model : Role }, (query) => {
293
+ return callback ? callback(query) : query
294
+ })
295
+ }
296
+ }
297
+ export default User
298
+ +----------------------------------------------------------------------------------+
299
+ import User from '../User'
300
+ const user = await new User().with('roles').findOne()
301
+ // user?.roles => [{...}]
302
+ const userUsingFunction = await new User().roles().findOne()
303
+ // user?.roles => [{...}]
304
+ ```
305
+ ## Query Builder Chaining
199
306
  method chaining for queries
200
307
  ```js
201
308
  where(column , operator , value)
@@ -230,25 +337,35 @@ createMultiple(array objects)
230
337
  update (objects)
231
338
  createNotExists(objects)
232
339
  updateOrCreate (objects)
340
+
233
341
  /**
234
- * relationship
235
- *
236
- * @Relation setup name in model
342
+ * registry relation in your models
343
+ * @relationship
344
+ */
345
+ hasOne({ name , model , localKey , foreignKey , freezeTable , as }
346
+ hasMany({ name , model , localKey , foreignKey , freezeTable , as }
347
+ belongsTo({ name , model , localKey , foreignKey , freezeTable , as }
348
+ belongsToMany({ name , model , localKey , foreignKey , freezeTable , as }
349
+ /**
350
+ * @relation using registry in your models
237
351
  */
238
352
  with(name1 , name2,...nameN)
353
+ /**
354
+ * @relation using registry in your models. if exists child data remove this parent data
355
+ */
239
356
  withExists(name1 , name2,...nameN)
240
- withQuery('relation registry',(callback queries))
357
+ /**
358
+ * @relation call a relation in registry, callback query of parent data
359
+ */
360
+ withQuery('relation registry',(callback query))
241
361
 
242
362
  /**
243
363
  * queries statements
244
- *
245
- * @exec statements
364
+ * @exec statements
246
365
  */
247
366
  findMany()
248
367
  findOne()
249
368
  find(id)
250
- first()
251
- get()
252
369
  delelte()
253
370
  exists ()
254
371
  onlyTrashed()
@@ -266,61 +383,64 @@ save() /*for action statements insert update or delete */
266
383
  ```
267
384
 
268
385
  ## Cli
269
- npm install tspace-mysql -g
270
- ```js
271
-
272
- tspace-mysql make:model <MODEL NAME> --m --dir=... --js
273
- * optional
274
- --m /* created table for migrate */
275
- --dir=directory /* created model in directory */
276
- --type=js /* extension js default ts */
277
-
278
- tspace-mysql make:migration <TABLE NAME>
279
- * optional
280
- --type=js /* extension js default ts */
281
- --dir=directory /* created table in directory */
282
-
283
- tspace-mysql migrate <FOLDER> --js
284
- * optional
285
- --type=js /* extension js default ts */
286
- --dir=directory /* find migrate in directory */
287
- ```
386
+ To get started, let's install npm install tspace-mysql -g
387
+ you may use a basic cli :
288
388
 
289
- tspace-mysql make:model User --m --dir=App/Models
290
- ```js
291
- /* Ex folder
389
+ ## Make Model
390
+ Command will be placed Model in the specific directory
391
+ ```sh
392
+ tspace-mysql make:model <MODEL NAME> --m --dir=.... --type=....
393
+ /**
394
+ * @options
395
+ * --m // created scheme table for migrate
396
+ * --dir=directory // created model in directory
397
+ * --type=js // extension js default ts
398
+ */
399
+
400
+ tspace-mysql make:model User --m --dir=app/Models
401
+ // =>
292
402
  - node_modules
293
- - App
403
+ - app
294
404
  - Models
295
405
  User.ts
296
406
  */
297
-
298
- /* in App/Models/User.ts */
299
- import { Model } from 'tspace-mysql'
300
- class User extends Model{
301
- constructor(){
302
- super()
303
- this.useDebug() /* default false *debug sql */
304
- this.useTimestamp() /* default false * case created_at & updated_at*/
305
- this.useSoftDelete() /* default false * case where deleted_at is null */
306
- this.useTable('users') /* default users */
307
- this.usePattern('camelCase') /* default snake_case */
308
- this.useUUID()
309
- }
310
- }
311
- export default User
312
407
  ```
313
- tspace-mysql make:migration users --dir=App/Models/Migrations
314
- ```js
315
- /* Ex folder
408
+
409
+ ## Make Migration
410
+ Command will be placed Migration in the specific directory
411
+ ```sh
412
+ tspace-mysql make:migration <TABLE NAME>
413
+ /**
414
+ * @options
415
+ * --type=js /* extension js default ts */
416
+ * --dir=directory /* created table in directory */
417
+ */
418
+ tspace-mysql make:migration users --dir=app/Models/Migrations
419
+ // =>
316
420
  - node_modules
317
- - App
421
+ - app
318
422
  - Models
319
- - migrations
423
+ - Migrations
320
424
  create_users_table.ts
321
425
  User.ts
322
426
  */
323
- /* in App/Models/Migrations/create_users_table.ts */
427
+ ```
428
+ ## Migrate
429
+ ```sh
430
+ tspace-mysql migrate <FOLDER> --type=...
431
+ /**
432
+ * @options
433
+ *--type=js /* extension js default ts */
434
+ *--dir=directory /* find migrate in directory */
435
+ */
436
+
437
+ tspace-mysql migrate --dir=App/Models/Migrations
438
+ // => migrate all schema table in folder into database
439
+ ```
440
+
441
+ ## Blueprint method
442
+ Schema table created by command make:migration, you may use the:
443
+ ```js
324
444
  import { Schema , Blueprint , DB } from 'tspace-mysql'
325
445
  (async () => {
326
446
  await new Schema().table('users',{
@@ -333,16 +453,11 @@ import { Schema , Blueprint , DB } from 'tspace-mysql'
333
453
  updated_at : new Blueprint().null().timestamp()
334
454
  })
335
455
  /**
336
- *
337
- * @Faker data
456
+ *
457
+ * @Faker fake data 5 raw
338
458
  * await new DB().table('users').faker(5)
339
459
  */
340
460
  })()
341
- ```
342
- tspace-mysql migrate --dir=App/Models/Migrations
343
- /* migrate all table in folder into database */
344
- ```js
345
- * Blueprint method
346
461
  /**
347
462
  *
348
463
  * @Types
@@ -376,4 +491,4 @@ primary()
376
491
  default (string)
377
492
  defaultTimestamp ()
378
493
  autoIncrement ()
379
- ```
494
+ ```
package/dist/cli/index.js CHANGED
@@ -16,10 +16,16 @@ var commands = {
16
16
  'migrate': make_3.default
17
17
  };
18
18
  try {
19
- var name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(function (data) { return data === null || data === void 0 ? void 0 : data.includes('--name='); })) === null || _b === void 0 ? void 0 : _b.replace('--name=', '')) !== null && _c !== void 0 ? _c : null;
19
+ var name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(function (data) {
20
+ return data === null || data === void 0 ? void 0 : data.includes('--name=');
21
+ })) === null || _b === void 0 ? void 0 : _b.replace('--name=', '')) !== null && _c !== void 0 ? _c : null;
20
22
  var migrate = (_e = (_d = process.argv.slice(2)) === null || _d === void 0 ? void 0 : _d.includes('--m')) !== null && _e !== void 0 ? _e : false;
21
- var dir = (_h = (_g = (_f = process.argv.slice(2)) === null || _f === void 0 ? void 0 : _f.find(function (data) { return data === null || data === void 0 ? void 0 : data.includes('--dir='); })) === null || _g === void 0 ? void 0 : _g.replace('--dir=', '/')) !== null && _h !== void 0 ? _h : null;
22
- var type = (_l = (_k = (_j = process.argv.slice(2)) === null || _j === void 0 ? void 0 : _j.find(function (data) { return data === null || data === void 0 ? void 0 : data.includes('--type='); })) === null || _k === void 0 ? void 0 : _k.replace('--type=', '.')) !== null && _l !== void 0 ? _l : '.ts';
23
+ var dir = (_h = (_g = (_f = process.argv.slice(2)) === null || _f === void 0 ? void 0 : _f.find(function (data) {
24
+ return data === null || data === void 0 ? void 0 : data.includes('--dir=');
25
+ })) === null || _g === void 0 ? void 0 : _g.replace('--dir=', '/')) !== null && _h !== void 0 ? _h : null;
26
+ var type = (_l = (_k = (_j = process.argv.slice(2)) === null || _j === void 0 ? void 0 : _j.find(function (data) {
27
+ return data === null || data === void 0 ? void 0 : data.includes('--type=');
28
+ })) === null || _k === void 0 ? void 0 : _k.replace('--type=', '.')) !== null && _l !== void 0 ? _l : '.ts';
23
29
  type = ['.js', '.ts'].includes(type) ? type : '.ts';
24
30
  var file = (_o = (_m = process.argv.slice(3)) === null || _m === void 0 ? void 0 : _m.shift()) !== null && _o !== void 0 ? _o : '';
25
31
  var cmd = {
@@ -1,4 +1,4 @@
1
- declare const _default: (_ref: {
1
+ declare const _default: (formCommand: {
2
2
  [x: string]: any;
3
3
  }) => void;
4
4
  export default _default;
@@ -12,10 +12,10 @@ var __values = (this && this.__values) || function(o) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  var child_process_1 = require("child_process");
15
- exports.default = (function (_ref) {
15
+ exports.default = (function (formCommand) {
16
16
  var e_1, _a;
17
17
  var _b, _c, _d;
18
- var type = _ref.type, dir = _ref.dir, cwd = _ref.cwd, fs = _ref.fs;
18
+ var type = formCommand.type, dir = formCommand.dir, cwd = formCommand.cwd, fs = formCommand.fs;
19
19
  try {
20
20
  if (dir == null)
21
21
  throw new Error('Not found directory');
@@ -1,4 +1,4 @@
1
- declare const _default: (_ref: {
1
+ declare const _default: (formCommand: {
2
2
  [x: string]: any;
3
3
  }) => void;
4
4
  export default _default;