@anthonylzq/simba.js 8.0.0 → 9.0.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/lib/src/functions/api/database.js +15 -17
- package/lib/src/functions/api/express.js +28 -53
- package/lib/src/functions/api/fastify.js +10 -10
- package/lib/src/functions/api/index.js +10 -50
- package/lib/src/functions/api/schemas.js +4 -5
- package/lib/src/functions/api/services.js +7 -11
- package/lib/src/functions/api/types.js +3 -3
- package/lib/src/functions/api/utils.js +6 -7
- package/lib/src/functions/biome.js +130 -0
- package/lib/src/functions/ghat.js +63 -49
- package/lib/src/functions/index.js +1 -1
- package/lib/src/functions/license.js +4 -2
- package/lib/src/functions/packageJson.js +1 -1
- package/lib/src/functions/tests.js +3 -3
- package/lib/src/functions/tsconfig.js +16 -21
- package/lib/src/index.js +11 -20
- package/lib/src/utils/writeFile.js +1 -1
- package/package.json +38 -39
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
const dbPrismaName = {
|
|
@@ -50,13 +50,11 @@ datasource db {
|
|
|
50
50
|
model User {
|
|
51
51
|
${
|
|
52
52
|
isMongo
|
|
53
|
-
?
|
|
54
|
-
|
|
55
|
-
name String`
|
|
56
|
-
: `id Int @id @default(autoincrement())
|
|
57
|
-
lastName String
|
|
58
|
-
name String`
|
|
53
|
+
? 'id String @id @default(auto()) @map("_id") @db.ObjectId'
|
|
54
|
+
: 'id Int @id @default(autoincrement())'
|
|
59
55
|
}
|
|
56
|
+
lastName String
|
|
57
|
+
name String
|
|
60
58
|
|
|
61
59
|
createdAt DateTime @default(now())
|
|
62
60
|
updatedAt DateTime @updatedAt
|
|
@@ -78,7 +76,7 @@ export * from './queries'\n`,
|
|
|
78
76
|
},
|
|
79
77
|
connection: {
|
|
80
78
|
content: `import { PrismaClient } from '@prisma/client'
|
|
81
|
-
import { Debugger } from 'debug'
|
|
79
|
+
import { type Debugger } from 'debug'
|
|
82
80
|
|
|
83
81
|
let dbConnected = false
|
|
84
82
|
|
|
@@ -132,14 +130,14 @@ import { dbConnection } from '../connection'
|
|
|
132
130
|
import { Id, User as UserSchema, UserDTO } from 'schemas'
|
|
133
131
|
import { Logger } from 'utils'
|
|
134
132
|
|
|
135
|
-
const
|
|
133
|
+
const logger = new Logger(debug('App:Database:Queries:User'))
|
|
136
134
|
|
|
137
|
-
const userDBOtoDTO = (userDBO: User)
|
|
135
|
+
const userDBOtoDTO = (userDBO: User) =>
|
|
138
136
|
({
|
|
139
137
|
...userDBO,
|
|
140
138
|
createdAt: userDBO.createdAt.toISOString(),
|
|
141
139
|
updatedAt: userDBO.updatedAt.toISOString()
|
|
142
|
-
})
|
|
140
|
+
}) satisfies UserDTO
|
|
143
141
|
|
|
144
142
|
const store = async (userData: UserSchema) => {
|
|
145
143
|
try {
|
|
@@ -150,7 +148,7 @@ const store = async (userData: UserSchema) => {
|
|
|
150
148
|
|
|
151
149
|
return userDBOtoDTO(user)
|
|
152
150
|
} catch (error) {
|
|
153
|
-
|
|
151
|
+
logger.log({
|
|
154
152
|
origin: 'queries/user.ts',
|
|
155
153
|
method: store.name,
|
|
156
154
|
value: 'error',
|
|
@@ -170,7 +168,7 @@ const removeById = async (id: Id) => {
|
|
|
170
168
|
|
|
171
169
|
return true
|
|
172
170
|
} catch (error) {
|
|
173
|
-
|
|
171
|
+
logger.log({
|
|
174
172
|
origin: 'queries/user.ts',
|
|
175
173
|
method: removeById.name,
|
|
176
174
|
value: 'error',
|
|
@@ -192,7 +190,7 @@ const getById = async (id: Id) => {
|
|
|
192
190
|
|
|
193
191
|
return userDBOtoDTO(user)
|
|
194
192
|
} catch (error) {
|
|
195
|
-
|
|
193
|
+
logger.log({
|
|
196
194
|
origin: 'queries/user.ts',
|
|
197
195
|
method: getById.name,
|
|
198
196
|
value: 'error',
|
|
@@ -215,7 +213,7 @@ const update = async (id: Id, user: UserSchema) => {
|
|
|
215
213
|
|
|
216
214
|
return userDBOtoDTO(userUpdated)
|
|
217
215
|
} catch (error) {
|
|
218
|
-
|
|
216
|
+
logger.log({
|
|
219
217
|
origin: 'queries/user.ts',
|
|
220
218
|
method: update.name,
|
|
221
219
|
value: 'error',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
|
|
5
5
|
const db = require('./database')
|
|
6
6
|
const schemas = require('./schemas')
|
|
@@ -11,14 +11,11 @@ const utils = require('./utils')
|
|
|
11
11
|
/**
|
|
12
12
|
* @param {Object} args
|
|
13
13
|
* @param {String} args.projectName
|
|
14
|
-
* @param {Boolean} args.graphQL
|
|
15
14
|
* @param {Boolean} args.dbIsSQL
|
|
16
15
|
*/
|
|
17
|
-
const types = async ({ projectName,
|
|
18
|
-
const createFoldersCommand = `mkdir ${projectName}/src/@types
|
|
19
|
-
${!dbIsSQL ? ` ${projectName}/src/@types/models` : ''}
|
|
20
|
-
graphQL ? ` ${projectName}/src/@types/graphQL` : ''
|
|
21
|
-
}`
|
|
16
|
+
const types = async ({ projectName, dbIsSQL }) => {
|
|
17
|
+
const createFoldersCommand = `mkdir ${projectName}/src/@types \
|
|
18
|
+
${!dbIsSQL ? ` ${projectName}/src/@types/models` : ''}`
|
|
22
19
|
|
|
23
20
|
if (platform() === 'win32')
|
|
24
21
|
await exec(createFoldersCommand.replaceAll('/', '\\'))
|
|
@@ -32,36 +29,9 @@ declare global {}
|
|
|
32
29
|
export {}
|
|
33
30
|
`,
|
|
34
31
|
file: `${projectName}/src/@types/index.d.ts`
|
|
35
|
-
}
|
|
36
|
-
custom: {
|
|
37
|
-
params: {
|
|
38
|
-
content: `type Params = {
|
|
39
|
-
[key: string]: string
|
|
40
|
-
}\n`,
|
|
41
|
-
file: `${projectName}/src/@types/custom/params.d.ts`
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
...(graphQL && {
|
|
45
|
-
graphQL: {
|
|
46
|
-
context: {
|
|
47
|
-
content: `type Context = {
|
|
48
|
-
log: import('express-pino-logger').HttpLogger['logger']
|
|
49
|
-
}
|
|
50
|
-
`,
|
|
51
|
-
file: `${projectName}/src/@types/graphQL/context.d.ts`
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
32
|
+
}
|
|
55
33
|
}
|
|
56
|
-
const processes = [
|
|
57
|
-
writeFile(types.index.file, types.index.content),
|
|
58
|
-
writeFile(types.custom.params.file, types.custom.params.content)
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
if (graphQL)
|
|
62
|
-
processes.push(
|
|
63
|
-
writeFile(types.graphQL.context.file, types.graphQL.context.content)
|
|
64
|
-
)
|
|
34
|
+
const processes = [writeFile(types.index.file, types.index.content)]
|
|
65
35
|
|
|
66
36
|
await Promise.all(processes)
|
|
67
37
|
}
|
|
@@ -129,13 +99,13 @@ const applyRoutes = (app: Application): void => {
|
|
|
129
99
|
routers.forEach((router: Router): Application => app.use('/api', router))
|
|
130
100
|
|
|
131
101
|
// Handling 404 error
|
|
132
|
-
app.use((
|
|
102
|
+
app.use((_req, _res, next) => {
|
|
133
103
|
next(new httpErrors.NotFound('This route does not exists'))
|
|
134
104
|
})
|
|
135
105
|
app.use(
|
|
136
106
|
(
|
|
137
107
|
error: httpErrors.HttpError,
|
|
138
|
-
|
|
108
|
+
_req: Request,
|
|
139
109
|
res: Response,
|
|
140
110
|
next: NextFunction
|
|
141
111
|
) => {
|
|
@@ -156,18 +126,17 @@ export { applyRoutes }
|
|
|
156
126
|
},
|
|
157
127
|
server: {
|
|
158
128
|
content: graphQL
|
|
159
|
-
? `import { Server as HttpServer } from 'http'
|
|
129
|
+
? `import type { Server as HttpServer } from 'node:http'
|
|
160
130
|
import express from 'express'
|
|
161
131
|
import cors from 'cors'
|
|
162
132
|
import debug from 'debug'
|
|
163
133
|
import { ApolloServer } from '@apollo/server'
|
|
164
|
-
|
|
165
|
-
import { expressMiddleware } from '@apollo/server/express4'
|
|
134
|
+
import { expressMiddleware } from '@as-integrations/express5'
|
|
166
135
|
|
|
167
136
|
import { dbConnection } from 'database'
|
|
168
137
|
import { applyRoutes } from './router'
|
|
169
138
|
import { buildSchemas } from './resolvers'
|
|
170
|
-
import { Log } from 'utils'
|
|
139
|
+
import { type Log } from 'utils'
|
|
171
140
|
|
|
172
141
|
const d = debug('App:Network:Server')
|
|
173
142
|
const PORT = (process.env.PORT as string) || 1996
|
|
@@ -190,7 +159,7 @@ class Server implements Log {
|
|
|
190
159
|
this.#app.use(express.urlencoded({ extended: false }))
|
|
191
160
|
this.#app.use(
|
|
192
161
|
(
|
|
193
|
-
|
|
162
|
+
_req: express.Request,
|
|
194
163
|
res: express.Response,
|
|
195
164
|
next: express.NextFunction
|
|
196
165
|
) => {
|
|
@@ -270,14 +239,14 @@ class Server implements Log {
|
|
|
270
239
|
const server = new Server()
|
|
271
240
|
|
|
272
241
|
export { server as Server }\n`
|
|
273
|
-
: `import { Server as HttpServer } from 'http'
|
|
242
|
+
: `import type { Server as HttpServer } from 'node:http'
|
|
274
243
|
import express from 'express'
|
|
275
244
|
import cors from 'cors'
|
|
276
245
|
import debug from 'debug'
|
|
277
246
|
|
|
278
247
|
import { dbConnection } from 'database'
|
|
279
248
|
import { applyRoutes } from './router'
|
|
280
|
-
import { Log } from 'utils'
|
|
249
|
+
import { type Log } from 'utils'
|
|
281
250
|
|
|
282
251
|
const d = debug('App:Network:Server')
|
|
283
252
|
const PORT = (process.env.PORT as string) || 1996
|
|
@@ -298,7 +267,7 @@ class Server implements Log {
|
|
|
298
267
|
this.#app.use(express.urlencoded({ extended: false }))
|
|
299
268
|
this.#app.use(
|
|
300
269
|
(
|
|
301
|
-
|
|
270
|
+
_req: express.Request,
|
|
302
271
|
res: express.Response,
|
|
303
272
|
next: express.NextFunction
|
|
304
273
|
) => {
|
|
@@ -374,7 +343,7 @@ import { response } from 'network/response'
|
|
|
374
343
|
|
|
375
344
|
const Home = Router()
|
|
376
345
|
|
|
377
|
-
Home.route('').get((
|
|
346
|
+
Home.route('').get((_req: Request, res: Response) => {
|
|
378
347
|
response({
|
|
379
348
|
error: false,
|
|
380
349
|
message: 'Welcome to your Express Backend!',
|
|
@@ -406,7 +375,13 @@ const User = Router()
|
|
|
406
375
|
User.route('/users').post(
|
|
407
376
|
validatorCompiler(storeUserDto, 'body'),
|
|
408
377
|
async (
|
|
409
|
-
req: Request<
|
|
378
|
+
req: Request<
|
|
379
|
+
{
|
|
380
|
+
[key: string]: string
|
|
381
|
+
},
|
|
382
|
+
Record<string, unknown>,
|
|
383
|
+
{ args: UserDTO }
|
|
384
|
+
>,
|
|
410
385
|
res: Response,
|
|
411
386
|
next: NextFunction
|
|
412
387
|
): Promise<void> => {
|
|
@@ -510,7 +485,7 @@ const validatorCompiler = (
|
|
|
510
485
|
schema: ZodType,
|
|
511
486
|
value: 'body' | 'params'
|
|
512
487
|
): Middleware => {
|
|
513
|
-
return (req: Request,
|
|
488
|
+
return (req: Request, _res: Response, next: NextFunction) => {
|
|
514
489
|
const result = schema.safeParse(req[value])
|
|
515
490
|
|
|
516
491
|
if (result.success) return next()
|
|
@@ -677,9 +652,9 @@ const main = async ({
|
|
|
677
652
|
graphQL,
|
|
678
653
|
dbIsSQL
|
|
679
654
|
})
|
|
680
|
-
await types({ projectName,
|
|
655
|
+
await types({ projectName, dbIsSQL })
|
|
681
656
|
await network({ projectName, graphQL, dbIsSQL })
|
|
682
|
-
await schemas({ projectName, dbIsSQL
|
|
657
|
+
await schemas({ projectName, dbIsSQL })
|
|
683
658
|
await services({ projectName, dbIsSQL })
|
|
684
659
|
await db({ projectName, database })
|
|
685
660
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
|
|
5
5
|
const db = require('./database')
|
|
6
6
|
const schemas = require('./schemas')
|
|
@@ -134,7 +134,7 @@ const applyRoutes = async (app: FastifyInstance) => {
|
|
|
134
134
|
await Docs(app)
|
|
135
135
|
|
|
136
136
|
// Handling 404 error
|
|
137
|
-
app.setNotFoundHandler((
|
|
137
|
+
app.setNotFoundHandler((_request, reply) => {
|
|
138
138
|
response({
|
|
139
139
|
error: true,
|
|
140
140
|
message: 'This route does not exists',
|
|
@@ -142,7 +142,7 @@ const applyRoutes = async (app: FastifyInstance) => {
|
|
|
142
142
|
status: 404
|
|
143
143
|
})
|
|
144
144
|
})
|
|
145
|
-
app.setErrorHandler<HttpError>((error,
|
|
145
|
+
app.setErrorHandler<HttpError>((error, _request, reply) => {
|
|
146
146
|
response({
|
|
147
147
|
error: true,
|
|
148
148
|
message: error.message,
|
|
@@ -189,7 +189,7 @@ class Server implements Log {
|
|
|
189
189
|
async #config() {
|
|
190
190
|
await this.#apolloConfig()
|
|
191
191
|
this.#app.register(require('@fastify/cors'), {})
|
|
192
|
-
this.#app.addHook('preHandler', (
|
|
192
|
+
this.#app.addHook('preHandler', (_request, reply, done) => {
|
|
193
193
|
reply.header('Access-Control-Allow-Methods', 'GET, POST, PATCH, DELETE')
|
|
194
194
|
reply.header('Access-Control-Allow-Origin', '*')
|
|
195
195
|
reply.header(
|
|
@@ -264,7 +264,7 @@ class Server implements Log {
|
|
|
264
264
|
const server = new Server()
|
|
265
265
|
|
|
266
266
|
export { server as Server }\n`
|
|
267
|
-
: `import fastify, { FastifyInstance } from 'fastify'
|
|
267
|
+
: `import fastify, { type FastifyInstance } from 'fastify'
|
|
268
268
|
import debug from 'debug'
|
|
269
269
|
import {
|
|
270
270
|
serializerCompiler,
|
|
@@ -272,7 +272,7 @@ import {
|
|
|
272
272
|
} from 'fastify-type-provider-zod'
|
|
273
273
|
|
|
274
274
|
import { dbConnection } from 'database'
|
|
275
|
-
import { Log } from 'utils'
|
|
275
|
+
import type { Log } from 'utils'
|
|
276
276
|
import { applyRoutes } from './router'
|
|
277
277
|
|
|
278
278
|
const d = debug('App:Network:Server')
|
|
@@ -289,7 +289,7 @@ class Server implements Log {
|
|
|
289
289
|
|
|
290
290
|
async #config() {
|
|
291
291
|
this.#app.register(require('@fastify/cors'), {})
|
|
292
|
-
this.#app.addHook('preHandler', (
|
|
292
|
+
this.#app.addHook('preHandler', (_req, reply, done) => {
|
|
293
293
|
reply.header('Access-Control-Allow-Methods', 'GET, POST, PATCH, DELETE')
|
|
294
294
|
reply.header('Access-Control-Allow-Origin', '*')
|
|
295
295
|
reply.header(
|
|
@@ -404,7 +404,7 @@ export { Docs }\n`,
|
|
|
404
404
|
import { response } from 'network/response'
|
|
405
405
|
|
|
406
406
|
const Home = (app: FastifyInstance, prefix = '/') => {
|
|
407
|
-
app.get(\`\${prefix}\`, (
|
|
407
|
+
app.get(\`\${prefix}\`, (_request, reply) => {
|
|
408
408
|
response({
|
|
409
409
|
error: false,
|
|
410
410
|
message: 'Welcome to your Fastify Backend!',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const os = require('os')
|
|
2
|
-
const util = require('util')
|
|
3
|
-
const exec = util.promisify(require('child_process').exec)
|
|
1
|
+
const os = require('node:os')
|
|
2
|
+
const util = require('node:util')
|
|
3
|
+
const exec = util.promisify(require('node:child_process').exec)
|
|
4
4
|
|
|
5
5
|
const express = require('./express')
|
|
6
6
|
const fastifyF = require('./fastify')
|
|
@@ -34,39 +34,6 @@ module.exports = async ({
|
|
|
34
34
|
}) => {
|
|
35
35
|
const dbIsSQL = database !== 'mongo'
|
|
36
36
|
const data = {
|
|
37
|
-
test: {
|
|
38
|
-
index: {
|
|
39
|
-
content: `### Testing store a user
|
|
40
|
-
POST http://localhost:1996/api/users
|
|
41
|
-
Content-Type: application/json
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
"args": {
|
|
45
|
-
"lastName": "Lzq",
|
|
46
|
-
"name": "Anthony"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
### Testing getOne user
|
|
51
|
-
GET http://localhost:1996/api/user/60e7e3b93b01c1a7aa74cd6b
|
|
52
|
-
|
|
53
|
-
### Testing update user
|
|
54
|
-
PATCH http://localhost:1996/api/user/60e7e3b93b01c1a7aa74cd6b
|
|
55
|
-
Content-Type: application/json
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
"args": {
|
|
59
|
-
"name": "Anthony",
|
|
60
|
-
"lastName": "Luzquiños"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
### Testing delete user
|
|
65
|
-
DELETE http://localhost:1996/api/user/60e7e3b93b01c1a7aa74cd6b
|
|
66
|
-
`,
|
|
67
|
-
file: `${projectName}/index.http`
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
37
|
'.env': {
|
|
71
38
|
content:
|
|
72
39
|
dbIsSQL && database !== 'sqlite'
|
|
@@ -76,12 +43,12 @@ DELETE http://localhost:1996/api/user/60e7e3b93b01c1a7aa74cd6b
|
|
|
76
43
|
: `${database}://${database}:${database}@${database}:${dbDefaultPorts[database]}/${projectName}`
|
|
77
44
|
}`
|
|
78
45
|
: database === 'sqlite'
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
46
|
+
? ''
|
|
47
|
+
: `DATABASE_URL = ${
|
|
48
|
+
ENVIRONMENTS_WITH_DB_URI.includes(process.env.NODE_ENV)
|
|
49
|
+
? process.env.MONGO_URI
|
|
50
|
+
: `mongodb://mongo:mongo@mongo:27017/${projectName}`
|
|
51
|
+
}`,
|
|
85
52
|
file: `${projectName}/.env`
|
|
86
53
|
},
|
|
87
54
|
index: {
|
|
@@ -103,8 +70,7 @@ Server.start()
|
|
|
103
70
|
// .env
|
|
104
71
|
writeFile(data['.env'].file, data['.env'].content),
|
|
105
72
|
// index
|
|
106
|
-
writeFile(data.index.file, data.index.content)
|
|
107
|
-
writeFile(data.test.index.file, data.test.index.content)
|
|
73
|
+
writeFile(data.index.file, data.index.content)
|
|
108
74
|
]
|
|
109
75
|
|
|
110
76
|
if (fastify)
|
|
@@ -128,11 +94,5 @@ Server.start()
|
|
|
128
94
|
})
|
|
129
95
|
])
|
|
130
96
|
|
|
131
|
-
if (!graphql)
|
|
132
|
-
processes.push(
|
|
133
|
-
// /test
|
|
134
|
-
writeFile(data.test.index.file, data.test.index.content)
|
|
135
|
-
)
|
|
136
|
-
|
|
137
97
|
await Promise.all(processes)
|
|
138
98
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} args
|
|
8
8
|
* @param {String} args.projectName
|
|
9
9
|
* @param {Boolean} args.dbIsSQL
|
|
10
|
-
* @param {Boolean} args.graphql
|
|
11
10
|
*/
|
|
12
|
-
module.exports = async ({ projectName, dbIsSQL
|
|
11
|
+
module.exports = async ({ projectName, dbIsSQL }) => {
|
|
13
12
|
const createFoldersCommand = `mkdir ${projectName}/src/schemas`
|
|
14
13
|
|
|
15
14
|
if (platform() === 'win32')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
|
|
5
5
|
const writeFile = require('../../utils/writeFile')
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ ${projectName}/src/services/utils/messages`
|
|
|
23
23
|
file: `${projectName}/src/services/index.ts`
|
|
24
24
|
},
|
|
25
25
|
base: {
|
|
26
|
-
content: `import { Debugger } from 'debug'
|
|
26
|
+
content: `import { type Debugger } from 'debug'
|
|
27
27
|
import httpErrors, {
|
|
28
28
|
HttpErrorConstructor,
|
|
29
29
|
NamedConstructors
|
|
@@ -87,15 +87,11 @@ class BaseHttpService implements Log {
|
|
|
87
87
|
value: 'error',
|
|
88
88
|
content: error
|
|
89
89
|
})
|
|
90
|
+
const errorMessage = message ?? (error as { message: string }).message
|
|
90
91
|
|
|
91
|
-
if (code)
|
|
92
|
-
throw new httpErrors[code](
|
|
93
|
-
message ?? (error as { message: string }).message
|
|
94
|
-
)
|
|
92
|
+
if (code) throw new httpErrors[code](errorMessage)
|
|
95
93
|
|
|
96
|
-
throw new httpErrors.InternalServerError(
|
|
97
|
-
message ?? (error as { message: string }).message
|
|
98
|
-
)
|
|
94
|
+
throw new httpErrors.InternalServerError(errorMessage)
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
97
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -32,7 +32,7 @@ module.exports = async ({
|
|
|
32
32
|
file: `${projectName}/src/utils/index.ts`
|
|
33
33
|
},
|
|
34
34
|
logger: {
|
|
35
|
-
content: `import { Debugger } from 'debug'
|
|
35
|
+
content: `import { type Debugger } from 'debug'
|
|
36
36
|
|
|
37
37
|
export interface Log {
|
|
38
38
|
log({
|
|
@@ -104,8 +104,7 @@ export { Logger }\n`,
|
|
|
104
104
|
"name": "user",
|
|
105
105
|
"description": "Operations related to the user"
|
|
106
106
|
}
|
|
107
|
-
]
|
|
108
|
-
${
|
|
107
|
+
]${
|
|
109
108
|
!graphQL
|
|
110
109
|
? `,
|
|
111
110
|
"paths": {
|
|
@@ -424,7 +423,7 @@ export { Logger }\n`,
|
|
|
424
423
|
}
|
|
425
424
|
}
|
|
426
425
|
}`
|
|
427
|
-
: '}'
|
|
426
|
+
: '\n}'
|
|
428
427
|
}`,
|
|
429
428
|
file: `${projectName}/src/utils/docs.json`
|
|
430
429
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const writeFile = require('../utils/writeFile')
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {Object} args
|
|
5
|
+
* @param {String} args.projectName
|
|
6
|
+
* @returns {Promise<void>}
|
|
7
|
+
*/
|
|
8
|
+
module.exports = async ({ projectName }) => {
|
|
9
|
+
const biomeConfig = {
|
|
10
|
+
$schema: 'https://biomejs.dev/schemas/2.4.4/schema.json',
|
|
11
|
+
vcs: {
|
|
12
|
+
enabled: false,
|
|
13
|
+
clientKind: 'git',
|
|
14
|
+
useIgnoreFile: false
|
|
15
|
+
},
|
|
16
|
+
files: {
|
|
17
|
+
ignoreUnknown: false
|
|
18
|
+
},
|
|
19
|
+
formatter: {
|
|
20
|
+
enabled: true,
|
|
21
|
+
useEditorconfig: true,
|
|
22
|
+
formatWithErrors: false,
|
|
23
|
+
indentStyle: 'space',
|
|
24
|
+
indentWidth: 2,
|
|
25
|
+
lineEnding: 'lf',
|
|
26
|
+
lineWidth: 80,
|
|
27
|
+
attributePosition: 'auto',
|
|
28
|
+
bracketSpacing: true
|
|
29
|
+
},
|
|
30
|
+
linter: {
|
|
31
|
+
enabled: true,
|
|
32
|
+
rules: {
|
|
33
|
+
recommended: true,
|
|
34
|
+
correctness: {
|
|
35
|
+
noUnusedVariables: 'error'
|
|
36
|
+
},
|
|
37
|
+
style: {
|
|
38
|
+
useConst: 'error',
|
|
39
|
+
useTemplate: 'error'
|
|
40
|
+
},
|
|
41
|
+
suspicious: {
|
|
42
|
+
noDebugger: 'error',
|
|
43
|
+
noDoubleEquals: 'error',
|
|
44
|
+
noExplicitAny: 'off'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
javascript: {
|
|
49
|
+
parser: {
|
|
50
|
+
unsafeParameterDecoratorsEnabled: true
|
|
51
|
+
},
|
|
52
|
+
formatter: {
|
|
53
|
+
jsxQuoteStyle: 'double',
|
|
54
|
+
quoteProperties: 'asNeeded',
|
|
55
|
+
trailingCommas: 'none',
|
|
56
|
+
semicolons: 'asNeeded',
|
|
57
|
+
arrowParentheses: 'asNeeded',
|
|
58
|
+
bracketSameLine: false,
|
|
59
|
+
bracketSpacing: true,
|
|
60
|
+
quoteStyle: 'single'
|
|
61
|
+
},
|
|
62
|
+
globals: [
|
|
63
|
+
'console',
|
|
64
|
+
'process',
|
|
65
|
+
'Buffer',
|
|
66
|
+
'__dirname',
|
|
67
|
+
'__filename',
|
|
68
|
+
'global',
|
|
69
|
+
'module',
|
|
70
|
+
'require',
|
|
71
|
+
'exports'
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// En Biome 2.1.3, los decoradores de TypeScript se configuran diferente
|
|
77
|
+
// Si necesitas decoradores para GraphQL, se pueden habilitar via tsconfig.json
|
|
78
|
+
|
|
79
|
+
// Configuración específica para Jest (equivalente al env jest: true)
|
|
80
|
+
biomeConfig.overrides = [
|
|
81
|
+
{
|
|
82
|
+
includes: [
|
|
83
|
+
'**/*.test.ts',
|
|
84
|
+
'**/*.test.js',
|
|
85
|
+
'**/*.spec.ts',
|
|
86
|
+
'**/*.spec.js'
|
|
87
|
+
],
|
|
88
|
+
javascript: {
|
|
89
|
+
globals: [
|
|
90
|
+
'describe',
|
|
91
|
+
'it',
|
|
92
|
+
'test',
|
|
93
|
+
'expect',
|
|
94
|
+
'beforeAll',
|
|
95
|
+
'afterAll',
|
|
96
|
+
'beforeEach',
|
|
97
|
+
'afterEach',
|
|
98
|
+
'jest'
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
const biomeConfigContent = JSON.stringify(biomeConfig, null, 2)
|
|
105
|
+
|
|
106
|
+
const biomeignoreContent = `# Build outputs
|
|
107
|
+
dist/
|
|
108
|
+
build/
|
|
109
|
+
|
|
110
|
+
# Dependencies
|
|
111
|
+
node_modules/
|
|
112
|
+
|
|
113
|
+
# Test coverage
|
|
114
|
+
coverage/
|
|
115
|
+
|
|
116
|
+
# Environment files
|
|
117
|
+
.env*
|
|
118
|
+
|
|
119
|
+
# Logs
|
|
120
|
+
*.log
|
|
121
|
+
|
|
122
|
+
# Database
|
|
123
|
+
prisma/migrations/
|
|
124
|
+
`
|
|
125
|
+
|
|
126
|
+
await Promise.all([
|
|
127
|
+
writeFile(`${projectName}/biome.json`, biomeConfigContent),
|
|
128
|
+
writeFile(`${projectName}/.biomeignore`, biomeignoreContent)
|
|
129
|
+
])
|
|
130
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,12 +11,37 @@ const writeFile = require('../utils/writeFile')
|
|
|
11
11
|
module.exports = async (projectName, manager) => {
|
|
12
12
|
const createFoldersCommand = `mkdir ${projectName}/.github \
|
|
13
13
|
${projectName}/.github/workflows`
|
|
14
|
-
const managerName = manager.split()[0]
|
|
14
|
+
const managerName = manager.split(' ')[0]
|
|
15
15
|
|
|
16
16
|
if (platform() === 'win32')
|
|
17
17
|
await exec(createFoldersCommand.replaceAll('/', '\\'))
|
|
18
18
|
else await exec(createFoldersCommand)
|
|
19
19
|
|
|
20
|
+
const installCmd =
|
|
21
|
+
managerName === 'yarn'
|
|
22
|
+
? 'yarn install --frozen-lockfile'
|
|
23
|
+
: managerName === 'pnpm'
|
|
24
|
+
? 'pnpm i --frozen-lockfile'
|
|
25
|
+
: 'npm ci'
|
|
26
|
+
|
|
27
|
+
const lockFile =
|
|
28
|
+
managerName === 'yarn'
|
|
29
|
+
? 'yarn.lock'
|
|
30
|
+
: managerName === 'pnpm'
|
|
31
|
+
? 'pnpm-lock.yaml'
|
|
32
|
+
: 'package-lock.json'
|
|
33
|
+
|
|
34
|
+
const runCmd = managerName === 'yarn' ? 'yarn' : `${managerName} run`
|
|
35
|
+
|
|
36
|
+
const pnpmSetup =
|
|
37
|
+
managerName === 'pnpm'
|
|
38
|
+
? `
|
|
39
|
+
- name: Setup pnpm
|
|
40
|
+
uses: pnpm/action-setup@v4
|
|
41
|
+
with:
|
|
42
|
+
version: 9.x.x\n`
|
|
43
|
+
: ''
|
|
44
|
+
|
|
20
45
|
const data = {
|
|
21
46
|
linting: {
|
|
22
47
|
content: `name: Lint - ${projectName}
|
|
@@ -30,38 +55,41 @@ jobs:
|
|
|
30
55
|
|
|
31
56
|
steps:
|
|
32
57
|
- name: Check out Git repository
|
|
33
|
-
uses: actions/checkout@
|
|
58
|
+
uses: actions/checkout@v4
|
|
34
59
|
with:
|
|
35
60
|
fetch-depth: 0
|
|
36
61
|
|
|
37
62
|
- name: Set up Node.js
|
|
38
|
-
uses: actions/setup-node@
|
|
39
|
-
with:
|
|
40
|
-
node-version: 18.x
|
|
41
|
-
${
|
|
42
|
-
managerName === 'pnpm'
|
|
43
|
-
? `
|
|
44
|
-
- name: Setup pnpm
|
|
45
|
-
uses: pnpm/action-setup@v2
|
|
63
|
+
uses: actions/setup-node@v4
|
|
46
64
|
with:
|
|
47
|
-
version:
|
|
48
|
-
|
|
49
|
-
}
|
|
65
|
+
node-version: 20.x
|
|
66
|
+
${pnpmSetup}
|
|
50
67
|
- name: Install Node.js dependencies
|
|
51
|
-
run: ${
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- name:
|
|
60
|
-
|
|
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
|
|
61
90
|
with:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
eslint_extensions: js\n`,
|
|
91
|
+
commit_message: 'feat: automated lint with biome'
|
|
92
|
+
file_pattern: '.'`,
|
|
65
93
|
file: `${projectName}/.github/workflows/lint.yml`
|
|
66
94
|
},
|
|
67
95
|
test: {
|
|
@@ -77,34 +105,20 @@ jobs:
|
|
|
77
105
|
|
|
78
106
|
steps:
|
|
79
107
|
- name: Check out Git repository
|
|
80
|
-
uses: actions/checkout@
|
|
108
|
+
uses: actions/checkout@v4
|
|
81
109
|
with:
|
|
82
110
|
fetch-depth: 0
|
|
83
111
|
|
|
84
112
|
- name: Set up Node.js
|
|
85
|
-
uses: actions/setup-node@
|
|
86
|
-
with:
|
|
87
|
-
node-version: 18.x
|
|
88
|
-
${
|
|
89
|
-
managerName === 'pnpm'
|
|
90
|
-
? `
|
|
91
|
-
- name: Setup pnpm
|
|
92
|
-
uses: pnpm/action-setup@v2
|
|
113
|
+
uses: actions/setup-node@v4
|
|
93
114
|
with:
|
|
94
|
-
version:
|
|
95
|
-
|
|
96
|
-
}
|
|
115
|
+
node-version: 20.x
|
|
116
|
+
${pnpmSetup}
|
|
97
117
|
- name: Install Node.js dependencies
|
|
98
|
-
run: ${
|
|
99
|
-
managerName === 'yarn'
|
|
100
|
-
? 'yarn install --frozen-lockfile'
|
|
101
|
-
: managerName
|
|
102
|
-
? 'pnpm i --frozen-lockfile'
|
|
103
|
-
: 'npm ci'
|
|
104
|
-
}
|
|
118
|
+
run: ${installCmd}
|
|
105
119
|
|
|
106
120
|
- name: Run test
|
|
107
|
-
run: ${
|
|
121
|
+
run: ${runCmd} test:ci
|
|
108
122
|
env:
|
|
109
123
|
DATABASE_URL: \${{ secrets.DATABASE_URL }}
|
|
110
124
|
NODE_ENV: ci
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
api: require('./api'),
|
|
3
|
+
biome: require('./biome'),
|
|
3
4
|
changelog: require('./changelog'),
|
|
4
5
|
docker: require('./docker'),
|
|
5
|
-
eslint: require('./eslint'),
|
|
6
6
|
ghat: require('./ghat'),
|
|
7
7
|
gitignore: require('./gitignore'),
|
|
8
8
|
licenseF: require('./license'),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const https = require('https')
|
|
1
|
+
const https = require('node:https')
|
|
2
2
|
const _ = require('underscore')
|
|
3
3
|
const writeFile = require('../utils/writeFile')
|
|
4
4
|
|
|
@@ -11,7 +11,9 @@ const getLicense = ({ author, license, year, projectDescription }) => {
|
|
|
11
11
|
https.get(`https://choosealicense.com/licenses/${license}/`, res => {
|
|
12
12
|
let result = ''
|
|
13
13
|
res.setEncoding('utf8')
|
|
14
|
-
res.on('data', chunk =>
|
|
14
|
+
res.on('data', chunk => {
|
|
15
|
+
result += chunk
|
|
16
|
+
})
|
|
15
17
|
res.on('end', () => {
|
|
16
18
|
const begin = result.indexOf('id="license-text"')
|
|
17
19
|
const end = result.indexOf('</pre>')
|
|
@@ -22,7 +22,7 @@ module.exports = async ({
|
|
|
22
22
|
"main": "${mainFile}",
|
|
23
23
|
"description": "${projectDescription}",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"lint": "
|
|
25
|
+
"lint": "biome check --write src/",
|
|
26
26
|
"service": "nodemon",
|
|
27
27
|
"start": "ts-node src/index.ts",
|
|
28
28
|
"release": "standard-version",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { platform } = require('os')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
const exec = promisify(require('child_process').exec)
|
|
1
|
+
const { platform } = require('node:os')
|
|
2
|
+
const { promisify } = require('node:util')
|
|
3
|
+
const exec = promisify(require('node:child_process').exec)
|
|
4
4
|
const writeFile = require('../utils/writeFile')
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -2,10 +2,9 @@ const writeFile = require('../utils/writeFile')
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {String} projectName
|
|
5
|
-
* @param {Boolean} graphQL
|
|
6
5
|
* @returns {Promise<void>}
|
|
7
6
|
*/
|
|
8
|
-
module.exports = async
|
|
7
|
+
module.exports = async projectName => {
|
|
9
8
|
const data = {
|
|
10
9
|
base: {
|
|
11
10
|
content: `{
|
|
@@ -18,13 +17,9 @@ module.exports = async (projectName, graphQL) => {
|
|
|
18
17
|
|
|
19
18
|
/* Basic Options */
|
|
20
19
|
// "incremental": true, /* Enable incremental compilation */
|
|
21
|
-
"target": "
|
|
22
|
-
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
23
|
-
|
|
24
|
-
graphQL
|
|
25
|
-
? '"lib": ["es2018", "esnext.asynciterable"],/* Specify library files to be included in the compilation. */'
|
|
26
|
-
: '// "lib": [], /* Specify library files to be included in the compilation. */'
|
|
27
|
-
}
|
|
20
|
+
"target": "ES2022" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2022', or 'ESNEXT'. */,
|
|
21
|
+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', 'ES2022', or 'ESNext'. */,
|
|
22
|
+
"lib": ["es2022", "esnext.asynciterable"], /* Specify library files to be included in the compilation. */
|
|
28
23
|
"allowJs": true /* Allow javascript files to be compiled. */,
|
|
29
24
|
// "checkJs": true, /* Report errors in .js files. */
|
|
30
25
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
@@ -44,27 +39,27 @@ module.exports = async (projectName, graphQL) => {
|
|
|
44
39
|
/* Strict Type-Checking Options */
|
|
45
40
|
"strict": true /* Enable all strict type-checking options. */,
|
|
46
41
|
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
"strictNullChecks": true, /* Enable strict null checks. */
|
|
43
|
+
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
44
|
+
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
45
|
+
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
46
|
+
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
47
|
+
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
53
48
|
|
|
54
49
|
/* Additional Checks */
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
51
|
+
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
52
|
+
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
53
|
+
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
59
54
|
|
|
60
55
|
/* Module Resolution Options */
|
|
61
|
-
"moduleResolution": "node" /* Specify module resolution strategy: 'node'
|
|
56
|
+
"moduleResolution": "node" /* Specify module resolution strategy: 'node', 'classic', or 'bundler' (modern). */,
|
|
62
57
|
"baseUrl": "src", /* Base directory to resolve non-absolute module names. */
|
|
63
58
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
64
59
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
65
60
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
66
61
|
// "types": [], /* Type declaration files to be included in compilation. */
|
|
67
|
-
|
|
62
|
+
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
68
63
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
69
64
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
70
65
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
package/lib/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const cliProgress = require('cli-progress')
|
|
2
2
|
const colors = require('colors')
|
|
3
|
-
const util = require('util')
|
|
4
|
-
const exec = util.promisify(require('child_process').exec)
|
|
3
|
+
const util = require('node:util')
|
|
4
|
+
const exec = util.promisify(require('node:child_process').exec)
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
packageJson,
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
licenseF,
|
|
11
11
|
gitignore,
|
|
12
12
|
tsconfig,
|
|
13
|
-
|
|
13
|
+
biome,
|
|
14
14
|
docker,
|
|
15
15
|
api,
|
|
16
16
|
testsF,
|
|
@@ -62,9 +62,9 @@ module.exports = async ({
|
|
|
62
62
|
const fastifyProdPackages = `fastify @fastify/swagger @fastify/swagger-ui @fastify/cors fastify-type-provider-zod ${
|
|
63
63
|
graphql ? '@as-integrations/fastify' : ''
|
|
64
64
|
}`
|
|
65
|
-
let prodPackages = `${manager} debug zod http-errors @prisma/client ${
|
|
65
|
+
let prodPackages = `${manager} debug zod http-errors @prisma/client@6 ${
|
|
66
66
|
graphql
|
|
67
|
-
?
|
|
67
|
+
? `@apollo/server ${!fastify ? '@as-integrations/express5' : ''} class-validator graphql graphql-scalars reflect-metadata type-graphql@2.0.0-rc.3`
|
|
68
68
|
: ''
|
|
69
69
|
} ${fastify ? fastifyProdPackages : expressProdPackages}`
|
|
70
70
|
|
|
@@ -91,21 +91,12 @@ module.exports = async ({
|
|
|
91
91
|
throw new Error('Database not supported')
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
let devPackages = `${manager} -D prisma @types/debug @types/http-errors \
|
|
94
|
+
let devPackages = `${manager} -D prisma@6 @types/debug @types/http-errors \
|
|
95
95
|
@types/node \
|
|
96
|
-
@
|
|
97
|
-
@typescript-eslint/parser \
|
|
96
|
+
@biomejs/biome \
|
|
98
97
|
axios \
|
|
99
98
|
dotenv \
|
|
100
|
-
eslint \
|
|
101
|
-
eslint-config-prettier \
|
|
102
|
-
eslint-config-standard \
|
|
103
|
-
eslint-plugin-import \
|
|
104
|
-
eslint-plugin-node \
|
|
105
|
-
eslint-plugin-prettier \
|
|
106
|
-
eslint-plugin-promise \
|
|
107
99
|
nodemon \
|
|
108
|
-
prettier \
|
|
109
100
|
standard-version \
|
|
110
101
|
ts-loader \
|
|
111
102
|
ts-node \
|
|
@@ -118,9 +109,9 @@ typescript`
|
|
|
118
109
|
|
|
119
110
|
devPackages += ` ${
|
|
120
111
|
fastify ? fastifyDevPackages : expressDevPackages
|
|
121
|
-
} @jest/types @types/jest
|
|
112
|
+
} @jest/types @types/jest jest jest-unit ts-jest`
|
|
122
113
|
|
|
123
|
-
|
|
114
|
+
// Biome no necesita plugins adicionales de Jest como ESLint
|
|
124
115
|
|
|
125
116
|
bar.start(process, i)
|
|
126
117
|
|
|
@@ -141,8 +132,8 @@ typescript`
|
|
|
141
132
|
readme(projectName, projectDescription),
|
|
142
133
|
changelog(projectName),
|
|
143
134
|
gitignore(projectName),
|
|
144
|
-
tsconfig(projectName
|
|
145
|
-
|
|
135
|
+
tsconfig(projectName),
|
|
136
|
+
biome({ projectName }),
|
|
146
137
|
docker({ projectName, manager }),
|
|
147
138
|
api({ projectName, version, email, fastify, graphql, database }),
|
|
148
139
|
testsF({ projectName, graphql, dbIsSQL }),
|
package/package.json
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
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
|
"service:q": "node ./bin -q",
|
|
9
9
|
"help": "node ./bin -h",
|
|
10
|
-
"lint": "
|
|
10
|
+
"lint": "biome check --write lib/",
|
|
11
|
+
"lint:ci": "biome check lib/",
|
|
12
|
+
"db:create": "node ./scripts/db/sql/create.mjs && node ./scripts/db/mongo/create.mjs",
|
|
13
|
+
"db:create:mongo": "node ./scripts/db/mongo/create.mjs",
|
|
14
|
+
"db:create:sql": "node ./scripts/db/sql/create.mjs",
|
|
15
|
+
"db:restore": "node ./scripts/db/sql/restore.mjs && node ./scripts/db/mongo/restore.mjs",
|
|
16
|
+
"db:restore:mongo": "node ./scripts/db/mongo/restore.mjs",
|
|
17
|
+
"db:restore:sql": "node ./scripts/db/sql/restore.mjs",
|
|
11
18
|
"example": "node -r dotenv/config ./bin -N local-example -D 'This is a test using fastify' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat -F",
|
|
12
19
|
"build": "npm run build:express:all && npm run build:fastify:all",
|
|
13
|
-
"build:mongo": "npm run rm:mongo && npm run build:express && npm run build:fastify && npm run build:express:graphql && npm run build:fastify:graphql",
|
|
14
|
-
"build:sql": "npm run rm:sql && npm run build:express && npm run build:fastify && npm run build:express:graphql && npm run build:fastify:graphql",
|
|
15
|
-
"build:express:all": "npm run build:express && npm run build:express:mongo && npm run build:express:graphql && npm run build:express:mongo:graphql",
|
|
16
|
-
"build:fastify:all": "npm run build:fastify && npm run build:fastify:mongo && npm run build:fastify:graphql && npm run build:fastify:mongo:graphql",
|
|
17
|
-
"build:express": "npm run rm:express && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express -D 'This is a test using Express with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat -d postgres && npm run rm:git:express:mongo",
|
|
18
|
-
"build:express:mongo": "npm run rm:express:mongo && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-mongo -D 'This is a test using Express with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat && npm run rm:git:express",
|
|
19
|
-
"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 with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H--tests --ghat -d postgres -F && npm run rm:git:fastify",
|
|
20
|
-
"build:fastify:mongo": "npm run rm:fastify:mongo && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-mongo -D 'This is a test using Fastify with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat -F && npm run rm:git:fastify:mongo",
|
|
21
|
-
"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 with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -d postgres && npm run rm:git:express:graphql",
|
|
22
|
-
"build:express:mongo:graphql": "npm run rm:express:mongo:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-mongo-graphql -D 'This is a test using Express with GraphQL with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat && npm run rm:git:express:mongo:graphql",
|
|
23
|
-
"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 with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -d postgres -F && npm run rm:git:fastify:graphql",
|
|
24
|
-
"build:fastify:mongo:graphql": "npm run rm:fastify:mongo:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-mongo-graphql -D 'This is a test using Fastify with GraphQL with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -F && npm run rm:git:fastify:mongo:graphql",
|
|
20
|
+
"build:mongo": "npm run rm:mongo && npm run db:create:mongo && npm run build:express:mongo && npm run build:fastify:mongo && npm run build:express:mongo:graphql && npm run build:fastify:mongo:graphql",
|
|
21
|
+
"build:sql": "npm run rm:sql && npm run db:create:sql && npm run build:express && npm run build:fastify && npm run build:express:graphql && npm run build:fastify:graphql",
|
|
22
|
+
"build:express:all": "npm run db:create && npm run build:express && npm run build:express:mongo && npm run build:express:graphql && npm run build:express:mongo:graphql",
|
|
23
|
+
"build:fastify:all": "npm run db:create && npm run build:fastify && npm run build:fastify:mongo && npm run build:fastify:graphql && npm run build:fastify:mongo:graphql",
|
|
24
|
+
"build:express": "npm run db:create:sql && npm run rm:express && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express -D 'This is a test using Express with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat -d postgres && npm run rm:git:express:mongo",
|
|
25
|
+
"build:express:mongo": "npm run db:create:mongo && npm run rm:express:mongo && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-mongo -D 'This is a test using Express with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat && npm run rm:git:express",
|
|
26
|
+
"build:fastify": "npm run db:create:sql && npm run rm:fastify && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify -D 'This is a test using Fastify with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H--tests --ghat -d postgres -F && npm run rm:git:fastify",
|
|
27
|
+
"build:fastify:mongo": "npm run db:create:mongo && npm run rm:fastify:mongo && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-mongo -D 'This is a test using Fastify with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H --tests --ghat -F && npm run rm:git:fastify:mongo",
|
|
28
|
+
"build:express:graphql": "npm run db:create:sql && 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 with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -d postgres && npm run rm:git:express:graphql",
|
|
29
|
+
"build:express:mongo:graphql": "npm run db:create:mongo && npm run rm:express:mongo:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/express-mongo-graphql -D 'This is a test using Express with GraphQL with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat && npm run rm:git:express:mongo:graphql",
|
|
30
|
+
"build:fastify:graphql": "npm run db:create:sql && 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 with Prisma and PostgreSQL' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -d postgres -F && npm run rm:git:fastify:graphql",
|
|
31
|
+
"build:fastify:mongo:graphql": "npm run db:create:mongo && npm run rm:fastify:mongo:graphql && npm run cd:mv:example && node -r dotenv/config ./bin -N example/fastify-mongo-graphql -D 'This is a test using Fastify with GraphQL with Prisma and MongoDB' -a AnthonyLzq -e sluzquinosa@uni.pe -l mit -H -g --tests --ghat -F && npm run rm:git:fastify:mongo:graphql",
|
|
25
32
|
"build:and:test:only": "npm run build && npm run test:only",
|
|
26
33
|
"test": "npm run test:without:restore && git restore .",
|
|
27
|
-
"test:local": "npm run test:without:restore
|
|
28
|
-
"test:integration": "jest --testPathPattern=test/integration",
|
|
29
|
-
"test:without:restore": "npm run build && npm run test:express:local && npm run test:express:mongo:local && npm run test:express:graphql:local && npm run test:express:mongo:graphql:local && npm run test:fastify:local && npm run test:fastify:mongo:local && npm run test:fastify:graphql:local && npm run test:fastify:mongo:graphql:local",
|
|
34
|
+
"test:local": "npm run test:without:restore",
|
|
35
|
+
"test:integration": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.integration.config.js --testPathPattern=test/integration",
|
|
36
|
+
"test:without:restore": "npm run db:create && npm run build && npm run test:express:local && npm run test:express:mongo:local && npm run test:express:graphql:local && npm run test:express:mongo:graphql:local && npm run test:fastify:local && npm run test:fastify:mongo:local && npm run test:fastify:graphql:local && npm run test:fastify:mongo:graphql:local",
|
|
30
37
|
"test:mongo:ci": "npm run build:mongo && npm run test:express:mongo:ci && npm run test:fastify:mongo:ci && npm run test:express:mongo:graphql:ci && npm run test:fastify:mongo:graphql:ci",
|
|
31
38
|
"test:sql:ci": "npm run build:sql && npm run test:express:ci && npm run test:fastify:ci && npm run test:express:graphql:ci && npm run test:fastify:graphql:ci",
|
|
32
39
|
"test:only": "npm run test:express:only && npm run test:fastify:only",
|
|
@@ -78,7 +85,6 @@
|
|
|
78
85
|
"rm:git:fastify:mongo:graphql": "if [ -d \"example/fastify-mongo-graphql/.git\" ]; then rm -rf example/fastify-mongo-graphql/.git; fi",
|
|
79
86
|
"rm:project:structures": "if [ -d \"projectStructureExamples\" ]; then rm -rf projectStructureExamples/*; fi",
|
|
80
87
|
"cd:mv:example": "if [ ! -d \"example\" ]; then mkdir example && cd example; fi",
|
|
81
|
-
"restore:db": "node ./scripts/restoreRelationalDb.js && node ./scripts/restoreMongoDb.js",
|
|
82
88
|
"release": "standard-version",
|
|
83
89
|
"version": "npm run release && npm run list:directory:tree:examples && git add ."
|
|
84
90
|
},
|
|
@@ -100,28 +106,21 @@
|
|
|
100
106
|
"author": "AnthonyLzq",
|
|
101
107
|
"license": "MIT",
|
|
102
108
|
"dependencies": {
|
|
103
|
-
"cli-progress": "
|
|
104
|
-
"colors": "
|
|
105
|
-
"prompts": "
|
|
106
|
-
"underscore": "
|
|
107
|
-
"yargs": "
|
|
109
|
+
"cli-progress": "3.12.0",
|
|
110
|
+
"colors": "1.4.0",
|
|
111
|
+
"prompts": "2.4.2",
|
|
112
|
+
"underscore": "1.13.8",
|
|
113
|
+
"yargs": "17.7.2"
|
|
108
114
|
},
|
|
109
115
|
"devDependencies": {
|
|
110
|
-
"@
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
119
|
-
"jest": "^29.6.2",
|
|
120
|
-
"knex": "^2.5.1",
|
|
121
|
-
"mongodb": "^5.7.0",
|
|
122
|
-
"pg": "^8.11.2",
|
|
123
|
-
"prettier": "^3.0.1",
|
|
124
|
-
"standard-version": "^9.5.0"
|
|
116
|
+
"@biomejs/biome": "^2.4.4",
|
|
117
|
+
"@types/jest": "30.0.0",
|
|
118
|
+
"dotenv": "17.3.1",
|
|
119
|
+
"jest": "30.2.0",
|
|
120
|
+
"knex": "3.1.0",
|
|
121
|
+
"mongodb": "7.1.0",
|
|
122
|
+
"pg": "8.18.0",
|
|
123
|
+
"standard-version": "9.5.0"
|
|
125
124
|
},
|
|
126
125
|
"repository": {
|
|
127
126
|
"type": "git",
|
|
@@ -144,6 +143,6 @@
|
|
|
144
143
|
},
|
|
145
144
|
"engines": {
|
|
146
145
|
"npm": ">=8.0.0",
|
|
147
|
-
"node": ">=
|
|
146
|
+
"node": ">=20.0.0"
|
|
148
147
|
}
|
|
149
148
|
}
|