nuxt-gin-tools 0.2.22 → 0.2.23

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 CHANGED
@@ -24,6 +24,8 @@ Quick Jump:
24
24
  - 🧩 `pack.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
+ - 🎨 Colorful command banners and clearer terminal feedback
28
+ - 📋 Fancy end-of-command summaries that show what just changed
27
29
 
28
30
  ### 📦 Install
29
31
 
@@ -31,6 +33,12 @@ Quick Jump:
31
33
  pnpm add -D nuxt-gin-tools
32
34
  ```
33
35
 
36
+ or
37
+
38
+ ```bash
39
+ bun add -d nuxt-gin-tools
40
+ ```
41
+
34
42
  ### ⚡ Quick Start
35
43
 
36
44
  ```bash
@@ -62,6 +70,7 @@ Runs the local development stack:
62
70
 
63
71
  - Nuxt: `npx nuxt dev --port=<nuxtPort> --host`
64
72
  - Go: watches files and restarts `go run main.go`
73
+ - prints a styled command banner before startup
65
74
 
66
75
  Flags:
67
76
 
@@ -75,34 +84,65 @@ Bootstraps the project:
75
84
 
76
85
  - always runs `npx nuxt prepare`
77
86
  - if Go is available, also runs `go mod download && go mod tidy`
87
+ - prints a styled command banner before execution
88
+
89
+ Options:
90
+
91
+ - `--skip-go`: skip Go dependency bootstrap
92
+ - `--skip-nuxt`: skip Nuxt prepare
78
93
 
79
94
  #### `nuxt-gin build`
80
95
 
81
96
  Runs the build-and-pack flow.
82
97
 
98
+ Terminal output includes:
99
+
100
+ - a styled command banner at startup
101
+ - the final `.7z` archive path after packing
102
+ - the bundle directory path used to assemble the release
103
+
83
104
  Flags:
84
105
 
85
106
  - `--skip-go`: skip Go build
86
107
  - `--skip-nuxt`: skip Nuxt static build
108
+ - `--skip-build`: skip the build step and only assemble/package existing artifacts
109
+ - `--skip-zip`: skip `.7z` creation and only prepare the bundle directory
87
110
  - `--binary-name <name>`: override the Go binary name under `.build/.server`
88
111
 
89
112
  #### `nuxt-gin cleanup`
90
113
 
91
114
  Removes generated temp files and build output.
92
115
 
116
+ Also prints a styled command banner before cleanup starts.
117
+
118
+ Options:
119
+
120
+ - `--dry-run`: print what would be removed without deleting anything
121
+
93
122
  #### `nuxt-gin update`
94
123
 
95
124
  Updates project dependencies with a conservative default strategy:
96
125
 
97
- - Node: `pnpm update`
126
+ - Node: package manager is controlled by `--package-manager`, default `auto`
98
127
  - Go: `go get -u=patch ./... && go mod tidy`
99
128
 
100
- Flags:
129
+ Options:
101
130
 
102
- - `--latest`: switch to a more aggressive upgrade strategy
131
+ - `--package-manager <auto|bun|pnpm|npm>`: package manager selection, default `auto`
132
+ - `--latest <true|false>`: whether to use the aggressive update strategy, default `false`
103
133
  - `--skip-go`: skip Go dependency updates
104
134
  - `--skip-node`: skip Node dependency updates
105
135
 
136
+ Examples:
137
+
138
+ ```bash
139
+ nuxt-gin update
140
+ nuxt-gin update --package-manager bun --latest true
141
+ nuxt-gin update --package-manager pnpm --latest false
142
+ ```
143
+
144
+ Also prints a styled command banner before execution.
145
+
106
146
  ### 🧩 `pack.config.ts` / `pack.config.json`
107
147
 
108
148
  `nuxt-gin build` can auto-load pack config from the project root with this priority:
@@ -226,7 +266,7 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
226
266
  ### 🖥️ Environment
227
267
 
228
268
  - Node.js
229
- - pnpm
269
+ - pnpm or bun
230
270
  - Go, if you need the Gin side to run
231
271
  - no extra generator dependency is required for the current command set
232
272
 
@@ -235,6 +275,9 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
235
275
  - 💨 Go hot reload no longer depends on Air
236
276
  - 👀 The current watcher model is `chokidar` + restart `go run main.go`
237
277
  - 🪟 Packaging uses platform-aware executable naming: Windows defaults to `.exe`, Linux/macOS defaults to no extension
278
+ - 🌈 Main commands print a consistent banner and clearer success/info output in the terminal
279
+ - 📋 Commands also print a styled summary of the actions they performed; long-running dev commands print the startup summary before entering watch mode
280
+ - 📦 Both `pnpm` and `bun` are supported, but one working tree should stick to one package manager at a time
238
281
 
239
282
  ---
240
283
 
@@ -248,6 +291,8 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
248
291
  - 🧩 支持 `pack.config.ts`,并提供类型化 helper
249
292
  - 🛡️ 对打包配置做校验,区分 `warn` 和 `error`
250
293
  - 🔧 支持 `--skip-go` 等局部开发参数
294
+ - 🎨 提供更醒目的彩色命令行 banner 与输出提示
295
+ - 📋 命令结束时会打印更清晰的结果摘要
251
296
 
252
297
  ### 📦 安装
253
298
 
@@ -255,6 +300,12 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
255
300
  pnpm add -D nuxt-gin-tools
256
301
  ```
257
302
 
303
+
304
+
305
+ ```bash
306
+ bun add -d nuxt-gin-tools
307
+ ```
308
+
258
309
  ### ⚡ 快速开始
259
310
 
