@moluoxixi/create-app 2.0.4 → 2.0.403

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 (264) hide show
  1. package/LICENSE.txt +21 -21
  2. package/README.md +129 -129
  3. package/dist/commands/create.d.ts +2 -1
  4. package/dist/commands/create.js +12 -8
  5. package/dist/commands/index.d.ts +1 -2
  6. package/dist/commands/index.js +1 -2
  7. package/dist/constants/index.d.ts +17 -0
  8. package/dist/constants/index.js +17 -0
  9. package/dist/generators/index.d.ts +3 -4
  10. package/dist/generators/index.js +3 -4
  11. package/dist/generators/project.d.ts +3 -2
  12. package/dist/generators/project.js +5 -4
  13. package/dist/generators/react.d.ts +4 -2
  14. package/dist/generators/react.js +10 -30
  15. package/dist/generators/vue.d.ts +4 -2
  16. package/dist/generators/vue.js +10 -31
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.js +21 -3
  19. package/dist/test.d.ts +5 -2
  20. package/dist/test.js +252 -206
  21. package/dist/types/ejs.d.ts +0 -1
  22. package/dist/types/ejs.js +0 -1
  23. package/dist/types/features.d.ts +1 -2
  24. package/dist/types/features.js +1 -1
  25. package/dist/types/index.d.ts +2 -4
  26. package/dist/types/index.js +2 -4
  27. package/dist/types/packageJson.d.ts +24 -0
  28. package/dist/types/packageJson.js +4 -0
  29. package/dist/types/viteConfig.d.ts +11 -9
  30. package/dist/types/viteConfig.js +0 -1
  31. package/dist/utils/deepMerge.d.ts +3 -1
  32. package/dist/utils/deepMerge.js +8 -1
  33. package/dist/utils/ejs.d.ts +3 -2
  34. package/dist/utils/ejs.js +2 -1
  35. package/dist/utils/featureMapping.d.ts +44 -0
  36. package/dist/utils/featureMapping.js +119 -0
  37. package/dist/utils/file.d.ts +22 -2
  38. package/dist/utils/file.js +35 -2
  39. package/dist/utils/generateFrameworkProject.d.ts +27 -0
  40. package/dist/utils/generateFrameworkProject.js +47 -0
  41. package/dist/utils/index.d.ts +11 -9
  42. package/dist/utils/index.js +11 -9
  43. package/dist/utils/install.d.ts +7 -4
  44. package/dist/utils/install.js +55 -12
  45. package/dist/utils/npmConfig.d.ts +15 -0
  46. package/dist/utils/npmConfig.js +79 -0
  47. package/dist/utils/prompts.d.ts +3 -2
  48. package/dist/utils/prompts.js +51 -5
  49. package/dist/utils/renderFeatures.d.ts +3 -2
  50. package/dist/utils/renderFeatures.js +41 -37
  51. package/dist/utils/renderTemplate.d.ts +13 -1
  52. package/dist/utils/renderTemplate.js +128 -61
  53. package/dist/utils/sortDependencies.d.ts +3 -2
  54. package/dist/utils/sortDependencies.js +3 -2
  55. package/dist/utils/viteConfigRender.d.ts +11 -14
  56. package/dist/utils/viteConfigRender.js +10 -173
  57. package/package.json +4 -2
  58. package/templates/common/base/.env +7 -7
  59. package/templates/common/base/.env.development +5 -5
  60. package/templates/common/base/.env.production +5 -5
  61. package/templates/common/base/package.json +23 -27
  62. package/templates/common/base/scripts/build.mts +37 -31
  63. package/templates/common/base/src/apis/index.ts +8 -8
  64. package/templates/common/base/src/apis/request.ts +43 -43
  65. package/templates/common/base/src/apis/services/example.ts +61 -40
  66. package/templates/common/base/src/apis/services/user.ts +33 -23
  67. package/templates/common/base/src/apis/types/common.ts +43 -28
  68. package/templates/common/base/src/apis/types/example.ts +15 -3
  69. package/templates/common/base/src/apis/types/index.ts +7 -7
  70. package/templates/common/base/src/apis/types/user.ts +39 -24
  71. package/templates/common/base/src/assets/fonts/index.css +7 -7
  72. package/templates/common/base/src/assets/styles/base.scss +72 -72
  73. package/templates/common/base/src/assets/styles/custom.scss +7 -7
  74. package/templates/common/base/src/assets/styles/tailwind.scss +6 -6
  75. package/templates/common/base/src/constants/index.ts +29 -29
  76. package/templates/common/base/src/utils/index.ts +88 -83
  77. package/templates/{vue/base/vite.config.ts → common/base/vite.config.ts.ejs} +28 -11
  78. package/templates/common/features/husky/.cz-config.cjs +35 -35
  79. package/templates/common/features/husky/commitlint.config.ts +32 -32
  80. package/templates/common/features/husky/node_modules/.bin/commitizen +17 -0
  81. package/templates/common/features/husky/node_modules/.bin/commitizen.CMD +12 -0
  82. package/templates/common/features/husky/node_modules/.bin/commitizen.ps1 +41 -0
  83. package/templates/common/features/husky/node_modules/.bin/commitlint +17 -0
  84. package/templates/common/features/husky/node_modules/.bin/commitlint.CMD +12 -0
  85. package/templates/common/features/husky/node_modules/.bin/commitlint.ps1 +41 -0
  86. package/templates/common/features/husky/node_modules/.bin/cz +17 -0
  87. package/templates/common/features/husky/node_modules/.bin/cz-cust +17 -0
  88. package/templates/common/features/husky/node_modules/.bin/cz-cust.CMD +12 -0
  89. package/templates/common/features/husky/node_modules/.bin/cz-cust.ps1 +41 -0
  90. package/templates/common/features/husky/node_modules/.bin/cz-customizable +17 -0
  91. package/templates/common/features/husky/node_modules/.bin/cz-customizable.CMD +12 -0
  92. package/templates/common/features/husky/node_modules/.bin/cz-customizable.ps1 +41 -0
  93. package/templates/common/features/husky/node_modules/.bin/cz.CMD +12 -0
  94. package/templates/common/features/husky/node_modules/.bin/cz.ps1 +41 -0
  95. package/templates/common/features/husky/node_modules/.bin/git-cz +17 -0
  96. package/templates/common/features/husky/node_modules/.bin/git-cz.CMD +12 -0
  97. package/templates/common/features/husky/node_modules/.bin/git-cz.ps1 +41 -0
  98. package/templates/common/features/husky/node_modules/.bin/husky +17 -0
  99. package/templates/common/features/husky/node_modules/.bin/husky.CMD +12 -0
  100. package/templates/common/features/husky/node_modules/.bin/husky.ps1 +41 -0
  101. package/templates/common/features/husky/node_modules/.bin/lint-staged +17 -0
  102. package/templates/common/features/husky/node_modules/.bin/lint-staged.CMD +12 -0
  103. package/templates/common/features/husky/node_modules/.bin/lint-staged.ps1 +41 -0
  104. package/templates/common/features/husky/package.json +6 -6
  105. package/templates/react/base/env.d.ts +19 -19
  106. package/templates/react/base/index.html +14 -14
  107. package/templates/react/base/node_modules/.bin/vite +17 -0
  108. package/templates/react/base/node_modules/.bin/vite.CMD +12 -0
  109. package/templates/react/base/node_modules/.bin/vite.ps1 +41 -0
  110. package/templates/react/base/package.json +18 -15
  111. package/templates/react/base/src/App.tsx +18 -18
  112. package/templates/react/base/src/assets/styles/main.scss +8 -8
  113. package/templates/react/base/src/main.tsx.ejs +51 -6
  114. package/templates/react/base/src/pages/about/index.tsx +14 -14
  115. package/templates/react/base/src/pages/home/index.tsx +14 -14
  116. package/templates/react/base/tsconfig.app.json +17 -17
  117. package/templates/react/base/tsconfig.base.json +23 -23
  118. package/templates/react/base/tsconfig.json +12 -12
  119. package/templates/react/base/tsconfig.node.json +15 -15
  120. package/templates/react/features/ant-design/package.json +6 -7
  121. package/templates/react/features/eslint/node_modules/.bin/eslint +17 -0
  122. package/templates/react/features/eslint/node_modules/.bin/eslint.CMD +12 -0
  123. package/templates/react/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
  124. package/templates/react/features/eslint/package.json +3 -3
  125. package/templates/react/features/i18n/package.json +6 -7
  126. package/templates/react/features/i18n/src/locales/index.ts +7 -0
  127. package/templates/{common/base → react/features/i18n}/src/locales/lang/en.ts +30 -30
  128. package/templates/{common/base → react/features/i18n}/src/locales/lang/es.ts +30 -30
  129. package/templates/{common/base → react/features/i18n}/src/locales/lang/zh.ts +30 -30
  130. package/templates/react/features/manualRoutes/src/router/routes.tsx +13 -0
  131. package/templates/react/features/pageRoutes/package.json +1 -2
  132. package/templates/react/features/qiankun/package.json +6 -0
  133. package/templates/react/features/qiankun/src/qiankun/index.ts +80 -0
  134. package/templates/react/features/router/package.json +1 -1
  135. package/templates/react/features/sentry/package.json +6 -7
  136. package/templates/react/features/sentry/src/utils/sentry.ts +10 -0
  137. package/templates/react/features/zustand/package.json +1 -1
  138. package/templates/react/features/zustand/src/stores/user.ts +42 -6
  139. package/templates/react/features/zustand/src/types/stores.ts +8 -1
  140. package/templates/vue/base/env.d.ts +27 -27
  141. package/templates/vue/base/index.html +14 -14
  142. package/templates/vue/base/node_modules/.bin/vite +17 -0
  143. package/templates/vue/base/node_modules/.bin/vite.CMD +12 -0
  144. package/templates/vue/base/node_modules/.bin/vite.ps1 +41 -0
  145. package/templates/vue/base/node_modules/.bin/vue-tsc +17 -0
  146. package/templates/vue/base/node_modules/.bin/vue-tsc.CMD +12 -0
  147. package/templates/vue/base/node_modules/.bin/vue-tsc.ps1 +41 -0
  148. package/templates/vue/base/package.json +16 -13
  149. package/templates/vue/base/src/App.vue +13 -13
  150. package/templates/vue/base/src/assets/styles/main.scss +9 -9
  151. package/templates/vue/base/src/directives/index.ts +36 -36
  152. package/templates/vue/base/src/layouts/index.ts +5 -7
  153. package/templates/vue/base/src/main.ts.ejs +9 -25
  154. package/templates/vue/base/src/pages/about/index.vue +31 -31
  155. package/templates/vue/base/src/pages/home/index.vue +31 -31
  156. package/templates/vue/base/src/router/index.ts.ejs +10 -13
  157. package/templates/vue/base/tsconfig.app.json +17 -17
  158. package/templates/vue/base/tsconfig.base.json +23 -23
  159. package/templates/vue/base/tsconfig.json +12 -12
  160. package/templates/vue/base/tsconfig.node.json +15 -15
  161. package/templates/vue/features/ant-design-vue/package.json +6 -7
  162. package/templates/vue/{base → features/ant-design-vue}/src/layouts/AntDesign.vue +86 -86
  163. package/templates/vue/features/element-plus/package.json +6 -7
  164. package/templates/vue/{base → features/element-plus}/src/assets/styles/element/index.scss +27 -27
  165. package/templates/vue/features/element-plus/src/components/SubMenu/index.ts +9 -0
  166. package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/index.ts +6 -6
  167. package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/props.ts +11 -11
  168. package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/index.vue +24 -24
  169. package/templates/vue/{base → features/element-plus}/src/layouts/element.vue +81 -81
  170. package/templates/vue/features/eslint/node_modules/.bin/eslint +17 -0
  171. package/templates/vue/features/eslint/node_modules/.bin/eslint.CMD +12 -0
  172. package/templates/vue/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
  173. package/templates/vue/features/eslint/package.json +3 -3
  174. package/templates/vue/features/i18n/package.json +5 -5
  175. package/templates/vue/features/i18n/src/locales/index.ts +23 -16
  176. package/templates/vue/features/i18n/src/locales/lang/en.ts +30 -0
  177. package/templates/vue/features/i18n/src/locales/lang/es.ts +30 -0
  178. package/templates/vue/features/i18n/src/locales/lang/zh.ts +30 -0
  179. package/templates/vue/features/manualRoutes/src/router/routes.ts +35 -27
  180. package/templates/vue/features/pageRoutes/package.json +5 -5
  181. package/templates/vue/features/pinia/package.json +3 -2
  182. package/templates/vue/features/pinia/src/stores/index.ts +8 -0
  183. package/templates/vue/features/pinia/src/stores/system.ts +60 -0
  184. package/templates/vue/features/pinia/src/stores/user.ts +33 -13
  185. package/templates/vue/features/qiankun/package.json +5 -5
  186. package/templates/vue/features/qiankun/src/qiankun/index.ts +19 -0
  187. package/templates/vue/features/router/package.json +1 -1
  188. package/templates/vue/features/sentry/package.json +6 -6
  189. package/templates/vue/features/sentry/src/utils/sentry.ts +12 -0
  190. package/dist/commands/create.d.ts.map +0 -1
  191. package/dist/commands/create.js.map +0 -1
  192. package/dist/commands/index.d.ts.map +0 -1
  193. package/dist/commands/index.js.map +0 -1
  194. package/dist/generators/index.d.ts.map +0 -1
  195. package/dist/generators/index.js.map +0 -1
  196. package/dist/generators/project.d.ts.map +0 -1
  197. package/dist/generators/project.js.map +0 -1
  198. package/dist/generators/react.d.ts.map +0 -1
  199. package/dist/generators/react.js.map +0 -1
  200. package/dist/generators/vue.d.ts.map +0 -1
  201. package/dist/generators/vue.js.map +0 -1
  202. package/dist/index.d.ts.map +0 -1
  203. package/dist/index.js.map +0 -1
  204. package/dist/test.d.ts.map +0 -1
  205. package/dist/test.js.map +0 -1
  206. package/dist/types/ejs.d.ts.map +0 -1
  207. package/dist/types/ejs.js.map +0 -1
  208. package/dist/types/features.d.ts.map +0 -1
  209. package/dist/types/features.js.map +0 -1
  210. package/dist/types/index.d.ts.map +0 -1
  211. package/dist/types/index.js.map +0 -1
  212. package/dist/types/viteConfig.d.ts.map +0 -1
  213. package/dist/types/viteConfig.js.map +0 -1
  214. package/dist/utils/deepMerge.d.ts.map +0 -1
  215. package/dist/utils/deepMerge.js.map +0 -1
  216. package/dist/utils/ejs.d.ts.map +0 -1
  217. package/dist/utils/ejs.js.map +0 -1
  218. package/dist/utils/file.d.ts.map +0 -1
  219. package/dist/utils/file.js.map +0 -1
  220. package/dist/utils/index.d.ts.map +0 -1
  221. package/dist/utils/index.js.map +0 -1
  222. package/dist/utils/install.d.ts.map +0 -1
  223. package/dist/utils/install.js.map +0 -1
  224. package/dist/utils/prompts.d.ts.map +0 -1
  225. package/dist/utils/prompts.js.map +0 -1
  226. package/dist/utils/renderFeatures.d.ts.map +0 -1
  227. package/dist/utils/renderFeatures.js.map +0 -1
  228. package/dist/utils/renderTemplate.d.ts.map +0 -1
  229. package/dist/utils/renderTemplate.js.map +0 -1
  230. package/dist/utils/sortDependencies.d.ts.map +0 -1
  231. package/dist/utils/sortDependencies.js.map +0 -1
  232. package/dist/utils/viteConfigRender.d.ts.map +0 -1
  233. package/dist/utils/viteConfigRender.js.map +0 -1
  234. package/templates/common/base/pnpm-workspace.yaml +0 -37
  235. package/templates/common/features/husky/pnpm-workspace.yaml +0 -9
  236. package/templates/react/base/pnpm-workspace.yaml +0 -9
  237. package/templates/react/base/src/stores/user.ts +0 -39
  238. package/templates/react/base/vite.config.ts +0 -52
  239. package/templates/react/features/ant-design/pnpm-workspace.yaml +0 -5
  240. package/templates/react/features/eslint/pnpm-workspace.yaml +0 -6
  241. package/templates/react/features/i18n/pnpm-workspace.yaml +0 -5
  242. package/templates/react/features/pageRoutes/pnpm-workspace.yaml +0 -4
  243. package/templates/react/features/pageRoutes/vite.config.data.ts +0 -10
  244. package/templates/react/features/router/pnpm-workspace.yaml +0 -3
  245. package/templates/react/features/sentry/pnpm-workspace.yaml +0 -5
  246. package/templates/react/features/sentry/vite.config.data.ts +0 -23
  247. package/templates/react/features/zustand/pnpm-workspace.yaml +0 -3
  248. package/templates/vue/base/pnpm-workspace.yaml +0 -6
  249. package/templates/vue/base/src/components/SubMenu/index.ts +0 -9
  250. package/templates/vue/base/src/stores/index.ts +0 -16
  251. package/templates/vue/base/src/stores/modules/system.ts +0 -52
  252. package/templates/vue/base/src/stores/modules/user.ts +0 -48
  253. package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +0 -5
  254. package/templates/vue/features/element-plus/pnpm-workspace.yaml +0 -5
  255. package/templates/vue/features/element-plus/vite.config.data.ts +0 -15
  256. package/templates/vue/features/eslint/pnpm-workspace.yaml +0 -6
  257. package/templates/vue/features/i18n/pnpm-workspace.yaml +0 -3
  258. package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +0 -4
  259. package/templates/vue/features/pageRoutes/vite.config.data.ts +0 -9
  260. package/templates/vue/features/pinia/pnpm-workspace.yaml +0 -4
  261. package/templates/vue/features/qiankun/pnpm-workspace.yaml +0 -3
  262. package/templates/vue/features/router/pnpm-workspace.yaml +0 -3
  263. package/templates/vue/features/sentry/pnpm-workspace.yaml +0 -4
  264. package/templates/vue/features/sentry/vite.config.data.ts +0 -23
