pwi-plata-type 0.3.17 → 0.4.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/__BUILD__/bin/extras/create-api-cli.js +96 -0
- package/__BUILD__/bin/extras/create-api-cli.js.map +1 -0
- package/__BUILD__/bin/extras/create-lib-cli.js +62 -0
- package/__BUILD__/bin/extras/create-lib-cli.js.map +1 -0
- package/__BUILD__/bin/extras/plata-create-tools.js +94 -0
- package/__BUILD__/bin/extras/plata-create-tools.js.map +1 -0
- package/__BUILD__/bin/plata-api.js +138 -0
- package/__BUILD__/bin/plata-api.js.map +1 -0
- package/__BUILD__/bin/plata-create.js +24 -0
- package/__BUILD__/bin/plata-create.js.map +1 -0
- package/__BUILD__/bin/plata-runtime.js +156 -0
- package/__BUILD__/bin/plata-runtime.js.map +1 -0
- package/__BUILD__/bin/plata-swagger.js +82 -0
- package/__BUILD__/bin/plata-swagger.js.map +1 -0
- package/__BUILD__/bin/runtime/_setupRuntime.js +43 -0
- package/__BUILD__/bin/runtime/_setupRuntime.js.map +1 -0
- package/__BUILD__/bin/runtime/class.js +18 -0
- package/__BUILD__/bin/runtime/class.js.map +1 -0
- package/__BUILD__/bin/runtime/dirs.js +16 -0
- package/__BUILD__/bin/runtime/dirs.js.map +1 -0
- package/__BUILD__/bin/runtime/promises.js +15 -0
- package/__BUILD__/bin/runtime/promises.js.map +1 -0
- package/__BUILD__/bin/runtime/require.js +88 -0
- package/__BUILD__/bin/runtime/require.js.map +1 -0
- package/__BUILD__/index.js +42 -0
- package/__BUILD__/index.js.map +1 -0
- package/__BUILD__/libs/axios.js +42 -0
- package/__BUILD__/libs/axios.js.map +1 -0
- package/__BUILD__/libs/cluster.js +160 -0
- package/__BUILD__/libs/cluster.js.map +1 -0
- package/__BUILD__/libs/fs.js +206 -0
- package/__BUILD__/libs/fs.js.map +1 -0
- package/__BUILD__/libs/model-validations.js +356 -0
- package/__BUILD__/libs/model-validations.js.map +1 -0
- package/__BUILD__/libs/model.js +185 -0
- package/__BUILD__/libs/model.js.map +1 -0
- package/__BUILD__/libs/router.js +127 -0
- package/__BUILD__/libs/router.js.map +1 -0
- package/__BUILD__/libs/swagger.js +64 -0
- package/__BUILD__/libs/swagger.js.map +1 -0
- package/__BUILD__/libs/tasks.js +134 -0
- package/__BUILD__/libs/tasks.js.map +1 -0
- package/__BUILD__/libs/tools.js +231 -0
- package/__BUILD__/libs/tools.js.map +1 -0
- package/__BUILD__/scripts/post-install/api.js +25 -0
- package/__BUILD__/scripts/post-install/api.js.map +1 -0
- package/__BUILD__/scripts/post-install/lib.js +25 -0
- package/__BUILD__/scripts/post-install/lib.js.map +1 -0
- package/__BUILD__/scripts/post-install.js +65 -0
- package/__BUILD__/scripts/post-install.js.map +1 -0
- package/__BUILD__/scripts/pre-test.js +25 -0
- package/__BUILD__/scripts/pre-test.js.map +1 -0
- package/package.json +18 -16
- package/src/@types/cluster.actions.d.ts +7 -0
- package/src/@types/cluster.d.ts +33 -0
- package/src/@types/create-cli.d.ts +9 -0
- package/src/@types/exported.d.ts +24 -0
- package/src/@types/global.d.ts +69 -0
- package/src/@types/model.d.ts +69 -0
- package/src/@types/router.d.ts +75 -0
- package/src/@types/swagger.d.ts +23 -0
- package/{bin/extras/plata-create-api.ts → src/bin/extras/create-api-cli.ts} +5 -6
- package/{bin/extras/plata-create-lib.ts → src/bin/extras/create-lib-cli.ts} +3 -4
- package/{bin → src/bin}/extras/plata-create-tools.ts +4 -4
- package/src/bin/plata-api.ts +172 -0
- package/src/bin/plata-create.ts +21 -0
- package/src/bin/plata-runtime.ts +188 -0
- package/src/bin/plata-swagger.ts +100 -0
- package/src/bin/runtime/_setupRuntime.ts +49 -0
- package/src/bin/runtime/_types.d.ts +4 -0
- package/src/bin/runtime/class.ts +21 -0
- package/src/bin/runtime/dirs.ts +26 -0
- package/src/bin/runtime/promises.ts +15 -0
- package/src/bin/runtime/require.ts +104 -0
- package/{index.ts → src/index.ts} +2 -4
- package/{libs → src/libs}/axios.ts +0 -0
- package/src/libs/cluster.ts +189 -0
- package/src/libs/fs.ts +382 -0
- package/{libs/model.ts → src/libs/model-validations.ts} +28 -262
- package/src/libs/model.ts +233 -0
- package/src/libs/router.ts +147 -0
- package/src/libs/swagger.ts +81 -0
- package/{libs → src/libs}/tasks.ts +0 -0
- package/{libs → src/libs}/tools.ts +3 -18
- package/src/scripts/post-install/api.ts +32 -0
- package/src/scripts/post-install/lib.ts +30 -0
- package/src/scripts/post-install.ts +65 -0
- package/src/scripts/pre-test.ts +34 -0
- package/src/tests/assets/config/test.txt +1 -0
- package/src/tests/config.test.ts +13 -0
- package/src/tests/model.test.ts +115 -0
- package/templates/create-cli/cluster.ts +7 -9
- package/templates/create-cli/config.ts +2 -8
- package/templates/create-cli/lib.ts +7 -17
- package/templates/create-cli/model.ts +10 -21
- package/templates/create-cli/route.ts +1 -3
- package/templates/postinstall/api/configs/env.ts +2 -8
- package/templates/postinstall/api/tsconfig.json +20 -37
- package/templates/postinstall/lib/postinstall-tools.mjs +1 -1
- package/templates/postinstall/lib/postinstall.js +1 -0
- package/templates/postinstall/lib/tsconfig.json +21 -38
- package/tsconfig.json +25 -37
- package/Dockerfile +0 -13
- package/bin/extras/plata-build-tool.ts +0 -151
- package/bin/plata-build.ts +0 -144
- package/bin/plata-create.ts +0 -28
- package/bin/plata-reload.ts +0 -13
- package/bin/plata-swagger-gen.ts +0 -183
- package/bin/plata.ts +0 -122
- package/libs/cluster.ts +0 -219
- package/libs/env.ts +0 -28
- package/libs/routes.ts +0 -275
- package/libs/swagger.ts +0 -79
- package/postinstall-tools.mjs +0 -115
- package/postinstall.mjs +0 -42
- package/templates/postinstall/api/_install.mjs +0 -34
- package/templates/postinstall/lib/_install.mjs +0 -30
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default (router: PlataRoutes.PlataRouter): PlataRoutes.PlataRouter => {
|
|
2
|
+
export default async (router: Router.Router): Promise<Router.Router> => {
|
|
5
3
|
|
|
6
4
|
router.get('/', async (req, res) => {
|
|
7
5
|
return res.status(200).json({})
|
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["esnext"],
|
|
6
|
+
"declaration": false,
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"outDir": "./__BUILD__",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"types": [ "node", "pwi-plata-type" ],
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"paths": {
|
|
17
|
+
"@@/*": [ "./*" ]
|
|
18
|
+
}
|
|
14
19
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"lib": ["esnext"],
|
|
19
|
-
"allowJs": true,
|
|
20
|
-
"outDir": "./build",
|
|
21
|
-
"rootDir": "./",
|
|
22
|
-
"esModuleInterop": true,
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"strictNullChecks": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
"baseUrl": ".",
|
|
27
|
-
"paths": {
|
|
28
|
-
"@Libs/*": ["./libs/*"],
|
|
29
|
-
"@Configs/*": [ "./configs/*" ],
|
|
30
|
-
"@Models/*": [ "./models/*" ],
|
|
31
|
-
"@Clusters/*": [ "./clusters/*" ],
|
|
32
|
-
"@Plata/*": [ "./node_modules/pwi-plata-type/*" ],
|
|
33
|
-
"@PlataBin/*": [ "./node_modules/pwi-plata-type/bin/*" ]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"include": [
|
|
37
|
-
"./**/*.ts",
|
|
38
|
-
"./node_modules/pwi-plata-type/**/*.ts"
|
|
39
|
-
]
|
|
20
|
+
"include": [
|
|
21
|
+
"./**/*"
|
|
22
|
+
]
|
|
40
23
|
}
|
|
@@ -1,40 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"strictNullChecks": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
"baseUrl": ".",
|
|
27
|
-
"paths": {
|
|
28
|
-
"@Libs/*": ["./libs/*"],
|
|
29
|
-
"@Configs/*": [ "./configs/*" ],
|
|
30
|
-
"@Models/*": [ "./models/*" ],
|
|
31
|
-
"@Clusters/*": [ "./clusters/*" ],
|
|
32
|
-
"@Plata/*": [ "./node_modules/pwi-plata-type/*" ],
|
|
33
|
-
"@PlataBin/*": [ "./node_modules/pwi-plata-type/bin/*" ],
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"include": [
|
|
37
|
-
"./**/*.ts",
|
|
38
|
-
"./node_modules/pwi-plata-type/**/*.ts"
|
|
39
|
-
]
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["esnext"],
|
|
6
|
+
"declaration": false,
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"outDir": "./__BUILD__",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"types": [ "node", "pwi-plata-type" ],
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"paths": {
|
|
17
|
+
"@@/*": [ "./*" ]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"include": [
|
|
21
|
+
"./**/*"
|
|
22
|
+
]
|
|
40
23
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["esnext"],
|
|
6
|
+
"declaration": false,
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"outDir": "./__BUILD__",
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"strictNullChecks": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"removeComments": true,
|
|
15
|
+
"types": ["node"],
|
|
16
|
+
"forceConsistentCasingInFileNames": true,
|
|
17
|
+
"baseUrl": ".",
|
|
18
|
+
"paths": {
|
|
19
|
+
"++/*": [ "./src/*" ]
|
|
20
|
+
}
|
|
14
21
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"rootDir": "./",
|
|
22
|
-
"esModuleInterop": true,
|
|
23
|
-
"resolveJsonModule": true,
|
|
24
|
-
"strictNullChecks": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
"baseUrl": ".",
|
|
27
|
-
"paths": {
|
|
28
|
-
"@libs/*": ["./libs/*"],
|
|
29
|
-
"@configs/*": [ "./configs/*" ],
|
|
30
|
-
"@models/*": [ "./models/*" ],
|
|
31
|
-
"@clusters/*": [ "./clusters/*" ],
|
|
32
|
-
"@Plata/*": [ "./node_modules/pwi-plata-type/*" ],
|
|
33
|
-
"@PlataBin/*": [ "./node_modules/pwi-plata-type/bin/*" ],
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"include": [
|
|
37
|
-
"./**/*.ts",
|
|
38
|
-
"./node_modules/pwi-plata-type/**/*.ts"
|
|
39
|
-
]
|
|
22
|
+
"include": [
|
|
23
|
+
"./src/**/*"
|
|
24
|
+
],
|
|
25
|
+
"exclude": [
|
|
26
|
+
"./templates/**/*"
|
|
27
|
+
]
|
|
40
28
|
}
|
package/Dockerfile
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process'
|
|
2
|
-
import fs from 'node:fs'
|
|
3
|
-
import path from 'node:path'
|
|
4
|
-
import { PlataResultado, PlataDirs, PlataFiles, PlataError } from '../../libs/tools';
|
|
5
|
-
|
|
6
|
-
export namespace tools {
|
|
7
|
-
export interface ProcessExit {
|
|
8
|
-
exitCode: number,
|
|
9
|
-
stdout: string,
|
|
10
|
-
stderr: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function runIn(command: string, args: string[], cwd: string,): Promise<PlataResultado<ProcessExit>> {
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
try {
|
|
16
|
-
const p = spawn(command, args, {
|
|
17
|
-
cwd: cwd,
|
|
18
|
-
shell: true
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
let stdout, stderr = ''
|
|
22
|
-
|
|
23
|
-
p.stdout.on('data', (data) => {
|
|
24
|
-
stdout += `${data}\n`
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
p.stderr.on('data', (data) => {
|
|
28
|
-
stderr += `${data}\n`
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
p.on('close', (code) => {
|
|
32
|
-
return resolve({
|
|
33
|
-
exitCode: code ?? 999,
|
|
34
|
-
stdout: stdout,
|
|
35
|
-
stderr: stderr,
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return resolve({
|
|
40
|
-
errorID: 'PBEBT0001',
|
|
41
|
-
msg: [ 'Erro ao rodar o comando no projeto:', command, ...args ].join(' '),
|
|
42
|
-
error: e
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export async function runInProject(command: string, args: string[], folder?: string): Promise<PlataResultado<ProcessExit>> {
|
|
49
|
-
return runIn(
|
|
50
|
-
command,
|
|
51
|
-
args,
|
|
52
|
-
path.join(PlataDirs.getProjectDir(), folder ?? '')
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getProjectJson(): any {
|
|
57
|
-
return PlataDirs.ProjectJson
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getPlataJson(): any {
|
|
61
|
-
return PlataFiles.readJsonSync(path.join(
|
|
62
|
-
PlataDirs.getPlataDir(),
|
|
63
|
-
'package.json'
|
|
64
|
-
))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function getBuildFolder(): string {
|
|
68
|
-
return path.join(PlataDirs.getProjectDir(), 'build')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getBuildPlataFolder(plataName: string): string {
|
|
72
|
-
return path.join(getBuildFolder(), 'node_modules', plataName)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function doError(error: PlataError): any {
|
|
76
|
-
console.log(error.errorID)
|
|
77
|
-
console.log(error.msg)
|
|
78
|
-
if (error.error) {
|
|
79
|
-
throw error.error
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
process.exit(1)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function copyFolder(folder: string, destination: string): Promise<PlataResultado<string>> {
|
|
86
|
-
return new Promise(resolve => {
|
|
87
|
-
const p = path.join(destination, path.basename(folder))
|
|
88
|
-
fs.cp(folder, p, { recursive: true, errorOnExist: false },(err) => {
|
|
89
|
-
if (err !== null) {
|
|
90
|
-
return resolve({
|
|
91
|
-
errorID: 'PBEBT0002',
|
|
92
|
-
msg: `Erro ao copiar a pasta ${folder} para ${p}`,
|
|
93
|
-
error: err
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return resolve(p)
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export async function copyFolderIfExits(folder: string, destination: string): Promise<PlataResultado<string>> {
|
|
103
|
-
try {
|
|
104
|
-
if (fs.existsSync(folder)) {
|
|
105
|
-
return copyFolder(folder, destination)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return ''
|
|
109
|
-
} catch(e) {
|
|
110
|
-
return {
|
|
111
|
-
errorID: 'PBEBT0003',
|
|
112
|
-
msg: `Erro ao checar se a pasta ${folder} existe`,
|
|
113
|
-
error: e
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function saveJson(folder: string, file: string, content: any): Promise<PlataResultado<string>> {
|
|
119
|
-
return new Promise(resolve => {
|
|
120
|
-
const p = path.join(folder, file)
|
|
121
|
-
fs.writeFile(p, JSON.stringify(content, null, 4), err => {
|
|
122
|
-
if (err !== null) {
|
|
123
|
-
return resolve({
|
|
124
|
-
errorID: 'PBEBT0004',
|
|
125
|
-
msg: `Erro salvar o arquivo ${p}`,
|
|
126
|
-
error: err
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return resolve(p)
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export async function createFolderIfNotExists(...folder: string[]): Promise<PlataResultado<string>> {
|
|
136
|
-
try {
|
|
137
|
-
const p = path.join(...folder)
|
|
138
|
-
if (!fs.existsSync(p)) {
|
|
139
|
-
fs.mkdirSync(p, { recursive: true })
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return p
|
|
143
|
-
} catch (e) {
|
|
144
|
-
return {
|
|
145
|
-
errorID: 'PBEBT0005',
|
|
146
|
-
msg: `Ao criar a pasta ${folder}`,
|
|
147
|
-
error: e
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
package/bin/plata-build.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { tools } from './extras/plata-build-tool'
|
|
2
|
-
import { PlataResultado, PlataDirs } from '../libs/tools'
|
|
3
|
-
|
|
4
|
-
const main = async () => {
|
|
5
|
-
// Prepara o JSONs
|
|
6
|
-
const projectJson = tools.getProjectJson()
|
|
7
|
-
const plataJson = tools.getPlataJson()
|
|
8
|
-
|
|
9
|
-
plataJson.main = 'index.js'
|
|
10
|
-
|
|
11
|
-
projectJson.plata_no_setup = "true"
|
|
12
|
-
projectJson.dependencies = { ...projectJson.dependencies, ...plataJson.dependencies }
|
|
13
|
-
|
|
14
|
-
for (const dependencia in projectJson.dependencies) {
|
|
15
|
-
switch (dependencia) {
|
|
16
|
-
case 'ts-jest':
|
|
17
|
-
delete projectJson.dependencies['ts-jest']
|
|
18
|
-
break
|
|
19
|
-
case 'ts-node':
|
|
20
|
-
delete projectJson.dependencies['ts-node']
|
|
21
|
-
break
|
|
22
|
-
case plataJson.name:
|
|
23
|
-
delete projectJson.dependencies[plataJson.name]
|
|
24
|
-
break
|
|
25
|
-
default:
|
|
26
|
-
if (/^@types/.test(dependencia)) {
|
|
27
|
-
delete projectJson.dependencies[dependencia]
|
|
28
|
-
}
|
|
29
|
-
break
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
projectJson.scripts = {
|
|
34
|
-
start: `node ./node_modules/${plataJson.name}/bin/plata`,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Faz a manipulação dos arquivos para deixar certinho
|
|
38
|
-
const buildFolder = tools.getBuildFolder()
|
|
39
|
-
|
|
40
|
-
// Copia a pasta da plata compilada para fora da node_modules
|
|
41
|
-
|
|
42
|
-
const plataTmpFolder = await tools.copyFolder(
|
|
43
|
-
tools.getBuildPlataFolder(plataJson.name),
|
|
44
|
-
buildFolder
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
if (plataTmpFolder.errorID !== undefined) {
|
|
48
|
-
return tools.doError(plataTmpFolder)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Salva os packages.json
|
|
52
|
-
{
|
|
53
|
-
const promises: Promise<PlataResultado<unknown>>[] = []
|
|
54
|
-
|
|
55
|
-
promises.push(tools.saveJson(
|
|
56
|
-
buildFolder,
|
|
57
|
-
'package.json',
|
|
58
|
-
projectJson
|
|
59
|
-
))
|
|
60
|
-
|
|
61
|
-
promises.push(tools.saveJson(
|
|
62
|
-
plataTmpFolder,
|
|
63
|
-
'package.json',
|
|
64
|
-
plataJson
|
|
65
|
-
))
|
|
66
|
-
|
|
67
|
-
const resultado = await Promise.all(promises)
|
|
68
|
-
|
|
69
|
-
for (const r of resultado) {
|
|
70
|
-
if (r.errorID !== undefined) {
|
|
71
|
-
return tools.doError(r)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Instala as dependencias
|
|
77
|
-
{
|
|
78
|
-
const install = await tools.runIn('npm', ['i'], buildFolder)
|
|
79
|
-
|
|
80
|
-
if (install.errorID !== undefined) {
|
|
81
|
-
return tools.doError(install)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (install.exitCode !== 0) {
|
|
85
|
-
return tools.doError({
|
|
86
|
-
errorID: 'PBB0002',
|
|
87
|
-
msg: `out:\n${install.stdout}\n err:\n${install.stderr}\n`
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Copia as pastas:
|
|
93
|
-
// plata compilada => node_modules
|
|
94
|
-
// env => projeto compilado
|
|
95
|
-
// swagger => projeto compilado
|
|
96
|
-
{
|
|
97
|
-
const promises: Promise<PlataResultado<unknown>>[] = []
|
|
98
|
-
|
|
99
|
-
promises.push(tools.copyFolder(
|
|
100
|
-
plataTmpFolder,
|
|
101
|
-
tools.getBuildPlataFolder('')
|
|
102
|
-
))
|
|
103
|
-
|
|
104
|
-
promises.push(tools.copyFolder(
|
|
105
|
-
PlataDirs.getProjectEnvFileDir(''),
|
|
106
|
-
buildFolder
|
|
107
|
-
))
|
|
108
|
-
|
|
109
|
-
promises.push(tools.copyFolderIfExits(
|
|
110
|
-
PlataDirs.getProjectDirSwagger(),
|
|
111
|
-
buildFolder
|
|
112
|
-
))
|
|
113
|
-
|
|
114
|
-
const resultado = await Promise.all(promises)
|
|
115
|
-
|
|
116
|
-
for (const r of resultado) {
|
|
117
|
-
if (r.errorID !== undefined) {
|
|
118
|
-
return tools.doError(r)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Cria as pasta caso ela não exista
|
|
124
|
-
{
|
|
125
|
-
const promises: Promise<PlataResultado<unknown>>[] = []
|
|
126
|
-
|
|
127
|
-
promises.push(tools.createFolderIfNotExists(buildFolder, 'clusters'))
|
|
128
|
-
promises.push(tools.createFolderIfNotExists(buildFolder, 'models'))
|
|
129
|
-
promises.push(tools.createFolderIfNotExists(buildFolder, 'routes'))
|
|
130
|
-
|
|
131
|
-
const resultado = await Promise.all(promises)
|
|
132
|
-
|
|
133
|
-
for (const r of resultado) {
|
|
134
|
-
if (r.errorID !== undefined) {
|
|
135
|
-
return tools.doError(r)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
console.log('Projeto compilado')
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
main()
|
package/bin/plata-create.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PlataDirs } from "../libs/tools"
|
|
2
|
-
|
|
3
|
-
import * as PlataCreateApi from "./extras/plata-create-api"
|
|
4
|
-
import * as PlataCreateLib from "./extras/plata-create-lib"
|
|
5
|
-
|
|
6
|
-
const main = async () => {
|
|
7
|
-
const projectPackage = PlataDirs.ProjectJson
|
|
8
|
-
|
|
9
|
-
if (projectPackage.plata_no_setup !== undefined) {
|
|
10
|
-
console.log('Existe o parametro plata_no_setup no package.json ou seja a plata não esta configurada')
|
|
11
|
-
process.exit(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
switch(projectPackage.plata_type ?? 'api') {
|
|
15
|
-
case 'api':
|
|
16
|
-
await PlataCreateApi.cli.parseAsync(process.argv)
|
|
17
|
-
break;
|
|
18
|
-
case 'lib':
|
|
19
|
-
await PlataCreateLib.cli.parseAsync(process.argv)
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
console.log(`tipo ${projectPackage.plata_type} não suportado pela plata`)
|
|
23
|
-
process.exit(0)
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
main()
|
package/bin/plata-reload.ts
DELETED