generator-mico-cli 0.2.19 → 0.2.20

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 (21) hide show
  1. package/generators/micro-react/index.js +10 -0
  2. package/generators/micro-react/templates/.eslintrc.js +24 -1
  3. package/generators/micro-react/templates/CICD/start_dev.sh +1 -1
  4. package/generators/micro-react/templates/apps/layout/docs/common-intl.md +15 -15
  5. package/generators/micro-react/templates/apps/layout/docs/feature-/344/270/273/351/242/230/350/211/262/345/210/207/346/215/242.md +1 -1
  6. package/generators/micro-react/templates/apps/layout/docs/feature-/345/276/256/345/211/215/347/253/257/346/250/241/345/274/217.md +1 -1
  7. package/generators/micro-react/templates/apps/layout/src/common/locale.ts +3 -3
  8. package/generators/micro-react/templates/apps/layout/src/components/MicroAppLoader/index.tsx +1 -1
  9. package/generators/micro-react/templates/apps/layout/src/global.less +1 -1
  10. package/generators/micro-react/templates/apps/layout/src/services/config/type.ts +2 -4
  11. package/generators/micro-react/templates/package.json +3 -1
  12. package/generators/micro-react/templates/packages/common-intl/README.md +8 -8
  13. package/generators/micro-react/templates/packages/common-intl/src/intl.ts +13 -5678
  14. package/generators/micro-react/templates/packages/common-intl/src/utils.ts +22 -21
  15. package/package.json +1 -1
  16. package/generators/micro-react/templates/packages/common-intl/.turbo/turbo-build.log +0 -13
  17. package/generators/micro-react/templates/packages/common-intl/dist/index.d.ts +0 -3
  18. package/generators/micro-react/templates/packages/common-intl/dist/index.js +0 -4388
  19. package/generators/micro-react/templates/packages/common-intl/dist/indexedDBUtils.d.ts +0 -13
  20. package/generators/micro-react/templates/packages/common-intl/dist/intl.d.ts +0 -1022
  21. package/generators/micro-react/templates/packages/common-intl/dist/utils.d.ts +0 -122
@@ -210,6 +210,16 @@ module.exports = class extends Generator {
210
210
  }
211
211
 
