phecda-server 5.2.1 → 5.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/cli.mjs +24 -17
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -9,10 +9,9 @@ import cac from 'cac'
|
|
|
9
9
|
import fse from 'fs-extra'
|
|
10
10
|
import { log } from '../dist/index.mjs'
|
|
11
11
|
|
|
12
|
-
const cli = cac('phecda')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
12
|
+
const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
13
|
+
default: 'ps.json',
|
|
14
|
+
})
|
|
16
15
|
|
|
17
16
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
18
17
|
|
|
@@ -75,19 +74,25 @@ process.on('SIGINT', () => {
|
|
|
75
74
|
})
|
|
76
75
|
|
|
77
76
|
cli
|
|
78
|
-
.command('init [
|
|
77
|
+
.command('init [root]', 'init config file')
|
|
79
78
|
.allowUnknownOptions()
|
|
80
79
|
.option('-t,--tsconfig <tsconfig>', 'init tsconfig file', {
|
|
81
80
|
default: 'tsconfig.json',
|
|
82
81
|
})
|
|
83
|
-
.action(async (
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
.action(async (root, options) => {
|
|
83
|
+
if (!root)
|
|
84
|
+
root = ''
|
|
85
|
+
|
|
86
|
+
const tsconfigPath = join(root, options.tsconfig)
|
|
87
|
+
const psconfigPath = join(root, options.config)
|
|
86
88
|
|
|
87
89
|
if (!fse.existsSync(tsconfigPath)) {
|
|
88
90
|
log(`create ${tsconfigPath}`)
|
|
89
91
|
|
|
90
|
-
await fse.copyFile(
|
|
92
|
+
await fse.copyFile(
|
|
93
|
+
resolve(__dirname, '../assets/tsconfig.json'),
|
|
94
|
+
tsconfigPath,
|
|
95
|
+
)
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
if (!fse.existsSync(psconfigPath)) {
|
|
@@ -95,15 +100,17 @@ cli
|
|
|
95
100
|
|
|
96
101
|
await fse.copyFile(resolve(__dirname, '../assets/ps.json'), psconfigPath)
|
|
97
102
|
}
|
|
103
|
+
|
|
104
|
+
log('init finish')
|
|
98
105
|
})
|
|
99
106
|
|
|
100
107
|
cli
|
|
101
|
-
.command('<file> [
|
|
108
|
+
.command('<file> [root]', 'run file')
|
|
102
109
|
.allowUnknownOptions()
|
|
103
110
|
.alias('run')
|
|
104
|
-
.action((file,
|
|
105
|
-
if (
|
|
106
|
-
process.env.PS_WORKDIR =
|
|
111
|
+
.action((file, root, options) => {
|
|
112
|
+
if (root)
|
|
113
|
+
process.env.PS_WORKDIR = root
|
|
107
114
|
process.env.PS_CONFIG_FILE = options.config
|
|
108
115
|
|
|
109
116
|
log('process start!')
|
|
@@ -134,11 +141,11 @@ cli
|
|
|
134
141
|
})
|
|
135
142
|
|
|
136
143
|
cli
|
|
137
|
-
.command('generate <file> [
|
|
144
|
+
.command('generate <file> [root]', 'generate code(mainly for ci)')
|
|
138
145
|
.allowUnknownOptions()
|
|
139
|
-
.action((file,
|
|
140
|
-
if (
|
|
141
|
-
process.env.PS_WORKDIR =
|
|
146
|
+
.action((file, root, options) => {
|
|
147
|
+
if (root)
|
|
148
|
+
process.env.PS_WORKDIR = root
|
|
142
149
|
process.env.PS_GENERATE = 'true'
|
|
143
150
|
process.env.PS_CONFIG_FILE = options.config
|
|
144
151
|
startChild(file, options['--'])
|