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
@@ -40,69 +40,69 @@ const utils_1 = require("./utils");
40
40
  const fs_1 = require("fs");
41
41
  // 常量定义
42
42
  const CLIENT_FILES = {
43
- reduxStore: '/store.ts',
44
- styledCommon: '/common.ts',
45
- styledLayoutIndex: '/index.ts',
46
- utilsCommon: '/common.ts',
47
- utilsFetch: '/fetch.ts',
48
- utilsCookie: '/cookie.ts',
49
- utilsSso: '/sso.ts',
50
- utilsI18n: '/i18n.ts',
51
- utilsNavigation: '/navigation.ts',
52
- utilsSuppressWarnings: '/suppressWarnings.ts',
53
- layoutIndex: '/index.tsx',
54
- languageSwitcher: '/LanguageSwitcher.tsx',
55
- clientProviders: '/ClientProviders.tsx',
56
- ssrSafeAntdProvider: '/SSRSafeAntdProvider.tsx',
57
- suppressHydrationWarnings: '/SuppressHydrationWarnings.tsx',
43
+ reduxStore: "/store.ts",
44
+ styledCommon: "/common.ts",
45
+ styledLayoutIndex: "/index.ts",
46
+ utilsCommon: "/common.ts",
47
+ utilsFetch: "/fetch.ts",
48
+ utilsCookie: "/cookie.ts",
49
+ utilsSso: "/sso.ts",
50
+ utilsI18n: "/i18n.ts",
51
+ utilsNavigation: "/navigation.ts",
52
+ utilsSuppressWarnings: "/suppressWarnings.ts",
53
+ layoutIndex: "/index.tsx",
54
+ languageSwitcher: "/LanguageSwitcher.tsx",
55
+ clientProviders: "/ClientProviders.tsx",
56
+ ssrSafeAntdProvider: "/SSRSafeAntdProvider.tsx",
57
+ suppressHydrationWarnings: "/SuppressHydrationWarnings.tsx",
58
58
  };
59
59
  const PAGES_FILES = {
60
- index: '/index.tsx',
61
- app: '/_app.tsx',
62
- document: '/_document.tsx',
63
- login: '/login.tsx',
60
+ index: "/index.tsx",
61
+ app: "/_app.tsx",
62
+ document: "/_document.tsx",
63
+ login: "/login.tsx",
64
64
  };
65
65
  const SERVER_FILES = {
66
- apisSso: '/sso.js',
67
- utilsCommon: '/common.js',
68
- utilsDBPoolManager: '/db-pool-manager.js',
69
- utilsValidation: '/validation.js',
66
+ apisSso: "/sso.js",
67
+ utilsCommon: "/common.js",
68
+ utilsDBPoolManager: "/db-pool-manager.js",
69
+ utilsValidation: "/validation.js",
70
70
  };
71
71
  const PUBLIC_FILES = {
72
- images: '/images',
73
- fonts: '/fonts',
74
- favicon: '/favicon.ico',
75
- locales: '/locales',
72
+ images: "/images",
73
+ fonts: "/fonts",
74
+ favicon: "/favicon.ico",
75
+ locales: "/locales",
76
76
  };
77
77
  const SCRIPTS_FILES = {
78
- startup: '/startup.sh',
79
- shutdown: '/shutdown.sh',
80
- password: '/generate-password-hash.js',
78
+ startup: "/startup.sh",
79
+ shutdown: "/shutdown.sh",
80
+ password: "/generate-password-hash.js",
81
81
  };
