@tbox.cn/app-template-h5 0.1.21 → 1.0.0-alpha.1
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/.gitignore +4 -8
- package/.npmignore +7 -0
- package/.tbox/app.json +3 -2
- package/AGENTS.md +17 -63
- package/README.md +21 -31
- package/apps/AGENTS.md +17 -0
- package/apps/client/index.html +0 -4
- package/apps/client/package.json +5 -7
- package/apps/client/src/pages/page.tsx +33 -0
- package/apps/client/src/platform/bootstrap.ts +0 -7
- package/apps/client/src/platform/mount-page.tsx +4 -12
- package/apps/client/src/styles/base.css +14 -34
- package/apps/client/tsconfig.json +3 -6
- package/apps/client/vite.config.ts +30 -39
- package/apps/client/vitest.config.ts +10 -0
- package/apps/server/package.json +6 -4
- package/apps/server/src/app.ts +2 -35
- package/apps/server/src/dev.ts +37 -123
- package/apps/server/src/functions/greet.server.ts +5 -0
- package/apps/server/src/index.ts +17 -39
- package/apps/server/tests/app.test.ts +30 -5
- package/apps/server/tsconfig.json +5 -3
- package/apps/server/tsup.config.ts +4 -7
- package/apps/server/vitest.config.ts +0 -1
- package/eslint.config.mjs +1 -1
- package/modules/.gitkeep +0 -0
- package/package.json +30 -16
- package/packages/shared/AGENTS.md +11 -0
- package/packages/shared/package.json +13 -0
- package/packages/shared/src/index.ts +7 -0
- package/packages/shared/tsconfig.json +7 -0
- package/pnpm-lock.template.yaml +72 -37
- package/pnpm-workspace.template.yaml +11 -18
- package/scripts/agents-check.mjs +23 -0
- package/scripts/agents-sync.mjs +9 -0
- package/scripts/build.sh +2 -26
- package/scripts/check.mjs +7 -0
- package/scripts/dev.sh +1 -9
- package/scripts/generate.mjs +3 -0
- package/scripts/start.sh +1 -7
- package/apps/client/src/business/App.tsx +0 -3
- package/apps/client/src/business/routes.json +0 -3
- package/apps/client/src/main.tsx +0 -29
- package/scripts/check-workspace.mjs +0 -144
- package/scripts/prepare.sh +0 -11
package/pnpm-lock.template.yaml
CHANGED
|
@@ -6,12 +6,15 @@ settings:
|
|
|
6
6
|
|
|
7
7
|
catalogs:
|
|
8
8
|
default:
|
|
9
|
+
'@tbox.cn/app-build':
|
|
10
|
+
specifier: 1.0.0-alpha.1
|
|
11
|
+
version: 1.0.0-alpha.1
|
|
9
12
|
'@tbox.cn/app-sdk-client':
|
|
10
|
-
specifier: 0.
|
|
11
|
-
version: 0.
|
|
13
|
+
specifier: 1.0.0-alpha.1
|
|
14
|
+
version: 1.0.0-alpha.1
|
|
12
15
|
'@tbox.cn/app-sdk-server':
|
|
13
|
-
specifier: 0.
|
|
14
|
-
version: 0.
|
|
16
|
+
specifier: 1.0.0-alpha.1
|
|
17
|
+
version: 1.0.0-alpha.1
|
|
15
18
|
'@types/express':
|
|
16
19
|
specifier: 4.17.25
|
|
17
20
|
version: 4.17.25
|
|
@@ -76,16 +79,35 @@ overrides:
|
|
|
76
79
|
importers:
|
|
77
80
|
|
|
78
81
|
.:
|
|
82
|
+
dependencies:
|
|
83
|
+
express:
|
|
84
|
+
specifier: 'catalog:'
|
|
85
|
+
version: 4.22.2
|
|
79
86
|
devDependencies:
|
|
87
|
+
'@tbox.cn/app-build':
|
|
88
|
+
specifier: 'catalog:'
|
|
89
|
+
version: 1.0.0-alpha.1(vite@6.4.3(@types/node@24.13.3)(tsx@4.23.11))
|
|
90
|
+
'@tbox.cn/app-sdk-client':
|
|
91
|
+
specifier: 'catalog:'
|
|
92
|
+
version: 1.0.0-alpha.1
|
|
80
93
|
'@tbox.cn/app-sdk-server':
|
|
81
94
|
specifier: 'catalog:'
|
|
82
|
-
version: 0.
|
|
95
|
+
version: 1.0.0-alpha.1
|
|
96
|
+
'@types/node':
|
|
97
|
+
specifier: 'catalog:'
|
|
98
|
+
version: 24.13.3
|
|
99
|
+
'@vitejs/plugin-react':
|
|
100
|
+
specifier: 'catalog:'
|
|
101
|
+
version: 4.7.0(vite@6.4.3(@types/node@24.13.3)(tsx@4.23.11))
|
|
83
102
|
eslint:
|
|
84
103
|
specifier: 'catalog:'
|
|
85
104
|
version: 9.39.5
|
|
86
105
|
eslint-plugin-react-hooks:
|
|
87
106
|
specifier: 'catalog:'
|
|
88
107
|
version: 5.2.0(eslint@9.39.5)
|
|
108
|
+
typescript:
|
|
109
|
+
specifier: 'catalog:'
|
|
110
|
+
version: 5.9.3
|
|
89
111
|
typescript-eslint:
|
|
90
112
|
specifier: 'catalog:'
|
|
91
113
|
version: 8.67.0(eslint@9.39.5)(typescript@5.9.3)
|
|
@@ -95,9 +117,12 @@ importers:
|
|
|
95
117
|
|
|
96
118
|
apps/client:
|
|
97
119
|
dependencies:
|
|
120
|
+
'@app/shared':
|
|
121
|
+
specifier: file:../../packages/shared
|
|
122
|
+
version: link:../../packages/shared
|
|
98
123
|
'@tbox.cn/app-sdk-client':
|
|
99
124
|
specifier: 'catalog:'
|
|
100
|
-
version: 0.
|
|
125
|
+
version: 1.0.0-alpha.1
|
|
101
126
|
react:
|
|
102
127
|
specifier: 'catalog:'
|
|
103
128
|
version: 18.3.1
|
|
@@ -105,9 +130,6 @@ importers:
|
|
|
105
130
|
specifier: 'catalog:'
|
|
106
131
|
version: 18.3.1(react@18.3.1)
|
|
107
132
|
devDependencies:
|
|
108
|
-
'@tbox.cn/app-sdk-server':
|
|
109
|
-
specifier: 'catalog:'
|
|
110
|
-
version: 0.26.4
|
|
111
133
|
'@types/node':
|
|
112
134
|
specifier: 'catalog:'
|
|
113
135
|
version: 24.13.3
|
|
@@ -135,13 +157,19 @@ importers:
|
|
|
135
157
|
|
|
136
158
|
apps/server:
|
|
137
159
|
dependencies:
|
|
160
|
+
'@app/shared':
|
|
161
|
+
specifier: file:../../packages/shared
|
|
162
|
+
version: link:../../packages/shared
|
|
138
163
|
'@tbox.cn/app-sdk-server':
|
|
139
164
|
specifier: 'catalog:'
|
|
140
|
-
version: 0.
|
|
165
|
+
version: 1.0.0-alpha.1
|
|
141
166
|
express:
|
|
142
167
|
specifier: 'catalog:'
|
|
143
168
|
version: 4.22.2
|
|
144
169
|
devDependencies:
|
|
170
|
+
'@tbox.cn/app-build':
|
|
171
|
+
specifier: 'catalog:'
|
|
172
|
+
version: 1.0.0-alpha.1(vite@6.4.3(@types/node@24.13.3)(tsx@4.23.11))
|
|
145
173
|
'@types/express':
|
|
146
174
|
specifier: 'catalog:'
|
|
147
175
|
version: 4.17.25
|
|
@@ -170,6 +198,8 @@ importers:
|
|
|
170
198
|
specifier: 'catalog:'
|
|
171
199
|
version: 4.1.10(@types/node@24.13.3)(happy-dom@20.11.2)(vite@6.4.3(@types/node@24.13.3)(tsx@4.23.11))
|
|
172
200
|
|
|
201
|
+
packages/shared: {}
|
|
202
|
+
|
|
173
203
|
packages:
|
|
174
204
|
|
|
175
205
|
'@ag-ui/core@0.0.47':
|
|
@@ -958,29 +988,34 @@ packages:
|
|
|
958
988
|
'@standard-schema/spec@1.1.0':
|
|
959
989
|
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
|
|
960
990
|
|
|
961
|
-
'@tbox.cn/app-
|
|
962
|
-
resolution: {integrity: sha512-
|
|
991
|
+
'@tbox.cn/app-build@1.0.0-alpha.1':
|
|
992
|
+
resolution: {integrity: sha512-1U5I5QF6uVYuyxHv79EfgOQqjS4vnWSCpvZBExcSYY2M9LOitaDjjaFguLyu1VOGmxsKYOZ2IxlSJMFioxEz0g==}
|
|
963
993
|
engines: {node: '>=20.0.0'}
|
|
994
|
+
peerDependencies:
|
|
995
|
+
vite: 6.4.3
|
|
996
|
+
peerDependenciesMeta:
|
|
997
|
+
vite:
|
|
998
|
+
optional: true
|
|
964
999
|
|
|
965
|
-
'@tbox.cn/app-contracts@0.
|
|
966
|
-
resolution: {integrity: sha512-
|
|
1000
|
+
'@tbox.cn/app-contracts@1.0.0-alpha.1':
|
|
1001
|
+
resolution: {integrity: sha512-9JBG3YEIb4/wKGBn49cZthLRe+ndEM0iZYwGGK5MthTUBiMNpBY9EzM6xMq+n7+pios4swAmswejNom5RoxAww==}
|
|
967
1002
|
engines: {node: '>=20.0.0'}
|
|
968
1003
|
|
|
969
|
-
'@tbox.cn/app-sdk-client@0.
|
|
970
|
-
resolution: {integrity: sha512-
|
|
1004
|
+
'@tbox.cn/app-sdk-client@1.0.0-alpha.1':
|
|
1005
|
+
resolution: {integrity: sha512-qBed4XTBHzzx98vNDggvhdMWzVNT2Wj5uMXaJ/86h12ZykXpdpNrCWjQtQ8kOp+6qAaLPqQp9wGa27hxxeQCEA==}
|
|
971
1006
|
engines: {node: '>=20.0.0'}
|
|
972
1007
|
|
|
973
|
-
'@tbox.cn/app-sdk-core@0.
|
|
974
|
-
resolution: {integrity: sha512-
|
|
1008
|
+
'@tbox.cn/app-sdk-core@1.0.0-alpha.1':
|
|
1009
|
+
resolution: {integrity: sha512-284KfkDzOmvbKnT9UXF6naY3vZ/hKGLFyDOFOTUCvjAvFtjMgq5dQbLuUtDGxWn16gPs3i3QAUBVGLv7WoVfSg==}
|
|
975
1010
|
engines: {node: '>=20.0.0'}
|
|
976
1011
|
|
|
977
|
-
'@tbox.cn/app-sdk-server@0.
|
|
978
|
-
resolution: {integrity: sha512-
|
|
1012
|
+
'@tbox.cn/app-sdk-server@1.0.0-alpha.1':
|
|
1013
|
+
resolution: {integrity: sha512-Kf1eM7nWljd2xCDB9kpBqBfw7j2ZCpsaYG6qCtlExxCK3mFewSVISheBgYrkNwR8i4v9fdOsxxkW9Ib014SvIA==}
|
|
979
1014
|
engines: {node: '>=20.0.0'}
|
|
980
1015
|
hasBin: true
|
|
981
1016
|
|
|
982
|
-
'@tbox.cn/app-toolkit@0.
|
|
983
|
-
resolution: {integrity: sha512-
|
|
1017
|
+
'@tbox.cn/app-toolkit@1.0.0-alpha.1':
|
|
1018
|
+
resolution: {integrity: sha512-WrA/U4BepEQwzdzS2TnYsxn9iG3qHLAsAKOUPMHoMHk7l7YqtBNXxGOw+VWKUhZAESJyLBz9svFXm2xCE+KqNw==}
|
|
984
1019
|
engines: {node: '>=20.0.0'}
|
|
985
1020
|
|
|
986
1021
|
'@types/babel__core@7.20.5':
|
|
@@ -2820,42 +2855,42 @@ snapshots:
|
|
|
2820
2855
|
|
|
2821
2856
|
'@standard-schema/spec@1.1.0': {}
|
|
2822
2857
|
|
|
2823
|
-
'@tbox.cn/app-
|
|
2858
|
+
'@tbox.cn/app-build@1.0.0-alpha.1(vite@6.4.3(@types/node@24.13.3)(tsx@4.23.11))':
|
|
2824
2859
|
dependencies:
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2860
|
+
typescript: 5.9.3
|
|
2861
|
+
optionalDependencies:
|
|
2862
|
+
vite: 6.4.3(@types/node@24.13.3)(tsx@4.23.11)
|
|
2828
2863
|
|
|
2829
|
-
'@tbox.cn/app-contracts@0.
|
|
2864
|
+
'@tbox.cn/app-contracts@1.0.0-alpha.1':
|
|
2830
2865
|
dependencies:
|
|
2831
2866
|
'@ag-ui/core': 0.0.47
|
|
2832
2867
|
react: 18.3.1
|
|
2833
2868
|
zod: 3.25.76
|
|
2834
2869
|
|
|
2835
|
-
'@tbox.cn/app-sdk-client@0.
|
|
2870
|
+
'@tbox.cn/app-sdk-client@1.0.0-alpha.1':
|
|
2836
2871
|
dependencies:
|
|
2837
|
-
'@tbox.cn/app-contracts': 0.
|
|
2838
|
-
'@tbox.cn/app-sdk-core': 0.
|
|
2872
|
+
'@tbox.cn/app-contracts': 1.0.0-alpha.1
|
|
2873
|
+
'@tbox.cn/app-sdk-core': 1.0.0-alpha.1
|
|
2839
2874
|
react: 18.3.1
|
|
2840
2875
|
react-dom: 18.3.1(react@18.3.1)
|
|
2841
2876
|
|
|
2842
|
-
'@tbox.cn/app-sdk-core@0.
|
|
2877
|
+
'@tbox.cn/app-sdk-core@1.0.0-alpha.1':
|
|
2843
2878
|
dependencies:
|
|
2844
|
-
'@tbox.cn/app-contracts': 0.
|
|
2879
|
+
'@tbox.cn/app-contracts': 1.0.0-alpha.1
|
|
2845
2880
|
|
|
2846
|
-
'@tbox.cn/app-sdk-server@0.
|
|
2881
|
+
'@tbox.cn/app-sdk-server@1.0.0-alpha.1':
|
|
2847
2882
|
dependencies:
|
|
2848
2883
|
'@ag-ui/core': 0.0.47
|
|
2849
|
-
'@tbox.cn/app-contracts': 0.
|
|
2850
|
-
'@tbox.cn/app-sdk-core': 0.
|
|
2851
|
-
'@tbox.cn/app-toolkit': 0.
|
|
2884
|
+
'@tbox.cn/app-contracts': 1.0.0-alpha.1
|
|
2885
|
+
'@tbox.cn/app-sdk-core': 1.0.0-alpha.1
|
|
2886
|
+
'@tbox.cn/app-toolkit': 1.0.0-alpha.1
|
|
2852
2887
|
express: 4.22.2
|
|
2853
2888
|
jose: 6.2.8
|
|
2854
2889
|
zod: 3.25.76
|
|
2855
2890
|
transitivePeerDependencies:
|
|
2856
2891
|
- supports-color
|
|
2857
2892
|
|
|
2858
|
-
'@tbox.cn/app-toolkit@0.
|
|
2893
|
+
'@tbox.cn/app-toolkit@1.0.0-alpha.1':
|
|
2859
2894
|
dependencies:
|
|
2860
2895
|
ajv: 8.20.0
|
|
2861
2896
|
zod: 3.25.76
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# 应用 workspace 模板:tbox-app create 用它生成应用的 pnpm-workspace.yaml。
|
|
2
2
|
# 本文件不触发 workspace root(非 pnpm-workspace.yaml 文件名)。
|
|
3
|
-
# 同步规则(guard-workspace h5 组恒等式校验):
|
|
4
|
-
# - catalog 键集 = 本模板成员 catalog: 引用并集 ∪ 平台三键(平台完备性:codegen 展开恒改写为 catalog:);
|
|
5
|
-
# 值与根 pnpm-workspace.yaml 同键全等(sync-catalog 维护)。
|
|
6
|
-
# - 非 catalog 顶层键与根镜像(packages/overrides 除外)。
|
|
7
3
|
packages:
|
|
8
|
-
- apps
|
|
4
|
+
- apps/client
|
|
5
|
+
- apps/server
|
|
9
6
|
- packages/*
|
|
7
|
+
- modules/*
|
|
10
8
|
|
|
11
9
|
onlyBuiltDependencies:
|
|
12
10
|
- esbuild
|
|
@@ -17,8 +15,6 @@ allowBuilds:
|
|
|
17
15
|
|
|
18
16
|
resolvePeersFromWorkspaceRoot: true
|
|
19
17
|
|
|
20
|
-
# 递归脚本并发上限(pnpm -r 默认 4):全速并行时多包 vitest worker 独立 transform
|
|
21
|
-
# 同一源码树,CI 峰值内存曾致 V8 fatal(SIGABRT)。本地提速可 CLI 旗标覆盖。
|
|
22
18
|
workspaceConcurrency: 2
|
|
23
19
|
|
|
24
20
|
catalog:
|
|
@@ -33,13 +29,14 @@ catalog:
|
|
|
33
29
|
"@types/node": 24.13.3
|
|
34
30
|
express: 4.22.2
|
|
35
31
|
"@types/express": 4.17.25
|
|
36
|
-
"@tbox.cn/app-sdk-core": 0.
|
|
37
|
-
"@tbox.cn/app-sdk-client": 0.
|
|
38
|
-
"@tbox.cn/app-sdk-server": 0.
|
|
39
|
-
"@tbox.cn/app-
|
|
40
|
-
"@tbox.cn/app-agent-sdk-
|
|
41
|
-
"@tbox.cn/app-
|
|
42
|
-
"@tbox.cn/app-contracts
|
|
32
|
+
"@tbox.cn/app-sdk-core": 1.0.0-alpha.1
|
|
33
|
+
"@tbox.cn/app-sdk-client": 1.0.0-alpha.1
|
|
34
|
+
"@tbox.cn/app-sdk-server": 1.0.0-alpha.1
|
|
35
|
+
"@tbox.cn/app-build": 1.0.0-alpha.1
|
|
36
|
+
"@tbox.cn/app-agent-sdk-server": 1.0.0-alpha.1
|
|
37
|
+
"@tbox.cn/app-agent-sdk-client": 1.0.0-alpha.1
|
|
38
|
+
"@tbox.cn/app-contracts": 1.0.0-alpha.1
|
|
39
|
+
"@tbox.cn/app-contracts-mall": 1.0.0-alpha.1
|
|
43
40
|
eslint: 9.39.5
|
|
44
41
|
typescript-eslint: 8.67.0
|
|
45
42
|
eslint-plugin-react-hooks: 5.2.0
|
|
@@ -49,9 +46,5 @@ catalog:
|
|
|
49
46
|
supertest: 7.2.2
|
|
50
47
|
"@types/supertest": 7.2.1
|
|
51
48
|
|
|
52
|
-
# debug 钉版止血(与根 pnpm-workspace.yaml 同步维护;见 2026-09-16-ci-internal-registry-pollution.md):
|
|
53
|
-
# 模板锁种子投影会清 overrides 段致 debug 重解析为 4.4.3(R5 子集校验失败),故模板必须同携此键;
|
|
54
|
-
# 段恒居文件末尾——create --local-deps 的 overrides 条目按"并入末尾段"注入(cli/src/commands/create.ts)。
|
|
55
|
-
# 平台修复内网 registry 数据后随根一并移除。
|
|
56
49
|
overrides:
|
|
57
50
|
"debug@4.4.3": "4.4.1"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { composeAgents } from '@tbox.cn/app-build';
|
|
5
|
+
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
const modulesDir = path.join(root, 'modules');
|
|
8
|
+
const hasModules = existsSync(modulesDir) && readdirSync(modulesDir, { withFileTypes: true }).some((entry) => entry.isDirectory());
|
|
9
|
+
const composed = await composeAgents({ appKind: 'web', hasModules });
|
|
10
|
+
const targets = [
|
|
11
|
+
['AGENTS.md', composed.root],
|
|
12
|
+
['apps/AGENTS.md', composed.app],
|
|
13
|
+
];
|
|
14
|
+
if (composed.modules) targets.push(['modules/AGENTS.md', composed.modules]);
|
|
15
|
+
let failed = false;
|
|
16
|
+
for (const [file, expected] of targets) {
|
|
17
|
+
const actual = await readFile(path.join(root, file), 'utf8');
|
|
18
|
+
if (!actual.includes(expected)) {
|
|
19
|
+
console.error(`AGENTS drift: ${file}`);
|
|
20
|
+
failed = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (failed) process.exitCode = 1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { syncAgents } from '@tbox.cn/app-build';
|
|
4
|
+
|
|
5
|
+
const root = process.cwd();
|
|
6
|
+
const modulesDir = path.join(root, 'modules');
|
|
7
|
+
const hasModules = existsSync(modulesDir) && readdirSync(modulesDir, { withFileTypes: true }).some((entry) => entry.isDirectory());
|
|
8
|
+
const written = await syncAgents({ root, appKind: 'web', hasModules, allowAppend: true });
|
|
9
|
+
for (const file of written) console.log(`✅ ${path.relative(root, file)}`);
|
package/scripts/build.sh
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
set -e
|
|
3
|
-
|
|
4
|
-
# Usage: build.sh [--skip-server]
|
|
5
|
-
|
|
6
3
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
4
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
8
5
|
cd "$PROJECT_DIR"
|
|
9
|
-
echo "Project directory: $PROJECT_DIR"
|
|
10
|
-
|
|
11
6
|
export NODE_ENV=production
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for arg in "$@"; do
|
|
15
|
-
[ "$arg" = "--skip-server" ] && SKIP_SERVER=true
|
|
16
|
-
done
|
|
17
|
-
echo "Skip server: $SKIP_SERVER"
|
|
18
|
-
|
|
19
|
-
# 零依赖守卫 install 前 fail-fast(幂等毫秒级)
|
|
20
|
-
pnpm check:workspace
|
|
21
|
-
|
|
22
|
-
echo "Installing dependencies..."
|
|
23
|
-
CI=true pnpm install
|
|
24
|
-
|
|
25
|
-
# 构建序列单源 = package.json build / build:client(守卫经 check 组合注入);本脚本只管环境与 install
|
|
26
|
-
if [ "$SKIP_SERVER" = false ]; then
|
|
27
|
-
pnpm build
|
|
28
|
-
else
|
|
29
|
-
pnpm build:client
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
echo "All builds completed successfully!"
|
|
7
|
+
pnpm install
|
|
8
|
+
pnpm build
|
package/scripts/dev.sh
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
set -e
|
|
3
|
-
|
|
4
3
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
4
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
6
5
|
cd "$PROJECT_DIR"
|
|
7
|
-
echo "Project directory: $PROJECT_DIR"
|
|
8
|
-
|
|
9
|
-
echo "Installing dependencies..."
|
|
10
6
|
pnpm install
|
|
11
|
-
|
|
12
|
-
echo "Starting development server..."
|
|
13
|
-
echo " - http://localhost:8000 (API + 页面 + HMR)"
|
|
14
|
-
# 相对 filter:仓内直跑时名称 filter 会三模板同名命中(@app/server ×3)
|
|
15
|
-
pnpm --filter ./apps/server dev
|
|
7
|
+
pnpm dev
|
package/scripts/start.sh
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
set -e
|
|
3
|
-
|
|
4
3
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
4
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
6
5
|
cd "$PROJECT_DIR"
|
|
7
|
-
|
|
8
|
-
echo "Starting production server..."
|
|
9
|
-
echo "NODE_ENV: $NODE_ENV"
|
|
10
|
-
|
|
11
|
-
# 相对 filter:仓内直跑时名称 filter 会三模板同名命中
|
|
12
|
-
NODE_ENV=production pnpm --filter ./apps/server start
|
|
6
|
+
NODE_ENV=production pnpm start
|
package/apps/client/src/main.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { StrictMode } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { ErrorBoundary } from '@tbox.cn/app-sdk-client';
|
|
4
|
-
import BusinessApp from './business/App';
|
|
5
|
-
import { bootstrap } from './platform/bootstrap';
|
|
6
|
-
|
|
7
|
-
// 启动层(运行时注入/错误兜底/基础样式)——与生成 entry(mount-page)共享
|
|
8
|
-
bootstrap();
|
|
9
|
-
|
|
10
|
-
const el = document.getElementById('root');
|
|
11
|
-
|
|
12
|
-
if (el) {
|
|
13
|
-
createRoot(el).render(
|
|
14
|
-
<StrictMode>
|
|
15
|
-
<ErrorBoundary
|
|
16
|
-
fallback={
|
|
17
|
-
<main>
|
|
18
|
-
<h1>页面暂时不可用</h1>
|
|
19
|
-
<button type="button" onClick={() => window.location.reload()}>
|
|
20
|
-
重新加载
|
|
21
|
-
</button>
|
|
22
|
-
</main>
|
|
23
|
-
}
|
|
24
|
-
>
|
|
25
|
-
<BusinessApp />
|
|
26
|
-
</ErrorBoundary>
|
|
27
|
-
</StrictMode>,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { readdir, readFile } from 'node:fs/promises';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import process from 'node:process';
|
|
7
|
-
|
|
8
|
-
const projectDir = path.resolve(process.argv[2] ?? path.join(import.meta.dirname, '..'));
|
|
9
|
-
const allowedViteConfigDirs = new Set(['apps/client']);
|
|
10
|
-
const ignoredDirs = new Set([
|
|
11
|
-
'.agents',
|
|
12
|
-
'.claude',
|
|
13
|
-
'.codex',
|
|
14
|
-
'.cursor',
|
|
15
|
-
'.git',
|
|
16
|
-
'.node',
|
|
17
|
-
'.pnpm-store',
|
|
18
|
-
'.tmp',
|
|
19
|
-
'.vite',
|
|
20
|
-
'dist',
|
|
21
|
-
'dist-ssr',
|
|
22
|
-
'node_modules',
|
|
23
|
-
]);
|
|
24
|
-
const nestedLockfiles = new Set([
|
|
25
|
-
'bun.lock',
|
|
26
|
-
'bun.lockb',
|
|
27
|
-
'package-lock.json',
|
|
28
|
-
'pnpm-lock.yaml',
|
|
29
|
-
'pnpm-lock.template.yaml',
|
|
30
|
-
'yarn.lock',
|
|
31
|
-
]);
|
|
32
|
-
const viteConfigPattern = /^vite\.config\.(?:js|mjs|cjs|ts|mts|cts)$/;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* CLI 裸简写防线:应用文档里不得出现 `tbox-app <cmd>`(agent 照抄后 PATH 无 bin → 命令失败)。
|
|
36
|
-
* 唯一合法形态 = `npx --yes @tbox.cn/app-cli <cmd>`;`tbox-app-dev`(私有 CLI)不匹配。
|
|
37
|
-
*/
|
|
38
|
-
const bareCliPattern = /\btbox-app\s+(?:module|provider|theme|starter|new|create|schema|skills|doctor|miniapp-container)\b/g;
|
|
39
|
-
const cliDocFiles = ['AGENTS.md', 'README.md', 'ENV.md'];
|
|
40
|
-
|
|
41
|
-
async function checkCliShorthand(findings) {
|
|
42
|
-
for (const rel of cliDocFiles) {
|
|
43
|
-
const file = path.join(projectDir, rel);
|
|
44
|
-
if (!existsSync(file)) continue;
|
|
45
|
-
const text = await readFile(file, 'utf8');
|
|
46
|
-
for (const match of text.matchAll(bareCliPattern)) {
|
|
47
|
-
findings.bareCliShorthands.push(`${rel}: ${match[0]}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function relativeDir(filePath) {
|
|
53
|
-
const relative = path.relative(projectDir, path.dirname(filePath));
|
|
54
|
-
return relative === '' ? '.' : relative.split(path.sep).join('/');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function walk(dir, findings) {
|
|
58
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
59
|
-
|
|
60
|
-
for (const entry of entries) {
|
|
61
|
-
if (entry.isSymbolicLink()) continue;
|
|
62
|
-
|
|
63
|
-
const fullPath = path.join(dir, entry.name);
|
|
64
|
-
if (entry.isDirectory()) {
|
|
65
|
-
if (!ignoredDirs.has(entry.name)) await walk(fullPath, findings);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (!entry.isFile()) continue;
|
|
69
|
-
|
|
70
|
-
const dirName = relativeDir(fullPath);
|
|
71
|
-
const relativePath = path.relative(projectDir, fullPath).split(path.sep).join('/');
|
|
72
|
-
|
|
73
|
-
if (nestedLockfiles.has(entry.name) && dirName !== '.') {
|
|
74
|
-
findings.nestedLockfiles.push(relativePath);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (viteConfigPattern.test(entry.name) && !allowedViteConfigDirs.has(dirName)) {
|
|
78
|
-
findings.detachedViteConfigs.push(relativePath);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function printFailure(findings) {
|
|
84
|
-
console.error('');
|
|
85
|
-
console.error('[check-workspace] 工程边界校验失败。');
|
|
86
|
-
|
|
87
|
-
if (findings.nestedLockfiles.length > 0) {
|
|
88
|
-
console.error('\n检测到嵌套 lockfile(本项目只允许根 pnpm-lock.yaml):');
|
|
89
|
-
for (const file of findings.nestedLockfiles) console.error(` - ${file}`);
|
|
90
|
-
}
|
|
91
|
-
if (findings.detachedViteConfigs.length > 0) {
|
|
92
|
-
console.error('\n检测到 apps/client/ 之外的 Vite 项目配置:');
|
|
93
|
-
for (const file of findings.detachedViteConfigs) console.error(` - ${file}`);
|
|
94
|
-
}
|
|
95
|
-
if (findings.bareCliShorthands.length > 0) {
|
|
96
|
-
console.error('\n检测到 CLI 裸简写(须写全 npx --yes @tbox.cn/app-cli <cmd>):');
|
|
97
|
-
for (const item of findings.bareCliShorthands) console.error(` - ${item}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
console.error('');
|
|
101
|
-
process.exitCode = 1;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** 向上查找最近的 pnpm-workspace.yaml(模板目录并入根 workspace 后本目录可无 workspace 文件,属父 workspace 成员) */
|
|
105
|
-
function findWorkspaceFile(dir) {
|
|
106
|
-
let cur = path.resolve(dir);
|
|
107
|
-
for (;;) {
|
|
108
|
-
const f = path.join(cur, 'pnpm-workspace.yaml');
|
|
109
|
-
if (existsSync(f)) return f;
|
|
110
|
-
const parent = path.dirname(cur);
|
|
111
|
-
if (parent === cur) return null;
|
|
112
|
-
cur = parent;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function main() {
|
|
117
|
-
const workspaceFile = findWorkspaceFile(projectDir);
|
|
118
|
-
if (!workspaceFile) {
|
|
119
|
-
console.error('[check-workspace] 缺少 pnpm-workspace.yaml(本目录及父级均未找到)。');
|
|
120
|
-
process.exitCode = 1;
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const findings = {
|
|
125
|
-
nestedLockfiles: [],
|
|
126
|
-
detachedViteConfigs: [],
|
|
127
|
-
bareCliShorthands: [],
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
await walk(projectDir, findings);
|
|
131
|
-
await checkCliShorthand(findings);
|
|
132
|
-
|
|
133
|
-
if (Object.values(findings).some((items) => items.length > 0)) {
|
|
134
|
-
printFailure(findings);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
console.log('[check-workspace] 工程边界校验通过(apps/* workspace)');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
main().catch((error) => {
|
|
142
|
-
console.error('[check-workspace] 校验执行失败:', error);
|
|
143
|
-
process.exitCode = 1;
|
|
144
|
-
});
|
package/scripts/prepare.sh
DELETED