@coze-arch/cli 0.0.1-alpha.351659 → 0.0.1-alpha.5b771d
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 +7 -2
- package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +0 -7
- package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +12 -16
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +35 -0
- package/lib/__templates__/expo/babel.config.js +10 -0
- 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 +779 -47
- package/lib/__templates__/expo/client/hooks/useTheme.ts +1 -1
- package/lib/__templates__/expo/metro.config.js +76 -8
- package/lib/__templates__/expo/package.json +13 -4
- package/lib/__templates__/expo/pnpm-lock.yaml +71 -516
- package/lib/__templates__/nextjs/scripts/dev.sh +7 -26
- package/lib/__templates__/nextjs/src/app/globals.css +99 -87
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
- package/lib/__templates__/vite/scripts/dev.sh +7 -26
- package/lib/__templates__/vite/vite.config.ts +3 -3
- package/lib/cli.js +1 -1
- package/package.json +5 -2
|
@@ -4,7 +4,7 @@ import { useColorScheme } from "@/hooks/useColorScheme";
|
|
|
4
4
|
export function useTheme() {
|
|
5
5
|
const colorScheme = useColorScheme();
|
|
6
6
|
const isDark = colorScheme === "dark";
|
|
7
|
-
const theme = Colors[colorScheme ?? "light"];
|
|
7
|
+
const theme = Colors[(colorScheme as "light" | "dark") ?? "light"];
|
|
8
8
|
|
|
9
9
|
return {
|
|
10
10
|
theme,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
|
-
|
|
2
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
3
3
|
const connect = require('connect');
|
|
4
4
|
|
|
5
5
|
const config = getDefaultConfig(__dirname);
|
|
@@ -28,26 +28,94 @@ config.resolver.blockList = [
|
|
|
28
28
|
/.*\.git\/.*/, // 排除 Git 目录
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
const BACKEND_TARGET = 'http://localhost:9091';
|
|
32
|
+
|
|
32
33
|
const apiProxy = createProxyMiddleware({
|
|
33
|
-
target:
|
|
34
|
+
target: BACKEND_TARGET,
|
|
35
|
+
changeOrigin: true,
|
|
34
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
|
+
},
|
|
35
55
|
});
|
|
36
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
|
+
|
|
37
102
|
config.server = {
|
|
38
|
-
|
|
39
|
-
|
|
103
|
+
...config.server,
|
|
104
|
+
enhanceMiddleware: (metroMiddleware, metroServer) => {
|
|
40
105
|
return connect()
|
|
41
106
|
.use((req, res, next) => {
|
|
42
|
-
if (req.url
|
|
107
|
+
if (shouldProxyToBackend(req.url)) {
|
|
43
108
|
console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
|
|
109
|
+
|
|
110
|
+
if (isWebSocketRequest(req) || isSSERequest(req)) {
|
|
111
|
+
return streamProxy(req, res, next);
|
|
112
|
+
}
|
|
44
113
|
return apiProxy(req, res, next);
|
|
45
114
|
}
|
|
46
115
|
next();
|
|
47
116
|
})
|
|
48
117
|
.use(metroMiddleware);
|
|
49
118
|
},
|
|
50
|
-
}
|
|
51
|
-
*/
|
|
119
|
+
};
|
|
52
120
|
|
|
53
121
|
module.exports = config;
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"install-missing": "node ./client/scripts/install-missing-deps.js",
|
|
13
13
|
"lint": "expo lint",
|
|
14
14
|
"server": "NODE_ENV=development tsx ./src/index.ts",
|
|
15
|
+
"server:build": "pnpm exec esbuild src/index.ts --platform=node --packages=external --bundle --format=esm --outdir=src_dist",
|
|
16
|
+
"server:prod": "NODE_ENV=production PORT=${PORT:-5000} node src_dist/index.js",
|
|
15
17
|
"start": "expo start --web",
|
|
16
18
|
"test": "jest --watchAll"
|
|
17
19
|
},
|
|
@@ -32,8 +34,10 @@
|
|
|
32
34
|
"@react-navigation/native": "^7.0.14",
|
|
33
35
|
"ajv": "^8.17.1",
|
|
34
36
|
"ajv-formats": "^3.0.1",
|
|
37
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
38
|
+
"babel-preset-expo": "^54.0.9",
|
|
35
39
|
"connect": "^3.7.0",
|
|
36
|
-
"coze-coding-dev-sdk": "^0.5.
|
|
40
|
+
"coze-coding-dev-sdk": "^0.5.5",
|
|
37
41
|
"dayjs": "^1.11.19",
|
|
38
42
|
"drizzle-kit": "^0.31.8",
|
|
39
43
|
"drizzle-orm": "^0.45.1",
|
|
@@ -58,6 +62,7 @@
|
|
|
58
62
|
"expo-system-ui": "~6.0.9",
|
|
59
63
|
"expo-web-browser": "~15.0.10",
|
|
60
64
|
"express": "^4.22.1",
|
|
65
|
+
"http-proxy-middleware": "^3.0.5",
|
|
61
66
|
"multer": "^2.0.2",
|
|
62
67
|
"pg": "^8.16.3",
|
|
63
68
|
"react": "19.1.0",
|
|
@@ -86,11 +91,10 @@
|
|
|
86
91
|
"@types/pg": "^8.16.0",
|
|
87
92
|
"@types/react": "~19.1.0",
|
|
88
93
|
"@types/react-test-renderer": "19.1.0",
|
|
89
|
-
"babel-plugin-module-resolver": "^5.0.2",
|
|
90
|
-
"babel-preset-expo": "^54.0.9",
|
|
91
94
|
"chalk": "^4.1.2",
|
|
92
95
|
"depcheck": "^1.4.7",
|
|
93
|
-
"
|
|
96
|
+
"esbuild": "0.27.2",
|
|
97
|
+
"eslint": "^9.39.2",
|
|
94
98
|
"eslint-formatter-compact": "^9.0.1",
|
|
95
99
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
96
100
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -108,5 +112,10 @@
|
|
|
108
112
|
"packageManager": "pnpm@9.0.0",
|
|
109
113
|
"engines": {
|
|
110
114
|
"pnpm": ">=9.0.0"
|
|
115
|
+
},
|
|
116
|
+
"pnpm": {
|
|
117
|
+
"overrides": {
|
|
118
|
+
"esbuild": "0.27.2"
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
}
|