82
82
  const ROOT_FILES = {
83
- nextConfig: '/next.config.js',
84
- nextI18nConfig: '/next-i18next.config.js',
85
- mysqlConfig: '/mysql.config.js',
86
- projectConfig: '/project.config.js',
87
- tsconfig: '/tsconfig.json',
88
- gitignoreSource: '/gitignore',
89
- gitignore: '/.gitignore',
90
- eslintrc: '/eslint.config.js',
91
- prettierrcSource: '/.prettierrc',
92
- prettierrc: '/.prettierrc',
93
- nextEnvSource: '../next-env.d.ts',
94
- nextEnv: '/next-env.d.ts',
95
- readme: '/README.md',
96
- appConfigSource: '../app.config.js',
97
- appConfig: '/app.config.js',
98
- app: '/app.js',
99
- envExampleSource: '/env.example',
100
- envExample: '/.env.example',
101
- envSource: '/env',
102
- env: '/.env',
103
- jestConfig: '/jest.config.js',
104
- jestSetup: '/jest.setup.js',
105
- jestSetupGlobals: '/jest.setup-globals.js',
83
+ nextConfig: "/next.config.js",
84
+ nextI18nConfig: "/next-i18next.config.js",
85
+ mysqlConfig: "/mysql.config.js",
86
+ projectConfig: "/project.config.js",
87
+ tsconfig: "/tsconfig.json",
88
+ gitignoreSource: "/gitignore",
89
+ gitignore: "/.gitignore",
90
+ eslintrc: "/eslint.config.js",
91
+ prettierrcSource: "/prettierrc",
92
+ prettierrc: "/.prettierrc",
93
+ nextEnvSource: "../next-env.d.ts",
94
+ nextEnv: "/next-env.d.ts",
95
+ readme: "/README.md",
96
+ appConfigSource: "../app.config.js",
97
+ appConfig: "/app.config.js",
98
+ app: "/app.js",
99
+ envExampleSource: "/env.example",
100
+ envExample: "/.env.example",
101
+ envSource: "/env",
102
+ env: "/.env",
103
+ jestConfig: "/jest.config.js",
104
+ jestSetup: "/jest.setup.js",
105
+ jestSetupGlobals: "/jest.setup-globals.js",
106
106
  };
107
107
  // 辅助函数
