@coze-arch/cli 0.0.1-alpha.ee4d5b → 0.0.1-alpha.ef0249

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 (33) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +10 -10
  2. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +2 -2
  3. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +2 -2
  4. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +45 -0
  5. package/lib/__templates__/expo/README.md +2 -0
  6. package/lib/__templates__/expo/client/app/_layout.tsx +14 -14
  7. package/lib/__templates__/expo/client/app/index.tsx +1 -1
  8. package/lib/__templates__/expo/client/app.config.ts +4 -3
  9. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  10. package/lib/__templates__/expo/client/eslint.config.mjs +13 -10
  11. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  12. package/lib/__templates__/expo/client/screens/{home → demo}/index.tsx +1 -1
  13. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
  14. package/lib/__templates__/expo/client/utils/index.ts +22 -0
  15. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  16. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +2486 -0
  17. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +155 -0
  18. package/lib/__templates__/expo/server/build.js +21 -0
  19. package/lib/__templates__/expo/server/package.json +2 -2
  20. package/lib/__templates__/expo/server/src/index.ts +2 -1
  21. package/lib/__templates__/nextjs/next.config.ts +2 -2
  22. package/lib/__templates__/nextjs/package.json +6 -1
  23. package/lib/__templates__/nextjs/pnpm-lock.yaml +1461 -1710
  24. package/lib/__templates__/nextjs/src/app/page.tsx +2 -2
  25. package/lib/__templates__/nextjs/template.config.js +5 -5
  26. package/lib/__templates__/vite/package.json +6 -1
  27. package/lib/__templates__/vite/pnpm-lock.yaml +504 -982
  28. package/lib/__templates__/vite/src/main.ts +1 -2
  29. package/lib/__templates__/vite/template.config.js +6 -4
  30. package/lib/cli.js +13 -6
  31. package/package.json +1 -1
  32. package/lib/__templates__/expo/client/app/home.tsx +0 -1
  33. /package/lib/__templates__/expo/client/screens/{home → demo}/styles.ts +0 -0
@@ -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
+ };
@@ -0,0 +1,21 @@
1
+ import * as esbuild from 'esbuild';
2
+ import { createRequire } from 'module';
3
+
4
+ const require = createRequire(import.meta.url);
5
+ const pkg = require('./package.json');
6
+ const dependencies = pkg.dependencies || {};
7
+ const externalList = Object.keys(dependencies).filter(dep => dep !== 'dayjs');
8
+ try {
9
+ await esbuild.build({
10
+ entryPoints: ['src/index.ts'],
11
+ bundle: true,
12
+ platform: 'node',
13
+ format: 'esm',
14
+ outdir: 'dist',
15
+ external: externalList,
16
+ });
17
+ console.log('⚡ Build complete!');
18
+ } catch (e) {
19
+ console.error(e);
20
+ process.exit(1);
21
+ }
@@ -4,8 +4,8 @@
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "preinstall": "npx only-allow pnpm",
7
- "dev": "NODE_ENV=development tsx ./src/index.ts",
8
- "build": "pnpm exec esbuild src/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist",
7
+ "dev": "bash ../.cozeproj/scripts/server_dev_run.sh",
8
+ "build": "node build.js",
9
9
  "start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js"
10
10
  },
11
11
  "dependencies": {
@@ -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' });
@@ -2,14 +2,14 @@ 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: {
9
9
  remotePatterns: [
10
10
  {
11
11
  protocol: 'https',
12
- hostname: 'lf3-static.bytednsdoc.com',
12
+ hostname: 'lf-coze-web-cdn.coze.cn',
13
13
  pathname: '/**',
14
14
  },
15
15
  ],
@@ -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",
@@ -82,5 +82,10 @@
82
82
  "packageManager": "pnpm@9.0.0",
83
83
  "engines": {
84
84
  "pnpm": ">=9.0.0"
85
+ },
86
+ "pnpm": {
87
+ "overrides": {
88
+ "esbuild": "^0.25.12"
89
+ }
85
90
  }
86
91
  }