260
311
  ```bash
@@ -286,6 +337,7 @@ nuxt-gin dev --no-cleanup
286
337
 
287
338
  - Nuxt:`npx nuxt dev --port=<nuxtPort> --host`
288
339
  - Go:监听文件变化并重启 `go run main.go`
340
+ - 启动前会输出一段样式化 banner
289
341
 
290
342
  参数:
291
343
 
@@ -299,34 +351,65 @@ nuxt-gin dev --no-cleanup
299
351
 
300
352
  - 总是执行 `npx nuxt prepare`
301
353
  - 检测到 Go 后,额外执行 `go mod download && go mod tidy`
354
+ - 执行前会输出一段样式化 banner
355
+
356
+ 参数:
357
+
358
+ - `--skip-go`:跳过 Go 依赖初始化
359
+ - `--skip-nuxt`:跳过 Nuxt prepare
302
360
 
303
361
  #### `nuxt-gin build`
304
362
 
305
363
  执行构建与打包流程。
306
364
 
365
+ 命令行输出会额外包含:
366
+
367
+ - 启动时的样式化 banner
368
+ - 打包完成后的 `.7z` 文件绝对路径
369
+ - 组装发布产物时使用的 bundle 目录路径
370
+
307
371
  参数:
308
372
 
309
373
  - `--skip-go`:跳过 Go 构建
310
374
  - `--skip-nuxt`:跳过 Nuxt 静态构建
375
+ - `--skip-build`:跳过构建阶段,仅组装或打包现有产物
376
+ - `--skip-zip`:跳过 `.7z` 生成,仅准备 bundle 目录
311
377
  - `--binary-name <name>`:覆盖 `.build/.server` 下的 Go 二进制名称
312
378
 
313
379
  #### `nuxt-gin cleanup`
314
380
 
315
381
  清理临时文件与构建产物。
316
382
 
383
+ 执行前也会输出一段样式化 banner。
384
+
385
+ 参数:
386
+
387
+ - `--dry-run`:只打印将要删除的内容,不真正删除
388
+
317
389
  #### `nuxt-gin update`
318
390
 
319
391
  按偏保守的默认策略更新依赖:
320
392
 
321
- - Node:`pnpm update`
393
+ - Node:通过 `--package-manager` 控制,默认值为 `auto`
322
394
  - Go:`go get -u=patch ./... && go mod tidy`
323
395
 
324
396
  参数:
325
397
 
326
- - `--latest`:切换成更激进的升级策略
398
+ - `--package-manager <auto|bun|pnpm|npm>`:指定包管理器,默认 `auto`
399
+ - `--latest <true|false>`:是否使用更激进的升级策略,默认 `false`
327
400
  - `--skip-go`:跳过 Go 依赖更新
328
401
  - `--skip-node`:跳过 Node 依赖更新
329
402
 
403
+ 示例:
404
+
405
+ ```bash
406
+ nuxt-gin update
407
+ nuxt-gin update --package-manager bun --latest true
408
+ nuxt-gin update --package-manager pnpm --latest false
409
+ ```
410
+
411
+ 执行前也会输出一段样式化 banner。
412
+
330
413
  ### 🧩 `pack.config.ts` / `pack.config.json`
331
414
 
332
415
  `nuxt-gin build` 会自动读取项目根目录中的打包配置,优先级如下:
@@ -450,7 +533,7 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
450
533
  ### 🖥️ 环境依赖
451
534
 
452
535
  - Node.js
453
- - pnpm
536
+ - pnpm 或 bun
454
537
  - Go,若需要运行 Gin 侧开发流程
455
538
  - 当前命令集不再依赖额外的代码生成器
456
539
 
@@ -459,3 +542,6 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
459
542
  - 💨 Go 热更新不再依赖 Air
460
543
  - 👀 当前 Go 开发监听方案为 `chokidar` + 重启 `go run main.go`
461
544
  - 🪟 打包时会按平台生成可执行文件名:Windows 默认 `.exe`,Linux/macOS 默认无扩展名
545
+ - 🌈 主要命令会输出统一风格的 banner,并提供更清晰的成功 / 信息提示
546
+ - 📋 命令结束后会打印本次实际执行内容的摘要;`dev` 这类常驻命令会在进入监听前先打印启动摘要
547
+ - 📦 同一个工作副本建议固定使用一种包管理器,不要在同一套依赖目录里反复混用 `pnpm` 与 `bun`
@@ -1,8 +1,11 @@
1
- export declare function ifExistsRemove(relativePath: string): void;
2
- export declare function cleanUpNuxt(): Promise<import("concurrently").CloseEvent[]>;
3
- export declare function cleanUpBuild(): void;
1
+ export type CleanupOptions = {
2
+ dryRun?: boolean;
3
+ };
4
+ export declare function ifExistsRemove(relativePath: string, options?: CleanupOptions, actions?: string[]): void;
5
+ export declare function cleanUpNuxt(options?: CleanupOptions, actions?: string[]): Promise<void> | Promise<import("concurrently").CloseEvent[]>;
6
+ export declare function cleanUpBuild(options?: CleanupOptions, actions?: string[]): void;
4
7
  /**
5
8
  * 清理构建目录和临时文件
6
9
  */
7
- export declare function cleanUp(): Promise<void>;
10
+ export declare function cleanUp(options?: CleanupOptions): Promise<void>;
8
11
  export default cleanUp;
@@ -54,45 +54,56 @@ const Path = __importStar(require("path"));
54
54
  const concurrently_1 = __importDefault(require("concurrently"));
55
55
  const terminal_ui_1 = require("../src/terminal-ui");
56
56
  const cwd = process.cwd();
57
- function ifExistsRemove(relativePath) {
57
+ const CLEANUP_PATHS = [
58
+ ".build/production",
59
+ "dist",
60
+ ".build",
61
+ "tmp",
62
+ "vue/.output",
63
+ ".openapi-generator",
64
+ ];
65
+ function ifExistsRemove(relativePath, options = {}, actions = []) {
58
66
  const absolutePath = Path.resolve(cwd, relativePath);
59
67
  if (FS.existsSync(absolutePath)) {
68
+ if (options.dryRun) {
69
+ (0, terminal_ui_1.printCommandInfo)("cleanup", `would remove ${absolutePath}`);
70
+ actions.push(`would remove ${relativePath}`);
71
+ return;
72
+ }
60
73
  FS.removeSync(absolutePath);
74
+ actions.push(`removed ${relativePath}`);
61
75
  }
62
76
  }
63
- function cleanUpNuxt() {
77
+ function cleanUpNuxt(options = {}, actions = []) {
78
+ if (options.dryRun) {
79
+ (0, terminal_ui_1.printCommandInfo)("cleanup", "would run `npx nuxt cleanup`");
80
+ actions.push("would run nuxt cleanup");
81
+ return Promise.resolve();
82
+ }
83
+ actions.push("ran nuxt cleanup");
64
84
  return (0, concurrently_1.default)([
65
85
  {
66
86
  command: "npx nuxt cleanup",
67
87
  },
68
88
  ]).result;
69
89
  }
70
- function cleanUpBuild() {
71
- // 清理构建目录
72
- ifExistsRemove(".build/production");
73
- // 清理原始 dist 目录
74
- ifExistsRemove("dist");
75
- // 清理临时文件
76
- ifExistsRemove(".build");
77
- // 清理临时文件
78
- ifExistsRemove("tmp");
79
- // 清理 Vue 应用构建输出目录
80
- ifExistsRemove("vue/.output");
81
- // 清理 OpenAPI 生成的文件
82
- ifExistsRemove(".openapi-generator");
83
- // 清理go.sum
84
- // ifExistsRemove("go.sum");
90
+ function cleanUpBuild(options = {}, actions = []) {
91
+ for (const path of CLEANUP_PATHS) {
92
+ ifExistsRemove(path, options, actions);
93
+ }
85
94
  }
86
95
  /**
87
96
  * 清理构建目录和临时文件
88
97
  */
89
98
  function cleanUp() {
90
- return __awaiter(this, void 0, void 0, function* () {
99
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
91
100
  (0, terminal_ui_1.printCommandBanner)("cleanup", "Remove generated build output and temporary files");
92
- const result = cleanUpNuxt();
93
- cleanUpBuild();
101
+ const actions = [];
102
+ const result = cleanUpNuxt(options, actions);
103
+ cleanUpBuild(options, actions);
94
104
  yield result;
95
- (0, terminal_ui_1.printCommandSuccess)("cleanup", "Temporary files removed");
105
+ (0, terminal_ui_1.printCommandSuccess)("cleanup", options.dryRun ? "Dry run completed" : "Temporary files removed");
106
+ (0, terminal_ui_1.printCommandSummary)("cleanup", actions);
96
107
  });
97
108
  }
98
109
  exports.default = cleanUp;
@@ -15,15 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.startGoDev = startGoDev;
16
16
  const child_process_1 = require("child_process");
17
17
  const chokidar_1 = __importDefault(require("chokidar"));
18
- const chalk_1 = __importDefault(require("chalk"));
19
18
  const fs_extra_1 = require("fs-extra");
20
19
  const path_1 = require("path");
21
20
  const utils_1 = require("../src/utils");
21
+ const terminal_ui_1 = require("../src/terminal-ui");
22
22
  const cwd = process.cwd();
23
23
  const RESTART_DEBOUNCE_MS = 150;
24
24
  const SHUTDOWN_TIMEOUT_MS = 2000;
25
25
  const LOG_TAG = "go-watch";
26
- const GO_WATCH_PREFIX = chalk_1.default.bgMagenta.white(`[${LOG_TAG}]`);
26
+ const GO_WATCH_PREFIX = `[${LOG_TAG}]`;
27
27
  const serverConfigPath = (0, path_1.join)(cwd, "server.config.json");
28
28
  const ginPort = getGinPort();
29
29
  function getGinPort() {
@@ -97,7 +97,7 @@ function loadWatchConfig() {
97
97
  parsedConfig = JSON.parse((0, fs_extra_1.readFileSync)(configPath, "utf-8"));
98
98
  }
99
99
  catch (_j) {
100
- console.warn(`${GO_WATCH_PREFIX} invalid watch config JSON, fallback to defaults: ${configPath}`);
100
+ (0, terminal_ui_1.printCommandWarn)(`${GO_WATCH_PREFIX} invalid watch config JSON, fallback to defaults: ${configPath}`);
101
101
  return defaultConfig;
102
102
  }
103
103
  const includeExt = toStringArray((_a = parsedConfig.includeExt) !== null && _a !== void 0 ? _a : parsedConfig.include_ext)
@@ -184,7 +184,7 @@ function quote(arg) {
184
184
  function runGoProcess() {
185
185
  const command = `go run ${quote("main.go")}`;
186
186
  killGinPortIfNeeded();
187
- console.log(`${GO_WATCH_PREFIX} start: ${command}`);
187
+ (0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `start: ${command}`);
188
188
  return (0, child_process_1.spawn)(command, {
189
189
  cwd,
190
190
  shell: true,
@@ -241,7 +241,7 @@ function startGoDev() {
241
241
  const watchRoots = watchConfig.includeDir.length
242
242
  ? watchConfig.includeDir.map((dir) => (0, path_1.join)(cwd, dir))
243
243
  : [cwd];
244
- console.log(`${GO_WATCH_PREFIX} watching: ${watchRoots.map((item) => toProjectRelative(item)).join(", ")}`);
244
+ (0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `watching: ${watchRoots.map((item) => toProjectRelative(item)).join(", ")}`);
245
245
  let restarting = false;
246
246
  let goProc = runGoProcess();
247
247
  let restartTimer = null;
@@ -266,7 +266,7 @@ function startGoDev() {
266
266
  return;
267
267
  }
268
268
  restarting = true;
269
- console.log(`${GO_WATCH_PREFIX} ${eventName}: ${relPath}, restarting...`);
269
+ (0, terminal_ui_1.printCommandLog)(GO_WATCH_PREFIX, `${eventName}: ${relPath}, restarting...`);
270
270
  yield stopGoProcess(goProc);
271
271
  goProc = runGoProcess();
272
272
  restarting = false;
@@ -277,7 +277,7 @@ function startGoDev() {
277
277
  .on("change", (filePath) => triggerRestart("change", filePath))
278
278
  .on("unlink", (filePath) => triggerRestart("unlink", filePath))
279
279
  .on("error", (error) => {
280
- console.error(`${GO_WATCH_PREFIX} watcher error: ${String(error)}`);
280
+ (0, terminal_ui_1.printCommandError)(`${GO_WATCH_PREFIX} watcher error`, error);
281
281
  });
282
282
  const shutdown = () => __awaiter(this, void 0, void 0, function* () {
283
283
  if (restartTimer) {
@@ -300,7 +300,7 @@ function startGoDev() {
300
300
  if (require.main === module) {
301
301
  // 兼容直接执行该文件(例如 node src/dev-go.js)。
302
302
  startGoDev().catch((error) => {
303
- console.error(`${GO_WATCH_PREFIX} failed to start: ${String(error)}`);
303
+ (0, terminal_ui_1.printCommandError)(`${GO_WATCH_PREFIX} failed to start`, error);
304
304
  process.exit(1);
305
305
  });
306
306
  }
@@ -70,6 +70,7 @@ function runGoDev() {
70
70
  function develop() {
71
71
  return __awaiter(this, arguments, void 0, function* (options = {}) {
72
72
  (0, terminal_ui_1.printCommandBanner)("dev", "Start Nuxt and Go development workflows");
73
+ const actions = [];
73
74
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
74
75
  yield prepareDevelop(options);
75
76
  // 在开发前确保占用端口被释放
@@ -78,14 +79,24 @@ function develop() {
78
79
  options.skipGo ? undefined : serverConfig.ginPort,
79
80
  options.skipNuxt ? undefined : serverConfig.nuxtPort,
80
81
  ]);
82
+ actions.push("released occupied development ports");
81
83
  }
82
84
  const tasks = [];
83
85
  if (!options.skipGo) {
84
86
  tasks.push(runGoDev());
87
+ actions.push(`started Go watcher on port ${serverConfig.ginPort}`);
85
88
  }
86
89
  if (!options.skipNuxt) {
87
90
  tasks.push(runNuxtDev());
91
+ actions.push(`started Nuxt dev server on port ${serverConfig.nuxtPort}`);
88
92
  }
93
+ if (options.skipGo) {
94
+ actions.push("skipped Go workflow");
95
+ }
96
+ if (options.skipNuxt) {
97
+ actions.push("skipped Nuxt workflow");
98
+ }
99
+ (0, terminal_ui_1.printCommandSummary)("dev", actions);
89
100
  yield Promise.all(tasks);
90
101
  });
91
102
  }
@@ -97,11 +108,15 @@ function develop() {
97
108
  function developNuxt() {
98
109
  return __awaiter(this, arguments, void 0, function* (options = {}) {
99
110
  (0, terminal_ui_1.printCommandBanner)("dev:nuxt", "Start Nuxt development server only");
111
+ const actions = [];
100
112
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
101
113
  yield prepareDevelop(options);
102
114
  if (killPortBeforeDevelop) {
103
115
  (0, utils_1.killPorts)([serverConfig.nuxtPort]);
116
+ actions.push("released Nuxt dev port");
104
117
  }
118
+ actions.push(`started Nuxt dev server on port ${serverConfig.nuxtPort}`);
119
+ (0, terminal_ui_1.printCommandSummary)("dev:nuxt", actions);
105
120
  yield runNuxtDev();
106
121
  });
107
122
  }
@@ -113,11 +128,15 @@ function developNuxt() {
113
128
  function developGo() {
114
129
  return __awaiter(this, arguments, void 0, function* (options = {}) {
115
130
  (0, terminal_ui_1.printCommandBanner)("dev:go", "Start Go watcher only");
131
+ const actions = [];
116
132
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
117
133
  yield prepareDevelop(options);
118
134
  if (killPortBeforeDevelop) {
119
135
  (0, utils_1.killPorts)([serverConfig.ginPort]);
136
+ actions.push("released Go server port");
120
137
  }
138
+ actions.push(`started Go watcher on port ${serverConfig.ginPort}`);
139
+ (0, terminal_ui_1.printCommandSummary)("dev:go", actions);
121
140
  yield runGoDev();
122
141
  });
123
142
  }
package/commands/pack.js CHANGED
@@ -148,7 +148,15 @@ function validatePackConfig(config, sourcePath) {
148
148
  issues.push({ level: "error", message: `${field} must be a string` });
149
149
  }
150
150
  }
151
- const booleanFields = ["skipGo", "skipNuxt", "cleanDist", "writeScripts", "overwrite"];
151
+ const booleanFields = [
152
+ "skipGo",
153
+ "skipNuxt",
154
+ "skipBuild",
155
+ "skipZip",
156
+ "cleanDist",
157
+ "writeScripts",
158
+ "overwrite",
159
+ ];
152
160
  for (const field of booleanFields) {
153
161
  const value = typedConfig[field];
154
162
  if (value !== undefined && typeof value !== "boolean") {
@@ -173,6 +181,9 @@ function validatePackConfig(config, sourcePath) {
173
181
  if (typedConfig.skipGo === true && typedConfig.skipNuxt === true) {
174
182
  issues.push({ level: "warn", message: `skipGo and skipNuxt are both true; build step will be skipped` });
175
183
  }
184
+ if (typedConfig.skipBuild === true && typedConfig.skipZip === true) {
185
+ issues.push({ level: "warn", message: `skipBuild and skipZip are both true; only bundle assembly will run` });
186
+ }
176
187
  for (const issue of issues) {
177
188
  if (issue.level === "warn") {
178
189
  warnPackConfig(`${Path.basename(sourcePath)}: ${issue.message}`);
@@ -296,10 +307,11 @@ function makeZip(serverPath, zipPath) {
296
307
  // 使用 7zip 将服务器构建目录打包为 7z 文件
297
308
  Zip.pack(serverPath, zipPath, (error) => {
298
309
  if (error) {
299
- console.error("打包失败:", error);
310
+ (0, terminal_ui_1.printCommandError)("打包失败", error);
300
311
  reject(error);
312
+ return;
301
313
  }
302
- console.log("打包成功:", zipPath);
314
+ (0, terminal_ui_1.printCommandSuccess)("pack", `archive ready: ${zipPath}`);
303
315
  resolve(zipPath);
304
316
  });
305
317
  });
@@ -327,25 +339,54 @@ function cleanUp(config) {
327
339
  function buildAndPack(config) {
328
340
  return __awaiter(this, void 0, void 0, function* () {
329
341
  (0, terminal_ui_1.printCommandBanner)("build", "Build project artifacts and pack deployment bundle");
342
+ const actions = [];
330
343
  const resolvedConfig = config !== null && config !== void 0 ? config : readPackConfigFromCwd();
331
344
  const serverPath = resolveServerPath(resolvedConfig);
332
345
  const zipPath = resolveZipPath(resolvedConfig);
333
- yield (0, builder_1.default)(resolvedConfig); // 执行项目构建
346
+ if (!(resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.skipBuild)) {
347
+ yield (0, builder_1.default)(resolvedConfig); // 执行项目构建
348
+ actions.push("built project artifacts");
349
+ }
350
+ else {
351
+ (0, terminal_ui_1.printCommandInfo)("build", "skipping build step");
352
+ actions.push("skipped build step");
353
+ }
334
354
  if (resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.beforePack) {
335
355
  yield resolvedConfig.beforePack();
356
+ actions.push("ran beforePack hook");
336
357
  }
337
358
  copyGeneratedFiles(serverPath, resolvedConfig); // 复制相关文件
359
+ actions.push(`assembled bundle in ${serverPath}`);
338
360
  if ((resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.writeScripts) !== false) {
339
361
  writeScriptFiles(serverPath, resolvedConfig); // 写入脚本文件
362
+ actions.push("wrote startup scripts and package.json");
363
+ }
364
+ else {
365
+ actions.push("skipped startup script generation");
366
+ }
367
+ if (!(resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.skipZip)) {
368
+ yield makeZip(serverPath, zipPath); // 打包文件
369
+ (0, terminal_ui_1.printCommandInfo)("pack", `7z archive: ${zipPath}`);
370
+ actions.push(`created 7z archive at ${zipPath}`);
371
+ }
372
+ else {
373
+ (0, terminal_ui_1.printCommandInfo)("pack", "skipping 7z archive step");
374
+ actions.push("skipped 7z archive step");
340
375
  }
341
- yield makeZip(serverPath, zipPath); // 打包文件
342
- (0, terminal_ui_1.printCommandInfo)("pack", `7z archive: ${zipPath}`);
343
376
  (0, terminal_ui_1.printCommandInfo)("pack", `bundle dir: ${serverPath}`);
344
377
  if (resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.afterPack) {
345
378
  yield resolvedConfig.afterPack(zipPath);
379
+ actions.push("ran afterPack hook");
346
380
  }
347
381
  cleanUp(resolvedConfig); // 清理临时文件
382
+ if ((resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.cleanDist) === false) {
383
+ actions.push("kept dist directory by configuration");
384
+ }
385
+ else {
386
+ actions.push("cleaned dist directory");
387
+ }
348
388
  (0, terminal_ui_1.printCommandSuccess)("build", "Build and pack completed");
389
+ (0, terminal_ui_1.printCommandSummary)("build", actions);
349
390
  });
350
391
  }
351
392
  exports.default = buildAndPack;
@@ -1,2 +1,6 @@
1
- export declare function postInstall(): Promise<void>;
1
+ export type PostInstallOptions = {
2
+ skipGo?: boolean;
3
+ skipNuxt?: boolean;
4
+ };
5
+ export declare function postInstall(options?: PostInstallOptions): Promise<void>;
2
6
  export default postInstall;
@@ -7,30 +7,47 @@ exports.postInstall = postInstall;
7
7
  const concurrently_1 = __importDefault(require("concurrently"));
8
8
  const node_child_process_1 = require("node:child_process");
9
9
  const terminal_ui_1 = require("../src/terminal-ui");
10
- function postInstall() {
10
+ function postInstall(options = {}) {
11
11
  (0, terminal_ui_1.printCommandBanner)("install", "Prepare Nuxt and optional Go dependencies");
12
+ const actions = [];
13
+ const commands = [];
12
14
  const hasGo = (0, node_child_process_1.spawnSync)("go", ["version"], { stdio: "ignore", shell: true }).status ===
13
15
  0;
14
- const commands = [
15
- {
16
+ if (!options.skipNuxt) {
17
+ actions.push("prepared Nuxt runtime");
18
+ commands.push({
16
19
  command: "npx nuxt prepare",
17
20
  name: "nuxt",
18
21
  prefixColor: "blue",
19
- },
20
- ];
21
- if (hasGo) {
22
- commands.unshift({
22
+ });
23
+ }
24
+ if (!options.skipGo && hasGo) {
25
+ actions.push("downloaded and tidied Go modules");
26
+ commands.push({
23
27
  command: "go mod download && go mod tidy",
24
28
  name: "go",
25
29
  prefixColor: "green",
26
30
  });
27
31
  }
28
- else {
32
+ else if (!options.skipGo) {
29
33
  (0, terminal_ui_1.printCommandWarn)("Go was not detected, skipping Go dependency bootstrap");
34
+ actions.push("skipped Go bootstrap because Go was not detected");
35
+ }
36
+ else {
37
+ actions.push("skipped Go bootstrap by option");
38
+ }
39
+ if (options.skipNuxt) {
40
+ actions.push("skipped Nuxt prepare by option");
41
+ }
42
+ if (commands.length === 0) {
43
+ (0, terminal_ui_1.printCommandWarn)("Nothing selected for install, skipping bootstrap");
44
+ (0, terminal_ui_1.printCommandSummary)("install", actions.length > 0 ? actions : ["nothing was executed"]);
45
+ return Promise.resolve();
30
46
  }
31
47
  // 执行并发命令
32
48
  return (0, concurrently_1.default)(commands).result.then(() => {
33
49
  (0, terminal_ui_1.printCommandSuccess)("install", "Project bootstrap completed");
50
+ (0, terminal_ui_1.printCommandSummary)("install", actions);
34
51
  });
35
52
  }
36
53
  exports.default = postInstall;
@@ -1,7 +1,9 @@
1
+ import { type PackageManagerSelection } from "../src/package-manager";
1
2
  export type UpdateOptions = {
2
- latest?: boolean;
3
+ latest: boolean;
4
+ packageManager: PackageManagerSelection;
3
5
  skipGo?: boolean;
4
6
  skipNode?: boolean;
5
7
  };
6
- export declare function update(options?: UpdateOptions): Promise<void>;
8
+ export declare function update(options: UpdateOptions): Promise<void>;
7
9
  export default update;
@@ -5,30 +5,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.update = update;
7
7
  const concurrently_1 = __importDefault(require("concurrently"));
8
+ const package_manager_1 = require("../src/package-manager");
8
9
  const terminal_ui_1 = require("../src/terminal-ui");
9
- function update(options = {}) {
10
+ function update(options) {
10
11
  (0, terminal_ui_1.printCommandBanner)("update", "Update Node and Go dependencies");
12
+ const actions = [];
11
13
  const commands = [];
14
+ const packageManager = (0, package_manager_1.resolvePackageManager)(options.packageManager);
12
15
  if (!options.skipNode) {
16
+ actions.push(`updated Node dependencies with ${packageManager} (${options.latest ? "latest" : "conservative"} mode)`);
13
17
  commands.push({
14
- command: options.latest ? "pnpm update --latest" : "pnpm update",
15
- name: "pnpm",
18
+ command: (0, package_manager_1.packageManagerUpdateCommand)(packageManager, options.latest),
19
+ name: packageManager,
16
20
  prefixColor: "magenta",
17
21
  });
18
22
  }
19
23
  if (!options.skipGo) {
24
+ actions.push(`updated Go modules with ${options.latest ? "latest" : "patch"} strategy`);
20
25
  commands.push({
21
26
  command: options.latest ? "go get -u ./... && go mod tidy" : "go get -u=patch ./... && go mod tidy",
22
27
  name: "go",
23
28
  prefixColor: "green",
24
29
  });
25
30
  }
31
+ if (options.skipNode) {
32
+ actions.push("skipped Node dependency update");
33
+ }
34
+ if (options.skipGo) {
35
+ actions.push("skipped Go dependency update");
36
+ }
26
37
  if (commands.length === 0) {
27
38
  (0, terminal_ui_1.printCommandWarn)("No update targets selected, nothing to do");
39
+ (0, terminal_ui_1.printCommandSummary)("update", actions.length > 0 ? actions : ["nothing was executed"]);
28
40
  return Promise.resolve();
29
41
  }
30
42
  return (0, concurrently_1.default)(commands).result.then(() => {
31
43
  (0, terminal_ui_1.printCommandSuccess)("update", "Dependency update completed");
44
+ (0, terminal_ui_1.printCommandSummary)("update", actions);
32
45
  });
33
46
  }
34
47
  exports.default = update;
package/index.js CHANGED
@@ -58,17 +58,25 @@ const cleanup_1 = __importDefault(require("./commands/cleanup"));
58
58
  // 导入更新功能
59
59
  const update_1 = __importDefault(require("./commands/update"));
60
60
  const cli_options_1 = require("./src/cli-options");
61
+ const package_manager_1 = require("./src/package-manager");
62
+ const terminal_ui_1 = require("./src/terminal-ui");
61
63
  // 获取命令行参数(去除前两个默认参数)
62
64
  const args = process.argv.slice(2);
63
65
  // 检查是否提供了命令
64
66
  if (args.length === 0) {
65
- console.error("未提供命令。请指定要运行的命令。");
67
+ (0, terminal_ui_1.printCommandError)("未提供命令。请指定要运行的命令。");
66
68
  process.exit(1);
67
69
  }
68
70
  function main() {
69
71
  return __awaiter(this, void 0, void 0, function* () {
70
72
  const command = args[0];
71
73
  const options = (0, cli_options_1.parseCLIOptions)(args.slice(1));
74
+ const rawPackageManager = (0, cli_options_1.getOption)(options, "package-manager");
75
+ const packageManagerCandidate = rawPackageManager !== null && rawPackageManager !== void 0 ? rawPackageManager : "auto";
76
+ if (!(0, package_manager_1.isPackageManagerSelection)(packageManagerCandidate)) {
77
+ throw new Error(`Invalid value for --package-manager: ${packageManagerCandidate}. Expected one of: auto, bun, pnpm, npm`);
78
+ }
79
+ const packageManagerOption = packageManagerCandidate;
72
80
  switch (command) {
73
81
  case "dev":
74
82
  yield (0, develop_1.default)({
@@ -92,31 +100,39 @@ function main() {
92
100
  binaryName: (0, cli_options_1.getOption)(options, "binary-name"),
93
101
  skipGo: (0, cli_options_1.hasFlag)(options, "skip-go"),
94
102
  skipNuxt: (0, cli_options_1.hasFlag)(options, "skip-nuxt"),
103
+ skipBuild: (0, cli_options_1.hasFlag)(options, "skip-build"),
104
+ skipZip: (0, cli_options_1.hasFlag)(options, "skip-zip"),
95
105
  });
96
106
  break;
97
107
  case "install":
98
108
  // 执行安装后的初始化操作
99
- yield (0, postinstall_1.default)();
109
+ yield (0, postinstall_1.default)({
110
+ skipGo: (0, cli_options_1.hasFlag)(options, "skip-go"),
111
+ skipNuxt: (0, cli_options_1.hasFlag)(options, "skip-nuxt"),
112
+ });
100
113
  break;
101
114
  case "cleanup":
102
115
  // 执行清理操作
103
- yield (0, cleanup_1.default)();
116
+ yield (0, cleanup_1.default)({
117
+ dryRun: (0, cli_options_1.hasFlag)(options, "dry-run"),
118
+ });
104
119
  break;
105
120
  case "update":
106
121
  // 更新依赖
107
122
  yield (0, update_1.default)({
108
- latest: (0, cli_options_1.hasFlag)(options, "latest"),
123
+ latest: (0, cli_options_1.getBooleanOption)(options, "latest", false),
124
+ packageManager: packageManagerOption,
109
125
  skipGo: (0, cli_options_1.hasFlag)(options, "skip-go"),
110
126
  skipNode: (0, cli_options_1.hasFlag)(options, "skip-node"),
111
127
  });
112
128
  break;
113
129
  default:
114
- console.error(`未知命令: ${command}`);
130
+ (0, terminal_ui_1.printCommandError)(`未知命令: ${command}`);
115
131
  process.exit(1);
116
132
  }
117
133
  });
118
134
  }
119
135
  void main().catch((error) => {
120
- console.error(error);
136
+ (0, terminal_ui_1.printCommandError)("命令执行失败", error);
121
137
  process.exit(1);
122
138
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-gin-tools",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
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"
@@ -6,3 +6,4 @@ export type CLIOptions = {
6
6
  export declare function parseCLIOptions(args: string[]): CLIOptions;
7
7
  export declare function hasFlag(options: CLIOptions, key: string): boolean;
8
8
  export declare function getOption(options: CLIOptions, key: string): string | undefined;
9
+ export declare function getBooleanOption(options: CLIOptions, key: string, defaultValue: boolean): boolean;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseCLIOptions = parseCLIOptions;
4
4
  exports.hasFlag = hasFlag;
5
5
  exports.getOption = getOption;
6
+ exports.getBooleanOption = getBooleanOption;
6
7
  function normalizeKey(key) {
7
8
  return key.replace(/^-+/, "").trim();
8
9
  }
@@ -41,3 +42,17 @@ function hasFlag(options, key) {
41
42
  function getOption(options, key) {
42
43
  return options.values.get(normalizeKey(key));
43
44
  }
45
+ function getBooleanOption(options, key, defaultValue) {
46
+ const value = getOption(options, key);
47
+ if (value === undefined) {
48
+ return defaultValue;
49
+ }
50
+ const normalized = value.trim().toLowerCase();
51
+ if (["true", "1", "yes", "y", "on"].includes(normalized)) {
52
+ return true;
53
+ }
54
+ if (["false", "0", "no", "n", "off"].includes(normalized)) {
55
+ return false;
56
+ }
57
+ throw new Error(`Invalid boolean value for --${key}: ${value}`);
58
+ }
package/src/pack.d.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  import type { BuildOptions } from "../commands/builder";
2
2
  export interface PackConfig extends BuildOptions {
3
+ /**
4
+ * 是否跳过构建步骤
5
+ */
6
+ skipBuild?: boolean;
7
+ /**
8
+ * 是否跳过 7z 打包步骤
9
+ */
10
+ skipZip?: boolean;
3
11
  /**
4
12
  * 额外需要打包的文件映射
5
13
  * key: 源文件路径(相对于项目根目录或绝对路径)
@@ -0,0 +1,7 @@
1
+ export type PackageManager = "bun" | "pnpm" | "npm";
2
+ export type PackageManagerSelection = PackageManager | "auto";
3
+ export declare const PACKAGE_MANAGER_SELECTIONS: readonly ["auto", "bun", "pnpm", "npm"];
4
+ export declare function detectPackageManager(): PackageManager;
5
+ export declare function resolvePackageManager(selection: PackageManagerSelection): PackageManager;
6
+ export declare function isPackageManagerSelection(value: string): value is PackageManagerSelection;
7
+ export declare function packageManagerUpdateCommand(packageManager: PackageManager, latest: boolean): string;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PACKAGE_MANAGER_SELECTIONS = void 0;
4
+ exports.detectPackageManager = detectPackageManager;
5
+ exports.resolvePackageManager = resolvePackageManager;
6
+ exports.isPackageManagerSelection = isPackageManagerSelection;
7
+ exports.packageManagerUpdateCommand = packageManagerUpdateCommand;
8
+ const fs_extra_1 = require("fs-extra");
9
+ const path_1 = require("path");
10
+ exports.PACKAGE_MANAGER_SELECTIONS = ["auto", "bun", "pnpm", "npm"];
11
+ const cwd = process.cwd();
12
+ function detectPackageManager() {
13
+ if ((0, fs_extra_1.existsSync)((0, path_1.join)(cwd, "bun.lock")) || (0, fs_extra_1.existsSync)((0, path_1.join)(cwd, "bun.lockb"))) {
14
+ return "bun";
15
+ }
16
+ if ((0, fs_extra_1.existsSync)((0, path_1.join)(cwd, "pnpm-lock.yaml"))) {
17
+ return "pnpm";
18
+ }
19
+ return "npm";
20
+ }
21
+ function resolvePackageManager(selection) {
22
+ if (selection === "auto") {
23
+ return detectPackageManager();
24
+ }
25
+ return selection;
26
+ }
27
+ function isPackageManagerSelection(value) {
28
+ return exports.PACKAGE_MANAGER_SELECTIONS.includes(value);
29
+ }
30
+ function packageManagerUpdateCommand(packageManager, latest) {
31
+ switch (packageManager) {
32
+ case "bun":
33
+ return latest ? "bun update --latest" : "bun update";
34
+ case "pnpm":
35
+ return latest ? "pnpm update --latest" : "pnpm update";
36
+ default:
37
+ return latest ? "npm update" : "npm update";
38
+ }
39
+ }
@@ -2,3 +2,6 @@ export declare function printCommandBanner(command: string, subtitle: string): v
2
2
  export declare function printCommandSuccess(command: string, message: string): void;
3
3
  export declare function printCommandInfo(label: string, message: string): void;
4
4
  export declare function printCommandWarn(message: string): void;
5
+ export declare function printCommandError(message: string, error?: unknown): void;
6
+ export declare function printCommandLog(label: string, message: string): void;
7
+ export declare function printCommandSummary(command: string, items: string[]): void;
@@ -7,27 +7,112 @@ exports.printCommandBanner = printCommandBanner;
7
7
  exports.printCommandSuccess = printCommandSuccess;
8
8
  exports.printCommandInfo = printCommandInfo;
9
9
  exports.printCommandWarn = printCommandWarn;
10
+ exports.printCommandError = printCommandError;
11
+ exports.printCommandLog = printCommandLog;
12
+ exports.printCommandSummary = printCommandSummary;
10
13
  const chalk_1 = __importDefault(require("chalk"));
11
- function line(width = 64) {
12
- return "".repeat(width);
14
+ const TERMINAL_WIDTH = 72;
15
+ function printLine(message, method = "log") {
16
+ if (method === "warn") {
17
+ console.warn(message);
18
+ return;
19
+ }
20
+ if (method === "error") {
21
+ console.error(message);
22
+ return;
23
+ }
24
+ console.log(message);
25
+ }
26
+ function repeat(char, width = TERMINAL_WIDTH) {
27
+ return char.repeat(width);
28
+ }
29
+ function formatClock() {
30
+ return new Date().toLocaleTimeString("en-GB", {
31
+ hour: "2-digit",
32
+ minute: "2-digit",
33
+ second: "2-digit",
34
+ hour12: false,
35
+ });
36
+ }
37
+ function padText(value, width) {
38
+ const text = value.length > width ? `${value.slice(0, Math.max(0, width - 1))}…` : value;
39
+ return text + " ".repeat(Math.max(0, width - text.length));
40
+ }
41
+ function sectionBorder(color) {
42
+ return color(`╭${repeat("─", TERMINAL_WIDTH - 2)}╮`);
43
+ }
44
+ function sectionFooter(color) {
45
+ return color(`╰${repeat("─", TERMINAL_WIDTH - 2)}╯`);
46
+ }
47
+ function sectionBody(text, color) {
48
+ return color(`│ ${padText(text, TERMINAL_WIDTH - 4)} │`);
49
+ }
50
+ function printSection(lines, options) {
51
+ var _a;
52
+ if (lines.length === 0) {
53
+ return;
54
+ }
55
+ const method = (_a = options.method) !== null && _a !== void 0 ? _a : "log";
56
+ printLine(options.color(``), method);
57
+ printLine(sectionBorder(options.color), method);
58
+ for (const line of lines) {
59
+ printLine(sectionBody(line, options.color), method);
60
+ }
61
+ printLine(sectionFooter(options.color), method);
62
+ }
63
+ function commandChip(command) {
64
+ return chalk_1.default.bgBlueBright.black(` ${command.toUpperCase()} `);
65
+ }
66
+ function subtleChip(text) {
67
+ return chalk_1.default.bgBlackBright.white(` ${text} `);
13
68
  }
14
69
  function printCommandBanner(command, subtitle) {
15
- const head = chalk_1.default.bgBlue.black(` ${command.toUpperCase()} `);
16
- const border = chalk_1.default.blueBright(line());
17
- const title = chalk_1.default.bold.white(`nuxt-gin-tools ${head}`);
18
- const detail = chalk_1.default.cyan(subtitle);
19
- console.log("");
20
- console.log(border);
21
- console.log(title);
22
- console.log(detail);
23
- console.log(border);
70
+ const timestamp = subtleChip(formatClock());
71
+ const title = `nuxt-gin-tools ${commandChip(command)} ${timestamp}`;
72
+ const detail = chalk_1.default.cyanBright(subtitle);
73
+ printLine("");
74
+ printSection([title, detail], {
75
+ color: chalk_1.default.blueBright,
76
+ });
24
77
  }
25
78
  function printCommandSuccess(command, message) {
26
- console.log(chalk_1.default.green(`✔ ${command}: ${message}`));
79
+ printLine(chalk_1.default.greenBright(`◆ ${chalk_1.default.bold(command)} completed`) + chalk_1.default.green(` ${message}`));
27
80
  }
28
81
  function printCommandInfo(label, message) {
29
- console.log(chalk_1.default.blueBright(`ℹ ${label}: ${message}`));
82
+ const head = chalk_1.default.bgCyan.black(` ${label.toUpperCase()} `);
83
+ printLine(`${head} ${chalk_1.default.cyanBright(message)}`);
30
84
  }
31
85
  function printCommandWarn(message) {
32
- console.warn(chalk_1.default.yellow(`⚠ ${message}`));
86
+ printSection([`${chalk_1.default.bold("warning")} ${message}`], {
87
+ color: chalk_1.default.yellow,
88
+ method: "warn",
89
+ });
90
+ }
91
+ function printCommandError(message, error) {
92
+ const detail = error instanceof Error ? error.message : error !== undefined ? String(error) : "";
93
+ const lines = [`${chalk_1.default.bold("error")} ${message}`];
94
+ if (detail) {
95
+ lines.push(chalk_1.default.redBright(detail));
96
+ }
97
+ printSection(lines, {
98
+ color: chalk_1.default.red,
99
+ method: "error",
100
+ });
101
+ }
102
+ function printCommandLog(label, message) {
103
+ const chip = chalk_1.default.bgMagenta.white(` ${label} `);
104
+ printLine(`${chip} ${chalk_1.default.white(message)}`);
105
+ }
106
+ function printCommandSummary(command, items) {
107
+ const normalizedItems = items.map((item) => item.trim()).filter(Boolean);
108
+ if (normalizedItems.length === 0) {
109
+ return;
110
+ }
111
+ const lines = [
112
+ `${chalk_1.default.bold(`${command} summary`)} ${chalk_1.default.gray(`(${normalizedItems.length} items)`)}`,
113
+ ...normalizedItems.map((item) => chalk_1.default.magenta(`• ${item}`)),
114
+ ];
115
+ printSection(lines, {
116
+ color: chalk_1.default.magentaBright,
117
+ });
33
118
  }
package/src/utils.js CHANGED
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.killPort = killPort;
7
7
  exports.killPorts = killPorts;
8
8
  const child_process_1 = require("child_process");
9
- const chalk_1 = __importDefault(require("chalk"));
10
9
  const os_1 = __importDefault(require("os"));
10
+ const terminal_ui_1 = require("./terminal-ui");
11
11
  function isValidPort(port) {
12
12
  return Number.isInteger(port) && port > 0;
13
13
  }
@@ -34,7 +34,7 @@ function killPortUnix(port, options) {
34
34
  for (const pid of pids) {
35
35
  try {
36
36
  process.kill(pid, "SIGKILL");
37
- console.log(chalk_1.default.green(buildMessage(pid, port, "unix", options)));
37
+ (0, terminal_ui_1.printCommandSuccess)("port", buildMessage(pid, port, "unix", options));
38
38
  }
39
39
  catch (_a) {
40
40
  // Best-effort: if the process is already gone, ignore.
@@ -81,7 +81,7 @@ function killPortWindows(port, options) {
81
81
  (0, child_process_1.execSync)(`taskkill /PID ${pid} /F`, {
82
82
  stdio: ["ignore", "ignore", "ignore"],
83
83
  });
84
- console.log(chalk_1.default.green(buildMessage(pid, port, "win32", options)));
84
+ (0, terminal_ui_1.printCommandSuccess)("port", buildMessage(pid, port, "win32", options));
85
85
  }
86
86
  catch (_a) {
87
87
  // Best-effort: if the process is already gone, ignore.