@coze-arch/cli 0.0.7-alpha.e6346c → 0.0.8-beta.0

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.
@@ -34,6 +34,19 @@
34
34
  ├── .cozeproj # 预置脚手架脚本(禁止修改)
35
35
  └── .coze # 配置文件(禁止修改)
36
36
 
37
+ ## 如何进行静态校验(TSC + ESLint)
38
+
39
+ ```bash
40
+ # 对 client 和 server 目录同时进行校验
41
+ npm run lint
42
+
43
+ # 对 client 目录进行校验
44
+ npm run lint:client
45
+
46
+ # 对 server 目录进行校验
47
+ npm run lint:server
48
+ ```
49
+
37
50
  ## 依赖管理与模块导入规范
38
51
 
39
52
  ### 依赖安装
@@ -34,6 +34,19 @@
34
34
  ├── .cozeproj # 预置脚手架脚本(禁止修改)
35
35
  └── .coze # 配置文件(禁止修改)
36
36
 
37
+ ## 如何进行静态校验(TSC + ESLint)
38
+
39
+ ```bash
40
+ # 对 client 和 server 目录同时进行校验
41
+ npm run lint
42
+
43
+ # 对 client 目录进行校验
44
+ npm run lint:client
45
+
46
+ # 对 server 目录进行校验
47
+ npm run lint:server
48
+ ```
49
+
37
50
  ## 依赖管理与模块导入规范
38
51
 
39
52
  ### 依赖安装
@@ -23,6 +23,7 @@ export default [
23
23
  '**/*.d.ts',
24
24
  'eslint.config.*',
25
25
  'metro.config.*',
26
+ './scripts/**',
26
27
  ],
27
28
  },
28
29
  regexp.configs["flat/recommended"],
@@ -7,7 +7,7 @@
7
7
  "check-deps": "npx depcheck",
8
8
  "postinstall": "npm run install-missing",
9
9
  "install-missing": "node ./scripts/install-missing-deps.js",
10
- "lint": "expo lint",
10
+ "lint": "tsc --noEmit; eslint ./ -f ./scripts/formatter.mjs --quiet",
11
11
  "start": "expo start --web --clear",
12
12
  "test": "jest --watchAll"
13
13
  },
@@ -90,6 +90,7 @@
90
90
  "react-test-renderer": "19.1.0",
91
91
  "tsx": "^4.21.0",
92
92
  "typescript": "^5.8.3",
93
- "typescript-eslint": "^8.32.1"
93
+ "typescript-eslint": "^8.32.1",
94
+ "axios": "^1.13.6"
94
95
  }
95
96
  }
@@ -0,0 +1,78 @@
1
+ import axios from 'axios'
2
+ import stylishFormatter from './stylish-formatter.mjs'
3
+ import { createMinimalClient, CustomPlugin } from './reporter.mjs'
4
+
5
+ const client = createMinimalClient()
6
+ const projectId = process.env.COZE_PROJECT_ID ?? ''
7
+
8
+ CustomPlugin(client);
9
+
10
+ client.init({
11
+ bid: 'coze_vibe_app',
12
+ transport: {
13
+ get: ({
14
+ success,
15
+ fail,
16
+ ...otherOptions
17
+ }) => {
18
+ axios({
19
+ method: 'get',
20
+ ...otherOptions,
21
+ }).then((res) => {
22
+ success && success(res.data)
23
+ }).catch(fail)
24
+ },
25
+ post: options => {
26
+ axios({
27
+ method: 'post',
28
+ ...options,
29
+ }).finally(() => {
30
+ console.log('\n')
31
+ })
32
+ },
33
+ }
34
+ })
35
+
36
+ client.start()
37
+
38
+ function normalizeESLintRuleId(ruleId) {
39
+ return ruleId?.replace(/[/-]/g, '_')
40
+ }
41
+
42
+ function reportESLintRulesMetrics(results) {
43
+ const metrics = {}
44
+ for (const { messages } of results) {
45
+ for (const message of messages) {
46
+ if (message.severity !== 2) {
47
+ continue
48
+ }
49
+
50
+ const normalizedRuleId = normalizeESLintRuleId(message.ruleId)
51
+ if (!normalizedRuleId) {
52
+ continue
53
+ }
54
+ metrics[normalizedRuleId] = (metrics[normalizedRuleId] ?? 0) + 1
55
+ }
56
+ }
57
+ try {
58
+ client.sendEvent({
59
+ name: 'eslint_rules',
60
+ metrics,
61
+ categories: {
62
+ project_id: projectId,
63
+ },
64
+ })
65
+ } catch (e) {
66
+
67
+ }
68
+ }
69
+
70
+ function formatter(results, data) {
71
+ if (projectId) {
72
+ reportESLintRulesMetrics(results)
73
+ }
74
+
75
+ return stylishFormatter(results, data)
76
+ }
77
+
78
+ export default formatter