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.
Files changed (167) hide show
  1. package/README.md +10 -108
  2. package/bin/cli.mjs +189 -186
  3. package/bin/schema.json +55 -55
  4. package/dist/{chunk-F5YWXY5W.js → chunk-423JPSEB.js} +18 -17
  5. package/dist/chunk-423JPSEB.js.map +1 -0
  6. package/dist/chunk-4R55T3HG.js +253 -0
  7. package/dist/chunk-4R55T3HG.js.map +1 -0
  8. package/dist/chunk-4YVAW3L4.mjs +76 -0
  9. package/dist/chunk-4YVAW3L4.mjs.map +1 -0
  10. package/dist/{chunk-W5EOVGQD.mjs → chunk-5DOVDDO7.mjs} +3 -2
  11. package/dist/chunk-5DOVDDO7.mjs.map +1 -0
  12. package/dist/{chunk-BXLBWRHS.js → chunk-5WQ2SMIK.js} +39 -38
  13. package/dist/chunk-5WQ2SMIK.js.map +1 -0
  14. package/dist/chunk-6MQP6OHU.mjs +295 -0
  15. package/dist/chunk-6MQP6OHU.mjs.map +1 -0
  16. package/dist/chunk-6Q2PCC3A.mjs +295 -0
  17. package/dist/chunk-6Q2PCC3A.mjs.map +1 -0
  18. package/dist/chunk-6UQYEBAN.js +253 -0
  19. package/dist/chunk-6UQYEBAN.js.map +1 -0
  20. package/dist/chunk-6W7CGOZC.mjs +565 -0
  21. package/dist/chunk-6W7CGOZC.mjs.map +1 -0
  22. package/dist/{chunk-YR5Q5F2K.js → chunk-7Y37NSBM.js} +1 -0
  23. package/dist/chunk-7Y37NSBM.js.map +1 -0
  24. package/dist/{chunk-RCTOVYZY.mjs → chunk-BQBSVGMG.mjs} +2 -1
  25. package/dist/chunk-BQBSVGMG.mjs.map +1 -0
  26. package/dist/chunk-BZP6GKM6.mjs +565 -0
  27. package/dist/chunk-BZP6GKM6.mjs.map +1 -0
  28. package/dist/{chunk-ITTD2GBR.mjs → chunk-C5JAHCS2.mjs} +1 -0
  29. package/dist/chunk-C5JAHCS2.mjs.map +1 -0
  30. package/dist/chunk-DTBKDALR.mjs +295 -0
  31. package/dist/chunk-DTBKDALR.mjs.map +1 -0
  32. package/dist/chunk-GHOKWS5V.js +295 -0
  33. package/dist/chunk-GHOKWS5V.js.map +1 -0
  34. package/dist/chunk-H4N6SHNG.mjs +76 -0
  35. package/dist/chunk-H4N6SHNG.mjs.map +1 -0
  36. package/dist/chunk-ICYHM4UM.js +565 -0
  37. package/dist/chunk-ICYHM4UM.js.map +1 -0
  38. package/dist/chunk-LOLXPM4J.mjs +529 -0
  39. package/dist/chunk-LOLXPM4J.mjs.map +1 -0
  40. package/dist/chunk-MSS6A2TU.js +585 -0
  41. package/dist/chunk-MSS6A2TU.js.map +1 -0
  42. package/dist/{chunk-AB4OX3WV.mjs → chunk-NEM3FY7C.mjs} +2 -1
  43. package/dist/chunk-NEM3FY7C.mjs.map +1 -0
  44. package/dist/chunk-OTHER3YM.mjs +253 -0
  45. package/dist/chunk-OTHER3YM.mjs.map +1 -0
  46. package/dist/chunk-Q2FYFIEY.js +295 -0
  47. package/dist/chunk-Q2FYFIEY.js.map +1 -0
  48. package/dist/chunk-QG4X6H5Y.js +565 -0
  49. package/dist/chunk-QG4X6H5Y.js.map +1 -0
  50. package/dist/chunk-QIEZ6YTG.mjs +295 -0
  51. package/dist/chunk-QIEZ6YTG.mjs.map +1 -0
  52. package/dist/chunk-QOAKHCM7.js +295 -0
  53. package/dist/chunk-QOAKHCM7.js.map +1 -0
  54. package/dist/chunk-QVUD6L5X.js +565 -0
  55. package/dist/chunk-QVUD6L5X.js.map +1 -0
  56. package/dist/{chunk-YERBWZCS.js → chunk-RGLTGKAU.js} +64 -63
  57. package/dist/chunk-RGLTGKAU.js.map +1 -0
  58. package/dist/chunk-SHRK3TVB.js +295 -0
  59. package/dist/chunk-SHRK3TVB.js.map +1 -0
  60. package/dist/chunk-TCH6S42Z.js +529 -0
  61. package/dist/chunk-TCH6S42Z.js.map +1 -0
  62. package/dist/chunk-UCGRFVHC.mjs +253 -0
  63. package/dist/chunk-UCGRFVHC.mjs.map +1 -0
  64. package/dist/chunk-VOISXWVF.mjs +295 -0
  65. package/dist/chunk-VOISXWVF.mjs.map +1 -0
  66. package/dist/chunk-W6BC5INO.mjs +295 -0
  67. package/dist/chunk-W6BC5INO.mjs.map +1 -0
  68. package/dist/chunk-X5WQRO4R.js +295 -0
  69. package/dist/chunk-X5WQRO4R.js.map +1 -0
  70. package/dist/chunk-XDMCVVD3.mjs +585 -0
  71. package/dist/chunk-XDMCVVD3.mjs.map +1 -0
  72. package/dist/chunk-XNTMYLK6.js +76 -0
  73. package/dist/chunk-XNTMYLK6.js.map +1 -0
  74. package/dist/chunk-Y6LI4FDO.js +537 -0
  75. package/dist/chunk-Y6LI4FDO.js.map +1 -0
  76. package/dist/chunk-YZ2AQ6IL.mjs +537 -0
  77. package/dist/chunk-YZ2AQ6IL.mjs.map +1 -0
  78. package/dist/chunk-Z4YJHEXT.js +76 -0
  79. package/dist/chunk-Z4YJHEXT.js.map +1 -0
  80. package/dist/chunk-ZE336SKZ.js +295 -0
  81. package/dist/chunk-ZE336SKZ.js.map +1 -0
  82. package/dist/chunk-ZJD235TO.mjs +565 -0
  83. package/dist/chunk-ZJD235TO.mjs.map +1 -0
  84. package/dist/core-39f27fe8.d.ts +131 -0
  85. package/dist/core-930ea883.d.ts +131 -0
  86. package/dist/core-eb646fe5.d.ts +139 -0
  87. package/dist/helper-06d25b37.d.ts +19 -0
  88. package/dist/helper-48454c0b.d.ts +20 -0
  89. package/dist/helper-6133f78f.d.ts +18 -0
  90. package/dist/helper-867a598d.d.ts +18 -0
  91. package/dist/helper-88b19c66.d.ts +12 -0
  92. package/dist/helper-9e206c66.d.ts +12 -0
  93. package/dist/helper-fcbf6aa8.d.ts +20 -0
  94. package/dist/index.d.ts +27 -32
  95. package/dist/index.js +45 -40
  96. package/dist/index.js.map +1 -0
  97. package/dist/index.mjs +15 -10
  98. package/dist/index.mjs.map +1 -0
  99. package/dist/rpc/bullmq/index.d.ts +10 -6
  100. package/dist/rpc/bullmq/index.js +33 -53
  101. package/dist/rpc/bullmq/index.js.map +1 -0
  102. package/dist/rpc/bullmq/index.mjs +27 -47
  103. package/dist/rpc/bullmq/index.mjs.map +1 -0
  104. package/dist/rpc/kafka/index.d.ts +10 -4
  105. package/dist/rpc/kafka/index.js +21 -37
  106. package/dist/rpc/kafka/index.js.map +1 -0
  107. package/dist/rpc/kafka/index.mjs +16 -32
  108. package/dist/rpc/kafka/index.mjs.map +1 -0
  109. package/dist/rpc/nats/index.d.ts +2 -2
  110. package/dist/rpc/nats/index.js +21 -34
  111. package/dist/rpc/nats/index.js.map +1 -0
  112. package/dist/rpc/nats/index.mjs +14 -27
  113. package/dist/rpc/nats/index.mjs.map +1 -0
  114. package/dist/rpc/rabbitmq/index.d.ts +2 -2
  115. package/dist/rpc/rabbitmq/index.js +24 -37
  116. package/dist/rpc/rabbitmq/index.js.map +1 -0
  117. package/dist/rpc/rabbitmq/index.mjs +15 -28
  118. package/dist/rpc/rabbitmq/index.mjs.map +1 -0
  119. package/dist/rpc/redis/index.d.ts +10 -4
  120. package/dist/rpc/redis/index.js +24 -37
  121. package/dist/rpc/redis/index.js.map +1 -0
  122. package/dist/rpc/redis/index.mjs +17 -30
  123. package/dist/rpc/redis/index.mjs.map +1 -0
  124. package/dist/server/elysia/index.d.ts +4 -3
  125. package/dist/server/elysia/index.js +78 -94
  126. package/dist/server/elysia/index.js.map +1 -0
  127. package/dist/server/elysia/index.mjs +75 -91
  128. package/dist/server/elysia/index.mjs.map +1 -0
  129. package/dist/server/express/index.d.ts +5 -4
  130. package/dist/server/express/index.js +80 -93
  131. package/dist/server/express/index.js.map +1 -0
  132. package/dist/server/express/index.mjs +78 -91
  133. package/dist/server/express/index.mjs.map +1 -0
  134. package/dist/server/fastify/index.d.ts +8 -5
  135. package/dist/server/fastify/index.js +84 -102
  136. package/dist/server/fastify/index.js.map +1 -0
  137. package/dist/server/fastify/index.mjs +80 -98
  138. package/dist/server/fastify/index.mjs.map +1 -0
  139. package/dist/server/h3/index.d.ts +5 -4
  140. package/dist/server/h3/index.js +82 -97
  141. package/dist/server/h3/index.js.map +1 -0
  142. package/dist/server/h3/index.mjs +81 -96
  143. package/dist/server/h3/index.mjs.map +1 -0
  144. package/dist/server/hono/index.d.ts +5 -4
  145. package/dist/server/hono/index.js +74 -90
  146. package/dist/server/hono/index.js.map +1 -0
  147. package/dist/server/hono/index.mjs +73 -89
  148. package/dist/server/hono/index.mjs.map +1 -0
  149. package/dist/server/hyper-express/index.d.ts +6 -5
  150. package/dist/server/hyper-express/index.js +79 -96
  151. package/dist/server/hyper-express/index.js.map +1 -0
  152. package/dist/server/hyper-express/index.mjs +78 -95
  153. package/dist/server/hyper-express/index.mjs.map +1 -0
  154. package/dist/server/koa/index.d.ts +5 -4
  155. package/dist/server/koa/index.js +80 -92
  156. package/dist/server/koa/index.js.map +1 -0
  157. package/dist/server/koa/index.mjs +77 -89
  158. package/dist/server/koa/index.mjs.map +1 -0
  159. package/dist/test.d.ts +1 -1
  160. package/dist/test.js +7 -6
  161. package/dist/test.js.map +1 -0
  162. package/dist/test.mjs +3 -2
  163. package/dist/test.mjs.map +1 -0
  164. package/package.json +8 -7
  165. package/register/index.mjs +40 -40
  166. package/register/loader.mjs +341 -340
  167. package/register/utils.mjs +81 -81
