@coze-arch/cli 0.0.1-alpha.f626fa → 0.0.1-alpha.f91253

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.
@@ -0,0 +1,155 @@
1
+ const names = require('./names')
2
+
3
+ const DEFAULTS = {
4
+ whitelist: names,
5
+ componentName: 'FontAwesome6',
6
+ attributeName: 'name',
7
+ };
8
+
9
+ function getJSXAttribute(openingElement, attrName) {
10
+ return openingElement.attributes.find(
11
+ (attr) =>
12
+ attr &&
13
+ attr.type === 'JSXAttribute' &&
14
+ attr.name &&
15
+ attr.name.name === attrName
16
+ );
17
+ }
18
+
19
+ function getStringLiteralValue(attribute) {
20
+ if (!attribute || !attribute.value) return null;
21
+
22
+ const val = attribute.value;
23
+
24
+ // <Comp name="hello" />
25
+ if (val.type === 'Literal' && typeof val.value === 'string') {
26
+ return val.value;
27
+ }
28
+
29
+ // <Comp name={'hello'} />
30
+ if (
31
+ val.type === 'JSXExpressionContainer' &&
32
+ val.expression &&
33
+ val.expression.type === 'Literal' &&
34
+ typeof val.expression.value === 'string'
35
+ ) {
36
+ return val.expression.value;
37
+ }
38
+
39
+ // <Comp name={`hello`} /> template literal without expressions
40
+ if (
41
+ val.type === 'JSXExpressionContainer' &&
42
+ val.expression &&
43
+ val.expression.type === 'TemplateLiteral' &&
44
+ val.expression.expressions.length === 0
45
+ ) {
46
+ return val.expression.quasis[0]?.value?.cooked ?? null;
47
+ }
48
+
49
+ return null;
50
+ }
51
+
52
+ module.exports = {
53
+ meta: {
54
+ type: 'problem',
55
+ docs: {
56
+ description:
57
+ 'Ensure FontAwesome6 name prop is a string literal in whitelist',
58
+ recommended: false,
59
+ },
60
+ schema: [
61
+ {
62
+ type: 'object',
63
+ additionalProperties: false,
64
+ properties: {
65
+ whitelist: {
66
+ type: 'array',
67
+ items: { type: 'string' },
68
+ default: DEFAULTS.whitelist,
69
+ },
70
+ componentName: {
71
+ type: 'string',
72
+ default: DEFAULTS.componentName,
73
+ },
74
+ attributeName: {
75
+ type: 'string',
76
+ default: DEFAULTS.attributeName,
77
+ },
78
+ caseSensitive: {
79
+ type: 'boolean',
80
+ default: true
81
+ }
82
+ },
83
+ },
84
+ ],
85
+ messages: {
86
+ invalidName:
87
+ '{{componentName}} 中不存在图标 {{name}},请更换为其他图标',
88
+ },
89
+ },
90
+
91
+ create(context) {
92
+ const options = context.options && context.options[0] ? context.options[0] : {};
93
+ const componentName = options.componentName || DEFAULTS.componentName;
94
+ const attributeName = options.attributeName || DEFAULTS.attributeName;
95
+ const caseSensitive = options.caseSensitive ?? true;
96
+
97
+ const whitelistRaw = Array.isArray(options.whitelist)
98
+ ? options.whitelist
99
+ : DEFAULTS.whitelist;
100
+
101
+ const normalize = (s) =>
102
+ caseSensitive ? String(s) : String(s).toLowerCase();
103
+
104
+ const whitelist = new Set(whitelistRaw.map(normalize));
105
+
106
+ function isTargetComponent(node) {
107
+ // Supports: <FontAwesome6 />, <NS.FontAwesome6 />
108
+ const nameNode = node.name;
109
+ if (!nameNode) return false;
110
+
111
+ if (nameNode.type === 'JSXIdentifier') {
112
+ return nameNode.name === componentName;
113
+ }
114
+
115
+ if (nameNode.type === 'JSXMemberExpression') {
116
+ // e.g., UI.FontAwesome6
117
+ let base = nameNode;
118
+ while (base.type === 'JSXMemberExpression') {
119
+ if (base.property && base.property.name === componentName) {
120
+ return true;
121
+ }
122
+ base = base.object;
123
+ }
124
+ }
125
+
126
+ return false;
127
+ }
128
+
129
+ return {
130
+ JSXOpeningElement(opening) {
131
+ if (!isTargetComponent(opening)) return;
132
+
133
+ const attrNode = getJSXAttribute(opening, attributeName);
134
+ if (!attrNode) return;
135
+
136
+ const literal = getStringLiteralValue(attrNode);
137
+
138
+ // Only lint when it's a string literal
139
+ if (literal == null) return;
140
+
141
+ const normalized = normalize(literal);
142
+ if (!whitelist.has(normalized)) {
143
+ context.report({
144
+ node: attrNode.value || attrNode,
145
+ messageId: 'invalidName',
146
+ data: {
147
+ componentName,
148
+ name: literal,
149
+ },
150
+ });
151
+ }
152
+ },
153
+ };
154
+ },
155
+ };
@@ -6,7 +6,8 @@ const port = process.env.PORT || 9091;
6
6
 
