nsgm-cli 2.1.19 → 2.1.21

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.
Files changed (99) hide show
  1. package/client/components/Button.tsx +3 -3
  2. package/client/components/ClientProviders.tsx +12 -12
  3. package/client/components/LanguageSwitcher.tsx +26 -26
  4. package/client/components/SSRSafeAntdProvider.tsx +7 -7
  5. package/client/components/SuppressHydrationWarnings.tsx +30 -30
  6. package/client/components/__tests__/Button.test.tsx +12 -12
  7. package/client/layout/index.tsx +124 -124
  8. package/client/redux/reducers.ts +2 -2
  9. package/client/redux/store.ts +24 -24
  10. package/client/redux/template/manage/actions.ts +40 -40
  11. package/client/redux/template/manage/reducers.ts +32 -32
  12. package/client/redux/template/manage/types.ts +19 -19
  13. package/client/service/template/manage.ts +29 -29
  14. package/client/styled/common.ts +6 -6
  15. package/client/styled/layout/index.ts +17 -17
  16. package/client/styled/template/manage.ts +19 -19
  17. package/client/utils/common.ts +54 -54
  18. package/client/utils/cookie.ts +30 -30
  19. package/client/utils/fetch.ts +111 -111
  20. package/client/utils/i18n.ts +41 -41
  21. package/client/utils/menu.tsx +12 -12
  22. package/client/utils/navigation.ts +22 -22
  23. package/client/utils/sso.ts +124 -124
  24. package/client/utils/suppressWarnings.ts +17 -17
  25. package/generation/prettierrc +6 -0
  26. package/lib/args.js +19 -19
  27. package/lib/cli/app.d.ts +1 -1
  28. package/lib/cli/app.js +2 -2
  29. package/lib/cli/commands/build.d.ts +1 -1
  30. package/lib/cli/commands/build.js +9 -9
  31. package/lib/cli/commands/create.d.ts +1 -1
  32. package/lib/cli/commands/create.js +36 -36
  33. package/lib/cli/commands/delete.d.ts +1 -1
  34. package/lib/cli/commands/delete.js +55 -55
  35. package/lib/cli/commands/export.d.ts +1 -1
  36. package/lib/cli/commands/export.js +12 -12
  37. package/lib/cli/commands/help.d.ts +1 -1
  38. package/lib/cli/commands/help.js +29 -29
  39. package/lib/cli/commands/init.d.ts +1 -1
  40. package/lib/cli/commands/init.js +31 -31
  41. package/lib/cli/commands/server.d.ts +1 -1
  42. package/lib/cli/commands/server.js +12 -12
  43. package/lib/cli/commands/upgrade.d.ts +1 -1
  44. package/lib/cli/commands/upgrade.js +13 -13
  45. package/lib/cli/commands/version.d.ts +1 -1
  46. package/lib/cli/commands/version.js +7 -7
  47. package/lib/cli/index.d.ts +13 -13
  48. package/lib/cli/parser.d.ts +1 -1
  49. package/lib/cli/parser.js +12 -12
  50. package/lib/cli/registry.d.ts +1 -1
  51. package/lib/cli/types.d.ts +2 -2
  52. package/lib/cli/utils/console.d.ts +2 -2
  53. package/lib/cli/utils/console.js +22 -22
  54. package/lib/cli/utils/index.d.ts +2 -2
  55. package/lib/cli/utils/prompt.d.ts +1 -1
  56. package/lib/cli/utils/prompt.js +98 -98
  57. package/lib/constants.js +28 -28
  58. package/lib/generate.d.ts +2 -2
  59. package/lib/generate.js +19 -19
  60. package/lib/generate_create.d.ts +1 -1
  61. package/lib/generate_create.js +38 -38
  62. package/lib/generate_delete.js +63 -63
  63. package/lib/generate_init.js +94 -94
  64. package/lib/generators/base-generator.d.ts +1 -1
  65. package/lib/generators/base-generator.js +23 -23
  66. package/lib/generators/file-generator.js +15 -15
  67. package/lib/generators/generator-factory.d.ts +5 -5
  68. package/lib/generators/i18n-generator.d.ts +1 -1
  69. package/lib/generators/i18n-generator.js +127 -127
  70. package/lib/generators/page-generator.d.ts +1 -1
  71. package/lib/generators/page-generator.js +25 -25
  72. package/lib/generators/resolver-generator.d.ts +1 -1
  73. package/lib/generators/resolver-generator.js +27 -27
  74. package/lib/generators/schema-generator.d.ts +1 -1
  75. package/lib/generators/schema-generator.js +4 -4
  76. package/lib/generators/service-generator.d.ts +1 -1
  77. package/lib/generators/service-generator.js +29 -29
  78. package/lib/generators/sql-generator.d.ts +1 -1
  79. package/lib/generators/sql-generator.js +10 -10
  80. package/lib/index.js +23 -23
  81. package/lib/server/csrf.d.ts +3 -3
  82. package/lib/server/csrf.js +20 -20
  83. package/lib/server/db.d.ts +1 -1
  84. package/lib/server/db.js +21 -21
  85. package/lib/server/graphql.js +26 -26
  86. package/lib/server/plugins/date.d.ts +1 -1
  87. package/lib/server/plugins/date.js +6 -6
  88. package/lib/server/utils/graphql-cache.js +5 -5
  89. package/lib/tsconfig.build.tsbuildinfo +1 -1
  90. package/lib/utils/project-config.d.ts +1 -1
  91. package/lib/utils/project-config.js +20 -20
  92. package/lib/utils.js +3 -3
  93. package/package.json +1 -1
  94. package/pages/_app.tsx +62 -62
  95. package/pages/_document.tsx +15 -15
  96. package/pages/_error.tsx +26 -26
  97. package/pages/index.tsx +48 -48
  98. package/pages/login.tsx +64 -64
  99. package/pages/template/manage.tsx +175 -175
