@wagq/wa-cli 0.6.5 → 0.6.10
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 +2 -1
- package/lib/server/index.js +21 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/server/index.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
const { spawn } = require('node:child_process'); // 使用 node: 前缀明确使用核心模块
|
|
2
|
+
const Prompt = require("inquirer");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// 可以在https://www.toolhelper.cn/SSL/SSLGenerate生成
|
|
5
|
+
const sslQuestions = () => [
|
|
6
|
+
{
|
|
7
|
+
type: "input",
|
|
8
|
+
name: "cert",
|
|
9
|
+
default: "cert.pem",
|
|
10
|
+
message: `证书地址(完整的绝对路径)`,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: "input",
|
|
14
|
+
name: "private",
|
|
15
|
+
default: "private.key",
|
|
16
|
+
message: `私钥地址(完整的绝对路径)`,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const server = async(filePath, argv) => {
|
|
4
21
|
const https = argv.https ?? false;
|
|
5
22
|
const port = argv.port ?? 3000;
|
|
6
23
|
|
|
7
24
|
try {
|
|
8
25
|
const args = [filePath, '-p', port.toString()];
|
|
9
|
-
if (https) {
|
|
10
|
-
|
|
26
|
+
if (https === 'true') {
|
|
27
|
+
const { cert, private } = await Prompt.default.prompt(sslQuestions());
|
|
28
|
+
args.push('-S', '-C', `${cert}`, '-K', `${private}`);
|
|
11
29
|
}
|
|
12
30
|
|
|
13
31
|
const child = spawn('npx', ['http-server', ...args], {
|