package/README.md CHANGED
@@ -1,108 +1,10 @@
1
- # phecda-server
2
- types share between server and client, `nestjs` format
3
-
4
- ## express
5
-
6
- actually, it works as a set of middlewares
7
- ### server side
8
- ```ts
9
- // in test.controller.ts
10
- import { Body, Controller, Get, Param, Post, Query, Watcher, emitter } from 'phecda-server'
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
- const require = createRequire(import.meta.url)
10
- let child
11
-
12
- let closePromise
13
- const nodeVersion = parseFloat(process.version.slice(1))
14
-
15
- if (nodeVersion < 18.19) {
16
- log(
17
- `Nodejs version less than 18.19(current is ${nodeVersion}) can't support hmr`,
18
- 'yellow',
19
- )
20
- }
21
-
22
- function startChild(file, args) {
23
- child = fork(file, {
24
- env: { NODE_ENV: 'development', ...process.env },
25
- stdio: 'inherit',
26
- execArgv: [
27
- nodeVersion < 18.19
28
- ? '--loader=phecda-server/register/loader.mjs'
29
- : '--import=phecda-server/register',
30
- ...args,
31
- ],
32
- })
33
-
34
- closePromise = new Promise((resolve) => {
35
- child.once('exit', (code) => {
36
- if (code === 4) {
37
- log('only generate code')
38
- process.exit(0)
39
- }
40
- if (code >= 2) {
41
- // for relaunch
42
- log('relaunch...')
43
- startChild(file, args)
44
- }
45
- child = undefined
46
-
47
- resolve()
48
- })
49
- })
50
- }
51
-
52
- function exit() {
53
- log('process exit')
54
-
55
- if (child) {
56
- child.kill()
57
- process.exit(0)
58
- }
59
- else {
60
- process.exit(0)
61
- }
62
- }
63
- process.on('SIGINT', () => {
64
- process.exit()
65
- })
66
-
67
- cli.command('init', 'init config file').action(async () => {
68
- if (!fse.existsSync('tsconfig.json')) {
69
- log('init tsconfig.json')
70
-
71
- await fse.outputFile(
72
- 'tsconfig.json',
73
- `{
74
- "compilerOptions": {
75
- "target": "esnext",
76
- "useDefineForClassFields": false,
77
- "experimentalDecorators": true,
78
- "emitDecoratorMetadata": true,
79
- "module": "esnext",
80
- "lib": ["esnext", "DOM"],
81
- "strictPropertyInitialization": false,
82
- "moduleResolution": "Node",
83
- "strict": true,
84
- "resolveJsonModule": true,
85
- "esModuleInterop": true,
86
- "noEmit": true,
87
- "noUnusedLocals": true,
88
- "noUnusedParameters": true,
89
- "noImplicitReturns": true,
90
- "skipLibCheck": true
91
- },
92
- "include": ["src","./ps.d.ts"]
93
- }
94
- `,
95
- )
96
- }
97
-
98
- if (!fse.existsSync('ps.json')) {
99
- log('init ps.json')
100
-
101
- await fse.outputFile(
102
- 'ps.json',
103
- `{
104
- "$schema": "node_modules/phecda-server/bin/schema.json",
105
- "resolve": [
106
- {
107
- "source": "controller",
108
- "importer": "http",
109
- "path": ".ps/http.ts"
110
- },
111
- {
112
- "source": "rpc",
113
- "importer": "client",
114
- "path": ".ps/rpc.ts"
115
- }
116
- ],
117
- "unimport":false,
118
- "moduleFile": []
119
- }
120
- `,
121
- )
122
- }
123
- })
124
-
125
- cli
126
- .command('[file]', 'run file')
127
- .alias('run')
128
- .option('-c, --config', 'config file', {
129
- default: './ps.json',
130
- })
131
- .action((file, options) => {
132
- process.env.PS_CONFIG_FILE = options.config
133
-
134
- log('process start!')
135
-
136
- startChild(file, options['--'])
137
- console.log(`${pc.green('->')} press ${pc.green('e')} to exit`)
138
- console.log(`${pc.green('->')} press ${pc.green('r')} to relaunch`)
139
-
140
- process.stdin.on('data', async (data) => {
141
- const input = data.toString().trim().toLocaleLowerCase()
142
- if (input === 'r') {
143
- if (child) {
144
- await child.kill()
145
- if (closePromise)
146
- await closePromise
147
- log('relaunch...')
148
- startChild(file, options['--'])
149
- }
150
- else {
151
- log('relaunch...')
152
-
153
- startChild(file, options['--'])
154
- }
155
- }
156
- if (input === 'e')
157
- exit()
158
- })
159
- })
160
-
161
- cli
162
- .command('generate [file]', 'generate code(mainly for ci)')
163
- .option('-c, --config', 'config file', {
164
- default: './ps.json',
165
- })
166
- .action((file, options) => {
167
- process.env.PS_GENERATE = 'true'
168
- process.env.PS_CONFIG_FILE = options.config
169
- startChild(file, options['--'])
170
- })
171
- // if (cmd[0] === 'init') {
172
-
173
- // }
174
- // else if (cmd[0] === 'code') {
175
- // process.env.PS_GENERATE = 'true'
176
- // cmd.splice(0, 1)
177
- // startChild(file,options['--'])
178
- // }
179
- // else {
180
-
181
- // }
182
-
183
- cli.help()
184
- cli.version(require('../package.json').version)
185
-
186
- cli.parse()
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
+ }