pwi-plata-type 0.1.10 → 0.2.2
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/bin/plata-create.ts
CHANGED
|
@@ -17,10 +17,10 @@ const main = async () => {
|
|
|
17
17
|
|
|
18
18
|
switch(projectPackage.plata_type ?? 'api') {
|
|
19
19
|
case 'api':
|
|
20
|
-
handler = (await import('
|
|
20
|
+
handler = (await import(PlataDirs.getPlataBinExtraFile('plata-create-api.js'))) as unknown as Handler
|
|
21
21
|
break;
|
|
22
22
|
case 'lib':
|
|
23
|
-
handler = (await import('
|
|
23
|
+
handler = (await import(PlataDirs.getPlataBinExtraFile('plata-create-lib.js'))) as unknown as Handler
|
|
24
24
|
break;
|
|
25
25
|
default:
|
|
26
26
|
console.log(`tipo ${projectPackage.plata_type} não suportado pela plata`)
|
package/libs/cluster.ts
CHANGED
|
@@ -163,7 +163,7 @@ export class PlataClusterManager {
|
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
if (file !== null) {
|
|
166
|
-
const config: PlataClusterWorkerConfig = (await import(file) as any).default
|
|
166
|
+
const config: PlataClusterWorkerConfig = (await import(`file:///${file}`.replace(/\\/g, '/')) as any).default
|
|
167
167
|
|
|
168
168
|
await config.onStart()
|
|
169
169
|
}
|
package/libs/routes.ts
CHANGED
|
@@ -21,7 +21,7 @@ export async function loadExpressRoutes(): Promise<Router> {
|
|
|
21
21
|
.replace(PlataDirs.getProjectRoutesDir(), '')
|
|
22
22
|
.replace(/.(ts|js)$/, '')
|
|
23
23
|
.replace(/index/, '')
|
|
24
|
-
.replace(
|
|
24
|
+
.replace(/\\/g, '/')
|
|
25
25
|
;
|
|
26
26
|
|
|
27
27
|
router.use(httpRoute, element.exports())
|
package/libs/tools.ts
CHANGED
|
@@ -19,7 +19,7 @@ export module PlataDirs {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function getProjectConfigFileDir(file: string): string {
|
|
22
|
-
return path.resolve('.', 'configs', file)
|
|
22
|
+
return `file:///${path.resolve('.', 'configs', file)}`.replace(/\\/g, '/')
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function getProjectDirEnvs(): string {
|
|
@@ -52,6 +52,10 @@ export module PlataDirs {
|
|
|
52
52
|
return path.join(getPlataTempletesDir(), group, template)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export function getPlataBinExtraFile(file: string): string {
|
|
56
|
+
return `file:///${path.join(getPlataDir(), 'bin', 'extras', file)}`.replace(/\\/g, '/')
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export module PlataFiles {
|
|
@@ -112,7 +116,7 @@ export module PlataFiles {
|
|
|
112
116
|
for (let i = 0; i < folders.length; i++) {
|
|
113
117
|
const folder = folders[i];
|
|
114
118
|
|
|
115
|
-
const f = glob.sync(`${folder}/**/${file}`)[0]
|
|
119
|
+
const f = glob.sync(`${folder.replace(/\\/g, '/')}/**/${file}`)[0]
|
|
116
120
|
|
|
117
121
|
if (f !== undefined) {
|
|
118
122
|
return f
|
|
@@ -136,7 +140,7 @@ export module PlataRequire {
|
|
|
136
140
|
return {
|
|
137
141
|
filePath: p,
|
|
138
142
|
name: path.basename(p).replace('.ts', '').replace('.js', ''),
|
|
139
|
-
exports: (await import(p) as any).default as Type
|
|
143
|
+
exports: (await import(`file:///${p}`.replace(/\\/g, '/')) as any).default as Type
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
|
|
@@ -144,7 +148,7 @@ export module PlataRequire {
|
|
|
144
148
|
const promises: Promise<Required<Type>>[] = []
|
|
145
149
|
const p = path.resolve(folder)
|
|
146
150
|
|
|
147
|
-
glob.sync(`${p}/**/*.ts`).forEach(value => {
|
|
151
|
+
glob.sync(`${p.replace(/\\/g, '/')}/**/*.ts`).forEach(value => {
|
|
148
152
|
value = value.replace('.ts', '.js')
|
|
149
153
|
|
|
150
154
|
promises.push(requireAsync<Type>(value))
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -18,7 +18,7 @@ const main = async () => {
|
|
|
18
18
|
|
|
19
19
|
const templateDir = path.join(templatesDir, projectPackageJson.plata_type)
|
|
20
20
|
|
|
21
|
-
const { install } = await import(path.join(templateDir, '_install.mjs'))
|
|
21
|
+
const { install } = await import(`file:///${path.join(templateDir, '_install.mjs')}`.replace(/\\/g, '/'))
|
|
22
22
|
|
|
23
23
|
projectPackageJson = await install({
|
|
24
24
|
dirs: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as path from 'node:path'
|
|
2
|
+
|
|
1
3
|
export async function install({ dirs, projectPackageJson }) {
|
|
2
|
-
const { tools } = await import('
|
|
4
|
+
const { tools } = await import(`file:///${path.resolve(dirs.plataDir, 'postinstall-tools.mjs')}`.replace(/\\/g, '/'))
|
|
3
5
|
const promises = []
|
|
4
6
|
|
|
5
7
|
const t = tools(dirs)
|
|
@@ -18,8 +20,8 @@ export async function install({ dirs, projectPackageJson }) {
|
|
|
18
20
|
|
|
19
21
|
projectPackageJson.type = "module"
|
|
20
22
|
projectPackageJson.scripts = new Object(null)
|
|
21
|
-
projectPackageJson.scripts.start =
|
|
22
|
-
projectPackageJson.scripts.create =
|
|
23
|
+
projectPackageJson.scripts.start = `ts-node --transpile-only --esm ./node_modules/${projectPackageJson.plata_name}/bin/plata`
|
|
24
|
+
projectPackageJson.scripts.create = `ts-node --transpile-only --esm ./node_modules/${projectPackageJson.plata_name}/bin/plata-create --`
|
|
23
25
|
projectPackageJson.scripts.dev = "npx nodemon -e '.js,.mjs,.json,.ts' --exec 'npm start'"
|
|
24
26
|
projectPackageJson.main = undefined
|
|
25
27
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as path from 'node:path'
|
|
2
|
+
|
|
1
3
|
export async function install({ dirs, projectPackageJson }) {
|
|
2
|
-
const { tools } = await import('
|
|
4
|
+
const { tools } = await import(`file:///${path.resolve(dirs.plataDir, 'postinstall-tools.mjs')}`.replace(/\\/g, '/'))
|
|
3
5
|
const promises = []
|
|
4
6
|
|
|
5
7
|
const t = tools(dirs)
|
|
@@ -19,7 +21,7 @@ export async function install({ dirs, projectPackageJson }) {
|
|
|
19
21
|
projectPackageJson.scripts = new Object(null)
|
|
20
22
|
projectPackageJson.scripts.dev = "ts-node"
|
|
21
23
|
projectPackageJson.scripts.postinstall = "node postinstall.js"
|
|
22
|
-
projectPackageJson.scripts.create = "ts-node --transpile-only --esm ./node_modules/.bin/plata-
|
|
24
|
+
projectPackageJson.scripts.create = "ts-node --transpile-only --esm ./node_modules/.bin/plata-create --"
|
|
23
25
|
projectPackageJson.main = undefined
|
|
24
26
|
|
|
25
27
|
await Promise.all(promises)
|