@4399ywkf/cli 1.0.8 → 1.0.10

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 (96) hide show
  1. package/dist/templates/AntdStaticMethods/index.tsx +20 -0
  2. package/dist/templates/AppTheme.tsx +136 -0
  3. package/dist/templates/DIRECTORY_STRUCTURE.md +141 -0
  4. package/dist/templates/GlobalProvider/AppTheme.tsx +136 -0
  5. package/dist/templates/GlobalProvider/Locale.tsx +84 -0
  6. package/dist/templates/GlobalProvider/Query.tsx +12 -0
  7. package/dist/templates/GlobalProvider/StyleRegistry.tsx +9 -0
  8. package/dist/templates/GlobalProvider/index.tsx +23 -0
  9. package/dist/templates/Locale.tsx +55 -56
  10. package/dist/templates/Query.tsx +12 -0
  11. package/dist/templates/StyleRegistry.tsx +9 -0
  12. package/dist/templates/analyzeUnusedKeys.ts +506 -0
  13. package/dist/templates/app/.i18nrc.js +57 -0
  14. package/dist/templates/app/config/jwt/index.ts +2 -1
  15. package/dist/templates/app/docs/DIRECTORY_STRUCTURE.md +141 -0
  16. package/dist/templates/app/docs/glossary.md +11 -0
  17. package/dist/templates/app/package.json.tpl +7 -15
  18. package/dist/templates/app/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  19. package/dist/templates/app/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  20. package/dist/templates/app/scripts/i18nWorkflow/const.ts +18 -0
  21. package/dist/templates/app/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  22. package/dist/templates/app/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
  23. package/dist/templates/app/scripts/i18nWorkflow/genDiff.ts +49 -0
  24. package/dist/templates/app/scripts/i18nWorkflow/i18nConfig.ts +7 -0
  25. package/dist/templates/app/scripts/i18nWorkflow/index.ts +11 -0
  26. package/dist/templates/app/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
  27. package/dist/templates/app/scripts/i18nWorkflow/utils.ts +76 -0
  28. package/dist/templates/app/src/components/AntdStaticMethods/index.tsx +20 -0
  29. package/dist/templates/app/src/index.tsx +0 -4
  30. package/dist/templates/app/src/layout/GlobalProvider/AppTheme.tsx +136 -0
  31. package/dist/templates/app/src/layout/GlobalProvider/Locale.tsx +84 -0
  32. package/dist/templates/app/src/layout/GlobalProvider/Query.tsx +12 -0
  33. package/dist/templates/app/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  34. package/dist/templates/app/src/layout/GlobalProvider/index.tsx +23 -0
  35. package/dist/templates/app/src/locales/utils.ts +23 -0
  36. package/dist/templates/app/src/pages/base/index.tsx +170 -79
  37. package/dist/templates/app/src/routes.tsx +2 -2
  38. package/dist/templates/app/tsconfig.json +19 -3
  39. package/dist/templates/base/index.tsx +170 -79
  40. package/dist/templates/cleanUnusedKeys.ts +344 -0
  41. package/dist/templates/components/AntdStaticMethods/index.tsx +20 -0
  42. package/dist/templates/config/jwt/index.ts +2 -1
  43. package/dist/templates/const.ts +18 -0
  44. package/dist/templates/docs/DIRECTORY_STRUCTURE.md +141 -0
  45. package/dist/templates/docs/glossary.md +11 -0
  46. package/dist/templates/flattenLocaleKeys.ts +139 -0
  47. package/dist/templates/genDefaultLocale.ts +19 -0
  48. package/dist/templates/genDiff.ts +49 -0
  49. package/dist/templates/glossary.md +11 -0
  50. package/dist/templates/i18nConfig.ts +7 -0
  51. package/dist/templates/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  52. package/dist/templates/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  53. package/dist/templates/i18nWorkflow/const.ts +18 -0
  54. package/dist/templates/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  55. package/dist/templates/i18nWorkflow/genDefaultLocale.ts +19 -0
  56. package/dist/templates/i18nWorkflow/genDiff.ts +49 -0
  57. package/dist/templates/i18nWorkflow/i18nConfig.ts +7 -0
  58. package/dist/templates/i18nWorkflow/index.ts +11 -0
  59. package/dist/templates/i18nWorkflow/protectedPatterns.ts +91 -0
  60. package/dist/templates/i18nWorkflow/utils.ts +76 -0
  61. package/dist/templates/index.tsx +170 -79
  62. package/dist/templates/jwt/index.ts +2 -1
  63. package/dist/templates/layout/GlobalProvider/AppTheme.tsx +136 -0
  64. package/dist/templates/layout/GlobalProvider/Locale.tsx +84 -0
  65. package/dist/templates/layout/GlobalProvider/Query.tsx +12 -0
  66. package/dist/templates/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  67. package/dist/templates/layout/GlobalProvider/index.tsx +23 -0
  68. package/dist/templates/locales/utils.ts +23 -0
  69. package/dist/templates/package.json.tpl +7 -15
  70. package/dist/templates/pages/base/index.tsx +170 -79
  71. package/dist/templates/protectedPatterns.ts +91 -0
  72. package/dist/templates/routes.tsx +2 -2
  73. package/dist/templates/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
  74. package/dist/templates/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
  75. package/dist/templates/scripts/i18nWorkflow/const.ts +18 -0
  76. package/dist/templates/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
  77. package/dist/templates/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
  78. package/dist/templates/scripts/i18nWorkflow/genDiff.ts +49 -0
  79. package/dist/templates/scripts/i18nWorkflow/i18nConfig.ts +7 -0
  80. package/dist/templates/scripts/i18nWorkflow/index.ts +11 -0
  81. package/dist/templates/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
  82. package/dist/templates/scripts/i18nWorkflow/utils.ts +76 -0
  83. package/dist/templates/src/components/AntdStaticMethods/index.tsx +20 -0
  84. package/dist/templates/src/index.tsx +0 -4
  85. package/dist/templates/src/layout/GlobalProvider/AppTheme.tsx +136 -0
  86. package/dist/templates/src/layout/GlobalProvider/Locale.tsx +84 -0
  87. package/dist/templates/src/layout/GlobalProvider/Query.tsx +12 -0
  88. package/dist/templates/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
  89. package/dist/templates/src/layout/GlobalProvider/index.tsx +23 -0
  90. package/dist/templates/src/locales/utils.ts +23 -0
  91. package/dist/templates/src/pages/base/index.tsx +170 -79
  92. package/dist/templates/src/routes.tsx +2 -2
  93. package/dist/templates/tsconfig.json +19 -3
  94. package/dist/templates/type.ts +23 -24
  95. package/dist/templates/utils.ts +23 -0
  96. package/package.json +19 -21