108
108
  const createDirectoryStructure = (directories) => {
@@ -120,10 +120,10 @@ const copyMultipleFiles = (fileMappings) => {
120
120
  * @param upgradeFlag 是否为升级模式
121
121
  */
122
122
  const initClientFiles = (dictionary, newDestFolder, upgradeFlag) => {
123
- console.log('Initializing client files...');
123
+ console.log("Initializing client files...");
124
124
  try {
125
125
  // 1. 确定目标路径
126
- const baseDestPath = dictionary === '' ? constants_1.destClientPath : path_1.default.join(newDestFolder, constants_1.clientPath);
126
+ const baseDestPath = dictionary === "" ? constants_1.destClientPath : path_1.default.join(newDestFolder, constants_1.clientPath);
127
127
  const destPaths = {
128
128
  client: baseDestPath,
129
129
  redux: (0, path_1.resolve)(baseDestPath + constants_1.reduxPath),
@@ -232,14 +232,14 @@ const initClientFiles = (dictionary, newDestFolder, upgradeFlag) => {
232
232
  ];
233
233
  // 4. 复制文件
234
234
  copyMultipleFiles(fileMappings);
235
- console.log('Client files initialization completed');
235
+ console.log("Client files initialization completed");
236
236
  return {
237
237
  destClientUtilsMenuPath: (0, path_1.resolve)(destPaths.utils + constants_1.utilsMenuPath),
238
238
  destClientReduxReducersAllPath: (0, path_1.resolve)(destPaths.redux + constants_1.reduxReducersPath),
239
239
  };
240
240
  }
241
241
  catch (error) {
242
- console.error('Failed to initialize client files:', error);
242
+ console.error("Failed to initialize client files:", error);
243
243
  throw error;
244
244
  }
245
245
  };
@@ -251,10 +251,10 @@ exports.initClientFiles = initClientFiles;
251
251
  * @param upgradeFlag 是否为升级模式
252
252
  */
253
253
  const initPagesFiles = (dictionary, newDestFolder, upgradeFlag) => {
254
- console.log('Initializing pages files...');
254
+ console.log("Initializing pages files...");
255
255
  try {
256
256
  // 1. 确定目标路径
257
- const baseDestPath = dictionary === '' ? constants_1.destPagesPath : path_1.default.join(newDestFolder, constants_1.pagesPath);
257
+ const baseDestPath = dictionary === "" ? constants_1.destPagesPath : path_1.default.join(newDestFolder, constants_1.pagesPath);
258
258
  // 2. 创建目录
259
259
  createDirectoryStructure([baseDestPath]);
260
260
  // 3. 定义文件映射
@@ -282,10 +282,10 @@ const initPagesFiles = (dictionary, newDestFolder, upgradeFlag) => {
282
282
  ];
283
283
  // 4. 复制文件
284
284
  copyMultipleFiles(fileMappings);
285
- console.log('Pages files initialization completed');
285
+ console.log("Pages files initialization completed");
286
286
  }
287
287
  catch (error) {
288
- console.error('Failed to initialize pages files:', error);
288
+ console.error("Failed to initialize pages files:", error);
289
289
  throw error;
290
290
  }
291
291
  };
@@ -297,10 +297,10 @@ exports.initPagesFiles = initPagesFiles;
297
297
  * @param upgradeFlag 是否为升级模式
298
298
  */
299
299
  const initServerFiles = (dictionary, newDestFolder, upgradeFlag) => {
300
- console.log('Initializing server files...');
300
+ console.log("Initializing server files...");
301
301
  try {
302
302
  // 1. 确定目标路径
303
- const baseDestPath = dictionary === '' ? constants_1.destServerPath : path_1.default.join(newDestFolder, constants_1.serverPath);
303
+ const baseDestPath = dictionary === "" ? constants_1.destServerPath : path_1.default.join(newDestFolder, constants_1.serverPath);
304
304
  const destPaths = {
305
305
  server: baseDestPath,
306
306
  apis: (0, path_1.resolve)(baseDestPath + constants_1.apisPath),
@@ -339,13 +339,13 @@ const initServerFiles = (dictionary, newDestFolder, upgradeFlag) => {
339
339
  ];
340
340
  // 4. 复制文件
341
341
  copyMultipleFiles(fileMappings);
342
- console.log('Server files initialization completed');
342
+ console.log("Server files initialization completed");
343
343
  return {
344
344
  destServerRestPath: (0, path_1.resolve)(destPaths.server + constants_1.restPath),
345
345
  };
346
346
  }
347
347
  catch (error) {
348
- console.error('Failed to initialize server files:', error);
348
+ console.error("Failed to initialize server files:", error);
349
349
  throw error;
350
350
  }
351
351
  };
@@ -357,10 +357,10 @@ exports.initServerFiles = initServerFiles;
357
357
  * @param upgradeFlag 是否为升级模式
358
358
  */
359
359
  const initPublicFiles = (dictionary, newDestFolder, upgradeFlag) => {
360
- console.log('Initializing public files...');
360
+ console.log("Initializing public files...");
361
361
  try {
362
362
  // 1. 确定目标路径
363
- const baseDestPath = dictionary === '' ? constants_1.destPublicPath : path_1.default.join(newDestFolder, constants_1.publicPath);
363
+ const baseDestPath = dictionary === "" ? constants_1.destPublicPath : path_1.default.join(newDestFolder, constants_1.publicPath);
364
364
  const destPaths = {
365
365
  public: baseDestPath,
366
366
  images: (0, path_1.resolve)(baseDestPath + PUBLIC_FILES.images),
@@ -414,13 +414,13 @@ const initPublicFiles = (dictionary, newDestFolder, upgradeFlag) => {
414
414
  };
415
415
  copyLocalesRecursive(sourceLocalesDir, destPaths.locales);
416
416
  }
417
- console.log('Public files initialization completed');
417
+ console.log("Public files initialization completed");
418
418
  return {
419
419
  destPublicHealthCheckPath: (0, path_1.resolve)(destPaths.public + constants_1.slbHealthCheckPath),
420
420
  };
421
421
  }
422
422
  catch (error) {
423
- console.error('Failed to initialize public files:', error);
423
+ console.error("Failed to initialize public files:", error);
424
424
  throw error;
425
425
  }
426
426
  };
@@ -431,10 +431,10 @@ exports.initPublicFiles = initPublicFiles;
431
431
  * @param newDestFolder 新的目标文件夹路径
432
432
  */
433
433
  const initScriptsFiles = (dictionary, newDestFolder) => {
434
- console.log('Initializing scripts files...');
434
+ console.log("Initializing scripts files...");
435
435
  try {
436
436
  // 1. 确定目标路径
437
- const baseDestPath = dictionary === '' ? constants_1.destScriptsPath : path_1.default.join(newDestFolder, constants_1.scriptsPath);
437
+ const baseDestPath = dictionary === "" ? constants_1.destScriptsPath : path_1.default.join(newDestFolder, constants_1.scriptsPath);
438
438
  // 2. 创建目录
439
439
  createDirectoryStructure([baseDestPath]);
440
440
  // 3. 定义文件映射(脚本文件通常不使用 upgradeFlag)
@@ -454,10 +454,10 @@ const initScriptsFiles = (dictionary, newDestFolder) => {
454
454
  ];
455
455
  // 4. 复制文件
456
456
  copyMultipleFiles(fileMappings);
457
- console.log('Scripts files initialization completed');
457
+ console.log("Scripts files initialization completed");
458
458
  }
459
459
  catch (error) {
460
- console.error('Failed to initialize scripts files:', error);
460
+ console.error("Failed to initialize scripts files:", error);
461
461
  throw error;
462
462
  }
463
463
  };
@@ -468,10 +468,10 @@ exports.initScriptsFiles = initScriptsFiles;
468
468
  * @param newDestFolder 新的目标文件夹路径
469
469
  */
470
470
  const initRootFiles = (dictionary, newDestFolder) => {
471
- console.log('Initializing root files...');
471
+ console.log("Initializing root files...");
472
472
  try {
473
473
  // 1. 确定目标路径
474
- const baseDestPath = dictionary === '' ? constants_1.destFolder : newDestFolder;
474
+ const baseDestPath = dictionary === "" ? constants_1.destFolder : newDestFolder;
475
475
  // 2. 定义文件映射(根文件通常不使用 upgradeFlag)
476
476
  const fileMappings = [
477
477
  {
@@ -479,7 +479,7 @@ const initRootFiles = (dictionary, newDestFolder) => {
479
479
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.nextConfig),
480
480
  },
481
481
  {
482
- source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, '..', ROOT_FILES.nextI18nConfig)),
482
+ source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, "..", ROOT_FILES.nextI18nConfig)),
483
483
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.nextI18nConfig),
484
484
  },
485
485
  {
@@ -507,7 +507,7 @@ const initRootFiles = (dictionary, newDestFolder) => {
507
507
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.eslintrc),
508
508
  },
509
509
  {
510
- source: path_1.default.join(constants_1.sourceFolder, '..', ROOT_FILES.prettierrcSource),
510
+ source: (0, path_1.resolve)(constants_1.sourceGenerationPath + ROOT_FILES.prettierrcSource),
511
511
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.prettierrc),
512
512
  },
513
513
  {
@@ -539,23 +539,23 @@ const initRootFiles = (dictionary, newDestFolder) => {
539
539
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.jestConfig),
540
540
  },
541
541
  {
542
- source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, '..', ROOT_FILES.jestSetup)),
542
+ source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, "..", ROOT_FILES.jestSetup)),
543
543
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.jestSetup),
544
544
  },
