@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/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 moluoxixi-template
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 moluoxixi-template
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,129 +1,129 @@
1
- # @moluoxixi/create-app
2
-
3
- > 基于原子化分层叠加架构的项目脚手架 CLI
4
-
5
- ## 快速开始
6
-
7
- ```bash
8
- # 使用 npx
9
- npx @moluoxixi/create-app
10
-
11
- # 使用 pnpm
12
- pnpm create @moluoxixi/app
13
-
14
- # 使用 npm
15
- npm create @moluoxixi/app
16
- ```
17
-
18
- ## 特性
19
-
20
- - 🚀 **原子化分层架构** - L0/L1/L2 三层模板,灵活组合
21
- - 📦 **多框架支持** - Vue 3、React 18
22
- - 🎨 **多 UI 库** - Element Plus、Ant Design Vue、Ant Design
23
- - 🌍 **国际化** - 内置 vue-i18n / i18next 支持
24
- - 📊 **错误监控** - 可选 Sentry 集成
25
- - 🔗 **微前端** - 可选 Qiankun 支持 (Vue)
26
- - ⚡ **文件系统路由** - 可选 vite-plugin-pages
27
- - 📝 **TypeScript** - 全面的类型支持
28
- - 🔧 **规范配置** - ESLint + Commitlint + Husky
29
-
30
- ## 内置依赖
31
-
32
- 所有生成的项目都包含以下核心依赖:
33
-
34
- | 依赖包 | 用途 |
35
- |--------|------|
36
- | `@moluoxixi/eslint-config` | ESLint 统一配置 |
37
- | `@moluoxixi/vite-config` | Vite 构建配置 |
38
- | `@moluoxixi/ajax-package` | HTTP 请求封装 |
39
- | `@moluoxixi/class-names` | CSS 类名工具 |
40
- | `@moluoxixi/css-module-global-root-plugin` | CSS Module 插件 |
41
-
42
- ## 项目结构
43
-
44
- 生成的项目结构示例:
45
-
46
- ```
47
- my-project/
48
- ├── .husky/ # Git Hooks
49
- ├── scripts/ # 构建脚本
50
- ├── src/
51
- │ ├── apis/ # API 请求层
52
- │ ├── assets/ # 静态资源
53
- │ ├── components/ # 公共组件
54
- │ ├── constants/ # 常量定义
55
- │ ├── directives/ # Vue 指令
56
- │ ├── layouts/ # 布局组件
57
- │ ├── locales/ # 多语言文件
58
- │ ├── pages/ # 页面组件
59
- │ ├── router/ # 路由配置
60
- │ ├── stores/ # 状态管理
61
- │ ├── utils/ # 工具函数
62
- │ ├── App.vue # 根组件
63
- │ └── main.ts # 入口文件
64
- ├── .env # 环境变量
65
- ├── package.json # 项目配置
66
- ├── pnpm-workspace.yaml # pnpm 工作区
67
- ├── vite.config.ts # Vite 配置
68
- ├── eslint.config.ts # ESLint 配置
69
- └── tsconfig.json # TypeScript 配置
70
- ```
71
-
72
- ## 命令
73
-
74
- ```bash
75
- # 开发
76
- pnpm dev
77
-
78
- # 构建
79
- pnpm build
80
-
81
- # 构建并打包
82
- pnpm build:zip
83
-
84
- # 类型检查
85
- pnpm type-check
86
-
87
- # 代码检查
88
- pnpm lint:eslint
89
-
90
- # 提交代码
91
- pnpm commit
92
- ```
93
-
94
- ## 配置选项
95
-
96
- | 选项 | 类型 | 说明 |
97
- |------|------|------|
98
- | 项目名称 | string | 项目名称,用于 package.json |
99
- | 框架 | vue / react | 前端框架 |
100
- | UI 库 | element-plus / ant-design-vue / ant-design | UI 组件库 |
101
- | 路由模式 | manual / file-system | 手动配置或文件系统路由 |
102
- | 国际化 | boolean | 是否启用多语言支持 |
103
- | 错误监控 | boolean | 是否集成 Sentry |
104
- | 微前端 | boolean | 是否支持 Qiankun (仅 Vue) |
105
- | 包管理器 | pnpm / npm / yarn | 包管理器 |
106
-
107
- ## 开发
108
-
109
- ```bash
110
- # 克隆仓库
111
- git clone https://github.com/moluoxixi/create-app.git
112
-
113
- # 安装依赖
114
- pnpm install
115
-
116
- # 运行测试
117
- pnpm test
118
-
119
- # 构建
120
- pnpm build
121
- ```
122
-
123
- ## 架构文档
124
-
125
- 详细的架构说明请参阅 [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md)
126
-
127
- ## 许可证
128
-
129
- MIT
1
+ # @moluoxixi/create-app
2
+
3
+ > 基于原子化分层叠加架构的项目脚手架 CLI
4
+
5
+ ## 快速开始
6
+
7
+ ```bash
8
+ # 使用 npx
9
+ npx @moluoxixi/create-app
10
+
11
+ # 使用 pnpm
12
+ pnpm create @moluoxixi/app
13
+
14
+ # 使用 npm
15
+ npm create @moluoxixi/app
16
+ ```
17
+
18
+ ## 特性
19
+
20
+ - 🚀 **原子化分层架构** - L0/L1/L2 三层模板,灵活组合
21
+ - 📦 **多框架支持** - Vue 3、React 18
22
+ - 🎨 **多 UI 库** - Element Plus、Ant Design Vue、Ant Design
23
+ - 🌍 **国际化** - 内置 vue-i18n / i18next 支持
24
+ - 📊 **错误监控** - 可选 Sentry 集成
25
+ - 🔗 **微前端** - 可选 Qiankun 支持 (Vue)
26
+ - ⚡ **文件系统路由** - 可选 vite-plugin-pages
27
+ - 📝 **TypeScript** - 全面的类型支持
28
+ - 🔧 **规范配置** - ESLint + Commitlint + Husky
29
+
30
+ ## 内置依赖
31
+
32
+ 所有生成的项目都包含以下核心依赖:
33
+
34
+ | 依赖包 | 用途 |
35
+ |--------|------|
36
+ | `@moluoxixi/eslint-config` | ESLint 统一配置 |
37
+ | `@moluoxixi/vite-config` | Vite 构建配置 |
38
+ | `@moluoxixi/ajax-package` | HTTP 请求封装 |
39
+ | `@moluoxixi/class-names` | CSS 类名工具 |
40
+ | `@moluoxixi/css-module-global-root-plugin` | CSS Module 插件 |
41
+
42
+ ## 项目结构
43
+
44
+ 生成的项目结构示例:
45
+
46
+ ```
47
+ my-project/
48
+ ├── .husky/ # Git Hooks
49
+ ├── scripts/ # 构建脚本
50
+ ├── src/
51
+ │ ├── apis/ # API 请求层
52
+ │ ├── assets/ # 静态资源
53
+ │ ├── components/ # 公共组件
54
+ │ ├── constants/ # 常量定义
55
+ │ ├── directives/ # Vue 指令
56
+ │ ├── layouts/ # 布局组件
57
+ │ ├── locales/ # 多语言文件
58
+ │ ├── pages/ # 页面组件
59
+ │ ├── router/ # 路由配置
60
+ │ ├── stores/ # 状态管理
61
+ │ ├── utils/ # 工具函数
62
+ │ ├── App.vue # 根组件
63
+ │ └── main.ts # 入口文件
64
+ ├── .env # 环境变量
65
+ ├── package.json # 项目配置
66
+ ├── pnpm-workspace.yaml # pnpm 工作区
67
+ ├── vite.config.ts # Vite 配置
68
+ ├── eslint.config.ts # ESLint 配置
69
+ └── tsconfig.json # TypeScript 配置
70
+ ```
71
+
72
+ ## 命令
73
+
74
+ ```bash
75
+ # 开发
76
+ pnpm dev
77
+
78
+ # 构建
79
+ pnpm build
80
+
81
+ # 构建并打包
82
+ pnpm build:zip
83
+
84
+ # 类型检查
85
+ pnpm type-check
86
+
87
+ # 代码检查
88
+ pnpm lint:eslint
89
+
90
+ # 提交代码
91
+ pnpm commit
92
+ ```
93
+
94
+ ## 配置选项
95
+
96
+ | 选项 | 类型 | 说明 |
97
+ |------|------|------|
98
+ | 项目名称 | string | 项目名称,用于 package.json |
99
+ | 框架 | vue / react | 前端框架 |
100
+ | UI 库 | element-plus / ant-design-vue / ant-design | UI 组件库 |
101
+ | 路由模式 | manual / file-system | 手动配置或文件系统路由 |
102
+ | 国际化 | boolean | 是否启用多语言支持 |
103
+ | 错误监控 | boolean | 是否集成 Sentry |
104
+ | 微前端 | boolean | 是否支持 Qiankun (仅 Vue) |
105
+ | 包管理器 | pnpm / npm / yarn | 包管理器 |
106
+
107
+ ## 开发
108
+
109
+ ```bash
110
+ # 克隆仓库
111
+ git clone https://github.com/moluoxixi/create-app.git
112
+
113
+ # 安装依赖
114
+ pnpm install
115
+
116
+ # 运行测试
117
+ pnpm test
118
+
119
+ # 构建
120
+ pnpm build
121
+ ```
122
+
123
+ ## 架构文档
124
+
125
+ 详细的架构说明请参阅 [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md)
126
+
127
+ ## 许可证
128
+
129
+ MIT
@@ -5,6 +5,7 @@
5
5
  /**
6
6
  * 创建项目
7
7
  * @param projectName 项目名称(可选)
8
+ * @returns Promise<void>
9
+ * @throws {Error} 如果项目创建过程中发生错误
8
10
  */
