@coze-arch/cli 0.0.1-alpha.9f719c → 0.0.1-alpha.a37c60
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/.coze +2 -2
- package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +4 -1
- package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
- package/lib/__templates__/expo/client/components/ThemedView.tsx +38 -0
- package/lib/__templates__/expo/client/constants/theme.ts +776 -54
- package/lib/__templates__/expo/metro.config.js +75 -5
- package/lib/__templates__/expo/package.json +10 -5
- package/lib/__templates__/expo/pnpm-lock.yaml +71 -516
- package/lib/__templates__/nextjs/next.config.ts +1 -0
- package/lib/__templates__/nextjs/src/app/globals.css +99 -87
- package/lib/__templates__/templates.json +27 -0
- package/lib/cli.js +144 -31
- package/package.json +8 -3
- /package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +0 -0
|
@@ -28,24 +28,94 @@ config.resolver.blockList = [
|
|
|
28
28
|
/.*\.git\/.*/, // 排除 Git 目录
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
+
const BACKEND_TARGET = 'http://localhost:9091';
|
|
32
|
+
|
|
31
33
|
const apiProxy = createProxyMiddleware({
|
|
32
|
-
target:
|
|
34
|
+
target: BACKEND_TARGET,
|
|
35
|
+
changeOrigin: true,
|
|
33
36
|
logLevel: 'debug',
|
|
37
|
+
proxyTimeout: 86400000,
|
|
38
|
+
onProxyReq: (proxyReq, req) => {
|
|
39
|
+
const accept = req.headers.accept || '';
|
|
40
|
+
if (accept.includes('text/event-stream')) {
|
|
41
|
+
proxyReq.setHeader('accept-encoding', 'identity');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
45
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
46
|
+
if (contentType.includes('text/event-stream') || contentType.includes('application/stream')) {
|
|
47
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
48
|
+
res.setHeader('Connection', 'keep-alive');
|
|
49
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
50
|
+
if (typeof res.flushHeaders === 'function') {
|
|
51
|
+
try { res.flushHeaders(); } catch {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
34
55
|
});
|
|
35
56
|
|
|
57
|
+
const streamProxy = createProxyMiddleware({
|
|
58
|
+
target: BACKEND_TARGET,
|
|
59
|
+
changeOrigin: true,
|
|
60
|
+
logLevel: 'debug',
|
|
61
|
+
ws: true,
|
|
62
|
+
proxyTimeout: 86400000,
|
|
63
|
+
onProxyReq: (proxyReq, req) => {
|
|
64
|
+
const upgrade = req.headers.upgrade;
|
|
65
|
+
const accept = req.headers.accept || '';
|
|
66
|
+
if (upgrade && upgrade.toLowerCase() === 'websocket') {
|
|
67
|
+
proxyReq.setHeader('Connection', 'upgrade');
|
|
68
|
+
proxyReq.setHeader('Upgrade', req.headers.upgrade);
|
|
69
|
+
} else if (accept.includes('text/event-stream')) {
|
|
70
|
+
proxyReq.setHeader('accept-encoding', 'identity');
|
|
71
|
+
proxyReq.setHeader('Connection', 'keep-alive');
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
75
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
76
|
+
if (contentType.includes('text/event-stream') || contentType.includes('application/stream')) {
|
|
77
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
78
|
+
res.setHeader('Connection', 'keep-alive');
|
|
79
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
80
|
+
if (typeof res.flushHeaders === 'function') {
|
|
81
|
+
try { res.flushHeaders(); } catch {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const shouldProxyToBackend = (url) => {
|
|
88
|
+
if (!url) return false;
|
|
89
|
+
if (/^\/api\/v\d+\//.test(url)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const isWebSocketRequest = (req) =>
|
|
96
|
+
!!(req.headers.upgrade && req.headers.upgrade.toLowerCase() === 'websocket');
|
|
97
|
+
const isSSERequest = (req) => {
|
|
98
|
+
const accept = req.headers.accept || '';
|
|
99
|
+
return accept.includes('text/event-stream');
|
|
100
|
+
};
|
|
101
|
+
|
|
36
102
|
config.server = {
|
|
37
|
-
|
|
38
|
-
|
|
103
|
+
...config.server,
|
|
104
|
+
enhanceMiddleware: (metroMiddleware, metroServer) => {
|
|
39
105
|
return connect()
|
|
40
106
|
.use((req, res, next) => {
|
|
41
|
-
if (req.url
|
|
107
|
+
if (shouldProxyToBackend(req.url)) {
|
|
42
108
|
console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
|
|
109
|
+
|
|
110
|
+
if (isWebSocketRequest(req) || isSSERequest(req)) {
|
|
111
|
+
return streamProxy(req, res, next);
|
|
112
|
+
}
|
|
43
113
|
return apiProxy(req, res, next);
|
|
44
114
|
}
|
|
45
115
|
next();
|
|
46
116
|
})
|
|
47
117
|
.use(metroMiddleware);
|
|
48
118
|
},
|
|
49
|
-
}
|
|
119
|
+
};
|
|
50
120
|
|
|
51
121
|
module.exports = config;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "bash .cozeproj/scripts/
|
|
7
|
+
"build": "bash .cozeproj/scripts/dev_build.sh",
|
|
8
8
|
"check-deps": "npx depcheck",
|
|
9
|
-
"dev": "bash .cozeproj/scripts/
|
|
9
|
+
"dev": "bash .cozeproj/scripts/dev_run.sh",
|
|
10
10
|
"preinstall": "npx only-allow pnpm",
|
|
11
11
|
"postinstall": "node ./client/scripts/install-missing-deps.js",
|
|
12
12
|
"install-missing": "node ./client/scripts/install-missing-deps.js",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"@react-navigation/native": "^7.0.14",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"ajv-formats": "^3.0.1",
|
|
37
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
38
|
+
"babel-preset-expo": "^54.0.9",
|
|
37
39
|
"connect": "^3.7.0",
|
|
38
40
|
"coze-coding-dev-sdk": "^0.5.5",
|
|
39
41
|
"dayjs": "^1.11.19",
|
|
@@ -89,11 +91,9 @@
|
|
|
89
91
|
"@types/pg": "^8.16.0",
|
|
90
92
|
"@types/react": "~19.1.0",
|
|
91
93
|
"@types/react-test-renderer": "19.1.0",
|
|
92
|
-
"babel-plugin-module-resolver": "^5.0.2",
|
|
93
|
-
"babel-preset-expo": "^54.0.9",
|
|
94
94
|
"chalk": "^4.1.2",
|
|
95
95
|
"depcheck": "^1.4.7",
|
|
96
|
-
"esbuild": "
|
|
96
|
+
"esbuild": "0.27.2",
|
|
97
97
|
"eslint": "^9.39.2",
|
|
98
98
|
"eslint-formatter-compact": "^9.0.1",
|
|
99
99
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
@@ -112,5 +112,10 @@
|
|
|
112
112
|
"packageManager": "pnpm@9.0.0",
|
|
113
113
|
"engines": {
|
|
114
114
|
"pnpm": ">=9.0.0"
|
|
115
|
+
},
|
|
116
|
+
"pnpm": {
|
|
117
|
+
"overrides": {
|
|
118
|
+
"esbuild": "0.27.2"
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
121
|
}
|