@anthonylzq/simba.js 5.1.1 → 6.1.0

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,6 +7,8 @@
7
7
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/AnthonyLzq/simba.js/blob/master/LICENSE)
8
8
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
9
9
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactjs.org/docs/how-to-contribute.html#your-first-pull-request)
10
+ [![Lint](https://github.com/AnthonyLzq/simba.js/actions/workflows/lint.yml/badge.svg)](https://github.com/AnthonyLzq/simba.js/actions/workflows/lint.yml)
11
+ [![Tests for Simba APIs](https://github.com/AnthonyLzq/simba.js/actions/workflows/test.yml/badge.svg)](https://github.com/AnthonyLzq/simba.js/actions/workflows/test.yml)
10
12
 
11
13
  Set up a modern backend app by running one command. This project has the goal to create a complete setup for a backend application using `TypeScript` and `Express` or `Fastify`. It will create many files that are usually created manually. Think about Simba.js like a [CRA](https://create-react-app.dev/), but for backend development. Check the [**project structure**](#project-structure) for more information.
12
14
 
@@ -37,8 +39,10 @@ By doing this your prompt will ask you the following questions:
37
39
  - `Project version (0.1.0):` the initial version of the project, `0.1.0` as default.
38
40
  - `Select your license [1...7]:`, the license you have chosen for the project.
39
41
  - `License year (current year):`, the year where your license starts, current year as default.
40
- - `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
42
+ - `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
41
43
  - `Will this project be deployed with Heroku? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
44
+ - `Would you want to have a basic suit of tests with Jest? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
45
+ - `Would you want to have a basic GitHub Action for the suit of tests? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
42
46
 
43
47
  The second option you have is by passing flags in one single command. If you need help, please run:
44
48
 
@@ -53,33 +57,40 @@ This will generate the following output:
53
57
  to be asked for the options one by one
54
58
 
55
59
  Options:
56
- -N, --projectName Project name
57
- -D, --projectDescription Project description
58
- -a, --author Author of the project
59
- -e, --email Email of the author
60
- -H, --heroku Whether or not the project will be deployed using
61
- Heroku [boolean] [default: false]
62
- -l, --license Type of license for the project, it can be one of:
63
- MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0 and AGPL
64
- 3.0, in lowercase without its version
60
+ -N, --projectName Project name
61
+ -D, --projectDescription Project description
62
+ -a, --author Author of the project
63
+ -e, --email Email of the author
64
+ -H, --heroku Whether or not the project will be deployed
65
+ using Heroku [boolean] [default: false]
66
+ -l, --license Type of license for the project, it can be one
67
+ of: MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0
68
+ and AGPL 3.0, in lowercase without its version
65
69
  [default: "unlicensed"]
66
- -v, --version Project initial version [default: "0.1.0"]
67
- -y, --licenseYear Year when the license starts [default: "2022"]
68
- -n, --npm Whether or not the project should use npm as package
69
- manager [boolean] [default: false]
70
- -f, --mainFile Main file of the project [default: "src/index.ts"]
71
- -q, --questions Whether or not you want to be asked to answer the
72
- questions related to the project one by one
70
+ -v, --version Project initial version [default: "0.1.0"]
71
+ -y, --licenseYear Year when the license starts [default: "2022"]
72
+ -n, --npm Whether or not the project should use npm as
73
+ package manager [boolean] [default: false]
74
+ -f, --mainFile Main file of the project
75
+ [default: "src/index.ts"]
76
+ -q, --questions Whether or not you want to be asked to answer
77
+ the questions related to the project one by one
73
78
  [boolean] [default: false]
74
- -F, --fastify Whether or not you want to use Fastify for your
75
- project [boolean] [default: false]
76
- -g, --graphql Whether or not you want to use GraphQL for your
77
- project [boolean] [default: false]
78
- -h, --help Show help [boolean]
79
+ -F, --fastify Whether or not you want to use Fastify for your
80
+ project [boolean] [default: false]
81
+ -g, --graphql Whether or not you want to use GraphQL for your
82
+ project [boolean] [default: false]
83
+ -t, --tests Whether or not you want to have a basic suit of
84
+ unit tests with Jest [boolean] [default: false]
85
+ --ghat, --gh-action-tests Whether or not you want to have a GitHub Action
86
+ with a CI for your tests. If this option is set
87
+ to true, the tests flag must be set to true.
88
+ [default: false]
89
+ -h, --help Show help [boolean]
79
90
 
80
91
  Examples:
81
92
  simba -N 'Project Name' -D 'Project description' -a Anthony -e
82
- sluzquinosa@uni.pe
93
+ sluzquinosa@uni.pe -l mit -F --tests --ghat
83
94
 
84
95
  Developed by AnthonyLzq
85
96
  ```
@@ -129,51 +140,59 @@ Regardless of the option chosen, a new folder will be generated with the name of
129
140
  ### Express case
130
141
 
131
142
  ```
143
+ 📂.github
144
+ ┣ 📂workflows
145
+ ┃ ┣ 📜test.yml
132
146
  📂node_modules
133
147
  📂src
134
- ┣ 📂@types
135
- ┃ ┣ 📂custom
136
- ┃ ┃ ┣ 📜request.d.ts
137
- ┃ ┃ ┗ 📜response.d.ts
138
- ┃ ┣ 📂models
139
- ┃ ┃ ┗ 📜user.d.ts
140
- ┃ ┗ 📜index.d.ts
141
- ┣ 📂database
142
- ┃ ┣ 📂mongo
143
- ┃ ┃ ┣ 📂models
144
- ┃ ┃ ┃ ┣ 📜index.ts
145
- ┃ ┃ ┃ ┗ 📜user.ts
146
- ┃ ┃ ┣ 📂queries
147
- ┃ ┃ ┃ ┣ 📜index.ts
148
- ┃ ┃ ┃ ┗ 📜user.ts
149
- ┃ ┃ 📜index.ts
150
- ┃ ┗ 📜index.ts
151
- 📂network
152
- ┣ 📂routes
153
- ┣ 📂utils
154
- ┃ ┃ ┗ 📜index.ts
155
- ┃ ┃ 📜home.ts
156
- ┃ ┃ ┣ 📜index.ts
157
- ┃ ┃ 📜user.ts
158
- 📜index.ts
159
- ┃ ┣ 📜response.ts
160
- ┃ ┣ 📜routes.ts
161
- 📜server.ts
162
- 📂schemas
163
- 📜index.ts
164
- 📜user.ts
165
- 📂services
166
- ┣ 📂utils
167
- ┣ 📂messages
168
- ┃ ┃ 📜index.ts
169
- ┃ ┃ ┃ 📜user.ts
170
- ┃ ┃ ┗ 📜index.ts
171
- 📜index.ts
172
- 📜user.ts
173
- 📂utils
174
- 📜docs.json
175
- 📜index.ts
176
- ┗ 📜index.ts
148
+ ┣ 📂@types
149
+ ┃ ┣ 📂custom
150
+ ┃ ┃ ┣ 📜request.d.ts
151
+ ┃ ┃ ┗ 📜response.d.ts
152
+ ┃ ┣ 📂models
153
+ ┃ ┃ ┗ 📜user.d.ts
154
+ ┃ ┗ 📜index.d.ts
155
+ ┣ 📂database
156
+ ┃ ┣ 📂mongo
157
+ ┃ ┃ ┣ 📂models
158
+ ┃ ┃ ┃ ┣ 📜index.ts
159
+ ┃ ┃ ┃ ┗ 📜user.ts
160
+ ┃ ┃ ┣ 📂queries
161
+ ┃ ┃ ┃ ┣ 📜index.ts
162
+ ┃ ┃ ┃ ┗ 📜user.ts
163
+ ┃ ┃ 📜connection.ts
164
+ ┃ ┗ 📜index.ts
165
+ 📜index.ts
166
+ ┣ 📂network
167
+ ┃ ┣ 📂routes
168
+ ┃ ┃ 📂utils
169
+ ┃ ┃ 📜index.ts
170
+ ┃ ┃ ┣ 📜home.ts
171
+ ┃ ┃ 📜index.ts
172
+ 📜user.ts
173
+ ┃ ┣ 📜index.ts
174
+ ┃ ┣ 📜response.ts
175
+ 📜routes.ts
176
+ 📜server.ts
177
+ 📂schemas
178
+ 📜index.ts
179
+ 📜user.ts
180
+ ┣ 📂services
181
+ ┃ ┣ 📂utils
182
+ ┃ ┃ ┣ 📂messages
183
+ ┃ ┃ ┃ 📜index.ts
184
+ ┃ ┃ ┗ 📜user.ts
185
+ 📜index.ts
186
+ 📜index.ts
187
+ 📜user.ts
188
+ 📂utils
189
+ 📜docs.json
190
+ ┗ 📜index.ts
191
+ ┣ 📜index.ts
192
+ 📂test
193
+ ┣ 📜index.test.ts
194
+ ┣ 📜jestGlobalSetup.ts
195
+ ┗ 📜setEnvVars.ts
177
196
  📜.env
178
197
  📜.eslintignore
179
198
  📜.eslintrc
@@ -196,61 +215,69 @@ Regardless of the option chosen, a new folder will be generated with the name of
196
215
  ### Express-GraphQL case
197
216
 
198
217
  ```
218
+ 📂.github
219
+ ┣ 📂workflows
220
+ ┃ ┣ 📜test.yml
199
221
  📂node_modules
200
222
  📂src
201
- ┣ 📂@types
202
- ┃ ┣ 📂custom
203
- ┃ ┃ ┣ 📜request.d.ts
204
- ┃ ┃ ┗ 📜response.d.ts
205
- ┃ ┣ 📂graphQL
206
- ┃ ┃ ┗ 📜context.d.ts
207
- ┃ ┣ 📂models
208
- ┃ ┃ ┗ 📜user.d.ts
209
- ┃ ┗ 📜index.d.ts
210
- ┣ 📂database
211
- ┃ ┣ 📂mongo
212
- ┃ ┃ ┣ 📂models
213
- ┃ ┃ ┃ ┣ 📜index.ts
214
- ┃ ┃ ┃ ┗ 📜user.ts
215
- ┃ ┃ ┣ 📂queries
216
- ┃ ┃ ┃ ┣ 📜index.ts
217
- ┃ ┃ ┃ ┗ 📜user.ts
218
- ┃ ┃ 📜index.ts
219
- ┃ ┗ 📜index.ts
220
- 📂graphQL
221
- ┣ 📂models
222
- ┣ 📂User
223
- ┃ ┃ 📜index.ts
224
- ┃ ┃ ┃ ┣ 📜mutations.ts
225
- ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
226
- ┃ ┃ ┃ ┣ 📜queries.ts
227
- ┃ ┃ ┃ ┣ 📜queriesResolver.ts
228
- ┃ ┃ ┃ ┣ 📜schemas.ts
229
- ┃ ┃ ┃ 📜typeDefs.ts
230
- ┃ ┃ 📂utils
231
- ┃ ┃ ┣ 📂messages
232
- ┃ ┃ ┃ 📜index.ts
233
- ┃ ┃ ┃ ┃ 📜user.ts
234
- ┃ ┃ ┃ ┗ 📜index.ts
235
- ┃ ┃ ┗ 📜index.ts
236
- ┃ ┗ 📜index.ts
237
- 📂network
238
- ┣ 📂routes
239
- ┣ 📂utils
240
- ┃ ┃ ┗ 📜index.ts
241
- ┃ ┃ 📜home.ts
242
- ┃ ┃ ┣ 📜index.ts
243
- ┃ ┣ 📜index.ts
244
- ┃ ┣ 📜response.ts
245
- ┃ ┣ 📜routes.ts
246
- 📜server.ts
247
- 📂schemas
248
- 📜index.ts
249
- 📜user.ts
250
- 📂utils
251
- 📜docs.json
252
- 📜index.ts
253
- ┗ 📜index.ts
223
+ ┣ 📂@types
224
+ ┃ ┣ 📂custom
225
+ ┃ ┃ ┣ 📜request.d.ts
226
+ ┃ ┃ ┗ 📜response.d.ts
227
+ ┃ ┣ 📂graphQL
228
+ ┃ ┃ ┗ 📜context.d.ts
229
+ ┃ ┣ 📂models
230
+ ┃ ┃ ┗ 📜user.d.ts
231
+ ┃ ┗ 📜index.d.ts
232
+ ┣ 📂database
233
+ ┃ ┣ 📂mongo
234
+ ┃ ┃ ┣ 📂models
235
+ ┃ ┃ ┃ ┣ 📜index.ts
236
+ ┃ ┃ ┃ ┗ 📜user.ts
237
+ ┃ ┃ ┣ 📂queries
238
+ ┃ ┃ ┃ ┣ 📜index.ts
239
+ ┃ ┃ ┃ ┗ 📜user.ts
240
+ ┃ ┃ 📜connection.ts
241
+ ┃ ┗ 📜index.ts
242
+ 📜index.ts
243
+ ┣ 📂graphQL
244
+ ┃ ┣ 📂models
245
+ ┃ ┃ ┣ 📂User
246
+ ┃ ┃ ┃ ┣ 📜index.ts
247
+ ┃ ┃ ┃ ┣ 📜mutations.ts
248
+ ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
249
+ ┃ ┃ ┃ ┣ 📜queries.ts
250
+ ┃ ┃ ┃ ┣ 📜queriesResolver.ts
251
+ ┃ ┃ ┃ 📜schemas.ts
252
+ ┃ ┃ 📜typeDefs.ts
253
+ ┃ ┃ ┣ 📂utils
254
+ ┃ ┃ ┃ ┣ 📂messages
255
+ ┃ ┃ ┃ ┃ 📜index.ts
256
+ ┃ ┃ ┃ ┗ 📜user.ts
257
+ ┃ ┃ ┗ 📜index.ts
258
+ ┃ ┗ 📜index.ts
259
+ 📜index.ts
260
+ ┣ 📂network
261
+ ┃ ┣ 📂routes
262
+ ┃ ┃ 📂utils
263
+ ┃ ┃ 📜index.ts
264
+ ┃ ┃ ┣ 📜home.ts
265
+ ┃ ┣ 📜index.ts
266
+ ┃ ┣ 📜index.ts
267
+ ┃ ┣ 📜response.ts
268
+ 📜routes.ts
269
+ 📜server.ts
270
+ 📂schemas
271
+ 📜index.ts
272
+ 📜user.ts
273
+ 📂utils
274
+ 📜docs.json
275
+ ┗ 📜index.ts
276
+ ┣ 📜index.ts
277
+ 📂test
278
+ ┣ 📜index.test.ts
279
+ ┣ 📜jestGlobalSetup.ts
280
+ ┗ 📜setEnvVars.ts
254
281
  📜.env
255
282
  📜.eslintignore
256
283
  📜.eslintrc
@@ -273,44 +300,49 @@ Regardless of the option chosen, a new folder will be generated with the name of
273
300
  ```
274
301
  📂node_modules
275
302
  📂src
276
- ┣ 📂@types
277
- ┃ ┣ 📂models
278
- ┃ ┃ ┗ 📜user.d.ts
279
- ┃ ┗ 📜index.d.ts
280
- ┣ 📂database
281
- ┃ ┣ 📂mongo
282
- ┃ ┃ ┣ 📂models
283
- ┃ ┃ ┃ ┣ 📜index.ts
284
- ┃ ┃ ┃ ┗ 📜user.ts
285
- ┃ ┃ ┣ 📂queries
286
- ┃ ┃ ┃ ┣ 📜index.ts
287
- ┃ ┃ ┃ ┗ 📜user.ts
288
- ┃ ┃ 📜index.ts
289
- ┃ ┗ 📜index.ts
290
- 📂network
291
- ┣ 📂routes
292
- ┣ 📂utils
293
- ┃ ┃ ┗ 📜docs.ts
294
- ┃ ┃ 📜docs.ts
295
- ┃ ┃ ┣ 📜home.ts
296
- ┃ ┃ ┣ 📜index.ts
297
- ┃ ┃ 📜user.ts
298
- 📜index.ts
299
- ┃ ┣ 📜response.ts
300
- ┃ ┣ 📜routes.ts
301
- 📜server.ts
302
- 📂schemas
303
- 📜index.ts
304
- 📜user.ts
305
- 📂services
306
- ┣ 📂utils
307
- ┣ 📂messages
308
- ┃ ┃ 📜index.ts
309
- ┃ ┃ ┃ 📜user.ts
310
- ┃ ┃ ┗ 📜index.ts
311
- 📜index.ts
312
- 📜user.ts
313
- ┗ 📜index.ts
303
+ ┣ 📂@types
304
+ ┃ ┣ 📂models
305
+ ┃ ┃ ┗ 📜user.d.ts
306
+ ┃ ┗ 📜index.d.ts
307
+ ┣ 📂database
308
+ ┃ ┣ 📂mongo
309
+ ┃ ┃ ┣ 📂models
310
+ ┃ ┃ ┃ ┣ 📜index.ts
311
+ ┃ ┃ ┃ ┗ 📜user.ts
312
+ ┃ ┃ ┣ 📂queries
313
+ ┃ ┃ ┃ ┣ 📜index.ts
314
+ ┃ ┃ ┃ ┗ 📜user.ts
315
+ ┃ ┃ 📜connection.ts
316
+ ┃ ┗ 📜index.ts
317
+ 📜index.ts
318
+ ┣ 📂network
319
+ ┃ ┣ 📂routes
320
+ ┃ ┃ 📂utils
321
+ ┃ ┃ 📜docs.ts
322
+ ┃ ┃ ┣ 📜docs.ts
323
+ ┃ ┃ ┣ 📜home.ts
324
+ ┃ ┃ 📜index.ts
325
+ 📜user.ts
326
+ ┃ ┣ 📜index.ts
327
+ ┃ ┣ 📜response.ts
328
+ 📜routes.ts
329
+ 📜server.ts
330
+ 📂schemas
331
+ 📜index.ts
332
+ 📜user.ts
333
+ ┣ 📂services
334
+ ┃ ┣ 📂utils
335
+ ┃ ┃ ┣ 📂messages
336
+ ┃ ┃ ┃ 📜index.ts
337
+ ┃ ┃ ┗ 📜user.ts
338
+ 📜index.ts
339
+ 📜index.ts
340
+ ┗ 📜user.ts
341
+ ┣ 📜index.ts
342
+ 📂test
343
+ ┣ 📜index.test.ts
344
+ ┣ 📜jestGlobalSetup.ts
345
+ ┗ 📜setEnvVars.ts
314
346
  📜.env
315
347
  📜.eslintignore
316
348
  📜.eslintrc
@@ -333,56 +365,64 @@ Regardless of the option chosen, a new folder will be generated with the name of
333
365
  ### Fastify-GraphQL case
334
366
 
335
367
  ```
368
+ 📂.github
369
+ ┣ 📂workflows
370
+ ┃ ┣ 📜test.yml
336
371
  📂node_modules
337
372
  📂src
338
- ┣ 📂@types
339
- ┃ ┣ 📂graphQL
340
- ┃ ┃ ┗ 📜context.d.ts
341
- ┃ ┣ 📂dto
342
- ┃ ┃ ┗ 📜user.d.ts
343
- ┃ ┣ 📂models
344
- ┃ ┃ ┗ 📜user.d.ts
345
- ┃ ┗ 📜index.d.ts
346
- ┣ 📂database
347
- ┃ ┣ 📂mongo
348
- ┃ ┃ ┣ 📂models
349
- ┃ ┃ ┃ ┣ 📜index.ts
350
- ┃ ┃ ┃ ┗ 📜user.ts
351
- ┃ ┃ ┣ 📂queries
352
- ┃ ┃ ┃ ┣ 📜index.ts
353
- ┃ ┃ ┃ ┗ 📜user.ts
354
- ┃ ┃ 📜index.ts
355
- ┃ ┗ 📜index.ts
356
- 📂graphQL
357
- ┣ 📂models
358
- ┣ 📂User
359
- ┃ ┃ 📜index.ts
360
- ┃ ┃ ┃ ┣ 📜mutations.ts
361
- ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
362
- ┃ ┃ ┃ ┣ 📜queries.ts
363
- ┃ ┃ ┃ ┣ 📜queriesResolver.ts
364
- ┃ ┃ ┃ ┣ 📜schemas.ts
365
- ┃ ┃ ┃ 📜typeDefs.ts
366
- ┃ ┃ 📂utils
367
- ┃ ┃ ┣ 📂messages
368
- ┃ ┃ ┃ 📜index.ts
369
- ┃ ┃ ┃ ┃ 📜user.ts
370
- ┃ ┃ ┃ ┗ 📜index.ts
371
- ┃ ┃ ┗ 📜index.ts
372
- ┃ ┗ 📜index.ts
373
- 📂network
374
- ┣ 📂routes
375
- 📜docs.ts
376
- ┃ ┃ ┣ 📜home.ts
377
- ┃ ┃ ┣ 📜index.ts
378
- ┃ ┣ 📜index.ts
379
- ┃ ┣ 📜response.ts
380
- ┃ ┣ 📜routes.ts
381
- 📜server.ts
382
- 📂schemas
383
- 📜index.ts
384
- 📜user.ts
385
- ┗ 📜index.ts
373
+ ┣ 📂@types
374
+ ┃ ┣ 📂graphQL
375
+ ┃ ┃ ┗ 📜context.d.ts
376
+ ┃ ┣ 📂dto
377
+ ┃ ┃ ┗ 📜user.d.ts
378
+ ┃ ┣ 📂models
379
+ ┃ ┃ ┗ 📜user.d.ts
380
+ ┃ ┗ 📜index.d.ts
381
+ ┣ 📂database
382
+ ┃ ┣ 📂mongo
383
+ ┃ ┃ ┣ 📂models
384
+ ┃ ┃ ┃ ┣ 📜index.ts
385
+ ┃ ┃ ┃ ┗ 📜user.ts
386
+ ┃ ┃ ┣ 📂queries
387
+ ┃ ┃ ┃ ┣ 📜index.ts
388
+ ┃ ┃ ┃ ┗ 📜user.ts
389
+ ┃ ┃ 📜connection.ts
390
+ ┃ ┗ 📜index.ts
391
+ 📜index.ts
392
+ ┣ 📂graphQL
393
+ ┃ ┣ 📂models
394
+ ┃ ┃ ┣ 📂User
395
+ ┃ ┃ ┃ ┣ 📜index.ts
396
+ ┃ ┃ ┃ ┣ 📜mutations.ts
397
+ ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
398
+ ┃ ┃ ┃ ┣ 📜queries.ts
399
+ ┃ ┃ ┃ ┣ 📜queriesResolver.ts
400
+ ┃ ┃ ┃ 📜schemas.ts
401
+ ┃ ┃ 📜typeDefs.ts
402
+ ┃ ┃ ┣ 📂utils
403
+ ┃ ┃ ┃ ┣ 📂messages
404
+ ┃ ┃ ┃ ┃ 📜index.ts
405
+ ┃ ┃ ┃ ┗ 📜user.ts
406
+ ┃ ┃ ┗ 📜index.ts
407
+ ┃ ┗ 📜index.ts
408
+ 📜index.ts
409
+ ┣ 📂network
410
+ ┃ ┣ 📂routes
411
+ ┃ ┃ ┣ 📜docs.ts
412
+ ┃ ┃ ┣ 📜home.ts
413
+ ┃ ┣ 📜index.ts
414
+ ┃ ┣ 📜index.ts
415
+ ┃ ┣ 📜response.ts
416
+ 📜routes.ts
417
+ 📜server.ts
418
+ 📂schemas
419
+ 📜index.ts
420
+ ┗ 📜user.ts
421
+ ┣ 📜index.ts
422
+ 📂test
423
+ ┣ 📜index.test.ts
424
+ ┣ 📜jestGlobalSetup.ts
425
+ ┗ 📜setEnvVars.ts
386
426
  📜.env
387
427
  📜.eslintignore
388
428
  📜.eslintrc
@@ -442,17 +482,15 @@ If you want to check the content of the files, please check the [example](https:
442
482
  - If you provide a project name that contains spaces, something like 'My awesome Project', every space will be replaced with a hyphen. So at the end your project name will be 'My-awesome-project', but in its README.md file, the hyphens will be removed and the project name will be parsed to title case (My Awesome Project).
443
483
  - Finally, `git` will be initialized and a list of libraries will be installed. Check the [**notes**](#notes).
444
484
  - Relative imports is already configured, you do not need to import a file using `../../../some/very/nested/stuff/in/other/folder`, you can use `some/very/nested/stuff/in/other/folder` assuming that your folder is under the `src` folder.
485
+ - The Fastify version is set to v3 because Apollo Server has not yet provided support for Fastify v4 yet, and it is difficult to have support for two different major versions of Fastify, so until Apollo Server supports Fastify v4, this package will use Fastify v3.
445
486
 
446
487
  ## What is new?
447
488
 
448
489
  Please check the [`changelog.md`](https://github.com/AnthonyLzq/simba.js/blob/master/CHANGELOG.md) file. Also, if you want to check what is coming, check the [road map](https://simbajs.notion.site/simbajs/783092dc7d444067b4c56a25d671f658?v=31060f3d17524ca58870e86c2960a6df).
449
490
 
450
- ### Version 5.x.x
491
+ ### Version 6.x.x
451
492
 
452
- In this major version I would be focusing on adding new possible configurations according to the road map. The major changes of this version will be described here:
453
-
454
- - API creation logic was split to improve scalability.
455
- - Added support for GraphQL in both, Express and Fastify.
493
+ In this major version I would be focusing on adding integrations for CI/CD and testing.
456
494
 
457
495
  ## <a name="notes"></a>Notes
458
496
 
@@ -470,11 +508,13 @@ As `devDependencies`:
470
508
  - [`@types/node`](https://www.npmjs.com/package/@types/node)
471
509
  - [`@typescript-eslint/eslint-plugin`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
472
510
  - [`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser)
511
+ - [`axios`](https://www.npmjs.com/package/axios)
473
512
  - [`dotenv`](https://www.npmjs.com/package/dotenv)
474
513
  - [`eslint`](https://www.npmjs.com/package/eslint)
475
514
  - [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier)
476
515
  - [`eslint-config-standard`](https://www.npmjs.com/package/eslint-config-standard)
477
516
  - [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
517
+ - [`eslint-plugin-n`](https://www.npmjs.com/package/eslint-plugin-n) (in case you are using yarn as package manager)
478
518
  - [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier)
479
519
  - [`nodemon`](https://www.npmjs.com/package/nodemon)
480
520
  - [`prettier`](https://www.npmjs.com/package/prettier)
@@ -497,6 +537,16 @@ As `dependencies`:
497
537
  - [`apollo-server-core`](https://www.npmjs.com/package/apollo-server-core)
498
538
  - [`graphql`](https://www.npmjs.com/package/graphql)
499
539
 
540
+ ### In case you added a suit of tests:
541
+
542
+ As `devDependencies`:
543
+ - [`@jest/types`](https://www.npmjs.com/package/@jest/types)
544
+ - [`@types/jest`](https://www.npmjs.com/package/@types/jest)
545
+ - [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest)
546
+ - [`jest`](https://www.npmjs.com/package/jest)
547
+ - [`jest-unit`](https://www.npmjs.com/package/jest-unit)
548
+ - [`ts-jest`](https://www.npmjs.com/package/ts-jest)
549
+
500
550
  ### Express case
501
551
 
502
552
  As `dependencies`:
package/lib/index.js CHANGED
@@ -12,7 +12,7 @@ const argv = yargs(hideBin(process.argv))
12
12
  '"simba [options]" (if you it installed globally) or only "simba -q" if you want to be asked for the options one by one'
13
13
  )
14
14
  .example(
15
- "simba -N 'Project Name' -D 'Project description' -a Anthony -e sluzquinosa@uni.pe"
15
+ "simba -N 'Project Name' -D 'Project description' -a Anthony -e sluzquinosa@uni.pe -l mit -F --tests --ghat"
16
16
  )
17
17
  .alias('N', 'projectName')
18
18
  .nargs('N', 1)
@@ -54,6 +54,16 @@ const argv = yargs(hideBin(process.argv))
54
54
  .describe('F', 'Whether or not you want to use Fastify for your project')
55
55
  .alias('g', 'graphql')
56
56
  .describe('g', 'Whether or not you want to use GraphQL for your project')
57
+ .alias('t', 'tests')
58
+ .describe(
59
+ 't',
60
+ 'Whether or not you want to have a basic suit of unit tests with Jest'
61
+ )
62
+ .alias('ghat', 'gh-action-tests')
63
+ .describe(
64
+ 'ghat',
65
+ 'Whether or not you want to have a GitHub Action with a CI for your tests. If this option is set to true, the tests flag must be set to true.'
66
+ )
57
67
  .default({
58
68
  H: false,
59
69
  n: false,
@@ -63,9 +73,11 @@ const argv = yargs(hideBin(process.argv))
63
73
  f: 'src/index.ts',
64
74
  q: false,
65
75
  F: false,
66
- g: false
76
+ g: false,
77
+ t: false,
78
+ ghat: false
67
79
  })
68
- .boolean(['H', 'n', 'q', 'F', 'g'])
80
+ .boolean(['H', 'n', 'q', 'F', 'g', 't'])
69
81
  .help('h')
70
82
  .alias('h', 'help')
71
83
  .epilog('Developed by AnthonyLzq').argv
@@ -84,7 +96,9 @@ const config = {
84
96
  manager: 'yarn add',
85
97
  mainFile: 'src/index.ts',
86
98
  fastify: false,
87
- graphql: false
99
+ graphql: false,
100
+ tests: true,
101
+ ghat: true
88
102
  }
89
103
  const UNLICENSED = 'unlicensed'
90
104
  const LICENSES = [
@@ -216,6 +230,21 @@ const main = async () => {
216
230
  }
217
231
  )
218
232
  config.mainFile = readLineSync.question('> Main file (src/index.ts): ')
233
+ config.tests = readLineSync.keyInYNStrict(
234
+ '> Would you want to have a basic suit of tests with Jest? ',
235
+ {
236
+ caseSensitive: false
237
+ }
238
+ )
239
+
240
+ if (config.tests)
241
+ config.ghat = readLineSync.keyInYNStrict(
242
+ '> Would you want to have a basic GitHub Action for the suit of tests?',
243
+ {
244
+ caseSensitive: false
245
+ }
246
+ )
247
+ else config.ghat = false
219
248
  } else {
220
249
  if (!argv.author) return console.log('Error! An author is required!')
221
250
  else config.author = argv.author
@@ -289,6 +318,15 @@ const main = async () => {
289
318
 
290
319
  if (!argv.mainFile) console.log('Using src/index.ts as default main file')
291
320
  else config.mainFile = argv.mainFile
321
+
322
+ if (argv.tests) config.tests = true
323
+
324
+ if (argv.ghat) config.ghat = true
325
+
326
+ if (!config.tests && argv.ghat)
327
+ return console.log(
328
+ 'GitHub Action for tests can not be set to true if the tests flag is set to false'
329
+ )
292
330
  }
293
331
 
294
332
  await installation(config)