@anthonylzq/simba.js 6.0.0 → 6.2.1
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 +74 -305
- 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 +10 -3
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)
|
|
@@ -39,8 +40,10 @@ By doing this your prompt will ask you the following questions:
|
|
|
39
40
|
- `Project version (0.1.0):` the initial version of the project, `0.1.0` as default.
|
|
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
|
-
- `Will this project use GraphQL?
|
|
43
|
-
- `Will this project be deployed with Heroku? [y/n]
|
|
43
|
+
- `Will this project use GraphQL? [y/n]:`, yes or no question, only **y** or **n** is accepted. This is not case sensitive.
|
|
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]:`.
|
|
44
47
|
|
|
45
48
|
The second option you have is by passing flags in one single command. If you need help, please run:
|
|
46
49
|
|
|
@@ -55,33 +58,40 @@ This will generate the following output:
|
|
|
55
58
|
to be asked for the options one by one
|
|
56
59
|
|
|
57
60
|
Options:
|
|
58
|
-
-N, --projectName
|
|
59
|
-
-D, --projectDescription
|
|
60
|
-
-a, --author
|
|
61
|
-
-e, --email
|
|
62
|
-
-H, --heroku
|
|
63
|
-
|
|
64
|
-
-l, --license
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
67
70
|
[default: "unlicensed"]
|
|
68
|
-
-v, --version
|
|
69
|
-
-y, --licenseYear
|
|
70
|
-
-n, --npm
|
|
71
|
-
|
|
72
|
-
-f, --mainFile
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
75
79
|
[boolean] [default: false]
|
|
76
|
-
-F, --fastify
|
|
77
|
-
|
|
78
|
-
-g, --graphql
|
|
79
|
-
|
|
80
|
-
-
|
|
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]
|
|
81
91
|
|
|
82
92
|
Examples:
|
|
83
93
|
simba -N 'Project Name' -D 'Project description' -a Anthony -e
|
|
84
|
-
sluzquinosa@uni.pe
|
|
94
|
+
sluzquinosa@uni.pe -l mit -F --tests --ghat
|
|
85
95
|
|
|
86
96
|
Developed by AnthonyLzq
|
|
87
97
|
```
|
|
@@ -120,289 +130,20 @@ Finally, you may not want to use a license or one of the available licenses, don
|
|
|
120
130
|
simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
|
|
121
131
|
```
|
|
122
132
|
|
|
123
|
-
#### Why didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
|
|
133
|
+
#### Why I didn't you use [`TypeGraphQL`](https://typegraphql.com/)?
|
|
124
134
|
|
|
125
135
|
[They don't support GraphQL v16.x.x](https://github.com/MichalLytek/type-graphql/issues/1100), until then.
|
|
126
136
|
|
|
127
137
|
## <a name="project-structure"></a>Project structure
|
|
128
138
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Express case
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
📂node_modules
|
|
135
|
-
📂src
|
|
136
|
-
┣ 📂@types
|
|
137
|
-
┃ ┣ 📂custom
|
|
138
|
-
┃ ┃ ┣ 📜request.d.ts
|
|
139
|
-
┃ ┃ ┗ 📜response.d.ts
|
|
140
|
-
┃ ┣ 📂models
|
|
141
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
142
|
-
┃ ┗ 📜index.d.ts
|
|
143
|
-
┣ 📂database
|
|
144
|
-
┃ ┣ 📂mongo
|
|
145
|
-
┃ ┃ ┣ 📂models
|
|
146
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
147
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
148
|
-
┃ ┃ ┣ 📂queries
|
|
149
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
150
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
151
|
-
┃ ┃ ┗ 📜index.ts
|
|
152
|
-
┃ ┗ 📜index.ts
|
|
153
|
-
┣ 📂network
|
|
154
|
-
┃ ┣ 📂routes
|
|
155
|
-
┃ ┃ ┣ 📂utils
|
|
156
|
-
┃ ┃ ┃ ┗ 📜index.ts
|
|
157
|
-
┃ ┃ ┣ 📜home.ts
|
|
158
|
-
┃ ┃ ┣ 📜index.ts
|
|
159
|
-
┃ ┃ ┗ 📜user.ts
|
|
160
|
-
┃ ┣ 📜index.ts
|
|
161
|
-
┃ ┣ 📜response.ts
|
|
162
|
-
┃ ┣ 📜routes.ts
|
|
163
|
-
┃ ┗ 📜server.ts
|
|
164
|
-
┣ 📂schemas
|
|
165
|
-
┃ ┣ 📜index.ts
|
|
166
|
-
┃ ┗ 📜user.ts
|
|
167
|
-
┣ 📂services
|
|
168
|
-
┃ ┣ 📂utils
|
|
169
|
-
┃ ┃ ┣ 📂messages
|
|
170
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
171
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
172
|
-
┃ ┃ ┗ 📜index.ts
|
|
173
|
-
┃ ┣ 📜index.ts
|
|
174
|
-
┃ ┗ 📜user.ts
|
|
175
|
-
┣ 📂utils
|
|
176
|
-
┃ ┣ 📜docs.json
|
|
177
|
-
┃ ┗ 📜index.ts
|
|
178
|
-
┗ 📜index.ts
|
|
179
|
-
📜.env
|
|
180
|
-
📜.eslintignore
|
|
181
|
-
📜.eslintrc
|
|
182
|
-
📜.gitignore
|
|
183
|
-
📜CHANGELOG.md
|
|
184
|
-
📜Dockerfile
|
|
185
|
-
📜heroku.yml
|
|
186
|
-
📜index.http
|
|
187
|
-
📜LICENSE
|
|
188
|
-
📜nodemon.json
|
|
189
|
-
📜package.json
|
|
190
|
-
📜README.md
|
|
191
|
-
📜index.http
|
|
192
|
-
📜tsconfig.base.json
|
|
193
|
-
📜tsconfig.json
|
|
194
|
-
📜webpack.config.js
|
|
195
|
-
📜yarn.lock (or package-lock.json)
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 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.
|
|
199
140
|
|
|
200
|
-
|
|
201
|
-
📂node_modules
|
|
202
|
-
📂src
|
|
203
|
-
┣ 📂@types
|
|
204
|
-
┃ ┣ 📂custom
|
|
205
|
-
┃ ┃ ┣ 📜request.d.ts
|
|
206
|
-
┃ ┃ ┗ 📜response.d.ts
|
|
207
|
-
┃ ┣ 📂graphQL
|
|
208
|
-
┃ ┃ ┗ 📜context.d.ts
|
|
209
|
-
┃ ┣ 📂models
|
|
210
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
211
|
-
┃ ┗ 📜index.d.ts
|
|
212
|
-
┣ 📂database
|
|
213
|
-
┃ ┣ 📂mongo
|
|
214
|
-
┃ ┃ ┣ 📂models
|
|
215
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
216
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
217
|
-
┃ ┃ ┣ 📂queries
|
|
218
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
219
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
220
|
-
┃ ┃ ┗ 📜index.ts
|
|
221
|
-
┃ ┗ 📜index.ts
|
|
222
|
-
┣ 📂graphQL
|
|
223
|
-
┃ ┣ 📂models
|
|
224
|
-
┃ ┃ ┣ 📂User
|
|
225
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
226
|
-
┃ ┃ ┃ ┣ 📜mutations.ts
|
|
227
|
-
┃ ┃ ┃ ┣ 📜mutationsResolver.ts
|
|
228
|
-
┃ ┃ ┃ ┣ 📜queries.ts
|
|
229
|
-
┃ ┃ ┃ ┣ 📜queriesResolver.ts
|
|
230
|
-
┃ ┃ ┃ ┣ 📜schemas.ts
|
|
231
|
-
┃ ┃ ┃ ┗ 📜typeDefs.ts
|
|
232
|
-
┃ ┃ ┣ 📂utils
|
|
233
|
-
┃ ┃ ┃ ┣ 📂messages
|
|
234
|
-
┃ ┃ ┃ ┃ ┣ 📜index.ts
|
|
235
|
-
┃ ┃ ┃ ┃ ┗ 📜user.ts
|
|
236
|
-
┃ ┃ ┃ ┗ 📜index.ts
|
|
237
|
-
┃ ┃ ┗ 📜index.ts
|
|
238
|
-
┃ ┗ 📜index.ts
|
|
239
|
-
┣ 📂network
|
|
240
|
-
┃ ┣ 📂routes
|
|
241
|
-
┃ ┃ ┣ 📂utils
|
|
242
|
-
┃ ┃ ┃ ┗ 📜index.ts
|
|
243
|
-
┃ ┃ ┣ 📜home.ts
|
|
244
|
-
┃ ┃ ┣ 📜index.ts
|
|
245
|
-
┃ ┣ 📜index.ts
|
|
246
|
-
┃ ┣ 📜response.ts
|
|
247
|
-
┃ ┣ 📜routes.ts
|
|
248
|
-
┃ ┗ 📜server.ts
|
|
249
|
-
┣ 📂schemas
|
|
250
|
-
┃ ┣ 📜index.ts
|
|
251
|
-
┃ ┗ 📜user.ts
|
|
252
|
-
┣ 📂utils
|
|
253
|
-
┃ ┣ 📜docs.json
|
|
254
|
-
┃ ┗ 📜index.ts
|
|
255
|
-
┗ 📜index.ts
|
|
256
|
-
📜.env
|
|
257
|
-
📜.eslintignore
|
|
258
|
-
📜.eslintrc
|
|
259
|
-
📜.gitignore
|
|
260
|
-
📜CHANGELOG.md
|
|
261
|
-
📜Dockerfile
|
|
262
|
-
📜heroku.yml
|
|
263
|
-
📜LICENSE
|
|
264
|
-
📜nodemon.json
|
|
265
|
-
📜package.json
|
|
266
|
-
📜README.md
|
|
267
|
-
📜tsconfig.base.json
|
|
268
|
-
📜tsconfig.json
|
|
269
|
-
📜webpack.config.js
|
|
270
|
-
📜yarn.lock (or package-lock.json)
|
|
271
|
-
```
|
|
141
|
+
Also, if you are interested in the folder structure of each case, please take a look at:
|
|
272
142
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
📂src
|
|
278
|
-
┣ 📂@types
|
|
279
|
-
┃ ┣ 📂models
|
|
280
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
281
|
-
┃ ┗ 📜index.d.ts
|
|
282
|
-
┣ 📂database
|
|
283
|
-
┃ ┣ 📂mongo
|
|
284
|
-
┃ ┃ ┣ 📂models
|
|
285
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
286
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
287
|
-
┃ ┃ ┣ 📂queries
|
|
288
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
289
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
290
|
-
┃ ┃ ┗ 📜index.ts
|
|
291
|
-
┃ ┗ 📜index.ts
|
|
292
|
-
┣ 📂network
|
|
293
|
-
┃ ┣ 📂routes
|
|
294
|
-
┃ ┃ ┣ 📂utils
|
|
295
|
-
┃ ┃ ┃ ┗ 📜docs.ts
|
|
296
|
-
┃ ┃ ┣ 📜docs.ts
|
|
297
|
-
┃ ┃ ┣ 📜home.ts
|
|
298
|
-
┃ ┃ ┣ 📜index.ts
|
|
299
|
-
┃ ┃ ┗ 📜user.ts
|
|
300
|
-
┃ ┣ 📜index.ts
|
|
301
|
-
┃ ┣ 📜response.ts
|
|
302
|
-
┃ ┣ 📜routes.ts
|
|
303
|
-
┃ ┗ 📜server.ts
|
|
304
|
-
┣ 📂schemas
|
|
305
|
-
┃ ┣ 📜index.ts
|
|
306
|
-
┃ ┗ 📜user.ts
|
|
307
|
-
┣ 📂services
|
|
308
|
-
┃ ┣ 📂utils
|
|
309
|
-
┃ ┃ ┣ 📂messages
|
|
310
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
311
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
312
|
-
┃ ┃ ┗ 📜index.ts
|
|
313
|
-
┃ ┣ 📜index.ts
|
|
314
|
-
┃ ┗ 📜user.ts
|
|
315
|
-
┗ 📜index.ts
|
|
316
|
-
📜.env
|
|
317
|
-
📜.eslintignore
|
|
318
|
-
📜.eslintrc
|
|
319
|
-
📜.gitignore
|
|
320
|
-
📜CHANGELOG.md
|
|
321
|
-
📜Dockerfile
|
|
322
|
-
📜heroku.yml
|
|
323
|
-
📜index.http
|
|
324
|
-
📜LICENSE
|
|
325
|
-
📜nodemon.json
|
|
326
|
-
📜package.json
|
|
327
|
-
📜README.md
|
|
328
|
-
📜index.http
|
|
329
|
-
📜tsconfig.base.json
|
|
330
|
-
📜tsconfig.json
|
|
331
|
-
📜webpack.config.js
|
|
332
|
-
📜yarn.lock (or package-lock.json)
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Fastify-GraphQL case
|
|
336
|
-
|
|
337
|
-
```
|
|
338
|
-
📂node_modules
|
|
339
|
-
📂src
|
|
340
|
-
┣ 📂@types
|
|
341
|
-
┃ ┣ 📂graphQL
|
|
342
|
-
┃ ┃ ┗ 📜context.d.ts
|
|
343
|
-
┃ ┣ 📂dto
|
|
344
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
345
|
-
┃ ┣ 📂models
|
|
346
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
347
|
-
┃ ┗ 📜index.d.ts
|
|
348
|
-
┣ 📂database
|
|
349
|
-
┃ ┣ 📂mongo
|
|
350
|
-
┃ ┃ ┣ 📂models
|
|
351
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
352
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
353
|
-
┃ ┃ ┣ 📂queries
|
|
354
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
355
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
356
|
-
┃ ┃ ┗ 📜index.ts
|
|
357
|
-
┃ ┗ 📜index.ts
|
|
358
|
-
┣ 📂graphQL
|
|
359
|
-
┃ ┣ 📂models
|
|
360
|
-
┃ ┃ ┣ 📂User
|
|
361
|
-
┃ ┃ ┃ ┣ 📜index.ts
|
|
362
|
-
┃ ┃ ┃ ┣ 📜mutations.ts
|
|
363
|
-
┃ ┃ ┃ ┣ 📜mutationsResolver.ts
|
|
364
|
-
┃ ┃ ┃ ┣ 📜queries.ts
|
|
365
|
-
┃ ┃ ┃ ┣ 📜queriesResolver.ts
|
|
366
|
-
┃ ┃ ┃ ┣ 📜schemas.ts
|
|
367
|
-
┃ ┃ ┃ ┗ 📜typeDefs.ts
|
|
368
|
-
┃ ┃ ┣ 📂utils
|
|
369
|
-
┃ ┃ ┃ ┣ 📂messages
|
|
370
|
-
┃ ┃ ┃ ┃ ┣ 📜index.ts
|
|
371
|
-
┃ ┃ ┃ ┃ ┗ 📜user.ts
|
|
372
|
-
┃ ┃ ┃ ┗ 📜index.ts
|
|
373
|
-
┃ ┃ ┗ 📜index.ts
|
|
374
|
-
┃ ┗ 📜index.ts
|
|
375
|
-
┣ 📂network
|
|
376
|
-
┃ ┣ 📂routes
|
|
377
|
-
┃ ┃ ┣ 📜docs.ts
|
|
378
|
-
┃ ┃ ┣ 📜home.ts
|
|
379
|
-
┃ ┃ ┣ 📜index.ts
|
|
380
|
-
┃ ┣ 📜index.ts
|
|
381
|
-
┃ ┣ 📜response.ts
|
|
382
|
-
┃ ┣ 📜routes.ts
|
|
383
|
-
┃ ┗ 📜server.ts
|
|
384
|
-
┣ 📂schemas
|
|
385
|
-
┃ ┣ 📜index.ts
|
|
386
|
-
┃ ┗ 📜user.ts
|
|
387
|
-
┗ 📜index.ts
|
|
388
|
-
📜.env
|
|
389
|
-
📜.eslintignore
|
|
390
|
-
📜.eslintrc
|
|
391
|
-
📜.gitignore
|
|
392
|
-
📜CHANGELOG.md
|
|
393
|
-
📜Dockerfile
|
|
394
|
-
📜heroku.yml
|
|
395
|
-
📜LICENSE
|
|
396
|
-
📜nodemon.json
|
|
397
|
-
📜package.json
|
|
398
|
-
📜README.md
|
|
399
|
-
📜tsconfig.base.json
|
|
400
|
-
📜tsconfig.json
|
|
401
|
-
📜webpack.config.js
|
|
402
|
-
📜yarn.lock (or package-lock.json)
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
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)
|
|
406
147
|
|
|
407
148
|
### Some considerations
|
|
408
149
|
|
|
@@ -446,16 +187,32 @@ If you want to check the content of the files, please check the [example](https:
|
|
|
446
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.
|
|
447
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.
|
|
448
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
|
+
|
|
449
209
|
## What is new?
|
|
450
210
|
|
|
451
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).
|
|
452
212
|
|
|
453
|
-
### Version
|
|
454
|
-
|
|
455
|
-
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
|
|
456
214
|
|
|
457
|
-
|
|
458
|
-
- 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.
|
|
459
216
|
|
|
460
217
|
## <a name="notes"></a>Notes
|
|
461
218
|
|
|
@@ -473,11 +230,13 @@ As `devDependencies`:
|
|
|
473
230
|
- [`@types/node`](https://www.npmjs.com/package/@types/node)
|
|
474
231
|
- [`@typescript-eslint/eslint-plugin`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
|
|
475
232
|
- [`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser)
|
|
233
|
+
- [`axios`](https://www.npmjs.com/package/axios)
|
|
476
234
|
- [`dotenv`](https://www.npmjs.com/package/dotenv)
|
|
477
235
|
- [`eslint`](https://www.npmjs.com/package/eslint)
|
|
478
236
|
- [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier)
|
|
479
237
|
- [`eslint-config-standard`](https://www.npmjs.com/package/eslint-config-standard)
|
|
480
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)
|
|
481
240
|
- [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier)
|
|
482
241
|
- [`nodemon`](https://www.npmjs.com/package/nodemon)
|
|
483
242
|
- [`prettier`](https://www.npmjs.com/package/prettier)
|
|
@@ -500,6 +259,16 @@ As `dependencies`:
|
|
|
500
259
|
- [`apollo-server-core`](https://www.npmjs.com/package/apollo-server-core)
|
|
501
260
|
- [`graphql`](https://www.npmjs.com/package/graphql)
|
|
502
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
|
+
|
|
503
272
|
### Express case
|
|
504
273
|
|
|
505
274
|
As `dependencies`:
|
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,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.1",
|
|
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
9
|
"release": "standard-version",
|
|
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",
|
|
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 && git restore .",
|
|
11
11
|
"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
12
|
"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
13
|
"build": "npm run rm && npm run build:express && npm run build:fastify && npm run build:express:graphql && npm run build:fastify:graphql",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"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
16
|
"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
17
|
"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",
|
|
18
|
+
"build:and:test:only": "npm run build && npm run test:only",
|
|
18
19
|
"lint": "eslint --ext js lib/ --fix",
|
|
19
20
|
"rm": "if [ -d \"example\" ]; then rm -rf example; fi",
|
|
20
21
|
"rm:express": "if [ -d \"example/express\" ]; then rm -rf example/express; fi",
|
|
@@ -34,7 +35,13 @@
|
|
|
34
35
|
"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
36
|
"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
37
|
"cd:mv:example": "if [ ! -d \"example\" ]; then mkdir example && cd example; fi",
|
|
37
|
-
"version": "npm run release && git add
|
|
38
|
+
"version": "npm run release && npm run list:directory:tree:examples && git add .",
|
|
39
|
+
"remove:node_modules": "if [ -f \"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 | 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 | 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 | 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 | 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"
|