545
545
  {
546
- source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, '..', ROOT_FILES.jestSetupGlobals)),
546
+ source: (0, path_1.resolve)(path_1.default.join(constants_1.sourceFolder, "..", ROOT_FILES.jestSetupGlobals)),
547
547
  dest: (0, path_1.resolve)(baseDestPath + ROOT_FILES.jestSetupGlobals),
548
548
  },
549
549
  ];
550
550
  // 3. 复制文件
551
551
  copyMultipleFiles(fileMappings);
552
- console.log('Root files initialization completed');
552
+ console.log("Root files initialization completed");
553
553
  return {
554
554
  destPackagePath: (0, path_1.resolve)(baseDestPath + constants_1.packagePath),
555
555
  };
556
556
  }
557
557
  catch (error) {
558
- console.error('Failed to initialize root files:', error);
558
+ console.error("Failed to initialize root files:", error);
559
559
  throw error;
560
560
  }
561
561
  };
@@ -566,22 +566,22 @@ exports.initRootFiles = initRootFiles;
566
566
  * @param newDestFolder 新的目标文件夹路径
567
567
  */
568
568
  const initTypesFiles = (dictionary, newDestFolder) => {
569
- console.log('Initializing types files...');
569
+ console.log("Initializing types files...");
570
570
  try {
571
571
  // 1. 确定目标路径
572
- const baseDestPath = dictionary === '' ? constants_1.destTypesPath : path_1.default.join(newDestFolder, constants_1.typesPath);
572
+ const baseDestPath = dictionary === "" ? constants_1.destTypesPath : path_1.default.join(newDestFolder, constants_1.typesPath);
573
573
  // 2. 创建目录
574
574
  createDirectoryStructure([baseDestPath]);
575
575
  // 3. 复制 i18next.d.ts 文件
576
- const sourceI18nextFile = (0, path_1.resolve)(constants_1.destFolder, 'types', 'i18next.d.ts');
577
- const destI18nextFile = (0, path_1.resolve)(baseDestPath, 'i18next.d.ts');
576
+ const sourceI18nextFile = (0, path_1.resolve)(constants_1.destFolder, "types", "i18next.d.ts");
577
+ const destI18nextFile = (0, path_1.resolve)(baseDestPath, "i18next.d.ts");
578
578
  if ((0, fs_1.existsSync)(sourceI18nextFile)) {
579
579
  (0, utils_1.copyFileSync)(sourceI18nextFile, destI18nextFile);
580
580
  }
581
- console.log('Types files initialization completed');
581
+ console.log("Types files initialization completed");
582
582
  }
583
583
  catch (error) {
584
- console.error('Failed to initialize types files:', error);
584
+ console.error("Failed to initialize types files:", error);
585
585
  throw error;
586
586
  }
587
587
  };
