pwi-plata-type 0.4.201 → 0.4.202
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/package.json +58 -58
- 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 +34 -31
- package/src/@types/fs.d.ts +6 -6
- package/src/@types/global.d.ts +131 -131
- 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 +120 -120
- 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 +19 -19
- package/src/bin/plata-cluster.ts +42 -42
- package/src/bin/plata-cmd.ts +19 -19
- package/src/bin/plata-create.ts +50 -50
- package/src/bin/plata-runtime.ts +110 -110
- package/src/bin/plata-swagger.ts +104 -104
- package/src/index.ts +20 -20
- package/src/libs/axios.ts +32 -32
- package/src/libs/build.ts +234 -234
- package/src/libs/build_wasm.ts +169 -169
- package/src/libs/cluster/cluster-controller.ts +93 -93
- package/src/libs/cluster.ts +319 -319
- package/src/libs/custom.ts +21 -21
- 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/job.ts +32 -32
- 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 +87 -87
- package/src/libs/models/model-template.ts +111 -111
- package/src/libs/models/model-validations.ts +453 -453
- package/src/libs/models/tools.ts +196 -196
- package/src/libs/router.ts +184 -184
- package/src/libs/runtime.ts +328 -328
- package/src/libs/sql.ts +931 -931
- package/src/libs/swagger.ts +81 -81
- package/src/libs/tools.ts +236 -236
- package/src/misc/golang/wasm_exec.js +574 -574
- 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/1-config.test.ts +12 -12
- package/src/tests/2-effect.test.ts +107 -107
- package/src/tests/3-model.env.test.ts +66 -66
- package/src/tests/4-model.test.ts +150 -150
- package/src/tests/5-model.union.test.ts +160 -160
- package/src/tests/6-router.test.ts +44 -44
- package/src/tests/7-switch.test.ts +75 -75
- package/src/tests/8-brands.test.ts +52 -52
- package/src/tests/9-sql.test.ts +639 -639
- package/src/tests/assets/sql/example.sql +94 -94
- 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 +22 -22
- 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,219 +1,219 @@
|
|
|
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('route <routes...>')
|
|
12
|
-
.description('Cria uma rota utilizando o templete da plata')
|
|
13
|
-
.action(async routes => {
|
|
14
|
-
if (!Array.isArray(routes)) {
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const promises: any[] = []
|
|
19
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
20
|
-
|
|
21
|
-
for (const route of routes) {
|
|
22
|
-
const r = `${route}/`.replace(/:(.*?)(?:\/|$)/g, (_, parm) => {
|
|
23
|
-
return parm[parm.length - 1] !== '?' ? `{${parm}}/` : `[${parm.slice(0, -1)}]/`
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const routeArg = r.slice(0, -1).split('/')
|
|
27
|
-
|
|
28
|
-
const routeFileName = routeArg[routeArg.length - 1] === '' ? 'index' : routeArg.pop()
|
|
29
|
-
const routeFilePath = path.join('routes', ...routeArg.filter(v => v !== ''))
|
|
30
|
-
|
|
31
|
-
promises.push(tools.files.deployFileToProject(
|
|
32
|
-
routeFilePath,
|
|
33
|
-
'route',
|
|
34
|
-
`${routeFileName}.ts`,
|
|
35
|
-
{ PlataName: `${plataName}` }
|
|
36
|
-
).finally(() => console.log(
|
|
37
|
-
`Rota ${routeFilePath}/${routeFileName === 'index' ? '' : routeFileName} criada`
|
|
38
|
-
)))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
await Promise.all(promises)
|
|
42
|
-
})
|
|
43
|
-
;
|
|
44
|
-
|
|
45
|
-
program.command('lib <libs...>')
|
|
46
|
-
.description('Cria uma lib utilizando o templete da plata')
|
|
47
|
-
.action(async libs => {
|
|
48
|
-
if (!Array.isArray(libs)) {
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const promises: any[] = []
|
|
53
|
-
|
|
54
|
-
for (const lib of libs) {
|
|
55
|
-
promises.push(tools.files.deployFileToProject(
|
|
56
|
-
'libs',
|
|
57
|
-
'lib',
|
|
58
|
-
`${lib}.ts`.toLowerCase(),
|
|
59
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
60
|
-
).finally(() => console.log(`Config ${lib} criada`)))
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
await Promise.all(promises)
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
program.command('class <classes...>')
|
|
70
|
-
.description('Cria uma config com e uma clase utilizando o templete da plata')
|
|
71
|
-
.action(async clazzs => {
|
|
72
|
-
if (!Array.isArray(clazzs)) {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const promises: any[] = []
|
|
77
|
-
|
|
78
|
-
for (const lib of clazzs) {
|
|
79
|
-
promises.push(tools.files.deployFileToProject(
|
|
80
|
-
'configs',
|
|
81
|
-
'config',
|
|
82
|
-
`${lib}.ts`.toLowerCase(),
|
|
83
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
84
|
-
).finally(() => console.log(`Config ${lib} criada`)))
|
|
85
|
-
|
|
86
|
-
promises.push(tools.files.deployFileToProject(
|
|
87
|
-
'libs',
|
|
88
|
-
'class',
|
|
89
|
-
`${lib}.ts`.toLowerCase(),
|
|
90
|
-
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
91
|
-
).finally(() => console.log(`Classe ${lib} criada`)))
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
await Promise.all(promises)
|
|
95
|
-
})
|
|
96
|
-
;
|
|
97
|
-
|
|
98
|
-
program.command('config <configs...>')
|
|
99
|
-
.description('Cria uma config utilizando o templete da plata')
|
|
100
|
-
.action(async configs => {
|
|
101
|
-
if (!Array.isArray(configs)) {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const promises: any[] = []
|
|
106
|
-
|
|
107
|
-
for (const config of configs) {
|
|
108
|
-
promises.push(tools.files.deployFileToProject(
|
|
109
|
-
'configs',
|
|
110
|
-
'config',
|
|
111
|
-
`${config}.ts`.toLowerCase(),
|
|
112
|
-
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
113
|
-
).finally(() => console.log(`Config ${config} criada`)))
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
await Promise.all(promises)
|
|
117
|
-
|
|
118
|
-
})
|
|
119
|
-
;
|
|
120
|
-
|
|
121
|
-
program.command('model <models...>')
|
|
122
|
-
.description('Cria um model utilizando o templete da plata')
|
|
123
|
-
.action(async models => {
|
|
124
|
-
if (!Array.isArray(models)) {
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const promises: any[] = []
|
|
129
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
130
|
-
|
|
131
|
-
for (const model of models) {
|
|
132
|
-
promises.push(tools.files.deployFileToProject(
|
|
133
|
-
'models',
|
|
134
|
-
'model',
|
|
135
|
-
`${model}.ts`.toLowerCase(),
|
|
136
|
-
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
137
|
-
).finally(() => console.log(`Model ${model} criada`)))
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
await Promise.all(promises)
|
|
141
|
-
})
|
|
142
|
-
;
|
|
143
|
-
|
|
144
|
-
program.command('task <tasks...>')
|
|
145
|
-
.description('Cria uma task utilizando o templete da plata')
|
|
146
|
-
.action(async tasks => {
|
|
147
|
-
if (!Array.isArray(tasks)) {
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const promises: any[] = []
|
|
152
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
153
|
-
|
|
154
|
-
for (const task of tasks) {
|
|
155
|
-
promises.push(tools.files.deployFileToProject(
|
|
156
|
-
'tasks',
|
|
157
|
-
'task',
|
|
158
|
-
`${task}.ts`.toLowerCase(),
|
|
159
|
-
{ Name: `${task}`, PlataName: `${plataName}` }
|
|
160
|
-
).finally(() => console.log(`Task ${tasks} criada`)))
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
await Promise.all(promises)
|
|
164
|
-
})
|
|
165
|
-
;
|
|
166
|
-
|
|
167
|
-
program.command('cluster <clusters...>')
|
|
168
|
-
.description('Cria o arquivo do worker utilizando o templete da plata')
|
|
169
|
-
.action(async clusters => {
|
|
170
|
-
if (!Array.isArray(clusters)) return
|
|
171
|
-
|
|
172
|
-
const promises: any[] = []
|
|
173
|
-
const plataName = Plata.ProjectJson.plata_name
|
|
174
|
-
|
|
175
|
-
for (const cluster of clusters) {
|
|
176
|
-
promises.push(tools.files.deployFileToProject(
|
|
177
|
-
'clusters',
|
|
178
|
-
'cluster',
|
|
179
|
-
`${cluster}.ts`.toLowerCase(),
|
|
180
|
-
{ Name: `${cluster}`, name: `${cluster}`.toLowerCase(), PlataName: `${plataName}` }
|
|
181
|
-
).finally(() => console.log(`Worker ${cluster} criada`)))
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
;
|
|
185
|
-
|
|
186
|
-
program.command('cmd <cmds...>')
|
|
187
|
-
.description('Cria o arquivo de um comando cmd')
|
|
188
|
-
.action(async cmds => {
|
|
189
|
-
if (!Array.isArray(cmds)) return
|
|
190
|
-
|
|
191
|
-
for (const cmd of cmds) {
|
|
192
|
-
await tools.files.deployFileToProject(
|
|
193
|
-
'cmds',
|
|
194
|
-
'cmd',
|
|
195
|
-
`${cmd}.ts`.toLowerCase(),
|
|
196
|
-
{}
|
|
197
|
-
).finally(() => console.log(`Cmd ${cmd} criado`))
|
|
198
|
-
|
|
199
|
-
Plata.ProjectJson['my-scripts'] = Plata.ProjectJson['my-scripts'] ?? Object.create(null)
|
|
200
|
-
|
|
201
|
-
if (Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] === undefined) {
|
|
202
|
-
Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] = `plata-runtime + plata-cmd ${cmd}`
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
Plata.ProjectJson.scripts = JSON.parse(JSON.stringify({
|
|
206
|
-
...Plata.ProjectJson['my-scripts'],
|
|
207
|
-
...Plata.ProjectJson.scripts,
|
|
208
|
-
}))
|
|
209
|
-
|
|
210
|
-
await Plata.files.fs
|
|
211
|
-
.writeFile(
|
|
212
|
-
path.join(Plata.ProjectDir, 'package.json'),
|
|
213
|
-
JSON.stringify(Plata.ProjectJson, null, 4)
|
|
214
|
-
)
|
|
215
|
-
;
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
|
|
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('route <routes...>')
|
|
12
|
+
.description('Cria uma rota utilizando o templete da plata')
|
|
13
|
+
.action(async routes => {
|
|
14
|
+
if (!Array.isArray(routes)) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const promises: any[] = []
|
|
19
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
20
|
+
|
|
21
|
+
for (const route of routes) {
|
|
22
|
+
const r = `${route}/`.replace(/:(.*?)(?:\/|$)/g, (_, parm) => {
|
|
23
|
+
return parm[parm.length - 1] !== '?' ? `{${parm}}/` : `[${parm.slice(0, -1)}]/`
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const routeArg = r.slice(0, -1).split('/')
|
|
27
|
+
|
|
28
|
+
const routeFileName = routeArg[routeArg.length - 1] === '' ? 'index' : routeArg.pop()
|
|
29
|
+
const routeFilePath = path.join('routes', ...routeArg.filter(v => v !== ''))
|
|
30
|
+
|
|
31
|
+
promises.push(tools.files.deployFileToProject(
|
|
32
|
+
routeFilePath,
|
|
33
|
+
'route',
|
|
34
|
+
`${routeFileName}.ts`,
|
|
35
|
+
{ PlataName: `${plataName}` }
|
|
36
|
+
).finally(() => console.log(
|
|
37
|
+
`Rota ${routeFilePath}/${routeFileName === 'index' ? '' : routeFileName} criada`
|
|
38
|
+
)))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await Promise.all(promises)
|
|
42
|
+
})
|
|
43
|
+
;
|
|
44
|
+
|
|
45
|
+
program.command('lib <libs...>')
|
|
46
|
+
.description('Cria uma lib utilizando o templete da plata')
|
|
47
|
+
.action(async libs => {
|
|
48
|
+
if (!Array.isArray(libs)) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const promises: any[] = []
|
|
53
|
+
|
|
54
|
+
for (const lib of libs) {
|
|
55
|
+
promises.push(tools.files.deployFileToProject(
|
|
56
|
+
'libs',
|
|
57
|
+
'lib',
|
|
58
|
+
`${lib}.ts`.toLowerCase(),
|
|
59
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
60
|
+
).finally(() => console.log(`Config ${lib} criada`)))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await Promise.all(promises)
|
|
64
|
+
|
|
65
|
+
})
|
|
66
|
+
;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
program.command('class <classes...>')
|
|
70
|
+
.description('Cria uma config com e uma clase utilizando o templete da plata')
|
|
71
|
+
.action(async clazzs => {
|
|
72
|
+
if (!Array.isArray(clazzs)) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const promises: any[] = []
|
|
77
|
+
|
|
78
|
+
for (const lib of clazzs) {
|
|
79
|
+
promises.push(tools.files.deployFileToProject(
|
|
80
|
+
'configs',
|
|
81
|
+
'config',
|
|
82
|
+
`${lib}.ts`.toLowerCase(),
|
|
83
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
84
|
+
).finally(() => console.log(`Config ${lib} criada`)))
|
|
85
|
+
|
|
86
|
+
promises.push(tools.files.deployFileToProject(
|
|
87
|
+
'libs',
|
|
88
|
+
'class',
|
|
89
|
+
`${lib}.ts`.toLowerCase(),
|
|
90
|
+
{ Name: `${lib}`, name: `${lib}`.toLowerCase() }
|
|
91
|
+
).finally(() => console.log(`Classe ${lib} criada`)))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await Promise.all(promises)
|
|
95
|
+
})
|
|
96
|
+
;
|
|
97
|
+
|
|
98
|
+
program.command('config <configs...>')
|
|
99
|
+
.description('Cria uma config utilizando o templete da plata')
|
|
100
|
+
.action(async configs => {
|
|
101
|
+
if (!Array.isArray(configs)) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const promises: any[] = []
|
|
106
|
+
|
|
107
|
+
for (const config of configs) {
|
|
108
|
+
promises.push(tools.files.deployFileToProject(
|
|
109
|
+
'configs',
|
|
110
|
+
'config',
|
|
111
|
+
`${config}.ts`.toLowerCase(),
|
|
112
|
+
{ Name: `${config}`, name: `${config}`.toLowerCase() }
|
|
113
|
+
).finally(() => console.log(`Config ${config} criada`)))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await Promise.all(promises)
|
|
117
|
+
|
|
118
|
+
})
|
|
119
|
+
;
|
|
120
|
+
|
|
121
|
+
program.command('model <models...>')
|
|
122
|
+
.description('Cria um model utilizando o templete da plata')
|
|
123
|
+
.action(async models => {
|
|
124
|
+
if (!Array.isArray(models)) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const promises: any[] = []
|
|
129
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
130
|
+
|
|
131
|
+
for (const model of models) {
|
|
132
|
+
promises.push(tools.files.deployFileToProject(
|
|
133
|
+
'models',
|
|
134
|
+
'model',
|
|
135
|
+
`${model}.ts`.toLowerCase(),
|
|
136
|
+
{ Name: `${model}`, PlataName: `${plataName}` }
|
|
137
|
+
).finally(() => console.log(`Model ${model} criada`)))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
await Promise.all(promises)
|
|
141
|
+
})
|
|
142
|
+
;
|
|
143
|
+
|
|
144
|
+
program.command('task <tasks...>')
|
|
145
|
+
.description('Cria uma task utilizando o templete da plata')
|
|
146
|
+
.action(async tasks => {
|
|
147
|
+
if (!Array.isArray(tasks)) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const promises: any[] = []
|
|
152
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
153
|
+
|
|
154
|
+
for (const task of tasks) {
|
|
155
|
+
promises.push(tools.files.deployFileToProject(
|
|
156
|
+
'tasks',
|
|
157
|
+
'task',
|
|
158
|
+
`${task}.ts`.toLowerCase(),
|
|
159
|
+
{ Name: `${task}`, PlataName: `${plataName}` }
|
|
160
|
+
).finally(() => console.log(`Task ${tasks} criada`)))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
await Promise.all(promises)
|
|
164
|
+
})
|
|
165
|
+
;
|
|
166
|
+
|
|
167
|
+
program.command('cluster <clusters...>')
|
|
168
|
+
.description('Cria o arquivo do worker utilizando o templete da plata')
|
|
169
|
+
.action(async clusters => {
|
|
170
|
+
if (!Array.isArray(clusters)) return
|
|
171
|
+
|
|
172
|
+
const promises: any[] = []
|
|
173
|
+
const plataName = Plata.ProjectJson.plata_name
|
|
174
|
+
|
|
175
|
+
for (const cluster of clusters) {
|
|
176
|
+
promises.push(tools.files.deployFileToProject(
|
|
177
|
+
'clusters',
|
|
178
|
+
'cluster',
|
|
179
|
+
`${cluster}.ts`.toLowerCase(),
|
|
180
|
+
{ Name: `${cluster}`, name: `${cluster}`.toLowerCase(), PlataName: `${plataName}` }
|
|
181
|
+
).finally(() => console.log(`Worker ${cluster} criada`)))
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
;
|
|
185
|
+
|
|
186
|
+
program.command('cmd <cmds...>')
|
|
187
|
+
.description('Cria o arquivo de um comando cmd')
|
|
188
|
+
.action(async cmds => {
|
|
189
|
+
if (!Array.isArray(cmds)) return
|
|
190
|
+
|
|
191
|
+
for (const cmd of cmds) {
|
|
192
|
+
await tools.files.deployFileToProject(
|
|
193
|
+
'cmds',
|
|
194
|
+
'cmd',
|
|
195
|
+
`${cmd}.ts`.toLowerCase(),
|
|
196
|
+
{}
|
|
197
|
+
).finally(() => console.log(`Cmd ${cmd} criado`))
|
|
198
|
+
|
|
199
|
+
Plata.ProjectJson['my-scripts'] = Plata.ProjectJson['my-scripts'] ?? Object.create(null)
|
|
200
|
+
|
|
201
|
+
if (Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] === undefined) {
|
|
202
|
+
Plata.ProjectJson['my-scripts'][`cmd:${cmd}`] = `plata-runtime + plata-cmd ${cmd}`
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
Plata.ProjectJson.scripts = JSON.parse(JSON.stringify({
|
|
206
|
+
...Plata.ProjectJson['my-scripts'],
|
|
207
|
+
...Plata.ProjectJson.scripts,
|
|
208
|
+
}))
|
|
209
|
+
|
|
210
|
+
await Plata.files.fs
|
|
211
|
+
.writeFile(
|
|
212
|
+
path.join(Plata.ProjectDir, 'package.json'),
|
|
213
|
+
JSON.stringify(Plata.ProjectJson, null, 4)
|
|
214
|
+
)
|
|
215
|
+
;
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
219
|
export const cli = program
|