phecda-server 5.0.2 → 5.1.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/README.md +10 -108
- package/bin/cli.mjs +189 -186
- package/bin/schema.json +55 -55
- package/dist/{chunk-F5YWXY5W.js → chunk-423JPSEB.js} +18 -17
- package/dist/chunk-423JPSEB.js.map +1 -0
- package/dist/chunk-4R55T3HG.js +253 -0
- package/dist/chunk-4R55T3HG.js.map +1 -0
- package/dist/chunk-4YVAW3L4.mjs +76 -0
- package/dist/chunk-4YVAW3L4.mjs.map +1 -0
- package/dist/{chunk-W5EOVGQD.mjs → chunk-5DOVDDO7.mjs} +3 -2
- package/dist/chunk-5DOVDDO7.mjs.map +1 -0
- package/dist/{chunk-BXLBWRHS.js → chunk-5WQ2SMIK.js} +39 -38
- package/dist/chunk-5WQ2SMIK.js.map +1 -0
- package/dist/chunk-6MQP6OHU.mjs +295 -0
- package/dist/chunk-6MQP6OHU.mjs.map +1 -0
- package/dist/chunk-6Q2PCC3A.mjs +295 -0
- package/dist/chunk-6Q2PCC3A.mjs.map +1 -0
- package/dist/chunk-6UQYEBAN.js +253 -0
- package/dist/chunk-6UQYEBAN.js.map +1 -0
- package/dist/chunk-6W7CGOZC.mjs +565 -0
- package/dist/chunk-6W7CGOZC.mjs.map +1 -0
- package/dist/{chunk-YR5Q5F2K.js → chunk-7Y37NSBM.js} +1 -0
- package/dist/chunk-7Y37NSBM.js.map +1 -0
- package/dist/{chunk-RCTOVYZY.mjs → chunk-BQBSVGMG.mjs} +2 -1
- package/dist/chunk-BQBSVGMG.mjs.map +1 -0
- package/dist/chunk-BZP6GKM6.mjs +565 -0
- package/dist/chunk-BZP6GKM6.mjs.map +1 -0
- package/dist/{chunk-ITTD2GBR.mjs → chunk-C5JAHCS2.mjs} +1 -0
- package/dist/chunk-C5JAHCS2.mjs.map +1 -0
- package/dist/chunk-DTBKDALR.mjs +295 -0
- package/dist/chunk-DTBKDALR.mjs.map +1 -0
- package/dist/chunk-GHOKWS5V.js +295 -0
- package/dist/chunk-GHOKWS5V.js.map +1 -0
- package/dist/chunk-H4N6SHNG.mjs +76 -0
- package/dist/chunk-H4N6SHNG.mjs.map +1 -0
- package/dist/chunk-ICYHM4UM.js +565 -0
- package/dist/chunk-ICYHM4UM.js.map +1 -0
- package/dist/chunk-LOLXPM4J.mjs +529 -0
- package/dist/chunk-LOLXPM4J.mjs.map +1 -0
- package/dist/chunk-MSS6A2TU.js +585 -0
- package/dist/chunk-MSS6A2TU.js.map +1 -0
- package/dist/{chunk-AB4OX3WV.mjs → chunk-NEM3FY7C.mjs} +2 -1
- package/dist/chunk-NEM3FY7C.mjs.map +1 -0
- package/dist/chunk-OTHER3YM.mjs +253 -0
- package/dist/chunk-OTHER3YM.mjs.map +1 -0
- package/dist/chunk-Q2FYFIEY.js +295 -0
- package/dist/chunk-Q2FYFIEY.js.map +1 -0
- package/dist/chunk-QG4X6H5Y.js +565 -0
- package/dist/chunk-QG4X6H5Y.js.map +1 -0
- package/dist/chunk-QIEZ6YTG.mjs +295 -0
- package/dist/chunk-QIEZ6YTG.mjs.map +1 -0
- package/dist/chunk-QOAKHCM7.js +295 -0
- package/dist/chunk-QOAKHCM7.js.map +1 -0
- package/dist/chunk-QVUD6L5X.js +565 -0
- package/dist/chunk-QVUD6L5X.js.map +1 -0
- package/dist/{chunk-YERBWZCS.js → chunk-RGLTGKAU.js} +64 -63
- package/dist/chunk-RGLTGKAU.js.map +1 -0
- package/dist/chunk-SHRK3TVB.js +295 -0
- package/dist/chunk-SHRK3TVB.js.map +1 -0
- package/dist/chunk-TCH6S42Z.js +529 -0
- package/dist/chunk-TCH6S42Z.js.map +1 -0
- package/dist/chunk-UCGRFVHC.mjs +253 -0
- package/dist/chunk-UCGRFVHC.mjs.map +1 -0
- package/dist/chunk-VOISXWVF.mjs +295 -0
- package/dist/chunk-VOISXWVF.mjs.map +1 -0
- package/dist/chunk-W6BC5INO.mjs +295 -0
- package/dist/chunk-W6BC5INO.mjs.map +1 -0
- package/dist/chunk-X5WQRO4R.js +295 -0
- package/dist/chunk-X5WQRO4R.js.map +1 -0
- package/dist/chunk-XDMCVVD3.mjs +585 -0
- package/dist/chunk-XDMCVVD3.mjs.map +1 -0
- package/dist/chunk-XNTMYLK6.js +76 -0
- package/dist/chunk-XNTMYLK6.js.map +1 -0
- package/dist/chunk-Y6LI4FDO.js +537 -0
- package/dist/chunk-Y6LI4FDO.js.map +1 -0
- package/dist/chunk-YZ2AQ6IL.mjs +537 -0
- package/dist/chunk-YZ2AQ6IL.mjs.map +1 -0
- package/dist/chunk-Z4YJHEXT.js +76 -0
- package/dist/chunk-Z4YJHEXT.js.map +1 -0
- package/dist/chunk-ZE336SKZ.js +295 -0
- package/dist/chunk-ZE336SKZ.js.map +1 -0
- package/dist/chunk-ZJD235TO.mjs +565 -0
- package/dist/chunk-ZJD235TO.mjs.map +1 -0
- package/dist/core-39f27fe8.d.ts +131 -0
- package/dist/core-930ea883.d.ts +131 -0
- package/dist/core-eb646fe5.d.ts +139 -0
- package/dist/helper-06d25b37.d.ts +19 -0
- package/dist/helper-48454c0b.d.ts +20 -0
- package/dist/helper-6133f78f.d.ts +18 -0
- package/dist/helper-867a598d.d.ts +18 -0
- package/dist/helper-88b19c66.d.ts +12 -0
- package/dist/helper-9e206c66.d.ts +12 -0
- package/dist/helper-fcbf6aa8.d.ts +20 -0
- package/dist/index.d.ts +27 -32
- package/dist/index.js +45 -40
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -0
- package/dist/rpc/bullmq/index.d.ts +10 -6
- package/dist/rpc/bullmq/index.js +33 -53
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +27 -47
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.ts +10 -4
- package/dist/rpc/kafka/index.js +21 -37
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +16 -32
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.ts +2 -2
- package/dist/rpc/nats/index.js +21 -34
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +14 -27
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.ts +2 -2
- package/dist/rpc/rabbitmq/index.js +24 -37
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +15 -28
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.ts +10 -4
- package/dist/rpc/redis/index.js +24 -37
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +17 -30
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/server/elysia/index.d.ts +4 -3
- package/dist/server/elysia/index.js +78 -94
- package/dist/server/elysia/index.js.map +1 -0
- package/dist/server/elysia/index.mjs +75 -91
- package/dist/server/elysia/index.mjs.map +1 -0
- package/dist/server/express/index.d.ts +5 -4
- package/dist/server/express/index.js +80 -93
- package/dist/server/express/index.js.map +1 -0
- package/dist/server/express/index.mjs +78 -91
- package/dist/server/express/index.mjs.map +1 -0
- package/dist/server/fastify/index.d.ts +8 -5
- package/dist/server/fastify/index.js +84 -102
- package/dist/server/fastify/index.js.map +1 -0
- package/dist/server/fastify/index.mjs +80 -98
- package/dist/server/fastify/index.mjs.map +1 -0
- package/dist/server/h3/index.d.ts +5 -4
- package/dist/server/h3/index.js +82 -97
- package/dist/server/h3/index.js.map +1 -0
- package/dist/server/h3/index.mjs +81 -96
- package/dist/server/h3/index.mjs.map +1 -0
- package/dist/server/hono/index.d.ts +5 -4
- package/dist/server/hono/index.js +74 -90
- package/dist/server/hono/index.js.map +1 -0
- package/dist/server/hono/index.mjs +73 -89
- package/dist/server/hono/index.mjs.map +1 -0
- package/dist/server/hyper-express/index.d.ts +6 -5
- package/dist/server/hyper-express/index.js +79 -96
- package/dist/server/hyper-express/index.js.map +1 -0
- package/dist/server/hyper-express/index.mjs +78 -95
- package/dist/server/hyper-express/index.mjs.map +1 -0
- package/dist/server/koa/index.d.ts +5 -4
- package/dist/server/koa/index.js +80 -92
- package/dist/server/koa/index.js.map +1 -0
- package/dist/server/koa/index.mjs +77 -89
- package/dist/server/koa/index.mjs.map +1 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/package.json +8 -7
- package/register/index.mjs +40 -40
- package/register/loader.mjs +341 -340
- package/register/utils.mjs +81 -81
package/README.md
CHANGED
|
@@ -1,108 +1,10 @@
|
|
|
1
|
-
# phecda-server
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@Controller('/base')
|
|
13
|
-
export class TestController {
|
|
14
|
-
@Post('/:test')
|
|
15
|
-
async test(@Param('test') test: string, @Body('name') name: string, @Query('id') id: string) {
|
|
16
|
-
console.log(`${test}-${name}-${id}`)
|
|
17
|
-
emitter.emit('watch', 1)
|
|
18
|
-
return `${test}-${name}-${id}`
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Get('/get')
|
|
22
|
-
async get() {
|
|
23
|
-
return {
|
|
24
|
-
data: 'test',
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
```ts
|
|
30
|
-
// in server.ts
|
|
31
|
-
import fs from 'fs'
|
|
32
|
-
import { Factory, bind } from 'phecda-server'
|
|
33
|
-
import express from 'express'
|
|
34
|
-
import { TestController } from './test.controller'
|
|
35
|
-
const data = await Factory([TestController])
|
|
36
|
-
fs.writeFileSync('meta.p.js', JSON.stringify(data.meta.map(item => item.data)))
|
|
37
|
-
const app = express()
|
|
38
|
-
app.all('*', (req, res, next) => {
|
|
39
|
-
res.header('Access-Control-Allow-Origin', '*')
|
|
40
|
-
res.header('Access-Control-Allow-Headers', 'Content-Type')
|
|
41
|
-
res.header('Access-Control-Allow-Methods', '*')
|
|
42
|
-
next()
|
|
43
|
-
})
|
|
44
|
-
app.use(express.json())
|
|
45
|
-
|
|
46
|
-
bind(app, data)
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### client side
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
// in vite.config.ts
|
|
53
|
-
|
|
54
|
-
import { defineConfig } from 'vite'
|
|
55
|
-
import { Server } from 'phecda-server'
|
|
56
|
-
|
|
57
|
-
export default defineConfig({
|
|
58
|
-
plugins: [Server('meta.p.js')],
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
// in main.ts
|
|
65
|
-
|
|
66
|
-
import { $S, createBeacon, createMergeReq, createReq, isError } from 'phecda-server/client'
|
|
67
|
-
import axios from 'axios'
|
|
68
|
-
import { TestController } from './test.controller'
|
|
69
|
-
|
|
70
|
-
const instance = axios.create({
|
|
71
|
-
// ...
|
|
72
|
-
})
|
|
73
|
-
const useRequest = createReq(instance)
|
|
74
|
-
const useMergeRequest = createMergeReq(instance)
|
|
75
|
-
const { test, get } = new TestController()
|
|
76
|
-
async function request() {
|
|
77
|
-
const { data } = await useRequest(test('phecda', 'server', '1'))
|
|
78
|
-
console.log('[normal request]:')
|
|
79
|
-
|
|
80
|
-
console.log(data)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function seriesRequest() {
|
|
84
|
-
const { data: [, res2] } = await useMergeRequest([get(), test($S(0, 'data'), 'server', '1')])
|
|
85
|
-
console.log('[series request]:')
|
|
86
|
-
|
|
87
|
-
if (isError(res2))
|
|
88
|
-
console.error(res2.message)
|
|
89
|
-
else console.log(res2)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function mergeRequest() {
|
|
93
|
-
const { data: [res1, res2] } = await useMergeRequest([test('phecda', 'server', '1'), get()])
|
|
94
|
-
console.log('[merge request]:')
|
|
95
|
-
|
|
96
|
-
if (isError(res1))
|
|
97
|
-
console.error(res1.message)
|
|
98
|
-
else console.log(res1)
|
|
99
|
-
|
|
100
|
-
if (isError(res2))
|
|
101
|
-
console.error(res2.message)
|
|
102
|
-
else console.log(res2)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
request()
|
|
106
|
-
mergeRequest()
|
|
107
|
-
seriesRequest()
|
|
108
|
-
```
|
|
1
|
+
# phecda-server
|
|
2
|
+
|
|
3
|
+
[DOCUMENT](https://fgsreally.github.io/phecda/)
|
|
4
|
+
|
|
5
|
+
nodejs server framework that provide IOC/type-reuse/http&rpc-adaptor
|
|
6
|
+
|
|
7
|
+
like `nestjs`+ `trpc`, work with `elysia/express/hono/h3/koa/fastify/hyper-express` and `redis/rabbimq/kafka/bullmq/nats`
|
|
8
|
+
|
|
9
|
+
Pragmatism , Progressive, Less code and Easy to maintain
|
|
10
|
+
|
package/bin/cli.mjs
CHANGED
|
@@ -1,186 +1,189 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import { fork } from 'child_process'
|
|
3
|
-
import { createRequire } from 'module'
|
|
4
|
-
import pc from 'picocolors'
|
|
5
|
-
import cac from 'cac'
|
|
6
|
-
import fse from 'fs-extra'
|
|
7
|
-
import { log } from '../dist/index.mjs'
|
|
8
|
-
const cli = cac('phecda')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
// }
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
cli.
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import { fork } from 'child_process'
|
|
3
|
+
import { createRequire } from 'module'
|
|
4
|
+
import pc from 'picocolors'
|
|
5
|
+
import cac from 'cac'
|
|
6
|
+
import fse from 'fs-extra'
|
|
7
|
+
import { log } from '../dist/index.mjs'
|
|
8
|
+
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
9
|
+
default: 'ps.json',
|
|
10
|
+
})
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
let child
|
|
13
|
+
|
|
14
|
+
let closePromise
|
|
15
|
+
const nodeVersion = parseFloat(process.version.slice(1))
|
|
16
|
+
|
|
17
|
+
if (nodeVersion < 18.19) {
|
|
18
|
+
log(
|
|
19
|
+
`Nodejs version less than 18.19(current is ${nodeVersion}) can't support hmr`,
|
|
20
|
+
'yellow',
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function startChild(file, args) {
|
|
25
|
+
child = fork(file, {
|
|
26
|
+
env: { NODE_ENV: 'development', ...process.env },
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
execArgv: [
|
|
29
|
+
nodeVersion < 18.19
|
|
30
|
+
? '--loader=phecda-server/register/loader.mjs'
|
|
31
|
+
: '--import=phecda-server/register',
|
|
32
|
+
...args,
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
closePromise = new Promise((resolve) => {
|
|
37
|
+
child.once('exit', (code) => {
|
|
38
|
+
if (code === 4) {
|
|
39
|
+
log('only generate code')
|
|
40
|
+
process.exit(0)
|
|
41
|
+
}
|
|
42
|
+
if (code >= 2) {
|
|
43
|
+
// for relaunch
|
|
44
|
+
log('relaunch...')
|
|
45
|
+
startChild(file, args)
|
|
46
|
+
}
|
|
47
|
+
child = undefined
|
|
48
|
+
|
|
49
|
+
resolve()
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function exit() {
|
|
55
|
+
log('process exit')
|
|
56
|
+
|
|
57
|
+
if (child) {
|
|
58
|
+
child.kill()
|
|
59
|
+
process.exit(0)
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
process.exit(0)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
process.on('SIGINT', () => {
|
|
66
|
+
process.exit()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
cli.command('init', 'init config file').action(async (options) => {
|
|
70
|
+
if (!fse.existsSync('tsconfig.json')) {
|
|
71
|
+
log('init tsconfig.json')
|
|
72
|
+
|
|
73
|
+
await fse.outputFile(
|
|
74
|
+
'tsconfig.json',
|
|
75
|
+
`{
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"target": "esnext",
|
|
78
|
+
"useDefineForClassFields": false,
|
|
79
|
+
"experimentalDecorators": true,
|
|
80
|
+
"emitDecoratorMetadata": true,
|
|
81
|
+
"module": "esnext",
|
|
82
|
+
"lib": ["esnext", "DOM"],
|
|
83
|
+
"strictPropertyInitialization": false,
|
|
84
|
+
"moduleResolution": "Node",
|
|
85
|
+
"strict": true,
|
|
86
|
+
"resolveJsonModule": true,
|
|
87
|
+
"esModuleInterop": true,
|
|
88
|
+
"noEmit": true,
|
|
89
|
+
"noUnusedLocals": true,
|
|
90
|
+
"noUnusedParameters": true,
|
|
91
|
+
"noImplicitReturns": true,
|
|
92
|
+
"skipLibCheck": true
|
|
93
|
+
},
|
|
94
|
+
"include": ["src","./ps.d.ts"]
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!fse.existsSync(options.config)) {
|
|
101
|
+
log(`init ${options.config}`)
|
|
102
|
+
|
|
103
|
+
await fse.outputFile(
|
|
104
|
+
options.config,
|
|
105
|
+
`{
|
|
106
|
+
"$schema": "node_modules/phecda-server/bin/schema.json",
|
|
107
|
+
"resolve": [
|
|
108
|
+
{
|
|
109
|
+
"source": "controller",
|
|
110
|
+
"importer": "http",
|
|
111
|
+
"path": ".ps/http.js"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"source": "rpc",
|
|
115
|
+
"importer": "client",
|
|
116
|
+
"path": ".ps/rpc.js"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"unimport": {
|
|
120
|
+
"dirs": [],
|
|
121
|
+
"dirsScanOptions":{
|
|
122
|
+
"filePatterns":["*.{service,controller,module,rpc,edge,guard,interceptor,extension,pipe,filter,plugin}.ts"]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"virtualFile":{},
|
|
126
|
+
"moduleFile": []
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
`,
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
cli
|
|
135
|
+
.command('[file]', 'run file')
|
|
136
|
+
.alias('run')
|
|
137
|
+
.action((file, options) => {
|
|
138
|
+
process.env.PS_CONFIG_FILE = options.config
|
|
139
|
+
|
|
140
|
+
log('process start!')
|
|
141
|
+
|
|
142
|
+
startChild(file, options['--'])
|
|
143
|
+
console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
|
|
144
|
+
console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
|
|
145
|
+
|
|
146
|
+
process.stdin.on('data', async (data) => {
|
|
147
|
+
const input = data.toString().trim().toLocaleLowerCase()
|
|
148
|
+
if (input === 'r') {
|
|
149
|
+
if (child) {
|
|
150
|
+
await child.kill()
|
|
151
|
+
if (closePromise)
|
|
152
|
+
await closePromise
|
|
153
|
+
log('relaunch...')
|
|
154
|
+
startChild(file, options['--'])
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
log('relaunch...')
|
|
158
|
+
|
|
159
|
+
startChild(file, options['--'])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (input === 'e')
|
|
163
|
+
exit()
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
cli
|
|
168
|
+
.command('generate [file]', 'generate code(mainly for ci)')
|
|
169
|
+
.action((file, options) => {
|
|
170
|
+
process.env.PS_GENERATE = 'true'
|
|
171
|
+
process.env.PS_CONFIG_FILE = options.config
|
|
172
|
+
startChild(file, options['--'])
|
|
173
|
+
})
|
|
174
|
+
// if (cmd[0] === 'init') {
|
|
175
|
+
|
|
176
|
+
// }
|
|
177
|
+
// else if (cmd[0] === 'code') {
|
|
178
|
+
// process.env.PS_GENERATE = 'true'
|
|
179
|
+
// cmd.splice(0, 1)
|
|
180
|
+
// startChild(file,options['--'])
|
|
181
|
+
// }
|
|
182
|
+
// else {
|
|
183
|
+
|
|
184
|
+
// }
|
|
185
|
+
|
|
186
|
+
cli.help()
|
|
187
|
+
cli.version(require('../package.json').version)
|
|
188
|
+
|
|
189
|
+
cli.parse()
|
package/bin/schema.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"type": "object",
|
|
4
|
-
"properties": {
|
|
5
|
-
"resolve": {
|
|
6
|
-
"type": "array",
|
|
7
|
-
"items": {
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"source": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"description": "The middle name of the imported file."
|
|
13
|
-
},
|
|
14
|
-
"importer": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "The middle name of the importer file."
|
|
17
|
-
},
|
|
18
|
-
"path": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
|
|
21
|
-
"description": "Redirect path"
|
|
22
|
-
},
|
|
23
|
-
"filename": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"optional": true,
|
|
26
|
-
|
|
27
|
-
"description": "generate split chunk,only work in vite"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"required": ["source", "path", "importer"]
|
|
31
|
-
},
|
|
32
|
-
"description": "Resolve and redirect modules path"
|
|
33
|
-
},
|
|
34
|
-
"moduleFile": {
|
|
35
|
-
"type": "array",
|
|
36
|
-
"items": {
|
|
37
|
-
"type": "string"
|
|
38
|
-
},
|
|
39
|
-
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
|
-
},
|
|
41
|
-
"virtualFile": {
|
|
42
|
-
"type": "object",
|
|
43
|
-
"additionalProperties": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
},
|
|
46
|
-
"description": "Virtual module, just like in Vite."
|
|
47
|
-
},
|
|
48
|
-
"unimport": {
|
|
49
|
-
"type": "object",
|
|
50
|
-
"description": "Includes the arguments passed to unimport and 'dtsPath' that specifies the location for generating type files."
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
"required": ["resolve"]
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"resolve": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"source": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The middle name of the imported file."
|
|
13
|
+
},
|
|
14
|
+
"importer": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The middle name of the importer file."
|
|
17
|
+
},
|
|
18
|
+
"path": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
|
|
21
|
+
"description": "Redirect path"
|
|
22
|
+
},
|
|
23
|
+
"filename": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"optional": true,
|
|
26
|
+
|
|
27
|
+
"description": "generate split chunk,only work in vite"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": ["source", "path", "importer"]
|
|
31
|
+
},
|
|
32
|
+
"description": "Resolve and redirect modules path"
|
|
33
|
+
},
|
|
34
|
+
"moduleFile": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"description": "Including the module's file middle name, such as controller mapping to xx.controller.ts"
|
|
40
|
+
},
|
|
41
|
+
"virtualFile": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"additionalProperties": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"description": "Virtual module, just like in Vite."
|
|
47
|
+
},
|
|
48
|
+
"unimport": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"description": "Includes the arguments passed to unimport and 'dtsPath' that specifies the location for generating type files."
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
"required": ["resolve"]
|
|
55
|
+
}
|