package/dist/test.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * 测试脚本
3
- * 生成验收样本并进行产物审计
3
+ * 通过文件系统扫描自动生成所有测试用例组合
4
+ *
5
+ * 用法:
6
+ * pnpm test # 生成所有测试用例
7
+ * pnpm test --minimal # 只生成全量和最小配置
4
8
  */
5
9
  export {};
6
- //# sourceMappingURL=test.d.ts.map
package/dist/test.js CHANGED
@@ -1,204 +1,196 @@
1
1
  /**
2
2
  * 测试脚本
3
- * 生成验收样本并进行产物审计
3
+ * 通过文件系统扫描自动生成所有测试用例组合
4
+ *
5
+ * 用法:
6
+ * pnpm test # 生成所有测试用例
7
+ * pnpm test --minimal # 只生成全量和最小配置
4
8
  */
5
9
  import path from 'node:path';
6
10
  import process from 'node:process';
7
11
  import { fileURLToPath } from 'node:url';
8
12
  import chalk from 'chalk';
9
13
  import fs from 'fs-extra';
10
- import { generateProject } from './generators/project.js';
14
+ import { FILE_CONSTANTS } from "./constants/index.js";
15
+ import { generateProject } from "./generators/index.js";
16
+ import { featureToConfig, scanAllFeatures } from "./utils/featureMapping.js";
11
17
  const __filename = fileURLToPath(import.meta.url);
