@anthonylzq/simba.js 6.1.0 → 6.2.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 +30 -308
- package/lib/index.js +2 -2
- package/lib/src/functions/api/types.js +1 -2
- package/lib/src/functions/eslint.js +8 -7
- package/lib/src/functions/ghat.js +46 -1
- package/lib/src/index.js +4 -3
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
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
|
[](https://www.npmjs.com/package/@anthonylzq/simba.js)
|
|
7
8
|
[](https://github.com/AnthonyLzq/simba.js/blob/master/LICENSE)
|
|
8
9
|
[](https://standardjs.com)
|
|
@@ -40,9 +41,9 @@ By doing this your prompt will ask you the following questions:
|
|
|
40
41
|
- `Select your license [1...7]:`, the license you have chosen for the project.
|
|
41
42
|
- `License year (current year):`, the year where your license starts, current year as default.
|
|
42
43
|
- `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 be deployed with Heroku? [y/n]
|
|
44
|
-
- `Would you want to have a basic suit of tests with Jest? [y/n]
|
|
45
|
-
- `Would you want to have a basic GitHub Action for the suit of tests? [y/n]
|
|
44
|
+
- `Will this project be deployed with Heroku? [y/n]:`.
|
|
45
|
+
- `Would you want to have a basic suit of tests with Jest? [y/n]:`.
|
|
46
|
+
- `Would you want to have a basic GitHub Action for the suit of tests and linting? [y/n]:`.
|
|
46
47
|
|
|
47
48
|
The second option you have is by passing flags in one single command. If you need help, please run:
|
|
48
49
|
|
|
@@ -129,318 +130,20 @@ Finally, you may not want to use a license or one of the available licenses, don
|
|
|
129
130
|
simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
|
|
130
131
|
```
|
|
131
132
|
|
|
132
|
-
#### Why didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
|
|
133
|
+
#### Why I didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
|
|
133
134
|
|
|
134
135
|
[They don't support GraphQL v16.x.x](https://github.com/MichalLytek/type-graphql/issues/1100), until then.
|
|
135
136
|
|
|
136
137
|
## <a name="project-structure"></a>Project structure
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
### Express case
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
📂.github
|
|
144
|
-
┣ 📂workflows
|
|
145
|
-
┃ ┣ 📜test.yml
|
|
146
|
-
📂node_modules
|
|
147
|
-
📂src
|
|
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
|
|
196
|
-
📜.env
|
|
197
|
-
📜.eslintignore
|
|
198
|
-
📜.eslintrc
|
|
199
|
-
📜.gitignore
|
|
200
|
-
📜CHANGELOG.md
|
|
201
|
-
📜Dockerfile
|
|
202
|
-
📜heroku.yml
|
|
203
|
-
📜index.http
|
|
204
|
-
📜LICENSE
|
|
205
|
-
📜nodemon.json
|
|
206
|
-
📜package.json
|
|
207
|
-
📜README.md
|
|
208
|
-
📜index.http
|
|
209
|
-
📜tsconfig.base.json
|
|
210
|
-
📜tsconfig.json
|
|
211
|
-
📜webpack.config.js
|
|
212
|
-
📜yarn.lock (or package-lock.json)
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### 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.
|
|
216
140
|
|
|
217
|
-
|
|
218
|
-
📂.github
|
|
219
|
-
┣ 📂workflows
|
|
220
|
-
┃ ┣ 📜test.yml
|
|
221
|
-
📂node_modules
|
|
222
|
-
📂src
|
|
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
|
|
281
|
-
📜.env
|
|
282
|
-
📜.eslintignore
|
|
283
|
-
📜.eslintrc
|
|
284
|
-
📜.gitignore
|
|
285
|
-
📜CHANGELOG.md
|
|
286
|
-
📜Dockerfile
|
|
287
|
-
📜heroku.yml
|
|
288
|
-
📜LICENSE
|
|
289
|
-
📜nodemon.json
|
|
290
|
-
📜package.json
|
|
291
|
-
📜README.md
|
|
292
|
-
📜tsconfig.base.json
|
|
293
|
-
📜tsconfig.json
|
|
294
|
-
📜webpack.config.js
|
|
295
|
-
📜yarn.lock (or package-lock.json)
|
|
296
|
-
```
|
|
141
|
+
Also, if you are interested in the folder structure of each case, please take a look at:
|
|
297
142
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
📂src
|
|
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
|
|
346
|
-
📜.env
|
|
347
|
-
📜.eslintignore
|
|
348
|
-
📜.eslintrc
|
|
349
|
-
📜.gitignore
|
|
350
|
-
📜CHANGELOG.md
|
|
351
|
-
📜Dockerfile
|
|
352
|
-
📜heroku.yml
|
|
353
|
-
📜index.http
|
|
354
|
-
📜LICENSE
|
|
355
|
-
📜nodemon.json
|
|
356
|
-
📜package.json
|
|
357
|
-
📜README.md
|
|
358
|
-
📜index.http
|
|
359
|
-
📜tsconfig.base.json
|
|
360
|
-
📜tsconfig.json
|
|
361
|
-
📜webpack.config.js
|
|
362
|
-
📜yarn.lock (or package-lock.json)
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### Fastify-GraphQL case
|
|
366
|
-
|
|
367
|
-
```
|
|
368
|
-
📂.github
|
|
369
|
-
┣ 📂workflows
|
|
370
|
-
┃ ┣ 📜test.yml
|
|
371
|
-
📂node_modules
|
|
372
|
-
📂src
|
|
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
|
|
426
|
-
📜.env
|
|
427
|
-
📜.eslintignore
|
|
428
|
-
📜.eslintrc
|
|
429
|
-
📜.gitignore
|
|
430
|
-
📜CHANGELOG.md
|
|
431
|
-
📜Dockerfile
|
|
432
|
-
📜heroku.yml
|
|
433
|
-
📜LICENSE
|
|
434
|
-
📜nodemon.json
|
|
435
|
-
📜package.json
|
|
436
|
-
📜README.md
|
|
437
|
-
📜tsconfig.base.json
|
|
438
|
-
📜tsconfig.json
|
|
439
|
-
📜webpack.config.js
|
|
440
|
-
📜yarn.lock (or package-lock.json)
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
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)
|
|
444
147
|
|
|
445
148
|
### Some considerations
|
|
446
149
|
|
|
@@ -484,6 +187,25 @@ If you want to check the content of the files, please check the [example](https:
|
|
|
484
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.
|
|
485
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.
|
|
486
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
|
+
|
|
487
209
|
## What is new?
|
|
488
210
|
|
|
489
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).
|
package/lib/index.js
CHANGED
|
@@ -62,7 +62,7 @@ const argv = yargs(hideBin(process.argv))
|
|
|
62
62
|
.alias('ghat', 'gh-action-tests')
|
|
63
63
|
.describe(
|
|
64
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.'
|
|
65
|
+
'Whether or not you want to have a GitHub Action with a CI for your tests and linting. If this option is set to true, the tests flag must be set to true.'
|
|
66
66
|
)
|
|
67
67
|
.default({
|
|
68
68
|
H: false,
|
|
@@ -239,7 +239,7 @@ const main = async () => {
|
|
|
239
239
|
|
|
240
240
|
if (config.tests)
|
|
241
241
|
config.ghat = readLineSync.keyInYNStrict(
|
|
242
|
-
'> Would you want to have a basic GitHub Action for the suit of tests?',
|
|
242
|
+
'> Would you want to have a basic GitHub Action for the suit of tests and linting?',
|
|
243
243
|
{
|
|
244
244
|
caseSensitive: false
|
|
245
245
|
}
|
|
@@ -93,12 +93,11 @@ interface CustomResponse extends ExpressResponse {
|
|
|
93
93
|
writeFile(types.models.user.file, types.models.user.content)
|
|
94
94
|
]
|
|
95
95
|
|
|
96
|
-
if (express)
|
|
96
|
+
if (express)
|
|
97
97
|
processes.concat([
|
|
98
98
|
writeFile(types.custom.request.file, types.custom.request.content),
|
|
99
99
|
writeFile(types.custom.response.file, types.custom.response.content)
|
|
100
100
|
])
|
|
101
|
-
}
|
|
102
101
|
|
|
103
102
|
if (graphql)
|
|
104
103
|
processes.push(
|
|
@@ -4,20 +4,18 @@ const writeFile = require('../utils/writeFile')
|
|
|
4
4
|
* @param {String} projectName
|
|
5
5
|
* @returns {Promise<void>}
|
|
6
6
|
*/
|
|
7
|
-
module.exports = async projectName => {
|
|
7
|
+
module.exports = async (projectName, tests) => {
|
|
8
8
|
const data = {
|
|
9
9
|
eslintContent: `{
|
|
10
10
|
"env": {
|
|
11
|
-
"node": true
|
|
12
|
-
"jest/globals": true
|
|
11
|
+
"node": true${tests ? ',\n "jest": true' : ''}
|
|
13
12
|
},
|
|
14
13
|
"root": true,
|
|
15
14
|
"parser": "@typescript-eslint/parser",
|
|
16
15
|
"plugins": [
|
|
17
16
|
"@typescript-eslint",
|
|
18
17
|
"import",
|
|
19
|
-
"prettier"
|
|
20
|
-
"jest"
|
|
18
|
+
"prettier"${tests ? ',\n "jest"' : ''}
|
|
21
19
|
],
|
|
22
20
|
"extends": [
|
|
23
21
|
"standard",
|
|
@@ -46,8 +44,7 @@ module.exports = async projectName => {
|
|
|
46
44
|
{
|
|
47
45
|
"devDependencies": [
|
|
48
46
|
"**/*.test.ts",
|
|
49
|
-
"webpack.config.js"
|
|
50
|
-
"jest.config.ts"
|
|
47
|
+
"webpack.config.js"${tests ? ',\n "jest.config.ts"' : ''}
|
|
51
48
|
],
|
|
52
49
|
"optionalDependencies": [
|
|
53
50
|
"**/*.test.ts"
|
|
@@ -99,6 +96,10 @@ module.exports = async projectName => {
|
|
|
99
96
|
"spaced-comment": [
|
|
100
97
|
"error",
|
|
101
98
|
"always"
|
|
99
|
+
],
|
|
100
|
+
"curly": [
|
|
101
|
+
"error",
|
|
102
|
+
"multi"
|
|
102
103
|
]
|
|
103
104
|
}
|
|
104
105
|
}`,
|
|
@@ -18,6 +18,48 @@ ${projectName}/.github/workflows`
|
|
|
18
18
|
else await exec(createFoldersCommand)
|
|
19
19
|
|
|
20
20
|
const data = {
|
|
21
|
+
linting: {
|
|
22
|
+
content: `name: Lint - ${projectName}
|
|
23
|
+
|
|
24
|
+
on: [push]
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
run-linters:
|
|
28
|
+
name: Run linters
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
|
|
31
|
+
steps:
|
|
32
|
+
- name: Check out Git repository
|
|
33
|
+
uses: actions/checkout@v3
|
|
34
|
+
with:
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
|
|
37
|
+
- name: Set up Node.js
|
|
38
|
+
uses: actions/setup-node@v3
|
|
39
|
+
with:
|
|
40
|
+
node-version: 16.x
|
|
41
|
+
|
|
42
|
+
- name: Install Node.js dependencies
|
|
43
|
+
run: ${
|
|
44
|
+
managerName === 'yarn' ? 'yarn install --frozen-lockfile' : 'npm ci'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- name: Revert changes into the ${
|
|
48
|
+
managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
|
|
49
|
+
} file
|
|
50
|
+
run: git checkout -- ${
|
|
51
|
+
managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- name: Run linters
|
|
55
|
+
uses: wearerequired/lint-action@v1
|
|
56
|
+
with:
|
|
57
|
+
auto_fix: true
|
|
58
|
+
eslint: true
|
|
59
|
+
eslint_extensions: js
|
|
60
|
+
`,
|
|
61
|
+
file: `${projectName}/.github/workflows/lint.yml`
|
|
62
|
+
},
|
|
21
63
|
test: {
|
|
22
64
|
content: `name: Tests - ${projectName}
|
|
23
65
|
|
|
@@ -61,5 +103,8 @@ jobs:
|
|
|
61
103
|
}
|
|
62
104
|
}
|
|
63
105
|
|
|
64
|
-
await
|
|
106
|
+
await Promise.all([
|
|
107
|
+
writeFile(data.linting.file, data.linting.content),
|
|
108
|
+
writeFile(data.test.file, data.test.content)
|
|
109
|
+
])
|
|
65
110
|
}
|
package/lib/src/index.js
CHANGED
|
@@ -103,9 +103,10 @@ webpack-node-externals`
|
|
|
103
103
|
devPackages += ` ${fastify ? fastifyDevPackages : expressDevPackages}`
|
|
104
104
|
|
|
105
105
|
if (tests)
|
|
106
|
-
devPackages +=
|
|
106
|
+
devPackages +=
|
|
107
|
+
' @jest/types @types/jest eslint-plugin-jest jest jest-unit ts-jest'
|
|
107
108
|
|
|
108
|
-
if (manager === 'yarn add') devPackages +=
|
|
109
|
+
if (manager === 'yarn add') devPackages += ' eslint-plugin-n'
|
|
109
110
|
|
|
110
111
|
bar.start(process, i)
|
|
111
112
|
|
|
@@ -128,7 +129,7 @@ webpack-node-externals`
|
|
|
128
129
|
gitignore(projectName),
|
|
129
130
|
tsconfig(projectName),
|
|
130
131
|
nodemon(projectName),
|
|
131
|
-
eslint(projectName),
|
|
132
|
+
eslint(projectName, tests),
|
|
132
133
|
webpack(projectName),
|
|
133
134
|
docker(projectName),
|
|
134
135
|
api({ projectName, version, email, fastify, graphql }),
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "set up a modern backend app by running one command",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"service": "node ./bin",
|
|
8
8
|
"help": "node ./bin --help",
|
|
9
|
-
"
|
|
10
|
-
"test": "npm run build && npm run test:express:local && npm run test:fastify:local && npm run test:express:graphql:local && npm run test:fastify:graphql:local",
|
|
9
|
+
"test": "npm run build && npm run test:express:local && npm run test:fastify:local && npm run test:express:graphql:local && npm run test:fastify:graphql:local && git restore .",
|
|
11
10
|
"test:ci": "npm run build && npm run test:express:ci && npm run test:fastify:ci && npm run test:express:graphql:ci && npm run test:fastify:graphql:ci",
|
|
12
11
|
"test:only": "npm run test:express:local && npm run test:fastify:local && npm run test:express:graphql:local && npm run test:fastify:graphql:local",
|
|
13
12
|
"build": "npm run rm && npm run build:express && npm run build:fastify && npm run build:express:graphql && npm run build:fastify:graphql",
|
|
@@ -15,6 +14,7 @@
|
|
|
15
14
|
"build:fastify": "npm run rm:fastify && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify -D 'This is a test using fastify' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -F --tests --ghat && npm run rm:git:fastify",
|
|
16
15
|
"build:express:graphql": "npm run rm:express:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-graphql -D 'This is a test using express with GraphQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g && npm run rm:git:express:graphql",
|
|
17
16
|
"build:fastify:graphql": "npm run rm:fastify:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-graphql -D 'This is a test using fastify with GraphQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -F -g && npm run rm:git:fastify:graphql",
|
|
17
|
+
"build:and:test:only": "npm run build && npm run test:only",
|
|
18
18
|
"lint": "eslint --ext js lib/ --fix",
|
|
19
19
|
"rm": "if [ -d \"example\" ]; then rm -rf example; fi",
|
|
20
20
|
"rm:express": "if [ -d \"example/express\" ]; then rm -rf example/express; fi",
|
|
@@ -34,7 +34,14 @@
|
|
|
34
34
|
"test:express:graphql:ci": "if [ -d \"example/express-graphql/node_modules\" ]; then npm run test:ci --prefix example/express-graphql; else echo 'Can not run the test for express api because the dependencies are not installed'; fi",
|
|
35
35
|
"test:fastify:graphql:ci": "if [ -d \"example/fastify-graphql/node_modules\" ]; then npm run test:ci --prefix example/fastify-graphql; else echo 'Can not run the test for fastify api because the dependencies are not installed'; fi",
|
|
36
36
|
"cd:mv:example": "if [ ! -d \"example\" ]; then mkdir example && cd example; fi",
|
|
37
|
-
"
|
|
37
|
+
"release": "standard-version",
|
|
38
|
+
"version": "npm run release && npm run list:directory:tree:examples && git add .",
|
|
39
|
+
"remove:node_modules": "if [ -d \"example/express/node_modules\" ]; then rm -rf example/express/node_modules; fi && if [ -d \"example/express-graphql/node_modules\" ]; then rm -rf example/express-graphql/node_modules; fi && if [ -d \"example/fastify/node_modules\" ]; then rm -rf example/fastify/node_modules; fi && if [ -d \"example/fastify-graphql/node_modules\" ]; then rm -rf example/fastify-graphql/node_modules; fi",
|
|
40
|
+
"list:directory:tree:express": "npm run remove:node_modules && if [ -f \"projectStructureExamples/express.txt\" ]; then rm projectStructureExamples/express.txt; fi && tree example/express -a --dirsfirst --sort name -I node_modules | cut -d'/' -f 2 | head -n -2 >> projectStructureExamples/express.txt",
|
|
41
|
+
"list:directory:tree:express-graphql": "npm run remove:node_modules && if [ -f \"projectStructureExamples/express-graphql.txt\" ]; then rm projectStructureExamples/express-graphql.txt; fi && tree example/express -a --dirsfirst --sort name -I node_modules | cut -d'/' -f 2 | head -n -2 >> projectStructureExamples/express-graphql.txt",
|
|
42
|
+
"list:directory:tree:fastify": "npm run remove:node_modules && if [ -f \"projectStructureExamples/fastify.txt\" ]; then rm projectStructureExamples/fastify.txt; fi && tree example/express -a --dirsfirst --sort name -I node_modules | cut -d'/' -f 2 | head -n -2 >> projectStructureExamples/fastify.txt",
|
|
43
|
+
"list:directory:tree:fastify-graphql": "npm run remove:node_modules && if [ -f \"projectStructureExamples/fastify-graphql.txt\" ]; then rm projectStructureExamples/fastify-graphql.txt; fi && tree example/express -a --dirsfirst --sort name -I node_modules | cut -d'/' -f 2 | head -n -2 >> projectStructureExamples/fastify-graphql.txt",
|
|
44
|
+
"list:directory:tree:examples": "npm run list:directory:tree:express && npm run list:directory:tree:express-graphql && npm run list:directory:tree:fastify && npm run list:directory:tree:fastify-graphql"
|
|
38
45
|
},
|
|
39
46
|
"bin": {
|
|
40
47
|
"simba": "./bin/index.js"
|