nuxt-gin-tools 0.2.15 → 0.2.17
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/.go-watch.json +20 -20
- package/LICENSE +21 -21
- package/README.md +150 -150
- package/package.json +30 -30
- package/src/go-gin-server.json +4 -4
- package/src/nuxt-config.js +14 -3
- package/src/pack-config.schema.json +62 -62
- package/src/server-config.json +35 -35
- package/src/api-generate.d.ts +0 -11
- package/src/api-generate.js +0 -133
- package/src/builder.d.ts +0 -2
- package/src/builder.js +0 -26
- package/src/cleanup.d.ts +0 -8
- package/src/cleanup.js +0 -97
- package/src/commands/api-generate.d.ts +0 -11
- package/src/commands/api-generate.js +0 -133
- package/src/commands/builder.d.ts +0 -2
- package/src/commands/builder.js +0 -26
- package/src/commands/cleanup.d.ts +0 -8
- package/src/commands/cleanup.js +0 -97
- package/src/commands/dev-go.d.ts +0 -8
- package/src/commands/dev-go.js +0 -306
- package/src/commands/develop.d.ts +0 -21
- package/src/commands/develop.js +0 -106
- package/src/commands/pack.d.ts +0 -82
- package/src/commands/pack.js +0 -230
- package/src/commands/postinstall.d.ts +0 -2
- package/src/commands/postinstall.js +0 -32
- package/src/commands/update.d.ts +0 -2
- package/src/commands/update.js +0 -22
- package/src/dev-go.d.ts +0 -8
- package/src/dev-go.js +0 -306
- package/src/develop.d.ts +0 -21
- package/src/develop.js +0 -106
- package/src/pack.d.ts +0 -82
- package/src/pack.js +0 -230
- package/src/postinstall.d.ts +0 -2
- package/src/postinstall.js +0 -32
- package/src/update.d.ts +0 -2
- package/src/update.js +0 -22
package/.go-watch.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tmpDir": ".build/.server",
|
|
3
|
-
"testDataDir": "testdata",
|
|
4
|
-
"includeExt": ["go", "tpl", "html"],
|
|
5
|
-
"includeDir": [],
|
|
6
|
-
"includeFile": [],
|
|
7
|
-
"excludeDir": [
|
|
8
|
-
"assets",
|
|
9
|
-
".build/.server",
|
|
10
|
-
"vendor",
|
|
11
|
-
"testdata",
|
|
12
|
-
"node_modules",
|
|
13
|
-
"vue",
|
|
14
|
-
"api",
|
|
15
|
-
".vscode",
|
|
16
|
-
".git"
|
|
17
|
-
],
|
|
18
|
-
"excludeFile": [],
|
|
19
|
-
"excludeRegex": ["_test.go"]
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tmpDir": ".build/.server",
|
|
3
|
+
"testDataDir": "testdata",
|
|
4
|
+
"includeExt": ["go", "tpl", "html"],
|
|
5
|
+
"includeDir": [],
|
|
6
|
+
"includeFile": [],
|
|
7
|
+
"excludeDir": [
|
|
8
|
+
"assets",
|
|
9
|
+
".build/.server",
|
|
10
|
+
"vendor",
|
|
11
|
+
"testdata",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"vue",
|
|
14
|
+
"api",
|
|
15
|
+
".vscode",
|
|
16
|
+
".git"
|
|
17
|
+
],
|
|
18
|
+
"excludeFile": [],
|
|
19
|
+
"excludeRegex": ["_test.go"]
|
|
20
|
+
}
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 AlbertGao
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AlbertGao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
# nuxt-gin-tools
|
|
2
|
-
|
|
3
|
-
`nuxt-gin-tools` 是 `nuxt-gin-starter` 的配套开发工具包,提供 Nuxt + Gin 项目的统一命令入口。
|
|
4
|
-
|
|
5
|
-
核心目标:
|
|
6
|
-
- 一条命令启动前后端开发环境
|
|
7
|
-
- 自动处理 Go 侧依赖和文件监听重启
|
|
8
|
-
- 提供 OpenAPI 代码生成与构建打包辅助
|
|
9
|
-
|
|
10
|
-
## 功能概览
|
|
11
|
-
|
|
12
|
-
- `nuxt-gin dev`
|
|
13
|
-
- 启动 Nuxt 开发服务
|
|
14
|
-
- 启动 Go 文件监听(基于 `chokidar`)
|
|
15
|
-
- Go 文件变化后自动重启 `go run main.go`
|
|
16
|
-
- `nuxt-gin install`
|
|
17
|
-
- 执行 Nuxt prepare
|
|
18
|
-
- 如果检测到 Go,则执行 `go mod download && go mod tidy`
|
|
19
|
-
- `nuxt-gin gen`
|
|
20
|
-
- 基于 `openapi.yaml` 生成 Go / TS API 代码
|
|
21
|
-
- `nuxt-gin build`
|
|
22
|
-
- 执行项目构建与打包流程
|
|
23
|
-
- `nuxt-gin cleanup`
|
|
24
|
-
- 清理开发产物
|
|
25
|
-
- `nuxt-gin update`
|
|
26
|
-
- 执行依赖更新流程
|
|
27
|
-
|
|
28
|
-
## 安装
|
|
29
|
-
|
|
30
|
-
在 `nuxt-gin-starter` 项目中作为依赖安装:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
pnpm add nuxt-gin-tools
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## 快速开始
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# 初始化依赖(可选)
|
|
40
|
-
nuxt-gin install
|
|
41
|
-
|
|
42
|
-
# 启动开发
|
|
43
|
-
nuxt-gin dev
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## 命令说明
|
|
47
|
-
|
|
48
|
-
### `nuxt-gin dev`
|
|
49
|
-
|
|
50
|
-
开发模式下会并行运行:
|
|
51
|
-
- Nuxt:`npx nuxt dev --port=<nuxtPort> --host`
|
|
52
|
-
- Go:监听变更并运行 `go run main.go`
|
|
53
|
-
|
|
54
|
-
Go 监听规则来自 `.go-watch.json`(见下文)。
|
|
55
|
-
|
|
56
|
-
### `nuxt-gin install`
|
|
57
|
-
|
|
58
|
-
- 总是执行:`npx nuxt prepare`
|
|
59
|
-
- 检测到 Go 时额外执行:`go mod download && go mod tidy`
|
|
60
|
-
|
|
61
|
-
### `nuxt-gin gen`
|
|
62
|
-
|
|
63
|
-
依赖 `openapi-generator-cli`,默认会:
|
|
64
|
-
- 生成 Go Gin server 相关代码
|
|
65
|
-
- 生成 TypeScript axios 客户端代码
|
|
66
|
-
|
|
67
|
-
### `nuxt-gin build`
|
|
68
|
-
|
|
69
|
-
执行工具链内置的构建与打包逻辑。
|
|
70
|
-
|
|
71
|
-
### `nuxt-gin cleanup`
|
|
72
|
-
|
|
73
|
-
清理由工具链生成的临时目录和产物。
|
|
74
|
-
|
|
75
|
-
### `nuxt-gin update`
|
|
76
|
-
|
|
77
|
-
执行项目约定的更新逻辑。
|
|
78
|
-
|
|
79
|
-
## 配置
|
|
80
|
-
|
|
81
|
-
### 1) `server.config.json`
|
|
82
|
-
|
|
83
|
-
`dev` 命令会读取该文件,常用字段:
|
|
84
|
-
|
|
85
|
-
- `ginPort`: Gin 服务端口
|
|
86
|
-
- `nuxtPort`: Nuxt 开发端口
|
|
87
|
-
- `baseUrl`: Nuxt baseUrl
|
|
88
|
-
- `killPortBeforeDevelop`: 开发前是否释放端口(默认 `true`)
|
|
89
|
-
- `cleanupBeforeDevelop`: 开发前是否执行 cleanup(默认 `false`)
|
|
90
|
-
|
|
91
|
-
### 3) 开发环境向前端暴露 `ginPort`
|
|
92
|
-
|
|
93
|
-
`createDefaultConfig` 会在 Nuxt `runtimeConfig.public` 中注入 `ginPort`:
|
|
94
|
-
|
|
95
|
-
- 开发环境:`useRuntimeConfig().public.ginPort` 为 `server.config.json` 的 `ginPort`
|
|
96
|
-
- 生产环境:`useRuntimeConfig().public.ginPort` 为 `null`
|
|
97
|
-
- 所有环境:`useRuntimeConfig().public.isDevelopment` 直接暴露当前是否开发环境
|
|
98
|
-
|
|
99
|
-
前端示例:
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
const config = useRuntimeConfig();
|
|
103
|
-
const ginPort = config.public.ginPort;
|
|
104
|
-
const isDevelopment = config.public.isDevelopment;
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 2) `.go-watch.json`
|
|
108
|
-
|
|
109
|
-
Go 监听配置文件,示例:
|
|
110
|
-
|
|
111
|
-
```json
|
|
112
|
-
{
|
|
113
|
-
"tmpDir": ".build/.server",
|
|
114
|
-
"testDataDir": "testdata",
|
|
115
|
-
"includeExt": ["go", "tpl", "html"],
|
|
116
|
-
"includeDir": [],
|
|
117
|
-
"includeFile": [],
|
|
118
|
-
"excludeDir": [
|
|
119
|
-
"assets",
|
|
120
|
-
".build/.server",
|
|
121
|
-
"vendor",
|
|
122
|
-
"testdata",
|
|
123
|
-
"node_modules",
|
|
124
|
-
"vue",
|
|
125
|
-
"api",
|
|
126
|
-
".vscode",
|
|
127
|
-
".git"
|
|
128
|
-
],
|
|
129
|
-
"excludeFile": [],
|
|
130
|
-
"excludeRegex": ["_test.go"]
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
也支持环境变量指定路径:
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## 环境依赖
|
|
141
|
-
|
|
142
|
-
- Node.js
|
|
143
|
-
- pnpm
|
|
144
|
-
- Go(需要运行 Gin 侧开发与依赖下载时)
|
|
145
|
-
- `openapi-generator-cli`(仅 `nuxt-gin gen` 需要)
|
|
146
|
-
|
|
147
|
-
## 说明
|
|
148
|
-
|
|
149
|
-
- Go 侧热更新已不再依赖 Air。
|
|
150
|
-
- 当前方案为:`chokidar` 监听文件变化 + 重启 `go run main.go`。
|
|
1
|
+
# nuxt-gin-tools
|
|
2
|
+
|
|
3
|
+
`nuxt-gin-tools` 是 `nuxt-gin-starter` 的配套开发工具包,提供 Nuxt + Gin 项目的统一命令入口。
|
|
4
|
+
|
|
5
|
+
核心目标:
|
|
6
|
+
- 一条命令启动前后端开发环境
|
|
7
|
+
- 自动处理 Go 侧依赖和文件监听重启
|
|
8
|
+
- 提供 OpenAPI 代码生成与构建打包辅助
|
|
9
|
+
|
|
10
|
+
## 功能概览
|
|
11
|
+
|
|
12
|
+
- `nuxt-gin dev`
|
|
13
|
+
- 启动 Nuxt 开发服务
|
|
14
|
+
- 启动 Go 文件监听(基于 `chokidar`)
|
|
15
|
+
- Go 文件变化后自动重启 `go run main.go`
|
|
16
|
+
- `nuxt-gin install`
|
|
17
|
+
- 执行 Nuxt prepare
|
|
18
|
+
- 如果检测到 Go,则执行 `go mod download && go mod tidy`
|
|
19
|
+
- `nuxt-gin gen`
|
|
20
|
+
- 基于 `openapi.yaml` 生成 Go / TS API 代码
|
|
21
|
+
- `nuxt-gin build`
|
|
22
|
+
- 执行项目构建与打包流程
|
|
23
|
+
- `nuxt-gin cleanup`
|
|
24
|
+
- 清理开发产物
|
|
25
|
+
- `nuxt-gin update`
|
|
26
|
+
- 执行依赖更新流程
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
在 `nuxt-gin-starter` 项目中作为依赖安装:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add nuxt-gin-tools
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 快速开始
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 初始化依赖(可选)
|
|
40
|
+
nuxt-gin install
|
|
41
|
+
|
|
42
|
+
# 启动开发
|
|
43
|
+
nuxt-gin dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 命令说明
|
|
47
|
+
|
|
48
|
+
### `nuxt-gin dev`
|
|
49
|
+
|
|
50
|
+
开发模式下会并行运行:
|
|
51
|
+
- Nuxt:`npx nuxt dev --port=<nuxtPort> --host`
|
|
52
|
+
- Go:监听变更并运行 `go run main.go`
|
|
53
|
+
|
|
54
|
+
Go 监听规则来自 `.go-watch.json`(见下文)。
|
|
55
|
+
|
|
56
|
+
### `nuxt-gin install`
|
|
57
|
+
|
|
58
|
+
- 总是执行:`npx nuxt prepare`
|
|
59
|
+
- 检测到 Go 时额外执行:`go mod download && go mod tidy`
|
|
60
|
+
|
|
61
|
+
### `nuxt-gin gen`
|
|
62
|
+
|
|
63
|
+
依赖 `openapi-generator-cli`,默认会:
|
|
64
|
+
- 生成 Go Gin server 相关代码
|
|
65
|
+
- 生成 TypeScript axios 客户端代码
|
|
66
|
+
|
|
67
|
+
### `nuxt-gin build`
|
|
68
|
+
|
|
69
|
+
执行工具链内置的构建与打包逻辑。
|
|
70
|
+
|
|
71
|
+
### `nuxt-gin cleanup`
|
|
72
|
+
|
|
73
|
+
清理由工具链生成的临时目录和产物。
|
|
74
|
+
|
|
75
|
+
### `nuxt-gin update`
|
|
76
|
+
|
|
77
|
+
执行项目约定的更新逻辑。
|
|
78
|
+
|
|
79
|
+
## 配置
|
|
80
|
+
|
|
81
|
+
### 1) `server.config.json`
|
|
82
|
+
|
|
83
|
+
`dev` 命令会读取该文件,常用字段:
|
|
84
|
+
|
|
85
|
+
- `ginPort`: Gin 服务端口
|
|
86
|
+
- `nuxtPort`: Nuxt 开发端口
|
|
87
|
+
- `baseUrl`: Nuxt baseUrl
|
|
88
|
+
- `killPortBeforeDevelop`: 开发前是否释放端口(默认 `true`)
|
|
89
|
+
- `cleanupBeforeDevelop`: 开发前是否执行 cleanup(默认 `false`)
|
|
90
|
+
|
|
91
|
+
### 3) 开发环境向前端暴露 `ginPort`
|
|
92
|
+
|
|
93
|
+
`createDefaultConfig` 会在 Nuxt `runtimeConfig.public` 中注入 `ginPort`:
|
|
94
|
+
|
|
95
|
+
- 开发环境:`useRuntimeConfig().public.ginPort` 为 `server.config.json` 的 `ginPort`
|
|
96
|
+
- 生产环境:`useRuntimeConfig().public.ginPort` 为 `null`
|
|
97
|
+
- 所有环境:`useRuntimeConfig().public.isDevelopment` 直接暴露当前是否开发环境
|
|
98
|
+
|
|
99
|
+
前端示例:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const config = useRuntimeConfig();
|
|
103
|
+
const ginPort = config.public.ginPort;
|
|
104
|
+
const isDevelopment = config.public.isDevelopment;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2) `.go-watch.json`
|
|
108
|
+
|
|
109
|
+
Go 监听配置文件,示例:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"tmpDir": ".build/.server",
|
|
114
|
+
"testDataDir": "testdata",
|
|
115
|
+
"includeExt": ["go", "tpl", "html"],
|
|
116
|
+
"includeDir": [],
|
|
117
|
+
"includeFile": [],
|
|
118
|
+
"excludeDir": [
|
|
119
|
+
"assets",
|
|
120
|
+
".build/.server",
|
|
121
|
+
"vendor",
|
|
122
|
+
"testdata",
|
|
123
|
+
"node_modules",
|
|
124
|
+
"vue",
|
|
125
|
+
"api",
|
|
126
|
+
".vscode",
|
|
127
|
+
".git"
|
|
128
|
+
],
|
|
129
|
+
"excludeFile": [],
|
|
130
|
+
"excludeRegex": ["_test.go"]
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
也支持环境变量指定路径:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 环境依赖
|
|
141
|
+
|
|
142
|
+
- Node.js
|
|
143
|
+
- pnpm
|
|
144
|
+
- Go(需要运行 Gin 侧开发与依赖下载时)
|
|
145
|
+
- `openapi-generator-cli`(仅 `nuxt-gin gen` 需要)
|
|
146
|
+
|
|
147
|
+
## 说明
|
|
148
|
+
|
|
149
|
+
- Go 侧热更新已不再依赖 Air。
|
|
150
|
+
- 当前方案为:`chokidar` 监听文件变化 + 重启 `go run main.go`。
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nuxt-gin-tools",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "This project is used as a dependency for [nuxt-gin-starter](https://github.com/RapboyGao/nuxt-gin-starter.git)",
|
|
5
|
-
"bin": {
|
|
6
|
-
"nuxt-gin": "index.js"
|
|
7
|
-
},
|
|
8
|
-
"keywords": [],
|
|
9
|
-
"author": "",
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "ts-node build.ts",
|
|
13
|
-
"publish": "npm publish --access public"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"7zip-min": "^2.1.0",
|
|
17
|
-
"chalk": "^5.4.1",
|
|
18
|
-
"chokidar": "^3.6.0",
|
|
19
|
-
"concurrently": "^9.2.0",
|
|
20
|
-
"fast-glob": "^3.3.3",
|
|
21
|
-
"fs-extra": "^11.3.0"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/fs-extra": "^11.0.4",
|
|
25
|
-
"@types/node": "^24.0.15",
|
|
26
|
-
"nuxt": "^4.0.1",
|
|
27
|
-
"ts-node": "^10.9.2",
|
|
28
|
-
"typescript": "^5.8.3"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt-gin-tools",
|
|
3
|
+
"version": "0.2.17",
|
|
4
|
+
"description": "This project is used as a dependency for [nuxt-gin-starter](https://github.com/RapboyGao/nuxt-gin-starter.git)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"nuxt-gin": "index.js"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "ts-node build.ts",
|
|
13
|
+
"publish": "npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"7zip-min": "^2.1.0",
|
|
17
|
+
"chalk": "^5.4.1",
|
|
18
|
+
"chokidar": "^3.6.0",
|
|
19
|
+
"concurrently": "^9.2.0",
|
|
20
|
+
"fast-glob": "^3.3.3",
|
|
21
|
+
"fs-extra": "^11.3.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/fs-extra": "^11.0.4",
|
|
25
|
+
"@types/node": "^24.0.15",
|
|
26
|
+
"nuxt": "^4.0.1",
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"typescript": "^5.8.3"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/go-gin-server.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiPath": "server/api",
|
|
3
|
-
"packageName": "api",
|
|
4
|
-
"serverPort": "8099"
|
|
1
|
+
{
|
|
2
|
+
"apiPath": "server/api",
|
|
3
|
+
"packageName": "api",
|
|
4
|
+
"serverPort": "8099"
|
|
5
5
|
}
|
package/src/nuxt-config.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDefaultConfig = createDefaultConfig;
|
|
4
4
|
const node_http_1 = require("node:http");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
5
6
|
function isDevEnvironment() {
|
|
6
7
|
return process.env.NODE_ENV !== "production";
|
|
7
8
|
}
|
|
@@ -84,13 +85,18 @@ function forwardWebSocketToGin(ginPort, req, clientSocket, clientHead) {
|
|
|
84
85
|
/**
|
|
85
86
|
* 创建默认的 Nuxt 配置。
|
|
86
87
|
*/
|
|
87
|
-
function createDefaultConfig({ serverConfig
|
|
88
|
+
function createDefaultConfig({ serverConfig }) {
|
|
88
89
|
const development = isDevEnvironment();
|
|
89
90
|
const baseUrl = normalizeBaseUrl(serverConfig.baseUrl);
|
|
90
91
|
const publicGinPort = development ? serverConfig.ginPort : null;
|
|
91
92
|
return {
|
|
92
93
|
buildDir: "vue/.nuxt",
|
|
93
94
|
srcDir: "vue",
|
|
95
|
+
nitro: {
|
|
96
|
+
output: {
|
|
97
|
+
dir: (0, node_path_1.join)(process.cwd(), "vue", ".output"),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
94
100
|
ssr: false,
|
|
95
101
|
experimental: {
|
|
96
102
|
payloadExtraction: false,
|
|
@@ -121,6 +127,9 @@ function createDefaultConfig({ serverConfig, }) {
|
|
|
121
127
|
},
|
|
122
128
|
vite: {
|
|
123
129
|
server: {},
|
|
130
|
+
optimizeDeps: {
|
|
131
|
+
include: ["@vue/devtools-core", "@vue/devtools-kit"],
|
|
132
|
+
},
|
|
124
133
|
plugins: [
|
|
125
134
|
{
|
|
126
135
|
name: "nuxt-gin-base-url-proxy",
|
|
@@ -128,7 +137,8 @@ function createDefaultConfig({ serverConfig, }) {
|
|
|
128
137
|
server.middlewares.use((req, res, next) => {
|
|
129
138
|
var _a;
|
|
130
139
|
const requestPath = ((_a = req.url) !== null && _a !== void 0 ? _a : "/").split("?")[0] || "/";
|
|
131
|
-
const shouldForward = !isViteInternalRequest(requestPath) &&
|
|
140
|
+
const shouldForward = !isViteInternalRequest(requestPath) &&
|
|
141
|
+
!isBaseUrlRequest(baseUrl, requestPath);
|
|
132
142
|
if (shouldForward) {
|
|
133
143
|
forwardToGin(serverConfig.ginPort, req, res);
|
|
134
144
|
return;
|
|
@@ -139,7 +149,8 @@ function createDefaultConfig({ serverConfig, }) {
|
|
|
139
149
|
server.httpServer.on("upgrade", (req, socket, head) => {
|
|
140
150
|
var _a;
|
|
141
151
|
const requestPath = ((_a = req.url) !== null && _a !== void 0 ? _a : "/").split("?")[0] || "/";
|
|
142
|
-
const shouldForward = !isViteInternalRequest(requestPath) &&
|
|
152
|
+
const shouldForward = !isViteInternalRequest(requestPath) &&
|
|
153
|
+
!isBaseUrlRequest(baseUrl, requestPath);
|
|
143
154
|
if (shouldForward) {
|
|
144
155
|
forwardWebSocketToGin(serverConfig.ginPort, req, socket, head);
|
|
145
156
|
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "Nuxt Gin Tools Pack Config",
|
|
3
|
-
"type": "object",
|
|
4
|
-
"additionalProperties": false,
|
|
5
|
-
"properties": {
|
|
6
|
-
"extraFiles": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"description": "额外需要打包的文件映射(key: 源文件路径,value: 打包后对应位置)",
|
|
9
|
-
"additionalProperties": {
|
|
10
|
-
"type": "string"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"extraFilesGlobs": {
|
|
14
|
-
"type": "array",
|
|
15
|
-
"description": "额外需要打包的文件 Glob(相对于项目根目录)",
|
|
16
|
-
"items": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"exclude": {
|
|
21
|
-
"type": "array",
|
|
22
|
-
"description": "排除文件/目录 Glob(相对于项目根目录)",
|
|
23
|
-
"items": {
|
|
24
|
-
"type": "string"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"zipName": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"description": "打包输出 zip 名称(相对于默认 zip 目录)"
|
|
30
|
-
},
|
|
31
|
-
"zipPath": {
|
|
32
|
-
"type": "string",
|
|
33
|
-
"description": "打包输出 zip 路径(相对于项目根目录或绝对路径)"
|
|
34
|
-
},
|
|
35
|
-
"serverPath": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"description": "服务器构建输出目录(相对于项目根目录或绝对路径)"
|
|
38
|
-
},
|
|
39
|
-
"beforePack": {
|
|
40
|
-
"description": "打包前钩子(仅在代码调用传入时生效)"
|
|
41
|
-
},
|
|
42
|
-
"afterPack": {
|
|
43
|
-
"description": "打包后钩子(仅在代码调用传入时生效)"
|
|
44
|
-
},
|
|
45
|
-
"cleanDist": {
|
|
46
|
-
"type": "boolean",
|
|
47
|
-
"description": "是否清理 dist"
|
|
48
|
-
},
|
|
49
|
-
"writeScripts": {
|
|
50
|
-
"type": "boolean",
|
|
51
|
-
"description": "是否写入启动脚本和 package.json"
|
|
52
|
-
},
|
|
53
|
-
"packageJson": {
|
|
54
|
-
"type": "object",
|
|
55
|
-
"description": "写入/覆盖 package.json 内容"
|
|
56
|
-
},
|
|
57
|
-
"overwrite": {
|
|
58
|
-
"type": "boolean",
|
|
59
|
-
"description": "复制时是否覆盖同名文件"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"title": "Nuxt Gin Tools Pack Config",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"extraFiles": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"description": "额外需要打包的文件映射(key: 源文件路径,value: 打包后对应位置)",
|
|
9
|
+
"additionalProperties": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"extraFilesGlobs": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"description": "额外需要打包的文件 Glob(相对于项目根目录)",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"exclude": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"description": "排除文件/目录 Glob(相对于项目根目录)",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"zipName": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "打包输出 zip 名称(相对于默认 zip 目录)"
|
|
30
|
+
},
|
|
31
|
+
"zipPath": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "打包输出 zip 路径(相对于项目根目录或绝对路径)"
|
|
34
|
+
},
|
|
35
|
+
"serverPath": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "服务器构建输出目录(相对于项目根目录或绝对路径)"
|
|
38
|
+
},
|
|
39
|
+
"beforePack": {
|
|
40
|
+
"description": "打包前钩子(仅在代码调用传入时生效)"
|
|
41
|
+
},
|
|
42
|
+
"afterPack": {
|
|
43
|
+
"description": "打包后钩子(仅在代码调用传入时生效)"
|
|
44
|
+
},
|
|
45
|
+
"cleanDist": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "是否清理 dist"
|
|
48
|
+
},
|
|
49
|
+
"writeScripts": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "是否写入启动脚本和 package.json"
|
|
52
|
+
},
|
|
53
|
+
"packageJson": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"description": "写入/覆盖 package.json 内容"
|
|
56
|
+
},
|
|
57
|
+
"overwrite": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"description": "复制时是否覆盖同名文件"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|