pwi-plata-type 0.3.3 → 0.3.6
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/Dockerfile +4 -9
- package/bin/extras/plata-build-tool.ts +3 -2
- package/bin/extras/plata-create-api.ts +2 -2
- package/bin/extras/plata-create-lib.ts +1 -1
- package/bin/extras/plata-create-tools.ts +1 -1
- package/bin/plata-build.ts +2 -2
- package/bin/plata-create.ts +6 -6
- package/bin/plata-reload.ts +13 -0
- package/bin/plata-swagger-gen.ts +28 -30
- package/bin/plata.ts +4 -4
- package/index.ts +6 -6
- package/libs/cluster.ts +3 -3
- package/libs/env.ts +2 -2
- package/libs/model.ts +3 -3
- package/libs/routes.ts +21 -13
- package/libs/swagger.ts +3 -4
- package/libs/tools.ts +4 -4
- package/package.json +8 -6
- package/{postinstall.js → postinstall.mjs} +4 -0
- package/templates/create-cli/lib.ts +1 -1
- package/templates/postinstall/api/Dockerfile +4 -9
- package/templates/postinstall/api/_install.mjs +5 -6
- package/templates/postinstall/api/envs/debug.env +2 -1
- package/templates/postinstall/api/envs/homolog.env +2 -1
- package/templates/postinstall/api/envs/prod.env +2 -1
- package/templates/postinstall/api/tsconfig.json +33 -9
- package/templates/postinstall/lib/_install.mjs +3 -3
- package/templates/postinstall/lib/tsconfig.json +38 -14
- package/tsconfig.json +33 -9
package/Dockerfile
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
FROM node:16-alpine
|
|
1
|
+
FROM node:16-alpine
|
|
2
2
|
|
|
3
3
|
WORKDIR /usr/src/app
|
|
4
4
|
|
|
5
|
-
COPY
|
|
6
|
-
|
|
7
|
-
RUN npm ci --only=production && \
|
|
8
|
-
npm run build
|
|
9
|
-
|
|
10
|
-
FROM node:16-alpine AS bin
|
|
5
|
+
COPY package*.json ./
|
|
11
6
|
|
|
12
7
|
EXPOSE 3050
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
RUN npm ci --only=production
|
|
15
10
|
|
|
16
|
-
COPY
|
|
11
|
+
COPY . ./
|
|
17
12
|
|
|
18
13
|
CMD [ "npm", "start" ]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
-
import { PlataResultado, PlataDirs, PlataFiles, PlataError } from '../../libs/tools
|
|
4
|
+
import { PlataResultado, PlataDirs, PlataFiles, PlataError } from '../../libs/tools';
|
|
5
5
|
|
|
6
6
|
export namespace tools {
|
|
7
7
|
export interface ProcessExit {
|
|
@@ -14,7 +14,8 @@ export namespace tools {
|
|
|
14
14
|
return new Promise((resolve) => {
|
|
15
15
|
try {
|
|
16
16
|
const p = spawn(command, args, {
|
|
17
|
-
cwd: cwd
|
|
17
|
+
cwd: cwd,
|
|
18
|
+
shell: true
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
let stdout, stderr = ''
|
package/bin/plata-build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { tools } from './extras/plata-build-tool
|
|
2
|
-
import { PlataResultado, PlataDirs } from '../libs/tools
|
|
1
|
+
import { tools } from './extras/plata-build-tool'
|
|
2
|
+
import { PlataResultado, PlataDirs } from '../libs/tools'
|
|
3
3
|
|
|
4
4
|
const main = async () => {
|
|
5
5
|
// Prepara o JSONs
|
package/bin/plata-create.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { PlataDirs } from "../libs/tools
|
|
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"
|
|
2
5
|
|
|
3
6
|
interface Handler {
|
|
4
7
|
h: () => Promise<void>
|
|
@@ -13,14 +16,12 @@ const main = async () => {
|
|
|
13
16
|
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
let handler: Handler
|
|
17
|
-
|
|
18
19
|
switch(projectPackage.plata_type ?? 'api') {
|
|
19
20
|
case 'api':
|
|
20
|
-
|
|
21
|
+
await PlataCreateApi.h()
|
|
21
22
|
break;
|
|
22
23
|
case 'lib':
|
|
23
|
-
|
|
24
|
+
await PlataCreateLib.h()
|
|
24
25
|
break;
|
|
25
26
|
default:
|
|
26
27
|
console.log(`tipo ${projectPackage.plata_type} não suportado pela plata`)
|
|
@@ -28,7 +29,6 @@ const main = async () => {
|
|
|
28
29
|
break;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
await handler.h()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
main()
|
package/bin/plata-swagger-gen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
|
-
import {
|
|
4
|
-
import { PlataResultado, PlataDirs, PlataFiles, PlataError } from '../libs/tools
|
|
3
|
+
import { buildExpressRouter } from '../libs/routes'
|
|
4
|
+
import { PlataResultado, PlataDirs, PlataFiles, PlataError } from '../libs/tools'
|
|
5
5
|
|
|
6
6
|
interface dumpParameter {
|
|
7
7
|
name: string,
|
|
@@ -106,47 +106,45 @@ function loadSwaggerFiles(): swaggerFiles {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async function dumpRotas(): Promise<dumpRoute[]> {
|
|
109
|
-
const rotas = await
|
|
109
|
+
const rotas = await buildExpressRouter()
|
|
110
110
|
const rotasMetodos: dumpRoute[] = []
|
|
111
111
|
const regex = /:(.*?)\??\//g
|
|
112
|
-
for (const r of rotas) {
|
|
113
|
-
const expressRouter = await r.exports()
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
if (rotas._routes === undefined) return []
|
|
114
|
+
|
|
115
|
+
for (const r of rotas._routes) {
|
|
116
|
+
if (r.swaggerHide) {
|
|
116
117
|
continue
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
required: p[p.length - 2] !== '?',
|
|
132
|
-
in: 'path',
|
|
133
|
-
type: 'string'
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
rotasMetodos.push({
|
|
138
|
-
httpRoute: httpLayerRoute.replace(regex, '{$1}/'),
|
|
139
|
-
params: routeParams,
|
|
140
|
-
metodo,
|
|
141
|
-
})
|
|
142
|
-
}
|
|
120
|
+
r.path = path.normalize(`${r.path ?? '/'}/`).replace(/\\/g, '/')
|
|
121
|
+
|
|
122
|
+
const routeParams: dumpParameter[] = []
|
|
123
|
+
const urlParms = r.path.match(regex) ?? []
|
|
124
|
+
|
|
125
|
+
for (const p of urlParms) {
|
|
126
|
+
routeParams.push({
|
|
127
|
+
name: p.replace(regex, '$1'),
|
|
128
|
+
required: p[p.length - 2] !== '?',
|
|
129
|
+
in: 'path',
|
|
130
|
+
type: 'string'
|
|
131
|
+
})
|
|
143
132
|
}
|
|
133
|
+
|
|
134
|
+
rotasMetodos.push({
|
|
135
|
+
httpRoute: r.path.replace(regex, '{$1}/'),
|
|
136
|
+
metodo: r.method,
|
|
137
|
+
params: routeParams,
|
|
138
|
+
})
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
return rotasMetodos
|
|
147
142
|
}
|
|
148
143
|
|
|
149
144
|
const main = async () => {
|
|
145
|
+
// TODO :: Colocar isso em um function que inicializa a process._plata ou n usa isso mais
|
|
146
|
+
(process as any)._plata = new Object(null)
|
|
147
|
+
|
|
150
148
|
const rotas = await dumpRotas()
|
|
151
149
|
const files = loadSwaggerFiles()
|
|
152
150
|
|
package/bin/plata.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PlataClusterManager, PlataClusterMsg } from "../libs/cluster
|
|
2
|
-
import { loadEnvProjectFile } from "../libs/env
|
|
3
|
-
import { buildExpressRouter } from "../libs/routes
|
|
1
|
+
import { PlataClusterManager, PlataClusterMsg } from "../libs/cluster"
|
|
2
|
+
import { loadEnvProjectFile } from "../libs/env"
|
|
3
|
+
import { buildExpressRouter } from "../libs/routes"
|
|
4
4
|
import express, { Express } from "express"
|
|
5
5
|
import { createServer } from 'node:https'
|
|
6
6
|
import fs from 'node:fs'
|
|
7
|
-
import { PlataDirs } from "../libs/tools
|
|
7
|
+
import { PlataDirs } from "../libs/tools"
|
|
8
8
|
import path from 'node:path'
|
|
9
9
|
|
|
10
10
|
const main = async () => {
|
package/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as PlataCluster from './libs/cluster
|
|
2
|
-
import * as PlataEnv from './libs/env
|
|
3
|
-
import * as PlataRoutes from './libs/routes
|
|
4
|
-
import * as PlataTools from './libs/tools
|
|
5
|
-
import * as PlataModels from './libs/model
|
|
6
|
-
import { PlataSwagger } from './libs/swagger
|
|
1
|
+
import * as PlataCluster from './libs/cluster'
|
|
2
|
+
import * as PlataEnv from './libs/env'
|
|
3
|
+
import * as PlataRoutes from './libs/routes'
|
|
4
|
+
import * as PlataTools from './libs/tools'
|
|
5
|
+
import * as PlataModels from './libs/model'
|
|
6
|
+
import { PlataSwagger } from './libs/swagger'
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
PlataCluster,
|
package/libs/cluster.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlataRequire, PlataDirs, PlataFiles } from './tools
|
|
1
|
+
import { PlataRequire, PlataDirs, PlataFiles } from './tools'
|
|
2
2
|
import { cpus } from 'node:os'
|
|
3
3
|
import * as typeCluster from 'node:cluster'
|
|
4
4
|
|
|
@@ -153,14 +153,14 @@ export class PlataClusterManager {
|
|
|
153
153
|
[
|
|
154
154
|
PlataDirs.getProjectDirClusters()
|
|
155
155
|
],
|
|
156
|
-
`${process.env["_plata_name"]}
|
|
156
|
+
`${process.env["_plata_name"]}`
|
|
157
157
|
).catch(err => {
|
|
158
158
|
console.error(err)
|
|
159
159
|
return null
|
|
160
160
|
})
|
|
161
161
|
|
|
162
162
|
if (file !== null) {
|
|
163
|
-
const config: PlataClusterWorkerConfig = (await import(
|
|
163
|
+
const config: PlataClusterWorkerConfig = (await import(file.replace(/\\/g, '/'))).default
|
|
164
164
|
|
|
165
165
|
await config.onStart()
|
|
166
166
|
}
|
package/libs/env.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlataDirs, PlataFiles } from "./tools
|
|
1
|
+
import { PlataDirs, PlataFiles } from "./tools"
|
|
2
2
|
|
|
3
3
|
export interface EnvConfig {
|
|
4
4
|
readonly env: 'prod' | 'debug' | 'homolog' | string
|
|
@@ -6,7 +6,7 @@ export interface EnvConfig {
|
|
|
6
6
|
|
|
7
7
|
export async function loadEnvProjectFile() {
|
|
8
8
|
const config = process.env['ENV'] === undefined ?
|
|
9
|
-
(await import(PlataDirs.getProjectConfigFileDir('env
|
|
9
|
+
(await import(PlataDirs.getProjectConfigFileDir('env'))).default as EnvConfig
|
|
10
10
|
: { env: process.env['ENV'] }
|
|
11
11
|
|
|
12
12
|
return PlataFiles.readFileAsync(
|
package/libs/model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlataError } from "./tools
|
|
1
|
+
import { PlataError } from "./tools"
|
|
2
2
|
|
|
3
3
|
export interface RetornoValidacaoPrimitivo {
|
|
4
4
|
error?: PlataError
|
|
@@ -442,7 +442,7 @@ export function Telefone(): ModelValicacaoPrimitivo {
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
if (v[0].length !== 2 || v[1].length
|
|
445
|
+
if (v[0].length !== 2 || (v[1].length !== 8 && v[1].length !== 9)) {
|
|
446
446
|
return {
|
|
447
447
|
error: {
|
|
448
448
|
errorID: "BPVTEL002",
|
|
@@ -481,7 +481,7 @@ export function TelefoneDDI(): ModelValicacaoPrimitivo {
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
if (telefone[0].length !== 2 || telefone[1].length
|
|
484
|
+
if (telefone[0].length !== 2 || (telefone[1].length !== 8 && telefone[1].length !== 9)) {
|
|
485
485
|
return {
|
|
486
486
|
error: {
|
|
487
487
|
errorID: "BPVTELD002",
|
package/libs/routes.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import { PlataDirs, PlataRequire, PlataError } from "./tools
|
|
2
|
+
import { PlataDirs, PlataRequire, PlataError } from "./tools";
|
|
3
3
|
import express, { Router } from "express";
|
|
4
4
|
|
|
5
5
|
export const HttpMethodsArray = [
|
|
@@ -69,7 +69,8 @@ export type PlataRouterMethods = (
|
|
|
69
69
|
export interface _PlataRoute {
|
|
70
70
|
path?: string,
|
|
71
71
|
method: HttpMethods
|
|
72
|
-
handlers: PlataRequestHandler[]
|
|
72
|
+
handlers: PlataRequestHandler[],
|
|
73
|
+
swaggerHide?: boolean
|
|
73
74
|
}
|
|
74
75
|
export interface PlataRouterExtras {
|
|
75
76
|
swaggerHide?: boolean
|
|
@@ -205,7 +206,7 @@ export async function loadExpressRoutes(): Promise<PlataRequiredRoute[]> {
|
|
|
205
206
|
r = r.map(route => {
|
|
206
207
|
route.httpRoute = route.filePath
|
|
207
208
|
.replace(PlataDirs.getProjectRoutesDir(), '')
|
|
208
|
-
.replace(
|
|
209
|
+
.replace(/\.ts|\.js$/, '')
|
|
209
210
|
.replace(/index/, '')
|
|
210
211
|
.replace(/\\/g, '/')
|
|
211
212
|
.replace(/\{(.*?)\}/g, ':$1')
|
|
@@ -235,9 +236,10 @@ export async function loadExpressRoutes(): Promise<PlataRequiredRoute[]> {
|
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
|
|
238
|
-
export async function buildExpressRouter(): Promise<
|
|
239
|
-
const router = Router()
|
|
240
|
-
router.
|
|
239
|
+
export async function buildExpressRouter(): Promise<_Router> {
|
|
240
|
+
const router = Router() as _Router
|
|
241
|
+
router._routes = []
|
|
242
|
+
router.use(express.json({ limit: process.env._PLATA_API_JSON_SIZE ?? '100kb' }))
|
|
241
243
|
|
|
242
244
|
const routes = await loadExpressRoutes()
|
|
243
245
|
|
|
@@ -249,14 +251,20 @@ export async function buildExpressRouter(): Promise<Router> {
|
|
|
249
251
|
for (let i = 0; i < pr._routes.length; i++) {
|
|
250
252
|
const prr = pr._routes[i];
|
|
251
253
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
path.normalize(`${r.httpRoute}/${prr.path}`).replace(/\\/g, '/'),
|
|
257
|
-
...prr.handlers.map(PlataRoute)
|
|
258
|
-
)
|
|
254
|
+
let httpPath = r.httpRoute
|
|
255
|
+
|
|
256
|
+
if (prr.path !== undefined) {
|
|
257
|
+
httpPath = path.normalize(`${r.httpRoute}/${prr.path}`).replace(/\\/g, '/')
|
|
259
258
|
}
|
|
259
|
+
|
|
260
|
+
router[prr.method](httpPath, ...prr.handlers.map(PlataRoute))
|
|
261
|
+
|
|
262
|
+
router._routes.push({
|
|
263
|
+
path: httpPath,
|
|
264
|
+
method: prr.method,
|
|
265
|
+
handlers: [],
|
|
266
|
+
swaggerHide: prr.swaggerHide
|
|
267
|
+
})
|
|
260
268
|
}
|
|
261
269
|
}
|
|
262
270
|
|
package/libs/swagger.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import swaggerUi from 'swagger-ui-express'
|
|
2
|
-
import { Router } from 'express'
|
|
3
2
|
import path from 'node:path'
|
|
4
|
-
import { PlataRouterBuilder, PlataRequestHandler } from './routes
|
|
5
|
-
import { PlataFiles, PlataDirs } from "./tools
|
|
3
|
+
import { PlataRouterBuilder, PlataRequestHandler } from './routes';
|
|
4
|
+
import { PlataFiles, PlataDirs } from "./tools";
|
|
6
5
|
|
|
7
6
|
export namespace PlataSwagger {
|
|
8
7
|
export const swagger: PlataRouterBuilder = async (router) => {
|
|
@@ -35,7 +34,7 @@ export namespace PlataSwagger {
|
|
|
35
34
|
const metodo = path.normalize(path.basename(docPath))
|
|
36
35
|
const httpPath = path.normalize(
|
|
37
36
|
path.dirname(docPath.replace(PlataDirs.getProjectDirSwaggerRotas(), ''))
|
|
38
|
-
)
|
|
37
|
+
).replace(/\\/g, '/')
|
|
39
38
|
|
|
40
39
|
const header = PlataFiles.readJsonSync(path.join(docPath, 'header.json'))
|
|
41
40
|
const body = PlataFiles.readJsonSync(path.join(docPath, 'body.json'))
|
package/libs/tools.ts
CHANGED
|
@@ -35,7 +35,7 @@ export namespace PlataDirs {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function getProjectConfigFileDir(file: string): string {
|
|
38
|
-
return
|
|
38
|
+
return path.resolve('.', 'configs', file).replace(/\\/g, '/')
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function getProjectDirEnvs(): string {
|
|
@@ -69,7 +69,7 @@ export namespace PlataDirs {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function getPlataBinExtraFile(file: string): string {
|
|
72
|
-
return
|
|
72
|
+
return `${path.join(getPlataDir(), 'bin', 'extras', file)}`.replace(/\\/g, '/')
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
}
|
|
@@ -194,7 +194,7 @@ export namespace PlataRequire {
|
|
|
194
194
|
export async function requireAsync<Type>(file: string): Promise<Required<Type>> {
|
|
195
195
|
const p = path.resolve(file)
|
|
196
196
|
|
|
197
|
-
const e = await import(
|
|
197
|
+
const e = await import(p.replace(/\\/g, '/')).catch(e => { return {_plataError: e } })
|
|
198
198
|
|
|
199
199
|
if (e._plataError !== undefined) {
|
|
200
200
|
return {
|
|
@@ -218,7 +218,7 @@ export namespace PlataRequire {
|
|
|
218
218
|
glob.sync(`${p.replace(/\\/g, '/')}/**/*.+(js|ts)`)
|
|
219
219
|
.filter(file => !file.endsWith('.d.ts'))
|
|
220
220
|
.forEach(file => {
|
|
221
|
-
file = file.replace(
|
|
221
|
+
file = file.replace(/\.ts|\.js$/, '')
|
|
222
222
|
|
|
223
223
|
promises.push(requireAsync<Type>(file))
|
|
224
224
|
})
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pwi-plata-type",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.3.6",
|
|
5
4
|
"main": "index.ts",
|
|
6
5
|
"bin": {
|
|
7
6
|
"plata": "bin/plata.ts",
|
|
8
7
|
"plata-cli-create": "bin/plata-create.ts",
|
|
9
|
-
"plata-swagger-gen": "bin/plata-swagger-gen.ts"
|
|
8
|
+
"plata-swagger-gen": "bin/plata-swagger-gen.ts",
|
|
9
|
+
"plata-reload": "bin/plata-reload.ts"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"postinstall": "node postinstall.
|
|
12
|
+
"postinstall": "node postinstall.mjs"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "UNLICENSED",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@swc/core": "^1.2.218",
|
|
18
19
|
"@types/express": "^4.17.13",
|
|
19
20
|
"@types/glob": "^7.2.0",
|
|
20
21
|
"@types/jest": "^28.1.1",
|
|
@@ -23,8 +24,9 @@
|
|
|
23
24
|
"jest": "^28.1.1",
|
|
24
25
|
"swagger-ui-express": "^4.4.0",
|
|
25
26
|
"ts-jest": "^28.0.4",
|
|
26
|
-
"ts-node": "10.
|
|
27
|
-
"express": "^4.18.1"
|
|
27
|
+
"ts-node": "^10.9.1",
|
|
28
|
+
"express": "^4.18.1",
|
|
29
|
+
"tsconfig-paths": "^4.0.0"
|
|
28
30
|
},
|
|
29
31
|
"description": "",
|
|
30
32
|
"devDependencies": {
|
|
@@ -15,6 +15,10 @@ const main = async () => {
|
|
|
15
15
|
projectPackageJson.plata_type = projectPackageJson.plata_type ?? 'api'
|
|
16
16
|
projectPackageJson.plata_name = plataPackageJson.name
|
|
17
17
|
projectPackageJson.license = "UNLICENSED"
|
|
18
|
+
projectPackageJson['scripts_plata'] = projectPackageJson['scripts_plata'] ?? new Object(null)
|
|
19
|
+
|
|
20
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy
|
|
21
|
+
projectPackageJson.scripts = JSON.parse(JSON.stringify(projectPackageJson['scripts_plata']))
|
|
18
22
|
|
|
19
23
|
const templateDir = path.join(templatesDir, projectPackageJson.plata_type)
|
|
20
24
|
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
FROM node:16-alpine
|
|
1
|
+
FROM node:16-alpine
|
|
2
2
|
|
|
3
3
|
WORKDIR /usr/src/app
|
|
4
4
|
|
|
5
|
-
COPY
|
|
6
|
-
|
|
7
|
-
RUN npm ci --only=production && \
|
|
8
|
-
npm run build
|
|
9
|
-
|
|
10
|
-
FROM node:16-alpine AS bin
|
|
5
|
+
COPY package*.json ./
|
|
11
6
|
|
|
12
7
|
EXPOSE 3050
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
RUN npm ci --only=production
|
|
15
10
|
|
|
16
|
-
COPY
|
|
11
|
+
COPY . ./
|
|
17
12
|
|
|
18
13
|
CMD [ "npm", "start" ]
|
|
@@ -18,13 +18,12 @@ export async function install({ dirs, projectPackageJson }) {
|
|
|
18
18
|
promises.push(t.copyFileToProject('Dockerfile'))
|
|
19
19
|
promises.push(t.syncFileToProject('tsconfig.json'))
|
|
20
20
|
|
|
21
|
-
projectPackageJson.
|
|
22
|
-
projectPackageJson.scripts =
|
|
23
|
-
projectPackageJson.scripts.
|
|
24
|
-
projectPackageJson.scripts.build = `npx tsc && ts-node --transpile-only --esm ./node_modules/${projectPackageJson.plata_name}/bin/plata-build --`
|
|
25
|
-
projectPackageJson.scripts.create = `ts-node --transpile-only --esm ./node_modules/${projectPackageJson.plata_name}/bin/plata-create --`
|
|
21
|
+
projectPackageJson.scripts.start = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata`
|
|
22
|
+
projectPackageJson.scripts.build = `npx tsc && ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-build --`
|
|
23
|
+
projectPackageJson.scripts.create = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-create --`
|
|
26
24
|
projectPackageJson.scripts.dev = "npx nodemon -e '.js,.mjs,.json,.ts' --exec 'npm start'"
|
|
27
|
-
projectPackageJson.scripts['swagger:gen'] = `ts-node
|
|
25
|
+
projectPackageJson.scripts['swagger:gen'] = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-swagger-gen`
|
|
26
|
+
projectPackageJson.scripts['plata:reload'] = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-reload.ts`
|
|
28
27
|
projectPackageJson.main = undefined
|
|
29
28
|
|
|
30
29
|
await Promise.all(promises)
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
+
"ts-node": {
|
|
3
|
+
"transpileOnly": true,
|
|
4
|
+
"swc": true,
|
|
5
|
+
"esm": false,
|
|
6
|
+
"project": "./tsconfig.json",
|
|
7
|
+
"skipIgnore": true,
|
|
8
|
+
"require": [
|
|
9
|
+
"tsconfig-paths/register"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"module": "CommonJS"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
2
15
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
"target": "ESNext",
|
|
17
|
+
"module": "CommonJS",
|
|
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
|
+
}
|
|
11
35
|
},
|
|
12
36
|
"include": [
|
|
13
37
|
"./**/*.ts",
|
|
14
|
-
"node_modules/pwi-plata
|
|
38
|
+
"./node_modules/pwi-plata-type/**/*.ts"
|
|
15
39
|
]
|
|
16
40
|
}
|
|
@@ -18,10 +18,10 @@ export async function install({ dirs, projectPackageJson }) {
|
|
|
18
18
|
promises.push(t.syncFileToProject('tsconfig.json'))
|
|
19
19
|
|
|
20
20
|
projectPackageJson.type = "module"
|
|
21
|
-
projectPackageJson.scripts =
|
|
22
|
-
projectPackageJson.scripts.dev = "ts-node"
|
|
21
|
+
projectPackageJson.scripts.dev = "ts-node -P ./tsconfig.json"
|
|
23
22
|
projectPackageJson.scripts.postinstall = "node postinstall.js"
|
|
24
|
-
projectPackageJson.scripts.create = `ts-node
|
|
23
|
+
projectPackageJson.scripts.create = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-create --`
|
|
24
|
+
projectPackageJson.scripts['plata:reload'] = `ts-node -P ./tsconfig.json ./node_modules/${projectPackageJson.plata_name}/bin/plata-reload.ts`
|
|
25
25
|
projectPackageJson.main = undefined
|
|
26
26
|
|
|
27
27
|
await Promise.all(promises)
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"ts-node": {
|
|
3
|
+
"transpileOnly": true,
|
|
4
|
+
"swc": true,
|
|
5
|
+
"esm": false,
|
|
6
|
+
"project": "./tsconfig.json",
|
|
7
|
+
"skipIgnore": true,
|
|
8
|
+
"require": [
|
|
9
|
+
"tsconfig-paths/register"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"module": "CommonJS"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"target": "ESNext",
|
|
17
|
+
"module": "CommonJS",
|
|
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
|
+
]
|
|
16
40
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
+
"ts-node": {
|
|
3
|
+
"transpileOnly": true,
|
|
4
|
+
"swc": true,
|
|
5
|
+
"esm": false,
|
|
6
|
+
"project": "./tsconfig.json",
|
|
7
|
+
"skipIgnore": true,
|
|
8
|
+
"require": [
|
|
9
|
+
"tsconfig-paths/register"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"module": "CommonJS"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
2
15
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
"target": "ESNext",
|
|
17
|
+
"module": "CommonJS",
|
|
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
|
+
}
|
|
11
35
|
},
|
|
12
36
|
"include": [
|
|
13
37
|
"./**/*.ts",
|
|
14
|
-
"node_modules/pwi-plata
|
|
38
|
+
"./node_modules/pwi-plata-type/**/*.ts"
|
|
15
39
|
]
|
|
16
40
|
}
|