@@ -0,0 +1,57 @@
1
+ const { defineConfig } = require("@lobehub/i18n-cli");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ module.exports = defineConfig({
6
+ entry: "locales/en-US",
7
+ entryLocale: "en-US",
8
+ output: "locales",
9
+ outputLocales: [
10
+ "ar",
11
+ "bg-BG",
12
+ "zh-CN",
13
+ "zh-TW",
14
+ "ru-RU",
15
+ "ja-JP",
16
+ "ko-KR",
17
+ "fr-FR",
18
+ "tr-TR",
19
+ "es-ES",
20
+ "pt-BR",
21
+ "de-DE",
22
+ "it-IT",
23
+ "nl-NL",
24
+ "pl-PL",
25
+ "vi-VN",
26
+ "fa-IR",
27
+ ],
28
+ temperature: 0,
29
+ saveImmediately: true,
30
+ modelName: "deepseek-chat",
31
+ experimental: {
32
+ jsonMode: true,
33
+ },
34
+ markdown: {
35
+ reference:
36
+ "You need to maintain the component format of the mdx file; the output text does not need to be wrapped in any code block syntax on the outermost layer.\n" +
37
+ fs.readFileSync(path.join(__dirname, "docs/glossary.md"), "utf-8"),
38
+ entry: ["./README.md", "./docs/**/*.md", "./docs/**/*.mdx"],
39
+ entryLocale: "en-US",
40
+ outputLocales: ["zh-CN"],
41
+ includeMatter: true,
42
+ exclude: [
43
+ "./README.zh-CN.md",
44
+ "./docs/**/*.zh-CN.md",
45
+ "./docs/**/*.zh-CN.mdx",
46
+ ],
47
+ outputExtensions: (locale, { filePath }) => {
48
+ if (filePath.includes(".mdx")) {
49
+ if (locale === "en-US") return ".mdx";
50
+ return `.${locale}.mdx`;
51
+ } else {
52
+ if (locale === "en-US") return ".md";
53
+ return `.${locale}.md`;
54
+ }
55
+ },
56
+ },
57
+ });
@@ -1,5 +1,6 @@
1
1
  import Cookies from "universal-cookie";
