nuxt-gin-tools 0.1.17 → 0.1.19
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/package.json +1 -1
- package/src/postinstall.js +33 -8
package/package.json
CHANGED
package/src/postinstall.js
CHANGED
|
@@ -5,19 +5,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.postInstall = postInstall;
|
|
7
7
|
const concurrently_1 = __importDefault(require("concurrently"));
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
9
|
function postInstall() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
name: "go",
|
|
14
|
-
prefixColor: "green",
|
|
15
|
-
},
|
|
10
|
+
const hasGo = (0, node_child_process_1.spawnSync)("go", ["version"], { stdio: "ignore", shell: true }).status ===
|
|
11
|
+
0;
|
|
12
|
+
const hasAir = (0, node_child_process_1.spawnSync)("air", ["-v"], { stdio: "ignore", shell: true }).status === 0;
|
|
13
|
+
const commands = [
|
|
16
14
|
{
|
|
17
15
|
command: "npx nuxt prepare",
|
|
18
16
|
name: "nuxt",
|
|
19
17
|
prefixColor: "blue",
|
|
20
18
|
},
|
|
21
|
-
]
|
|
19
|
+
];
|
|
20
|
+
if (hasGo) {
|
|
21
|
+
commands.unshift({
|
|
22
|
+
command: "go mod download && go mod tidy",
|
|
23
|
+
name: "go",
|
|
24
|
+
prefixColor: "green",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.warn("[nuxt-gin-tools] 未检测到 Go,已跳过 Go 相关安装。请先安装 Go 后再重新运行相关命令。");
|
|
29
|
+
}
|
|
30
|
+
if (!hasAir) {
|
|
31
|
+
const isWindows = process.platform === "win32";
|
|
32
|
+
const pathHint = isWindows
|
|
33
|
+
? [
|
|
34
|
+
"PowerShell: $env:Path += \";$env:USERPROFILE\\go\\bin\"",
|
|
35
|
+
"CMD: set PATH=%PATH%;%USERPROFILE%\\go\\bin",
|
|
36
|
+
].join(" | ")
|
|
37
|
+
: "export PATH=\"$PATH:$HOME/go/bin\"";
|
|
38
|
+
console.warn([
|
|
39
|
+
"[nuxt-gin-tools] 未检测到 air,请先安装 1.63.0 版本并加入 PATH。",
|
|
40
|
+
"安装命令: go install github.com/cosmtrek/air@v1.63.0",
|
|
41
|
+
`PATH 示例: ${pathHint}`,
|
|
42
|
+
"安装完成后请执行: air -v",
|
|
43
|
+
].join("\n"));
|
|
44
|
+
}
|
|
45
|
+
// 执行并发命令
|
|
46
|
+
return (0, concurrently_1.default)(commands).result;
|
|
22
47
|
}
|
|
23
48
|
exports.default = postInstall;
|