@@ -3,24 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startCommand = exports.devCommand = void 0;
4
4
  const index_1 = require("../../index");
5
5
  exports.devCommand = {
6
- name: 'dev',
6
+ name: "dev",
7
7
  aliases: [],
8
- description: '开发模式启动服务器',
9
- usage: 'nsgm dev',
10
- examples: ['nsgm dev'],
8
+ description: "开发模式启动服务器",
9
+ usage: "nsgm dev",
10
+ examples: ["nsgm dev"],
11
11
  execute: async (_options) => {
12
- console.log('🚀 启动开发服务器...');
13
- (0, index_1.startExpress)({ dev: true }, undefined, 'dev');
12
+ console.log("🚀 启动开发服务器...");
13
+ (0, index_1.startExpress)({ dev: true }, undefined, "dev");
14
14
  },
15
15
  };
16
16
  exports.startCommand = {
17
- name: 'start',
17
+ name: "start",
18
18
  aliases: [],
19
- description: '生产模式启动服务器',
20
- usage: 'nsgm start',
21
- examples: ['nsgm start'],
19
+ description: "生产模式启动服务器",
20
+ usage: "nsgm start",
21
+ examples: ["nsgm start"],
22
22
  execute: async (_options) => {
23
- console.log('🌟 启动生产服务器...');
24
- (0, index_1.startExpress)({ dev: false }, undefined, 'start');
23
+ console.log("🌟 启动生产服务器...");
24
+ (0, index_1.startExpress)({ dev: false }, undefined, "start");
25
25
  },
26
26
  };
@@ -1,2 +1,2 @@
1
- import { Command } from '../types';
1
+ import { Command } from "../types";
2
2
  export declare const upgradeCommand: Command;
@@ -4,34 +4,34 @@ exports.upgradeCommand = void 0;
4
4
  const parser_1 = require("../parser");
