@coze-arch/cli 0.0.7 → 0.0.8
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.
- package/lib/__templates__/expo/AGENTS.md +13 -0
- package/lib/__templates__/expo/README.md +13 -0
- package/lib/__templates__/expo/client/eslint.config.mjs +1 -0
- package/lib/__templates__/expo/client/package.json +3 -2
- package/lib/__templates__/expo/client/scripts/formatter.mjs +78 -0
- package/lib/__templates__/expo/client/scripts/reporter.mjs +1358 -0
- package/lib/__templates__/expo/client/scripts/stylish-formatter.mjs +153 -0
- package/lib/__templates__/expo/client/scripts/text-table.mjs +68 -0
- package/lib/__templates__/expo/package.json +4 -1
- package/lib/__templates__/expo/pnpm-lock.yaml +15 -4
- package/lib/__templates__/expo/server/package.json +2 -1
- package/lib/__templates__/nextjs/scripts/build.sh +2 -2
- package/lib/__templates__/nextjs/scripts/dev.sh +1 -1
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +13 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +1 -1
- package/lib/__templates__/taro/eslint.config.mjs +132 -123
- package/lib/__templates__/vite/scripts/build.sh +2 -2
- package/lib/__templates__/vite/scripts/dev.sh +1 -1
- package/lib/cli.js +4236 -488
- package/package.json +3 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Stylish reporter
|
|
3
|
+
* @author Sindre Sorhus
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import util from "node:util"
|
|
8
|
+
import table from "./text-table.mjs"
|
|
9
|
+
|
|
10
|
+
//------------------------------------------------------------------------------
|
|
11
|
+
// Helpers
|
|
12
|
+
//------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns a styling function based on the color option.
|
|
16
|
+
* @param {boolean|undefined} color Indicates whether to use colors.
|
|
17
|
+
* @returns {Function} A function that styles text.
|
|
18
|
+
*/
|
|
19
|
+
function getStyleText(color) {
|
|
20
|
+
if (typeof color === "undefined") {
|
|
21
|
+
return (format, text) =>
|
|
22
|
+
util.styleText(format, text, { validateStream: true });
|
|
23
|
+
}
|
|
24
|
+
if (color) {
|
|
25
|
+
return (format, text) =>
|
|
26
|
+
util.styleText(format, text, { validateStream: false });
|
|
27
|
+
}
|
|
28
|
+
return (_, text) => text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Given a word and a count, append an s if count is not one.
|
|
33
|
+
* @param {string} word A word in its singular form.
|
|
34
|
+
* @param {number} count A number controlling whether word should be pluralized.
|
|
35
|
+
* @returns {string} The original word with an s on the end if count is not one.
|
|
36
|
+
*/
|
|
37
|
+
function pluralize(word, count) {
|
|
38
|
+
return count === 1 ? word : `${word}s`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//------------------------------------------------------------------------------
|
|
42
|
+
// Public Interface
|
|
43
|
+
//------------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
export default function (results, data) {
|
|
46
|
+
const styleText = getStyleText(data?.color);
|
|
47
|
+
|
|
48
|
+
let output = "\n",
|
|
49
|
+
errorCount = 0,
|
|
50
|
+
warningCount = 0,
|
|
51
|
+
fixableErrorCount = 0,
|
|
52
|
+
fixableWarningCount = 0,
|
|
53
|
+
summaryColor = "yellow";
|
|
54
|
+
|
|
55
|
+
results.forEach(result => {
|
|
56
|
+
const messages = result.messages;
|
|
57
|
+
|
|
58
|
+
if (messages.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
errorCount += result.errorCount;
|
|
63
|
+
warningCount += result.warningCount;
|
|
64
|
+
fixableErrorCount += result.fixableErrorCount;
|
|
65
|
+
fixableWarningCount += result.fixableWarningCount;
|
|
66
|
+
|
|
67
|
+
output += `${styleText("underline", result.filePath)}\n`;
|
|
68
|
+
|
|
69
|
+
output += `${table(
|
|
70
|
+
messages.map(message => {
|
|
71
|
+
let messageType;
|
|
72
|
+
|
|
73
|
+
if (message.fatal || message.severity === 2) {
|
|
74
|
+
messageType = styleText("red", "error");
|
|
75
|
+
summaryColor = "red";
|
|
76
|
+
} else {
|
|
77
|
+
messageType = styleText("yellow", "warning");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return [
|
|
81
|
+
"",
|
|
82
|
+
String(message.line || 0),
|
|
83
|
+
String(message.column || 0),
|
|
84
|
+
messageType,
|
|
85
|
+
message.message.replace(/([^ ])\.$/u, "$1"),
|
|
86
|
+
message.ruleId ? styleText("dim", message.ruleId) : "",
|
|
87
|
+
];
|
|
88
|
+
}),
|
|
89
|
+
{
|
|
90
|
+
align: ["", "r", "l"],
|
|
91
|
+
stringLength(str) {
|
|
92
|
+
return util.stripVTControlCharacters(str).length;
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
.split("\n")
|
|
97
|
+
.map(el =>
|
|
98
|
+
el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) =>
|
|
99
|
+
styleText("dim", `${p1}:${p2}`),
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
.join("\n")}\n\n`;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const total = errorCount + warningCount;
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* We can't use a single `styleText` call like `styleText([summaryColor, "bold"], text)` here.
|
|
109
|
+
* This is a bug in `util.styleText` in Node.js versions earlier than v22.15.0 (https://github.com/nodejs/node/issues/56717).
|
|
110
|
+
* As a workaround, we use nested `styleText` calls.
|
|
111
|
+
*/
|
|
112
|
+
if (total > 0) {
|
|
113
|
+
output += `${styleText(
|
|
114
|
+
summaryColor,
|
|
115
|
+
styleText(
|
|
116
|
+
"bold",
|
|
117
|
+
[
|
|
118
|
+
"\u2716 ",
|
|
119
|
+
total,
|
|
120
|
+
pluralize(" problem", total),
|
|
121
|
+
" (",
|
|
122
|
+
errorCount,
|
|
123
|
+
pluralize(" error", errorCount),
|
|
124
|
+
", ",
|
|
125
|
+
warningCount,
|
|
126
|
+
pluralize(" warning", warningCount),
|
|
127
|
+
")",
|
|
128
|
+
].join(""),
|
|
129
|
+
),
|
|
130
|
+
)}\n`;
|
|
131
|
+
|
|
132
|
+
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
|
133
|
+
output += `${styleText(
|
|
134
|
+
summaryColor,
|
|
135
|
+
styleText(
|
|
136
|
+
"bold",
|
|
137
|
+
[
|
|
138
|
+
" ",
|
|
139
|
+
fixableErrorCount,
|
|
140
|
+
pluralize(" error", fixableErrorCount),
|
|
141
|
+
" and ",
|
|
142
|
+
fixableWarningCount,
|
|
143
|
+
pluralize(" warning", fixableWarningCount),
|
|
144
|
+
" potentially fixable with the `--fix` option.",
|
|
145
|
+
].join(""),
|
|
146
|
+
),
|
|
147
|
+
)}\n`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Resets output color, for prevent change on top level
|
|
152
|
+
return total > 0 ? styleText("reset", output) : "";
|
|
153
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Optimized version of the `text-table` npm module to improve performance by replacing inefficient regex-based
|
|
3
|
+
* whitespace trimming with a modern built-in method.
|
|
4
|
+
*
|
|
5
|
+
* This modification addresses a performance issue reported in https://github.com/eslint/eslint/issues/18709
|
|
6
|
+
*
|
|
7
|
+
* The `text-table` module is published under the MIT License. For the original source, refer to:
|
|
8
|
+
* https://www.npmjs.com/package/text-table.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
*
|
|
13
|
+
* This software is released under the MIT license:
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
16
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
17
|
+
* the Software without restriction, including without limitation the rights to
|
|
18
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
19
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
20
|
+
* subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
27
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
28
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
29
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
30
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
"use strict";
|
|
34
|
+
|
|
35
|
+
export default function (rows_, opts) {
|
|
36
|
+
const hsep = " ";
|
|
37
|
+
const align = opts.align;
|
|
38
|
+
const stringLength = opts.stringLength;
|
|
39
|
+
|
|
40
|
+
const sizes = rows_.reduce((acc, row) => {
|
|
41
|
+
row.forEach((c, ix) => {
|
|
42
|
+
const n = stringLength(c);
|
|
43
|
+
|
|
44
|
+
if (!acc[ix] || n > acc[ix]) {
|
|
45
|
+
acc[ix] = n;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return acc;
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return rows_
|
|
52
|
+
.map(row =>
|
|
53
|
+
row
|
|
54
|
+
.map((c, ix) => {
|
|
55
|
+
const n = sizes[ix] - stringLength(c) || 0;
|
|
56
|
+
const s = Array(Math.max(n + 1, 1)).join(" ");
|
|
57
|
+
|
|
58
|
+
if (align[ix] === "r") {
|
|
59
|
+
return s + c;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return c + s;
|
|
63
|
+
})
|
|
64
|
+
.join(hsep)
|
|
65
|
+
.trimEnd(),
|
|
66
|
+
)
|
|
67
|
+
.join("\n");
|
|
68
|
+
};
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
"dev": "bash .cozeproj/scripts/dev_run.sh",
|
|
7
7
|
"build": "bash .cozeproj/scripts/prod_build.sh",
|
|
8
8
|
"start": "bash .cozeproj/scripts/prod_run.sh",
|
|
9
|
-
"preinstall": "npx only-allow pnpm"
|
|
9
|
+
"preinstall": "npx only-allow pnpm",
|
|
10
|
+
"lint:client": "npm run lint --prefix ./client",
|
|
11
|
+
"lint:server": "npm run lint --prefix ./server",
|
|
12
|
+
"lint": "npm run lint --prefix ./client; npm run lint --prefix ./server"
|
|
10
13
|
},
|
|
11
14
|
"dependencies": {},
|
|
12
15
|
"devDependencies": {},
|
|
@@ -178,6 +178,9 @@ importers:
|
|
|
178
178
|
'@types/react-test-renderer':
|
|
179
179
|
specifier: 19.1.0
|
|
180
180
|
version: 19.1.0
|
|
181
|
+
axios:
|
|
182
|
+
specifier: ^1.13.6
|
|
183
|
+
version: 1.13.6
|
|
181
184
|
babel-plugin-module-resolver:
|
|
182
185
|
specifier: ^5.0.2
|
|
183
186
|
version: 5.0.2
|
|
@@ -2182,8 +2185,8 @@ packages:
|
|
|
2182
2185
|
resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
|
|
2183
2186
|
engines: {node: '>= 0.4'}
|
|
2184
2187
|
|
|
2185
|
-
axios@1.13.
|
|
2186
|
-
resolution: {integrity: sha512-
|
|
2188
|
+
axios@1.13.6:
|
|
2189
|
+
resolution: {integrity: sha512-ChTCHMouEe2kn713WHbQGcuYrr6fXTBiu460OTwWrWob16g1bXn4vtz07Ope7ewMozJAnEquLk5lWQWtBig9DQ==}
|
|
2187
2190
|
|
|
2188
2191
|
babel-jest@29.7.0:
|
|
2189
2192
|
resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==}
|
|
@@ -4711,6 +4714,9 @@ packages:
|
|
|
4711
4714
|
resolution: {integrity: sha512-3mqcLomDBXOo7Fo+UlaenG6f71bk1ZezPQy2JCmYHy2W2k5VKpP+Jbin9H0bjXynelTbglCqdFhSEkeIkKTYUA==}
|
|
4712
4715
|
engines: {node: '>=0.11.0'}
|
|
4713
4716
|
|
|
4717
|
+
pg-cloudflare@1.3.0:
|
|
4718
|
+
resolution: {integrity: sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ==}
|
|
4719
|
+
|
|
4714
4720
|
pg-connection-string@2.10.1:
|
|
4715
4721
|
resolution: {integrity: sha512-iNzslsoeSH2/gmDDKiyMqF64DATUCWj3YJ0wP14kqcsf2TUklwimd+66yYojKwZCA7h2yRNLGug71hCBA2a4sw==}
|
|
4716
4722
|
|
|
@@ -8267,7 +8273,7 @@ snapshots:
|
|
|
8267
8273
|
dependencies:
|
|
8268
8274
|
possible-typed-array-names: 1.1.0
|
|
8269
8275
|
|
|
8270
|
-
axios@1.13.
|
|
8276
|
+
axios@1.13.6:
|
|
8271
8277
|
dependencies:
|
|
8272
8278
|
follow-redirects: 1.15.11(debug@4.4.3)
|
|
8273
8279
|
form-data: 4.0.5
|
|
@@ -8700,7 +8706,7 @@ snapshots:
|
|
|
8700
8706
|
'@langchain/core': 1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6))
|
|
8701
8707
|
'@langchain/openai': 1.2.3(@langchain/core@1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6)))(ws@8.19.0)
|
|
8702
8708
|
'@supabase/supabase-js': 2.95.3
|
|
8703
|
-
axios: 1.13.
|
|
8709
|
+
axios: 1.13.6
|
|
8704
8710
|
pg: 8.17.2
|
|
8705
8711
|
transitivePeerDependencies:
|
|
8706
8712
|
- '@opentelemetry/api'
|
|
@@ -11331,6 +11337,9 @@ snapshots:
|
|
|
11331
11337
|
|
|
11332
11338
|
paths-js@0.4.11: {}
|
|
11333
11339
|
|
|
11340
|
+
pg-cloudflare@1.3.0:
|
|
11341
|
+
optional: true
|
|
11342
|
+
|
|
11334
11343
|
pg-connection-string@2.10.1: {}
|
|
11335
11344
|
|
|
11336
11345
|
pg-int8@1.0.1: {}
|
|
@@ -11356,6 +11365,8 @@ snapshots:
|
|
|
11356
11365
|
pg-protocol: 1.11.0
|
|
11357
11366
|
pg-types: 2.2.0
|
|
11358
11367
|
pgpass: 1.0.5
|
|
11368
|
+
optionalDependencies:
|
|
11369
|
+
pg-cloudflare: 1.3.0
|
|
11359
11370
|
|
|
11360
11371
|
pgpass@1.0.5:
|
|
11361
11372
|
dependencies:
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"build": "node build.js",
|
|
7
7
|
"dev": "bash ../.cozeproj/scripts/server_dev_run.sh",
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
9
|
-
"start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js"
|
|
9
|
+
"start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js",
|
|
10
|
+
"lint": "tsc --noEmit"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"@supabase/supabase-js": "2.95.3",
|
|
@@ -9,9 +9,9 @@ echo "Installing dependencies..."
|
|
|
9
9
|
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
10
10
|
|
|
11
11
|
echo "Building the Next.js project..."
|
|
12
|
-
|
|
12
|
+
pnpm next build
|
|
13
13
|
|
|
14
14
|
echo "Bundling server with tsup..."
|
|
15
|
-
|
|
15
|
+
pnpm tsup src/server.ts --format cjs --platform node --target node20 --outDir dist --no-splitting --no-minify
|
|
16
16
|
|
|
17
17
|
echo "Build completed successfully!"
|
|
@@ -91,6 +91,19 @@ export default defineNuxtConfig({
|
|
|
91
91
|
clientPort: 443,
|
|
92
92
|
timeout: 30000,
|
|
93
93
|
},
|
|
94
|
+
// Fix EMFILE: too many open files error
|
|
95
|
+
// Exclude large directories from file watching to avoid exceeding system limits
|
|
96
|
+
watch: {
|
|
97
|
+
ignored: [
|
|
98
|
+
'**/node_modules/**',
|
|
99
|
+
'**/.nuxt/**',
|
|
100
|
+
'**/.output/**',
|
|
101
|
+
'**/dist/**',
|
|
102
|
+
'**/.git/**',
|
|
103
|
+
'**/coverage/**',
|
|
104
|
+
'**/.cache/**',
|
|
105
|
+
],
|
|
106
|
+
},
|
|
94
107
|
},
|
|
95
108
|
},
|
|
96
109
|
|
|
@@ -9,6 +9,130 @@ const compat = new FlatCompat({
|
|
|
9
9
|
baseDirectory: __dirname,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
const baseRestrictedSyntaxRules = [
|
|
13
|
+
{
|
|
14
|
+
selector: "MemberExpression[object.name='process'][property.name='env']",
|
|
15
|
+
message:
|
|
16
|
+
'工程规范:请勿在 src 目录下直接使用 process.env\n如需获取 URL 请求前缀,请使用已经注入全局的 PROJECT_DOMAIN',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
selector:
|
|
20
|
+
":matches(ExportNamedDeclaration, ExportDefaultDeclaration) :matches([id.name='Network'], [declaration.id.name='Network'])",
|
|
21
|
+
message:
|
|
22
|
+
"工程规范:禁止自行定义 Network,项目已提供 src/network.ts,请直接使用: import { Network } from '@/network'",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
selector:
|
|
26
|
+
'Literal[value=/(^|\\s)(?:[^\\s:]+:)*(bg|text|border|divide|outline|ring|ring-offset|from|to|via|decoration|shadow|accent|caret|fill|stroke)-[a-z0-9-]+\\/([0-9]+|\\[[^\\]]+\\])/], TemplateElement[value.raw=/(^|\\s)(?:[^\\s:]+:)*(bg|text|border|divide|outline|ring|ring-offset|from|to|via|decoration|shadow|accent|caret|fill|stroke)-[a-z0-9-]+\\/([0-9]+|\\[[^\\]]+\\])/]',
|
|
27
|
+
message:
|
|
28
|
+
'微信小程序兼容性:禁用 Tailwind 颜色不透明度简写(如 bg-primary/10),该语法在微信小程序下 opacity 会丢失。请拆分写(如 bg-primary bg-opacity-10)。',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
selector:
|
|
32
|
+
'Literal[value=/(^|\\s)peer-[a-z0-9-]+\\b/], TemplateElement[value.raw=/(^|\\s)peer-[a-z0-9-]+\\b/]',
|
|
33
|
+
message:
|
|
34
|
+
'微信小程序兼容性:不支持 Tailwind 的 peer-*(如 peer-checked、peer-disabled)。',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
selector:
|
|
38
|
+
'Literal[value=/(^|\\s)group-[a-z0-9-]+\\b/], TemplateElement[value.raw=/(^|\\s)group-[a-z0-9-]+\\b/]',
|
|
39
|
+
message: '微信小程序兼容性:不支持 Tailwind 的 group-*(如 group-hover)。',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
selector:
|
|
43
|
+
'Literal[value=/\\b(?!gap(?:-x|-y)?-)[a-zA-Z0-9-]+\\-[0-9]+\\.[0-9]+\\b/], TemplateElement[value.raw=/\\b(?!gap(?:-x|-y)?-)[a-zA-Z0-9-]+\\-[0-9]+\\.[0-9]+\\b/]',
|
|
44
|
+
message:
|
|
45
|
+
'微信小程序兼容性:禁用 Tailwind 小数值类名(如 space-y-1.5、w-0.5),请用整数替代(如 space-y-2、w-1)。',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
selector:
|
|
49
|
+
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\:has\\(/], TemplateElement[value.raw=/\\:has\\(/])",
|
|
50
|
+
message: '微信小程序兼容性:WXSS 不支持 :has(...)(会导致预览上传失败)。',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
selector:
|
|
54
|
+
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/(^|\\s)has-[^\\s]+/], TemplateElement[value.raw=/(^|\\s)has-[^\\s]+/])",
|
|
55
|
+
message:
|
|
56
|
+
'微信小程序兼容性:禁用 Tailwind 的 has-* 变体(会生成 :has,导致预览上传失败)。',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
selector:
|
|
60
|
+
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[&>\\*/], TemplateElement[value.raw=/\\[&>\\*/])",
|
|
61
|
+
message:
|
|
62
|
+
'微信小程序兼容性:禁用 [&>*...](可能生成非法 WXSS,如 >:last-child)。请改为 [&>view] 等明确标签。',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
selector:
|
|
66
|
+
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[&[^\\]]*\\[data-/], TemplateElement[value.raw=/\\[&[^\\]]*\\[data-/])",
|
|
67
|
+
message:
|
|
68
|
+
'微信小程序兼容性:禁用 Tailwind 任意选择器里的属性选择器(如 [&>[data-...]]),可能导致预览上传失败。',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
selector:
|
|
72
|
+
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[[^\\]]*&[^\\]]*~[^\\]]*\\]/], TemplateElement[value.raw=/\\[[^\\]]*&[^\\]]*~[^\\]]*\\]/])",
|
|
73
|
+
message: '微信小程序兼容性:WXSS 不支持 ~(会导致预览上传失败)。',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
selector:
|
|
77
|
+
"JSXAttribute[name.name='color'][value.type='Literal'][value.value='currentColor'], JSXAttribute[name.name='color'] > JSXExpressionContainer > Literal[value='currentColor']",
|
|
78
|
+
message:
|
|
79
|
+
'lucide-react-taro 规范:禁止使用 color="currentColor",小程序端不会按预期继承颜色。请改为显式颜色值,或通过 LucideTaroProvider 提供默认颜色。',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const pageRestrictedSyntaxRules = [
|
|
84
|
+
{
|
|
85
|
+
selector:
|
|
86
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Button']",
|
|
87
|
+
message:
|
|
88
|
+
"组件规范:Button 优先使用 '@/components/ui/button',不要在页面中直接使用 '@tarojs/components' 的 Button。",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
selector:
|
|
92
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Input']",
|
|
93
|
+
message:
|
|
94
|
+
"组件规范:Input 优先使用 '@/components/ui/input',不要在页面中直接使用 '@tarojs/components' 的 Input。",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
selector:
|
|
98
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Textarea']",
|
|
99
|
+
message:
|
|
100
|
+
"组件规范:Textarea 优先使用 '@/components/ui/textarea',不要在页面中直接使用 '@tarojs/components' 的 Textarea。",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
selector:
|
|
104
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Label']",
|
|
105
|
+
message:
|
|
106
|
+
"组件规范:Label 优先使用 '@/components/ui/label',不要在页面中直接使用 '@tarojs/components' 的 Label。",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
selector:
|
|
110
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Switch']",
|
|
111
|
+
message:
|
|
112
|
+
"组件规范:Switch 优先使用 '@/components/ui/switch',不要在页面中直接使用 '@tarojs/components' 的 Switch。",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
selector:
|
|
116
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Slider']",
|
|
117
|
+
message:
|
|
118
|
+
"组件规范:Slider 优先使用 '@/components/ui/slider',不要在页面中直接使用 '@tarojs/components' 的 Slider。",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
selector:
|
|
122
|
+
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Progress']",
|
|
123
|
+
message:
|
|
124
|
+
"组件规范:Progress 优先使用 '@/components/ui/progress',不要在页面中直接使用 '@tarojs/components' 的 Progress。",
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const indexPageRestrictedSyntaxRules = [
|
|
129
|
+
{
|
|
130
|
+
selector: 'JSXText[value=/\\s*应用开发中\\s*/]',
|
|
131
|
+
message:
|
|
132
|
+
'工程规范:检测到首页 (src/pages/index/index.tsx) 仍为默认占位页面,这会导致用户无法进入新增页面,请根据用户需求开发实际的首页功能与界面。如果已经开发了新的首页,也需要删除旧首页,并更新 src/app.config.ts 文件',
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
|
|
12
136
|
export default [
|
|
13
137
|
...compat.extends('taro/react'),
|
|
14
138
|
{
|
|
@@ -25,80 +149,7 @@ export default [
|
|
|
25
149
|
files: ['src/**/*.{js,jsx,ts,tsx}'],
|
|
26
150
|
ignores: ['src/network.ts'],
|
|
27
151
|
rules: {
|
|
28
|
-
'no-restricted-syntax': [
|
|
29
|
-
'error',
|
|
30
|
-
{
|
|
31
|
-
selector:
|
|
32
|
-
"MemberExpression[object.name='process'][property.name='env']",
|
|
33
|
-
message:
|
|
34
|
-
'工程规范:请勿在 src 目录下直接使用 process.env\n如需获取 URL 请求前缀,请使用已经注入全局的 PROJECT_DOMAIN',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
selector:
|
|
38
|
-
":matches(ExportNamedDeclaration, ExportDefaultDeclaration) :matches([id.name='Network'], [declaration.id.name='Network'])",
|
|
39
|
-
message:
|
|
40
|
-
"工程规范:禁止自行定义 Network,项目已提供 src/network.ts,请直接使用: import { Network } from '@/network'",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
selector:
|
|
44
|
-
'Literal[value=/(^|\\s)(?:[^\\s:]+:)*(bg|text|border|divide|outline|ring|ring-offset|from|to|via|decoration|shadow|accent|caret|fill|stroke)-[a-z0-9-]+\\/([0-9]+|\\[[^\\]]+\\])/], TemplateElement[value.raw=/(^|\\s)(?:[^\\s:]+:)*(bg|text|border|divide|outline|ring|ring-offset|from|to|via|decoration|shadow|accent|caret|fill|stroke)-[a-z0-9-]+\\/([0-9]+|\\[[^\\]]+\\])/]',
|
|
45
|
-
message:
|
|
46
|
-
'微信小程序兼容性:禁用 Tailwind 颜色不透明度简写(如 bg-primary/10),该语法在微信小程序下 opacity 会丢失。请拆分写(如 bg-primary bg-opacity-10)。',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
selector:
|
|
50
|
-
'Literal[value=/(^|\\s)peer-[a-z0-9-]+\\b/], TemplateElement[value.raw=/(^|\\s)peer-[a-z0-9-]+\\b/]',
|
|
51
|
-
message:
|
|
52
|
-
'微信小程序兼容性:不支持 Tailwind 的 peer-*(如 peer-checked、peer-disabled)。',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
selector:
|
|
56
|
-
'Literal[value=/(^|\\s)group-[a-z0-9-]+\\b/], TemplateElement[value.raw=/(^|\\s)group-[a-z0-9-]+\\b/]',
|
|
57
|
-
message:
|
|
58
|
-
'微信小程序兼容性:不支持 Tailwind 的 group-*(如 group-hover)。',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
selector:
|
|
62
|
-
'Literal[value=/\\b(?!gap(?:-x|-y)?-)[a-zA-Z0-9-]+\\-[0-9]+\\.[0-9]+\\b/], TemplateElement[value.raw=/\\b(?!gap(?:-x|-y)?-)[a-zA-Z0-9-]+\\-[0-9]+\\.[0-9]+\\b/]',
|
|
63
|
-
message:
|
|
64
|
-
'微信小程序兼容性:禁用 Tailwind 小数值类名(如 space-y-1.5、w-0.5),请用整数替代(如 space-y-2、w-1)。',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
selector:
|
|
68
|
-
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\:has\\(/], TemplateElement[value.raw=/\\:has\\(/])",
|
|
69
|
-
message:
|
|
70
|
-
'微信小程序兼容性:WXSS 不支持 :has(...)(会导致预览上传失败)。',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
selector:
|
|
74
|
-
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/(^|\\s)has-[^\\s]+/], TemplateElement[value.raw=/(^|\\s)has-[^\\s]+/])",
|
|
75
|
-
message:
|
|
76
|
-
'微信小程序兼容性:禁用 Tailwind 的 has-* 变体(会生成 :has,导致预览上传失败)。',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
selector:
|
|
80
|
-
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[&>\\*/], TemplateElement[value.raw=/\\[&>\\*/])",
|
|
81
|
-
message:
|
|
82
|
-
'微信小程序兼容性:禁用 [&>*...](可能生成非法 WXSS,如 >:last-child)。请改为 [&>view] 等明确标签。',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
selector:
|
|
86
|
-
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[&[^\\]]*\\[data-/], TemplateElement[value.raw=/\\[&[^\\]]*\\[data-/])",
|
|
87
|
-
message:
|
|
88
|
-
'微信小程序兼容性:禁用 Tailwind 任意选择器里的属性选择器(如 [&>[data-...]]),可能导致预览上传失败。',
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
selector:
|
|
92
|
-
":matches(JSXAttribute[name.name='className'], CallExpression[callee.name=/^(cn|cva)$/]) :matches(Literal[value=/\\[[^\\]]*&[^\\]]*~[^\\]]*\\]/], TemplateElement[value.raw=/\\[[^\\]]*&[^\\]]*~[^\\]]*\\]/])",
|
|
93
|
-
message: '微信小程序兼容性:WXSS 不支持 ~(会导致预览上传失败)。',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
selector:
|
|
97
|
-
"JSXAttribute[name.name='color'][value.type='Literal'][value.value='currentColor'], JSXAttribute[name.name='color'] > JSXExpressionContainer > Literal[value='currentColor']",
|
|
98
|
-
message:
|
|
99
|
-
'lucide-react-taro 规范:禁止使用 color="currentColor",小程序端不会按预期继承颜色。请改为显式颜色值,或通过 LucideTaroProvider 提供默认颜色。',
|
|
100
|
-
},
|
|
101
|
-
],
|
|
152
|
+
'no-restricted-syntax': ['error', ...baseRestrictedSyntaxRules],
|
|
102
153
|
'no-restricted-properties': [
|
|
103
154
|
'error',
|
|
104
155
|
{
|
|
@@ -123,65 +174,23 @@ export default [
|
|
|
123
174
|
},
|
|
124
175
|
},
|
|
125
176
|
{
|
|
126
|
-
files: ['src/pages
|
|
177
|
+
files: ['src/pages/**/*.tsx'],
|
|
127
178
|
rules: {
|
|
128
179
|
'no-restricted-syntax': [
|
|
129
180
|
'error',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
message:
|
|
133
|
-
'工程规范:检测到首页 (src/pages/index/index.tsx) 仍为默认占位页面,这会导致用户无法进入新增页面,请根据用户需求开发实际的首页功能 and 界面。如果已经开发了新的首页,也需要删除旧首页,并更新 src/app.config.ts 文件',
|
|
134
|
-
},
|
|
181
|
+
...baseRestrictedSyntaxRules,
|
|
182
|
+
...pageRestrictedSyntaxRules,
|
|
135
183
|
],
|
|
136
184
|
},
|
|
137
185
|
},
|
|
138
186
|
{
|
|
139
|
-
files: ['src/pages
|
|
187
|
+
files: ['src/pages/index/index.tsx'],
|
|
140
188
|
rules: {
|
|
141
189
|
'no-restricted-syntax': [
|
|
142
190
|
'error',
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
message:
|
|
147
|
-
"组件规范:Button 优先使用 '@/components/ui/button',不要在页面中直接使用 '@tarojs/components' 的 Button。",
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
selector:
|
|
151
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Input']",
|
|
152
|
-
message:
|
|
153
|
-
"组件规范:Input 优先使用 '@/components/ui/input',不要在页面中直接使用 '@tarojs/components' 的 Input。",
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
selector:
|
|
157
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Textarea']",
|
|
158
|
-
message:
|
|
159
|
-
"组件规范:Textarea 优先使用 '@/components/ui/textarea',不要在页面中直接使用 '@tarojs/components' 的 Textarea。",
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
selector:
|
|
163
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Label']",
|
|
164
|
-
message:
|
|
165
|
-
"组件规范:Label 优先使用 '@/components/ui/label',不要在页面中直接使用 '@tarojs/components' 的 Label。",
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
selector:
|
|
169
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Switch']",
|
|
170
|
-
message:
|
|
171
|
-
"组件规范:Switch 优先使用 '@/components/ui/switch',不要在页面中直接使用 '@tarojs/components' 的 Switch。",
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
selector:
|
|
175
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Slider']",
|
|
176
|
-
message:
|
|
177
|
-
"组件规范:Slider 优先使用 '@/components/ui/slider',不要在页面中直接使用 '@tarojs/components' 的 Slider。",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
selector:
|
|
181
|
-
"ImportDeclaration[source.value='@tarojs/components'] ImportSpecifier[imported.name='Progress']",
|
|
182
|
-
message:
|
|
183
|
-
"组件规范:Progress 优先使用 '@/components/ui/progress',不要在页面中直接使用 '@tarojs/components' 的 Progress。",
|
|
184
|
-
},
|
|
191
|
+
...baseRestrictedSyntaxRules,
|
|
192
|
+
...pageRestrictedSyntaxRules,
|
|
193
|
+
...indexPageRestrictedSyntaxRules,
|
|
185
194
|
],
|
|
186
195
|
},
|
|
187
196
|
},
|
|
@@ -9,9 +9,9 @@ echo "Installing dependencies..."
|
|
|
9
9
|
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
10
10
|
|
|
11
11
|
echo "Building frontend with Vite..."
|
|
12
|
-
|
|
12
|
+
pnpm vite build
|
|
13
13
|
|
|
14
14
|
echo "Bundling server with tsup..."
|
|
15
|
-
|
|
15
|
+
pnpm tsup server/server.ts --format cjs --platform node --target node20 --outDir dist-server --no-splitting --no-minify --external vite
|
|
16
16
|
|
|
17
17
|
echo "Build completed successfully!"
|