nuxt-gin-tools 0.2.20 → 0.2.22

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
@@ -76,13 +76,6 @@ Bootstraps the project:
76
76
  - always runs `npx nuxt prepare`
77
77
  - if Go is available, also runs `go mod download && go mod tidy`
78
78
 
79
- #### `nuxt-gin gen`
80
-
81
- Generates API code from `openapi.yaml`:
82
-
83
- - Go Gin server code
84
- - TypeScript axios client code
85
-
86
79
  #### `nuxt-gin build`
87
80
 
88
81
  Runs the build-and-pack flow.
@@ -235,7 +228,7 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
235
228
  - Node.js
236
229
  - pnpm
237
230
  - Go, if you need the Gin side to run
238
- - `openapi-generator-cli`, only for `nuxt-gin gen`
231
+ - no extra generator dependency is required for the current command set
239
232
 
240
233
  ### 📝 Notes
241
234
 
@@ -307,13 +300,6 @@ nuxt-gin dev --no-cleanup
307
300
  - 总是执行 `npx nuxt prepare`
308
301
  - 检测到 Go 后,额外执行 `go mod download && go mod tidy`
309
302
 
310
- #### `nuxt-gin gen`
311
-
312
- 基于 `openapi.yaml` 生成 API 代码:
313
-
314
- - Go Gin server 代码
315
- - TypeScript axios 客户端代码
316
-
317
303
  #### `nuxt-gin build`
318
304
 
319
305
  执行构建与打包流程。
@@ -466,7 +452,7 @@ NUXT_GIN_WATCH_CONFIG=/path/to/.go-watch.json
466
452
  - Node.js
467
453
  - pnpm
468
454
  - Go,若需要运行 Gin 侧开发流程
469
- - `openapi-generator-cli`,仅 `nuxt-gin gen` 需要
455
+ - 当前命令集不再依赖额外的代码生成器
470
456
 
471
457
  ### 📝 说明
472
458
 
@@ -52,7 +52,7 @@ exports.cleanUp = cleanUp;
52
52
  const FS = __importStar(require("fs-extra"));
53
53
  const Path = __importStar(require("path"));
54
54
  const concurrently_1 = __importDefault(require("concurrently"));
55
- const chalk_1 = __importDefault(require("chalk"));
55
+ const terminal_ui_1 = require("../src/terminal-ui");
56
56
  const cwd = process.cwd();