5
5
  const generate_1 = require("../../generate");
6
6
  exports.upgradeCommand = {
7
- name: 'upgrade',
8
- aliases: ['-u', '--upgrade'],
9
- description: '升级 NSGM 项目',
10
- usage: 'nsgm upgrade [dictionary]',
11
- examples: ['nsgm upgrade', 'nsgm upgrade myproject'],
7
+ name: "upgrade",
8
+ aliases: ["-u", "--upgrade"],
9
+ description: "升级 NSGM 项目",
10
+ usage: "nsgm upgrade [dictionary]",
11
+ examples: ["nsgm upgrade", "nsgm upgrade myproject"],
12
12
  options: [
13
13
  {
14
- name: 'dictionary',
15
- description: '项目目录名称',
16
- default: '',
17
- type: 'string',
14
+ name: "dictionary",
15
+ description: "项目目录名称",
16
+ default: "",
17
+ type: "string",
18
18
  },
19
19
  ],
20
20
  execute: async (options) => {
21
21
  try {
22
22
  const finalOptions = parser_1.ArgumentParser.applyDefaults(options, {
23
- dictionary: '',
23
+ dictionary: "",
24
24
  });
25
- console.log('⬆️ 升级 NSGM 项目...');
25
+ console.log("⬆️ 升级 NSGM 项目...");
26
26
  if (finalOptions.dictionary) {
27
27
  console.log(`📁 目录: ${finalOptions.dictionary}`);
28
28
  }
29
29
  (0, generate_1.initFiles)(finalOptions.dictionary, true);
30
- console.log('✅ 升级完成!');
30
+ console.log("✅ 升级完成!");
31
31
  process.exit(0);
32
32
  }
33
33
  catch (error) {
34
- console.error('❌ 升级失败:', error);
34
+ console.error("❌ 升级失败:", error);
35
35
  process.exit(1);
36
36
  }
37
37
  },
@@ -1,2 +1,2 @@
1
- import { Command } from '../types';
1
+ import { Command } from "../types";
2
2
  export declare const versionCommand: Command;
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versionCommand = void 0;
4
4
  exports.versionCommand = {
5
- name: 'version',
6
- aliases: ['-v', '--version'],
7
- description: '显示版本信息',
8
- usage: 'nsgm version',
9
- examples: ['nsgm version', 'nsgm -v'],
5
+ name: "version",
6
+ aliases: ["-v", "--version"],
7
+ description: "显示版本信息",
8
+ usage: "nsgm version",
9
+ examples: ["nsgm version", "nsgm -v"],
10
10
  execute: async () => {
11
11
  try {
12
- const { version } = require('../../../package.json');
12
+ const { version } = require("../../../package.json");
13
13
  console.log(`📦 NSGM CLI 版本: ${version}`);
14
14
  // 显示额外的环境信息
15
15
  console.log(`🔧 Node.js 版本: ${process.version}`);
@@ -17,7 +17,7 @@ exports.versionCommand = {
17
17
  process.exit(0);
18
18
  }
19
19
  catch (error) {
20
- console.error('❌ 无法获取版本信息:', error);
20
+ console.error("❌ 无法获取版本信息:", error);
21
21
  process.exit(1);
22
22
  }
23
23
  },
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * CLI 模块入口
3
3
  */
4
- export * from './types';
5
- export * from './parser';
6
- export * from './registry';
7
- export * from './app';
8
- export * from './commands/build';
9
- export * from './commands/create';
10
- export * from './commands/delete';
11
- export * from './commands/export';
12
- export * from './commands/help';
13
- export * from './commands/init';
14
- export * from './commands/server';
15
- export * from './commands/upgrade';
16
- export * from './commands/version';
4
+ export * from "./types";
5
+ export * from "./parser";
6
+ export * from "./registry";
7
+ export * from "./app";
8
+ export * from "./commands/build";
9
+ export * from "./commands/create";
10
+ export * from "./commands/delete";
11
+ export * from "./commands/export";
12
+ export * from "./commands/help";
13
+ export * from "./commands/init";
14
+ export * from "./commands/server";
15
+ export * from "./commands/upgrade";
16
+ export * from "./commands/version";
@@ -1,4 +1,4 @@
1
- import { CommandOptions, ParsedArgs } from './types';
1
+ import { CommandOptions, ParsedArgs } from "./types";
2
2
  /**
3
3
  * 改进的命令行参数解析器
4
4
  */
package/lib/cli/parser.js CHANGED
@@ -10,23 +10,23 @@ class ArgumentParser {
10
10
  */
11
11
  static parse(args = process.argv.slice(2)) {
12
12
  if (args.length === 0) {
13
- return { command: 'help', options: {} };
13
+ return { command: "help", options: {} };
14
14
  }
15
15
  const command = args[0];
16
16
  const options = {};
17
17
  // 解析参数
18
18
  for (let i = 1; i < args.length; i++) {
19
19
  const arg = args[i];
20
- if (arg.includes('=')) {
20
+ if (arg.includes("=")) {
21
21
  // 处理 key=value 格式
22
- const [key, value] = arg.split('=', 2);
22
+ const [key, value] = arg.split("=", 2);
23
23
  options[key.toLowerCase()] = value;
24
24
  }
25
- else if (arg.startsWith('--')) {
25
+ else if (arg.startsWith("--")) {
26
26
  // 处理 --key value 格式
27
27
  const key = arg.slice(2).toLowerCase();
28
28
  const nextArg = args[i + 1];
29
- if (nextArg && !nextArg.startsWith('-')) {
29
+ if (nextArg && !nextArg.startsWith("-")) {
30
30
  options[key] = nextArg;
31
31
  i++; // 跳过下一个参数
32
32
  }
@@ -34,11 +34,11 @@ class ArgumentParser {
34
34
  options[key] = true;
35
35
  }
36
36
  }
37
- else if (arg.startsWith('-')) {
37
+ else if (arg.startsWith("-")) {
38
38
  // 处理 -k value 格式
39
39
  const key = arg.slice(1).toLowerCase();
40
40
  const nextArg = args[i + 1];
41
- if (nextArg && !nextArg.startsWith('-')) {
41
+ if (nextArg && !nextArg.startsWith("-")) {
42
42
  options[key] = nextArg;
43
43
  i++; // 跳过下一个参数
44
44
  }
@@ -58,10 +58,10 @@ class ArgumentParser {
58
58
  * 解析位置参数(保持向后兼容)
59
59
  */
60
60
  static parsePositionalArgs(command, args, options) {
61
- const createCommands = ['create', '-c', 'delete', '-d', 'deletedb', '-db'];
62
- const initCommands = ['init', '-i', 'export'];
61
+ const createCommands = ["create", "-c", "delete", "-d", "deletedb", "-db"];
62
+ const initCommands = ["init", "-i", "export"];
63
63
  args.forEach((arg, index) => {
64
- if (arg.includes('=') || arg.startsWith('-')) {
64
+ if (arg.includes("=") || arg.startsWith("-")) {
65
65
  return; // 跳过已处理的参数
66
66
  }
67
67
  if (createCommands.includes(command)) {
@@ -93,7 +93,7 @@ class ArgumentParser {
93
93
  static validateRequired(options, required) {
94
94
  const missing = [];
95
95
  for (const key of required) {
96
- if (!options[key] || options[key] === '') {
96
+ if (!options[key] || options[key] === "") {
97
97
  missing.push(key);
98
98
  }
99
99
  }
@@ -105,7 +105,7 @@ class ArgumentParser {
105
105
  static applyDefaults(options, defaults) {
106
106
  const result = { ...options };
107
107
  for (const [key, value] of Object.entries(defaults)) {
108
- if (result[key] === undefined || result[key] === '') {
108
+ if (result[key] === undefined || result[key] === "") {
109
109
  result[key] = value;
110
110
  }
111
111
  }
@@ -1,4 +1,4 @@
1
- import { Command } from './types';
1
+ import { Command } from "./types";
2
2
  /**
3
3
  * CLI 命令注册表
4
4
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * CLI 类型定义
3
3
  */
4
- export * from './types/project';
4
+ export * from "./types/project";
5
5
  export interface CommandOptions {
6
6
  dictionary?: string;
7
7
  controller?: string;
@@ -23,7 +23,7 @@ export interface CommandOption {
23
23
  description: string;
24
24
  required?: boolean;
25
25
  default?: any;
26
- type?: 'string' | 'number' | 'boolean';
26
+ type?: "string" | "number" | "boolean";
27
27
  }
28
28
  export interface ParsedArgs {
29
29
  command: string;
@@ -45,7 +45,7 @@ export declare class Console {
45
45
  /**
46
46
  * 简单的加载动画
47
47
  */
48
- static spinner(text: string, color?: 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white'): {
48
+ static spinner(text: string, color?: "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white"): {
49
49
  start(): void;
50
50
  stop(): void;
51
51
  succeed(message?: string): void;
@@ -54,7 +54,7 @@ export declare class Console {
54
54
  /**
55
55
  * 带边框的消息
56
56
  */
57
- static box(message: string, type?: 'success' | 'error' | 'warning' | 'info'): void;
57
+ static box(message: string, type?: "success" | "error" | "warning" | "info"): void;
58
58
  /**
59
59
  * 进度条(简单版本)
60
60
  */
@@ -13,31 +13,31 @@ class Console {
13
13
  * 成功消息
14
14
  */
15
15
  static success(message) {
16
- console.log(chalk_1.default.green('') + chalk_1.default.white(message));
16
+ console.log(chalk_1.default.green("") + chalk_1.default.white(message));
17
17
  }
18
18
  /**
19
19
  * 错误消息
20
20
  */
21
21
  static error(message) {
22
- console.log(chalk_1.default.red('') + chalk_1.default.white(message));
22
+ console.log(chalk_1.default.red("") + chalk_1.default.white(message));
23
23
  }
24
24
  /**
25
25
  * 警告消息
26
26
  */
27
27
  static warning(message) {
28
- console.log(chalk_1.default.yellow('⚠️ ') + chalk_1.default.white(message));
28
+ console.log(chalk_1.default.yellow("⚠️ ") + chalk_1.default.white(message));
29
29
  }
30
30
  /**
31
31
  * 信息消息
32
32
  */
33
33
  static info(message) {
34
- console.log(chalk_1.default.blue('ℹ️ ') + chalk_1.default.white(message));
34
+ console.log(chalk_1.default.blue("ℹ️ ") + chalk_1.default.white(message));
35
35
  }
36
36
  /**
37
37
  * 调试消息
38
38
  */
39
39
  static debug(message) {
40
- console.log(chalk_1.default.gray('🐛 ') + chalk_1.default.gray(message));
40
+ console.log(chalk_1.default.gray("🐛 ") + chalk_1.default.gray(message));
41
41
  }
42
42
  /**
43
43
  * 标题
@@ -61,20 +61,20 @@ class Console {
61
61
  * 分隔线
62
62
  */
63
63
  static separator() {
64
- console.log(chalk_1.default.gray(''.repeat(50)));
64
+ console.log(chalk_1.default.gray("".repeat(50)));
65
65
  }
66
66
  /**
67
67
  * 空行
68
68
  */
69
69
  static newLine(count = 1) {
70
- console.log('\n'.repeat(count - 1));
70
+ console.log("\n".repeat(count - 1));
71
71
  }
72
72
  /**
73
73
  * 简单的加载动画
74
74
  */
75
- static spinner(text, color = 'cyan') {
75
+ static spinner(text, color = "cyan") {
76
76
  let spinnerInterval = null;
77
- const frames = ['', '', '', '', '', '', '', '', '', ''];
77
+ const frames = ["", "", "", "", "", "", "", "", "", ""];
78
78
  let currentFrame = 0;
79
79
  return {
80
80
  start() {
@@ -88,7 +88,7 @@ class Console {
88
88
  if (spinnerInterval) {
89
89
  clearInterval(spinnerInterval);
90
90
  spinnerInterval = null;
91
- process.stdout.write(`\r${' '.repeat(text.length + 2)}\r`);
91
+ process.stdout.write(`\r${" ".repeat(text.length + 2)}\r`);
92
92
  }
93
93
  },
94
94
  succeed(message) {
@@ -104,7 +104,7 @@ class Console {
104
104
  /**
105
105
  * 带边框的消息
106
106
  */
107
- static box(message, type = 'info') {
107
+ static box(message, type = "info") {
108
108
  const colors = {
109
109
  success: chalk_1.default.green,
110
110
  error: chalk_1.default.red,
@@ -112,20 +112,20 @@ class Console {
112
112
  info: chalk_1.default.blue,
113
113
  };
114
114
  const icons = {
115
- success: '',
116
- error: '',
117
- warning: '⚠️',
118
- info: 'ℹ️',
115
+ success: "",
116
+ error: "",
117
+ warning: "⚠️",
118
+ info: "ℹ️",
119
119
  };
120
120
  const color = colors[type];
121
121
  const icon = icons[type];
122
- const lines = message.split('\n');
122
+ const lines = message.split("\n");
123
123
  const maxLength = Math.max(...lines.map((line) => line.length));
124
- const border = ''.repeat(maxLength + 4);
124
+ const border = "".repeat(maxLength + 4);
125
125
  console.log(color(`┌${border}┐`));
126
- console.log(color(`│ ${icon} ${' '.repeat(maxLength - 1)} │`));
126
+ console.log(color(`│ ${icon} ${" ".repeat(maxLength - 1)} │`));
127
127
  lines.forEach((line) => {
128
- const padding = ' '.repeat(maxLength - line.length);
128
+ const padding = " ".repeat(maxLength - line.length);
129
129
  console.log(color(`│ ${line}${padding} │`));
130
130
  });
131
131
  console.log(color(`└${border}┘`));
@@ -133,12 +133,12 @@ class Console {
133
133
  /**
134
134
  * 进度条(简单版本)
135
135
  */
136
- static progress(current, total, description = '') {
136
+ static progress(current, total, description = "") {
137
137
  const percentage = Math.round((current / total) * 100);
138
138
  const completed = Math.round((current / total) * 20);
139
139
  const remaining = 20 - completed;
140
- const progressBar = chalk_1.default.green(''.repeat(completed)) + chalk_1.default.gray(''.repeat(remaining));
141
- const text = description ? ` ${description}` : '';
140
+ const progressBar = chalk_1.default.green("".repeat(completed)) + chalk_1.default.gray("".repeat(remaining));
141
+ const text = description ? ` ${description}` : "";
142
142
  process.stdout.write(`\r[${progressBar}] ${percentage}%${text}`);
143
143
  if (current === total) {
144
144
  console.log(); // 换行
@@ -1,2 +1,2 @@
1
- export { Console } from './console';
2
- export { Prompt } from './prompt';
1
+ export { Console } from "./console";
2
+ export { Prompt } from "./prompt";
@@ -1,6 +1,6 @@
1
1
  export interface FieldDefinition {
2
2
  name: string;
3
- type: 'varchar' | 'text' | 'integer' | 'decimal' | 'boolean' | 'date' | 'datetime' | 'timestamp';
3
+ type: "varchar" | "text" | "integer" | "decimal" | "boolean" | "date" | "datetime" | "timestamp";
4
4
  length?: string | number;
5
5
  required?: boolean;
6
6
  comment?: string;