@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.
- package/LICENSE.txt +21 -21
- package/README.md +129 -129
- package/dist/commands/create.d.ts +2 -1
- package/dist/commands/create.js +12 -8
- package/dist/commands/index.d.ts +1 -2
- package/dist/commands/index.js +1 -2
- package/dist/constants/index.d.ts +17 -0
- package/dist/constants/index.js +17 -0
- package/dist/generators/index.d.ts +3 -4
- package/dist/generators/index.js +3 -4
- package/dist/generators/project.d.ts +3 -2
- package/dist/generators/project.js +5 -4
- package/dist/generators/react.d.ts +4 -2
- package/dist/generators/react.js +10 -30
- package/dist/generators/vue.d.ts +4 -2
- package/dist/generators/vue.js +10 -31
- package/dist/index.d.ts +0 -1
- package/dist/index.js +21 -3
- package/dist/test.d.ts +5 -2
- package/dist/test.js +252 -206
- package/dist/types/ejs.d.ts +0 -1
- package/dist/types/ejs.js +0 -1
- package/dist/types/features.d.ts +1 -2
- package/dist/types/features.js +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +2 -4
- package/dist/types/packageJson.d.ts +24 -0
- package/dist/types/packageJson.js +4 -0
- package/dist/types/viteConfig.d.ts +11 -9
- package/dist/types/viteConfig.js +0 -1
- package/dist/utils/deepMerge.d.ts +3 -1
- package/dist/utils/deepMerge.js +8 -1
- package/dist/utils/ejs.d.ts +3 -2
- package/dist/utils/ejs.js +2 -1
- package/dist/utils/featureMapping.d.ts +44 -0
- package/dist/utils/featureMapping.js +119 -0
- package/dist/utils/file.d.ts +22 -2
- package/dist/utils/file.js +35 -2
- package/dist/utils/generateFrameworkProject.d.ts +27 -0
- package/dist/utils/generateFrameworkProject.js +47 -0
- package/dist/utils/index.d.ts +11 -9
- package/dist/utils/index.js +11 -9
- package/dist/utils/install.d.ts +7 -4
- package/dist/utils/install.js +55 -12
- package/dist/utils/npmConfig.d.ts +15 -0
- package/dist/utils/npmConfig.js +79 -0
- package/dist/utils/prompts.d.ts +3 -2
- package/dist/utils/prompts.js +51 -5
- package/dist/utils/renderFeatures.d.ts +3 -2
- package/dist/utils/renderFeatures.js +41 -37
- package/dist/utils/renderTemplate.d.ts +13 -1
- package/dist/utils/renderTemplate.js +128 -61
- package/dist/utils/sortDependencies.d.ts +3 -2
- package/dist/utils/sortDependencies.js +3 -2
- package/dist/utils/viteConfigRender.d.ts +11 -14
- package/dist/utils/viteConfigRender.js +10 -173
- package/package.json +4 -2
- package/templates/common/base/.env +7 -7
- package/templates/common/base/.env.development +5 -5
- package/templates/common/base/.env.production +5 -5
- package/templates/common/base/package.json +23 -27
- package/templates/common/base/scripts/build.mts +37 -31
- package/templates/common/base/src/apis/index.ts +8 -8
- package/templates/common/base/src/apis/request.ts +43 -43
- package/templates/common/base/src/apis/services/example.ts +61 -40
- package/templates/common/base/src/apis/services/user.ts +33 -23
- package/templates/common/base/src/apis/types/common.ts +43 -28
- package/templates/common/base/src/apis/types/example.ts +15 -3
- package/templates/common/base/src/apis/types/index.ts +7 -7
- package/templates/common/base/src/apis/types/user.ts +39 -24
- package/templates/common/base/src/assets/fonts/index.css +7 -7
- package/templates/common/base/src/assets/styles/base.scss +72 -72
- package/templates/common/base/src/assets/styles/custom.scss +7 -7
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -6
- package/templates/common/base/src/constants/index.ts +29 -29
- package/templates/common/base/src/utils/index.ts +88 -83
- package/templates/{vue/base/vite.config.ts → common/base/vite.config.ts.ejs} +28 -11
- package/templates/common/features/husky/.cz-config.cjs +35 -35
- package/templates/common/features/husky/commitlint.config.ts +32 -32
- package/templates/common/features/husky/node_modules/.bin/commitizen +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/husky +17 -0
- package/templates/common/features/husky/node_modules/.bin/husky.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/husky.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged +17 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.ps1 +41 -0
- package/templates/common/features/husky/package.json +6 -6
- package/templates/react/base/env.d.ts +19 -19
- package/templates/react/base/index.html +14 -14
- package/templates/react/base/node_modules/.bin/vite +17 -0
- package/templates/react/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/react/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/react/base/package.json +18 -15
- package/templates/react/base/src/App.tsx +18 -18
- package/templates/react/base/src/assets/styles/main.scss +8 -8
- package/templates/react/base/src/main.tsx.ejs +51 -6
- package/templates/react/base/src/pages/about/index.tsx +14 -14
- package/templates/react/base/src/pages/home/index.tsx +14 -14
- package/templates/react/base/tsconfig.app.json +17 -17
- package/templates/react/base/tsconfig.base.json +23 -23
- package/templates/react/base/tsconfig.json +12 -12
- package/templates/react/base/tsconfig.node.json +15 -15
- package/templates/react/features/ant-design/package.json +6 -7
- package/templates/react/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/react/features/eslint/package.json +3 -3
- package/templates/react/features/i18n/package.json +6 -7
- package/templates/react/features/i18n/src/locales/index.ts +7 -0
- package/templates/{common/base → react/features/i18n}/src/locales/lang/en.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/es.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/zh.ts +30 -30
- package/templates/react/features/manualRoutes/src/router/routes.tsx +13 -0
- package/templates/react/features/pageRoutes/package.json +1 -2
- package/templates/react/features/qiankun/package.json +6 -0
- package/templates/react/features/qiankun/src/qiankun/index.ts +80 -0
- package/templates/react/features/router/package.json +1 -1
- package/templates/react/features/sentry/package.json +6 -7
- package/templates/react/features/sentry/src/utils/sentry.ts +10 -0
- package/templates/react/features/zustand/package.json +1 -1
- package/templates/react/features/zustand/src/stores/user.ts +42 -6
- package/templates/react/features/zustand/src/types/stores.ts +8 -1
- package/templates/vue/base/env.d.ts +27 -27
- package/templates/vue/base/index.html +14 -14
- package/templates/vue/base/node_modules/.bin/vite +17 -0
- package/templates/vue/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc +17 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.ps1 +41 -0
- package/templates/vue/base/package.json +16 -13
- package/templates/vue/base/src/App.vue +13 -13
- package/templates/vue/base/src/assets/styles/main.scss +9 -9
- package/templates/vue/base/src/directives/index.ts +36 -36
- package/templates/vue/base/src/layouts/index.ts +5 -7
- package/templates/vue/base/src/main.ts.ejs +9 -25
- package/templates/vue/base/src/pages/about/index.vue +31 -31
- package/templates/vue/base/src/pages/home/index.vue +31 -31
- package/templates/vue/base/src/router/index.ts.ejs +10 -13
- package/templates/vue/base/tsconfig.app.json +17 -17
- package/templates/vue/base/tsconfig.base.json +23 -23
- package/templates/vue/base/tsconfig.json +12 -12
- package/templates/vue/base/tsconfig.node.json +15 -15
- package/templates/vue/features/ant-design-vue/package.json +6 -7
- package/templates/vue/{base → features/ant-design-vue}/src/layouts/AntDesign.vue +86 -86
- package/templates/vue/features/element-plus/package.json +6 -7
- package/templates/vue/{base → features/element-plus}/src/assets/styles/element/index.scss +27 -27
- package/templates/vue/features/element-plus/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/index.ts +6 -6
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/props.ts +11 -11
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/index.vue +24 -24
- package/templates/vue/{base → features/element-plus}/src/layouts/element.vue +81 -81
- package/templates/vue/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/vue/features/eslint/package.json +3 -3
- package/templates/vue/features/i18n/package.json +5 -5
- package/templates/vue/features/i18n/src/locales/index.ts +23 -16
- package/templates/vue/features/i18n/src/locales/lang/en.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/es.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/zh.ts +30 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +35 -27
- package/templates/vue/features/pageRoutes/package.json +5 -5
- package/templates/vue/features/pinia/package.json +3 -2
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/system.ts +60 -0
- package/templates/vue/features/pinia/src/stores/user.ts +33 -13
- package/templates/vue/features/qiankun/package.json +5 -5
- package/templates/vue/features/qiankun/src/qiankun/index.ts +19 -0
- package/templates/vue/features/router/package.json +1 -1
- package/templates/vue/features/sentry/package.json +6 -6
- package/templates/vue/features/sentry/src/utils/sentry.ts +12 -0
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/generators/index.d.ts.map +0 -1
- package/dist/generators/index.js.map +0 -1
- package/dist/generators/project.d.ts.map +0 -1
- package/dist/generators/project.js.map +0 -1
- package/dist/generators/react.d.ts.map +0 -1
- package/dist/generators/react.js.map +0 -1
- package/dist/generators/vue.d.ts.map +0 -1
- package/dist/generators/vue.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/types/ejs.d.ts.map +0 -1
- package/dist/types/ejs.js.map +0 -1
- package/dist/types/features.d.ts.map +0 -1
- package/dist/types/features.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/viteConfig.d.ts.map +0 -1
- package/dist/types/viteConfig.js.map +0 -1
- package/dist/utils/deepMerge.d.ts.map +0 -1
- package/dist/utils/deepMerge.js.map +0 -1
- package/dist/utils/ejs.d.ts.map +0 -1
- package/dist/utils/ejs.js.map +0 -1
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/install.d.ts.map +0 -1
- package/dist/utils/install.js.map +0 -1
- package/dist/utils/prompts.d.ts.map +0 -1
- package/dist/utils/prompts.js.map +0 -1
- package/dist/utils/renderFeatures.d.ts.map +0 -1
- package/dist/utils/renderFeatures.js.map +0 -1
- package/dist/utils/renderTemplate.d.ts.map +0 -1
- package/dist/utils/renderTemplate.js.map +0 -1
- package/dist/utils/sortDependencies.d.ts.map +0 -1
- package/dist/utils/sortDependencies.js.map +0 -1
- package/dist/utils/viteConfigRender.d.ts.map +0 -1
- package/dist/utils/viteConfigRender.js.map +0 -1
- package/templates/common/base/pnpm-workspace.yaml +0 -37
- package/templates/common/features/husky/pnpm-workspace.yaml +0 -9
- package/templates/react/base/pnpm-workspace.yaml +0 -9
- package/templates/react/base/src/stores/user.ts +0 -39
- package/templates/react/base/vite.config.ts +0 -52
- package/templates/react/features/ant-design/pnpm-workspace.yaml +0 -5
- package/templates/react/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/react/features/i18n/pnpm-workspace.yaml +0 -5
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/react/features/pageRoutes/vite.config.data.ts +0 -10
- package/templates/react/features/router/pnpm-workspace.yaml +0 -3
- package/templates/react/features/sentry/pnpm-workspace.yaml +0 -5
- package/templates/react/features/sentry/vite.config.data.ts +0 -23
- package/templates/react/features/zustand/pnpm-workspace.yaml +0 -3
- package/templates/vue/base/pnpm-workspace.yaml +0 -6
- package/templates/vue/base/src/components/SubMenu/index.ts +0 -9
- package/templates/vue/base/src/stores/index.ts +0 -16
- package/templates/vue/base/src/stores/modules/system.ts +0 -52
- package/templates/vue/base/src/stores/modules/user.ts +0 -48
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/vite.config.data.ts +0 -15
- package/templates/vue/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/vue/features/i18n/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/pageRoutes/vite.config.data.ts +0 -9
- package/templates/vue/features/pinia/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/router/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/sentry/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/sentry/vite.config.data.ts +0 -23
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
* Vite 配置数据类型定义
|
|
3
3
|
* 用于 features 中的 vite.config.data.ts
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Vite 配置数据接口
|
|
7
|
+
*/
|
|
5
8
|
export interface ViteConfigData {
|
|
6
|
-
/**
|
|
9
|
+
/** 导入语句字符串数组(完整的 import 语句) */
|
|
7
10
|
imports?: string[];
|
|
8
|
-
/**
|
|
9
|
-
options?: Record<string, unknown>;
|
|
10
|
-
/** 插件配置 */
|
|
11
|
+
/** 插件初始化字符串数组 */
|
|
11
12
|
plugins?: string[];
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/** 纯 JSON 数据配置(包含 server, build, resolve 等静态配置) */
|
|
14
|
+
config?: Record<string, unknown>;
|
|
15
|
+
/** ViteConfig 顶层选项(如 pageRoutes) */
|
|
16
|
+
options?: Record<string, unknown>;
|
|
17
|
+
/** 函数逻辑分片映射,Key 为配置项的深度访问路径(如 'css.preprocessorOptions.scss.additionalData') */
|
|
18
|
+
hooks?: Record<string, string>;
|
|
16
19
|
}
|
|
17
|
-
//# sourceMappingURL=viteConfig.d.ts.map
|
package/dist/types/viteConfig.js
CHANGED
package/dist/utils/deepMerge.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* - 对象会递归合并
|
|
4
4
|
* - 数组会合并并去重
|
|
5
5
|
* - 基本类型后者覆盖前者
|
|
6
|
+
* @param target 目标对象
|
|
7
|
+
* @param source 源对象
|
|
8
|
+
* @returns 合并后的对象
|
|
6
9
|
*/
|
|
7
10
|
export function deepMerge(target, source) {
|
|
8
11
|
const result = { ...target };
|
|
@@ -27,7 +30,11 @@ export function deepMerge(target, source) {
|
|
|
27
30
|
}
|
|
28
31
|
return result;
|
|
29
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* 判断值是否为对象(非数组、非 null)
|
|
35
|
+
* @param val 待判断的值
|
|
36
|
+
* @returns 是否为对象
|
|
37
|
+
*/
|
|
30
38
|
function isObject(val) {
|
|
31
39
|
return val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
32
40
|
}
|
|
33
|
-
//# sourceMappingURL=deepMerge.js.map
|
package/dist/utils/ejs.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EJS 模板渲染工具
|
|
3
3
|
*/
|
|
4
|
-
import type { EjsDataType } from '../types';
|
|
4
|
+
import type { EjsDataType } from '../types/index.ts';
|
|
5
5
|
/**
|
|
6
6
|
* 渲染 EJS 模板文件
|
|
7
7
|
* @param templatePath 模板文件路径
|
|
8
8
|
* @param data 模板数据
|
|
9
9
|
* @returns 渲染后的字符串内容
|
|
10
|
+
* @throws {Error} 如果模板文件不存在或渲染失败
|
|
10
11
|
*/
|
|
11
12
|
export declare function renderEjsFile(templatePath: string, data: EjsDataType): string;
|
|
12
13
|
/**
|
|
@@ -14,6 +15,6 @@ export declare function renderEjsFile(templatePath: string, data: EjsDataType):
|
|
|
14
15
|
* @param templatePath 模板文件路径
|
|
15
16
|
* @param targetPath 目标文件路径
|
|
16
17
|
* @param data 模板数据
|
|
18
|
+
* @throws {Error} 如果模板文件不存在、渲染失败或写入失败
|
|
17
19
|
*/
|
|
18
20
|
export declare function renderEjsToFile(templatePath: string, targetPath: string, data: EjsDataType): void;
|
|
19
|
-
//# sourceMappingURL=ejs.d.ts.map
|
package/dist/utils/ejs.js
CHANGED
|
@@ -9,6 +9,7 @@ import ejs from 'ejs';
|
|
|
9
9
|
* @param templatePath 模板文件路径
|
|
10
10
|
* @param data 模板数据
|
|
11
11
|
* @returns 渲染后的字符串内容
|
|
12
|
+
* @throws {Error} 如果模板文件不存在或渲染失败
|
|
12
13
|
*/
|
|
13
14
|
export function renderEjsFile(templatePath, data) {
|
|
14
15
|
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
@@ -21,10 +22,10 @@ export function renderEjsFile(templatePath, data) {
|
|
|
21
22
|
* @param templatePath 模板文件路径
|
|
22
23
|
* @param targetPath 目标文件路径
|
|
23
24
|
* @param data 模板数据
|
|
25
|
+
* @throws {Error} 如果模板文件不存在、渲染失败或写入失败
|
|
24
26
|
*/
|
|
25
27
|
export function renderEjsToFile(templatePath, targetPath, data) {
|
|
26
28
|
const content = renderEjsFile(templatePath, data);
|
|
27
29
|
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
28
30
|
fs.writeFileSync(targetPath, content);
|
|
29
31
|
}
|
|
30
|
-
//# sourceMappingURL=ejs.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features 映射工具
|
|
3
|
+
* 统一管理配置项到 feature 目录的映射关系
|
|
4
|
+
*/
|
|
5
|
+
import type { FrameworkType } from '../types/index.ts';
|
|
6
|
+
/**
|
|
7
|
+
* 扫描所有 features(框架的 + 公共的)
|
|
8
|
+
* @param framework 框架类型
|
|
9
|
+
* @returns 所有 feature 名称数组(UI 库按优先级排序)
|
|
10
|
+
*/
|
|
11
|
+
export declare function scanAllFeatures(framework: FrameworkType): string[];
|
|
12
|
+
/**
|
|
13
|
+
* 配置项到 feature 目录的映射(从 renderFeatures 提取)
|
|
14
|
+
* @param framework 框架类型
|
|
15
|
+
* @returns 配置键到 feature 名称的映射对象
|
|
16
|
+
*/
|
|
17
|
+
export declare function getConfigToFeatureMap(framework: FrameworkType): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* 公共 features 映射
|
|
20
|
+
* @returns 公共配置键到 feature 名称的映射对象
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCommonFeatureMap(): Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* 路由模式映射
|
|
25
|
+
* @param routeMode 路由模式('manual' 或 'file-system')
|
|
26
|
+
* @returns feature 名称
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRouteModeFeature(routeMode: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* UI 库映射
|
|
31
|
+
* @param uiLibrary UI 库名称
|
|
32
|
+
* @returns feature 名称(通常与 UI 库名称相同)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getUILibraryFeature(uiLibrary: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Feature 名称转换为配置键和值(用于测试用例生成)
|
|
37
|
+
* @param feature feature 名称
|
|
38
|
+
* @param framework 框架类型
|
|
39
|
+
* @returns 配置键值对,如果无法映射则返回 null
|
|
40
|
+
*/
|
|
41
|
+
export declare function featureToConfig(feature: string, framework: FrameworkType): {
|
|
42
|
+
key: string;
|
|
43
|
+
value: string | boolean;
|
|
44
|
+
} | null;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features 映射工具
|
|
3
|
+
* 统一管理配置项到 feature 目录的映射关系
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { getTemplatesDir } from "./file.js";
|
|
8
|
+
/**
|
|
9
|
+
* UI 库优先级顺序(用于排序,确保默认选择)
|
|
10
|
+
*/
|
|
11
|
+
const UI_LIBRARY_PRIORITY = {
|
|
12
|
+
'element-plus': 1,
|
|
13
|
+
'ant-design-vue': 2,
|
|
14
|
+
'ant-design': 1,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 扫描所有 features(框架的 + 公共的)
|
|
18
|
+
* @param framework 框架类型
|
|
19
|
+
* @returns 所有 feature 名称数组(UI 库按优先级排序)
|
|
20
|
+
*/
|
|
21
|
+
export function scanAllFeatures(framework) {
|
|
22
|
+
const frameworkDir = path.join(getTemplatesDir(), framework, 'features');
|
|
23
|
+
const commonDir = path.join(getTemplatesDir(), 'common', 'features');
|
|
24
|
+
const features = [];
|
|
25
|
+
if (fs.existsSync(frameworkDir)) {
|
|
26
|
+
features.push(...fs.readdirSync(frameworkDir).filter(f => fs.statSync(path.join(frameworkDir, f)).isDirectory()));
|
|
27
|
+
}
|
|
28
|
+
if (fs.existsSync(commonDir)) {
|
|
29
|
+
features.push(...fs.readdirSync(commonDir).filter(f => fs.statSync(path.join(commonDir, f)).isDirectory()));
|
|
30
|
+
}
|
|
31
|
+
// 对 UI 库进行排序,确保 element-plus 优先(优先级数字越小越靠前)
|
|
32
|
+
return features.sort((a, b) => {
|
|
33
|
+
const priorityA = UI_LIBRARY_PRIORITY[a] ?? 999;
|
|
34
|
+
const priorityB = UI_LIBRARY_PRIORITY[b] ?? 999;
|
|
35
|
+
if (priorityA !== priorityB) {
|
|
36
|
+
return priorityA - priorityB;
|
|
37
|
+
}
|
|
38
|
+
// 相同优先级时保持字母顺序
|
|
39
|
+
return a.localeCompare(b);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 配置项到 feature 目录的映射(从 renderFeatures 提取)
|
|
44
|
+
* @param framework 框架类型
|
|
45
|
+
* @returns 配置键到 feature 名称的映射对象
|
|
46
|
+
*/
|
|
47
|
+
export function getConfigToFeatureMap(framework) {
|
|
48
|
+
return {
|
|
49
|
+
router: 'router',
|
|
50
|
+
stateManagement: framework === 'vue' ? 'pinia' : 'zustand',
|
|
51
|
+
eslint: 'eslint',
|
|
52
|
+
i18n: 'i18n',
|
|
53
|
+
sentry: 'sentry',
|
|
54
|
+
qiankun: 'qiankun',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 公共 features 映射
|
|
59
|
+
* @returns 公共配置键到 feature 名称的映射对象
|
|
60
|
+
*/
|
|
61
|
+
export function getCommonFeatureMap() {
|
|
62
|
+
return {
|
|
63
|
+
gitHooks: 'husky',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 路由模式映射
|
|
68
|
+
* @param routeMode 路由模式('manual' 或 'file-system')
|
|
69
|
+
* @returns feature 名称
|
|
70
|
+
*/
|
|
71
|
+
export function getRouteModeFeature(routeMode) {
|
|
72
|
+
return routeMode === 'manual' ? 'manualRoutes' : 'pageRoutes';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* UI 库映射
|
|
76
|
+
* @param uiLibrary UI 库名称
|
|
77
|
+
* @returns feature 名称(通常与 UI 库名称相同)
|
|
78
|
+
*/
|
|
79
|
+
export function getUILibraryFeature(uiLibrary) {
|
|
80
|
+
return uiLibrary;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Feature 名称转换为配置键和值(用于测试用例生成)
|
|
84
|
+
* @param feature feature 名称
|
|
85
|
+
* @param framework 框架类型
|
|
86
|
+
* @returns 配置键值对,如果无法映射则返回 null
|
|
87
|
+
*/
|
|
88
|
+
export function featureToConfig(feature, framework) {
|
|
89
|
+
// 路由模式
|
|
90
|
+
if (feature === 'manualRoutes')
|
|
91
|
+
return { key: 'routeMode', value: 'manual' };
|
|
92
|
+
if (feature === 'pageRoutes')
|
|
93
|
+
return { key: 'routeMode', value: 'file-system' };
|
|
94
|
+
// UI 库
|
|
95
|
+
const uiLibraries = ['element-plus', 'ant-design-vue', 'ant-design'];
|
|
96
|
+
if (uiLibraries.includes(feature))
|
|
97
|
+
return { key: 'uiLibrary', value: feature };
|
|
98
|
+
// 状态管理(反向映射)
|
|
99
|
+
const stateManagementMap = {
|
|
100
|
+
pinia: 'stateManagement',
|
|
101
|
+
zustand: 'stateManagement',
|
|
102
|
+
};
|
|
103
|
+
if (stateManagementMap[feature])
|
|
104
|
+
return { key: stateManagementMap[feature], value: true };
|
|
105
|
+
// Git Hooks(公共 feature)
|
|
106
|
+
if (feature === 'husky')
|
|
107
|
+
return { key: 'gitHooks', value: true };
|
|
108
|
+
// 其他布尔 features(通过映射查找)
|
|
109
|
+
const configMap = getConfigToFeatureMap(framework);
|
|
110
|
+
const configKey = Object.keys(configMap).find(key => configMap[key] === feature);
|
|
111
|
+
if (configKey)
|
|
112
|
+
return { key: configKey, value: true };
|
|
113
|
+
// 公共 features
|
|
114
|
+
const commonMap = getCommonFeatureMap();
|
|
115
|
+
const commonKey = Object.keys(commonMap).find(key => commonMap[key] === feature);
|
|
116
|
+
if (commonKey)
|
|
117
|
+
return { key: commonKey, value: true };
|
|
118
|
+
return null;
|
|
119
|
+
}
|
package/dist/utils/file.d.ts
CHANGED
|
@@ -2,69 +2,89 @@
|
|
|
2
2
|
* 文件操作工具
|
|
3
3
|
* 文件和目录操作相关函数
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* 验证路径安全性,防止路径遍历攻击
|
|
7
|
+
* @param filePath 文件路径
|
|
8
|
+
* @param baseDir 基础目录(可选,用于限制路径范围)
|
|
9
|
+
* @throws {Error} 如果路径不安全
|
|
10
|
+
*/
|
|
11
|
+
export declare function validatePath(filePath: string, baseDir?: string): void;
|
|
5
12
|
/**
|
|
6
13
|
* 创建目录
|
|
7
14
|
* @param dirPath 目录路径
|
|
15
|
+
* @throws {Error} 如果目录创建失败
|
|
8
16
|
*/
|
|
9
17
|
export declare function createDir(dirPath: string): void;
|
|
10
18
|
/**
|
|
11
19
|
* 清空并重新创建目录
|
|
12
20
|
* @param dirPath 目录路径
|
|
21
|
+
* @throws {Error} 如果目录操作失败
|
|
13
22
|
*/
|
|
14
23
|
export declare function emptyDir(dirPath: string): void;
|
|
15
24
|
/**
|
|
16
25
|
* 检查路径是否存在
|
|
17
26
|
* @param filePath 文件路径
|
|
27
|
+
* @returns 路径是否存在
|
|
18
28
|
*/
|
|
19
29
|
export declare function pathExists(filePath: string): boolean;
|
|
20
30
|
/**
|
|
21
31
|
* 复制文件
|
|
22
32
|
* @param src 源文件路径
|
|
23
33
|
* @param dest 目标文件路径
|
|
34
|
+
* @throws {Error} 如果文件复制失败
|
|
24
35
|
*/
|
|
25
36
|
export declare function copyFile(src: string, dest: string): void;
|
|
26
37
|
/**
|
|
27
38
|
* 复制目录
|
|
28
39
|
* @param src 源目录路径
|
|
29
40
|
* @param dest 目标目录路径
|
|
41
|
+
* @throws {Error} 如果目录复制失败
|
|
30
42
|
*/
|
|
31
43
|
export declare function copyDir(src: string, dest: string): void;
|
|
32
44
|
/**
|
|
33
45
|
* 写入文件
|
|
34
46
|
* @param filePath 文件路径
|
|
35
47
|
* @param content 文件内容
|
|
48
|
+
* @throws {Error} 如果文件写入失败
|
|
36
49
|
*/
|
|
37
50
|
export declare function writeFile(filePath: string, content: string): void;
|
|
38
51
|
/**
|
|
39
52
|
* 读取文件
|
|
40
53
|
* @param filePath 文件路径
|
|
54
|
+
* @returns 文件内容
|
|
55
|
+
* @throws {Error} 如果文件不存在或读取失败
|
|
41
56
|
*/
|
|
42
57
|
export declare function readFile(filePath: string): string;
|
|
43
58
|
/**
|
|
44
59
|
* 读取 JSON 文件
|
|
45
60
|
* @param filePath 文件路径
|
|
61
|
+
* @returns 解析后的 JSON 对象
|
|
62
|
+
* @throws {Error} 如果文件不存在、读取失败或 JSON 解析失败
|
|
46
63
|
*/
|
|
47
64
|
export declare function readJsonFile<T = Record<string, unknown>>(filePath: string): T;
|
|
48
65
|
/**
|
|
49
66
|
* 写入 JSON 文件
|
|
50
67
|
* @param filePath 文件路径
|
|
51
68
|
* @param data 数据
|
|
69
|
+
* @throws {Error} 如果文件写入失败
|
|
52
70
|
*/
|
|
53
71
|
export declare function writeJsonFile(filePath: string, data: unknown): void;
|
|
54
72
|
/**
|
|
55
73
|
* 获取目录下所有文件
|
|
56
74
|
* @param dirPath 目录路径
|
|
57
|
-
* @param recursive
|
|
75
|
+
* @param recursive 是否递归,默认为 true
|
|
76
|
+
* @returns 文件路径数组
|
|
58
77
|
*/
|
|
59
78
|
export declare function getFiles(dirPath: string, recursive?: boolean): string[];
|
|
60
79
|
/**
|
|
61
80
|
* 获取模板目录路径
|
|
81
|
+
* @returns 模板目录的绝对路径
|
|
62
82
|
*/
|
|
63
83
|
export declare function getTemplatesDir(): string;
|
|
64
84
|
/**
|
|
65
85
|
* 获取相对路径
|
|
66
86
|
* @param from 起始路径
|
|
67
87
|
* @param to 目标路径
|
|
88
|
+
* @returns 相对路径字符串
|
|
68
89
|
*/
|
|
69
90
|
export declare function getRelativePath(from: string, to: string): string;
|
|
70
|
-
//# sourceMappingURL=file.d.ts.map
|
package/dist/utils/file.js
CHANGED
|
@@ -5,11 +5,32 @@
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import fs from 'fs-extra';
|
|
8
|
+
/**
|
|
9
|
+
* 验证路径安全性,防止路径遍历攻击
|
|
10
|
+
* @param filePath 文件路径
|
|
11
|
+
* @param baseDir 基础目录(可选,用于限制路径范围)
|
|
12
|
+
* @throws {Error} 如果路径不安全
|
|
13
|
+
*/
|
|
14
|
+
export function validatePath(filePath, baseDir) {
|
|
15
|
+
// 检查路径遍历攻击(.. 和 ~)
|
|
16
|
+
if (filePath.includes('..') || filePath.includes('~')) {
|
|
17
|
+
throw new Error(`不安全的路径: ${filePath}`);
|
|
18
|
+
}
|
|
19
|
+
// 如果提供了基础目录,确保路径在基础目录内
|
|
20
|
+
if (baseDir) {
|
|
21
|
+
const resolvedPath = path.resolve(filePath);
|
|
22
|
+
const resolvedBase = path.resolve(baseDir);
|
|
23
|
+
if (!resolvedPath.startsWith(resolvedBase)) {
|
|
24
|
+
throw new Error(`路径超出允许范围: ${filePath}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
8
28
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
29
|
const __dirname = path.dirname(__filename);
|
|
10
30
|
/**
|
|
11
31
|
* 创建目录
|
|
12
32
|
* @param dirPath 目录路径
|
|
33
|
+
* @throws {Error} 如果目录创建失败
|
|
13
34
|
*/
|
|
14
35
|
export function createDir(dirPath) {
|
|
15
36
|
fs.ensureDirSync(dirPath);
|
|
@@ -17,6 +38,7 @@ export function createDir(dirPath) {
|
|
|
17
38
|
/**
|
|
18
39
|
* 清空并重新创建目录
|
|
19
40
|
* @param dirPath 目录路径
|
|
41
|
+
* @throws {Error} 如果目录操作失败
|
|
20
42
|
*/
|
|
21
43
|
export function emptyDir(dirPath) {
|
|
22
44
|
fs.emptyDirSync(dirPath);
|
|
@@ -24,6 +46,7 @@ export function emptyDir(dirPath) {
|
|
|
24
46
|
/**
|
|
25
47
|
* 检查路径是否存在
|
|
26
48
|
* @param filePath 文件路径
|
|
49
|
+
* @returns 路径是否存在
|
|
27
50
|
*/
|
|
28
51
|
export function pathExists(filePath) {
|
|
29
52
|
return fs.existsSync(filePath);
|
|
@@ -32,6 +55,7 @@ export function pathExists(filePath) {
|
|
|
32
55
|
* 复制文件
|
|
33
56
|
* @param src 源文件路径
|
|
34
57
|
* @param dest 目标文件路径
|
|
58
|
+
* @throws {Error} 如果文件复制失败
|
|
35
59
|
*/
|
|
36
60
|
export function copyFile(src, dest) {
|
|
37
61
|
fs.ensureDirSync(path.dirname(dest));
|
|
@@ -41,6 +65,7 @@ export function copyFile(src, dest) {
|
|
|
41
65
|
* 复制目录
|
|
42
66
|
* @param src 源目录路径
|
|
43
67
|
* @param dest 目标目录路径
|
|
68
|
+
* @throws {Error} 如果目录复制失败
|
|
44
69
|
*/
|
|
45
70
|
export function copyDir(src, dest) {
|
|
46
71
|
fs.copySync(src, dest);
|
|
@@ -49,6 +74,7 @@ export function copyDir(src, dest) {
|
|
|
49
74
|
* 写入文件
|
|
50
75
|
* @param filePath 文件路径
|
|
51
76
|
* @param content 文件内容
|
|
77
|
+
* @throws {Error} 如果文件写入失败
|
|
52
78
|
*/
|
|
53
79
|
export function writeFile(filePath, content) {
|
|
54
80
|
fs.ensureDirSync(path.dirname(filePath));
|
|
@@ -57,6 +83,8 @@ export function writeFile(filePath, content) {
|
|
|
57
83
|
/**
|
|
58
84
|
* 读取文件
|
|
59
85
|
* @param filePath 文件路径
|
|
86
|
+
* @returns 文件内容
|
|
87
|
+
* @throws {Error} 如果文件不存在或读取失败
|
|
60
88
|
*/
|
|
61
89
|
export function readFile(filePath) {
|
|
62
90
|
return fs.readFileSync(filePath, 'utf-8');
|
|
@@ -64,6 +92,8 @@ export function readFile(filePath) {
|
|
|
64
92
|
/**
|
|
65
93
|
* 读取 JSON 文件
|
|
66
94
|
* @param filePath 文件路径
|
|
95
|
+
* @returns 解析后的 JSON 对象
|
|
96
|
+
* @throws {Error} 如果文件不存在、读取失败或 JSON 解析失败
|
|
67
97
|
*/
|
|
68
98
|
export function readJsonFile(filePath) {
|
|
69
99
|
return fs.readJsonSync(filePath);
|
|
@@ -72,6 +102,7 @@ export function readJsonFile(filePath) {
|
|
|
72
102
|
* 写入 JSON 文件
|
|
73
103
|
* @param filePath 文件路径
|
|
74
104
|
* @param data 数据
|
|
105
|
+
* @throws {Error} 如果文件写入失败
|
|
75
106
|
*/
|
|
76
107
|
export function writeJsonFile(filePath, data) {
|
|
77
108
|
fs.ensureDirSync(path.dirname(filePath));
|
|
@@ -80,7 +111,8 @@ export function writeJsonFile(filePath, data) {
|
|
|
80
111
|
/**
|
|
81
112
|
* 获取目录下所有文件
|
|
82
113
|
* @param dirPath 目录路径
|
|
83
|
-
* @param recursive
|
|
114
|
+
* @param recursive 是否递归,默认为 true
|
|
115
|
+
* @returns 文件路径数组
|
|
84
116
|
*/
|
|
85
117
|
export function getFiles(dirPath, recursive = true) {
|
|
86
118
|
const files = [];
|
|
@@ -104,6 +136,7 @@ export function getFiles(dirPath, recursive = true) {
|
|
|
104
136
|
}
|
|
105
137
|
/**
|
|
106
138
|
* 获取模板目录路径
|
|
139
|
+
* @returns 模板目录的绝对路径
|
|
107
140
|
*/
|
|
108
141
|
export function getTemplatesDir() {
|
|
109
142
|
return path.resolve(__dirname, '../../templates');
|
|
@@ -112,8 +145,8 @@ export function getTemplatesDir() {
|
|
|
112
145
|
* 获取相对路径
|
|
113
146
|
* @param from 起始路径
|
|
114
147
|
* @param to 目标路径
|
|
148
|
+
* @returns 相对路径字符串
|
|
115
149
|
*/
|
|
116
150
|
export function getRelativePath(from, to) {
|
|
117
151
|
return path.relative(from, to);
|
|
118
152
|
}
|
|
119
|
-
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 框架项目生成通用工具
|
|
3
|
+
* 抽离 react.ts 和 vue.ts 的公共逻辑
|
|
4
|
+
*/
|
|
5
|
+
import type { ProjectConfigType } from '../types/index.ts';
|
|
6
|
+
/**
|
|
7
|
+
* EJS 模板配置接口
|
|
8
|
+
* 定义框架项目生成所需的模板路径配置
|
|
9
|
+
*/
|
|
10
|
+
interface EjsTemplateConfig {
|
|
11
|
+
/** 主入口文件模板路径(相对于框架 base 目录) */
|
|
12
|
+
mainTemplate: string;
|
|
13
|
+
/** 主入口文件输出路径(相对于目标目录) */
|
|
14
|
+
mainOutput: string;
|
|
15
|
+
/** 路由文件模板路径(相对于框架 base 目录) */
|
|
16
|
+
routerTemplate: string;
|
|
17
|
+
/** 路由文件输出路径(相对于目标目录) */
|
|
18
|
+
routerOutput: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 生成框架项目的通用函数
|
|
22
|
+
* @param config 项目配置
|
|
23
|
+
* @param ejsConfig EJS 模板配置
|
|
24
|
+
* @throws {Error} 如果模板渲染失败、文件写入失败或配置生成失败
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateFrameworkProject(config: ProjectConfigType, ejsConfig: EjsTemplateConfig): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 框架项目生成通用工具
|
|
3
|
+
* 抽离 react.ts 和 vue.ts 的公共逻辑
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { FILE_CONSTANTS } from "../constants/index.js";
|
|
7
|
+
import { renderEjsToFile } from "./ejs.js";
|
|
8
|
+
import { getTemplatesDir } from "./file.js";
|
|
9
|
+
import { renderCommonFeatures, renderFrameworkFeatures } from "./renderFeatures.js";
|
|
10
|
+
import { renderTemplate, updatePackageJsonMetadata } from "./index.js";
|
|
11
|
+
import { getViteConfigEjsData } from "./viteConfigRender.js";
|
|
12
|
+
/**
|
|
13
|
+
* 生成框架项目的通用函数
|
|
14
|
+
* @param config 项目配置
|
|
15
|
+
* @param ejsConfig EJS 模板配置
|
|
16
|
+
* @throws {Error} 如果模板渲染失败、文件写入失败或配置生成失败
|
|
17
|
+
*/
|
|
18
|
+
export function generateFrameworkProject(config, ejsConfig) {
|
|
19
|
+
const { targetDir, framework } = config;
|
|
20
|
+
const templatesDir = getTemplatesDir();
|
|
21
|
+
// 1. 渲染 L0 公共基础模板
|
|
22
|
+
renderTemplate(path.join(templatesDir, 'common', 'base'), targetDir);
|
|
23
|
+
// 2. 渲染公共特性模板
|
|
24
|
+
renderCommonFeatures(config, targetDir);
|
|
25
|
+
// 3. 渲染 L1 框架基础模板
|
|
26
|
+
renderTemplate(path.join(templatesDir, framework, 'base'), targetDir);
|
|
27
|
+
// 4. 渲染 L2 特性模板(统一处理)
|
|
28
|
+
renderFrameworkFeatures(config, targetDir);
|
|
29
|
+
// 5. 渲染 EJS 模板
|
|
30
|
+
const ejsData = {
|
|
31
|
+
i18n: config.i18n,
|
|
32
|
+
sentry: config.sentry,
|
|
33
|
+
qiankun: config.qiankun,
|
|
34
|
+
routeMode: config.routeMode,
|
|
35
|
+
uiLibrary: config.uiLibrary,
|
|
36
|
+
};
|
|
37
|
+
const frameworkBasePath = path.join(templatesDir, framework, 'base');
|
|
38
|
+
renderEjsToFile(path.join(frameworkBasePath, ejsConfig.mainTemplate), path.join(targetDir, ejsConfig.mainOutput), ejsData);
|
|
39
|
+
renderEjsToFile(path.join(frameworkBasePath, ejsConfig.routerTemplate), path.join(targetDir, ejsConfig.routerOutput), ejsData);
|
|
40
|
+
// 6. 数据驱动生成 vite.config.ts(使用 EJS 模板)
|
|
41
|
+
const viteConfigEjsData = getViteConfigEjsData(config);
|
|
42
|
+
const commonBasePath = path.join(templatesDir, 'common', 'base');
|
|
43
|
+
renderEjsToFile(path.join(commonBasePath, 'vite.config.ts.ejs'), path.join(targetDir, 'vite.config.ts'), viteConfigEjsData);
|
|
44
|
+
// 7. 更新 package.json 的元数据字段
|
|
45
|
+
const packageJsonPath = path.join(targetDir, FILE_CONSTANTS.PACKAGE_JSON);
|
|
46
|
+
updatePackageJsonMetadata(packageJsonPath, config.projectName, config.description, config.author, config.packageManager);
|
|
47
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 工具函数导出
|
|
3
3
|
*/
|
|
4
|
-
export * from './deepMerge';
|
|
5
|
-
export * from './ejs';
|
|
6
|
-
export * from './file';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export
|
|
12
|
-
|
|
4
|
+
export * from './deepMerge.ts';
|
|
5
|
+
export * from './ejs.ts';
|
|
6
|
+
export * from './file.ts';
|
|
7
|
+
export * from './generateFrameworkProject.ts';
|
|
8
|
+
export * from './install.ts';
|
|
9
|
+
export * from './npmConfig.ts';
|
|
10
|
+
export * from './prompts.ts';
|
|
11
|
+
export { updatePackageJsonMetadata } from './renderTemplate.ts';
|
|
12
|
+
export * from './renderTemplate.ts';
|
|
13
|
+
export * from './sortDependencies.ts';
|
|
14
|
+
export * from './viteConfigRender.ts';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 工具函数导出
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export
|
|
12
|
-
|
|
4
|
+
export * from "./deepMerge.js";
|
|
5
|
+
export * from "./ejs.js";
|
|
6
|
+
export * from "./file.js";
|
|
7
|
+
export * from "./generateFrameworkProject.js";
|
|
8
|
+
export * from "./install.js";
|
|
9
|
+
export * from "./npmConfig.js";
|
|
10
|
+
export * from "./prompts.js";
|
|
11
|
+
export { updatePackageJsonMetadata } from "./renderTemplate.js";
|
|
12
|
+
export * from "./renderTemplate.js";
|
|
13
|
+
export * from "./sortDependencies.js";
|
|
14
|
+
export * from "./viteConfigRender.js";
|
package/dist/utils/install.d.ts
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
* 依赖安装工具
|
|
3
3
|
* 执行包管理器安装依赖
|
|
4
4
|
*/
|
|
5
|
-
import type { PackageManagerType } from '../types';
|
|
5
|
+
import type { PackageManagerType } from '../types/index.ts';
|
|
6
6
|
/**
|
|
7
7
|
* 安装依赖
|
|
8
8
|
* @param packageManager 包管理器
|
|
9
9
|
* @param cwd 工作目录
|
|
10
|
+
* @param retries 重试次数,默认 0(不重试)
|
|
11
|
+
* @returns Promise<void>
|
|
12
|
+
* @throws {Error} 如果安装失败
|
|
10
13
|
*/
|
|
11
|
-
export declare function installDependencies(packageManager: PackageManagerType, cwd: string): void
|
|
14
|
+
export declare function installDependencies(packageManager: PackageManagerType, cwd: string, retries?: number): Promise<void>;
|
|
12
15
|
/**
|
|
13
16
|
* 初始化 Git 仓库
|
|
14
17
|
* @param cwd 工作目录
|
|
18
|
+
* @returns Promise<void>
|
|
15
19
|
*/
|
|
16
|
-
export declare function initGit(cwd: string): void
|
|
17
|
-
//# sourceMappingURL=install.d.ts.map
|
|
20
|
+
export declare function initGit(cwd: string): Promise<void>;
|