@@ -592,26 +592,26 @@ exports.initTypesFiles = initTypesFiles;
592
592
  * @param newDestFolder 新的目标文件夹路径
593
593
  */
594
594
  const initTestFiles = (dictionary, newDestFolder) => {
595
- console.log('Initializing test files...');
595
+ console.log("Initializing test files...");
596
596
  try {
597
597
  // 1. 确定目标路径
598
- const baseDestPath = dictionary === '' ? constants_1.destFolder : newDestFolder;
599
- const testDestPath = path_1.default.join(baseDestPath, '__tests__');
598
+ const baseDestPath = dictionary === "" ? constants_1.destFolder : newDestFolder;
599
+ const testDestPath = path_1.default.join(baseDestPath, "__tests__");
600
600
  // 2. 创建测试目录
601
601
  createDirectoryStructure([testDestPath]);
602
602
  // 3. 定义文件映射
603
603
  const fileMappings = [
604
604
  {
605
- source: path_1.default.join(constants_1.sourceGenerationPath, '__tests__', 'example.test.js'),
606
- dest: path_1.default.join(testDestPath, 'example.test.js'),
605
+ source: path_1.default.join(constants_1.sourceGenerationPath, "__tests__", "example.test.js"),
606
+ dest: path_1.default.join(testDestPath, "example.test.js"),
607
607
  },
608
608
  ];
609
609
  // 4. 复制文件
610
610
  copyMultipleFiles(fileMappings);
611
- console.log('Test files initialization completed');
611
+ console.log("Test files initialization completed");
612
612
  }
613
613
  catch (error) {
614
- console.error('Failed to initialize test files:', error);
614
+ console.error("Failed to initialize test files:", error);
615
615
  throw error;
616
616
  }
617
617
  };
@@ -1,4 +1,4 @@
1
- import { FieldDefinition } from '../cli/utils/prompt';
1
+ import { FieldDefinition } from "../cli/utils/prompt";
2
2
  /**
3
3
  * 基础生成器抽象类
4
4
  * 定义所有代码生成器的通用接口
@@ -52,14 +52,14 @@ class BaseGenerator {
52
52
  */