12
18
  const __dirname = path.dirname(__filename);
13
19
  /** 测试输出目录 */
14
20
  const TEST_OUTPUT_DIR = path.resolve(__dirname, '../test');
15
- /** 测试配置矩阵 */
16
- const TEST_CONFIGS = [
17
- // Vue 基础配置组合
18
- {
19
- name: 'vue-element-basic',
20
- config: {
21
- projectName: 'vue-element-basic',
22
- description: 'Vue + Element Plus 基础项目',
23
- author: 'test',
24
- framework: 'vue',
25
- uiLibrary: 'element-plus',
26
- routeMode: 'manual',
27
- i18n: true,
28
- qiankun: false,
29
- sentry: false,
30
- eslint: true,
31
- gitHooks: true,
32
- packageManager: 'pnpm',
33
- },
34
- },
35
- {
36
- name: 'vue-element-full',
37
- config: {
38
- projectName: 'vue-element-full',
39
- description: 'Vue + Element Plus 全量特性项目',
40
- author: 'test',
41
- framework: 'vue',
42
- uiLibrary: 'element-plus',
43
- routeMode: 'file-system',
44
- i18n: true,
45
- qiankun: true,
46
- sentry: true,
47
- eslint: true,
48
- gitHooks: true,
49
- packageManager: 'pnpm',
50
- },
51
- },
52
- {
53
- name: 'vue-antd-basic',
54
- config: {
55
- projectName: 'vue-antd-basic',
56
- description: 'Vue + Ant Design Vue 基础项目',
57
- author: 'test',
58
- framework: 'vue',
59
- uiLibrary: 'ant-design-vue',
60
- routeMode: 'manual',
61
- i18n: true,
62
- qiankun: false,
63
- sentry: false,
64
- eslint: true,
65
- gitHooks: true,
66
- packageManager: 'pnpm',
67
- },
68
- },
69
- {
70
- name: 'vue-antd-minimal',
71
- config: {
72
- projectName: 'vue-antd-minimal',
73
- description: 'Vue + Ant Design Vue 最小配置(无 i18n)',
74
- author: 'test',
75
- framework: 'vue',
76
- uiLibrary: 'ant-design-vue',
77
- routeMode: 'manual',
78
- i18n: false,
79
- qiankun: false,
80
- sentry: false,
81
- eslint: true,
82
- gitHooks: true,
83
- packageManager: 'pnpm',
84
- },
85
- },
86
- {
87
- name: 'vue-element-sentry-only',
88
- config: {
89
- projectName: 'vue-element-sentry-only',
90
- description: 'Vue + Element Plus + Sentry(无其他特性)',
91
- author: 'test',
92
- framework: 'vue',
93
- uiLibrary: 'element-plus',
94
- routeMode: 'manual',
95
- i18n: false,
96
- qiankun: false,
97
- sentry: true,
98
- eslint: true,
99
- gitHooks: true,
100
- packageManager: 'pnpm',
101
- },
102
- },
103
- {
104
- name: 'vue-no-eslint-no-hooks',
105
- config: {
106
- projectName: 'vue-no-eslint-no-hooks',
107
- description: 'Vue 项目(无 ESLint,无 Git Hooks)',
108
- author: 'test',
109
- framework: 'vue',
110
- uiLibrary: 'element-plus',
111
- routeMode: 'manual',
112
- i18n: false,
113
- qiankun: false,
114
- sentry: false,
115
- eslint: false,
116
- gitHooks: false,
117
- packageManager: 'pnpm',
118
- },
119
- },
120
- // React 配置组合
121
- {
122
- name: 'react-antd-basic',
123
- config: {
124
- projectName: 'react-antd-basic',
125
- description: 'React + Ant Design 基础项目',
126
- author: 'test',
127
- framework: 'react',
128
- uiLibrary: 'ant-design',
129
- routeMode: 'manual',
130
- i18n: true,
131
- qiankun: false,
132
- sentry: false,
133
- eslint: true,
134
- gitHooks: true,
135
- packageManager: 'pnpm',
136
- },
137
- },
138
- {
139
- name: 'react-antd-full',
140
- config: {
141
- projectName: 'react-antd-full',
142
- description: 'React + Ant Design 全量特性项目',
143
- author: 'test',
144
- framework: 'react',
145
- uiLibrary: 'ant-design',
146
- routeMode: 'file-system',
147
- i18n: true,
148
- qiankun: false,
149
- sentry: true,
150
- eslint: true,
151
- gitHooks: true,
152
- packageManager: 'pnpm',
153
- },
154
- },
155
- {
156
- name: 'react-antd-minimal',
157
- config: {
158
- projectName: 'react-antd-minimal',
159
- description: 'React + Ant Design 最小配置(无 i18n, 无 sentry)',
160
- author: 'test',
161
- framework: 'react',
162
- uiLibrary: 'ant-design',
163
- routeMode: 'manual',
164
- i18n: false,
165
- qiankun: false,
166
- sentry: false,
167
- eslint: true,
168
- gitHooks: true,
169
- packageManager: 'pnpm',
170
- },
171
- },
172
- {
173
- name: 'react-no-eslint-no-hooks',
21
+ /**
22
+ * 解析命令行参数
23
+ */
24
+ function parseArgs() {
25
+ const args = process.argv.slice(2);
26
+ const minimalOnly = args.includes('--minimal') || args.includes('--min') || args.includes('-m');
27
+ return { minimalOnly };
28
+ }
29
+ /**
30
+ * 生成所有可能的组合(包括全开、全关)
31
+ */
32
+ function generateAllCombinations(items) {
33
+ const n = items.length;
34
+ const combinations = [];
35
+ // 生成 2^n 种组合
36
+ for (let i = 0; i < 2 ** n; i++) {
37
+ const combination = [];
38
+ for (let j = 0; j < n; j++) {
39
+ combination.push((i & (1 << j)) !== 0);
40
+ }
41
+ combinations.push(combination);
42
+ }
43
+ return combinations;
44
+ }
45
+ /**
46
+ * 自动生成测试用例配置(基于组合算法)
47
+ * @param minimalOnly 是否只生成全量和最小配置
48
+ */
49
+ function generateTestConfigs(minimalOnly = false) {
50
+ const configs = [];
51
+ const frameworks = ['vue', 'react'];
52
+ for (const framework of frameworks) {
53
+ const allFeatures = scanAllFeatures(framework);
54
+ // 分离不同类型的 features
55
+ const uiLibraries = [];
56
+ const routeModes = [];
57
+ const booleanFeatures = [];
58
+ for (const feature of allFeatures) {
59
+ const config = featureToConfig(feature, framework);
60
+ if (!config)
61
+ continue;
62
+ if (config.key === 'uiLibrary') {
63
+ uiLibraries.push(feature);
64
+ }
65
+ else if (config.key === 'routeMode') {
66
+ routeModes.push(feature);
67
+ }
68
+ else {
69
+ booleanFeatures.push(feature);
70
+ }
71
+ }
72
+ if (uiLibraries.length === 0)
73
+ continue;
74
+ if (minimalOnly) {
75
+ // 只生成全量和最小配置:每个框架只选择一个 UI 库和一个路由模式
76
+ const uiLibrary = uiLibraries[0]; // 只选择第一个 UI 库
77
+ const routeModeFeature = routeModes.length > 0 ? routeModes[0] : 'manualRoutes'; // 只选择第一个路由模式
78
+ // 只生成全量和最小两种配置
79
+ const allFalse = Array.from({ length: booleanFeatures.length }, () => false);
80
+ const allTrue = Array.from({ length: booleanFeatures.length }, () => true);
81
+ const combinations = [allFalse, allTrue];
82
+ // 为每种包管理器生成测试用例
83
+ const packageManagers = ['pnpm', 'npm', 'yarn'];
84
+ for (const packageManager of packageManagers) {
85
+ for (const combination of combinations) {
86
+ const config = {
87
+ framework,
88
+ uiLibrary: uiLibrary,
89
+ routeMode: featureToConfig(routeModeFeature, framework).value,
90
+ packageManager,
91
+ };
92
+ // 应用布尔 features 的组合
93
+ for (let i = 0; i < booleanFeatures.length; i++) {
94
+ const feature = booleanFeatures[i];
95
+ const enabled = combination[i];
96
+ const featureConfig = featureToConfig(feature, framework);
97
+ if (featureConfig && featureConfig.key !== 'uiLibrary' && featureConfig.key !== 'routeMode') {
98
+ config[featureConfig.key] = enabled;
99
+ }
100
+ }
101
+ // 生成测试用例名称(包含包管理器)
102
+ const suffix = combination.every(v => !v) ? 'minimal' : 'full';
103
+ configs.push(createTestConfig(framework, uiLibrary, `${packageManager}-${suffix}`, config));
104
+ }
105
+ }
106
+ }
107
+ else {
108
+ // 生成所有组合
109
+ for (const uiLibrary of uiLibraries) {
110
+ // 为每个路由模式生成测试用例
111
+ const routeModesToTest = routeModes.length > 0 ? routeModes : ['manualRoutes']; // 默认
112
+ for (const routeModeFeature of routeModesToTest) {
113
+ // 生成所有布尔 features 的组合(2^n 种)
114
+ const combinations = generateAllCombinations(booleanFeatures);
115
+ // 为每种包管理器生成测试用例
116
+ const packageManagers = ['pnpm', 'npm', 'yarn'];
117
+ for (const packageManager of packageManagers) {
118
+ for (const combination of combinations) {
119
+ const config = {
120
+ framework,
121
+ uiLibrary: uiLibrary,
122
+ routeMode: featureToConfig(routeModeFeature, framework).value,
123
+ packageManager,
124
+ };
125
+ // 应用布尔 features 的组合
126
+ for (let i = 0; i < booleanFeatures.length; i++) {
127
+ const feature = booleanFeatures[i];
128
+ const enabled = combination[i];
129
+ const featureConfig = featureToConfig(feature, framework);
130
+ if (featureConfig && featureConfig.key !== 'uiLibrary' && featureConfig.key !== 'routeMode') {
131
+ config[featureConfig.key] = enabled;
132
+ }
133
+ }
134
+ // 生成测试用例名称(包含包管理器)
135
+ const enabledFeatures = booleanFeatures.filter((_, i) => combination[i]);
136
+ const suffix = enabledFeatures.length === 0
137
+ ? 'minimal'
138
+ : enabledFeatures.length === booleanFeatures.length
139
+ ? 'full'
140
+ : enabledFeatures.join('-');
141
+ configs.push(createTestConfig(framework, uiLibrary, `${packageManager}-${routeModeFeature}-${suffix}`, config));
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ return configs;
149
+ }
150
+ /**
151
+ * 创建测试配置的辅助函数
152
+ * @param framework 框架类型
153
+ * @param uiLibrary UI 库名称
154
+ * @param suffix 后缀名称
155
+ * @param overrides 配置覆盖项
156
+ * @returns 测试配置对象
157
+ */
158
+ function createTestConfig(framework, uiLibrary, suffix, overrides) {
159
+ const name = `${framework}-${uiLibrary}-${suffix}`;
160
+ return {
161
+ name,
174
162
  config: {
175
- projectName: 'react-no-eslint-no-hooks',
176
- description: 'React 项目(无 ESLint,无 Git Hooks)',
163
+ projectName: name,
164
+ description: `${framework === 'vue' ? 'Vue' : 'React'} + ${uiLibrary} ${suffix}`,
177
165
  author: 'test',
178
- framework: 'react',
179
- uiLibrary: 'ant-design',
180
- routeMode: 'manual',
181
- i18n: false,
182
- qiankun: false,
183
- sentry: false,
184
- eslint: false,
185
- gitHooks: false,
186
- packageManager: 'pnpm',
166
+ ...overrides,
187
167
  },
188
- },
189
- ];
168
+ };
169
+ }
190
170
  /**
191
171
  * 生成测试项目
172
+ * @param minimalOnly 是否只生成全量和最小配置
192
173
  */
193
- async function generateTestProjects() {
194
- console.log(chalk.blue.bold('\n🧪 开始生成测试项目...\n'));
174
+ async function generateTestProjects(minimalOnly = false) {
175
+ const mode = minimalOnly ? '(仅全量和最小配置)' : '(全部组合)';
176
+ console.log(chalk.blue.bold(`\n🧪 开始生成测试项目${mode}...\n`));
177
+ // 扫描并生成测试配置
178
+ const TEST_CONFIGS = generateTestConfigs(minimalOnly);
179
+ console.log(chalk.cyan(`📋 扫描到 ${TEST_CONFIGS.length} 个测试用例\n`));
195
180
  // 清理并创建测试目录
196
181
  if (fs.existsSync(TEST_OUTPUT_DIR)) {
197
182
  fs.removeSync(TEST_OUTPUT_DIR);
198
183
  }
199
184
  fs.ensureDirSync(TEST_OUTPUT_DIR);
185
+ // 创建 Vue 和 React 子目录
186
+ const vueOutputDir = path.join(TEST_OUTPUT_DIR, 'vue');
187
+ const reactOutputDir = path.join(TEST_OUTPUT_DIR, 'react');
188
+ fs.ensureDirSync(vueOutputDir);
189
+ fs.ensureDirSync(reactOutputDir);
200
190
  for (const { name, config } of TEST_CONFIGS) {
201
191
  console.log(chalk.cyan(`📦 生成 ${name}...`));
192
+ // 根据框架决定输出目录
193
+ const frameworkOutputDir = config.framework === 'vue' ? vueOutputDir : reactOutputDir;
202
194
  const fullConfig = {
203
195
  projectName: config.projectName,
204
196
  description: config.description,
@@ -214,7 +206,7 @@ async function generateTestProjects() {
214
206
  eslint: config.eslint,
215
207
  gitHooks: config.gitHooks,
216
208
  packageManager: config.packageManager,
217
- targetDir: path.join(TEST_OUTPUT_DIR, name),
209
+ targetDir: path.join(frameworkOutputDir, name),
218
210
  };
219
211
  try {
220
212
  await generateProject(fullConfig);
@@ -226,20 +218,59 @@ async function generateTestProjects() {
226
218
  }
227
219
  console.log(chalk.green.bold('\n✅ 测试项目生成完成!\n'));
228
220
  }
221
+ /**
222
+ * 检查 package.json 中是否有 catalog 引用(应该已经全部替换为实际版本号)
223
+ */
224
+ function checkPackageJsonVersions(projectDir) {
225
+ const packageJsonPath = path.join(projectDir, FILE_CONSTANTS.PACKAGE_JSON);
226
+ if (!fs.existsSync(packageJsonPath)) {
227
+ console.log(chalk.red(` ❌ package.json 不存在`));
228
+ return false;
229
+ }
230
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
231
+ let hasError = false;
232
+ // 检查 dependencies 中是否还有 catalog 引用
233
+ if (packageJson.dependencies) {
234
+ for (const [dep, version] of Object.entries(packageJson.dependencies)) {
235
+ if (typeof version === 'string' && version.startsWith('catalog:')) {
236
+ console.log(chalk.red(` ❌ dependencies.${dep}: "${version}" 应该使用实际版本号`));
237
+ hasError = true;
238
+ }
239
+ }
240
+ }
241
+ // 检查 devDependencies 中是否还有 catalog 引用
242
+ if (packageJson.devDependencies) {
243
+ for (const [dep, version] of Object.entries(packageJson.devDependencies)) {
244
+ if (typeof version === 'string' && version.startsWith('catalog:')) {
245
+ console.log(chalk.red(` ❌ devDependencies.${dep}: "${version}" 应该使用实际版本号`));
246
+ hasError = true;
247
+ }
248
+ }
249
+ }
250
+ if (!hasError) {
251
+ console.log(chalk.green(` ✅ package.json 版本号检查通过(无 catalog 引用)`));
252
+ }
253
+ return !hasError;
254
+ }
229
255
  /**
230
256
  * 审计 @moluoxixi 依赖
257
+ * @param minimalOnly 是否只生成全量和最小配置
231
258
  */
232
- async function auditMoluoxixiDeps() {
259
+ async function auditMoluoxixiDeps(minimalOnly = false) {
233
260
  console.log(chalk.blue.bold('\n🔍 开始审计 @moluoxixi 依赖...\n'));
261
+ const TEST_CONFIGS = generateTestConfigs(minimalOnly);
234
262
  const requiredDeps = [
235
263
  '@moluoxixi/vite-config',
236
264
  '@moluoxixi/ajax-package',
237
265
  ];
238
266
  let hasError = false;
239
267
  for (const { name, config } of TEST_CONFIGS) {
240
- const projectDir = path.join(TEST_OUTPUT_DIR, name);
241
- const packageJsonPath = path.join(projectDir, 'package.json');
242
- const workspacePath = path.join(projectDir, 'pnpm-workspace.yaml');
268
+ // 根据框架决定输出目录
269
+ const frameworkOutputDir = config.framework === 'vue'
270
+ ? path.join(TEST_OUTPUT_DIR, 'vue')
271
+ : path.join(TEST_OUTPUT_DIR, 'react');
272
+ const projectDir = path.join(frameworkOutputDir, name);
273
+ const packageJsonPath = path.join(projectDir, FILE_CONSTANTS.PACKAGE_JSON);
243
274
  console.log(chalk.cyan(`📋 检查 ${name}...`));
244
275
  // 根据配置决定需要检查的依赖
245
276
  const depsToCheck = [...requiredDeps];
@@ -267,23 +298,6 @@ async function auditMoluoxixiDeps() {
267
298
  console.log(chalk.red(` ❌ package.json 不存在`));
268
299
  hasError = true;
269
300
  }
270
- // 检查 pnpm-workspace.yaml
271
- if (fs.existsSync(workspacePath)) {
272
- const workspaceContent = fs.readFileSync(workspacePath, 'utf-8');
273
- for (const dep of depsToCheck) {
274
- if (!workspaceContent.includes(dep)) {
275
- console.log(chalk.red(` ❌ pnpm-workspace.yaml 缺少 ${dep}`));
276
- hasError = true;
277
- }
278
- else {
279
- console.log(chalk.green(` ✅ pnpm-workspace.yaml 包含 ${dep}`));
280
- }
281
- }
282
- }
283
- else {
284
- console.log(chalk.red(` ❌ pnpm-workspace.yaml 不存在`));
285
- hasError = true;
286
- }
287
301
  // 检查可选特性文件
288
302
  if (!config.eslint) {
289
303
  const eslintConfig = path.join(projectDir, 'eslint.config.ts');
@@ -305,6 +319,12 @@ async function auditMoluoxixiDeps() {
305
319
  console.log(chalk.green(` ✅ .husky/ 目录已正确移除`));
306
320
  }
307
321
  }
322
+ // 检查 package.json 版本号(确保没有 catalog 引用)
323
+ console.log(chalk.cyan(` 🔍 检查 package.json 版本号...`));
324
+ const packageJsonOk = checkPackageJsonVersions(projectDir);
325
+ if (!packageJsonOk) {
326
+ hasError = true;
327
+ }
308
328
  console.log('');
309
329
  }
310
330
  if (hasError) {
@@ -320,10 +340,33 @@ async function auditMoluoxixiDeps() {
320
340
  */
321
341
  async function showFileTrees() {
322
342
  console.log(chalk.blue.bold('\n📂 项目文件树...\n'));
323
- for (const { name } of TEST_CONFIGS) {
324
- const projectDir = path.join(TEST_OUTPUT_DIR, name);
325
- console.log(chalk.cyan(`\n${name}/`));
326
- await printFileTree(projectDir, ' ');
343
+ const vueOutputDir = path.join(TEST_OUTPUT_DIR, 'vue');
344
+ const reactOutputDir = path.join(TEST_OUTPUT_DIR, 'react');
345
+ // 显示 Vue 项目
346
+ if (fs.existsSync(vueOutputDir)) {
347
+ console.log(chalk.cyan.bold('\n📁 Vue 项目:\n'));
348
+ const vueProjects = fs.readdirSync(vueOutputDir).filter((item) => {
349
+ const itemPath = path.join(vueOutputDir, item);
350
+ return fs.statSync(itemPath).isDirectory();
351
+ });
352
+ for (const projectName of vueProjects) {
353
+ const projectDir = path.join(vueOutputDir, projectName);
354
+ console.log(chalk.cyan(`\n${projectName}/`));
355
+ await printFileTree(projectDir, ' ');
356
+ }
357
+ }
358
+ // 显示 React 项目
359
+ if (fs.existsSync(reactOutputDir)) {
360
+ console.log(chalk.cyan.bold('\n📁 React 项目:\n'));
361
+ const reactProjects = fs.readdirSync(reactOutputDir).filter((item) => {
362
+ const itemPath = path.join(reactOutputDir, item);
363
+ return fs.statSync(itemPath).isDirectory();
364
+ });
365
+ for (const projectName of reactProjects) {
366
+ const projectDir = path.join(reactOutputDir, projectName);
367
+ console.log(chalk.cyan(`\n${projectName}/`));
368
+ await printFileTree(projectDir, ' ');
369
+ }
327
370
  }
328
371
  }
329
372
  /**
@@ -332,7 +375,7 @@ async function showFileTrees() {
332
375
  async function printFileTree(dir, indent) {
333
376
  const items = fs.readdirSync(dir).sort();
334
377
  for (const item of items) {
335
- if (item === 'node_modules')
378
+ if (item === FILE_CONSTANTS.NODE_MODULES)
336
379
  continue;
337
380
  const itemPath = path.join(dir, item);
338
381
  const stat = fs.statSync(itemPath);
@@ -349,16 +392,19 @@ async function printFileTree(dir, indent) {
349
392
  * 主函数
350
393
  */
351
394
  async function main() {
395
+ const { minimalOnly } = parseArgs();
352
396
  console.log(chalk.blue.bold(`\n${'='.repeat(60)}`));
353
397
  console.log(chalk.blue.bold(' Vite CLI Next - 产物审计测试'));
398
+ if (minimalOnly) {
399
+ console.log(chalk.yellow.bold(' 模式: 仅全量和最小配置'));
400
+ }
354
401
  console.log(chalk.blue.bold('='.repeat(60)));
355
402
  // 1. 生成测试项目
356
- await generateTestProjects();
403
+ await generateTestProjects(minimalOnly);
357
404
  // 2. 审计 @moluoxixi 依赖
358
- await auditMoluoxixiDeps();
405
+ await auditMoluoxixiDeps(minimalOnly);
359
406
  // 3. 显示文件树
360
407
  await showFileTrees();
361
408
  console.log(chalk.green.bold('\n✅ 全量产物审计完成!\n'));
362
409
  }
363
410
  main().catch(console.error);
364
- //# sourceMappingURL=test.js.map
@@ -8,4 +8,3 @@
8
8
  export interface EjsDataType {
9
9
  [key: string]: unknown;
10
10
  }
11
- //# sourceMappingURL=ejs.d.ts.map
package/dist/types/ejs.js CHANGED
@@ -2,4 +2,3 @@
2
2
  * EJS 模板相关类型定义
3
3
  */
4
4
  export {};
5
- //# sourceMappingURL=ejs.js.map
@@ -20,7 +20,6 @@ export declare const VUE_FEATURES: readonly ["router", "pinia", "eslint", "i18n"
20
20
  /**
21
21
  * React 特性 ID
22
22
  */
23
- export declare const REACT_FEATURES: readonly ["router", "zustand", "eslint", "i18n", "sentry", "ant-design"];
23
+ export declare const REACT_FEATURES: readonly ["router", "zustand", "eslint", "i18n", "sentry", "qiankun", "ant-design"];
24
24
  export type VueFeatureId = typeof VUE_FEATURES[number];
25
25
  export type ReactFeatureId = typeof REACT_FEATURES[number];
26
- //# sourceMappingURL=features.d.ts.map
@@ -36,6 +36,6 @@ export const REACT_FEATURES = [
36
36
  'eslint',
37
37
  'i18n',
38
38
  'sentry',
39
+ 'qiankun',
39
40
  'ant-design',
40
41
  ];
41
- //# sourceMappingURL=features.js.map
@@ -2,9 +2,8 @@
2
2
  * CLI 类型定义
3
3
  * 定义项目配置、模板层级等核心类型
4
4
  */
5
- export * from './ejs';
6
- export * from './features';
7
- export * from './viteConfig';
5
+ export * from './ejs.ts';
6
+ export * from './features.ts';
8
7
  /**
9
8
  * 框架类型
10
9
  */
@@ -56,4 +55,3 @@ export interface ProjectConfigType {
56
55
  /** 目标目录 */
57
56
  targetDir: string;
58
57
  }
59
- //# sourceMappingURL=index.d.ts.map
@@ -2,7 +2,5 @@
2
2
  * CLI 类型定义
3
3
  * 定义项目配置、模板层级等核心类型
4
4
  */
5
- export * from './ejs.js';
6
- export * from './features.js';
7
- export * from './viteConfig.js';
8
- //# sourceMappingURL=index.js.map
5
+ export * from "./ejs.js";
6
+ export * from "./features.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * package.json 类型定义
3
+ */
4
+ /**
5
+ * package.json 文件结构接口
6
+ */
7
+ export interface PackageJson {
8
+ /** 包名称 */
9
+ name?: string;
10
+ /** 版本号 */
11
+ version?: string;
12
+ /** 描述 */
13
+ description?: string;
14
+ /** 作者 */
15
+ author?: string;
16
+ /** 包管理器及版本 */
17
+ packageManager?: string;
18
+ /** 生产依赖 */
19
+ dependencies?: Record<string, string>;
20
+ /** 开发依赖 */
21
+ devDependencies?: Record<string, string>;
22
+ /** 其他字段 */
23
+ [key: string]: unknown;
24
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * package.json 类型定义
3
+ */
4
+ export {};