9
11
  export declare function createProject(projectName?: string): Promise<void>;
10
- //# sourceMappingURL=create.d.ts.map
@@ -5,13 +5,15 @@
5
5
  import process from 'node:process';
6
6
  import chalk from 'chalk';
7
7
  import ora from 'ora';
8
- import { generateProject } from '../generators/project.js';
9
- import { pathExists } from '../utils/file.js';
10
- import { initGit, installDependencies } from '../utils/install.js';
11
- import { collectProjectConfig, confirmOverwrite } from '../utils/prompts.js';
8
+ import { generateProject } from "../generators/project.js";
9
+ import { pathExists } from "../utils/file.js";
10
+ import { initGit, installDependencies } from "../utils/install.js";
11
+ import { collectProjectConfig, confirmOverwrite } from "../utils/prompts.js";
12
12
  /**
13
13
  * 创建项目
14
14
  * @param projectName 项目名称(可选)
15
+ * @returns Promise<void>
16
+ * @throws {Error} 如果项目创建过程中发生错误
15
17
  */
16
18
  export async function createProject(projectName) {
17
19
  try {
@@ -52,18 +54,21 @@ export async function createProject(projectName) {
52
54
  // 安装依赖
53
55
  const installSpinner = ora('正在安装依赖...').start();
54
56
  try {
55
- installDependencies(config.packageManager, config.targetDir);
57
+ await installDependencies(config.packageManager, config.targetDir, 1);
56
58
  installSpinner.succeed('依赖安装成功!');
57
59
  }
58
- catch {
60
+ catch (error) {
59
61
  installSpinner.fail('依赖安装失败');
60
62
  console.log(chalk.yellow('\n⚠️ 项目已创建,但依赖安装失败。'));
61
63
  console.log(chalk.yellow(` 请手动运行 "${config.packageManager} install"\n`));
64
+ if (error instanceof Error) {
65
+ console.log(chalk.gray(` 错误详情: ${error.message}`));
66
+ }
62
67
  }
63
68
  // 初始化 Git
64
69
  const gitSpinner = ora('正在初始化 Git...').start();
65
70
  try {
66
- initGit(config.targetDir);
71
+ await initGit(config.targetDir);
67
72
  gitSpinner.succeed('Git 初始化成功!');
68
73
  }
69
74
  catch {
@@ -86,4 +91,3 @@ export async function createProject(projectName) {
86
91
  process.exit(1);
87
92
  }
88
93
  }
89
- //# sourceMappingURL=create.js.map
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * 命令导出
3
3
  */
4
- export * from './create';
5
- //# sourceMappingURL=index.d.ts.map
4
+ export * from './create.ts';
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * 命令导出
3
3
  */
4
- export * from './create.js';
5
- //# sourceMappingURL=index.js.map
4
+ export * from "./create.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 项目常量定义
3
+ * 统一管理所有硬编码的字符串和配置值
4
+ */
5
+ /**
6
+ * 文件系统相关常量
7
+ */
8
+ export declare const FILE_CONSTANTS: {
9
+ /** node_modules 目录名 */
10
+ readonly NODE_MODULES: "node_modules";
11
+ /** package.json 文件名 */
12
+ readonly PACKAGE_JSON: "package.json";
13
+ /** .ejs 文件扩展名 */
14
+ readonly EJS_EXTENSION: ".ejs";
15
+ /** pnpm-workspace.yaml 文件名 */
16
+ readonly PNPM_WORKSPACE_YAML: "pnpm-workspace.yaml";
17
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 项目常量定义
3
+ * 统一管理所有硬编码的字符串和配置值
4
+ */
5
+ /**
6
+ * 文件系统相关常量
7
+ */
8
+ export const FILE_CONSTANTS = {
9
+ /** node_modules 目录名 */
10
+ NODE_MODULES: 'node_modules',
11
+ /** package.json 文件名 */
12
+ PACKAGE_JSON: 'package.json',
13
+ /** .ejs 文件扩展名 */
14
+ EJS_EXTENSION: '.ejs',
15
+ /** pnpm-workspace.yaml 文件名 */
16
+ PNPM_WORKSPACE_YAML: 'pnpm-workspace.yaml',
17
+ };
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 生成器导出
3
3
  */
4
- export * from './project';
5
- export * from './react';
6
- export * from './vue';
7
- //# sourceMappingURL=index.d.ts.map
4
+ export * from './project.ts';
5
+ export * from './react.ts';
6
+ export * from './vue.ts';
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 生成器导出
3
3
  */
4
- export * from './project.js';
5
- export * from './react.js';
6
- export * from './vue.js';
7
- //# sourceMappingURL=index.js.map
4
+ export * from "./project.js";
5
+ export * from "./react.js";
6
+ export * from "./vue.js";
@@ -2,10 +2,11 @@
2
2
  * 项目生成器
3
3
  * 根据配置生成完整的项目结构
4
4
  */
5
- import type { ProjectConfigType } from '../types';
5
+ import type { ProjectConfigType } from '../types/index.ts';
6
6
  /**
7
7
  * 生成项目
8
8
  * @param config 项目配置
9
+ * @returns Promise<void>
10
+ * @throws {Error} 如果框架不支持或项目生成失败
9
11
  */
10
12
  export declare function generateProject(config: ProjectConfigType): Promise<void>;
11
- //# sourceMappingURL=project.d.ts.map
@@ -2,12 +2,14 @@
2
2
  * 项目生成器
3
3
  * 根据配置生成完整的项目结构
4
4
  */
5
- import { emptyDir } from '../utils/file.js';
6
- import { generateReactProject } from './react.js';
7
- import { generateVueProject } from './vue.js';
5
+ import { emptyDir } from "../utils/file.js";
6
+ import { generateReactProject } from "./react.js";
7
+ import { generateVueProject } from "./vue.js";
8
8
  /**
9
9
  * 生成项目
10
10
  * @param config 项目配置
11
+ * @returns Promise<void>
12
+ * @throws {Error} 如果框架不支持或项目生成失败
11
13
  */
12
14
  export async function generateProject(config) {
13
15
  // 清空并创建项目根目录(确保干净的构建环境)
@@ -23,4 +25,3 @@ export async function generateProject(config) {
23
25
  throw new Error(`不支持的框架: ${config.framework}`);
24
26
  }
25
27
  }
26
- //# sourceMappingURL=project.js.map
@@ -2,9 +2,11 @@
2
2
  * React 项目生成器
3
3
  * 采用物理路径合并 + EJS 模板 + 数据驱动配置
4
4
  */
5
- import type { ProjectConfigType } from '../types';
5
+ import type { ProjectConfigType } from '../types/index.ts';
6
6
  /**
7
7
  * 生成 React 项目
8
+ * @param config 项目配置
9
+ * @returns Promise<void>
10
+ * @throws {Error} 如果项目生成失败
8
11
  */
9
12
  export declare function generateReactProject(config: ProjectConfigType): Promise<void>;
10
- //# sourceMappingURL=react.d.ts.map
@@ -2,38 +2,18 @@
2
2
  * React 项目生成器
3
3
  * 采用物理路径合并 + EJS 模板 + 数据驱动配置
4
4
  */
5
- import fs from 'node:fs';
6
- import path from 'node:path';
7
- import { renderEjsToFile } from '../utils/ejs.js';
8
- import { getTemplatesDir } from '../utils/file.js';
9
- import { renderCommonFeatures, renderFrameworkFeatures } from '../utils/renderFeatures.js';
10
- import { renderTemplate } from '../utils/renderTemplate.js';
11
- import { renderViteConfig } from '../utils/viteConfigRender.js';
5
+ import { generateFrameworkProject } from "../utils/index.js";
12
6
  /**
13
7
  * 生成 React 项目
8
+ * @param config 项目配置
9
+ * @returns Promise<void>
10
+ * @throws {Error} 如果项目生成失败
14
11
  */
15
12
  export async function generateReactProject(config) {
16
- const { targetDir } = config;
17
- const templatesDir = getTemplatesDir();
18
- // 1. 渲染 L0 公共基础模板
19
- renderTemplate(path.join(templatesDir, 'common', 'base'), targetDir);
20
- // 2. 渲染公共特性模板
21
- renderCommonFeatures(config, targetDir);
22
- // 3. 渲染 L1 React 基础模板
23
- renderTemplate(path.join(templatesDir, 'react', 'base'), targetDir);
24
- // 4. 渲染 L2 特性模板(统一处理)
25
- renderFrameworkFeatures(config, targetDir);
26
- // 5. 渲染 EJS 模板(main.tsx, router/index.tsx)
27
- const ejsData = {
28
- i18n: config.i18n,
29
- sentry: config.sentry,
30
- routeMode: config.routeMode,
31
- uiLibrary: config.uiLibrary,
32
- };
33
- renderEjsToFile(path.join(templatesDir, 'react', 'base', 'src', 'main.tsx.ejs'), path.join(targetDir, 'src', 'main.tsx'), ejsData);
34
- renderEjsToFile(path.join(templatesDir, 'react', 'base', 'src', 'router', 'index.tsx.ejs'), path.join(targetDir, 'src', 'router', 'index.tsx'), ejsData);
35
- // 6. 数据驱动生成 vite.config.ts
36
- const viteConfigContent = renderViteConfig(config);
37
- fs.writeFileSync(path.join(targetDir, 'vite.config.ts'), viteConfigContent);
13
+ generateFrameworkProject(config, {
14
+ mainTemplate: 'src/main.tsx.ejs',
15
+ mainOutput: 'src/main.tsx',
16
+ routerTemplate: 'src/router/index.tsx.ejs',
17
+ routerOutput: 'src/router/index.tsx',
18
+ });
38
19
  }
39
- //# sourceMappingURL=react.js.map
@@ -2,9 +2,11 @@
2
2
  * Vue 项目生成器
3
3
  * 采用物理路径合并 + EJS 模板 + 数据驱动配置
4
4
  */
5
- import type { ProjectConfigType } from '../types';
5
+ import type { ProjectConfigType } from '../types/index.ts';
6
6
  /**
7
7
  * 生成 Vue 项目
8
+ * @param config 项目配置
9
+ * @returns Promise<void>
10
+ * @throws {Error} 如果项目生成失败
8
11
  */
9
12
  export declare function generateVueProject(config: ProjectConfigType): Promise<void>;
10
- //# sourceMappingURL=vue.d.ts.map
@@ -2,39 +2,18 @@
2
2
  * Vue 项目生成器
3
3
  * 采用物理路径合并 + EJS 模板 + 数据驱动配置
4
4
  */
5
- import fs from 'node:fs';
6
- import path from 'node:path';
7
- import { renderEjsToFile } from '../utils/ejs.js';
8
- import { getTemplatesDir } from '../utils/file.js';
9
- import { renderCommonFeatures, renderFrameworkFeatures } from '../utils/renderFeatures.js';
10
- import { renderTemplate } from '../utils/renderTemplate.js';
11
- import { renderViteConfig } from '../utils/viteConfigRender.js';
5
+ import { generateFrameworkProject } from "../utils/index.js";
12
6
  /**
13
7
  * 生成 Vue 项目
8
+ * @param config 项目配置
9
+ * @returns Promise<void>
10
+ * @throws {Error} 如果项目生成失败
14
11
  */
15
12
  export async function generateVueProject(config) {
16
- const { targetDir } = config;
17
- const templatesDir = getTemplatesDir();
18
- // 1. 渲染 L0 公共基础模板
19
- renderTemplate(path.join(templatesDir, 'common', 'base'), targetDir);
20
- // 2. 渲染公共特性模板
21
- renderCommonFeatures(config, targetDir);
22
- // 3. 渲染 L1 Vue 基础模板
23
- renderTemplate(path.join(templatesDir, 'vue', 'base'), targetDir);
24
- // 4. 渲染 L2 特性模板(统一处理)
25
- renderFrameworkFeatures(config, targetDir);
26
- // 5. 渲染 EJS 模板(main.ts, router/index.ts)
27
- const ejsData = {
28
- i18n: config.i18n,
29
- sentry: config.sentry,
30
- qiankun: config.qiankun,
31
- routeMode: config.routeMode,
32
- uiLibrary: config.uiLibrary,
33
- };
34
- renderEjsToFile(path.join(templatesDir, 'vue', 'base', 'src', 'main.ts.ejs'), path.join(targetDir, 'src', 'main.ts'), ejsData);
35
- renderEjsToFile(path.join(templatesDir, 'vue', 'base', 'src', 'router', 'index.ts.ejs'), path.join(targetDir, 'src', 'router', 'index.ts'), ejsData);
36
- // 6. 数据驱动生成 vite.config.ts
37
- const viteConfigContent = renderViteConfig(config);
38
- fs.writeFileSync(path.join(targetDir, 'vite.config.ts'), viteConfigContent);
13
+ generateFrameworkProject(config, {
14
+ mainTemplate: 'src/main.ts.ejs',
15
+ mainOutput: 'src/main.ts',
16
+ routerTemplate: 'src/router/index.ts.ejs',
17
+ routerOutput: 'src/router/index.ts',
18
+ });
39
19
  }
40
- //# sourceMappingURL=vue.js.map
package/dist/index.d.ts CHANGED
@@ -4,4 +4,3 @@
4
4
  * 基于原子化分层叠加架构的项目脚手架
5
5
  */
6
6
  export {};
7
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -3,13 +3,32 @@
3
3
  * CLI 入口文件
4
4
  * 基于原子化分层叠加架构的项目脚手架
5
5
  */
6
+ import { readFileSync } from 'node:fs';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { dirname, join } from 'node:path';
6
9
  import { Command } from 'commander';
7
- import { createProject } from './commands/create.js';
10
+ import { createProject } from "./commands/index.js";
11
+ /**
12
+ * 获取 package.json 中的版本号
13
+ * @returns 版本号字符串
14
+ */
15
+ function getVersion() {
16
+ try {
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const packageJsonPath = join(__dirname, '../package.json');
20
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
21
+ return packageJson.version || '1.0.0';
22
+ }
23
+ catch {
24
+ return '1.0.0';
25
+ }
26
+ }
8
27
  const program = new Command();
9
28
  program
10
29
  .name('create-mox')
11
30
  .description('基于原子化分层叠加架构的 Vue/React 项目脚手架')
12
- .version('1.0.0');
31
+ .version(getVersion());
13
32
  program
14
33
  .command('create [project-name]')
15
34
  .description('创建新项目')
@@ -23,4 +42,3 @@ program
23
42
  await createProject(projectName);
24
43
  });
25
44
  program.parse();
26
- //# sourceMappingURL=index.js.map