@moluoxixi/create-app 2.0.1
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.
- package/LICENSE.txt +21 -0
- package/README.md +129 -0
- package/dist/commands/create.d.ts +10 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +89 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/generators/index.d.ts +7 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +7 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/project.d.ts +11 -0
- package/dist/generators/project.d.ts.map +1 -0
- package/dist/generators/project.js +26 -0
- package/dist/generators/project.js.map +1 -0
- package/dist/generators/react.d.ts +10 -0
- package/dist/generators/react.d.ts.map +1 -0
- package/dist/generators/react.js +39 -0
- package/dist/generators/react.js.map +1 -0
- package/dist/generators/vue.d.ts +10 -0
- package/dist/generators/vue.d.ts.map +1 -0
- package/dist/generators/vue.js +40 -0
- package/dist/generators/vue.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/test.d.ts +6 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +364 -0
- package/dist/test.js.map +1 -0
- package/dist/types/ejs.d.ts +11 -0
- package/dist/types/ejs.d.ts.map +1 -0
- package/dist/types/ejs.js +5 -0
- package/dist/types/ejs.js.map +1 -0
- package/dist/types/features.d.ts +26 -0
- package/dist/types/features.d.ts.map +1 -0
- package/dist/types/features.js +41 -0
- package/dist/types/features.js.map +1 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/viteConfig.d.ts +17 -0
- package/dist/types/viteConfig.d.ts.map +1 -0
- package/dist/types/viteConfig.js +6 -0
- package/dist/types/viteConfig.js.map +1 -0
- package/dist/utils/deepMerge.d.ts +8 -0
- package/dist/utils/deepMerge.d.ts.map +1 -0
- package/dist/utils/deepMerge.js +33 -0
- package/dist/utils/deepMerge.js.map +1 -0
- package/dist/utils/ejs.d.ts +19 -0
- package/dist/utils/ejs.d.ts.map +1 -0
- package/dist/utils/ejs.js +30 -0
- package/dist/utils/ejs.js.map +1 -0
- package/dist/utils/file.d.ts +70 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +119 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/install.d.ts +17 -0
- package/dist/utils/install.d.ts.map +1 -0
- package/dist/utils/install.js +37 -0
- package/dist/utils/install.js.map +1 -0
- package/dist/utils/prompts.d.ts +16 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +180 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/renderFeatures.d.ts +18 -0
- package/dist/utils/renderFeatures.d.ts.map +1 -0
- package/dist/utils/renderFeatures.js +72 -0
- package/dist/utils/renderFeatures.js.map +1 -0
- package/dist/utils/renderTemplate.d.ts +6 -0
- package/dist/utils/renderTemplate.d.ts.map +1 -0
- package/dist/utils/renderTemplate.js +102 -0
- package/dist/utils/renderTemplate.js.map +1 -0
- package/dist/utils/sortDependencies.d.ts +6 -0
- package/dist/utils/sortDependencies.d.ts.map +1 -0
- package/dist/utils/sortDependencies.js +22 -0
- package/dist/utils/sortDependencies.js.map +1 -0
- package/dist/utils/viteConfigRender.d.ts +19 -0
- package/dist/utils/viteConfigRender.d.ts.map +1 -0
- package/dist/utils/viteConfigRender.js +180 -0
- package/dist/utils/viteConfigRender.js.map +1 -0
- package/package.json +93 -0
- package/templates/common/base/.env +7 -0
- package/templates/common/base/.env.development +5 -0
- package/templates/common/base/.env.production +5 -0
- package/templates/common/base/package.json +56 -0
- package/templates/common/base/pnpm-workspace.yaml +37 -0
- package/templates/common/base/scripts/build.mts +31 -0
- package/templates/common/base/src/apis/index.ts +8 -0
- package/templates/common/base/src/apis/request.ts +43 -0
- package/templates/common/base/src/apis/services/example.ts +40 -0
- package/templates/common/base/src/apis/services/user.ts +23 -0
- package/templates/common/base/src/apis/types/common.ts +28 -0
- package/templates/common/base/src/apis/types/example.ts +18 -0
- package/templates/common/base/src/apis/types/index.ts +7 -0
- package/templates/common/base/src/apis/types/user.ts +24 -0
- package/templates/common/base/src/assets/fonts/index.css +7 -0
- package/templates/common/base/src/assets/styles/base.scss +72 -0
- package/templates/common/base/src/assets/styles/custom.scss +7 -0
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -0
- package/templates/common/base/src/constants/index.ts +29 -0
- package/templates/common/base/src/locales/lang/en.ts +30 -0
- package/templates/common/base/src/locales/lang/es.ts +30 -0
- package/templates/common/base/src/locales/lang/zh.ts +30 -0
- package/templates/common/base/src/utils/index.ts +83 -0
- package/templates/common/features/husky/.cz-config.cjs +35 -0
- package/templates/common/features/husky/.husky/commit-msg +9 -0
- package/templates/common/features/husky/.husky/install.mjs +6 -0
- package/templates/common/features/husky/.husky/pre-commit +4 -0
- package/templates/common/features/husky/commitlint.config.ts +32 -0
- package/templates/common/features/husky/package.json +28 -0
- package/templates/common/features/husky/pnpm-workspace.yaml +9 -0
- package/templates/react/base/env.d.ts +19 -0
- package/templates/react/base/index.html +14 -0
- package/templates/react/base/package.json +15 -0
- package/templates/react/base/pnpm-workspace.yaml +9 -0
- package/templates/react/base/src/App.tsx +18 -0
- package/templates/react/base/src/assets/styles/main.scss +8 -0
- package/templates/react/base/src/main.tsx.ejs +39 -0
- package/templates/react/base/src/pages/about/index.tsx +14 -0
- package/templates/react/base/src/pages/home/index.tsx +14 -0
- package/templates/react/base/src/router/index.tsx.ejs +28 -0
- package/templates/react/base/src/stores/user.ts +39 -0
- package/templates/react/base/tsconfig.app.json +17 -0
- package/templates/react/base/tsconfig.base.json +23 -0
- package/templates/react/base/tsconfig.json +12 -0
- package/templates/react/base/tsconfig.node.json +15 -0
- package/templates/react/base/vite.config.ts +52 -0
- package/templates/react/features/ant-design/package.json +7 -0
- package/templates/react/features/ant-design/pnpm-workspace.yaml +5 -0
- package/templates/react/features/eslint/eslint.config.ts +12 -0
- package/templates/react/features/eslint/package.json +7 -0
- package/templates/react/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/react/features/i18n/package.json +7 -0
- package/templates/react/features/i18n/pnpm-workspace.yaml +5 -0
- package/templates/react/features/i18n/src/locales/index.ts +20 -0
- package/templates/react/features/manualRoutes/src/router/routes.tsx +21 -0
- package/templates/react/features/pageRoutes/package.json +6 -0
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/react/features/pageRoutes/vite.config.data.ts +10 -0
- package/templates/react/features/router/package.json +5 -0
- package/templates/react/features/router/pnpm-workspace.yaml +3 -0
- package/templates/react/features/sentry/package.json +7 -0
- package/templates/react/features/sentry/pnpm-workspace.yaml +5 -0
- package/templates/react/features/sentry/src/utils/sentry.ts +30 -0
- package/templates/react/features/sentry/vite.config.data.ts +23 -0
- package/templates/react/features/zustand/package.json +5 -0
- package/templates/react/features/zustand/pnpm-workspace.yaml +3 -0
- package/templates/react/features/zustand/src/stores/user.ts +19 -0
- package/templates/react/features/zustand/src/types/stores.ts +15 -0
- package/templates/vue/base/env.d.ts +27 -0
- package/templates/vue/base/index.html +14 -0
- package/templates/vue/base/package.json +13 -0
- package/templates/vue/base/pnpm-workspace.yaml +6 -0
- package/templates/vue/base/src/App.vue +13 -0
- package/templates/vue/base/src/assets/styles/element/index.scss +27 -0
- package/templates/vue/base/src/assets/styles/main.scss +9 -0
- package/templates/vue/base/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/index.ts +6 -0
- package/templates/vue/base/src/components/SubMenu/src/_types/props.ts +11 -0
- package/templates/vue/base/src/components/SubMenu/src/index.vue +24 -0
- package/templates/vue/base/src/directives/index.ts +36 -0
- package/templates/vue/base/src/layouts/AntDesign.vue +86 -0
- package/templates/vue/base/src/layouts/element.vue +81 -0
- package/templates/vue/base/src/layouts/index.ts +7 -0
- package/templates/vue/base/src/main.ts.ejs +100 -0
- package/templates/vue/base/src/pages/about/index.vue +31 -0
- package/templates/vue/base/src/pages/home/index.vue +31 -0
- package/templates/vue/base/src/router/index.ts.ejs +39 -0
- package/templates/vue/base/src/stores/index.ts +16 -0
- package/templates/vue/base/src/stores/modules/system.ts +52 -0
- package/templates/vue/base/src/stores/modules/user.ts +48 -0
- package/templates/vue/base/tsconfig.app.json +17 -0
- package/templates/vue/base/tsconfig.base.json +23 -0
- package/templates/vue/base/tsconfig.json +12 -0
- package/templates/vue/base/tsconfig.node.json +15 -0
- package/templates/vue/base/vite.config.ts +53 -0
- package/templates/vue/features/ant-design-vue/package.json +7 -0
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/package.json +7 -0
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +5 -0
- package/templates/vue/features/element-plus/vite.config.data.ts +15 -0
- package/templates/vue/features/eslint/eslint.config.ts +12 -0
- package/templates/vue/features/eslint/package.json +7 -0
- package/templates/vue/features/eslint/pnpm-workspace.yaml +6 -0
- package/templates/vue/features/i18n/package.json +5 -0
- package/templates/vue/features/i18n/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/i18n/src/locales/index.ts +16 -0
- package/templates/vue/features/manualRoutes/src/router/layout.vue +10 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +27 -0
- package/templates/vue/features/pageRoutes/package.json +5 -0
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pageRoutes/vite.config.data.ts +9 -0
- package/templates/vue/features/pinia/package.json +6 -0
- package/templates/vue/features/pinia/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/user.ts +36 -0
- package/templates/vue/features/qiankun/package.json +5 -0
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/qiankun/src/qiankun/index.ts +56 -0
- package/templates/vue/features/router/package.json +5 -0
- package/templates/vue/features/router/pnpm-workspace.yaml +3 -0
- package/templates/vue/features/sentry/package.json +6 -0
- package/templates/vue/features/sentry/pnpm-workspace.yaml +4 -0
- package/templates/vue/features/sentry/src/utils/sentry.ts +33 -0
- package/templates/vue/features/sentry/vite.config.data.ts +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ejs.d.ts","sourceRoot":"","sources":["../../src/utils/ejs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAO3C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAK7E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,WAAW,GAChB,IAAI,CAIN"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EJS 模板渲染工具
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import ejs from 'ejs';
|
|
7
|
+
/**
|
|
8
|
+
* 渲染 EJS 模板文件
|
|
9
|
+
* @param templatePath 模板文件路径
|
|
10
|
+
* @param data 模板数据
|
|
11
|
+
* @returns 渲染后的字符串内容
|
|
12
|
+
*/
|
|
13
|
+
export function renderEjsFile(templatePath, data) {
|
|
14
|
+
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
15
|
+
return ejs.render(template, data, {
|
|
16
|
+
filename: templatePath,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 渲染 EJS 模板并写入目标文件
|
|
21
|
+
* @param templatePath 模板文件路径
|
|
22
|
+
* @param targetPath 目标文件路径
|
|
23
|
+
* @param data 模板数据
|
|
24
|
+
*/
|
|
25
|
+
export function renderEjsToFile(templatePath, targetPath, data) {
|
|
26
|
+
const content = renderEjsFile(templatePath, data);
|
|
27
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
28
|
+
fs.writeFileSync(targetPath, content);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ejs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ejs.js","sourceRoot":"","sources":["../../src/utils/ejs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,YAAoB,EAAE,IAAiB;IACnE,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACvD,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE;QAChC,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAoB,EACpB,UAAkB,EAClB,IAAiB;IAEjB,MAAM,OAAO,GAAG,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACjD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件操作工具
|
|
3
|
+
* 文件和目录操作相关函数
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 创建目录
|
|
7
|
+
* @param dirPath 目录路径
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDir(dirPath: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* 清空并重新创建目录
|
|
12
|
+
* @param dirPath 目录路径
|
|
13
|
+
*/
|
|
14
|
+
export declare function emptyDir(dirPath: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* 检查路径是否存在
|
|
17
|
+
* @param filePath 文件路径
|
|
18
|
+
*/
|
|
19
|
+
export declare function pathExists(filePath: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 复制文件
|
|
22
|
+
* @param src 源文件路径
|
|
23
|
+
* @param dest 目标文件路径
|
|
24
|
+
*/
|
|
25
|
+
export declare function copyFile(src: string, dest: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* 复制目录
|
|
28
|
+
* @param src 源目录路径
|
|
29
|
+
* @param dest 目标目录路径
|
|
30
|
+
*/
|
|
31
|
+
export declare function copyDir(src: string, dest: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* 写入文件
|
|
34
|
+
* @param filePath 文件路径
|
|
35
|
+
* @param content 文件内容
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeFile(filePath: string, content: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* 读取文件
|
|
40
|
+
* @param filePath 文件路径
|
|
41
|
+
*/
|
|
42
|
+
export declare function readFile(filePath: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 读取 JSON 文件
|
|
45
|
+
* @param filePath 文件路径
|
|
46
|
+
*/
|
|
47
|
+
export declare function readJsonFile<T = Record<string, unknown>>(filePath: string): T;
|
|
48
|
+
/**
|
|
49
|
+
* 写入 JSON 文件
|
|
50
|
+
* @param filePath 文件路径
|
|
51
|
+
* @param data 数据
|
|
52
|
+
*/
|
|
53
|
+
export declare function writeJsonFile(filePath: string, data: unknown): void;
|
|
54
|
+
/**
|
|
55
|
+
* 获取目录下所有文件
|
|
56
|
+
* @param dirPath 目录路径
|
|
57
|
+
* @param recursive 是否递归
|
|
58
|
+
*/
|
|
59
|
+
export declare function getFiles(dirPath: string, recursive?: boolean): string[];
|
|
60
|
+
/**
|
|
61
|
+
* 获取模板目录路径
|
|
62
|
+
*/
|
|
63
|
+
export declare function getTemplatesDir(): string;
|
|
64
|
+
/**
|
|
65
|
+
* 获取相对路径
|
|
66
|
+
* @param from 起始路径
|
|
67
|
+
* @param to 目标路径
|
|
68
|
+
*/
|
|
69
|
+
export declare function getRelativePath(from: string, to: string): string;
|
|
70
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGxD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAGjE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM,EAAE,CAwBpE;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件操作工具
|
|
3
|
+
* 文件和目录操作相关函数
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
/**
|
|
11
|
+
* 创建目录
|
|
12
|
+
* @param dirPath 目录路径
|
|
13
|
+
*/
|
|
14
|
+
export function createDir(dirPath) {
|
|
15
|
+
fs.ensureDirSync(dirPath);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 清空并重新创建目录
|
|
19
|
+
* @param dirPath 目录路径
|
|
20
|
+
*/
|
|
21
|
+
export function emptyDir(dirPath) {
|
|
22
|
+
fs.emptyDirSync(dirPath);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 检查路径是否存在
|
|
26
|
+
* @param filePath 文件路径
|
|
27
|
+
*/
|
|
28
|
+
export function pathExists(filePath) {
|
|
29
|
+
return fs.existsSync(filePath);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 复制文件
|
|
33
|
+
* @param src 源文件路径
|
|
34
|
+
* @param dest 目标文件路径
|
|
35
|
+
*/
|
|
36
|
+
export function copyFile(src, dest) {
|
|
37
|
+
fs.ensureDirSync(path.dirname(dest));
|
|
38
|
+
fs.copyFileSync(src, dest);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 复制目录
|
|
42
|
+
* @param src 源目录路径
|
|
43
|
+
* @param dest 目标目录路径
|
|
44
|
+
*/
|
|
45
|
+
export function copyDir(src, dest) {
|
|
46
|
+
fs.copySync(src, dest);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 写入文件
|
|
50
|
+
* @param filePath 文件路径
|
|
51
|
+
* @param content 文件内容
|
|
52
|
+
*/
|
|
53
|
+
export function writeFile(filePath, content) {
|
|
54
|
+
fs.ensureDirSync(path.dirname(filePath));
|
|
55
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 读取文件
|
|
59
|
+
* @param filePath 文件路径
|
|
60
|
+
*/
|
|
61
|
+
export function readFile(filePath) {
|
|
62
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 读取 JSON 文件
|
|
66
|
+
* @param filePath 文件路径
|
|
67
|
+
*/
|
|
68
|
+
export function readJsonFile(filePath) {
|
|
69
|
+
return fs.readJsonSync(filePath);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 写入 JSON 文件
|
|
73
|
+
* @param filePath 文件路径
|
|
74
|
+
* @param data 数据
|
|
75
|
+
*/
|
|
76
|
+
export function writeJsonFile(filePath, data) {
|
|
77
|
+
fs.ensureDirSync(path.dirname(filePath));
|
|
78
|
+
fs.writeJsonSync(filePath, data, { spaces: 2 });
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 获取目录下所有文件
|
|
82
|
+
* @param dirPath 目录路径
|
|
83
|
+
* @param recursive 是否递归
|
|
84
|
+
*/
|
|
85
|
+
export function getFiles(dirPath, recursive = true) {
|
|
86
|
+
const files = [];
|
|
87
|
+
if (!fs.existsSync(dirPath)) {
|
|
88
|
+
return files;
|
|
89
|
+
}
|
|
90
|
+
const items = fs.readdirSync(dirPath);
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
const itemPath = path.join(dirPath, item);
|
|
93
|
+
const stat = fs.statSync(itemPath);
|
|
94
|
+
if (stat.isDirectory()) {
|
|
95
|
+
if (recursive) {
|
|
96
|
+
files.push(...getFiles(itemPath, recursive));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
files.push(itemPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return files;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 获取模板目录路径
|
|
107
|
+
*/
|
|
108
|
+
export function getTemplatesDir() {
|
|
109
|
+
return path.resolve(__dirname, '../../templates');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 获取相对路径
|
|
113
|
+
* @param from 起始路径
|
|
114
|
+
* @param to 目标路径
|
|
115
|
+
*/
|
|
116
|
+
export function getRelativePath(from, to) {
|
|
117
|
+
return path.relative(from, to);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C;;;GAGG;AACH,MAAM,UAAU,S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
/**
|
|
2
|
+
* 工具函数导出
|
|
3
|
+
*/
|
|
4
|
+
export * from './deepMerge';
|
|
5
|
+
export * from './ejs';
|
|
6
|
+
export * from './file';
|
|
7
|
+
export * from './install';
|
|
8
|
+
export * from './prompts';
|
|
9
|
+
export * from './renderTemplate';
|
|
10
|
+
export * from './sortDependencies';
|
|
11
|
+
export * from './viteConfigRender';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具函数导出
|
|
3
|
+
*/
|
|
4
|
+
export * from './deepMerge';
|
|
5
|
+
export * from './ejs';
|
|
6
|
+
export * from './file';
|
|
7
|
+
export * from './install';
|
|
8
|
+
export * from './prompts';
|
|
9
|
+
export * from './renderTemplate';
|
|
10
|
+
export * from './sortDependencies';
|
|
11
|
+
export * from './viteConfigRender';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 依赖安装工具
|
|
3
|
+
* 执行包管理器安装依赖
|
|
4
|
+
*/
|
|
5
|
+
import type { PackageManagerType } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 安装依赖
|
|
8
|
+
* @param packageManager 包管理器
|
|
9
|
+
* @param cwd 工作目录
|
|
10
|
+
*/
|
|
11
|
+
export declare function installDependencies(packageManager: PackageManagerType, cwd: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* 初始化 Git 仓库
|
|
14
|
+
* @param cwd 工作目录
|
|
15
|
+
*/
|
|
16
|
+
export declare function initGit(cwd: string): void;
|
|
17
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/utils/install.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAIlD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,kBAAkB,EAClC,GAAG,EAAE,MAAM,GACV,IAAI,CAaN;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CASzC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 依赖安装工具
|
|
3
|
+
* 执行包管理器安装依赖
|
|
4
|
+
*/
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
/**
|
|
7
|
+
* 安装依赖
|
|
8
|
+
* @param packageManager 包管理器
|
|
9
|
+
* @param cwd 工作目录
|
|
10
|
+
*/
|
|
11
|
+
export function installDependencies(packageManager, cwd) {
|
|
12
|
+
const commands = {
|
|
13
|
+
pnpm: 'pnpm install',
|
|
14
|
+
npm: 'npm install',
|
|
15
|
+
yarn: 'yarn install',
|
|
16
|
+
};
|
|
17
|
+
const command = commands[packageManager];
|
|
18
|
+
execSync(command, {
|
|
19
|
+
cwd,
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 初始化 Git 仓库
|
|
25
|
+
* @param cwd 工作目录
|
|
26
|
+
*/
|
|
27
|
+
export function initGit(cwd) {
|
|
28
|
+
try {
|
|
29
|
+
execSync('git init', { cwd, stdio: 'ignore' });
|
|
30
|
+
execSync('git add .', { cwd, stdio: 'ignore' });
|
|
31
|
+
execSync('git commit -m "chore: initial commit"', { cwd, stdio: 'ignore' });
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Git 初始化失败不影响项目创建
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/utils/install.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,cAAkC,EAClC,GAAW;IAEX,MAAM,QAAQ,GAAuC;QACnD,IAAI,EAAE,cAAc;QACpB,GAAG,EAAE,aAAa;QAClB,IAAI,EAAE,cAAc;KACrB,CAAA;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;IAExC,QAAQ,CAAC,OAAO,EAAE;QAChB,GAAG;QACH,KAAK,EAAE,SAAS;KACjB,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,CAAC;QACH,QAAQ,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC9C,QAAQ,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC/C,QAAQ,CAAC,uCAAuC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC7E,CAAC;IACD,MAAM,CAAC;QACL,mBAAmB;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互式问答工具
|
|
3
|
+
* 收集用户的项目配置信息(对标 create-vue)
|
|
4
|
+
*/
|
|
5
|
+
import type { ProjectConfigType } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 收集项目配置信息
|
|
8
|
+
* @param projectName 项目名称(可选)
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectProjectConfig(projectName?: string): Promise<ProjectConfigType>;
|
|
11
|
+
/**
|
|
12
|
+
* 确认覆盖目录
|
|
13
|
+
* @param dirPath 目录路径
|
|
14
|
+
*/
|
|
15
|
+
export declare function confirmOverwrite(dirPath: string): Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/utils/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAGV,iBAAiB,EAGlB,MAAM,UAAU,CAAA;AAMjB;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,iBAAiB,CAAC,CA2J5B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWxE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 交互式问答工具
|
|
3
|
+
* 收集用户的项目配置信息(对标 create-vue)
|
|
4
|
+
*/
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
/**
|
|
8
|
+
* 收集项目配置信息
|
|
9
|
+
* @param projectName 项目名称(可选)
|
|
10
|
+
*/
|
|
11
|
+
export async function collectProjectConfig(projectName) {
|
|
12
|
+
const answers = await inquirer.prompt([
|
|
13
|
+
// 项目名称
|
|
14
|
+
{
|
|
15
|
+
type: 'input',
|
|
16
|
+
name: 'projectName',
|
|
17
|
+
message: '项目名称:',
|
|
18
|
+
default: projectName || 'my-project',
|
|
19
|
+
validate: (input) => {
|
|
20
|
+
if (!input.trim()) {
|
|
21
|
+
return '项目名称不能为空';
|
|
22
|
+
}
|
|
23
|
+
if (!/^[\w-]+$/.test(input)) {
|
|
24
|
+
return '项目名称只能包含字母、数字、连字符和下划线';
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
// 项目描述
|
|
30
|
+
{
|
|
31
|
+
type: 'input',
|
|
32
|
+
name: 'description',
|
|
33
|
+
message: '项目描述:',
|
|
34
|
+
default: 'A Vite project',
|
|
35
|
+
},
|
|
36
|
+
// 作者
|
|
37
|
+
{
|
|
38
|
+
type: 'input',
|
|
39
|
+
name: 'author',
|
|
40
|
+
message: '作者:',
|
|
41
|
+
default: '',
|
|
42
|
+
},
|
|
43
|
+
// 框架选择
|
|
44
|
+
{
|
|
45
|
+
type: 'list',
|
|
46
|
+
name: 'framework',
|
|
47
|
+
message: '选择框架:',
|
|
48
|
+
choices: [
|
|
49
|
+
{ name: 'Vue 3', value: 'vue' },
|
|
50
|
+
{ name: 'React', value: 'react' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
// UI 库选择
|
|
54
|
+
{
|
|
55
|
+
type: 'list',
|
|
56
|
+
name: 'uiLibrary',
|
|
57
|
+
message: '选择 UI 组件库:',
|
|
58
|
+
choices: (answers) => {
|
|
59
|
+
if (answers.framework === 'vue') {
|
|
60
|
+
return [
|
|
61
|
+
{ name: 'Element Plus', value: 'element-plus' },
|
|
62
|
+
{ name: 'Ant Design Vue', value: 'ant-design-vue' },
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return [{ name: 'Ant Design', value: 'ant-design' }];
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
// 路由模式
|
|
71
|
+
{
|
|
72
|
+
type: 'list',
|
|
73
|
+
name: 'routeMode',
|
|
74
|
+
message: '选择路由模式:',
|
|
75
|
+
choices: [
|
|
76
|
+
{ name: '文件系统路由 (vite-plugin-pages)', value: 'file-system' },
|
|
77
|
+
{ name: '手动配置路由', value: 'manual' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
// 是否启用路由
|
|
81
|
+
{
|
|
82
|
+
type: 'confirm',
|
|
83
|
+
name: 'router',
|
|
84
|
+
message: '是否启用路由 (vue-router/react-router-dom)?',
|
|
85
|
+
default: true,
|
|
86
|
+
},
|
|
87
|
+
// 是否启用状态管理
|
|
88
|
+
{
|
|
89
|
+
type: 'confirm',
|
|
90
|
+
name: 'stateManagement',
|
|
91
|
+
message: (answers) => {
|
|
92
|
+
return answers.framework === 'vue'
|
|
93
|
+
? '是否启用状态管理 (Pinia)?'
|
|
94
|
+
: '是否启用状态管理 (Zustand)?';
|
|
95
|
+
},
|
|
96
|
+
default: true,
|
|
97
|
+
},
|
|
98
|
+
// 是否启用国际化
|
|
99
|
+
{
|
|
100
|
+
type: 'confirm',
|
|
101
|
+
name: 'i18n',
|
|
102
|
+
message: '是否启用国际化 (i18n)?',
|
|
103
|
+
default: true,
|
|
104
|
+
},
|
|
105
|
+
// 是否启用微前端
|
|
106
|
+
{
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
name: 'qiankun',
|
|
109
|
+
message: '是否启用微前端 (qiankun)?',
|
|
110
|
+
default: false,
|
|
111
|
+
},
|
|
112
|
+
// 是否启用错误监控
|
|
113
|
+
{
|
|
114
|
+
type: 'confirm',
|
|
115
|
+
name: 'sentry',
|
|
116
|
+
message: '是否启用错误监控 (Sentry)?',
|
|
117
|
+
default: false,
|
|
118
|
+
},
|
|
119
|
+
// 是否启用 ESLint
|
|
120
|
+
{
|
|
121
|
+
type: 'confirm',
|
|
122
|
+
name: 'eslint',
|
|
123
|
+
message: '是否启用 ESLint 代码规范检查?',
|
|
124
|
+
default: true,
|
|
125
|
+
},
|
|
126
|
+
// 是否启用 Git Hooks
|
|
127
|
+
{
|
|
128
|
+
type: 'confirm',
|
|
129
|
+
name: 'gitHooks',
|
|
130
|
+
message: '是否启用 Git Hooks (husky + commitlint)?',
|
|
131
|
+
default: true,
|
|
132
|
+
},
|
|
133
|
+
// 包管理器
|
|
134
|
+
{
|
|
135
|
+
type: 'list',
|
|
136
|
+
name: 'packageManager',
|
|
137
|
+
message: '选择包管理器:',
|
|
138
|
+
choices: [
|
|
139
|
+
{ name: 'pnpm (推荐)', value: 'pnpm' },
|
|
140
|
+
{ name: 'npm', value: 'npm' },
|
|
141
|
+
{ name: 'yarn', value: 'yarn' },
|
|
142
|
+
],
|
|
143
|
+
default: 'pnpm',
|
|
144
|
+
},
|
|
145
|
+
]);
|
|
146
|
+
const targetDir = `${process.cwd()}/${answers.projectName}`;
|
|
147
|
+
return {
|
|
148
|
+
projectName: answers.projectName,
|
|
149
|
+
description: answers.description,
|
|
150
|
+
author: answers.author,
|
|
151
|
+
framework: answers.framework,
|
|
152
|
+
uiLibrary: answers.uiLibrary,
|
|
153
|
+
routeMode: answers.routeMode,
|
|
154
|
+
router: answers.router,
|
|
155
|
+
stateManagement: answers.stateManagement,
|
|
156
|
+
i18n: answers.i18n,
|
|
157
|
+
qiankun: answers.qiankun,
|
|
158
|
+
sentry: answers.sentry,
|
|
159
|
+
eslint: answers.eslint,
|
|
160
|
+
gitHooks: answers.gitHooks,
|
|
161
|
+
packageManager: answers.packageManager,
|
|
162
|
+
targetDir,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 确认覆盖目录
|
|
167
|
+
* @param dirPath 目录路径
|
|
168
|
+
*/
|
|
169
|
+
export async function confirmOverwrite(dirPath) {
|
|
170
|
+
const { confirm } = await inquirer.prompt([
|
|
171
|
+
{
|
|
172
|
+
type: 'confirm',
|
|
173
|
+
name: 'confirm',
|
|
174
|
+
message: `目录 ${dirPath} 已存在,是否覆盖?`,
|
|
175
|
+
default: false,
|
|
176
|
+
},
|
|
177
|
+
]);
|
|
178
|
+
return confirm;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/utils/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,WAAoB;IAEpB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACpC,OAAO;QACP;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,WAAW,IAAI,YAAY;YACpC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE;gBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;oBAClB,OAAO,UAAU,CAAA;gBACnB,CAAC;gBACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC5B,OAAO,uBAAuB,CAAA;gBAChC,CAAC;gBACD,OAAO,IAAI,CAAA;YACb,CAAC;SACF;QACD,OAAO;QACP;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,gBAAgB;SAC1B;QACD,KAAK;QACL;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,EAAE;SACZ;QACD,OAAO;QACP;YACE,IAAI,EAAE,MAAM;YACZ,IAA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;QAC7C,SAAS,EAAE,OAAO,CAAC,SAA0B;QAC7C,SAAS,EAAE,OAAO,CAAC,SAA0B;QAC7C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,cAAc,EAAE,OAAO,CAAC,cAAoC;QAC5D,SAAS;KACV,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAe;IACpD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACxC;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,MAAM,OAAO,YAAY;YAClC,OAAO,EAAE,KAAK;SACf;KACF,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features 渲染工具
|
|
3
|
+
* 统一处理 features 的渲染逻辑
|
|
4
|
+
*/
|
|
5
|
+
import type { ProjectConfigType } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 渲染框架特定的 features
|
|
8
|
+
* @param config 项目配置
|
|
9
|
+
* @param targetDir 目标目录
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderFrameworkFeatures(config: ProjectConfigType, targetDir: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* 渲染公共 features
|
|
14
|
+
* @param config 项目配置
|
|
15
|
+
* @param targetDir 目标目录
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderCommonFeatures(config: ProjectConfigType, targetDir: string): void;
|
|
18
|
+
//# sourceMappingURL=renderFeatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFeatures.d.ts","sourceRoot":"","sources":["../../src/utils/renderFeatures.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAOjD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA4C1F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAcvF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features 渲染工具
|
|
3
|
+
* 统一处理 features 的渲染逻辑
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { getTemplatesDir } from './file';
|
|
7
|
+
import { renderTemplate } from './renderTemplate';
|
|
8
|
+
/**
|
|
9
|
+
* 渲染框架特定的 features
|
|
10
|
+
* @param config 项目配置
|
|
11
|
+
* @param targetDir 目标目录
|
|
12
|
+
*/
|
|
13
|
+
export function renderFrameworkFeatures(config, targetDir) {
|
|
14
|
+
const templatesDir = getTemplatesDir();
|
|
15
|
+
const framework = config.framework;
|
|
16
|
+
// 定义 features 映射:配置项名称 -> feature 目录名称
|
|
17
|
+
const featureMap = {
|
|
18
|
+
router: 'router',
|
|
19
|
+
stateManagement: framework === 'vue' ? 'pinia' : 'zustand',
|
|
20
|
+
eslint: 'eslint',
|
|
21
|
+
i18n: 'i18n',
|
|
22
|
+
sentry: 'sentry',
|
|
23
|
+
qiankun: 'qiankun',
|
|
24
|
+
};
|
|
25
|
+
// 统一处理布尔类型的 features
|
|
26
|
+
for (const [configKey, featureName] of Object.entries(featureMap)) {
|
|
27
|
+
if (config[configKey] === true) {
|
|
28
|
+
const featurePath = path.join(templatesDir, framework, 'features', featureName);
|
|
29
|
+
renderTemplate(featurePath, targetDir);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// 特殊处理:路由模式相关的 features
|
|
33
|
+
if (config.routeMode === 'manual') {
|
|
34
|
+
renderTemplate(path.join(templatesDir, framework, 'features', 'manualRoutes'), targetDir);
|
|
35
|
+
}
|
|
36
|
+
else if (config.routeMode === 'file-system') {
|
|
37
|
+
renderTemplate(path.join(templatesDir, framework, 'features', 'pageRoutes'), targetDir);
|
|
38
|
+
}
|
|
39
|
+
// 特殊处理:UI 库相关的 features
|
|
40
|
+
if (framework === 'vue') {
|
|
41
|
+
if (config.uiLibrary === 'element-plus') {
|
|
42
|
+
renderTemplate(path.join(templatesDir, framework, 'features', 'element-plus'), targetDir);
|
|
43
|
+
}
|
|
44
|
+
else if (config.uiLibrary === 'ant-design-vue') {
|
|
45
|
+
renderTemplate(path.join(templatesDir, framework, 'features', 'ant-design-vue'), targetDir);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (framework === 'react') {
|
|
49
|
+
if (config.uiLibrary === 'ant-design') {
|
|
50
|
+
renderTemplate(path.join(templatesDir, framework, 'features', 'ant-design'), targetDir);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 渲染公共 features
|
|
56
|
+
* @param config 项目配置
|
|
57
|
+
* @param targetDir 目标目录
|
|
58
|
+
*/
|
|
59
|
+
export function renderCommonFeatures(config, targetDir) {
|
|
60
|
+
const templatesDir = getTemplatesDir();
|
|
61
|
+
// 公共 features 映射
|
|
62
|
+
const commonFeatureMap = {
|
|
63
|
+
gitHooks: 'husky',
|
|
64
|
+
};
|
|
65
|
+
for (const [configKey, featureName] of Object.entries(commonFeatureMap)) {
|
|
66
|
+
if (config[configKey] === true) {
|
|
67
|
+
const featurePath = path.join(templatesDir, 'common', 'features', featureName);
|
|
68
|
+
renderTemplate(featurePath, targetDir);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+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