@moluoxixi/create-app 2.0.412 → 2.0.414

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 (187) hide show
  1. package/README.md +57 -1
  2. package/dist/commands/create.js +1 -1
  3. package/dist/core/feature.d.ts +80 -0
  4. package/dist/core/feature.js +252 -0
  5. package/dist/core/index.d.ts +6 -0
  6. package/dist/core/index.js +6 -0
  7. package/dist/core/prompts.d.ts +17 -0
  8. package/dist/core/prompts.js +235 -0
  9. package/dist/core/template.d.ts +22 -0
  10. package/dist/core/template.js +177 -0
  11. package/dist/generators/index.d.ts +0 -2
  12. package/dist/generators/index.js +0 -2
  13. package/dist/generators/project.d.ts +1 -0
  14. package/dist/generators/project.js +66 -13
  15. package/dist/generators/react.d.ts +5 -5
  16. package/dist/generators/react.js +6 -9
  17. package/dist/generators/vue.d.ts +5 -5
  18. package/dist/generators/vue.js +6 -9
  19. package/dist/test.d.ts +0 -4
  20. package/dist/test.js +32 -17
  21. package/dist/types/index.d.ts +25 -26
  22. package/dist/types/index.js +2 -3
  23. package/dist/utils/featureMapping.js +6 -3
  24. package/dist/utils/generateFrameworkProject.d.ts +10 -20
  25. package/dist/utils/generateFrameworkProject.js +32 -127
  26. package/dist/utils/index.d.ts +1 -6
  27. package/dist/utils/index.js +1 -6
  28. package/dist/utils/prompts.js +7 -3
  29. package/package.json +2 -2
  30. package/templates/common/base/package.json +3 -1
  31. package/templates/common/base/vite/index.ts +53 -0
  32. package/templates/common/base/vite.config.ts +56 -0
  33. package/templates/common/features/husky/node_modules/.bin/tsc +17 -0
  34. package/templates/common/features/husky/node_modules/.bin/tsc.CMD +12 -0
  35. package/templates/common/features/husky/node_modules/.bin/tsc.ps1 +41 -0
  36. package/templates/common/features/husky/node_modules/.bin/tsserver +17 -0
  37. package/templates/common/features/husky/node_modules/.bin/tsserver.CMD +12 -0
  38. package/templates/common/features/husky/node_modules/.bin/tsserver.ps1 +41 -0
  39. package/templates/react/base/src/main/index.ts +34 -0
  40. package/templates/react/base/src/main.tsx +34 -0
  41. package/templates/react/base/tsconfig.app.json +1 -0
  42. package/templates/react/base/tsconfig.node.json +1 -0
  43. package/templates/react/features/ant-design/package.json +2 -1
  44. package/templates/react/features/ant-design/src/main/features/ant-design.ts +21 -0
  45. package/templates/react/features/i18n/package.json +2 -1
  46. package/templates/react/features/i18n/src/main/features/i18n.ts +19 -0
  47. package/templates/react/features/manualRoutes/package.json +1 -0
  48. package/templates/react/features/sentry/package.json +2 -1
  49. package/templates/react/features/sentry/src/main/features/sentry.ts +20 -0
  50. package/templates/react/features/sentry/vite/features/sentry.ts +39 -0
  51. package/templates/react/features/zustand/src/apis/types/user.ts +39 -0
  52. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti +17 -0
  53. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti.CMD +12 -0
  54. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/jiti.ps1 +41 -0
  55. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser +17 -0
  56. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser.CMD +12 -0
  57. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/parser.ps1 +41 -0
  58. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup +17 -0
  59. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup.CMD +12 -0
  60. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/rollup.ps1 +41 -0
  61. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass +17 -0
  62. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass.CMD +12 -0
  63. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/sass.ps1 +41 -0
  64. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser +17 -0
  65. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser.CMD +12 -0
  66. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/terser.ps1 +41 -0
  67. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc +17 -0
  68. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc.CMD +12 -0
  69. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsc.ps1 +41 -0
  70. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver +17 -0
  71. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver.CMD +12 -0
  72. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsserver.ps1 +41 -0
  73. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx +17 -0
  74. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx.CMD +12 -0
  75. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/tsx.ps1 +41 -0
  76. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite +17 -0
  77. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite.CMD +12 -0
  78. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/vite.ps1 +41 -0
  79. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml +17 -0
  80. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml.CMD +12 -0
  81. package/templates/react/micro-frontends/qiankun/base/node_modules/.bin/yaml.ps1 +41 -0
  82. package/templates/react/micro-frontends/qiankun/base/package.json +5 -2
  83. package/templates/react/micro-frontends/qiankun/base/src/main/index.ts +34 -0
  84. package/templates/react/micro-frontends/qiankun/base/src/{main.tsx.ejs → main.tsx} +13 -27
  85. package/templates/react/micro-frontends/qiankun/base/vite/index.ts +53 -0
  86. package/templates/react/micro-frontends/qiankun/base/vite.config.ts +58 -0
  87. package/templates/vue/base/src/main/index.ts +36 -0
  88. package/templates/vue/base/src/main.ts +34 -0
  89. package/templates/vue/base/tsconfig.app.json +2 -1
  90. package/templates/vue/base/tsconfig.node.json +2 -1
  91. package/templates/vue/features/ant-design-vue/package.json +3 -1
  92. package/templates/vue/features/ant-design-vue/src/main/features/ant-design-vue.ts +18 -0
  93. package/templates/vue/features/element-plus/package.json +5 -1
  94. package/templates/vue/features/element-plus/src/main/features/element-plus.ts +23 -0
  95. package/templates/vue/features/element-plus/src/stores/index.ts +6 -0
  96. package/templates/vue/features/element-plus/src/stores/modules/system.ts +51 -0
  97. package/templates/vue/features/element-plus/vite/features/element-plus.ts +35 -0
  98. package/templates/vue/features/i18n/package.json +3 -1
  99. package/templates/vue/features/i18n/src/main/features/i18n.ts +19 -0
  100. package/templates/vue/features/manualRoutes/package.json +7 -1
  101. package/templates/vue/features/manualRoutes/src/layouts/index.ts +26 -0
  102. package/templates/vue/features/manualRoutes/src/stores/index.ts +6 -0
  103. package/templates/vue/features/manualRoutes/src/stores/modules/system.ts +51 -0
  104. package/templates/vue/features/pageRoutes/package.json +7 -1
  105. package/templates/vue/features/pageRoutes/src/layouts/index.ts +26 -0
  106. package/templates/vue/features/pageRoutes/src/stores/index.ts +6 -0
  107. package/templates/vue/features/pageRoutes/src/stores/modules/system.ts +51 -0
  108. package/templates/vue/features/pinia/package.json +3 -1
  109. package/templates/vue/features/pinia/src/main/features/pinia.ts +19 -0
  110. package/templates/vue/features/sentry/package.json +4 -2
  111. package/templates/vue/features/sentry/src/main/features/sentry.ts +22 -0
  112. package/templates/vue/features/sentry/vite/features/sentry.ts +39 -0
  113. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti +17 -0
  114. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti.CMD +12 -0
  115. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/jiti.ps1 +41 -0
  116. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser +17 -0
  117. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser.CMD +12 -0
  118. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/parser.ps1 +41 -0
  119. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup +17 -0
  120. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup.CMD +12 -0
  121. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/rollup.ps1 +41 -0
  122. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass +17 -0
  123. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass.CMD +12 -0
  124. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/sass.ps1 +41 -0
  125. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser +17 -0
  126. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser.CMD +12 -0
  127. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/terser.ps1 +41 -0
  128. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc +17 -0
  129. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc.CMD +12 -0
  130. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsc.ps1 +41 -0
  131. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver +17 -0
  132. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver.CMD +12 -0
  133. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsserver.ps1 +41 -0
  134. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx +17 -0
  135. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx.CMD +12 -0
  136. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/tsx.ps1 +41 -0
  137. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite +17 -0
  138. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite.CMD +12 -0
  139. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/vite.ps1 +41 -0
  140. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml +17 -0
  141. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml.CMD +12 -0
  142. package/templates/vue/micro-frontends/qiankun/base/node_modules/.bin/yaml.ps1 +41 -0
  143. package/templates/vue/micro-frontends/qiankun/base/package.json +5 -2
  144. package/templates/vue/micro-frontends/qiankun/base/src/main/index.ts +36 -0
  145. package/templates/vue/micro-frontends/qiankun/base/src/{main.ts.ejs → main.ts} +11 -28
  146. package/templates/vue/micro-frontends/qiankun/base/vite/index.ts +53 -0
  147. package/templates/vue/micro-frontends/qiankun/base/vite.config.ts +59 -0
  148. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti +17 -0
  149. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti.CMD +12 -0
  150. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/jiti.ps1 +41 -0
  151. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass +17 -0
  152. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass.CMD +12 -0
  153. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/sass.ps1 +41 -0
  154. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser +17 -0
  155. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser.CMD +12 -0
  156. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/terser.ps1 +41 -0
  157. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc +17 -0
  158. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc.CMD +12 -0
  159. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsc.ps1 +41 -0
  160. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver +17 -0
  161. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver.CMD +12 -0
  162. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsserver.ps1 +41 -0
  163. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx +17 -0
  164. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx.CMD +12 -0
  165. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/tsx.ps1 +41 -0
  166. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite +17 -0
  167. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite.CMD +12 -0
  168. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/vite.ps1 +41 -0
  169. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml +17 -0
  170. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml.CMD +12 -0
  171. package/templates/vue/micro-frontends/qiankun/features/element-plus/node_modules/.bin/yaml.ps1 +41 -0
  172. package/templates/vue/micro-frontends/qiankun/features/element-plus/package.json +10 -0
  173. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/index.ts +8 -0
  174. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/_types/index.ts +1 -0
  175. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/_types/props.ts +16 -0
  176. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/components/SubMenu/src/index.vue +60 -0
  177. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/main/features/element-plus.ts +24 -0
  178. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/stores/index.ts +6 -0
  179. package/templates/vue/micro-frontends/qiankun/features/element-plus/src/stores/modules/system.ts +51 -0
  180. package/templates/vue/micro-frontends/qiankun/features/element-plus/vite/features/element-plus.ts +35 -0
  181. package/templates/vue/micro-frontends/qiankun/features/manualRoutes/package.json +6 -1
  182. package/templates/vue/micro-frontends/qiankun/features/pageRoutes/package.json +6 -1
  183. package/templates/common/base/vite.config.ts.ejs +0 -85
  184. package/templates/react/base/src/main.tsx.ejs +0 -56
  185. package/templates/react/micro-frontends/qiankun/base/vite.config.ts.ejs +0 -89
  186. package/templates/vue/base/src/main.ts.ejs +0 -61
  187. package/templates/vue/micro-frontends/qiankun/base/vite.config.ts.ejs +0 -89
