pwi-plata-type 0.4.166 → 0.4.167
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 +2 -2
- package/__BUILD__/libs/sql.js +4 -1
- package/__BUILD__/libs/sql.js.map +1 -1
- package/package.json +53 -53
- package/src/@types/build.d.ts +26 -26
- package/src/@types/cluster.actions.d.ts +27 -27
- package/src/@types/cluster.d.ts +55 -55
- package/src/@types/create-cli.d.ts +8 -8
- package/src/@types/exported.d.ts +31 -31
- package/src/@types/fs.d.ts +6 -6
- package/src/@types/global.d.ts +113 -113
- package/src/@types/knex.d.ts +13 -13
- package/src/@types/model.d.ts +143 -143
- package/src/@types/router.d.ts +107 -107
- package/src/@types/sql.d.ts +75 -75
- package/src/@types/swagger.d.ts +22 -22
- package/src/bin/extras/create-api-cli.ts +218 -218
- package/src/bin/extras/create-cluster-cli.ts +160 -160
- package/src/bin/extras/create-lib-cli.ts +84 -84
- package/src/bin/extras/plata-create-tools.ts +97 -97
- package/src/bin/plata-api.ts +189 -189
- package/src/bin/plata-build.ts +17 -17
- package/src/bin/plata-cluster.ts +42 -42
- package/src/bin/plata-cmd.ts +18 -18
- package/src/bin/plata-create.ts +49 -49
- package/src/bin/plata-runtime.ts +131 -131
- package/src/bin/plata-swagger.ts +99 -99
- package/src/bin/runtime/_setupRuntime.ts +48 -48
- package/src/bin/runtime/_types.d.ts +7 -7
- package/src/bin/runtime/class.ts +20 -20
- package/src/bin/runtime/dirs.ts +25 -25
- package/src/bin/runtime/effect.ts +60 -60
- package/src/bin/runtime/fs.ts +10 -10
- package/src/bin/runtime/promises.ts +18 -18
- package/src/bin/runtime/require.ts +113 -113
- package/src/bin/runtime/sql.ts +12 -12
- package/src/bin/runtime/switch.ts +60 -60
- package/src/index.ts +19 -19
- package/src/libs/axios.ts +51 -51
- package/src/libs/build.ts +162 -162
- package/src/libs/cluster/cluster-controller.ts +93 -93
- package/src/libs/cluster.ts +330 -330
- package/src/libs/custom.ts +15 -15
- package/src/libs/env.ts +10 -10
- package/src/libs/fs.ts +399 -399
- package/src/libs/hot-reload.ts +63 -63
- package/src/libs/models/index.ts +4 -4
- package/src/libs/models/model-template-combine.ts +93 -93
- package/src/libs/models/model-template-env.ts +58 -58
- package/src/libs/models/model-template-union.ts +83 -83
- package/src/libs/models/model-template.ts +107 -107
- package/src/libs/models/model-validations.ts +443 -443
- package/src/libs/models/tools.ts +194 -194
- package/src/libs/router.ts +185 -185
- package/src/libs/sql.ts +792 -788
- package/src/libs/swagger.ts +81 -81
- package/src/libs/tools.ts +240 -240
- package/src/scripts/post-install/api.ts +32 -32
- package/src/scripts/post-install/cluster.ts +28 -28
- package/src/scripts/post-install/lib.ts +25 -25
- package/src/scripts/post-install.ts +64 -64
- package/src/scripts/pre-test.ts +33 -33
- package/src/tests/assets/sql/example.sql +76 -76
- package/src/tests/config.test.ts +12 -12
- package/src/tests/effect.test.ts +62 -62
- package/src/tests/model.env.test.ts +66 -66
- package/src/tests/model.test.ts +141 -141
- package/src/tests/model.union.test.ts +160 -160
- package/src/tests/router.test.ts +44 -44
- package/src/tests/sql.test.ts +502 -502
- package/src/tests/switch.test.ts +76 -76
- package/templates/create-cli/class.ts +13 -13
- package/templates/create-cli/cluster.ts +14 -14
- package/templates/create-cli/cmd.ts +3 -3
- package/templates/create-cli/config.ts +2 -2
- package/templates/create-cli/lib.ts +3 -3
- package/templates/create-cli/model.ts +14 -14
- package/templates/create-cli/route.ts +8 -8
- package/templates/create-cli/task.ts +13 -13
- package/templates/postinstall/api/.vscode/launch.json +20 -20
- package/templates/postinstall/api/Dockerfile +24 -24
- package/templates/postinstall/api/configs/env.ts +2 -2
- package/templates/postinstall/api/envs/debug.env +15 -15
- package/templates/postinstall/api/envs/homolog.env +15 -15
- package/templates/postinstall/api/envs/prod.env +15 -15
- package/templates/postinstall/api/tsconfig.json +24 -24
- package/templates/postinstall/cluster/.vscode/launch.json +20 -20
- package/templates/postinstall/cluster/Dockerfile +24 -24
- package/templates/postinstall/cluster/configs/env.ts +2 -2
- package/templates/postinstall/cluster/envs/debug.env +10 -10
- package/templates/postinstall/cluster/envs/homolog.env +10 -10
- package/templates/postinstall/cluster/envs/prod.env +10 -10
- package/templates/postinstall/cluster/tsconfig.json +24 -24
- package/templates/postinstall/lib/postinstall-tools.mjs +111 -111
- package/templates/postinstall/lib/postinstall.js +33 -33
- package/templates/postinstall/lib/tsconfig.json +22 -22
- package/templates/swagger-cli/header.json +21 -21
- package/templates/swagger-cli/route/body.json +14 -14
- package/templates/swagger-cli/route/header.json +18 -18
- package/templates/swagger-cli/route/response.json +53 -53
- package/tsconfig.json +28 -28
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import { tools } from "./plata-create-tools";
|
|
2
|
-
import { Command } from 'commander'
|
|
3
|
-
import path from 'node:path'
|
|
4
|
-
|
|
5
|
-
const program = new Command()
|
|
6
|
-
|
|
7
|
-
program.name('Plata Create cli')
|
|
8
|
-
program.description('CLI usada para criar rotas, libs, models e muito mais na plata')
|
|
9
|
-
program.version(Plata.PlataJson.version)
|
|
10
|
-
|
|
11
|
-
program.command('lib <libs...>')
|
|
12
|
-
.description('Cria uma lib utilizando o templete da plata')
|
|
13
|
-
.action(async libs => {
|
|
14
|
-
if (!Array.isArray(libs)) {
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const promises: any[] = []
|
|
19
|
-
|
|
20
|
-
for (const lib of libs) {
|
|
21
|
-
promises.push(tools.files.deployFileToProject(
|
|
22
|
-
'libs',
|
|
23
|
-
'lib',
|
|
24
|
-
`${lib}.ts`.toLowerCase(),
|
|
25
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
26
|
-
).finally(() => console.log(`Config ${lib} criada`)))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
await Promise.all(promises)
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
;
|
|
33
|
-
|
|
34
|
-
program.command('class <classes...>')
|
|
35
|
-
.description('Cria uma config com e uma clase utilizando o templete da plata')
|
|
36
|
-
.action(async clazzs => {
|
|
37
|
-
if (!Array.isArray(clazzs)) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const promises: any[] = []
|
|
42
|
-
|
|
43
|
-
for (const lib of clazzs) {
|
|
44
|
-
promises.push(tools.files.deployFileToProject(
|
|
45
|
-
'configs',
|
|
46
|
-
'config',
|
|
47
|
-
`${lib}.ts`.toLowerCase(),
|
|
48
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
49
|
-
).finally(() => console.log(`Config ${lib} criada`)))
|
|
50
|
-
|
|
51
|
-
promises.push(tools.files.deployFileToProject(
|
|
52
|
-
'libs',
|
|
53
|
-
'class',
|
|
54
|
-
`${lib}.ts`.toLowerCase(),
|
|
55
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
56
|
-
).finally(() => console.log(`Classe ${lib} criada`)))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
await Promise.all(promises)
|
|
60
|
-
})
|
|
61
|
-
;
|
|
62
|
-
|
|
63
|
-
program.command('config <configs...>')
|
|
64
|
-
.description('Cria uma config utilizando o templete da plata')
|
|
65
|
-
.action(async configs => {
|
|
66
|
-
if (!Array.isArray(configs)) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const promises: any[] = []
|
|
71
|
-
|
|
72
|
-
for (const config of configs) {
|
|
73
|
-
promises.push(tools.files.deployFileToProject(
|
|
74
|
-
'configs',
|
|
75
|
-
'config',
|
|
76
|
-
`${config}.ts`.toLowerCase(),
|
|
77
|
-
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
78
|
-
).finally(() => console.log(`Config ${config} criada`)))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await Promise.all(promises)
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
;
|
|
85
|
-
|
|
86
|
-
program.command('model <models...>')
|
|
87
|
-
.description('Cria um model utilizando o templete da plata')
|
|
88
|
-
.action(async models => {
|
|
89
|
-
if (!Array.isArray(models)) {
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const promises: any[] = []
|
|
94
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
95
|
-
|
|
96
|
-
for (const model of models) {
|
|
97
|
-
promises.push(tools.files.deployFileToProject(
|
|
98
|
-
'models',
|
|
99
|
-
'model',
|
|
100
|
-
`${model}.ts`.toLowerCase(),
|
|
101
|
-
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
102
|
-
).finally(() => console.log(`Model ${model} criada`)))
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
await Promise.all(promises)
|
|
106
|
-
})
|
|
107
|
-
;
|
|
108
|
-
|
|
109
|
-
program.command('cluster <clusters...>')
|
|
110
|
-
.description('Cria o arquivo do worker utilizando o templete da plata')
|
|
111
|
-
.action(async clusters => {
|
|
112
|
-
if (!Array.isArray(clusters)) return
|
|
113
|
-
|
|
114
|
-
const promises: any[] = []
|
|
115
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
116
|
-
|
|
117
|
-
for (const cluster of clusters) {
|
|
118
|
-
promises.push(tools.files.deployFileToProject(
|
|
119
|
-
'clusters',
|
|
120
|
-
'cluster',
|
|
121
|
-
`${cluster}.ts`.toLowerCase(),
|
|
122
|
-
{ Name: `${cluster}`, name: `${cluster}`.toLowerCase(), PlataName: `${plataName}` }
|
|
123
|
-
).finally(() => console.log(`Worker ${cluster} criada`)))
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
;
|
|
127
|
-
|
|
128
|
-
program.command('cmd <cmds...>')
|
|
129
|
-
.description('Cria o arquivo de um comando cmd')
|
|
130
|
-
.action(async cmds => {
|
|
131
|
-
if (!Array.isArray(cmds)) return
|
|
132
|
-
|
|
133
|
-
for (const cmd of cmds) {
|
|
134
|
-
await tools.files.deployFileToProject(
|
|
135
|
-
'cmds',
|
|
136
|
-
'cmd',
|
|
137
|
-
`${cmd}.ts`.toLowerCase(),
|
|
138
|
-
{}
|
|
139
|
-
).finally(() => console.log(`Cmd ${cmd} criado`))
|
|
140
|
-
|
|
141
|
-
Plata.ProjectJson['my-scripts'] = Plata.ProjectJson['my-scripts'] ?? Object.create(null)
|
|
142
|
-
|
|
143
|
-
if (Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] === undefined) {
|
|
144
|
-
Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] = `plata-runtime + plata-cmd ${cmd}`
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
Plata.ProjectJson.scripts = JSON.parse(JSON.stringify({
|
|
148
|
-
...Plata.ProjectJson['my-scripts'],
|
|
149
|
-
...Plata.ProjectJson.scripts,
|
|
150
|
-
}))
|
|
151
|
-
|
|
152
|
-
await Plata.files.fs
|
|
153
|
-
.writeFile(
|
|
154
|
-
path.join(Plata.ProjectDir, 'package.json'),
|
|
155
|
-
JSON.stringify(Plata.ProjectJson, null, 4)
|
|
156
|
-
)
|
|
157
|
-
;
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
|
|
1
|
+
import { tools } from "./plata-create-tools";
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
const program = new Command()
|
|
6
|
+
|
|
7
|
+
program.name('Plata Create cli')
|
|
8
|
+
program.description('CLI usada para criar rotas, libs, models e muito mais na plata')
|
|
9
|
+
program.version(Plata.PlataJson.version)
|
|
10
|
+
|
|
11
|
+
program.command('lib <libs...>')
|
|
12
|
+
.description('Cria uma lib utilizando o templete da plata')
|
|
13
|
+
.action(async libs => {
|
|
14
|
+
if (!Array.isArray(libs)) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const promises: any[] = []
|
|
19
|
+
|
|
20
|
+
for (const lib of libs) {
|
|
21
|
+
promises.push(tools.files.deployFileToProject(
|
|
22
|
+
'libs',
|
|
23
|
+
'lib',
|
|
24
|
+
`${lib}.ts`.toLowerCase(),
|
|
25
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
26
|
+
).finally(() => console.log(`Config ${lib} criada`)))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await Promise.all(promises)
|
|
30
|
+
|
|
31
|
+
})
|
|
32
|
+
;
|
|
33
|
+
|
|
34
|
+
program.command('class <classes...>')
|
|
35
|
+
.description('Cria uma config com e uma clase utilizando o templete da plata')
|
|
36
|
+
.action(async clazzs => {
|
|
37
|
+
if (!Array.isArray(clazzs)) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const promises: any[] = []
|
|
42
|
+
|
|
43
|
+
for (const lib of clazzs) {
|
|
44
|
+
promises.push(tools.files.deployFileToProject(
|
|
45
|
+
'configs',
|
|
46
|
+
'config',
|
|
47
|
+
`${lib}.ts`.toLowerCase(),
|
|
48
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
49
|
+
).finally(() => console.log(`Config ${lib} criada`)))
|
|
50
|
+
|
|
51
|
+
promises.push(tools.files.deployFileToProject(
|
|
52
|
+
'libs',
|
|
53
|
+
'class',
|
|
54
|
+
`${lib}.ts`.toLowerCase(),
|
|
55
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
56
|
+
).finally(() => console.log(`Classe ${lib} criada`)))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await Promise.all(promises)
|
|
60
|
+
})
|
|
61
|
+
;
|
|
62
|
+
|
|
63
|
+
program.command('config <configs...>')
|
|
64
|
+
.description('Cria uma config utilizando o templete da plata')
|
|
65
|
+
.action(async configs => {
|
|
66
|
+
if (!Array.isArray(configs)) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const promises: any[] = []
|
|
71
|
+
|
|
72
|
+
for (const config of configs) {
|
|
73
|
+
promises.push(tools.files.deployFileToProject(
|
|
74
|
+
'configs',
|
|
75
|
+
'config',
|
|
76
|
+
`${config}.ts`.toLowerCase(),
|
|
77
|
+
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
78
|
+
).finally(() => console.log(`Config ${config} criada`)))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await Promise.all(promises)
|
|
82
|
+
|
|
83
|
+
})
|
|
84
|
+
;
|
|
85
|
+
|
|
86
|
+
program.command('model <models...>')
|
|
87
|
+
.description('Cria um model utilizando o templete da plata')
|
|
88
|
+
.action(async models => {
|
|
89
|
+
if (!Array.isArray(models)) {
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const promises: any[] = []
|
|
94
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
95
|
+
|
|
96
|
+
for (const model of models) {
|
|
97
|
+
promises.push(tools.files.deployFileToProject(
|
|
98
|
+
'models',
|
|
99
|
+
'model',
|
|
100
|
+
`${model}.ts`.toLowerCase(),
|
|
101
|
+
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
102
|
+
).finally(() => console.log(`Model ${model} criada`)))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
await Promise.all(promises)
|
|
106
|
+
})
|
|
107
|
+
;
|
|
108
|
+
|
|
109
|
+
program.command('cluster <clusters...>')
|
|
110
|
+
.description('Cria o arquivo do worker utilizando o templete da plata')
|
|
111
|
+
.action(async clusters => {
|
|
112
|
+
if (!Array.isArray(clusters)) return
|
|
113
|
+
|
|
114
|
+
const promises: any[] = []
|
|
115
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
116
|
+
|
|
117
|
+
for (const cluster of clusters) {
|
|
118
|
+
promises.push(tools.files.deployFileToProject(
|
|
119
|
+
'clusters',
|
|
120
|
+
'cluster',
|
|
121
|
+
`${cluster}.ts`.toLowerCase(),
|
|
122
|
+
{ Name: `${cluster}`, name: `${cluster}`.toLowerCase(), PlataName: `${plataName}` }
|
|
123
|
+
).finally(() => console.log(`Worker ${cluster} criada`)))
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
;
|
|
127
|
+
|
|
128
|
+
program.command('cmd <cmds...>')
|
|
129
|
+
.description('Cria o arquivo de um comando cmd')
|
|
130
|
+
.action(async cmds => {
|
|
131
|
+
if (!Array.isArray(cmds)) return
|
|
132
|
+
|
|
133
|
+
for (const cmd of cmds) {
|
|
134
|
+
await tools.files.deployFileToProject(
|
|
135
|
+
'cmds',
|
|
136
|
+
'cmd',
|
|
137
|
+
`${cmd}.ts`.toLowerCase(),
|
|
138
|
+
{}
|
|
139
|
+
).finally(() => console.log(`Cmd ${cmd} criado`))
|
|
140
|
+
|
|
141
|
+
Plata.ProjectJson['my-scripts'] = Plata.ProjectJson['my-scripts'] ?? Object.create(null)
|
|
142
|
+
|
|
143
|
+
if (Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] === undefined) {
|
|
144
|
+
Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] = `plata-runtime + plata-cmd ${cmd}`
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
Plata.ProjectJson.scripts = JSON.parse(JSON.stringify({
|
|
148
|
+
...Plata.ProjectJson['my-scripts'],
|
|
149
|
+
...Plata.ProjectJson.scripts,
|
|
150
|
+
}))
|
|
151
|
+
|
|
152
|
+
await Plata.files.fs
|
|
153
|
+
.writeFile(
|
|
154
|
+
path.join(Plata.ProjectDir, 'package.json'),
|
|
155
|
+
JSON.stringify(Plata.ProjectJson, null, 4)
|
|
156
|
+
)
|
|
157
|
+
;
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
|
|
161
161
|
export const cli = program
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { tools } from "./plata-create-tools";
|
|
2
|
-
import { Command } from 'commander'
|
|
3
|
-
|
|
4
|
-
const program = new Command()
|
|
5
|
-
|
|
6
|
-
program.name('Plata Create cli')
|
|
7
|
-
program.description('CLI usada para criar rotas, libs, models e muito mais na plata')
|
|
8
|
-
program.version(Plata.PlataJson.version)
|
|
9
|
-
|
|
10
|
-
program.command('lib <libs...>')
|
|
11
|
-
.description('Cria uma config com e uma lib utilizando o templete da plata')
|
|
12
|
-
.action(async libs => {
|
|
13
|
-
if (!Array.isArray(libs)) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const promises: any[] = []
|
|
18
|
-
|
|
19
|
-
for (const lib of libs) {
|
|
20
|
-
promises.push(tools.files.deployFileToProject(
|
|
21
|
-
'configs',
|
|
22
|
-
'config',
|
|
23
|
-
`${lib}.ts`.toLowerCase(),
|
|
24
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
25
|
-
).finally(() => console.log(`Config ${lib} criada`)))
|
|
26
|
-
|
|
27
|
-
promises.push(tools.files.deployFileToProject(
|
|
28
|
-
'libs',
|
|
29
|
-
'lib',
|
|
30
|
-
`${lib}.ts`.toLowerCase(),
|
|
31
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
32
|
-
).finally(() => console.log(`Lib ${lib} criada`)))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
await Promise.all(promises)
|
|
36
|
-
})
|
|
37
|
-
;
|
|
38
|
-
|
|
39
|
-
program.command('config <configs...>')
|
|
40
|
-
.description('Cria uma config utilizando o templete da plata')
|
|
41
|
-
.action(async configs => {
|
|
42
|
-
if (!Array.isArray(configs)) {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const promises: any[] = []
|
|
47
|
-
|
|
48
|
-
for (const config of configs) {
|
|
49
|
-
promises.push(tools.files.deployFileToProject(
|
|
50
|
-
'configs',
|
|
51
|
-
'config',
|
|
52
|
-
`${config}.ts`.toLowerCase(),
|
|
53
|
-
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
54
|
-
).finally(() => console.log(`Config ${config} criada`)))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await Promise.all(promises)
|
|
58
|
-
|
|
59
|
-
})
|
|
60
|
-
;
|
|
61
|
-
|
|
62
|
-
program.command('model <models...>')
|
|
63
|
-
.description('Cria um model utilizando o templete da plata')
|
|
64
|
-
.action(async models => {
|
|
65
|
-
if (!Array.isArray(models)) {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const promises: any[] = []
|
|
70
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
71
|
-
|
|
72
|
-
for (const model of models) {
|
|
73
|
-
promises.push(tools.files.deployFileToProject(
|
|
74
|
-
'models',
|
|
75
|
-
'model',
|
|
76
|
-
`${model}.ts`.toLowerCase(),
|
|
77
|
-
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
78
|
-
).finally(() => console.log(`Model ${model} criada`)))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await Promise.all(promises)
|
|
82
|
-
})
|
|
83
|
-
;
|
|
84
|
-
|
|
1
|
+
import { tools } from "./plata-create-tools";
|
|
2
|
+
import { Command } from 'commander'
|
|
3
|
+
|
|
4
|
+
const program = new Command()
|
|
5
|
+
|
|
6
|
+
program.name('Plata Create cli')
|
|
7
|
+
program.description('CLI usada para criar rotas, libs, models e muito mais na plata')
|
|
8
|
+
program.version(Plata.PlataJson.version)
|
|
9
|
+
|
|
10
|
+
program.command('lib <libs...>')
|
|
11
|
+
.description('Cria uma config com e uma lib utilizando o templete da plata')
|
|
12
|
+
.action(async libs => {
|
|
13
|
+
if (!Array.isArray(libs)) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const promises: any[] = []
|
|
18
|
+
|
|
19
|
+
for (const lib of libs) {
|
|
20
|
+
promises.push(tools.files.deployFileToProject(
|
|
21
|
+
'configs',
|
|
22
|
+
'config',
|
|
23
|
+
`${lib}.ts`.toLowerCase(),
|
|
24
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
25
|
+
).finally(() => console.log(`Config ${lib} criada`)))
|
|
26
|
+
|
|
27
|
+
promises.push(tools.files.deployFileToProject(
|
|
28
|
+
'libs',
|
|
29
|
+
'lib',
|
|
30
|
+
`${lib}.ts`.toLowerCase(),
|
|
31
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
32
|
+
).finally(() => console.log(`Lib ${lib} criada`)))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await Promise.all(promises)
|
|
36
|
+
})
|
|
37
|
+
;
|
|
38
|
+
|
|
39
|
+
program.command('config <configs...>')
|
|
40
|
+
.description('Cria uma config utilizando o templete da plata')
|
|
41
|
+
.action(async configs => {
|
|
42
|
+
if (!Array.isArray(configs)) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const promises: any[] = []
|
|
47
|
+
|
|
48
|
+
for (const config of configs) {
|
|
49
|
+
promises.push(tools.files.deployFileToProject(
|
|
50
|
+
'configs',
|
|
51
|
+
'config',
|
|
52
|
+
`${config}.ts`.toLowerCase(),
|
|
53
|
+
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
54
|
+
).finally(() => console.log(`Config ${config} criada`)))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await Promise.all(promises)
|
|
58
|
+
|
|
59
|
+
})
|
|
60
|
+
;
|
|
61
|
+
|
|
62
|
+
program.command('model <models...>')
|
|
63
|
+
.description('Cria um model utilizando o templete da plata')
|
|
64
|
+
.action(async models => {
|
|
65
|
+
if (!Array.isArray(models)) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const promises: any[] = []
|
|
70
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
71
|
+
|
|
72
|
+
for (const model of models) {
|
|
73
|
+
promises.push(tools.files.deployFileToProject(
|
|
74
|
+
'models',
|
|
75
|
+
'model',
|
|
76
|
+
`${model}.ts`.toLowerCase(),
|
|
77
|
+
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
78
|
+
).finally(() => console.log(`Model ${model} criada`)))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await Promise.all(promises)
|
|
82
|
+
})
|
|
83
|
+
;
|
|
84
|
+
|
|
85
85
|
export const cli = program
|