@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 +260 -210
- package/lib/index.js +42 -4
- package/lib/src/functions/api/database.js +139 -15
- package/lib/src/functions/api/index.js +4 -2
- package/lib/src/functions/api/network.js +159 -251
- package/lib/src/functions/api/schemas.js +18 -29
- package/lib/src/functions/api/services.js +7 -9
- package/lib/src/functions/api/types.js +0 -1
- package/lib/src/functions/docker.js +20 -4
- package/lib/src/functions/eslint.js +40 -12
- package/lib/src/functions/ghat.js +65 -0
- package/lib/src/functions/gitignore.js +1 -0
- package/lib/src/functions/packageJson.js +11 -2
- package/lib/src/functions/tests.js +615 -0
- package/lib/src/index.js +24 -13
- package/lib/src/utils/constants.js +3 -0
- package/package.json +38 -27
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
[](https://github.com/AnthonyLzq/simba.js/blob/master/LICENSE)
|
|
8
8
|
[](https://standardjs.com)
|
|
9
9
|
[](https://reactjs.org/docs/how-to-contribute.html#your-first-pull-request)
|
|
10
|
+
[](https://github.com/AnthonyLzq/simba.js/actions/workflows/lint.yml)
|
|
11
|
+
[](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?
|
|
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
|
|
57
|
-
-D, --projectDescription
|
|
58
|
-
-a, --author
|
|
59
|
-
-e, --email
|
|
60
|
-
-H, --heroku
|
|
61
|
-
|
|
62
|
-
-l, --license
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
67
|
-
-y, --licenseYear
|
|
68
|
-
-n, --npm
|
|
69
|
-
|
|
70
|
-
-f, --mainFile
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
75
|
-
|
|
76
|
-
-g, --graphql
|
|
77
|
-
|
|
78
|
-
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
┃ ┗ 📜index.ts
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
┃ ┃
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
┃
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
┃ ┃ ┗ 📜
|
|
171
|
-
┃
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
┃ ┗ 📜index.ts
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
┃ ┃
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
┃ ┃ ┃ ┗ 📜
|
|
235
|
-
┃ ┃ ┗ 📜index.ts
|
|
236
|
-
┃ ┗ 📜index.ts
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
┃ ┃
|
|
242
|
-
|
|
243
|
-
┃ ┣ 📜index.ts
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
┃ ┗ 📜index.ts
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
┃ ┃
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
┃
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
┃ ┃ ┗ 📜
|
|
311
|
-
┃
|
|
312
|
-
|
|
313
|
-
┗ 📜
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
┃ ┗ 📜index.ts
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
┃ ┃
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
┃ ┃ ┃ ┗ 📜
|
|
371
|
-
┃ ┃ ┗ 📜index.ts
|
|
372
|
-
┃ ┗ 📜index.ts
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
┃ ┣ 📜index.ts
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
┗ 📜
|
|
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
|
|
491
|
+
### Version 6.x.x
|
|
451
492
|
|
|
452
|
-
In this major version I would be focusing on adding
|
|
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)
|