nuxt-gin-tools 0.2.23 → 0.3.1
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 +194 -72
- package/index.js +28 -28
- package/package.json +2 -2
- package/src/assets/go-gin-server.json +5 -0
- package/src/assets/pack-config.schema.json +62 -0
- package/src/assets/server-config.schema.json +35 -0
- package/src/cli/commands/build.d.ts +1 -0
- package/src/cli/commands/build.js +22 -0
- package/src/cli/commands/cleanup.d.ts +11 -0
- package/src/cli/commands/cleanup.js +115 -0
- package/src/cli/commands/develop.d.ts +26 -0
- package/src/cli/commands/develop.js +168 -0
- package/src/cli/commands/install.d.ts +6 -0
- package/src/cli/commands/install.js +59 -0
- package/src/cli/commands/update.d.ts +9 -0
- package/src/cli/commands/update.js +89 -0
- package/src/cli/options.d.ts +10 -0
- package/src/cli/options.js +66 -0
- package/src/cli/terminal-ui.d.ts +7 -0
- package/src/cli/terminal-ui.js +191 -0
- package/src/config/package-manager.d.ts +7 -0
- package/src/config/package-manager.js +39 -0
- package/src/nuxt-gin.d.ts +103 -0
- package/src/nuxt-gin.js +178 -0
- package/src/pack.d.ts +1 -1
- package/src/services/build-service.d.ts +7 -0
- package/src/services/build-service.js +35 -0
- package/src/services/go-dev-service.d.ts +8 -0
- package/src/services/go-dev-service.js +356 -0
- package/src/services/pack-service.d.ts +23 -0
- package/src/services/pack-service.js +372 -0
- package/src/system/ports.d.ts +7 -0
- package/src/system/ports.js +112 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Quick Jump:
|
|
|
21
21
|
- 🚀 One command to run Nuxt dev + Go watcher together
|
|
22
22
|
- 🔁 Automatic Go restart on file changes with `chokidar`
|
|
23
23
|
- 📦 Build-and-pack workflow for deployment artifacts
|
|
24
|
-
- 🧩 `
|
|
24
|
+
- 🧩 `nuxt-gin.config.ts` support with typed config helper
|
|
25
25
|
- 🛡️ Config validation with `warn` and `error` feedback
|
|
26
26
|
- 🔧 Useful CLI switches for partial workflows like `--skip-go`
|
|
27
27
|
- 🎨 Colorful command banners and clearer terminal feedback
|
|
@@ -62,6 +62,45 @@ nuxt-gin dev --skip-nuxt
|
|
|
62
62
|
nuxt-gin dev --no-cleanup
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
### 🧱 Source Layout
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
src/
|
|
69
|
+
├── assets/
|
|
70
|
+
│ ├── go-gin-server.json
|
|
71
|
+
│ ├── pack-config.schema.json
|
|
72
|
+
│ └── server-config.schema.json
|
|
73
|
+
├── cli/
|
|
74
|
+
│ ├── commands/
|
|
75
|
+
│ │ ├── build.ts
|
|
76
|
+
│ │ ├── cleanup.ts
|
|
77
|
+
│ │ ├── develop.ts
|
|
78
|
+
│ │ ├── install.ts
|
|
79
|
+
│ │ └── update.ts
|
|
80
|
+
│ ├── options.ts
|
|
81
|
+
│ └── terminal-ui.ts
|
|
82
|
+
├── config/
|
|
83
|
+
│ └── package-manager.ts
|
|
84
|
+
├── services/
|
|
85
|
+
│ ├── build-service.ts
|
|
86
|
+
│ ├── go-dev-service.ts
|
|
87
|
+
│ └── pack-service.ts
|
|
88
|
+
├── system/
|
|
89
|
+
│ └── ports.ts
|
|
90
|
+
├── nuxt-config.ts
|
|
91
|
+
├── nuxt-gin.ts
|
|
92
|
+
└── pack.ts
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Responsibility split:
|
|
96
|
+
|
|
97
|
+
- `src/cli`: command entrypoints, option parsing, terminal output
|
|
98
|
+
- `src/config`: CLI configuration helpers
|
|
99
|
+
- `src/services`: build, pack, and Go watcher implementation
|
|
100
|
+
- `src/system`: low-level system helpers such as port cleanup
|
|
101
|
+
- `src/assets`: JSON resources and schemas shipped in the package
|
|
102
|
+
- `src/nuxt-config.ts`, `src/nuxt-gin.ts`, `src/pack.ts`: public helper modules for consumers
|
|
103
|
+
|
|
65
104
|
### 🗂️ Commands
|
|
66
105
|
|
|
67
106
|
#### `nuxt-gin dev`
|
|
@@ -143,40 +182,40 @@ nuxt-gin update --package-manager pnpm --latest false
|
|
|
143
182
|
|
|
144
183
|
Also prints a styled command banner before execution.
|
|
145
184
|
|
|
146
|
-
### 🧩 `
|
|
185
|
+
### 🧩 `nuxt-gin.config.ts`
|
|
147
186
|
|
|
148
|
-
`nuxt-gin
|
|
187
|
+
`nuxt-gin` commands can auto-load project config from the root with this priority:
|
|
149
188
|
|
|
150
|
-
1. `
|
|
151
|
-
2. `
|
|
152
|
-
3. `
|
|
153
|
-
4. `
|
|
154
|
-
5. `
|
|
189
|
+
1. `nuxt-gin.config.ts`
|
|
190
|
+
2. `nuxt-gin.config.js`
|
|
191
|
+
3. `nuxt-gin.config.cjs`
|
|
192
|
+
4. `nuxt-gin.config.mjs`
|
|
193
|
+
5. `nuxt-gin.config.json`
|
|
155
194
|
|
|
156
195
|
If multiple config files exist, the CLI prints a `warn` and uses the first one by priority.
|
|
157
196
|
|
|
158
197
|
Recommended TypeScript form:
|
|
159
198
|
|
|
160
199
|
```ts
|
|
161
|
-
import
|
|
200
|
+
import createNuxtGinConfig from 'nuxt-gin-tools/src/nuxt-gin';
|
|
162
201
|
|
|
163
|
-
export default
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
202
|
+
export default createNuxtGinConfig({
|
|
203
|
+
dev: {
|
|
204
|
+
killPortBeforeDevelop: true,
|
|
205
|
+
},
|
|
206
|
+
goWatch: {
|
|
207
|
+
include: {
|
|
208
|
+
ext: ['go', 'tpl', 'html'],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
pack: {
|
|
212
|
+
zipName: 'server.7z',
|
|
213
|
+
extraFilesGlobs: ['prisma/**'],
|
|
168
214
|
},
|
|
169
215
|
});
|
|
170
216
|
```
|
|
171
217
|
|
|
172
|
-
Legacy
|
|
173
|
-
|
|
174
|
-
```json
|
|
175
|
-
{
|
|
176
|
-
"zipName": "server.7z",
|
|
177
|
-
"extraFilesGlobs": ["prisma/**"]
|
|
178
|
-
}
|
|
179
|
-
```
|
|
218
|
+
Legacy `pack.config.*` is still supported as a fallback for `build`, but `nuxt-gin.config.*` is now the primary entry.
|
|
180
219
|
|
|
181
220
|
Validation behavior:
|
|
182
221
|
|
|
@@ -184,36 +223,57 @@ Validation behavior:
|
|
|
184
223
|
- ⚠️ ambiguous but survivable cases produce a `warn`
|
|
185
224
|
- 📝 example: if both `zipPath` and `zipName` are present, `zipPath` wins and a warning is shown
|
|
186
225
|
|
|
187
|
-
### 🧱 `
|
|
226
|
+
### 🧱 `nuxt-gin.config.ts` Helper
|
|
188
227
|
|
|
189
|
-
Use the helper from [`src/
|
|
228
|
+
Use the helper from [`src/nuxt-gin.ts`](./src/nuxt-gin.ts):
|
|
190
229
|
|
|
191
230
|
```ts
|
|
192
|
-
import
|
|
231
|
+
import createNuxtGinConfig from 'nuxt-gin-tools/src/nuxt-gin';
|
|
193
232
|
|
|
194
|
-
export default
|
|
195
|
-
|
|
196
|
-
|
|
233
|
+
export default createNuxtGinConfig({
|
|
234
|
+
dev: {
|
|
235
|
+
killPortBeforeDevelop: true,
|
|
236
|
+
},
|
|
237
|
+
goWatch: {
|
|
238
|
+
exclude: {
|
|
239
|
+
dir: ['vendor', 'testdata'],
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
pack: {
|
|
243
|
+
serverPath: '.build/production/server',
|
|
244
|
+
zipName: 'release.7z',
|
|
245
|
+
},
|
|
197
246
|
});
|
|
198
247
|
```
|
|
199
248
|
|
|
200
249
|
It provides:
|
|
201
250
|
|
|
202
|
-
- `
|
|
203
|
-
- `
|
|
204
|
-
- default export as `
|
|
251
|
+
- `NuxtGinConfig` type
|
|
252
|
+
- `createNuxtGinConfig(config)` helper
|
|
253
|
+
- default export as `createNuxtGinConfig`
|
|
205
254
|
|
|
206
255
|
### ⚙️ Runtime Config
|
|
207
256
|
|
|
257
|
+
#### `nuxt-gin.config.ts`
|
|
258
|
+
|
|
259
|
+
`dev`, `install`, `cleanup`, `update`, and `build` can all read defaults from this file:
|
|
260
|
+
|
|
261
|
+
- `dev`: development command defaults
|
|
262
|
+
- `goWatch`: built-in Go watcher defaults
|
|
263
|
+
- `install`: bootstrap command defaults
|
|
264
|
+
- `cleanup`: cleanup command defaults
|
|
265
|
+
- `update`: dependency update defaults
|
|
266
|
+
- `pack`: build-and-pack defaults
|
|
267
|
+
|
|
208
268
|
#### `server.config.json`
|
|
209
269
|
|
|
210
|
-
`
|
|
270
|
+
`server.config.json` is still kept for Go runtime and packaged output:
|
|
211
271
|
|
|
212
272
|
- `ginPort`: Gin server port
|
|
213
273
|
- `nuxtPort`: Nuxt dev port
|
|
214
274
|
- `baseUrl`: Nuxt base URL
|
|
215
|
-
|
|
216
|
-
- `
|
|
275
|
+
|
|
276
|
+
`nuxt-gin build` requires this file to exist in the project root.
|
|
217
277
|
|
|
218
278
|
#### Frontend Runtime Exposure
|
|
219
279
|
|
|
@@ -232,7 +292,8 @@ const isDevelopment = config.public.isDevelopment;
|
|
|
232
292
|
|
|
233
293
|
#### `.go-watch.json`
|
|
234
294
|
|
|
235
|
-
Go watcher
|
|
295
|
+
Go watcher defaults are built into `src/services/go-dev-service.ts`.
|
|
296
|
+
You can set project-level defaults in `nuxt-gin.config.ts` with `goWatch`, and then optionally override them with `.go-watch.json`:
|
|
236
297
|
|
|
237
298
|
```json
|
|
238
299
|
{
|
|
@@ -257,7 +318,7 @@ Go watcher rules come from `.go-watch.json`:
|
|
|
257
318
|
}
|
|
258
319
|
```
|
|
259
320
|
|
|
260
|
-
You can also point to a custom watcher config:
|
|
321
|
+
You can also point to a custom watcher config file:
|
|
261
322
|
|
|
262
323
|
```bash
|
|
263
324
|
NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
|
|
@@ -288,7 +349,7 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
|
|
|
288
349
|
- 🚀 一条命令同时启动 Nuxt 与 Go 开发环境
|
|
289
350
|
- 🔁 基于 `chokidar` 的 Go 文件监听与自动重启
|
|
290
351
|
- 📦 内置构建与打包流程,适合产物发布
|
|
291
|
-
- 🧩 支持 `
|
|
352
|
+
- 🧩 支持 `nuxt-gin.config.ts`,并提供类型化 helper
|
|
292
353
|
- 🛡️ 对打包配置做校验,区分 `warn` 和 `error`
|
|
293
354
|
- 🔧 支持 `--skip-go` 等局部开发参数
|
|
294
355
|
- 🎨 提供更醒目的彩色命令行 banner 与输出提示
|
|
@@ -329,6 +390,45 @@ nuxt-gin dev --skip-nuxt
|
|
|
329
390
|
nuxt-gin dev --no-cleanup
|
|
330
391
|
```
|
|
331
392
|
|
|
393
|
+
### 🧱 源码结构
|
|
394
|
+
|
|
395
|
+
```text
|
|
396
|
+
src/
|
|
397
|
+
├── assets/
|
|
398
|
+
│ ├── go-gin-server.json
|
|
399
|
+
│ ├── pack-config.schema.json
|
|
400
|
+
│ └── server-config.schema.json
|
|
401
|
+
├── cli/
|
|
402
|
+
│ ├── commands/
|
|
403
|
+
│ │ ├── build.ts
|
|
404
|
+
│ │ ├── cleanup.ts
|
|
405
|
+
│ │ ├── develop.ts
|
|
406
|
+
│ │ ├── install.ts
|
|
407
|
+
│ │ └── update.ts
|
|
408
|
+
│ ├── options.ts
|
|
409
|
+
│ └── terminal-ui.ts
|
|
410
|
+
├── config/
|
|
411
|
+
│ └── package-manager.ts
|
|
412
|
+
├── services/
|
|
413
|
+
│ ├── build-service.ts
|
|
414
|
+
│ ├── go-dev-service.ts
|
|
415
|
+
│ └── pack-service.ts
|
|
416
|
+
├── system/
|
|
417
|
+
│ └── ports.ts
|
|
418
|
+
├── nuxt-config.ts
|
|
419
|
+
├── nuxt-gin.ts
|
|
420
|
+
└── pack.ts
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
职责划分:
|
|
424
|
+
|
|
425
|
+
- `src/cli`:命令入口、参数解析、终端输出
|
|
426
|
+
- `src/config`:CLI 配置解析
|
|
427
|
+
- `src/services`:构建、打包、Go watcher 执行逻辑
|
|
428
|
+
- `src/system`:端口清理等底层系统辅助能力
|
|
429
|
+
- `src/assets`:随 npm 包一起分发的 JSON 资源与 schema
|
|
430
|
+
- `src/nuxt-config.ts`、`src/nuxt-gin.ts`、`src/pack.ts`:给使用方直接 import 的 helper 模块
|
|
431
|
+
|
|
332
432
|
### 🗂️ 命令说明
|
|
333
433
|
|
|
334
434
|
#### `nuxt-gin dev`
|
|
@@ -410,40 +510,40 @@ nuxt-gin update --package-manager pnpm --latest false
|
|
|
410
510
|
|
|
411
511
|
执行前也会输出一段样式化 banner。
|
|
412
512
|
|
|
413
|
-
### 🧩 `
|
|
513
|
+
### 🧩 `nuxt-gin.config.ts`
|
|
414
514
|
|
|
415
|
-
`nuxt-gin
|
|
515
|
+
`nuxt-gin` 会自动读取项目根目录中的统一配置,优先级如下:
|
|
416
516
|
|
|
417
|
-
1. `
|
|
418
|
-
2. `
|
|
419
|
-
3. `
|
|
420
|
-
4. `
|
|
421
|
-
5. `
|
|
517
|
+
1. `nuxt-gin.config.ts`
|
|
518
|
+
2. `nuxt-gin.config.js`
|
|
519
|
+
3. `nuxt-gin.config.cjs`
|
|
520
|
+
4. `nuxt-gin.config.mjs`
|
|
521
|
+
5. `nuxt-gin.config.json`
|
|
422
522
|
|
|
423
523
|
如果同时存在多个配置文件,CLI 会输出 `warn`,并按优先级选择第一个。
|
|
424
524
|
|
|
425
525
|
推荐使用 TypeScript 写法:
|
|
426
526
|
|
|
427
527
|
```ts
|
|
428
|
-
import
|
|
528
|
+
import createNuxtGinConfig from 'nuxt-gin-tools/src/nuxt-gin';
|
|
429
529
|
|
|
430
|
-
export default
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
530
|
+
export default createNuxtGinConfig({
|
|
531
|
+
dev: {
|
|
532
|
+
killPortBeforeDevelop: true,
|
|
533
|
+
},
|
|
534
|
+
goWatch: {
|
|
535
|
+
include: {
|
|
536
|
+
ext: ['go', 'tpl', 'html'],
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
pack: {
|
|
540
|
+
zipName: 'server.7z',
|
|
541
|
+
extraFilesGlobs: ['prisma/**'],
|
|
435
542
|
},
|
|
436
543
|
});
|
|
437
544
|
```
|
|
438
545
|
|
|
439
|
-
旧的
|
|
440
|
-
|
|
441
|
-
```json
|
|
442
|
-
{
|
|
443
|
-
"zipName": "server.7z",
|
|
444
|
-
"extraFilesGlobs": ["prisma/**"]
|
|
445
|
-
}
|
|
446
|
-
```
|
|
546
|
+
旧的 `pack.config.*` 仍可作为 `build` 的兼容兜底,但 `nuxt-gin.config.*` 已经成为主入口。
|
|
447
547
|
|
|
448
548
|
校验规则:
|
|
449
549
|
|
|
@@ -451,36 +551,57 @@ export default createPackConfig({
|
|
|
451
551
|
- ⚠️ 可继续执行但存在歧义的情况会输出 `warn`
|
|
452
552
|
- 📝 例如同时设置 `zipPath` 和 `zipName` 时,会提示 `zipPath` 优先生效
|
|
453
553
|
|
|
454
|
-
### 🧱 `
|
|
554
|
+
### 🧱 `nuxt-gin.config.ts` Helper
|
|
455
555
|
|
|
456
|
-
可通过 [`src/
|
|
556
|
+
可通过 [`src/nuxt-gin.ts`](./src/nuxt-gin.ts) 使用 helper:
|
|
457
557
|
|
|
458
558
|
```ts
|
|
459
|
-
import
|
|
559
|
+
import createNuxtGinConfig from 'nuxt-gin-tools/src/nuxt-gin';
|
|
460
560
|
|
|
461
|
-
export default
|
|
462
|
-
|
|
463
|
-
|
|
561
|
+
export default createNuxtGinConfig({
|
|
562
|
+
dev: {
|
|
563
|
+
killPortBeforeDevelop: true,
|
|
564
|
+
},
|
|
565
|
+
goWatch: {
|
|
566
|
+
exclude: {
|
|
567
|
+
dir: ['vendor', 'testdata'],
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
pack: {
|
|
571
|
+
serverPath: '.build/production/server',
|
|
572
|
+
zipName: 'release.7z',
|
|
573
|
+
},
|
|
464
574
|
});
|
|
465
575
|
```
|
|
466
576
|
|
|
467
577
|
它提供:
|
|
468
578
|
|
|
469
|
-
- `
|
|
470
|
-
- `
|
|
471
|
-
- 默认导出即 `
|
|
579
|
+
- `NuxtGinConfig` 类型
|
|
580
|
+
- `createNuxtGinConfig(config)` 函数
|
|
581
|
+
- 默认导出即 `createNuxtGinConfig`
|
|
472
582
|
|
|
473
583
|
### ⚙️ 运行时配置
|
|
474
584
|
|
|
585
|
+
#### `nuxt-gin.config.ts`
|
|
586
|
+
|
|
587
|
+
`dev`、`install`、`cleanup`、`update`、`build` 都可以从这个文件读取默认值:
|
|
588
|
+
|
|
589
|
+
- `dev`:开发命令默认行为
|
|
590
|
+
- `goWatch`:Go watcher 的默认规则
|
|
591
|
+
- `install`:初始化命令默认行为
|
|
592
|
+
- `cleanup`:清理命令默认行为
|
|
593
|
+
- `update`:包管理器与更新策略默认值
|
|
594
|
+
- `pack`:打包默认值
|
|
595
|
+
|
|
475
596
|
#### `server.config.json`
|
|
476
597
|
|
|
477
|
-
`
|
|
598
|
+
`server.config.json` 仍然保留,用于 Go 运行时与打包产物:
|
|
478
599
|
|
|
479
600
|
- `ginPort`:Gin 服务端口
|
|
480
601
|
- `nuxtPort`:Nuxt 开发端口
|
|
481
602
|
- `baseUrl`:Nuxt 的 base URL
|
|
482
|
-
|
|
483
|
-
- `
|
|
603
|
+
|
|
604
|
+
`nuxt-gin build` 要求项目根目录中存在这个文件。
|
|
484
605
|
|
|
485
606
|
#### 前端运行时暴露
|
|
486
607
|
|
|
@@ -499,7 +620,8 @@ const isDevelopment = config.public.isDevelopment;
|
|
|
499
620
|
|
|
500
621
|
#### `.go-watch.json`
|
|
501
622
|
|
|
502
|
-
Go
|
|
623
|
+
Go watcher 的默认规则已经内置在 `src/services/go-dev-service.ts`。
|
|
624
|
+
你可以先在 `nuxt-gin.config.ts` 里通过 `goWatch` 设置项目级默认值,再用项目根目录的 `.go-watch.json` 做覆盖:
|
|
503
625
|
|
|
504
626
|
```json
|
|
505
627
|
{
|
|
@@ -524,7 +646,7 @@ Go 监听规则来自 `.go-watch.json`:
|
|
|
524
646
|
}
|
|
525
647
|
```
|
|
526
648
|
|
|
527
|
-
|
|
649
|
+
也支持通过环境变量指定自定义配置文件:
|
|
528
650
|
|
|
529
651
|
```bash
|
|
530
652
|
NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
|
package/index.js
CHANGED
|
@@ -48,18 +48,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
// index.ts - 入口文件,用于处理命令行参数并调用相应的功能模块
|
|
50
50
|
// 导入构建和打包功能
|
|
51
|
-
const
|
|
51
|
+
const build_1 = __importDefault(require("./src/cli/commands/build"));
|
|
52
52
|
// 导入开发模式功能
|
|
53
|
-
const develop_1 = __importStar(require("./commands/develop"));
|
|
53
|
+
const develop_1 = __importStar(require("./src/cli/commands/develop"));
|
|
54
54
|
// 导入安装后处理功能
|
|
55
|
-
const
|
|
55
|
+
const install_1 = __importDefault(require("./src/cli/commands/install"));
|
|
56
56
|
// 导入清理功能
|
|
57
|
-
const cleanup_1 = __importDefault(require("./commands/cleanup"));
|
|
57
|
+
const cleanup_1 = __importDefault(require("./src/cli/commands/cleanup"));
|
|
58
58
|
// 导入更新功能
|
|
59
|
-
const update_1 = __importDefault(require("./commands/update"));
|
|
60
|
-
const
|
|
61
|
-
const package_manager_1 = require("./src/package-manager");
|
|
62
|
-
const terminal_ui_1 = require("./src/terminal-ui");
|
|
59
|
+
const update_1 = __importDefault(require("./src/cli/commands/update"));
|
|
60
|
+
const options_1 = require("./src/cli/options");
|
|
61
|
+
const package_manager_1 = require("./src/config/package-manager");
|
|
62
|
+
const terminal_ui_1 = require("./src/cli/terminal-ui");
|
|
63
63
|
// 获取命令行参数(去除前两个默认参数)
|
|
64
64
|
const args = process.argv.slice(2);
|
|
65
65
|
// 检查是否提供了命令
|
|
@@ -70,8 +70,8 @@ if (args.length === 0) {
|
|
|
70
70
|
function main() {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
72
|
const command = args[0];
|
|
73
|
-
const options = (0,
|
|
74
|
-
const rawPackageManager = (0,
|
|
73
|
+
const options = (0, options_1.parseCLIOptions)(args.slice(1));
|
|
74
|
+
const rawPackageManager = (0, options_1.getOption)(options, "package-manager");
|
|
75
75
|
const packageManagerCandidate = rawPackageManager !== null && rawPackageManager !== void 0 ? rawPackageManager : "auto";
|
|
76
76
|
if (!(0, package_manager_1.isPackageManagerSelection)(packageManagerCandidate)) {
|
|
77
77
|
throw new Error(`Invalid value for --package-manager: ${packageManagerCandidate}. Expected one of: auto, bun, pnpm, npm`);
|
|
@@ -80,50 +80,50 @@ function main() {
|
|
|
80
80
|
switch (command) {
|
|
81
81
|
case "dev":
|
|
82
82
|
yield (0, develop_1.default)({
|
|
83
|
-
noCleanup: (0,
|
|
84
|
-
skipGo: (0,
|
|
85
|
-
skipNuxt: (0,
|
|
83
|
+
noCleanup: (0, options_1.hasFlag)(options, "no-cleanup"),
|
|
84
|
+
skipGo: (0, options_1.hasFlag)(options, "skip-go"),
|
|
85
|
+
skipNuxt: (0, options_1.hasFlag)(options, "skip-nuxt"),
|
|
86
86
|
});
|
|
87
87
|
break;
|
|
88
88
|
case "dev:nuxt":
|
|
89
89
|
yield (0, develop_1.developNuxt)({
|
|
90
|
-
noCleanup: (0,
|
|
90
|
+
noCleanup: (0, options_1.hasFlag)(options, "no-cleanup"),
|
|
91
91
|
});
|
|
92
92
|
break;
|
|
93
93
|
case "dev:go":
|
|
94
94
|
yield (0, develop_1.developGo)({
|
|
95
|
-
noCleanup: (0,
|
|
95
|
+
noCleanup: (0, options_1.hasFlag)(options, "no-cleanup"),
|
|
96
96
|
});
|
|
97
97
|
break;
|
|
98
98
|
case "build":
|
|
99
|
-
yield (0,
|
|
100
|
-
binaryName: (0,
|
|
101
|
-
skipGo: (0,
|
|
102
|
-
skipNuxt: (0,
|
|
103
|
-
skipBuild: (0,
|
|
104
|
-
skipZip: (0,
|
|
99
|
+
yield (0, build_1.default)({
|
|
100
|
+
binaryName: (0, options_1.getOption)(options, "binary-name"),
|
|
101
|
+
skipGo: (0, options_1.hasFlag)(options, "skip-go"),
|
|
102
|
+
skipNuxt: (0, options_1.hasFlag)(options, "skip-nuxt"),
|
|
103
|
+
skipBuild: (0, options_1.hasFlag)(options, "skip-build"),
|
|
104
|
+
skipZip: (0, options_1.hasFlag)(options, "skip-zip"),
|
|
105
105
|
});
|
|
106
106
|
break;
|
|
107
107
|
case "install":
|
|
108
108
|
// 执行安装后的初始化操作
|
|
109
|
-
yield (0,
|
|
110
|
-
skipGo: (0,
|
|
111
|
-
skipNuxt: (0,
|
|
109
|
+
yield (0, install_1.default)({
|
|
110
|
+
skipGo: (0, options_1.hasFlag)(options, "skip-go"),
|
|
111
|
+
skipNuxt: (0, options_1.hasFlag)(options, "skip-nuxt"),
|
|
112
112
|
});
|
|
113
113
|
break;
|
|
114
114
|
case "cleanup":
|
|
115
115
|
// 执行清理操作
|
|
116
116
|
yield (0, cleanup_1.default)({
|
|
117
|
-
dryRun: (0,
|
|
117
|
+
dryRun: (0, options_1.hasFlag)(options, "dry-run"),
|
|
118
118
|
});
|
|
119
119
|
break;
|
|
120
120
|
case "update":
|
|
121
121
|
// 更新依赖
|
|
122
122
|
yield (0, update_1.default)({
|
|
123
|
-
latest: (0,
|
|
123
|
+
latest: (0, options_1.getOptionalBooleanOption)(options, "latest"),
|
|
124
124
|
packageManager: packageManagerOption,
|
|
125
|
-
skipGo: (0,
|
|
126
|
-
skipNode: (0,
|
|
125
|
+
skipGo: (0, options_1.hasFlag)(options, "skip-go"),
|
|
126
|
+
skipNode: (0, options_1.hasFlag)(options, "skip-node"),
|
|
127
127
|
});
|
|
128
128
|
break;
|
|
129
129
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-gin-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "This project is used as a dependency for [nuxt-gin-starter](https://github.com/RapboyGao/nuxt-gin-starter.git)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nuxt-gin": "index.js"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "ts-node build.ts",
|
|
12
|
+
"build": "ts-node scripts/build-package.ts",
|
|
13
13
|
"publish": "npm publish --access public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "API configuration schema",
|
|
3
|
+
"description": "API configuration schema. For more info see http://json-schema.org/ and https://frontaid.io/blog/json-schema-vscode/",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"ginPort": {
|
|
7
|
+
"title": "The port for Gin / Gin框架端口",
|
|
8
|
+
"type": "integer"
|
|
9
|
+
},
|
|
10
|
+
"nuxtPort": {
|
|
11
|
+
"title": "The port for Nuxt / Nuxt框架devServer端口",
|
|
12
|
+
"type": "integer"
|
|
13
|
+
},
|
|
14
|
+
"baseUrl": {
|
|
15
|
+
"title": "The base url for nuxt. / Nuxt的BaseUrl",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"pattern": "^\\/\\w.+"
|
|
18
|
+
},
|
|
19
|
+
"killPortBeforeDevelop": {
|
|
20
|
+
"title": "Kill port before develop / 开发前释放端口",
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"default": true
|
|
23
|
+
},
|
|
24
|
+
"cleanupBeforeDevelop": {
|
|
25
|
+
"title": "Cleanup before develop / 开发前清理",
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": [
|
|
31
|
+
"ginPort",
|
|
32
|
+
"nuxtPort",
|
|
33
|
+
"baseUrl"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BUILD_EXECUTABLE, FILES_TO_COPY, LEGACY_PACK_CONFIG_CJS_PATH, LEGACY_PACK_CONFIG_JS_PATH, LEGACY_PACK_CONFIG_MJS_PATH, LEGACY_PACK_CONFIG_PATH, LEGACY_PACK_CONFIG_TS_PATH, ORIGINAL_DIST_PATH, PACKAGE_JSON_CONTENT, SERVER_EXECUTABLE, SERVER_PATH, ZIP_PATH, buildAndPack, builtPath, default, } from "../../services/pack-service";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = exports.builtPath = exports.buildAndPack = exports.ZIP_PATH = exports.SERVER_PATH = exports.SERVER_EXECUTABLE = exports.PACKAGE_JSON_CONTENT = exports.ORIGINAL_DIST_PATH = exports.LEGACY_PACK_CONFIG_TS_PATH = exports.LEGACY_PACK_CONFIG_PATH = exports.LEGACY_PACK_CONFIG_MJS_PATH = exports.LEGACY_PACK_CONFIG_JS_PATH = exports.LEGACY_PACK_CONFIG_CJS_PATH = exports.FILES_TO_COPY = exports.BUILD_EXECUTABLE = void 0;
|
|
7
|
+
var pack_service_1 = require("../../services/pack-service");
|
|
8
|
+
Object.defineProperty(exports, "BUILD_EXECUTABLE", { enumerable: true, get: function () { return pack_service_1.BUILD_EXECUTABLE; } });
|
|
9
|
+
Object.defineProperty(exports, "FILES_TO_COPY", { enumerable: true, get: function () { return pack_service_1.FILES_TO_COPY; } });
|
|
10
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_CJS_PATH", { enumerable: true, get: function () { return pack_service_1.LEGACY_PACK_CONFIG_CJS_PATH; } });
|
|
11
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_JS_PATH", { enumerable: true, get: function () { return pack_service_1.LEGACY_PACK_CONFIG_JS_PATH; } });
|
|
12
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_MJS_PATH", { enumerable: true, get: function () { return pack_service_1.LEGACY_PACK_CONFIG_MJS_PATH; } });
|
|
13
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_PATH", { enumerable: true, get: function () { return pack_service_1.LEGACY_PACK_CONFIG_PATH; } });
|
|
14
|
+
Object.defineProperty(exports, "LEGACY_PACK_CONFIG_TS_PATH", { enumerable: true, get: function () { return pack_service_1.LEGACY_PACK_CONFIG_TS_PATH; } });
|
|
15
|
+
Object.defineProperty(exports, "ORIGINAL_DIST_PATH", { enumerable: true, get: function () { return pack_service_1.ORIGINAL_DIST_PATH; } });
|
|
16
|
+
Object.defineProperty(exports, "PACKAGE_JSON_CONTENT", { enumerable: true, get: function () { return pack_service_1.PACKAGE_JSON_CONTENT; } });
|
|
17
|
+
Object.defineProperty(exports, "SERVER_EXECUTABLE", { enumerable: true, get: function () { return pack_service_1.SERVER_EXECUTABLE; } });
|
|
18
|
+
Object.defineProperty(exports, "SERVER_PATH", { enumerable: true, get: function () { return pack_service_1.SERVER_PATH; } });
|
|
19
|
+
Object.defineProperty(exports, "ZIP_PATH", { enumerable: true, get: function () { return pack_service_1.ZIP_PATH; } });
|
|
20
|
+
Object.defineProperty(exports, "buildAndPack", { enumerable: true, get: function () { return pack_service_1.buildAndPack; } });
|
|
21
|
+
Object.defineProperty(exports, "builtPath", { enumerable: true, get: function () { return pack_service_1.builtPath; } });
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(pack_service_1).default; } });
|