53
53
  getGraphQLType(fieldType) {
54
54
  switch (fieldType) {
55
- case 'integer':
56
- return 'Int';
57
- case 'decimal':
58
- return 'Float';
59
- case 'boolean':
60
- return 'Boolean';
55
+ case "integer":
56
+ return "Int";
57
+ case "decimal":
58
+ return "Float";
59
+ case "boolean":
60
+ return "Boolean";
61
61
  default:
62
- return 'String';
62
+ return "String";
63
63
  }
64
64
  }
65
65
  /**
@@ -67,25 +67,25 @@ class BaseGenerator {
67
67
  */
68
68
  getSQLType(field) {
69
69
  switch (field.type) {
70
- case 'varchar':
70
+ case "varchar":
71
71
  return `varchar(${field.length || 255})`;
72
- case 'text':
73
- return 'text';
74
- case 'integer':
75
- return 'integer';
76
- case 'decimal':
77
- const [precision, scale] = (field.length || '10,2').toString().split(',');
72
+ case "text":
73
+ return "text";
74
+ case "integer":
75
+ return "integer";
76
+ case "decimal":
77
+ const [precision, scale] = (field.length || "10,2").toString().split(",");
78
78
  return `decimal(${precision || 10},${scale || 2})`;
79
- case 'boolean':
80
- return 'boolean';
81
- case 'date':
82
- return 'date';
83
- case 'datetime':
84
- return 'datetime';
85
- case 'timestamp':
86
- return 'TIMESTAMP(3)';
79
+ case "boolean":
80
+ return "boolean";
81
+ case "date":
82
+ return "date";
83
+ case "datetime":
84
+ return "datetime";
85
+ case "timestamp":
86
+ return "TIMESTAMP(3)";
87
87
  default:
88
- return 'varchar(255)';
88
+ return "varchar(255)";
89
89
  }
90
90
  }
91
91
  }
@@ -42,7 +42,7 @@ const path = __importStar(require("path"));
42
42
  * 负责将生成的内容写入到文件系统
43
43
  */
