@coze-arch/cli 0.0.1-alpha.cd0f36 → 0.0.1-alpha.cf9a3b
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/.cozeproj/scripts/server_dev_run.sh +1 -1
- package/lib/__templates__/expo/README.md +0 -1
- package/lib/__templates__/expo/client/contexts/AuthContext.tsx +3 -4
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +101 -45
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/nextjs/package.json +3 -1
- package/lib/__templates__/nextjs/pnpm-lock.yaml +119 -106
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +2 -2
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +4 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -15
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +117 -24
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
- package/lib/__templates__/taro/README.md +79 -17
- package/lib/__templates__/taro/config/index.ts +1 -1
- package/lib/__templates__/taro/eslint.config.mjs +25 -3
- package/lib/__templates__/taro/package.json +6 -4
- package/lib/__templates__/taro/pnpm-lock.yaml +378 -114
- package/lib/__templates__/taro/server/package.json +3 -1
- package/lib/__templates__/taro/server/src/main.ts +14 -2
- package/lib/__templates__/taro/src/app.css +18 -18
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/index.html +20 -1
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +171 -0
- package/lib/__templates__/taro/src/{utils → presets}/h5-styles.ts +15 -4
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/vite/package.json +5 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +146 -1659
- package/lib/cli.js +5 -59
- package/package.json +1 -1
- package/lib/__templates__/taro/src/app.ts +0 -14
- /package/lib/__templates__/taro/src/{utils → presets}/wx-debug.ts +0 -0
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"@nestjs/common": "^10.4.15",
|
|
17
17
|
"@nestjs/core": "^10.4.15",
|
|
18
18
|
"@nestjs/platform-express": "^10.4.15",
|
|
19
|
+
"@supabase/supabase-js": "2.95.3",
|
|
19
20
|
"better-sqlite3": "^11.9.1",
|
|
20
|
-
"coze-coding-dev-sdk": "^0.7.
|
|
21
|
+
"coze-coding-dev-sdk": "^0.7.16",
|
|
22
|
+
"dotenv": "^17.2.3",
|
|
21
23
|
"drizzle-kit": "^0.31.8",
|
|
22
24
|
"drizzle-orm": "^0.45.1",
|
|
23
25
|
"drizzle-zod": "^0.8.3",
|
|
@@ -3,6 +3,18 @@ import { AppModule } from '@/app.module';
|
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { HttpStatusInterceptor } from '@/interceptors/http-status.interceptor';
|
|
5
5
|
|
|
6
|
+
function parsePort(): number {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const portIndex = args.indexOf('-p');
|
|
9
|
+
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
10
|
+
const port = parseInt(args[portIndex + 1], 10);
|
|
11
|
+
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
12
|
+
return port;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return <%= serverPort %>;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
async function bootstrap() {
|
|
7
19
|
const app = await NestFactory.create(AppModule);
|
|
8
20
|
|
|
@@ -19,8 +31,8 @@ async function bootstrap() {
|
|
|
19
31
|
// 1. 开启优雅关闭 Hooks (关键!)
|
|
20
32
|
app.enableShutdownHooks();
|
|
21
33
|
|
|
22
|
-
// 2.
|
|
23
|
-
const port =
|
|
34
|
+
// 2. 解析端口
|
|
35
|
+
const port = parsePort();
|
|
24
36
|
try {
|
|
25
37
|
await app.listen(port);
|
|
26
38
|
console.log(`Server running on http://localhost:${port}`);
|
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* H5 端 rem 适配:与小程序 rpx 缩放一致
|
|
5
|
-
* 375px 屏幕:1rem = 16px,小程序 32rpx = 16px
|
|
5
|
+
* 375px 屏幕:1rem = 16px,小程序 32rpx = 16px
|
|
6
6
|
*/
|
|
7
7
|
html {
|
|
8
|
-
|
|
8
|
+
font-size: 4vw !important;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/* 小程序页面容器高度设置,确保垂直居中生效 */
|
|
12
12
|
/* stylelint-disable-next-line selector-type-no-unknown */
|
|
13
13
|
page {
|
|
14
|
-
|
|
14
|
+
height: 100%;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/* H5 端组件默认样式修复 */
|
|
18
18
|
taro-view-core {
|
|
19
|
-
|
|
19
|
+
display: block;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
taro-text-core {
|
|
23
|
-
|
|
23
|
+
display: inline;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
taro-input-core {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
display: block;
|
|
28
|
+
width: 100%;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
taro-input-core input {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
width: 100%;
|
|
33
|
+
background: transparent;
|
|
34
|
+
border: none;
|
|
35
|
+
outline: none;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/* 全局按钮样式重置 */
|
|
39
39
|
taro-button-core,
|
|
40
40
|
button {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
margin: 0 !important;
|
|
42
|
+
padding: 0 !important;
|
|
43
|
+
line-height: inherit;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
taro-button-core::after,
|
|
50
50
|
button::after {
|
|
51
|
-
|
|
51
|
+
border: none;
|
|
52
52
|
}
|
|
@@ -14,7 +14,26 @@
|
|
|
14
14
|
</head>
|
|
15
15
|
|
|
16
16
|
<body>
|
|
17
|
-
<div id="app"
|
|
17
|
+
<div id="app">
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="lab(2.86037 0.455312 0.568903)"
|
|
19
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="
|
|
20
|
+
position: fixed;
|
|
21
|
+
inset: 0;
|
|
22
|
+
margin: auto;
|
|
23
|
+
width: 24px;
|
|
24
|
+
height: 24px;
|
|
25
|
+
animation: __app-loading-spin 1s linear infinite;
|
|
26
|
+
">
|
|
27
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
28
|
+
</svg>
|
|
29
|
+
<style>
|
|
30
|
+
@keyframes __app-loading-spin {
|
|
31
|
+
to {
|
|
32
|
+
transform: rotate(360deg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
</div>
|
|
18
37
|
</body>
|
|
19
38
|
|
|
20
39
|
</html>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { View, Text } from '@tarojs/components';
|
|
2
|
+
import Taro, { useDidShow, usePageScroll } from '@tarojs/taro';
|
|
3
|
+
import { useState, useEffect, PropsWithChildren, useCallback } from 'react';
|
|
4
|
+
import { ChevronLeft, House } from 'lucide-react-taro';
|
|
5
|
+
|
|
6
|
+
interface NavConfig {
|
|
7
|
+
navigationBarTitleText?: string;
|
|
8
|
+
navigationBarBackgroundColor?: string;
|
|
9
|
+
navigationBarTextStyle?: 'black' | 'white';
|
|
10
|
+
navigationStyle?: 'default' | 'custom';
|
|
11
|
+
transparentTitle?: 'none' | 'always' | 'auto';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
enum LeftIcon {
|
|
15
|
+
Back = 'back',
|
|
16
|
+
Home = 'home',
|
|
17
|
+
None = 'none',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface NavState {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
title: string;
|
|
23
|
+
bgColor: string;
|
|
24
|
+
textStyle: 'black' | 'white';
|
|
25
|
+
navStyle: 'default' | 'custom';
|
|
26
|
+
transparent: 'none' | 'always' | 'auto';
|
|
27
|
+
leftIcon: LeftIcon;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const DEFAULT_NAV_STATE: NavState = {
|
|
31
|
+
visible: false,
|
|
32
|
+
title: '',
|
|
33
|
+
bgColor: '#ffffff',
|
|
34
|
+
textStyle: 'black',
|
|
35
|
+
navStyle: 'default',
|
|
36
|
+
transparent: 'none',
|
|
37
|
+
leftIcon: LeftIcon.None,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getTabBarPages = (): Set<string> => {
|
|
41
|
+
const tabBar = Taro.getApp()?.config?.tabBar;
|
|
42
|
+
return new Set(
|
|
43
|
+
tabBar?.list?.map((item: { pagePath: string }) => item.pagePath) || [],
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const computeLeftIcon = (
|
|
48
|
+
route: string,
|
|
49
|
+
tabBarPages: Set<string>,
|
|
50
|
+
historyLength: number,
|
|
51
|
+
): LeftIcon => {
|
|
52
|
+
if (!route) return LeftIcon.None;
|
|
53
|
+
|
|
54
|
+
const isHomePage =
|
|
55
|
+
route === 'pages/index/index' || route === '/pages/index/index';
|
|
56
|
+
const isTabBarPage = tabBarPages.has(route);
|
|
57
|
+
const hasHistory = historyLength > 1;
|
|
58
|
+
|
|
59
|
+
if (isTabBarPage || isHomePage) return LeftIcon.None;
|
|
60
|
+
if (hasHistory) return LeftIcon.Back;
|
|
61
|
+
return LeftIcon.Home;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const H5NavBar = ({ children }: PropsWithChildren) => {
|
|
65
|
+
const [navState, setNavState] = useState<NavState>(DEFAULT_NAV_STATE);
|
|
66
|
+
const [scrollOpacity, setScrollOpacity] = useState(0);
|
|
67
|
+
|
|
68
|
+
const updateNavState = useCallback(() => {
|
|
69
|
+
const pages = Taro.getCurrentPages();
|
|
70
|
+
const currentPage = pages[pages.length - 1];
|
|
71
|
+
const route = currentPage?.route || '';
|
|
72
|
+
const config: NavConfig = (currentPage as any)?.config || {};
|
|
73
|
+
const tabBarPages = getTabBarPages();
|
|
74
|
+
|
|
75
|
+
const isSinglePageApp = tabBarPages.size <= 1 && pages.length <= 1;
|
|
76
|
+
|
|
77
|
+
setNavState({
|
|
78
|
+
visible: !isSinglePageApp,
|
|
79
|
+
title: config.navigationBarTitleText || '',
|
|
80
|
+
bgColor: config.navigationBarBackgroundColor || '#ffffff',
|
|
81
|
+
textStyle: config.navigationBarTextStyle || 'black',
|
|
82
|
+
navStyle: config.navigationStyle || 'default',
|
|
83
|
+
transparent: config.transparentTitle || 'none',
|
|
84
|
+
leftIcon: isSinglePageApp
|
|
85
|
+
? LeftIcon.None
|
|
86
|
+
: computeLeftIcon(route, tabBarPages, pages.length),
|
|
87
|
+
});
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
useDidShow(() => {
|
|
91
|
+
updateNavState();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
usePageScroll(({ scrollTop }) => {
|
|
95
|
+
if (navState.transparent === 'auto') {
|
|
96
|
+
setScrollOpacity(Math.min(scrollTop / 100, 1));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (TARO_ENV !== 'h5') return;
|
|
102
|
+
|
|
103
|
+
const titleEl = document.querySelector('title') || document.head;
|
|
104
|
+
const observer = new MutationObserver(() => updateNavState());
|
|
105
|
+
observer.observe(titleEl, {
|
|
106
|
+
subtree: true,
|
|
107
|
+
childList: true,
|
|
108
|
+
characterData: true,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return () => observer.disconnect();
|
|
112
|
+
}, [updateNavState]);
|
|
113
|
+
|
|
114
|
+
if (
|
|
115
|
+
TARO_ENV !== 'h5' ||
|
|
116
|
+
navState.navStyle === 'custom' ||
|
|
117
|
+
!navState.visible
|
|
118
|
+
) {
|
|
119
|
+
return <>{children}</>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const iconColor = navState.textStyle === 'white' ? '#fff' : '#333';
|
|
123
|
+
const textColorClass =
|
|
124
|
+
navState.textStyle === 'white' ? 'text-white' : 'text-gray-800';
|
|
125
|
+
|
|
126
|
+
const getBgStyle = () => {
|
|
127
|
+
if (navState.transparent === 'always') {
|
|
128
|
+
return { backgroundColor: 'transparent' };
|
|
129
|
+
}
|
|
130
|
+
if (navState.transparent === 'auto') {
|
|
131
|
+
return { backgroundColor: navState.bgColor, opacity: scrollOpacity };
|
|
132
|
+
}
|
|
133
|
+
return { backgroundColor: navState.bgColor };
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleBack = () => Taro.navigateBack();
|
|
137
|
+
const handleGoHome = () => Taro.switchTab({ url: '/pages/index/index' });
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<View className="flex flex-col h-full">
|
|
141
|
+
<View
|
|
142
|
+
className={`fixed top-0 left-0 right-0 h-11 flex items-center justify-center z-1000 ${navState.transparent === 'none' ? 'border-b border-gray-200' : ''}`}
|
|
143
|
+
style={getBgStyle()}
|
|
144
|
+
>
|
|
145
|
+
{navState.leftIcon === LeftIcon.Back && (
|
|
146
|
+
<View
|
|
147
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 p-1 flex items-center justify-center"
|
|
148
|
+
onClick={handleBack}
|
|
149
|
+
>
|
|
150
|
+
<ChevronLeft size={24} color={iconColor} />
|
|
151
|
+
</View>
|
|
152
|
+
)}
|
|
153
|
+
{navState.leftIcon === LeftIcon.Home && (
|
|
154
|
+
<View
|
|
155
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 p-1 flex items-center justify-center"
|
|
156
|
+
onClick={handleGoHome}
|
|
157
|
+
>
|
|
158
|
+
<House size={22} color={iconColor} />
|
|
159
|
+
</View>
|
|
160
|
+
)}
|
|
161
|
+
<Text
|
|
162
|
+
className={`text-base font-medium max-w-3/5 truncate ${textColorClass}`}
|
|
163
|
+
>
|
|
164
|
+
{navState.title}
|
|
165
|
+
</Text>
|
|
166
|
+
</View>
|
|
167
|
+
<View className="h-11 shrink-0" />
|
|
168
|
+
<View className="pb-11 h-full">{children}</View>
|
|
169
|
+
</View>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* 如无必要,请勿修改本文件
|
|
4
4
|
*/
|
|
5
5
|
export function injectH5Styles() {
|
|
6
|
-
if (TARO_ENV !== 'h5') return
|
|
6
|
+
if (TARO_ENV !== 'h5') return;
|
|
7
7
|
|
|
8
|
-
const style = document.createElement('style')
|
|
8
|
+
const style = document.createElement('style');
|
|
9
9
|
style.innerHTML = `
|
|
10
10
|
/* H5 端隐藏 TabBar 空图标(只隐藏没有 src 的图标) */
|
|
11
11
|
.weui-tabbar__icon:not([src]),
|
|
@@ -17,6 +17,17 @@ export function injectH5Styles() {
|
|
|
17
17
|
.weui-tabbar__item:has(.weui-tabbar__icon[src='']) .weui-tabbar__label {
|
|
18
18
|
margin-top: 0 !important;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
/* Vite 错误覆盖层无法选择文本的问题 */
|
|
22
|
+
vite-error-overlay {
|
|
23
|
+
/* stylelint-disable-next-line property-no-vendor-prefix */
|
|
24
|
+
-webkit-user-select: text !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vite-error-overlay::part(window) {
|
|
28
|
+
max-width: 90vw;
|
|
29
|
+
padding: 10px;
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
document.head.appendChild(style);
|
|
22
33
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useLaunch } from '@tarojs/taro';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { H5NavBar } from './h5-navbar';
|
|
4
|
+
import { injectH5Styles } from './h5-styles';
|
|
5
|
+
import { enableWxDebugIfNeeded } from './wx-debug';
|
|
6
|
+
|
|
7
|
+
export const Preset = ({ children }: PropsWithChildren) => {
|
|
8
|
+
useLaunch(() => {
|
|
9
|
+
enableWxDebugIfNeeded();
|
|
10
|
+
injectH5Styles();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (TARO_ENV === 'h5') {
|
|
14
|
+
return <H5NavBar>{children}</H5NavBar>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <>{children}</>;
|
|
18
|
+
};
|
|
@@ -10,9 +10,13 @@
|
|
|
10
10
|
"start": "bash ./scripts/start.sh",
|
|
11
11
|
"ts-check": "tsc -p tsconfig.json"
|
|
12
12
|
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@supabase/supabase-js": "2.95.3",
|
|
15
|
+
"dotenv": "^17.2.3"
|
|
16
|
+
},
|
|
13
17
|
"devDependencies": {
|
|
14
18
|
"autoprefixer": "^10.4.20",
|
|
15
|
-
"coze-coding-dev-sdk": "^0.7.
|
|
19
|
+
"coze-coding-dev-sdk": "^0.7.16",
|
|
16
20
|
"eslint": "^9",
|
|
17
21
|
"only-allow": "^1.2.2",
|
|
18
22
|
"postcss": "^8.4.49",
|