7
7
  // Middleware
8
8
  app.use(cors());
9
- app.use(express.json());
9
+ app.use(express.json({ limit: '50mb' }));
10
+ app.use(express.urlencoded({ limit: '50mb', extended: true }));
10
11
 
11
12
  app.get('/api/v1/health', (req, res) => {
12
13
  res.status(200).json({ status: 'ok' });
@@ -0,0 +1,15 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "next/babel",
5
+ {
6
+ "preset-react": {
7
+ "development": true
8
+ }
9
+ }
10
+ ]
11
+ ],
12
+ "plugins": [
13
+ "@react-dev-inspector/babel-plugin"
14
+ ]
15
+ }
@@ -2,7 +2,7 @@ import type { NextConfig } from 'next';
2
2
  import path from 'path';
3
3
 
4
4
  const nextConfig: NextConfig = {
5
- // outputFileTracingRoot: path.resolve(__dirname, '../../'),
5
+ outputFileTracingRoot: path.resolve(__dirname, '../../'),
6
6
  /* config options here */
7
7
  allowedDevOrigins: ['*.dev.coze.site'],
8
8
  images: {
@@ -43,7 +43,7 @@
43
43
  "class-variance-authority": "^0.7.1",
44
44
  "clsx": "^2.1.1",
45
45
  "cmdk": "^1.1.1",
46
- "coze-coding-dev-sdk": "^0.7.0",
46
+ "coze-coding-dev-sdk": "^0.7.3",
47
47
  "date-fns": "^4.1.0",
48
48
  "drizzle-kit": "^0.31.8",
49
49
  "drizzle-orm": "^0.45.1",
@@ -67,6 +67,8 @@
67
67
  "zod": "^4.3.5"
68
68
  },
69
69
  "devDependencies": {
70
+ "@react-dev-inspector/babel-plugin": "^2.0.1",
71
+ "@react-dev-inspector/middleware": "^2.0.1",
70
72
  "@tailwindcss/postcss": "^4",
71
73
  "@types/node": "^20",
72
74
  "@types/pg": "^8.16.0",
@@ -75,6 +77,7 @@
75
77
  "eslint": "^9",
76
78
  "eslint-config-next": "16.1.1",
77
79
  "only-allow": "^1.2.2",
80
+ "react-dev-inspector": "^2.0.1",
78
81
  "shadcn": "latest",
79
82
  "tailwindcss": "^4",
80
83
  "typescript": "^5"
@@ -82,5 +85,10 @@
82
85
  "packageManager": "pnpm@9.0.0",
83
86
  "engines": {
84
87
  "pnpm": ">=9.0.0"
88
+ },
89
+ "pnpm": {
90
+ "overrides": {
91
+ "esbuild": "^0.25.12"
92
+ }
85
93
  }
86
94
  }