2
2
 
3
+ const cookies = new Cookies();
3
4
  const accessTokenKey = process.env.COOKIE_NAME;
4
5
 
5
6
  export default class jwt {
@@ -15,7 +16,7 @@ export default class jwt {
15
16
  token ? `${token.token_type} ${token.access_token}` : "",
16
17
  {
17
18
  expires: new Date(token.expires_at * 1000),
18
- }
19
+ },
19
20
  );
20
21
  }
21
22
 
@@ -0,0 +1,141 @@
1
+ # 企业脚手架目录规划说明
2
+
3
+ ## 1. 现状概览
4
+
5
+ ```
6
+ app/
7
+ ├── config/ # 构建 + 运行时配置混放
8
+ │ ├── env/ # 环境变量文件
9
+ │ ├── jwt/ # 运行时
10
+ │ ├── request/ # 运行时
11
+ │ ├── router/ # 渲染入口(renderClient)
12
+ │ └── rspack/ # 构建
13
+ ├── locales/ # 文案 JSON(与 src/locales 双源)
14
+ ├── public/
15
+ ├── scripts/
16
+ ├── src/
17
+ │ ├── bootstrap/
18
+ │ ├── color/ # 设计 token 色板
19
+ │ ├── components/
20
+ │ ├── config/ # 仅 env.ts(与根 config 易混淆)
21
+ │ ├── const/
22
+ │ ├── layout/
23
+ │ ├── locales/ # i18n 逻辑 + TS 文案
24
+ │ ├── micro/
25
+ │ ├── pages/
26
+ │ ├── routes.tsx
27
+ │ ├── styles/ # 全局样式 + theme 算法
28
+ │ ├── types/
29
+ │ └── utils/
30
+ └── store/ # 与 src 平级
31
+ ├── middleware/
32
+ └── user/
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 2. 结论:整体可用,有几处需约定或收敛
38
+
39
+ - **做得好的**:`store` 独立、按 agent/slice 拆分;`pages` + `layout` + `components` 分层清晰;构建配置集中在 `config/rspack`、环境变量在 `config/env`,便于维护。
40
+ - **需要约定的**:根目录 `config` 与 `src/config` 的职责边界、`locales` 双源、`color`/`styles`/`theme` 的归属。
41
+ - **可优化项**:收敛「配置与文案」的入口、统一命名(如 `const` vs `constants`)、可选能力(如 `micro`)在文档中说明。
42
+
43
+ ---
44
+
45
+ ## 3. 问题与建议
46
+
47
+ ### 3.1 config 双位置(根 config vs src/config)
48
+
49
+ | 位置 | 内容 | 问题 |
50
+ |------------|----------------|------------------------------|
51
+ | 根 `config/` | env 文件、rspack、request、jwt、router | 构建与运行时混在同一层 |
52
+ | `src/config/` | 仅 `env.ts`(zod 解析) | 新人易困惑「改 env 改哪边」 |
53
+
54
+ **建议(二选一或折中):**
55
+
56
+ - **方案 A(推荐)**:约定「根 `config/` = 仅构建与环境文件」:只放 `env/`、`rspack/`;把 `request/`、`jwt/`、`router/` 迁到 `src/config/`(或 `src/core/`),alias 保持 `@config` 指向 `src/config`,构建配置单独用 `config/rspack` 路径。这样「构建配置在根 config,运行时配置在 src」边界清晰。
57
+ - **方案 B**:维持现状,在 README 中明确写清:「环境变量与构建用根 `config/`,运行时解析用 `src/config/env.ts`;请求/路由等由根 `config/` 的模块提供」,减少误改。
58
+
59
+ ### 3.2 locales 双源(根 locales vs src/locales)
60
+
61
+ - 根 `locales/zh-CN/common.json` 与 `src/locales/default/common.ts` 内容重复,且有脚本把 TS 转 JSON。
62
+ - **建议**:选单一数据源。若以 i18n 代码为主,保留 `src/locales`,删除根 `locales/` 和转换脚本,构建或运行时从 `src/locales` 生成/加载;若以 JSON 为主,则只保留根 `locales/`,在 README 中说明「文案只放根 locales」。
63
+
64
+ ### 3.3 store 与 src 平级
65
+
66
+ - `store/` 在项目根与 `src/` 平级,符合「状态与 UI 分离」的常见企业习惯;alias `@store` 指向根下 `store` 也合理。
67
+ - **建议**:保持现状;在 README 或本说明中写一句:「业务 UI 在 `src/`,领域状态在 `store/`,按 agent/slice 拆分」,避免被误挪进 `src`。
68
+
69
+ ### 3.4 src 内部:color / styles / theme
70
+
71
+ - `color/`:色板与 token 数据;`styles/`:全局样式、antd 覆盖、**theme 算法与 customToken**;`types/` 中还有 `customStylish`、`customToken`。
72
+ - 问题:主题相关分散在 `color`、`styles/theme`、`styles`、`types`,新人找「改主题」入口不直观。
73
+ - **建议**:
74
+ - 要么保留 `color/` 但在 README 标明「设计 token 与色板,被 `styles/theme` 消费」;
75
+ - 要么将 `color/` 收进 `styles/theme/`(如 `styles/theme/color/`),入口统一为 `styles/theme`,减少顶层目录。
76
+ - 不强求一步到位,但需在文档中画一条线:**主题与 token 的入口是 `src/styles/theme`(及可选 `src/color`)**。
77
+
78
+ ### 3.5 横切目录:const / types / utils
79
+
80
+ - `const/`、`types/`、`utils/` 是常见横切层,结构合理。
81
+ - 小问题:`const/constants.ts` 当前为空;`types` 里既有全局类型又有与 theme 强相关的类型。
82
+ - **建议**:`const` 保留,删除或补全 `constants.ts`,避免空文件;在 README 或本说明中约定「全局业务常量放 `const/`,组件/页面私有常量随模块」。`types` 可注明「与 theme/样式强相关的类型与 `styles/theme` 同目录或在本目录集中维护」,二选一即可。
83
+
84
+ ### 3.6 可选能力:micro、bootstrap
85
+
86
+ - `micro/` 仅 Garfish,已作为可选项;`bootstrap/` 仅应用启动逻辑。
87
+ - **建议**:保持 `micro/` 在 `src` 下,README 中说明「微前端为可选项,入口与配置见 xxx」。`bootstrap/` 可保留;若希望根入口更短,可把 `bootstrapWithEnv()` 的实现迁到 `src/index.tsx` 或 `src/config/bootstrap.ts`,只保留单文件也可。
88
+
89
+ ### 3.7 pages 与路由
90
+
91
+ - `pages/` 下有 404、base、index 等;路由定义在 `src/routes.tsx`,渲染入口在 `config/router/index.tsx`。
92
+ - **建议**:约定「路由表仅由 `src/routes.tsx` 维护;`config/router` 只负责 `renderClient` 与挂载」,在 README 或本说明写清,避免在 `config/router` 里再配路由造成双源。
93
+
94
+ ### 3.8 根目录与脚本
95
+
96
+ - 根目录的 `tsconfig`、`tailwind`、`postcss`、`scripts/` 等符合常规,无需调整。
97
+ - `scripts/` 若仅剩「locales 转 JSON」且已决定废弃根 `locales/`,可删除该脚本;否则保留并注明用途。
98
+
99
+ ---
100
+
101
+ ## 4. 推荐约定(最小改动版)
102
+
103
+ 在不做大范围迁移的前提下,建议先做「约定文档化 + 少量收敛」:
104
+
105
+ 1. **配置**:在 README 中写清「根 `config/` = 构建与环境文件;运行时配置与请求/路由实现来自 `@config`(当前指向根 config,或你们改为 src/config)」。
106
+ 2. **文案**:选定 locales 单一数据源(推荐 `src/locales`),删除或弃用另一侧及转换脚本。
107
+ 3. **主题**:在 README 中标明「主题与 token 入口:`src/styles/theme`,色板数据见 `src/color`(可选)」。
108
+ 4. **store**:说明「全局状态在根 `store/`,按 agent/slice 划分,与 `src` 并列」。
109
+ 5. **路由**:说明「路由表只在 `src/routes.tsx` 维护;`config/router` 仅负责渲染与挂载」。
110
+ 6. **空文件**:删除或补全 `src/const/constants.ts`。
111
+
112
+ 若后续要做更大调整,再考虑:把 request/jwt/router 迁入 `src/config` 或 `src/core`、将 `color` 并入 `styles/theme` 等。
113
+
114
+ ---
115
+
116
+ ## 5. 可选:目标结构示意(供长期演进参考)
117
+
118
+ ```
119
+ app/
120
+ ├── config/ # 仅构建与环境
121
+ │ ├── env/
122
+ │ └── rspack/
123
+ ├── public/
124
+ ├── scripts/
125
+ ├── src/
126
+ │ ├── config/ # 运行时:env 解析、request、router 挂载等
127
+ │ ├── core/ # 可选:bootstrap、微前端入口等
128
+ │ ├── layout/
129
+ │ ├── pages/
130
+ │ ├── components/
131
+ │ ├── styles/ # 全局样式 + theme(含 token/color 或引用)
132
+ │ ├── locales/ # 单一 i18n 数据源
133
+ │ ├── const/
134
+ │ ├── types/
135
+ │ ├── utils/
136
+ │ ├── routes.tsx
137
+ │ └── index.tsx
138
+ └── store/
139
+ ```
140
+
141
+ 当前模板不必立刻改成上述结构,可先落实「约定 + 文档 + 删除冗余」,再按团队习惯逐步演进。
@@ -0,0 +1,11 @@
1
+ # Glossary
2
+
3
+ 以下是一些词汇的固定翻译:
4
+
5
+ | develop key | zh-CN (中文) | en-US(English) |
6
+ | ----------- | ------------ | -------------- |
7
+ | agent | 助理 | Agent |
8
+ | agentGroup | 群组 | Group |
9
+ | page | 文稿 | Page |
10
+ | topic | 话题 | Topic |
11
+ | thread | 子话题 | Thread |
@@ -8,11 +8,10 @@
8
8
  "dev:test": "cross-env NODE_ENV=testDevelopment rspack serve --config config/rspack/rspack.dev.mjs",
9
9
  "build:test": "cross-env NODE_ENV=test rspack build --config config/rspack/rspack.prod.mjs --mode production",
10
10
  "build": "cross-env NODE_ENV=production rspack build --config config/rspack/rspack.prod.mjs --mode production",
11
- "test": "jest",
12
11
  "lint": "biome check",
13
- "test:watch": "jest --watch",
14
- "test:coverage": "jest --coverage",
15
12
  "prepare": "husky install",
13
+ "i18n": "npm run workflow:i18n && lobe-i18n && prettier -c --write \"locales/**\"",
14
+ "workflow:i18n": "tsx ./scripts/i18nWorkflow/index.ts",
16
15
  "test:ci": "jest --coverage --watchAll=false"
17
16
  },
18
17
  "engines": {
@@ -29,7 +28,7 @@
29
28
  "@tanstack/react-query": "^5.80.6",
30
29
  "ahooks": "^3.8.5",
31
30
  "antd": "^6.1.1",
32
- "antd-style": "^3.7.1",
31
+ "antd-style": "^4.0.0",
33
32
  "clsx": "^2.1.1",
34
33
  "copy-webpack-plugin": "^13.0.1",
35
34
  "dayjs": "^1.11.13",
@@ -53,7 +52,6 @@
53
52
  "resolve-accept-language": "^3.1.11",
54
53
  "rtl-detect": "^1.1.2",
55
54
  "rxjs": "^7.8.2",
56
- "styled-components": "^5.3.11",
57
55
  "tailwind-merge": "^3.3.0",
58
56
  "tailwindcss": "^4.1.8",
59
57
  "universal-cookie": "^8.0.1",
@@ -71,16 +69,13 @@
71
69
  "@rspack/cli": "^1.1.8",
72
70
  "@rspack/core": "^1.1.8",
73
71
  "@svgr/webpack": "^7.0.0",
74
- "@testing-library/jest-dom": "^6.6.3",
75
- "@testing-library/react": "^16.3.0",
76
- "@testing-library/user-event": "^14.6.1",
77
- "@types/jest": "^29.5.14",
78
72
  "@types/lodash-es": "^4.17.12",
79
73
  "@types/node": "^22.9.0",
80
74
  "@types/react": "^19.1.6",
81
75
  "@types/react-dom": "^19.1.6",
82
76
  "@types/react-resizable": "^3.0.8",
83
- "@types/styled-components": "^5.1.34",
77
+ "@prettier/sync": "^0.6.1",
78
+ "@lobehub/i18n-cli": "^1.26.0",
84
79
  "assert": "^2.1.0",
85
80
  "autoprefixer": "^10.4.20",
86
81
  "axios": "^1.6.8",
@@ -88,6 +83,7 @@
88
83
  "browserify-zlib": "^0.2.0",
89
84
  "buffer": "^6.0.3",
90
85
  "chokidar": "^4.0.3",
86
+ "consola": "^3.4.2",
91
87
  "clean-webpack-plugin": "^4.0.0",
92
88
  "cross-env": "^7.0.3",
93
89
  "crypto-browserify": "^3.12.1",
@@ -100,10 +96,6 @@
100
96
  "globals": "^16.3.0",
101
97
  "html-webpack-plugin": "^5.6.3",
102
98
  "husky": "^9.1.7",
103
- "jest": "^29.7.0",
104
- "jest-environment-jsdom": "30.0.0-beta.3",
105
- "jiti": "^2.5.1",
106
- "js-cookie": "^2.2.1",
107
99
  "less": "^4.2.0",
108
100
  "less-loader": "^12.2.0",
109
101
  "lint-staged": "^16.1.6",
@@ -121,11 +113,11 @@
121
113
  "stream-browserify": "^3.0.0",
122
114
  "style-loader": "^3.3.4",
123
115
  "terser-webpack-plugin": "^5.3.11",
124
- "ts-jest": "^29.3.4",
125
116
  "ts-loader": "^9.5.1",
126
117
  "typescript": "^5.6.3",
127
118
  "url": "^0.11.4",
128
119
  "util": "^0.12.5",
120
+ "tsx": "^4.21.0",
129
121
  "webpack-merge": "^6.0.1"
130
122
  },
131
123
  "lint-staged": {