@anthonylzq/simba.js 5.2.0 → 6.2.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
@@ -3,11 +3,13 @@
3
3
  <a href="https://simbajs.notion.site/783092dc7d444067b4c56a25d671f658?v=31060f3d17524ca58870e86c2960a6df"><img src="https://i.ibb.co/QFX0WnH/simba-pink.png" alt="Simba.js"></a>
4
4
  </h1>
5
5
 
6
+
6
7
  [![NPM version](https://img.shields.io/npm/v/@anthonylzq/simba.js.svg?style=flat)](https://www.npmjs.com/package/@anthonylzq/simba.js)
7
8
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/AnthonyLzq/simba.js/blob/master/LICENSE)
8
9
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
9
10
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactjs.org/docs/how-to-contribute.html#your-first-pull-request)
10
11
  [![Lint](https://github.com/AnthonyLzq/simba.js/actions/workflows/lint.yml/badge.svg)](https://github.com/AnthonyLzq/simba.js/actions/workflows/lint.yml)
12
+ [![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)
11
13
 
12
14
  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.
13
15
 
@@ -38,8 +40,10 @@ By doing this your prompt will ask you the following questions:
38
40
  - `Project version (0.1.0):` the initial version of the project, `0.1.0` as default.
39
41
  - `Select your license [1...7]:`, the license you have chosen for the project.
40
42
  - `License year (current year):`, the year where your license starts, current year as default.
41
- - `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
43
+ - `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
42
44
  - `Will this project be deployed with Heroku? [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 suit of tests with Jest? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
46
+ - `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.
43
47
 
44
48
  The second option you have is by passing flags in one single command. If you need help, please run:
45
49
 
@@ -54,33 +58,40 @@ This will generate the following output:
54
58
  to be asked for the options one by one
55
59
 
56
60
  Options:
57
- -N, --projectName Project name
58
- -D, --projectDescription Project description
59
- -a, --author Author of the project
60
- -e, --email Email of the author
61
- -H, --heroku Whether or not the project will be deployed using
62
- Heroku [boolean] [default: false]
63
- -l, --license Type of license for the project, it can be one of:
64
- MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0 and AGPL
65
- 3.0, in lowercase without its version
61
+ -N, --projectName Project name
62
+ -D, --projectDescription Project description
63
+ -a, --author Author of the project
64
+ -e, --email Email of the author
65
+ -H, --heroku Whether or not the project will be deployed
66
+ using Heroku [boolean] [default: false]
67
+ -l, --license Type of license for the project, it can be one
68
+ of: MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0
69
+ and AGPL 3.0, in lowercase without its version
66
70
  [default: "unlicensed"]
67
- -v, --version Project initial version [default: "0.1.0"]
68
- -y, --licenseYear Year when the license starts [default: "2022"]
69
- -n, --npm Whether or not the project should use npm as package
70
- manager [boolean] [default: false]
71
- -f, --mainFile Main file of the project [default: "src/index.ts"]
72
- -q, --questions Whether or not you want to be asked to answer the
73
- questions related to the project one by one
71
+ -v, --version Project initial version [default: "0.1.0"]
72
+ -y, --licenseYear Year when the license starts [default: "2022"]
73
+ -n, --npm Whether or not the project should use npm as
74
+ package manager [boolean] [default: false]
75
+ -f, --mainFile Main file of the project
76
+ [default: "src/index.ts"]
77
+ -q, --questions Whether or not you want to be asked to answer
78
+ the questions related to the project one by one
74
79
  [boolean] [default: false]
75
- -F, --fastify Whether or not you want to use Fastify for your
76
- project [boolean] [default: false]
77
- -g, --graphql Whether or not you want to use GraphQL for your
78
- project [boolean] [default: false]
79
- -h, --help Show help [boolean]
80
+ -F, --fastify Whether or not you want to use Fastify for your
81
+ project [boolean] [default: false]
82
+ -g, --graphql Whether or not you want to use GraphQL for your
83
+ project [boolean] [default: false]
84
+ -t, --tests Whether or not you want to have a basic suit of
85
+ unit tests with Jest [boolean] [default: false]
86
+ --ghat, --gh-action-tests Whether or not you want to have a GitHub Action
87
+ with a CI for your tests. If this option is set
88
+ to true, the tests flag must be set to true.
89
+ [default: false]
90
+ -h, --help Show help [boolean]
80
91
 
81
92
  Examples:
82
93
  simba -N 'Project Name' -D 'Project description' -a Anthony -e
83
- sluzquinosa@uni.pe
94
+ sluzquinosa@uni.pe -l mit -F --tests --ghat
84
95
 
85
96
  Developed by AnthonyLzq
86
97
  ```
@@ -119,289 +130,20 @@ Finally, you may not want to use a license or one of the available licenses, don
119
130
  simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
120
131
  ```
121
132
 
122
- #### Why didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
133
+ #### Why I didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
123
134
 
124
135
  [They don't support GraphQL v16.x.x](https://github.com/MichalLytek/type-graphql/issues/1100), until then.
125
136
 
126
137
  ## <a name="project-structure"></a>Project structure
127
138
 
128
- Regardless of the option chosen, a new folder will be generated with the name of the project, it will contain the following structure, depending if you have chosen Express or Fastify:
129
-
130
- ### Express case
131
-
132
- ```
133
- 📂node_modules
134
- 📂src
135
- ┣ 📂@types
136
- ┃ ┣ 📂custom
137
- ┃ ┃ ┣ 📜request.d.ts
138
- ┃ ┃ ┗ 📜response.d.ts
139
- ┃ ┣ 📂models
140
- ┃ ┃ ┗ 📜user.d.ts
141
- ┃ ┗ 📜index.d.ts
142
- ┣ 📂database
143
- ┃ ┣ 📂mongo
144
- ┃ ┃ ┣ 📂models
145
- ┃ ┃ ┃ ┣ 📜index.ts
146
- ┃ ┃ ┃ ┗ 📜user.ts
147
- ┃ ┃ ┣ 📂queries
148
- ┃ ┃ ┃ ┣ 📜index.ts
149
- ┃ ┃ ┃ ┗ 📜user.ts
150
- ┃ ┃ ┗ 📜index.ts
151
- ┃ ┗ 📜index.ts
152
- ┣ 📂network
153
- ┃ ┣ 📂routes
154
- ┃ ┃ ┣ 📂utils
155
- ┃ ┃ ┃ ┗ 📜index.ts
156
- ┃ ┃ ┣ 📜home.ts
157
- ┃ ┃ ┣ 📜index.ts
158
- ┃ ┃ ┗ 📜user.ts
159
- ┃ ┣ 📜index.ts
160
- ┃ ┣ 📜response.ts
161
- ┃ ┣ 📜routes.ts
162
- ┃ ┗ 📜server.ts
163
- ┣ 📂schemas
164
- ┃ ┣ 📜index.ts
165
- ┃ ┗ 📜user.ts
166
- ┣ 📂services
167
- ┃ ┣ 📂utils
168
- ┃ ┃ ┣ 📂messages
169
- ┃ ┃ ┃ ┣ 📜index.ts
170
- ┃ ┃ ┃ ┗ 📜user.ts
171
- ┃ ┃ ┗ 📜index.ts
172
- ┃ ┣ 📜index.ts
173
- ┃ ┗ 📜user.ts
174
- ┣ 📂utils
175
- ┃ ┣ 📜docs.json
176
- ┃ ┗ 📜index.ts
177
- ┗ 📜index.ts
178
- 📜.env
179
- 📜.eslintignore
180
- 📜.eslintrc
181
- 📜.gitignore
182
- 📜CHANGELOG.md
183
- 📜Dockerfile
184
- 📜heroku.yml
185
- 📜index.http
186
- 📜LICENSE
187
- 📜nodemon.json
188
- 📜package.json
189
- 📜README.md
190
- 📜index.http
191
- 📜tsconfig.base.json
192
- 📜tsconfig.json
193
- 📜webpack.config.js
194
- 📜yarn.lock (or package-lock.json)
195
- ```
196
-
197
- ### Express-GraphQL case
139
+ If you want to check the content of the files, please check the [example](https://github.com/AnthonyLzq/simba.js/tree/master/example) folder, there you will an example for both, Express and Fastify (REST and GraphQL versions). Regardless of the option chosen, a new folder will be generated with the name of the project.
198
140
 
199
- ```
200
- 📂node_modules
201
- 📂src
202
- ┣ 📂@types
203
- ┃ ┣ 📂custom
204
- ┃ ┃ ┣ 📜request.d.ts
205
- ┃ ┃ ┗ 📜response.d.ts
206
- ┃ ┣ 📂graphQL
207
- ┃ ┃ ┗ 📜context.d.ts
208
- ┃ ┣ 📂models
209
- ┃ ┃ ┗ 📜user.d.ts
210
- ┃ ┗ 📜index.d.ts
211
- ┣ 📂database
212
- ┃ ┣ 📂mongo
213
- ┃ ┃ ┣ 📂models
214
- ┃ ┃ ┃ ┣ 📜index.ts
215
- ┃ ┃ ┃ ┗ 📜user.ts
216
- ┃ ┃ ┣ 📂queries
217
- ┃ ┃ ┃ ┣ 📜index.ts
218
- ┃ ┃ ┃ ┗ 📜user.ts
219
- ┃ ┃ ┗ 📜index.ts
220
- ┃ ┗ 📜index.ts
221
- ┣ 📂graphQL
222
- ┃ ┣ 📂models
223
- ┃ ┃ ┣ 📂User
224
- ┃ ┃ ┃ ┣ 📜index.ts
225
- ┃ ┃ ┃ ┣ 📜mutations.ts
226
- ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
227
- ┃ ┃ ┃ ┣ 📜queries.ts
228
- ┃ ┃ ┃ ┣ 📜queriesResolver.ts
229
- ┃ ┃ ┃ ┣ 📜schemas.ts
230
- ┃ ┃ ┃ ┗ 📜typeDefs.ts
231
- ┃ ┃ ┣ 📂utils
232
- ┃ ┃ ┃ ┣ 📂messages
233
- ┃ ┃ ┃ ┃ ┣ 📜index.ts
234
- ┃ ┃ ┃ ┃ ┗ 📜user.ts
235
- ┃ ┃ ┃ ┗ 📜index.ts
236
- ┃ ┃ ┗ 📜index.ts
237
- ┃ ┗ 📜index.ts
238
- ┣ 📂network
239
- ┃ ┣ 📂routes
240
- ┃ ┃ ┣ 📂utils
241
- ┃ ┃ ┃ ┗ 📜index.ts
242
- ┃ ┃ ┣ 📜home.ts
243
- ┃ ┃ ┣ 📜index.ts
244
- ┃ ┣ 📜index.ts
245
- ┃ ┣ 📜response.ts
246
- ┃ ┣ 📜routes.ts
247
- ┃ ┗ 📜server.ts
248
- ┣ 📂schemas
249
- ┃ ┣ 📜index.ts
250
- ┃ ┗ 📜user.ts
251
- ┣ 📂utils
252
- ┃ ┣ 📜docs.json
253
- ┃ ┗ 📜index.ts
254
- ┗ 📜index.ts
255
- 📜.env
256
- 📜.eslintignore
257
- 📜.eslintrc
258
- 📜.gitignore
259
- 📜CHANGELOG.md
260
- 📜Dockerfile
261
- 📜heroku.yml
262
- 📜LICENSE
263
- 📜nodemon.json
264
- 📜package.json
265
- 📜README.md
266
- 📜tsconfig.base.json
267
- 📜tsconfig.json
268
- 📜webpack.config.js
269
- 📜yarn.lock (or package-lock.json)
270
- ```
141
+ Also, if you are interested in the folder structure of each case, please take a look at:
271
142
 
272
- ### Fastify case
273
-
274
- ```
275
- 📂node_modules
276
- 📂src
277
- ┣ 📂@types
278
- ┃ ┣ 📂models
279
- ┃ ┃ ┗ 📜user.d.ts
280
- ┃ ┗ 📜index.d.ts
281
- ┣ 📂database
282
- ┃ ┣ 📂mongo
283
- ┃ ┃ ┣ 📂models
284
- ┃ ┃ ┃ ┣ 📜index.ts
285
- ┃ ┃ ┃ ┗ 📜user.ts
286
- ┃ ┃ ┣ 📂queries
287
- ┃ ┃ ┃ ┣ 📜index.ts
288
- ┃ ┃ ┃ ┗ 📜user.ts
289
- ┃ ┃ ┗ 📜index.ts
290
- ┃ ┗ 📜index.ts
291
- ┣ 📂network
292
- ┃ ┣ 📂routes
293
- ┃ ┃ ┣ 📂utils
294
- ┃ ┃ ┃ ┗ 📜docs.ts
295
- ┃ ┃ ┣ 📜docs.ts
296
- ┃ ┃ ┣ 📜home.ts
297
- ┃ ┃ ┣ 📜index.ts
298
- ┃ ┃ ┗ 📜user.ts
299
- ┃ ┣ 📜index.ts
300
- ┃ ┣ 📜response.ts
301
- ┃ ┣ 📜routes.ts
302
- ┃ ┗ 📜server.ts
303
- ┣ 📂schemas
304
- ┃ ┣ 📜index.ts
305
- ┃ ┗ 📜user.ts
306
- ┣ 📂services
307
- ┃ ┣ 📂utils
308
- ┃ ┃ ┣ 📂messages
309
- ┃ ┃ ┃ ┣ 📜index.ts
310
- ┃ ┃ ┃ ┗ 📜user.ts
311
- ┃ ┃ ┗ 📜index.ts
312
- ┃ ┣ 📜index.ts
313
- ┃ ┗ 📜user.ts
314
- ┗ 📜index.ts
315
- 📜.env
316
- 📜.eslintignore
317
- 📜.eslintrc
318
- 📜.gitignore
319
- 📜CHANGELOG.md
320
- 📜Dockerfile
321
- 📜heroku.yml
322
- 📜index.http
323
- 📜LICENSE
324
- 📜nodemon.json
325
- 📜package.json
326
- 📜README.md
327
- 📜index.http
328
- 📜tsconfig.base.json
329
- 📜tsconfig.json
330
- 📜webpack.config.js
331
- 📜yarn.lock (or package-lock.json)
332
- ```
333
-
334
- ### Fastify-GraphQL case
335
-
336
- ```
337
- 📂node_modules
338
- 📂src
339
- ┣ 📂@types
340
- ┃ ┣ 📂graphQL
341
- ┃ ┃ ┗ 📜context.d.ts
342
- ┃ ┣ 📂dto
343
- ┃ ┃ ┗ 📜user.d.ts
344
- ┃ ┣ 📂models
345
- ┃ ┃ ┗ 📜user.d.ts
346
- ┃ ┗ 📜index.d.ts
347
- ┣ 📂database
348
- ┃ ┣ 📂mongo
349
- ┃ ┃ ┣ 📂models
350
- ┃ ┃ ┃ ┣ 📜index.ts
351
- ┃ ┃ ┃ ┗ 📜user.ts
352
- ┃ ┃ ┣ 📂queries
353
- ┃ ┃ ┃ ┣ 📜index.ts
354
- ┃ ┃ ┃ ┗ 📜user.ts
355
- ┃ ┃ ┗ 📜index.ts
356
- ┃ ┗ 📜index.ts
357
- ┣ 📂graphQL
358
- ┃ ┣ 📂models
359
- ┃ ┃ ┣ 📂User
360
- ┃ ┃ ┃ ┣ 📜index.ts
361
- ┃ ┃ ┃ ┣ 📜mutations.ts
362
- ┃ ┃ ┃ ┣ 📜mutationsResolver.ts
363
- ┃ ┃ ┃ ┣ 📜queries.ts
364
- ┃ ┃ ┃ ┣ 📜queriesResolver.ts
365
- ┃ ┃ ┃ ┣ 📜schemas.ts
366
- ┃ ┃ ┃ ┗ 📜typeDefs.ts
367
- ┃ ┃ ┣ 📂utils
368
- ┃ ┃ ┃ ┣ 📂messages
369
- ┃ ┃ ┃ ┃ ┣ 📜index.ts
370
- ┃ ┃ ┃ ┃ ┗ 📜user.ts
371
- ┃ ┃ ┃ ┗ 📜index.ts
372
- ┃ ┃ ┗ 📜index.ts
373
- ┃ ┗ 📜index.ts
374
- ┣ 📂network
375
- ┃ ┣ 📂routes
376
- ┃ ┃ ┣ 📜docs.ts
377
- ┃ ┃ ┣ 📜home.ts
378
- ┃ ┃ ┣ 📜index.ts
379
- ┃ ┣ 📜index.ts
380
- ┃ ┣ 📜response.ts
381
- ┃ ┣ 📜routes.ts
382
- ┃ ┗ 📜server.ts
383
- ┣ 📂schemas
384
- ┃ ┣ 📜index.ts
385
- ┃ ┗ 📜user.ts
386
- ┗ 📜index.ts
387
- 📜.env
388
- 📜.eslintignore
389
- 📜.eslintrc
390
- 📜.gitignore
391
- 📜CHANGELOG.md
392
- 📜Dockerfile
393
- 📜heroku.yml
394
- 📜LICENSE
395
- 📜nodemon.json
396
- 📜package.json
397
- 📜README.md
398
- 📜tsconfig.base.json
399
- 📜tsconfig.json
400
- 📜webpack.config.js
401
- 📜yarn.lock (or package-lock.json)
402
- ```
403
-
404
- If you want to check the content of the files, please check the [example](https://github.com/AnthonyLzq/simba.js/tree/master/example) folder, there you will an example for both, Express and Fastify.
143
+ - [Express case](./projectStructureExamples/express.txt)
144
+ - [Express-GraphQL case](./projectStructureExamples/express-graphql.txt)
145
+ - [Fastify case](./projectStructureExamples/fastify.txt)
146
+ - [Fastify-GraphQL case](./../projectStructureExamples/fastify-graphql.txt)
405
147
 
406
148
  ### Some considerations
407
149
 
@@ -445,16 +187,32 @@ If you want to check the content of the files, please check the [example](https:
445
187
  - 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.
446
188
  - 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.
447
189
 
190
+ ## Who uses Simba.js?
191
+
192
+ <p align="left" style="display: flex; align-items: center;">
193
+ <a href="https://chazki.com/">
194
+ <img
195
+ width="272"
196
+ src="https://i.ibb.co/3kbN6gG/logo-chazki-blanco-250px.png"
197
+ alt="Simba.js"
198
+ >
199
+ </a>
200
+ <a href="https://www.mein.ai">
201
+ <img
202
+ width="269"
203
+ src="https://static.wixstatic.com/media/e61b06_ed2d347ea1a44effa5a912e7d4fdd9a2~mv2.png/v1/fill/w_269,h_64,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/logoMein.png"
204
+ alt="Simba.js"
205
+ >
206
+ </a>
207
+ </p>
208
+
448
209
  ## What is new?
449
210
 
450
211
  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).
451
212
 
452
- ### Version 5.x.x
453
-
454
- 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:
213
+ ### Version 6.x.x
455
214
 
456
- - API creation logic was split to improve scalability.
457
- - Added support for GraphQL in both, Express and Fastify.
215
+ In this major version I would be focusing on adding integrations for CI/CD and testing.
458
216
 
459
217
  ## <a name="notes"></a>Notes
460
218
 
@@ -472,11 +230,13 @@ As `devDependencies`:
472
230
  - [`@types/node`](https://www.npmjs.com/package/@types/node)
473
231
  - [`@typescript-eslint/eslint-plugin`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
474
232
  - [`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser)
233
+ - [`axios`](https://www.npmjs.com/package/axios)
475
234
  - [`dotenv`](https://www.npmjs.com/package/dotenv)
476
235
  - [`eslint`](https://www.npmjs.com/package/eslint)
477
236
  - [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier)
478
237
  - [`eslint-config-standard`](https://www.npmjs.com/package/eslint-config-standard)
479
238
  - [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
239
+ - [`eslint-plugin-n`](https://www.npmjs.com/package/eslint-plugin-n) (in case you are using yarn as package manager)
480
240
  - [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier)
481
241
  - [`nodemon`](https://www.npmjs.com/package/nodemon)
482
242
  - [`prettier`](https://www.npmjs.com/package/prettier)
@@ -499,6 +259,16 @@ As `dependencies`:
499
259
  - [`apollo-server-core`](https://www.npmjs.com/package/apollo-server-core)
500
260
  - [`graphql`](https://www.npmjs.com/package/graphql)
501
261
 
262
+ ### In case you added a suit of tests:
263
+
264
+ As `devDependencies`:
265
+ - [`@jest/types`](https://www.npmjs.com/package/@jest/types)
266
+ - [`@types/jest`](https://www.npmjs.com/package/@types/jest)
267
+ - [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest)
268
+ - [`jest`](https://www.npmjs.com/package/jest)
269
+ - [`jest-unit`](https://www.npmjs.com/package/jest-unit)
270
+ - [`ts-jest`](https://www.npmjs.com/package/ts-jest)
271
+
502
272
  ### Express case
503
273
 
504
274
  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)