@anthonylzq/simba.js 9.0.1 → 9.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 +59 -30
- package/lib/index.js +42 -5
- package/lib/src/functions/api/database.js +40 -218
- package/lib/src/functions/api/express.js +100 -604
- package/lib/src/functions/api/fastify.js +93 -645
- package/lib/src/functions/api/hono.js +157 -0
- package/lib/src/functions/api/index.js +37 -59
- package/lib/src/functions/api/schemas.js +20 -84
- package/lib/src/functions/api/services.js +28 -210
- package/lib/src/functions/api/utils.js +10 -432
- package/lib/src/functions/biome.js +3 -2
- package/lib/src/functions/changelog.js +5 -5
- package/lib/src/functions/docker.js +7 -39
- package/lib/src/functions/ghat.js +12 -94
- package/lib/src/functions/gitignore.js +3 -134
- package/lib/src/functions/index.js +1 -2
- package/lib/src/functions/license.js +10 -2
- package/lib/src/functions/packageJson.js +13 -37
- package/lib/src/functions/readme.js +6 -5
- package/lib/src/functions/tests.js +17 -320
- package/lib/src/functions/tsconfig.js +13 -114
- package/lib/src/index.js +45 -21
- package/lib/src/utils/entity.js +115 -0
- package/lib/src/utils/index.js +2 -0
- package/lib/src/utils/mkdirs.js +9 -0
- package/lib/src/utils/renderTemplate.js +22 -0
- package/lib/src/utils/titleCase.js +5 -10
- package/lib/src/utils/writeFile.js +3 -10
- package/lib/templates/api/database/connection.ts.ejs +40 -0
- package/lib/templates/api/database/db-index.ts.ejs +2 -0
- package/lib/templates/api/database/index.ts.ejs +1 -0
- package/lib/templates/api/database/queries-entity.ts.ejs +98 -0
- package/lib/templates/api/database/queries-index.ts.ejs +1 -0
- package/lib/templates/api/database/schema.prisma.ejs +25 -0
- package/lib/templates/api/express/network/index.ts.ejs +2 -0
- package/lib/templates/api/express/network/models/entity.ts.ejs +21 -0
- package/lib/templates/api/express/network/models/index.ts.ejs +1 -0
- package/lib/templates/api/express/network/resolvers/entity.ts.ejs +41 -0
- package/lib/templates/api/express/network/resolvers/index.ts.ejs +13 -0
- package/lib/templates/api/express/network/response.ts.ejs +17 -0
- package/lib/templates/api/express/network/router.ts.ejs +39 -0
- package/lib/templates/api/express/network/routes/docs.ts.ejs +43 -0
- package/lib/templates/api/express/network/routes/entity.ts.ejs +165 -0
- package/lib/templates/api/express/network/routes/home.ts.ejs +16 -0
- package/lib/templates/api/express/network/routes/index.ts.ejs +5 -0
- package/lib/templates/api/express/network/server.ts.ejs +139 -0
- package/lib/templates/api/express/network/utils/index.ts.ejs +45 -0
- package/lib/templates/api/express/types/graphQL/context.d.ts.ejs +3 -0
- package/lib/templates/api/express/types/index.d.ts.ejs +4 -0
- package/lib/templates/api/fastify/network/index.ts.ejs +2 -0
- package/lib/templates/api/fastify/network/models/entity.ts.ejs +21 -0
- package/lib/templates/api/fastify/network/models/index.ts.ejs +1 -0
- package/lib/templates/api/fastify/network/resolvers/entity.ts.ejs +41 -0
- package/lib/templates/api/fastify/network/resolvers/index.ts.ejs +13 -0
- package/lib/templates/api/fastify/network/response.ts.ejs +17 -0
- package/lib/templates/api/fastify/network/router.ts.ejs +36 -0
- package/lib/templates/api/fastify/network/routes/docs.ts.ejs +41 -0
- package/lib/templates/api/fastify/network/routes/entity.ts.ejs +116 -0
- package/lib/templates/api/fastify/network/routes/home.ts.ejs +15 -0
- package/lib/templates/api/fastify/network/routes/index.ts.ejs +5 -0
- package/lib/templates/api/fastify/network/server.ts.ejs +129 -0
- package/lib/templates/api/fastify/types/graphQL/context.d.ts.ejs +3 -0
- package/lib/templates/api/fastify/types/index.d.ts.ejs +4 -0
- package/lib/templates/api/hono/network/index.ts.ejs +2 -0
- package/lib/templates/api/hono/network/models/entity.ts.ejs +21 -0
- package/lib/templates/api/hono/network/models/index.ts.ejs +1 -0
- package/lib/templates/api/hono/network/resolvers/entity.ts.ejs +41 -0
- package/lib/templates/api/hono/network/resolvers/index.ts.ejs +13 -0
- package/lib/templates/api/hono/network/response.ts.ejs +18 -0
- package/lib/templates/api/hono/network/router.ts.ejs +45 -0
- package/lib/templates/api/hono/network/routes/docs.ts.ejs +39 -0
- package/lib/templates/api/hono/network/routes/entity.ts.ejs +104 -0
- package/lib/templates/api/hono/network/routes/home.ts.ejs +15 -0
- package/lib/templates/api/hono/network/routes/index.ts.ejs +5 -0
- package/lib/templates/api/hono/network/server.ts.ejs +160 -0
- package/lib/templates/api/hono/network/utils/index.ts.ejs +23 -0
- package/lib/templates/api/hono/types/graphQL/context.d.ts.ejs +3 -0
- package/lib/templates/api/hono/types/index.d.ts.ejs +4 -0
- package/lib/templates/api/schemas/entity.ts.ejs +43 -0
- package/lib/templates/api/schemas/id.ts.ejs +11 -0
- package/lib/templates/api/schemas/index.ts.ejs +2 -0
- package/lib/templates/api/services/BaseHttp.ts.ejs +73 -0
- package/lib/templates/api/services/entity.ts.ejs +75 -0
- package/lib/templates/api/services/index.ts.ejs +1 -0
- package/lib/templates/api/services/utils/index.ts.ejs +1 -0
- package/lib/templates/api/services/utils/messages/entity.ts.ejs +11 -0
- package/lib/templates/api/services/utils/messages/index.ts.ejs +6 -0
- package/lib/templates/api/utils/Logger.ts.ejs +41 -0
- package/lib/templates/api/utils/index.ts.ejs +1 -0
- package/lib/templates/config/.dockerignore.ejs +20 -0
- package/lib/templates/config/.env.ejs +3 -0
- package/lib/templates/config/.gitignore.ejs +129 -0
- package/lib/templates/config/CHANGELOG.md.ejs +1 -0
- package/lib/templates/config/Dockerfile.ejs +13 -0
- package/lib/templates/config/README.md.ejs +3 -0
- package/lib/templates/config/ghat/lint.yml.ejs +46 -0
- package/lib/templates/config/ghat/test.yml.ejs +29 -0
- package/lib/templates/config/index.ts.ejs +3 -0
- package/lib/templates/config/package.json.ejs +30 -0
- package/lib/templates/config/test/index.test.ts.ejs +260 -0
- package/lib/templates/config/tsconfig.base.json.ejs +43 -0
- package/lib/templates/config/tsconfig.json.ejs +16 -0
- package/lib/templates/config/vitest.config.ts.ejs +19 -0
- package/package.json +45 -17
- package/lib/src/functions/api/types.js +0 -108
- package/lib/src/functions/eslint.js +0 -125
|
@@ -1,441 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { promisify } = require('node:util')
|
|
3
|
-
const exec = promisify(require('node:child_process').exec)
|
|
1
|
+
const mkdirs = require('../../utils/mkdirs')
|
|
4
2
|
const writeFile = require('../../utils/writeFile')
|
|
3
|
+
const { renderTemplate } = require('../../utils/renderTemplate')
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @param {Object} args
|
|
8
|
-
* @param {Boolean} args.fastify
|
|
9
7
|
* @param {String} args.projectName
|
|
10
|
-
* @param {String} args.email
|
|
11
|
-
* @param {String} args.projectVersion
|
|
12
|
-
* @param {String} args.graphQL
|
|
13
8
|
*/
|
|
14
|
-
module.exports = async ({
|
|
15
|
-
|
|
16
|
-
projectName,
|
|
17
|
-
email,
|
|
18
|
-
projectVersion,
|
|
19
|
-
graphQL
|
|
20
|
-
}) => {
|
|
21
|
-
const createFoldersCommand = `mkdir ${projectName}/src/utils`
|
|
9
|
+
module.exports = async ({ projectName }) => {
|
|
10
|
+
await mkdirs(`${projectName}/src/utils`)
|
|
22
11
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
else await exec(createFoldersCommand)
|
|
12
|
+
const t = (templatePath, data = {}) =>
|
|
13
|
+
renderTemplate(`api/utils/${templatePath}`, data)
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
index
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}export * from './Logger'\n`,
|
|
32
|
-
file: `${projectName}/src/utils/index.ts`
|
|
33
|
-
},
|
|
34
|
-
logger: {
|
|
35
|
-
content: `import { type Debugger } from 'debug'
|
|
36
|
-
|
|
37
|
-
export interface Log {
|
|
38
|
-
log({
|
|
39
|
-
origin,
|
|
40
|
-
method,
|
|
41
|
-
value,
|
|
42
|
-
content
|
|
43
|
-
}: {
|
|
44
|
-
origin?: string
|
|
45
|
-
method: string
|
|
46
|
-
value: string
|
|
47
|
-
content: unknown
|
|
48
|
-
}): void
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
class Logger implements Log {
|
|
52
|
-
#debug: Debugger
|
|
53
|
-
|
|
54
|
-
constructor(debug: Debugger) {
|
|
55
|
-
this.#debug = debug
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
log({
|
|
59
|
-
origin,
|
|
60
|
-
method,
|
|
61
|
-
value,
|
|
62
|
-
content
|
|
63
|
-
}: {
|
|
64
|
-
origin: string
|
|
65
|
-
method: string
|
|
66
|
-
value: string
|
|
67
|
-
content: unknown
|
|
68
|
-
}) {
|
|
69
|
-
this.#debug(
|
|
70
|
-
\`\${origin} -> \${method} ~ value: \${value} ~ content: \${JSON.stringify(
|
|
71
|
-
content
|
|
72
|
-
)}\`
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { Logger }\n`,
|
|
78
|
-
file: `${projectName}/src/utils/Logger.ts`
|
|
79
|
-
},
|
|
80
|
-
...(!fastify && {
|
|
81
|
-
docs: {
|
|
82
|
-
content: `{
|
|
83
|
-
"openapi": "3.0.0",
|
|
84
|
-
"info": {
|
|
85
|
-
"title": "${projectName}",
|
|
86
|
-
"description": "Documentation of the test",
|
|
87
|
-
"contact": {
|
|
88
|
-
"email": "${email}"
|
|
89
|
-
},
|
|
90
|
-
"license": {
|
|
91
|
-
"name": "MIT",
|
|
92
|
-
"url": "https://opensource.org/licenses/MIT"
|
|
93
|
-
},
|
|
94
|
-
"version": "${projectVersion}"
|
|
95
|
-
},
|
|
96
|
-
"servers": [
|
|
97
|
-
{
|
|
98
|
-
"url": "http://localhost:1996/api",
|
|
99
|
-
"description": "${projectName} local API"
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
"tags": [
|
|
103
|
-
{
|
|
104
|
-
"name": "user",
|
|
105
|
-
"description": "Operations related to the user"
|
|
106
|
-
}
|
|
107
|
-
]${
|
|
108
|
-
!graphQL
|
|
109
|
-
? `,
|
|
110
|
-
"paths": {
|
|
111
|
-
"/users": {
|
|
112
|
-
"post": {
|
|
113
|
-
"tags": [
|
|
114
|
-
"user"
|
|
115
|
-
],
|
|
116
|
-
"summary": "Save a user in the database",
|
|
117
|
-
"operationId": "store",
|
|
118
|
-
"requestBody": {
|
|
119
|
-
"$ref": "#/components/requestBodies/UserDTO"
|
|
120
|
-
},
|
|
121
|
-
"responses": {
|
|
122
|
-
"201": {
|
|
123
|
-
"description": "User successfully stored",
|
|
124
|
-
"content": {
|
|
125
|
-
"application/json": {
|
|
126
|
-
"schema": {
|
|
127
|
-
"$ref": "#/components/schemas/User"
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
"422": {
|
|
133
|
-
"description": "Invalid request format",
|
|
134
|
-
"content": {
|
|
135
|
-
"application/json": {
|
|
136
|
-
"schema": {
|
|
137
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
"500": {
|
|
143
|
-
"description": "Internal server error",
|
|
144
|
-
"content": {
|
|
145
|
-
"application/json": {
|
|
146
|
-
"schema": {
|
|
147
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
"/user/{id}": {
|
|
156
|
-
"get": {
|
|
157
|
-
"tags": [
|
|
158
|
-
"user"
|
|
159
|
-
],
|
|
160
|
-
"summary": "Get an specific user",
|
|
161
|
-
"operationId": "getOne",
|
|
162
|
-
"parameters": [
|
|
163
|
-
{
|
|
164
|
-
"name": "id",
|
|
165
|
-
"in": "path",
|
|
166
|
-
"description": "MongoDB user id",
|
|
167
|
-
"required": true,
|
|
168
|
-
"style": "simple",
|
|
169
|
-
"explode": false,
|
|
170
|
-
"schema": {
|
|
171
|
-
"type": "string"
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
"responses": {
|
|
176
|
-
"200": {
|
|
177
|
-
"description": "User stored in the database",
|
|
178
|
-
"content": {
|
|
179
|
-
"application/json": {
|
|
180
|
-
"schema": {
|
|
181
|
-
"$ref": "#/components/schemas/User"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
"404": {
|
|
187
|
-
"description": "User not found",
|
|
188
|
-
"content": {
|
|
189
|
-
"application/json": {
|
|
190
|
-
"schema": {
|
|
191
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
"422": {
|
|
197
|
-
"description": "Invalid request format",
|
|
198
|
-
"content": {
|
|
199
|
-
"application/json": {
|
|
200
|
-
"schema": {
|
|
201
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
"500": {
|
|
207
|
-
"description": "Internal server error",
|
|
208
|
-
"content": {
|
|
209
|
-
"application/json": {
|
|
210
|
-
"schema": {
|
|
211
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"patch": {
|
|
219
|
-
"tags": [
|
|
220
|
-
"user"
|
|
221
|
-
],
|
|
222
|
-
"summary": "Update the user data",
|
|
223
|
-
"operationId": "update",
|
|
224
|
-
"parameters": [
|
|
225
|
-
{
|
|
226
|
-
"name": "id",
|
|
227
|
-
"in": "path",
|
|
228
|
-
"description": "MongoDB user id",
|
|
229
|
-
"required": true,
|
|
230
|
-
"style": "simple",
|
|
231
|
-
"explode": false,
|
|
232
|
-
"schema": {
|
|
233
|
-
"type": "string"
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
"requestBody": {
|
|
238
|
-
"$ref": "#/components/requestBodies/UserDTO"
|
|
239
|
-
},
|
|
240
|
-
"responses": {
|
|
241
|
-
"200": {
|
|
242
|
-
"description": "User successfully updated",
|
|
243
|
-
"content": {
|
|
244
|
-
"application/json": {
|
|
245
|
-
"schema": {
|
|
246
|
-
"$ref": "#/components/schemas/User"
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
"404": {
|
|
252
|
-
"description": "User not found",
|
|
253
|
-
"content": {
|
|
254
|
-
"application/json": {
|
|
255
|
-
"schema": {
|
|
256
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
"422": {
|
|
262
|
-
"description": "Invalid request format",
|
|
263
|
-
"content": {
|
|
264
|
-
"application/json": {
|
|
265
|
-
"schema": {
|
|
266
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
"500": {
|
|
272
|
-
"description": "Internal server error",
|
|
273
|
-
"content": {
|
|
274
|
-
"application/json": {
|
|
275
|
-
"schema": {
|
|
276
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
"delete": {
|
|
284
|
-
"tags": [
|
|
285
|
-
"user"
|
|
286
|
-
],
|
|
287
|
-
"summary": "Delete one user from the database",
|
|
288
|
-
"operationId": "delete",
|
|
289
|
-
"parameters": [
|
|
290
|
-
{
|
|
291
|
-
"name": "id",
|
|
292
|
-
"in": "path",
|
|
293
|
-
"description": "MongoDB user id",
|
|
294
|
-
"required": true,
|
|
295
|
-
"style": "simple",
|
|
296
|
-
"explode": false,
|
|
297
|
-
"schema": {
|
|
298
|
-
"type": "string"
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
],
|
|
302
|
-
"responses": {
|
|
303
|
-
"200": {
|
|
304
|
-
"description": "User successfully deleted",
|
|
305
|
-
"content": {
|
|
306
|
-
"application/json": {
|
|
307
|
-
"schema": {
|
|
308
|
-
"$ref": "#/components/schemas/DefaultSuccess"
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
"404": {
|
|
314
|
-
"description": "User not found",
|
|
315
|
-
"content": {
|
|
316
|
-
"application/json": {
|
|
317
|
-
"schema": {
|
|
318
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
"422": {
|
|
324
|
-
"description": "Invalid request format",
|
|
325
|
-
"content": {
|
|
326
|
-
"application/json": {
|
|
327
|
-
"schema": {
|
|
328
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
"500": {
|
|
334
|
-
"description": "Internal server error",
|
|
335
|
-
"content": {
|
|
336
|
-
"application/json": {
|
|
337
|
-
"schema": {
|
|
338
|
-
"$ref": "#/components/schemas/DefaultError"
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
"components": {
|
|
348
|
-
"schemas": {
|
|
349
|
-
"User": {
|
|
350
|
-
"type": "object",
|
|
351
|
-
"properties": {
|
|
352
|
-
"id": {
|
|
353
|
-
"type": "string"
|
|
354
|
-
},
|
|
355
|
-
"lastName": {
|
|
356
|
-
"type": "string"
|
|
357
|
-
},
|
|
358
|
-
"name": {
|
|
359
|
-
"type": "string"
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
"DefaultSuccess": {
|
|
364
|
-
"type": "object",
|
|
365
|
-
"properties": {
|
|
366
|
-
"error": {
|
|
367
|
-
"type": "boolean",
|
|
368
|
-
"default": false
|
|
369
|
-
},
|
|
370
|
-
"message": {
|
|
371
|
-
"type": "object",
|
|
372
|
-
"properties": {
|
|
373
|
-
"result": {
|
|
374
|
-
"type": "string"
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
"DefaultError": {
|
|
381
|
-
"type": "object",
|
|
382
|
-
"properties": {
|
|
383
|
-
"error": {
|
|
384
|
-
"type": "boolean",
|
|
385
|
-
"default": true
|
|
386
|
-
},
|
|
387
|
-
"message": {
|
|
388
|
-
"type": "object",
|
|
389
|
-
"properties": {
|
|
390
|
-
"result": {
|
|
391
|
-
"type": "string"
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
},
|
|
398
|
-
"requestBodies": {
|
|
399
|
-
"UserDTO": {
|
|
400
|
-
"description": "User name and last name",
|
|
401
|
-
"content": {
|
|
402
|
-
"application/json": {
|
|
403
|
-
"schema": {
|
|
404
|
-
"type": "object",
|
|
405
|
-
"properties": {
|
|
406
|
-
"args": {
|
|
407
|
-
"type": "object",
|
|
408
|
-
"properties": {
|
|
409
|
-
"name": {
|
|
410
|
-
"type": "string"
|
|
411
|
-
},
|
|
412
|
-
"lastName": {
|
|
413
|
-
"type": "string"
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
"required": true
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}`
|
|
426
|
-
: '\n}'
|
|
427
|
-
}`,
|
|
428
|
-
file: `${projectName}/src/utils/docs.json`
|
|
429
|
-
}
|
|
430
|
-
})
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
const processes = [
|
|
434
|
-
writeFile(utils.index.file, utils.index.content),
|
|
435
|
-
writeFile(utils.logger.file, utils.logger.content)
|
|
436
|
-
]
|
|
437
|
-
|
|
438
|
-
if (!fastify) processes.push(writeFile(utils.docs.file, utils.docs.content))
|
|
439
|
-
|
|
440
|
-
await Promise.all(processes)
|
|
15
|
+
await Promise.all([
|
|
16
|
+
writeFile(`${projectName}/src/utils/index.ts`, t('index.ts.ejs')),
|
|
17
|
+
writeFile(`${projectName}/src/utils/Logger.ts`, t('Logger.ts.ejs'))
|
|
18
|
+
])
|
|
441
19
|
}
|
|
@@ -76,7 +76,8 @@ module.exports = async ({ projectName }) => {
|
|
|
76
76
|
// En Biome 2.1.3, los decoradores de TypeScript se configuran diferente
|
|
77
77
|
// Si necesitas decoradores para GraphQL, se pueden habilitar via tsconfig.json
|
|
78
78
|
|
|
79
|
-
// Configuración específica para
|
|
79
|
+
// Configuración específica para archivos de test
|
|
80
|
+
// Vitest usa imports explícitos, pero mantenemos globals por compatibilidad
|
|
80
81
|
biomeConfig.overrides = [
|
|
81
82
|
{
|
|
82
83
|
includes: [
|
|
@@ -95,7 +96,7 @@ module.exports = async ({ projectName }) => {
|
|
|
95
96
|
'afterAll',
|
|
96
97
|
'beforeEach',
|
|
97
98
|
'afterEach',
|
|
98
|
-
'
|
|
99
|
+
'vi'
|
|
99
100
|
]
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const writeFile = require('../utils/writeFile')
|
|
2
2
|
const titleCase = require('../utils/titleCase')
|
|
3
|
+
const { renderTemplate } = require('../utils/renderTemplate')
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @param {String} projectName
|
|
6
7
|
* @returns {Promise<void>}
|
|
7
8
|
*/
|
|
8
9
|
module.exports = async projectName => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
const content = renderTemplate('config/CHANGELOG.md.ejs', {
|
|
11
|
+
titleCaseName: titleCase(projectName)
|
|
12
|
+
})
|
|
13
13
|
|
|
14
|
-
await writeFile(`${projectName}
|
|
14
|
+
await writeFile(`${projectName}/CHANGELOG.md`, content)
|
|
15
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const writeFile = require('../utils/writeFile')
|
|
2
|
+
const { renderTemplate } = require('../utils/renderTemplate')
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @param {Object} args
|
|
@@ -10,47 +11,14 @@ const writeFile = require('../utils/writeFile')
|
|
|
10
11
|
module.exports = async ({ projectName, manager }) => {
|
|
11
12
|
const managerName = manager.split(' ')[0]
|
|
12
13
|
|
|
13
|
-
const data = {
|
|
14
|
-
dockerContent: `FROM node:18-alpine
|
|
15
|
-
${managerName === 'pnpm' ? '\nRUN corepack enable\n' : ''}
|
|
16
|
-
WORKDIR /app
|
|
17
|
-
|
|
18
|
-
COPY . ./
|
|
19
|
-
|
|
20
|
-
RUN ${
|
|
21
|
-
managerName === 'yarn' ? 'yarn' : managerName === 'npm' ? 'npm' : 'pnpm'
|
|
22
|
-
} i
|
|
23
|
-
|
|
24
|
-
CMD [ "${managerName}", "start" ]`,
|
|
25
|
-
dockerFile: 'Dockerfile',
|
|
26
|
-
dockerIgnoreContent: `.eslintignore
|
|
27
|
-
.eslintrc
|
|
28
|
-
|
|
29
|
-
.git
|
|
30
|
-
.gitignore
|
|
31
|
-
.github
|
|
32
|
-
|
|
33
|
-
*.md
|
|
34
|
-
LICENSE
|
|
35
|
-
|
|
36
|
-
*.http
|
|
37
|
-
nodemon.json
|
|
38
|
-
|
|
39
|
-
jest.config.ts
|
|
40
|
-
*.log
|
|
41
|
-
|
|
42
|
-
test
|
|
43
|
-
|
|
44
|
-
# optionally you may want to ignore the .env file, but that depends on your own implementation
|
|
45
|
-
.env`,
|
|
46
|
-
dockerIgnoreFile: '.dockerignore'
|
|
47
|
-
}
|
|
48
|
-
|
|
49
14
|
await Promise.all([
|
|
50
|
-
writeFile(`${projectName}/${data.dockerFile}`, data.dockerContent),
|
|
51
15
|
writeFile(
|
|
52
|
-
`${projectName}
|
|
53
|
-
|
|
16
|
+
`${projectName}/Dockerfile`,
|
|
17
|
+
renderTemplate('config/Dockerfile.ejs', { managerName })
|
|
18
|
+
),
|
|
19
|
+
writeFile(
|
|
20
|
+
`${projectName}/.dockerignore`,
|
|
21
|
+
renderTemplate('config/.dockerignore.ejs')
|
|
54
22
|
)
|
|
55
23
|
])
|
|
56
24
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { promisify } = require('node:util')
|
|
3
|
-
const exec = promisify(require('node:child_process').exec)
|
|
1
|
+
const mkdirs = require('../utils/mkdirs')
|
|
4
2
|
const writeFile = require('../utils/writeFile')
|
|
3
|
+
const { renderTemplate } = require('../utils/renderTemplate')
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @param {String} projectName
|
|
@@ -9,13 +8,9 @@ const writeFile = require('../utils/writeFile')
|
|
|
9
8
|
* @returns {Promise<void>}
|
|
10
9
|
*/
|
|
11
10
|
module.exports = async (projectName, manager) => {
|
|
12
|
-
const createFoldersCommand = `mkdir ${projectName}/.github \
|
|
13
|
-
${projectName}/.github/workflows`
|
|
14
11
|
const managerName = manager.split(' ')[0]
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
await exec(createFoldersCommand.replaceAll('/', '\\'))
|
|
18
|
-
else await exec(createFoldersCommand)
|
|
13
|
+
await mkdirs(`${projectName}/.github/workflows`)
|
|
19
14
|
|
|
20
15
|
const installCmd =
|
|
21
16
|
managerName === 'yarn'
|
|
@@ -42,93 +37,16 @@ ${projectName}/.github/workflows`
|
|
|
42
37
|
version: 9.x.x\n`
|
|
43
38
|
: ''
|
|
44
39
|
|
|
45
|
-
const data = {
|
|
46
|
-
linting: {
|
|
47
|
-
content: `name: Lint - ${projectName}
|
|
48
|
-
|
|
49
|
-
on: [push]
|
|
50
|
-
|
|
51
|
-
jobs:
|
|
52
|
-
run-linters:
|
|
53
|
-
name: Run linters
|
|
54
|
-
runs-on: ubuntu-latest
|
|
55
|
-
|
|
56
|
-
steps:
|
|
57
|
-
- name: Check out Git repository
|
|
58
|
-
uses: actions/checkout@v4
|
|
59
|
-
with:
|
|
60
|
-
fetch-depth: 0
|
|
61
|
-
|
|
62
|
-
- name: Set up Node.js
|
|
63
|
-
uses: actions/setup-node@v4
|
|
64
|
-
with:
|
|
65
|
-
node-version: 20.x
|
|
66
|
-
${pnpmSetup}
|
|
67
|
-
- name: Install Node.js dependencies
|
|
68
|
-
run: ${installCmd}
|
|
69
|
-
|
|
70
|
-
- name: Revert changes into the ${lockFile} file
|
|
71
|
-
run: git checkout -- ${lockFile}
|
|
72
|
-
|
|
73
|
-
- name: Run lint
|
|
74
|
-
run: ${runCmd} lint
|
|
75
|
-
|
|
76
|
-
- name: Check for changes
|
|
77
|
-
id: verify-changed-files
|
|
78
|
-
run: |
|
|
79
|
-
if [ -n "$(git status --porcelain)" ]; then
|
|
80
|
-
echo "changed=true" >> $GITHUB_OUTPUT
|
|
81
|
-
echo "✅ Changes detected after linting, preparing to commit..."
|
|
82
|
-
else
|
|
83
|
-
echo "changed=false" >> $GITHUB_OUTPUT
|
|
84
|
-
echo "ℹ️ No changes after linting, nothing to do, skipping commit"
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
- name: Commit lint fixes
|
|
88
|
-
if: steps.verify-changed-files.outputs.changed == 'true'
|
|
89
|
-
uses: stefanzweifel/git-auto-commit-action@v6
|
|
90
|
-
with:
|
|
91
|
-
commit_message: 'feat: automated lint with biome'
|
|
92
|
-
file_pattern: '.'`,
|
|
93
|
-
file: `${projectName}/.github/workflows/lint.yml`
|
|
94
|
-
},
|
|
95
|
-
test: {
|
|
96
|
-
content: `name: Tests - ${projectName}
|
|
97
|
-
|
|
98
|
-
on: [push]
|
|
99
|
-
|
|
100
|
-
jobs:
|
|
101
|
-
test:
|
|
102
|
-
environment: Test
|
|
103
|
-
name: Testing Simba.js API
|
|
104
|
-
runs-on: ubuntu-latest
|
|
105
|
-
|
|
106
|
-
steps:
|
|
107
|
-
- name: Check out Git repository
|
|
108
|
-
uses: actions/checkout@v4
|
|
109
|
-
with:
|
|
110
|
-
fetch-depth: 0
|
|
111
|
-
|
|
112
|
-
- name: Set up Node.js
|
|
113
|
-
uses: actions/setup-node@v4
|
|
114
|
-
with:
|
|
115
|
-
node-version: 20.x
|
|
116
|
-
${pnpmSetup}
|
|
117
|
-
- name: Install Node.js dependencies
|
|
118
|
-
run: ${installCmd}
|
|
119
|
-
|
|
120
|
-
- name: Run test
|
|
121
|
-
run: ${runCmd} test:ci
|
|
122
|
-
env:
|
|
123
|
-
DATABASE_URL: \${{ secrets.DATABASE_URL }}
|
|
124
|
-
NODE_ENV: ci
|
|
125
|
-
`,
|
|
126
|
-
file: `${projectName}/.github/workflows/test.yml`
|
|
127
|
-
}
|
|
128
|
-
}
|
|
40
|
+
const data = { projectName, installCmd, lockFile, runCmd, pnpmSetup }
|
|
129
41
|
|
|
130
42
|
await Promise.all([
|
|
131
|
-
writeFile(
|
|
132
|
-
|
|
43
|
+
writeFile(
|
|
44
|
+
`${projectName}/.github/workflows/lint.yml`,
|
|
45
|
+
renderTemplate('config/ghat/lint.yml.ejs', data)
|
|
46
|
+
),
|
|
47
|
+
writeFile(
|
|
48
|
+
`${projectName}/.github/workflows/test.yml`,
|
|
49
|
+
renderTemplate('config/ghat/test.yml.ejs', data)
|
|
50
|
+
)
|
|
133
51
|
])
|
|
134
52
|
}
|