@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.
Files changed (45) hide show
  1. package/.gitignore +4 -8
  2. package/.npmignore +7 -0
  3. package/.tbox/app.json +3 -2
  4. package/AGENTS.md +17 -63
  5. package/README.md +21 -31
  6. package/apps/AGENTS.md +17 -0
  7. package/apps/client/index.html +0 -4
  8. package/apps/client/package.json +5 -7
  9. package/apps/client/src/pages/page.tsx +33 -0
  10. package/apps/client/src/platform/bootstrap.ts +0 -7
  11. package/apps/client/src/platform/mount-page.tsx +4 -12
  12. package/apps/client/src/styles/base.css +14 -34
  13. package/apps/client/tsconfig.json +3 -6
  14. package/apps/client/vite.config.ts +30 -39
  15. package/apps/client/vitest.config.ts +10 -0
  16. package/apps/server/package.json +6 -4
  17. package/apps/server/src/app.ts +2 -35
  18. package/apps/server/src/dev.ts +37 -123
  19. package/apps/server/src/functions/greet.server.ts +5 -0
  20. package/apps/server/src/index.ts +17 -39
  21. package/apps/server/tests/app.test.ts +30 -5
  22. package/apps/server/tsconfig.json +5 -3
  23. package/apps/server/tsup.config.ts +4 -7
  24. package/apps/server/vitest.config.ts +0 -1
  25. package/eslint.config.mjs +1 -1
  26. package/modules/.gitkeep +0 -0
  27. package/package.json +30 -16
  28. package/packages/shared/AGENTS.md +11 -0
  29. package/packages/shared/package.json +13 -0
  30. package/packages/shared/src/index.ts +7 -0
  31. package/packages/shared/tsconfig.json +7 -0
  32. package/pnpm-lock.template.yaml +72 -37
  33. package/pnpm-workspace.template.yaml +11 -18
  34. package/scripts/agents-check.mjs +23 -0
  35. package/scripts/agents-sync.mjs +9 -0
  36. package/scripts/build.sh +2 -26
  37. package/scripts/check.mjs +7 -0
  38. package/scripts/dev.sh +1 -9
  39. package/scripts/generate.mjs +3 -0
  40. package/scripts/start.sh +1 -7
  41. package/apps/client/src/business/App.tsx +0 -3
  42. package/apps/client/src/business/routes.json +0 -3
  43. package/apps/client/src/main.tsx +0 -29
  44. package/scripts/check-workspace.mjs +0 -144
  45. package/scripts/prepare.sh +0 -11
@@ -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.21.4
11
- version: 0.21.4
13
+ specifier: 1.0.0-alpha.1
14
+ version: 1.0.0-alpha.1
12
15
  '@tbox.cn/app-sdk-server':
13
- specifier: 0.26.4
14
- version: 0.26.4
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.26.4
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.21.4
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.26.4
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-contracts@0.13.2':
962
- resolution: {integrity: sha512-0lY9g29ice7xYbmV5XDnEiMmM70jvSzeK2cciUZVpzHgGykWqZiPRlqXIGkIRY7uObDQ1cICHC4mS67HuNQ8Jg==}
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.13.3':
966
- resolution: {integrity: sha512-P16LFd+ZzIASrujs6fyaOEwRnsLg7Lh5k1qOVDNblmohrvUbVIOK5ntn+7mupJxnjK7SY43RUT4mtWtfM85/rQ==}
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.21.4':
970
- resolution: {integrity: sha512-Vbk0593RGWGIVgGiR1xNOF8x62z+2/Ix6NRTHURhdrLLB1pOIFlixm4AHn9d/noyaItiXTND55OeOTAaTEJQcQ==}
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.20.5':
974
- resolution: {integrity: sha512-HLLRg1y2jB32uJPL3/a387eABdNZUxrmkGoJwIv44XV9B94DXmTgb9vxYzbyBa0FazxXG0WudyzFnmH5eeqqrw==}
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.26.4':
978
- resolution: {integrity: sha512-U5dxB6y8mkDB8dF01uU82+2Qbzi8MU+3ChxiFB++Rpef5YeJ7v9DcqklXS+uNwI1cSK4qFSd67jPR/qfosTbdQ==}
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.8.5':
983
- resolution: {integrity: sha512-WyFbaEr8N064PFeWknfZfg5MMinEYI4xExbG2KnE4QPbvcS01NazA1vImPTidrOSXZ411PRFr/JNArS/38nv/w==}
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-contracts@0.13.2':
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
- '@ag-ui/core': 0.0.47
2826
- react: 18.3.1
2827
- zod: 3.25.76
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.13.3':
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.21.4':
2870
+ '@tbox.cn/app-sdk-client@1.0.0-alpha.1':
2836
2871
  dependencies:
2837
- '@tbox.cn/app-contracts': 0.13.3
2838
- '@tbox.cn/app-sdk-core': 0.20.5
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.20.5':
2877
+ '@tbox.cn/app-sdk-core@1.0.0-alpha.1':
2843
2878
  dependencies:
2844
- '@tbox.cn/app-contracts': 0.13.2
2879
+ '@tbox.cn/app-contracts': 1.0.0-alpha.1
2845
2880
 
2846
- '@tbox.cn/app-sdk-server@0.26.4':
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.13.3
2850
- '@tbox.cn/app-sdk-core': 0.20.5
2851
- '@tbox.cn/app-toolkit': 0.8.5
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.8.5':
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.20.5
37
- "@tbox.cn/app-sdk-client": 0.21.4
38
- "@tbox.cn/app-sdk-server": 0.26.4
39
- "@tbox.cn/app-agent-sdk-server": 0.3.4
40
- "@tbox.cn/app-agent-sdk-client": 0.2.2
41
- "@tbox.cn/app-contracts": 0.13.3
42
- "@tbox.cn/app-contracts-mall": 0.14.0
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
- SKIP_SERVER=false
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
@@ -0,0 +1,7 @@
1
+ import { checkApp } from '@tbox.cn/app-build';
2
+
3
+ const result = await checkApp({ root: process.cwd() });
4
+ for (const issue of result.issues) {
5
+ console.error(`${issue.file ?? ''} ${issue.code}: ${issue.message}`);
6
+ }
7
+ if (!result.ok) process.exitCode = 1;
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
@@ -0,0 +1,3 @@
1
+ import { generateApp } from '@tbox.cn/app-build';
2
+
3
+ await generateApp({ root: process.cwd() });
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
@@ -1,3 +0,0 @@
1
- export default function BusinessApp() {
2
- return <main>应用从这里开始</main>;
3
- }
@@ -1,3 +0,0 @@
1
- [
2
- { "id": "index", "path": "/" }
3
- ]
@@ -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
- });
@@ -1,11 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
6
- cd "$PROJECT_DIR"
7
-
8
- echo "Installing dependencies..."
9
- CI=true pnpm install
10
-
11
- echo "Prepare complete!"