@anthonylzq/simba.js 6.2.2 → 7.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/index.js +48 -17
- package/lib/src/functions/api/database.js +4 -4
- package/lib/src/functions/api/express.js +1989 -0
- package/lib/src/functions/api/fastify.js +2033 -0
- package/lib/src/functions/api/index.js +36 -140
- package/lib/src/functions/api/services.js +5 -5
- package/lib/src/functions/eslint.js +8 -3
- package/lib/src/functions/ghat.js +2 -1
- package/lib/src/functions/tests.js +20 -15
- package/lib/src/functions/tsconfig.js +7 -2
- package/lib/src/index.js +36 -27
- package/lib/src/utils/constants.js +2 -2
- package/package.json +61 -24
- package/lib/src/functions/api/network.js +0 -2444
package/lib/index.js
CHANGED
|
@@ -9,61 +9,70 @@ const argv = yargs(hideBin(process.argv))
|
|
|
9
9
|
.version(false)
|
|
10
10
|
// Pending to test it using npx
|
|
11
11
|
.usage(
|
|
12
|
-
'"simba [options]" (if you it installed globally) or only "simba -q" if you want to be asked for the options one by one'
|
|
12
|
+
'"simba [options]" (if you it installed globally) or only "simba -q" if you want to be asked for the options one by one.'
|
|
13
13
|
)
|
|
14
14
|
.example(
|
|
15
|
-
"simba -N 'Project Name' -D 'Project description' -a Anthony -e sluzquinosa@uni.pe -l mit -F
|
|
15
|
+
"simba -N 'Project Name' -D 'Project description' -a Anthony -e sluzquinosa@uni.pe -l mit -F -t -d mongo --ghat"
|
|
16
16
|
)
|
|
17
17
|
.alias('N', 'projectName')
|
|
18
18
|
.nargs('N', 1)
|
|
19
19
|
.describe('N', 'Project name')
|
|
20
20
|
.alias('D', 'projectDescription')
|
|
21
21
|
.nargs('D', 1)
|
|
22
|
-
.describe('D', 'Project description')
|
|
22
|
+
.describe('D', 'Project description.')
|
|
23
23
|
.alias('a', 'author')
|
|
24
24
|
.nargs('a', 1)
|
|
25
|
-
.describe('a', 'Author of the project')
|
|
25
|
+
.describe('a', 'Author of the project.')
|
|
26
26
|
.alias('e', 'email')
|
|
27
27
|
.nargs('e', 1)
|
|
28
|
-
.describe('e', 'Email of the author')
|
|
28
|
+
.describe('e', 'Email of the author.')
|
|
29
29
|
.alias('H', 'heroku')
|
|
30
|
-
.describe('H', 'Whether or not the project will be deployed using Heroku')
|
|
30
|
+
.describe('H', 'Whether or not the project will be deployed using Heroku.')
|
|
31
31
|
.alias('l', 'license')
|
|
32
32
|
.nargs('l', 1)
|
|
33
33
|
.describe(
|
|
34
34
|
'l',
|
|
35
|
-
'Type of license for the project, it can be one of: MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0 and AGPL 3.0, in lowercase without its version'
|
|
35
|
+
'Type of license for the project, it can be one of: MIT, Apache 2.0, MPL 2.0, LGPL 3.0, GPL 3.0 and AGPL 3.0, in lowercase without its version.'
|
|
36
36
|
)
|
|
37
37
|
.alias('v', 'version')
|
|
38
38
|
.nargs('v', 1)
|
|
39
|
-
.describe('v', 'Project initial version')
|
|
39
|
+
.describe('v', 'Project initial version.')
|
|
40
40
|
.alias('y', 'licenseYear')
|
|
41
41
|
.nargs('y', 1)
|
|
42
|
-
.describe('y', 'Year when the license starts')
|
|
42
|
+
.describe('y', 'Year when the license starts.')
|
|
43
43
|
.alias('n', 'npm')
|
|
44
|
-
.describe(
|
|
44
|
+
.describe(
|
|
45
|
+
'n',
|
|
46
|
+
'Whether or not the project should use npm as package manager.'
|
|
47
|
+
)
|
|
45
48
|
.alias('f', 'mainFile')
|
|
46
49
|
.nargs('f', 1)
|
|
47
|
-
.describe('f', 'Main file of the project')
|
|
50
|
+
.describe('f', 'Main file of the project.')
|
|
48
51
|
.alias('q', 'questions')
|
|
49
52
|
.describe(
|
|
50
53
|
'q',
|
|
51
|
-
'Whether or not you want to be asked to answer the questions related to the project one by one'
|
|
54
|
+
'Whether or not you want to be asked to answer the questions related to the project one by one.'
|
|
52
55
|
)
|
|
53
56
|
.alias('F', 'fastify')
|
|
54
|
-
.describe('F', 'Whether or not you want to use Fastify for your project')
|
|
57
|
+
.describe('F', 'Whether or not you want to use Fastify for your project.')
|
|
55
58
|
.alias('g', 'graphql')
|
|
56
|
-
.describe('g', 'Whether or not you want to use GraphQL for your project')
|
|
59
|
+
.describe('g', 'Whether or not you want to use GraphQL for your project.')
|
|
57
60
|
.alias('t', 'tests')
|
|
58
61
|
.describe(
|
|
59
62
|
't',
|
|
60
|
-
'Whether or not you want to have a basic suit of unit tests with Jest'
|
|
63
|
+
'Whether or not you want to have a basic suit of unit tests with Jest.'
|
|
61
64
|
)
|
|
62
65
|
.alias('ghat', 'gh-action-tests')
|
|
63
66
|
.describe(
|
|
64
67
|
'ghat',
|
|
65
68
|
'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
69
|
)
|
|
70
|
+
.describe(
|
|
71
|
+
'd',
|
|
72
|
+
'Which database you want to use, available databases are: MongoDB, PostgreSQL, MySQL, MariaDB, Sqlite and Microsoft SQL Server.'
|
|
73
|
+
)
|
|
74
|
+
.alias('d', 'database')
|
|
75
|
+
.nargs('d', 1)
|
|
67
76
|
.default({
|
|
68
77
|
H: false,
|
|
69
78
|
n: false,
|
|
@@ -75,7 +84,8 @@ const argv = yargs(hideBin(process.argv))
|
|
|
75
84
|
F: false,
|
|
76
85
|
g: false,
|
|
77
86
|
t: false,
|
|
78
|
-
ghat: false
|
|
87
|
+
ghat: false,
|
|
88
|
+
d: 'mongo'
|
|
79
89
|
})
|
|
80
90
|
.boolean(['H', 'n', 'q', 'F', 'g', 't'])
|
|
81
91
|
.help('h')
|
|
@@ -98,7 +108,8 @@ const config = {
|
|
|
98
108
|
fastify: false,
|
|
99
109
|
graphql: false,
|
|
100
110
|
tests: true,
|
|
101
|
-
ghat: true
|
|
111
|
+
ghat: true,
|
|
112
|
+
database: 'mongo'
|
|
102
113
|
}
|
|
103
114
|
const UNLICENSED = 'unlicensed'
|
|
104
115
|
const LICENSES = [
|
|
@@ -109,6 +120,14 @@ const LICENSES = [
|
|
|
109
120
|
'GPL 3.0',
|
|
110
121
|
'AGPL 3.0'
|
|
111
122
|
]
|
|
123
|
+
const DATABASES = {
|
|
124
|
+
MongoDB: 'mongo',
|
|
125
|
+
PostgreSQL: 'postgres',
|
|
126
|
+
MySQL: 'mysql',
|
|
127
|
+
MariaDB: 'mariadb',
|
|
128
|
+
Sqlite: 'sqlite',
|
|
129
|
+
'Microsoft SQL Server': 'sqlServer'
|
|
130
|
+
}
|
|
112
131
|
const POSSIBLE_LICENSES = ['mit', 'apache', 'mpl', 'lgpl', 'gpl', 'agpl']
|
|
113
132
|
const ONE_CHARACTER_REGEXP = /^\w/
|
|
114
133
|
const YEAR_REGEXP = /^\d{4}$/
|
|
@@ -245,6 +264,14 @@ const main = async () => {
|
|
|
245
264
|
}
|
|
246
265
|
)
|
|
247
266
|
else config.ghat = false
|
|
267
|
+
|
|
268
|
+
config.database = readLineSync.keyInSelect(
|
|
269
|
+
Object.keys(DATABASES),
|
|
270
|
+
'> Select your database: ',
|
|
271
|
+
{
|
|
272
|
+
cancel: false
|
|
273
|
+
}
|
|
274
|
+
)
|
|
248
275
|
} else {
|
|
249
276
|
if (!argv.author) return console.log('Error! An author is required!')
|
|
250
277
|
else config.author = argv.author
|
|
@@ -327,6 +354,8 @@ const main = async () => {
|
|
|
327
354
|
return console.log(
|
|
328
355
|
'GitHub Action for tests can not be set to true if the tests flag is set to false'
|
|
329
356
|
)
|
|
357
|
+
|
|
358
|
+
if (argv.database) config.database = argv.database
|
|
330
359
|
}
|
|
331
360
|
|
|
332
361
|
await installation(config)
|
|
@@ -349,4 +378,6 @@ module.exports = main
|
|
|
349
378
|
* @property {String} mainFile main file of the project
|
|
350
379
|
* @property {Boolean} fastify true means that the project will be using Fastify
|
|
351
380
|
* @property {Boolean} graphql true means that the project will be using GraphQL
|
|
381
|
+
* @property {'mongo'|'postgres'|'mysql'|'mariadb'|'sqlite'|'sqlServer'} database project database
|
|
382
|
+
* @property {Boolean} tests true means that the project will have tests
|
|
352
383
|
*/
|
|
@@ -57,7 +57,7 @@ const dbConnection = async (
|
|
|
57
57
|
'Mongo connection disconnected. Trying to reconnected to Mongo...'
|
|
58
58
|
)
|
|
59
59
|
setTimeout(() => {
|
|
60
|
-
connect(process.env.
|
|
60
|
+
connect(process.env.DB_URI as string, {
|
|
61
61
|
...connection,
|
|
62
62
|
connectTimeoutMS: 3000,
|
|
63
63
|
socketTimeoutMS: 3000
|
|
@@ -74,7 +74,7 @@ const dbConnection = async (
|
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
return {
|
|
77
|
-
connect: () => connect(process.env.
|
|
77
|
+
connect: () => connect(process.env.DB_URI as string, connectionConfig),
|
|
78
78
|
disconnect: () => connection.close()
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -113,7 +113,7 @@ const dbConnection = async (
|
|
|
113
113
|
'Mongo connection disconnected. Trying to reconnected to Mongo...'
|
|
114
114
|
)
|
|
115
115
|
setTimeout(() => {
|
|
116
|
-
connect(process.env.
|
|
116
|
+
connect(process.env.DB_URI as string, {
|
|
117
117
|
...connection,
|
|
118
118
|
connectTimeoutMS: 3000,
|
|
119
119
|
socketTimeoutMS: 3000
|
|
@@ -130,7 +130,7 @@ const dbConnection = async (
|
|
|
130
130
|
})
|
|
131
131
|
|
|
132
132
|
return {
|
|
133
|
-
connect: () => connect(process.env.
|
|
133
|
+
connect: () => connect(process.env.DB_URI as string, connectionConfig),
|
|
134
134
|
disconnect: () => connection.close()
|
|
135
135
|
}
|
|
136
136
|
}
|