44
44
  class FileGenerator {
45
- constructor(projectPath = '.') {
45
+ constructor(projectPath = ".") {
46
46
  this.projectPath = projectPath;
47
47
  }
48
48
  /**
@@ -52,20 +52,20 @@ class FileGenerator {
52
52
  const i18nGenerator = new i18n_generator_1.I18nGenerator(controller, action, fields);
53
53
  // 定义支持的语言
54
54
  const locales = [
55
- { code: 'zh-CN', generator: () => i18nGenerator.generateChineseTranslation() },
56
- { code: 'en-US', generator: () => i18nGenerator.generateEnglishTranslation() },
57
- { code: 'ja-JP', generator: () => i18nGenerator.generateJapaneseTranslation() },
55
+ { code: "zh-CN", generator: () => i18nGenerator.generateChineseTranslation() },
56
+ { code: "en-US", generator: () => i18nGenerator.generateEnglishTranslation() },
57
+ { code: "ja-JP", generator: () => i18nGenerator.generateJapaneseTranslation() },
58
58
  ];
59
59
  // 为每种语言生成文件
60
60
  locales.forEach((locale) => {
61
- const localeDir = path.join(this.projectPath, 'public', 'locales', locale.code);
61
+ const localeDir = path.join(this.projectPath, "public", "locales", locale.code);
62
62
  const filePath = path.join(localeDir, `${controller}.json`);
63
63
  // 确保目录存在
64
64
  this.ensureDirectoryExists(localeDir);
65
65
  // 生成内容
66
66
  const content = locale.generator();
67
67
  // 写入文件
68
- fs.writeFileSync(filePath, content, 'utf8');
68
+ fs.writeFileSync(filePath, content, "utf8");
69
69
  console.log(`✅ 生成多语言文件: ${filePath}`);
70
70
  });
71
71
  }
@@ -73,53 +73,53 @@ class FileGenerator {
73
73
  * 生成页面组件文件
74
74
  */
75
75
  generatePageFile(controller, action, _fields, content) {
76
- const pageDir = path.join(this.projectPath, 'pages', controller);
76
+ const pageDir = path.join(this.projectPath, "pages", controller);
77
77
  const filePath = path.join(pageDir, `${action}.tsx`);
78
78
  // 确保目录存在
79
79
  this.ensureDirectoryExists(pageDir);
80
80
  // 写入文件
81
- fs.writeFileSync(filePath, content, 'utf8');
81
+ fs.writeFileSync(filePath, content, "utf8");
82
82
  console.log(`✅ 生成页面文件: ${filePath}`);
83
83
  }
84
84
  /**
85
85
  * 生成样式文件
86
86
  */
87
87
  generateStyleFile(controller, action) {
88
- const styleDir = path.join(this.projectPath, 'client', 'styled', controller);
88
+ const styleDir = path.join(this.projectPath, "client", "styled", controller);
89
89
  const filePath = path.join(styleDir, `${action}.ts`);
90
90
  // 确保目录存在
91
91
  this.ensureDirectoryExists(styleDir);
92
92
  const content = this.generateStyledComponentsContent(controller, action);
93
93
  // 写入文件
94
- fs.writeFileSync(filePath, content, 'utf8');
94
+ fs.writeFileSync(filePath, content, "utf8");
95
95
  console.log(`✅ 生成样式文件: ${filePath}`);
96
96
  }
97
97
  /**
98
98
  * 生成Redux相关文件
99
99
  */
100
100
  generateReduxFiles(controller, action, _fields) {
101
- const reduxDir = path.join(this.projectPath, 'client', 'redux', controller, action);
101
+ const reduxDir = path.join(this.projectPath, "client", "redux", controller, action);
102
102
  // 确保目录存在
103
103
  this.ensureDirectoryExists(reduxDir);
104
104
  // 生成actions文件
105
105
  const actionsContent = this.generateActionsContent(controller, action);
106
- fs.writeFileSync(path.join(reduxDir, 'actions.ts'), actionsContent, 'utf8');
106
+ fs.writeFileSync(path.join(reduxDir, "actions.ts"), actionsContent, "utf8");
107
107
  // 生成reducer文件
108
108
  const reducerContent = this.generateReducerContent(controller, action);
109
- fs.writeFileSync(path.join(reduxDir, 'reducer.ts'), reducerContent, 'utf8');
109
+ fs.writeFileSync(path.join(reduxDir, "reducer.ts"), reducerContent, "utf8");
110
110
  console.log(`✅ 生成Redux文件: ${reduxDir}`);
111
111
  }
112
112
  /**
113
113
  * 生成服务文件
114
114
  */
115
115
  generateServiceFile(controller, action) {
116
- const serviceDir = path.join(this.projectPath, 'client', 'service', controller);
116
+ const serviceDir = path.join(this.projectPath, "client", "service", controller);
117
117
  const filePath = path.join(serviceDir, `${action}.ts`);
118
118
  // 确保目录存在
119
119
  this.ensureDirectoryExists(serviceDir);
120
120
  const content = this.generateServiceContent(controller, action);
121
121
  // 写入文件
122
- fs.writeFileSync(filePath, content, 'utf8');
122
+ fs.writeFileSync(filePath, content, "utf8");
123
123
  console.log(`✅ 生成服务文件: ${filePath}`);
124
124
  }
125
125
  /**
@@ -1,8 +1,8 @@
1
- import { SQLGenerator } from './sql-generator';
2
- import { SchemaGenerator } from './schema-generator';
3
- import { ResolverGenerator } from './resolver-generator';
4
- import { ServiceGenerator } from './service-generator';
5
- import { FieldDefinition } from '../cli/utils/prompt';
1
+ import { SQLGenerator } from "./sql-generator";
2
+ import { SchemaGenerator } from "./schema-generator";
3
+ import { ResolverGenerator } from "./resolver-generator";
4
+ import { ServiceGenerator } from "./service-generator";
5
+ import { FieldDefinition } from "../cli/utils/prompt";
6
6
  /**
7
7
  * 代码生成器工厂
8
8
  * 统一管理所有代码生成器
@@ -1,4 +1,4 @@
1
- import { BaseGenerator } from './base-generator';
1
+ import { BaseGenerator } from "./base-generator";
2
2
  /**
3
3
  * 国际化文件生成器
4
4
  * 生成控制器对应的多语言文件