@@ -8,11 +8,12 @@ import path from 'node:path';
8
8
  import { getTemplatesDir } from "./file.js";
9
9
  /**
10
10
  * UI 库优先级顺序(用于排序,确保默认选择)
11
+ * TODO: ant-design-vue 和 ant-design (React) 功能暂时关闭
11
12
  */
12
13
  const UI_LIBRARY_PRIORITY = {
13
14
  'element-plus': 1,
14
- 'ant-design-vue': 2,
15
- 'ant-design': 1,
15
+ // 'ant-design-vue': 2, // TODO: 暂时关闭
16
+ // 'ant-design': 1, // TODO: 暂时关闭 (React)
16
17
  };
17
18
  /**
18
19
  * 扫描所有 features(框架的 + 公共的)
@@ -49,7 +50,9 @@ export function scanAllFeatures(framework) {
49
50
  */
50
51
  export function featureToConfig(feature, _framework) {
51
52
  // UI 库:配置键是 uiLibrary,值是 feature 名称
52
- const uiLibraries = ['element-plus', 'ant-design-vue', 'ant-design'];
53
+ // TODO: ant-design-vue ant-design (React) 功能暂时关闭
54
+ // const uiLibraries = ['element-plus', 'ant-design-vue', 'ant-design']
55
+ const uiLibraries = ['element-plus'];
53
56
  if (uiLibraries.includes(feature)) {
54
57
  return { key: 'uiLibrary', value: feature };
55
58
  }
@@ -1,25 +1,15 @@
1
1
  /**
2
- * 框架项目生成通用工具
3
- * 抽离 react.ts vue.ts 的公共逻辑
4
- * 支持三层嵌套优先级(L1: common, L2: framework, L3: micro-frontend
2
+ * Framework project generation utility
3
+ * Extract common logic from react.ts and vue.ts
4
+ * Support three-layer nested priority (L1: common, L2: framework, L3: micro-frontend)
5
+ * No longer uses EJS templates - all templates are fixed TypeScript files
5
6
  */
6
7
  import type { ProjectConfigType } from '../types/index.ts';
7
8
  /**
8
- * EJS 模板配置接口
9
- * 定义框架项目生成所需的模板路径配置
9
+ * Generate framework project
10
+ * Render templates in three-layer nested priority: L1 (common) -> L2 (framework) -> L3 (micro-frontend)
11
+ * Uses fixed TypeScript templates with glob import for feature discovery
12
+ * @param config - Project configuration
13
+ * @throws {Error} If template rendering fails, file writing fails, or configuration generation fails
10
14
  */
11
- interface EjsTemplateConfig {
12
- /** 主入口文件模板路径(相对于框架 base 目录) */
13
- mainTemplate: string;
14
- /** 主入口文件输出路径(相对于目标目录) */
15
- mainOutput: string;
16
- }
17
- /**
18
- * 生成框架项目的通用函数
19
- * 按照三层嵌套优先级渲染模板:L1 (common) -> L2 (framework) -> L3 (micro-frontend)
20
- * @param config 项目配置
21
- * @param ejsConfig EJS 模板配置
22
- * @throws {Error} 如果模板渲染失败、文件写入失败或配置生成失败
23
- */
24
- export declare function generateFrameworkProject(config: ProjectConfigType, ejsConfig: EjsTemplateConfig): void;
25
- export {};
15
+ export declare function generateFrameworkProject(config: ProjectConfigType): void;
@@ -1,162 +1,67 @@
1
1
  /**
2
- * 框架项目生成通用工具
3
- * 抽离 react.ts vue.ts 的公共逻辑
4
- * 支持三层嵌套优先级(L1: common, L2: framework, L3: micro-frontend
2
+ * Framework project generation utility
3
+ * Extract common logic from react.ts and vue.ts
4
+ * Support three-layer nested priority (L1: common, L2: framework, L3: micro-frontend)
5
+ * No longer uses EJS templates - all templates are fixed TypeScript files
5
6
  */
6
- import fs from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { FILE_CONSTANTS } from "../constants/index.js";
9
- import { renderEjsToFile } from "./ejs.js";
10
9
  import { getTemplatesDir } from "./file.js";
11
10
  import { renderCommonFeatures, renderFrameworkFeatures, renderMicroFrontendFeatures } from "./renderFeatures.js";
12
11
  import { renderTemplate, updatePackageJsonMetadata } from "./index.js";
13
- import { getViteConfigEjsData } from "./viteConfigRender.js";
14
12
  /**
15
- * 获取 EJS 模板路径(完整优先级查找)
16
- * 优先级:微前端 feature > 微前端 base > 框架 feature > 框架 base > common feature > common base
17
- * @param templatesDir 模板根目录
18
- * @param framework 框架类型
19
- * @param config 项目配置(用于获取启用的 features)
20
- * @param templatePath 模板文件路径(相对于 base 目录)
21
- * @returns EJS 模板文件路径
22
- */
23
- function getEjsTemplatePath(templatesDir, framework, config, templatePath) {
24
- const { microFrontend, microFrontendEngine } = config;
25
- // 获取所有启用的 features(包括 UI 库)
26
- const enabledFeatures = [];
27
- for (const [key, value] of Object.entries(config)) {
28
- if (value === true && typeof key === 'string') {
29
- enabledFeatures.push(key);
30
- }
31
- }
32
- if (config.uiLibrary) {
33
- enabledFeatures.push(config.uiLibrary);
34
- }
35
- // 1. 微前端 feature(按优先级顺序检查每个启用的 feature)
36
- if (microFrontend && microFrontendEngine) {
37
- for (const feature of enabledFeatures) {
38
- const microFrontendFeaturePath = path.join(templatesDir, framework, 'micro-frontends', microFrontendEngine, 'features', feature, templatePath);
39
- if (fs.existsSync(microFrontendFeaturePath)) {
40
- return microFrontendFeaturePath;
41
- }
42
- }
43
- }
44
- // 2. 微前端 base
45
- if (microFrontend && microFrontendEngine) {
46
- const microFrontendBasePath = path.join(templatesDir, framework, 'micro-frontends', microFrontendEngine, 'base', templatePath);
47
- if (fs.existsSync(microFrontendBasePath)) {
48
- return microFrontendBasePath;
49
- }
50
- }
51
- // 3. 框架 feature(按优先级顺序检查每个启用的 feature)
52
- for (const feature of enabledFeatures) {
53
- const frameworkFeaturePath = path.join(templatesDir, framework, 'features', feature, templatePath);
54
- if (fs.existsSync(frameworkFeaturePath)) {
55
- return frameworkFeaturePath;
56
- }
57
- }
58
- // 4. 框架 base
59
- const frameworkBasePath = path.join(templatesDir, framework, 'base', templatePath);
60
- if (fs.existsSync(frameworkBasePath)) {
61
- return frameworkBasePath;
62
- }
63
- // 5. common feature(按优先级顺序检查每个启用的 feature)
64
- for (const feature of enabledFeatures) {
65
- const commonFeaturePath = path.join(templatesDir, 'common', 'features', feature, templatePath);
66
- if (fs.existsSync(commonFeaturePath)) {
67
- return commonFeaturePath;
68
- }
69
- }
70
- // 6. common base(最终回退)
71
- return path.join(templatesDir, 'common', 'base', templatePath);
72
- }
73
- /**
74
- * 渲染所有基础模板(base 模板)
75
- * 按照三层嵌套优先级渲染:L1 (common) -> L2 (framework) -> L3 (micro-frontend)
76
- * @param templatesDir 模板根目录
77
- * @param framework 框架类型
78
- * @param microFrontend 是否启用微前端
79
- * @param microFrontendEngine 微前端引擎类型
80
- * @param targetDir 目标目录
81
- * @throws {Error} 如果模板渲染失败
13
+ * Render all base templates
14
+ * Render in three-layer nested priority: L1 (common) -> L2 (framework) -> L3 (micro-frontend)
15
+ * @param templatesDir - Templates root directory
16
+ * @param framework - Framework type
17
+ * @param microFrontend - Whether micro-frontend is enabled
18
+ * @param microFrontendEngine - Micro-frontend engine type
19
+ * @param targetDir - Target directory
20
+ * @throws {Error} If template rendering fails
82
21
  */
83
22
  function renderBaseTemplates(templatesDir, framework, microFrontend, microFrontendEngine, targetDir) {
84
- // 1. 渲染 L1: 公共基础模板(通用层)
23
+ // 1. Render L1: Common base template (universal layer)
85
24
  renderTemplate(path.join(templatesDir, 'common', 'base'), targetDir);
86
- // 2. 渲染 L2: 框架基础模板(框架标准层)
25
+ // 2. Render L2: Framework base template (framework standard layer)
87
26
  renderTemplate(path.join(templatesDir, framework, 'base'), targetDir);
88
- // 3. 渲染 L3: 微前端基础模板(架构增强层)- 按需覆盖
27
+ // 3. Render L3: Micro-frontend base template (architecture enhancement layer) - on-demand override
89
28
  if (microFrontend && microFrontendEngine) {
90
29
  const microFrontendPath = path.join(templatesDir, framework, 'micro-frontends', microFrontendEngine, 'base');
91
30
  renderTemplate(microFrontendPath, targetDir);
92
31
  }
93
32
  }
94
33
  /**
95
- * 渲染所有特性模板(features)
96
- * 按照三层嵌套优先级渲染:common features -> framework features -> micro-frontend features
97
- * @param config 项目配置
98
- * @param targetDir 目标目录
99
- * @throws {Error} 如果特性渲染失败
34
+ * Render all feature templates
35
+ * Render in three-layer nested priority: common features -> framework features -> micro-frontend features
36
+ * @param config - Project configuration
37
+ * @param targetDir - Target directory
38
+ * @throws {Error} If feature rendering fails
100
39
  */
101
40
  function renderAllFeatures(config, targetDir) {
102
- // 1. 渲染公共特性模板
41
+ // 1. Render common feature templates
103
42
  renderCommonFeatures(config, targetDir);
104
- // 2. 渲染框架特性模板
43
+ // 2. Render framework feature templates
105
44
  renderFrameworkFeatures(config, targetDir);
106
- // 3. 渲染微前端专属的 features(覆盖标准 features
45
+ // 3. Render micro-frontend specific features (override standard features)
107
46
  if (config.microFrontend && config.microFrontendEngine) {
108
47
  renderMicroFrontendFeatures(config, targetDir, config.microFrontendEngine);
109
48
  }
110
49
  }
111
50
  /**
112
- * 渲染所有 EJS 模板
113
- * 包括主入口文件和 vite.config.ts,按照完整优先级查找模板
114
- * @param templatesDir 模板根目录
115
- * @param framework 框架类型
116
- * @param config 项目配置
117
- * @param ejsConfig EJS 模板配置
118
- * @param targetDir 目标目录
119
- * @throws {Error} 如果 EJS 模板渲染失败
120
- */
121
- function renderEjsTemplates(templatesDir, framework, config, ejsConfig, targetDir) {
122
- // 准备 EJS 数据
123
- const ejsData = {
124
- i18n: config.i18n,
125
- sentry: config.sentry,
126
- routeMode: config.routeMode,
127
- uiLibrary: config.uiLibrary,
128
- // Store management features
129
- pinia: config.pinia,
130
- zustand: config.zustand,
131
- // Router features (derived from routeMode)
132
- hasRouter: config.manualRoutes || config.pageRoutes,
133
- };
134
- // 渲染主入口文件 EJS 模板(完整优先级查找)
135
- const mainTemplatePath = getEjsTemplatePath(templatesDir, framework, config, ejsConfig.mainTemplate);
136
- renderEjsToFile(mainTemplatePath, path.join(targetDir, ejsConfig.mainOutput), ejsData);
137
- // Router 已通过 feature 覆盖实现(manualRoutes/pageRoutes),不再使用 EJS
138
- // 渲染 vite.config.ts(使用 EJS 模板,完整优先级查找)
139
- const viteConfigEjsData = getViteConfigEjsData(config);
140
- const viteConfigTemplatePath = getEjsTemplatePath(templatesDir, framework, config, 'vite.config.ts.ejs');
141
- renderEjsToFile(viteConfigTemplatePath, path.join(targetDir, 'vite.config.ts'), viteConfigEjsData);
142
- }
143
- /**
144
- * 生成框架项目的通用函数
145
- * 按照三层嵌套优先级渲染模板:L1 (common) -> L2 (framework) -> L3 (micro-frontend)
146
- * @param config 项目配置
147
- * @param ejsConfig EJS 模板配置
148
- * @throws {Error} 如果模板渲染失败、文件写入失败或配置生成失败
51
+ * Generate framework project
52
+ * Render templates in three-layer nested priority: L1 (common) -> L2 (framework) -> L3 (micro-frontend)
53
+ * Uses fixed TypeScript templates with glob import for feature discovery
54
+ * @param config - Project configuration
55
+ * @throws {Error} If template rendering fails, file writing fails, or configuration generation fails
149
56
  */
150
- export function generateFrameworkProject(config, ejsConfig) {
57
+ export function generateFrameworkProject(config) {
151
58
  const { targetDir, framework, microFrontend, microFrontendEngine } = config;
152
59
  const templatesDir = getTemplatesDir();
153
- // 1. 渲染所有基础模板(base 模板)
60
+ // 1. Render all base templates
154
61
  renderBaseTemplates(templatesDir, framework, microFrontend, microFrontendEngine, targetDir);
155
- // 2. 渲染所有特性模板(features)
62
+ // 2. Render all feature templates
156
63
  renderAllFeatures(config, targetDir);
157
- // 3. 渲染所有 EJS 模板
158
- renderEjsTemplates(templatesDir, framework, config, ejsConfig, targetDir);
159
- // 4. 更新 package.json 的元数据字段
64
+ // 3. Update package.json metadata fields
160
65
  const packageJsonPath = path.join(targetDir, FILE_CONSTANTS.PACKAGE_JSON);
161
66
  updatePackageJsonMetadata(packageJsonPath, config.projectName, config.description, config.author, config.packageManager);
162
67
  }
@@ -1,14 +1,9 @@
1
1
  /**
2
2
  * 工具函数导出
3
+ * 仅包含纯工具函数,业务逻辑在 core/ 目录
3
4
  */
4
5
  export * from './deepMerge.ts';
5
- export * from './ejs.ts';
6
6
  export * from './file.ts';
7
- export * from './generateFrameworkProject.ts';
8
7
  export * from './install.ts';
9
8
  export * from './npmConfig.ts';
10
- export * from './prompts.ts';
11
- export { updatePackageJsonMetadata } from './renderTemplate.ts';
12
- export * from './renderTemplate.ts';
13
9
  export * from './sortDependencies.ts';
14
- export * from './viteConfigRender.ts';
@@ -1,14 +1,9 @@
1
1
  /**
2
2
  * 工具函数导出
3
+ * 仅包含纯工具函数,业务逻辑在 core/ 目录
3
4
  */
4
5
  export * from "./deepMerge.js";
5
- export * from "./ejs.js";
6
6
  export * from "./file.js";
7
- export * from "./generateFrameworkProject.js";
8
7
  export * from "./install.js";
9
8
  export * from "./npmConfig.js";
10
- export * from "./prompts.js";
11
- export { updatePackageJsonMetadata } from "./renderTemplate.js";
12
- export * from "./renderTemplate.js";
13
9
  export * from "./sortDependencies.js";
14
- export * from "./viteConfigRender.js";
@@ -94,7 +94,8 @@ export async function collectProjectConfig(projectName) {
94
94
  message: '选择框架:',
95
95
  choices: [
96
96
  { name: 'Vue 3', value: 'vue' },
97
- { name: 'React', value: 'react' },
97
+ // TODO: React 功能暂时关闭
98
+ // { name: 'React', value: 'react' },
98
99
  ],
99
100
  },
100
101
  // UI 库选择
@@ -106,11 +107,14 @@ export async function collectProjectConfig(projectName) {
106
107
  if (answers.framework === 'vue') {
107
108
  return [
108
109
  { name: 'Element Plus', value: 'element-plus' },
109
- { name: 'Ant Design Vue', value: 'ant-design-vue' },
110
+ // TODO: Ant Design Vue 功能暂时关闭
111
+ // { name: 'Ant Design Vue', value: 'ant-design-vue' },
110
112
  ];
111
113
  }
112
114
  else {
113
- return [{ name: 'Ant Design', value: 'ant-design' }];
115
+ // TODO: React 功能暂时关闭
116
+ // return [{ name: 'Ant Design', value: 'ant-design' }]
117
+ return [];
114
118
  }
115
119
  },
116
120
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/create-app",
3
- "version": "2.0.412",
3
+ "version": "2.0.414",
4
4
  "type": "module",
5
5
  "description": "Create Vue/React projects with atomic layered architecture",
6
6
  "main": "dist/index.js",
@@ -76,7 +76,7 @@
76
76
  "test": "tsx src/test.ts",
77
77
  "type-check": "tsc --noEmit",
78
78
  "lint:eslint": "eslint . --fix",
79
- "submodule:update": "git submodule init && git submodule update --init --recursive",
79
+ "submodule:update": "git submodule update --init --recursive --remote",
80
80
  "lint-staged": "lint-staged",
81
81
  "commit": "git add . && git-cz",
82
82
  "version:patch": "pnpm version patch --no-git-tag-version",
@@ -9,7 +9,7 @@
9
9
  "packageManager": "pnpm@10.8.0",
10
10
  "scripts": {
11
11
  "dev": "vite",
12
- "submodule:update": "git init && git submodule init && git submodule update --init --recursive",
12
+ "submodule:update": "git submodule update --init --recursive",
13
13
  "prepare": "pnpm submodule:update",
14
14
  "build": "vite build --mode production",
15
15
  "build:zip": "vite build --mode production && tsx scripts/build.mts",
@@ -32,6 +32,8 @@
32
32
  "uuid": "^11.1.0"
33
33
  },
34
34
  "devDependencies": {
35
+ "@moluoxixi/css-module-global-root-plugin": "latest",
36
+ "@moluoxixi/vite-config": "latest",
35
37
  "@types/crypto-js": "^4.2.2",
36
38
  "@types/lodash-es": "^4.17.12",
37
39
  "@types/node": "^22.14.0",
@@ -0,0 +1,53 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import { mergeConfig } from 'vite'
5
+ import type { UserConfig } from 'vite'
6
+ import { createJiti } from 'jiti'
7
+
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
+ const _require = createJiti(import.meta.url, { interopDefault: true })
10
+
11
+ /**
12
+ * Vite feature 配置上下文
13
+ */
14
+ export interface ViteFeatureContext {
15
+ /** Vite 环境变量 */
16
+ viteEnv: Record<string, any>
17
+ /** 构建模式 */
18
+ mode: string
19
+ /** 应用代码 */
20
+ appCode: string
21
+ }
22
+
23
+ /**
24
+ * 加载所有 feature 的 Vite 配置
25
+ * @param ctx - feature 配置上下文
26
+ * @returns 合并后的 UserConfig
27
+ */
28
+ export function loadFeatureConfigs(ctx: ViteFeatureContext): UserConfig {
29
+ const featuresDir = path.resolve(__dirname, 'features')
30
+
31
+ if (!fs.existsSync(featuresDir)) {
32
+ return {}
33
+ }
34
+
35
+ const featureFiles = fs.readdirSync(featuresDir).filter(f => f.endsWith('.ts'))
36
+ const configs: UserConfig[] = []
37
+
38
+ for (const file of featureFiles) {
39
+ try {
40
+ const filePath = path.resolve(featuresDir, file)
41
+ const mod = _require(filePath)
42
+ const config = mod.default(ctx)
43
+ if (config) {
44
+ configs.push(config)
45
+ }
46
+ }
47
+ catch (e) {
48
+ console.warn(`[Vite] Failed to load feature config: ${file}`, e)
49
+ }
50
+ }
51
+
52
+ return configs.reduce((acc, cfg) => mergeConfig(acc, cfg), {} as UserConfig)
53
+ }
@@ -0,0 +1,56 @@
1
+ import path from 'node:path'
2
+ import cssModuleGlobalRootPlugin from '@moluoxixi/css-module-global-root-plugin'
3
+ import { ViteConfig, wrapperEnv } from '@moluoxixi/vite-config'
4
+ import { loadEnv, mergeConfig } from 'vite'
5
+ import process from 'node:process'
6
+ import { loadFeatureConfigs } from './vite/index.ts'
7
+
8
+ const config: ReturnType<typeof ViteConfig> = ViteConfig(({ mode }) => {
9
+ const env = loadEnv(mode!, process.cwd())
10
+ const viteEnv = wrapperEnv(env)
11
+ const rootPath = path.resolve()
12
+ const appCode = viteEnv.VITE_APP_CODE
13
+ const appTitle = viteEnv.VITE_APP_TITLE
14
+ const port = viteEnv.VITE_APP_PORT
15
+
16
+ // 加载所有 feature 配置
17
+ const featureConfig = loadFeatureConfigs({ viteEnv, mode: mode!, appCode })
18
+
19
+ return {
20
+ rootPath,
21
+ appTitle,
22
+ appCode,
23
+ port,
24
+ vue: true,
25
+ autoComponent: true,
26
+ pageRoutes: true,
27
+ viteConfig: mergeConfig(
28
+ {
29
+ server: {
30
+ proxy: {
31
+ '/api': {
32
+ changeOrigin: true,
33
+ target: 'http://localhost:3000',
34
+ },
35
+ },
36
+ },
37
+ css: {
38
+ preprocessorOptions: {
39
+ scss: {
40
+ silenceDeprecations: ['legacy-js-api'],
41
+ api: 'modern-compiler',
42
+ },
43
+ postcss: {
44
+ plugins: [
45
+ cssModuleGlobalRootPlugin() as any,
46
+ ],
47
+ },
48
+ },
49
+ },
50
+ },
51
+ featureConfig,
52
+ ),
53
+ }
54
+ })
55
+
56
+ export default config
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" "$@"
15
+ else
16
+ exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" "$@"
17
+ fi
@@ -0,0 +1,12 @@
1
+ @SETLOCAL
2
+ @IF NOT DEFINED NODE_PATH (
3
+ @SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
4
+ ) ELSE (
5
+ @SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules;%NODE_PATH%"
6
+ )
7
+ @IF EXIST "%~dp0\node.exe" (
8
+ "%~dp0\node.exe" "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsc" %*
9
+ ) ELSE (
10
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
11
+ node "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsc" %*
12
+ )
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env pwsh
2
+ $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+ $exe=""
5
+ $pathsep=":"
6
+ $env_node_path=$env:NODE_PATH
7
+ $new_node_path="E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
8
+ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
9
+ # Fix case when both the Windows and Linux builds of Node
10
+ # are installed in the same directory
11
+ $exe=".exe"
12
+ $pathsep=";"
13
+ } else {
14
+ $new_node_path="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
15
+ }
16
+ if ([string]::IsNullOrEmpty($env_node_path)) {
17
+ $env:NODE_PATH=$new_node_path
18
+ } else {
19
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
20
+ }
21
+
22
+ $ret=0
23
+ if (Test-Path "$basedir/node$exe") {
24
+ # Support pipeline input
25
+ if ($MyInvocation.ExpectingInput) {
26
+ $input | & "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
27
+ } else {
28
+ & "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
29
+ }
30
+ $ret=$LASTEXITCODE
31
+ } else {
32
+ # Support pipeline input
33
+ if ($MyInvocation.ExpectingInput) {
34
+ $input | & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
35
+ } else {
36
+ & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsc" $args
37
+ }
38
+ $ret=$LASTEXITCODE
39
+ }
40
+ $env:NODE_PATH=$env_node_path
41
+ exit $ret
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
+ esac
7
+
8
+ if [ -z "$NODE_PATH" ]; then
9
+ export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules:$NODE_PATH"
12
+ fi
13
+ if [ -x "$basedir/node" ]; then
14
+ exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" "$@"
15
+ else
16
+ exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" "$@"
17
+ fi
@@ -0,0 +1,12 @@
1
+ @SETLOCAL
2
+ @IF NOT DEFINED NODE_PATH (
3
+ @SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
4
+ ) ELSE (
5
+ @SET "NODE_PATH=E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules;%NODE_PATH%"
6
+ )
7
+ @IF EXIST "%~dp0\node.exe" (
8
+ "%~dp0\node.exe" "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsserver" %*
9
+ ) ELSE (
10
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
11
+ node "%~dp0\..\..\..\..\..\..\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\tsserver" %*
12
+ )
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env pwsh
2
+ $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+ $exe=""
5
+ $pathsep=":"
6
+ $env_node_path=$env:NODE_PATH
7
+ $new_node_path="E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\bin\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules\typescript\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\typescript@5.8.3\node_modules;E:\project\template\vite-cli\node_modules\.pnpm\node_modules"
8
+ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
9
+ # Fix case when both the Windows and Linux builds of Node
10
+ # are installed in the same directory
11
+ $exe=".exe"
12
+ $pathsep=";"
13
+ } else {
14
+ $new_node_path="/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/typescript@5.8.3/node_modules:/mnt/e/project/template/vite-cli/node_modules/.pnpm/node_modules"
15
+ }
16
+ if ([string]::IsNullOrEmpty($env_node_path)) {
17
+ $env:NODE_PATH=$new_node_path
18
+ } else {
19
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
20
+ }
21
+
22
+ $ret=0
23
+ if (Test-Path "$basedir/node$exe") {
24
+ # Support pipeline input
25
+ if ($MyInvocation.ExpectingInput) {
26
+ $input | & "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" $args
27
+ } else {
28
+ & "$basedir/node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" $args
29
+ }
30
+ $ret=$LASTEXITCODE
31
+ } else {
32
+ # Support pipeline input
33
+ if ($MyInvocation.ExpectingInput) {
34
+ $input | & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" $args
35
+ } else {
36
+ & "node$exe" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/bin/tsserver" $args
37
+ }
38
+ $ret=$LASTEXITCODE
39
+ }
40
+ $env:NODE_PATH=$env_node_path
41
+ exit $ret