57
57
  function ifExistsRemove(relativePath) {
58
58
  const absolutePath = Path.resolve(cwd, relativePath);
@@ -88,10 +88,11 @@ function cleanUpBuild() {
88
88
  */
89
89
  function cleanUp() {
90
90
  return __awaiter(this, void 0, void 0, function* () {
91
+ (0, terminal_ui_1.printCommandBanner)("cleanup", "Remove generated build output and temporary files");
91
92
  const result = cleanUpNuxt();
92
93
  cleanUpBuild();
93
94
  yield result;
94
- console.log(chalk_1.default.bgGreen("----- 清理完成!-----"));
95
+ (0, terminal_ui_1.printCommandSuccess)("cleanup", "Temporary files removed");
95
96
  });
96
97
  }
97
98
  exports.default = cleanUp;
@@ -22,6 +22,7 @@ const cleanup_1 = __importDefault(require("./cleanup"));
22
22
  const postinstall_1 = __importDefault(require("./postinstall"));
23
23
  const dev_go_1 = require("./dev-go");
24
24
  const utils_1 = require("../src/utils");
25
+ const terminal_ui_1 = require("../src/terminal-ui");
25
26
  const cwd = process.cwd();
26
27
  const serverConfig = (0, fs_extra_1.readJSONSync)((0, path_1.join)(cwd, "server.config.json"));
27
28
  function prepareDevelop() {
@@ -68,6 +69,7 @@ function runGoDev() {
68
69
  */
69
70
  function develop() {
70
71
  return __awaiter(this, arguments, void 0, function* (options = {}) {
72
+ (0, terminal_ui_1.printCommandBanner)("dev", "Start Nuxt and Go development workflows");
71
73
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
72
74
  yield prepareDevelop(options);
73
75
  // 在开发前确保占用端口被释放
@@ -94,6 +96,7 @@ function develop() {
94
96
  */
95
97
  function developNuxt() {
96
98
  return __awaiter(this, arguments, void 0, function* (options = {}) {
99
+ (0, terminal_ui_1.printCommandBanner)("dev:nuxt", "Start Nuxt development server only");
97
100
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
98
101
  yield prepareDevelop(options);
99
102
  if (killPortBeforeDevelop) {
@@ -109,6 +112,7 @@ function developNuxt() {
109
112
  */
110
113
  function developGo() {
111
114
  return __awaiter(this, arguments, void 0, function* (options = {}) {
115
+ (0, terminal_ui_1.printCommandBanner)("dev:go", "Start Go watcher only");
112
116
  const killPortBeforeDevelop = serverConfig.killPortBeforeDevelop !== false;
113
117
  yield prepareDevelop(options);
114
118
  if (killPortBeforeDevelop) {
package/commands/pack.js CHANGED
@@ -58,6 +58,7 @@ const FS = __importStar(require("fs-extra"));
58
58
  const Path = __importStar(require("path"));
59
59
  const os = __importStar(require("os"));
60
60
  const fast_glob_1 = __importDefault(require("fast-glob"));
61
+ const terminal_ui_1 = require("../src/terminal-ui");
61
62
  const { createJiti } = require("jiti");
62
63
  /**
63
64
  * 生成相对于服务器构建目录的绝对路径
@@ -96,7 +97,7 @@ const DEFAULT_FILES_TO_COPY = {
96
97
  // 兼容旧导出:默认构建目录下的绝对目标路径
97
98
  exports.FILES_TO_COPY = Object.fromEntries(Object.entries(DEFAULT_FILES_TO_COPY).map(([src, dest]) => [src, builtPath(dest)]));
98
99
  function warnPackConfig(message) {
99
- console.warn(`[nuxt-gin-tools][pack] WARN: ${message}`);
100
+ (0, terminal_ui_1.printCommandWarn)(`[pack] ${message}`);
100
101
  }
101
102
  function errorPackConfig(message) {
102
103
  throw new Error(`[nuxt-gin-tools][pack] ${message}`);
@@ -325,6 +326,7 @@ function cleanUp(config) {
325
326
  */
326
327
  function buildAndPack(config) {
327
328
  return __awaiter(this, void 0, void 0, function* () {
329
+ (0, terminal_ui_1.printCommandBanner)("build", "Build project artifacts and pack deployment bundle");
328
330
  const resolvedConfig = config !== null && config !== void 0 ? config : readPackConfigFromCwd();
329
331
  const serverPath = resolveServerPath(resolvedConfig);
330
332
  const zipPath = resolveZipPath(resolvedConfig);
@@ -337,10 +339,13 @@ function buildAndPack(config) {
337
339
  writeScriptFiles(serverPath, resolvedConfig); // 写入脚本文件
338
340
  }
339
341
  yield makeZip(serverPath, zipPath); // 打包文件
342
+ (0, terminal_ui_1.printCommandInfo)("pack", `7z archive: ${zipPath}`);
343
+ (0, terminal_ui_1.printCommandInfo)("pack", `bundle dir: ${serverPath}`);
340
344
  if (resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.afterPack) {
341
345
  yield resolvedConfig.afterPack(zipPath);
342
346
  }
343
347
  cleanUp(resolvedConfig); // 清理临时文件
348
+ (0, terminal_ui_1.printCommandSuccess)("build", "Build and pack completed");
344
349
  });
345
350
  }
346
351
  exports.default = buildAndPack;
@@ -1,2 +1,2 @@
1
- export declare function postInstall(): Promise<import("concurrently").CloseEvent[]>;
1
+ export declare function postInstall(): Promise<void>;
2
2
  export default postInstall;
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.postInstall = postInstall;
7
7
  const concurrently_1 = __importDefault(require("concurrently"));
8
8
  const node_child_process_1 = require("node:child_process");
9
+ const terminal_ui_1 = require("../src/terminal-ui");
9
10
  function postInstall() {
11
+ (0, terminal_ui_1.printCommandBanner)("install", "Prepare Nuxt and optional Go dependencies");
10
12
  const hasGo = (0, node_child_process_1.spawnSync)("go", ["version"], { stdio: "ignore", shell: true }).status ===
11
13
  0;
12
14
  const commands = [
@@ -24,9 +26,11 @@ function postInstall() {
24
26
  });
25
27
  }
26
28
  else {
27
- console.warn("[nuxt-gin-tools] 未检测到 Go,已跳过 Go 相关安装。请先安装 Go 后再重新运行相关命令。");
29
+ (0, terminal_ui_1.printCommandWarn)("Go was not detected, skipping Go dependency bootstrap");
28
30
  }
29
31
  // 执行并发命令
30
- return (0, concurrently_1.default)(commands).result;
32
+ return (0, concurrently_1.default)(commands).result.then(() => {
33
+ (0, terminal_ui_1.printCommandSuccess)("install", "Project bootstrap completed");
34
+ });
31
35
  }
32
36
  exports.default = postInstall;
@@ -3,5 +3,5 @@ export type UpdateOptions = {
3
3
  skipGo?: boolean;
4
4
  skipNode?: boolean;
5
5
  };
6
- export declare function update(options?: UpdateOptions): Promise<void> | Promise<import("concurrently").CloseEvent[]>;
6
+ export declare function update(options?: UpdateOptions): Promise<void>;
7
7
  export default update;
@@ -5,7 +5,9 @@ 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 terminal_ui_1 = require("../src/terminal-ui");
8
9
  function update(options = {}) {
10
+ (0, terminal_ui_1.printCommandBanner)("update", "Update Node and Go dependencies");
9
11
  const commands = [];
10
12
  if (!options.skipNode) {
11
13
  commands.push({
@@ -22,8 +24,11 @@ function update(options = {}) {
22
24
  });
23
25
  }
24
26
  if (commands.length === 0) {
27
+ (0, terminal_ui_1.printCommandWarn)("No update targets selected, nothing to do");
25
28
  return Promise.resolve();
26
29
  }
27
- return (0, concurrently_1.default)(commands).result;
30
+ return (0, concurrently_1.default)(commands).result.then(() => {
31
+ (0, terminal_ui_1.printCommandSuccess)("update", "Dependency update completed");
32
+ });
28
33
  }
29
34
  exports.default = update;
package/index.js CHANGED
@@ -51,8 +51,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
51
51
  const pack_1 = __importDefault(require("./commands/pack"));
52
52
  // 导入开发模式功能
53
53
  const develop_1 = __importStar(require("./commands/develop"));
54
- // 导入API生成功能
55
- const api_generate_1 = __importDefault(require("./commands/api-generate"));
56
54
  // 导入安装后处理功能
57
55
  const postinstall_1 = __importDefault(require("./commands/postinstall"));
58
56
  // 导入清理功能
@@ -96,10 +94,6 @@ function main() {
96
94
  skipNuxt: (0, cli_options_1.hasFlag)(options, "skip-nuxt"),
97
95
  });
98
96
  break;
99
- case "gen":
100
- // 生成API代码(注:此处命令可能拼写错误,应为generate)
101
- yield (0, api_generate_1.default)();
102
- break;
103
97
  case "install":
104
98
  // 执行安装后的初始化操作
105
99
  yield (0, postinstall_1.default)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-gin-tools",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
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"
@@ -0,0 +1,4 @@
1
+ export declare function printCommandBanner(command: string, subtitle: string): void;
2
+ export declare function printCommandSuccess(command: string, message: string): void;
3
+ export declare function printCommandInfo(label: string, message: string): void;
4
+ export declare function printCommandWarn(message: string): void;
@@ -0,0 +1,33 @@
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.printCommandBanner = printCommandBanner;
7
+ exports.printCommandSuccess = printCommandSuccess;
8
+ exports.printCommandInfo = printCommandInfo;
9
+ exports.printCommandWarn = printCommandWarn;
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ function line(width = 64) {
12
+ return "═".repeat(width);
13
+ }
14
+ 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);
24
+ }
25
+ function printCommandSuccess(command, message) {
26
+ console.log(chalk_1.default.green(`✔ ${command}: ${message}`));
27
+ }
28
+ function printCommandInfo(label, message) {
29
+ console.log(chalk_1.default.blueBright(`ℹ ${label}: ${message}`));
30
+ }
31
+ function printCommandWarn(message) {
32
+ console.warn(chalk_1.default.yellow(`⚠ ${message}`));
33
+ }