212
212
  install() {
213
+ // 检查并初始化 git
214
+ const gitDir = path.join(this.destDir, '.git');
215
+ if (!fs.existsSync(gitDir)) {
216
+ this.log('');
217
+ this.log('🔧 初始化 Git 仓库...');
218
+ this.spawnCommandSync('git', ['init'], {
219
+ cwd: this.destDir,
220
+ });
221
+ }
222
+
213
223
  this.log('');
214
224
  this.log('📦 正在安装依赖...');
215
225
  this.spawnCommandSync('pnpm', ['install'], {
@@ -19,7 +19,30 @@ module.exports = {
19
19
  },
20
20
  ],
21
21
  },
22
- // 忽略 apps/ 子包和 scripts/
22
+ // TypeScript 文件使用专门的 parser
23
+ overrides: [
24
+ {
25
+ files: ["*.ts", "*.tsx"],
26
+ parser: "@typescript-eslint/parser",
27
+ plugins: ["@typescript-eslint"],
28
+ extends: [
29
+ "eslint:recommended",
30
+ "plugin:@typescript-eslint/recommended",
31
+ ],
32
+ rules: {
33
+ // 使用 TS 版本的 no-unused-vars
34
+ "no-unused-vars": "off",
35
+ "@typescript-eslint/no-unused-vars": [
36
+ "warn",
37
+ {
38
+ argsIgnorePattern: "^_",
39
+ varsIgnorePattern: "^_",
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ ],
45
+ // 忽略 apps/ 子包和 scripts/,apps由内部的eslint规则处理
23
46
  ignorePatterns: [
24
47
  'node_modules/',
25
48
  'dist/',
@@ -38,7 +38,7 @@ pnpm run build:development
38
38
 
39
39
  # 只有在 CI 环境时才写入版本号文件(覆盖写入)
40
40
  if [ "${CI}" = "true" ]; then
41
- echo "VERSION=$VERSION" > .env_x_<%= projectName %>portal-web
41
+ echo "VERSION=$VERSION" > .env_x_<%= projectName %>
42
42
  fi
43
43
 
44
44
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 概述
4
4
 
5
- `@portal-web/common-intl` 是 Portal 项目的通用国际化(i18n)库,用于管理多语言文案,支持从多语言中台拉取翻译数据。
5
+ `<%= packageScope %>/common-intl` 是 Portal 项目的通用国际化(i18n)库,用于管理多语言文案,支持从多语言中台拉取翻译数据。
6
6
 
7
7
  ## 适用场景
8
8
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  ## 两种使用模式
24
24
 
25
- 根据应用架构的不同,`@portal-web/common-intl` 支持两种使用模式:
25
+ 根据应用架构的不同,`<%= packageScope %>/common-intl` 支持两种使用模式:
26
26
 
27
27
  | 模式 | 适用场景 | 示例应用 |
28
28
  | ------------ | ------------------------------------------------ | ------------------------------------------------------------ |
@@ -64,7 +64,7 @@ import {
64
64
  getCurrentLocale,
65
65
  initIntl,
66
66
  type ILang,
67
- } from "@portal-web/common-intl";
67
+ } from "<%= packageScope %>/common-intl";
68
68
  import { Message } from "@mico-platform/ui";
69
69
  import { request } from "@umijs/max";
70
70
 
@@ -100,7 +100,7 @@ export function render(oldRender: () => void): void {
100
100
 
101
101
  ```typescript
102
102
  // apps/conversation-v2、apps/session、apps/workorder 等子应用
103
- import { intl } from "@portal-web/common-intl";
103
+ import { intl } from "<%= packageScope %>/common-intl";
104
104
 
105
105
  // 直接使用,文案来自主应用
106
106
  <h1>{intl.cs_web_workbench_conversation_record()}</h1>;
@@ -113,7 +113,7 @@ import { intl } from "@portal-web/common-intl";
113
113
  **独立应用配置(apps/mico-cs-mobile/src/app.ts)**:
114
114
 
115
115
  ```typescript
116
- import { initIntl } from "@portal-web/common-intl";
116
+ import { initIntl } from "<%= packageScope %>/common-intl";
117
117
  import { Toast } from "@arco-design/mobile-react";
118
118
  import { request } from "@umijs/max";
119
119
  import { convertLocaleToLangParam } from "./locales/utils";
@@ -149,7 +149,7 @@ export function render(oldRender: () => void): void {
149
149
  **独立应用的文案文件(apps/mico-cs-mobile/src/locales/index.ts)**:
150
150
 
151
151
  ```typescript
152
- import { i18n } from "@portal-web/common-intl";
152
+ import { i18n } from "<%= packageScope %>/common-intl";
153
153
 
154
154
  const intl = {
155
155
  sdk_h5_ticket_record: () =>
@@ -173,7 +173,7 @@ import intl from "@/locales";
173
173
 
174
174
  ## 导出 API
175
175
 
176
- `@portal-web/common-intl` 提供以下导出:
176
+ `<%= packageScope %>/common-intl` 提供以下导出:
177
177
 
178
178
  | 导出 | 类型 | 说明 |
179
179
  | -------------------- | ---- | --------------------------------------------------------- |
@@ -192,18 +192,18 @@ import intl from "@/locales";
192
192
 
193
193
  ```typescript
194
194
  // 微前端子应用 - 直接使用共享的 intl 对象
195
- import { intl } from "@portal-web/common-intl";
195
+ import { intl } from "<%= packageScope %>/common-intl";
196
196
  intl.cs_web_common_request_failed();
197
197
 
198
198
  // 独立应用 - 使用 i18n 函数构建自己的文案对象
199
- import { i18n, initIntl, LANG } from "@portal-web/common-intl";
199
+ import { i18n, initIntl, LANG } from "<%= packageScope %>/common-intl";
200
200
 
201
201
  // 获取当前语言环境
202
- import { getCurrentLocale } from "@portal-web/common-intl";
202
+ import { getCurrentLocale } from "<%= packageScope %>/common-intl";
203
203
  const currentLang = getCurrentLocale(); // 'zh_CN' | 'en' | 'ar' | 'tr'
204
204
 
205
205
  // 获取支持的语言列表
206
- import { SUPPORTED_LOCALES } from "@portal-web/common-intl";
206
+ import { SUPPORTED_LOCALES } from "<%= packageScope %>/common-intl";
207
207
  console.log(SUPPORTED_LOCALES); // ['zh_CN', 'en', 'ar', 'tr']
208
208
  ```
209
209
 
@@ -212,7 +212,7 @@ console.log(SUPPORTED_LOCALES); // ['zh_CN', 'en', 'ar', 'tr']
212
212
  ### PC 端主子应用
213
213
 
214
214
  - **文案位置**:[packages/common-intl/src/intl.ts](../packages/common-intl/src/intl.ts)
215
- - **使用方式**:`import { intl } from '@portal-web/common-intl'`
215
+ - **使用方式**:`import { intl } from '<%= packageScope %>/common-intl'`
216
216
  - **适用应用**:
217
217
  - apps/layout(主应用)
218
218
  - apps/conversation-v2(工作台子应用)
@@ -242,7 +242,7 @@ console.log(SUPPORTED_LOCALES); // ['zh_CN', 'en', 'ar', 'tr']
242
242
  // apps/your-app/package.json
243
243
  {
244
244
  "dependencies": {
245
- "@portal-web/common-intl": "workspace:*"
245
+ "<%= packageScope %>/common-intl": "workspace:*"
246
246
  }
247
247
  }
248
248
  ```
@@ -252,7 +252,7 @@ console.log(SUPPORTED_LOCALES); // ['zh_CN', 'en', 'ar', 'tr']
252
252
  **如果是 layout 的子应用**:
253
253
 
254
254
  - 无需调用 `initIntl()`
255
- - 直接使用 `import { intl } from '@portal-web/common-intl'`
255
+ - 直接使用 `import { intl } from '<%= packageScope %>/common-intl'`
256
256
 
257
257
  **如果是独立应用**:
258
258
 
@@ -321,7 +321,7 @@ console.log(SUPPORTED_LOCALES); // ['zh_CN', 'en', 'ar', 'tr']
321
321
  ### Q: 如何在代码中获取当前语言?
322
322
 
323
323
  ```typescript
324
- import { getCurrentLocale } from "@portal-web/common-intl";
324
+ import { getCurrentLocale } from "<%= packageScope %>/common-intl";
325
325
 
326
326
  const currentLang = getCurrentLocale();
327
327
  if (currentLang === "ar") {
@@ -201,7 +201,7 @@ wc -c apps/[子应用]/dist/umi.css
201
201
  1. 主应用加载 @mico-platform/ui 并暴露到 `window.micoUI`
202
202
  2. 主应用的样式包含 `arco-theme` 属性选择器(基于 Arco)
203
203
  3. 主应用切换主题时设置 `body[arco-theme="dark"]`
204
- 4. 子应用的 UI 组件(来自 window.micoUi)自动应用暗色样式
204
+ 4. 子应用的 UI 组件(来自 window.micoUI)自动应用暗色样式
205
205
 
206
206
  #### 子应用使用 @mico-platform/ui
207
207
 
@@ -70,7 +70,7 @@ interface MicroAppLoaderProps {
70
70
  ```typescript
71
71
  interface MicroAppProps {
72
72
  /** 主应用标识 */
73
- mainApp: 'portal-web';
73
+ mainApp: '<%= projectName %>';
74
74
  /** 运行环境 */
75
75
  env: 'development' | 'testing' | 'production';
76
76
  /** 认证 token */
@@ -122,7 +122,7 @@ export function setLocaleToStorage(locale: SupportedLocale): void {
122
122
  /**
123
123
  * 根据语言获取图标库路径
124
124
  */
125
- export function getIconFontPath(locale: SupportedLocale): string {
126
- // 如果后续需要支持 RTL 语言(如阿拉伯语),可在此扩展
127
- return withPublicPath('/font/default.js');
125
+ export function getIconFontPath(/* locale: SupportedLocale */): string {
126
+ // 如果后续需要支持 RTL 语言(如阿拉伯语),可在此扩展
127
+ return withPublicPath("/font/default.js");
128
128
  }
@@ -70,7 +70,7 @@ const MicroAppLoader: React.FC<MicroAppLoaderProps> = ({
70
70
  const buildProps = useCallback(() => {
71
71
  const authInfo = getAuthInfo();
72
72
  return {
73
- mainApp: 'portal-web',
73
+ mainApp: '<%= projectName %>',
74
74
  env,
75
75
  authToken: authInfo.token,
76
76
  uid: authInfo.uid,
@@ -7,7 +7,7 @@
7
7
  box-sizing: border-box;
8
8
  }
9
9
 
10
- #<%= projectName %> {
10
+ #root {
11
11
  height: 100vh;
12
12
  min-height: 800px;
13
13
  display: flex;
@@ -13,11 +13,9 @@ export interface ITimezone {
13
13
  }
14
14
 
15
15
  /**
16
- * 获取时区配置请求
16
+ * 获取时区配置请求(空请求体)
17
17
  */
18
- export interface IGetTimezoneListRequest {
19
- // 空请求体
20
- }
18
+ export type IGetTimezoneListRequest = Record<string, never>;
21
19
 
22
20
  /**
23
21
  * 获取时区配置响应
@@ -24,13 +24,15 @@
24
24
  "lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix && turbo run lint:fix",
25
25
  "check-types": "turbo run check-types",
26
26
  "lint-staged": "pnpm exec lint-staged --quiet",
27
- "prepare": "husky install",
27
+ "prepare": "husky",
28
28
  "test": "dotenv -e .env -e .env.local -- turbo run test",
29
29
  "create:umi-app": "./scripts/create-umi-app.sh"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@commitlint/cli": "^19.5.0",
33
33
  "@commitlint/config-conventional": "^19.5.0",
34
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
35
+ "@typescript-eslint/parser": "^8.54.0",
34
36
  "dotenv-cli": "^7.4.1",
35
37
  "eslint": "^8.57.0",
36
38
  "husky": "^9.1.7",
@@ -1,4 +1,4 @@
1
- # @portal-web/common-intl
1
+ # <%= packageScope %>/common-intl
2
2
 
3
3
  通用国际化(i18n)库,用于 Portal 多应用间的多语言文案管理。
4
4
 
@@ -18,14 +18,14 @@
18
18
  ```json
19
19
  {
20
20
  "dependencies": {
21
- "@portal-web/common-intl": "workspace:*"
21
+ "<%= packageScope %>/common-intl": "workspace:*"
22
22
  }
23
23
  }
24
24
  ```
25
25
 
26
26
  ## 两种使用模式
27
27
 
28
- 根据应用架构的不同,`@portal-web/common-intl` 支持两种使用模式:
28
+ 根据应用架构的不同,`<%= packageScope %>/common-intl` 支持两种使用模式:
29
29
 
30
30
  | 模式 | 适用场景 | 示例应用 |
31
31
  | ------------ | ------------------------------------------------ | ------------------------------------------------------------ |
@@ -49,7 +49,7 @@ import {
49
49
  getCurrentLocale,
50
50
  initIntl,
51
51
  type ILang,
52
- } from "@portal-web/common-intl";
52
+ } from "<%= packageScope %>/common-intl";
53
53
  import { Message } from "@mico-platform/ui";
54
54
  import { request } from "@umijs/max";
55
55
 
@@ -85,7 +85,7 @@ export function render(oldRender: () => void): void {
85
85
 
86
86
  ```typescript
87
87
  // apps/conversation-v2、apps/session、apps/workorder 等子应用
88
- import { intl } from "@portal-web/common-intl";
88
+ import { intl } from "<%= packageScope %>/common-intl";
89
89
 
90
90
  // 直接使用,文案来自主应用
91
91
  <h1>{intl.cs_web_workbench_conversation_record()}</h1>;
@@ -98,7 +98,7 @@ import { intl } from "@portal-web/common-intl";
98
98
  **独立应用配置**(参考 `apps/mico-cs-mobile/src/app.ts`):
99
99
 
100
100
  ```typescript
101
- import { initIntl } from "@portal-web/common-intl";
101
+ import { initIntl } from "<%= packageScope %>/common-intl";
102
102
  import { request } from "@umijs/max";
103
103
  import { convertLocaleToLangParam } from "./locales/utils";
104
104
  import { getSearchParams } from "@/common/jsbridge/jsbridge";
@@ -140,7 +140,7 @@ export function render(oldRender: () => void): void {
140
140
  **独立应用的文案文件**(`apps/mico-cs-mobile/src/locales/index.ts`):集中管理所有国际化文案
141
141
 
142
142
  ```typescript
143
- import { i18n } from "@portal-web/common-intl";
143
+ import { i18n } from "<%= packageScope %>/common-intl";
144
144
 
145
145
  const intl = {
146
146
  // 无插值示例
@@ -395,7 +395,7 @@ const intl = {
395
395
  2. 在业务代码中使用:
396
396
 
397
397
  ```typescript
398
- import { intl } from "@portal-web/common-intl";
398
+ import { intl } from "<%= packageScope %>/common-intl";
399
399
 
400
400
  // 使用新 key
401
401
  intl.cs_web_your_new_key();