@coze-arch/cli 0.0.1-alpha.035e0e → 0.0.1-alpha.07ff12
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/dev_run.sh +12 -4
- package/lib/__templates__/expo/README.md +4 -2
- package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
- package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
- package/lib/__templates__/expo/client/app.config.ts +4 -3
- package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
- package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
- package/lib/__templates__/expo/client/constants/theme.ts +21 -814
- package/lib/__templates__/expo/client/eslint.config.mjs +30 -10
- package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
- package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
- package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
- package/lib/__templates__/expo/client/package.json +3 -1
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
- package/lib/__templates__/expo/client/utils/index.ts +22 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
- package/lib/__templates__/expo/package.json +3 -0
- package/lib/__templates__/expo/patches/expo@54.0.32.patch +44 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +1924 -1846
- package/lib/__templates__/expo/server/build.js +21 -0
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/expo/server/src/index.ts +2 -1
- package/lib/__templates__/nextjs/.babelrc +15 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -1
- package/lib/__templates__/nextjs/package.json +8 -10
- package/lib/__templates__/nextjs/pnpm-lock.yaml +2543 -1755
- package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
- package/lib/__templates__/nextjs/template.config.js +5 -5
- package/lib/__templates__/vite/package.json +6 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +504 -982
- package/lib/__templates__/vite/template.config.js +6 -4
- package/lib/cli.js +511 -94
- package/package.json +1 -1
- package/lib/__templates__/expo/client/app/demo.tsx +0 -1
- package/lib/__templates__/expo/client/components/ThemedText.tsx +0 -33
|
@@ -15,13 +15,14 @@ EXPO_PORT="5000"
|
|
|
15
15
|
WEB_URL="${COZE_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
|
|
16
16
|
ASSUME_YES="1"
|
|
17
17
|
EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
|
|
18
|
-
|
|
18
|
+
EXPO_PUBLIC_COZE_PROJECT_ID="${COZE_PROJECT_ID:-}"
|
|
19
19
|
|
|
20
20
|
EXPO_PACKAGER_PROXY_URL="${EXPO_PUBLIC_BACKEND_BASE_URL}"
|
|
21
|
-
export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL
|
|
21
|
+
export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL EXPO_PUBLIC_COZE_PROJECT_ID
|
|
22
22
|
# 运行时变量(为避免 set -u 的未绑定错误,预置为空)
|
|
23
23
|
SERVER_PID=""
|
|
24
24
|
EXPO_PID=""
|
|
25
|
+
|
|
25
26
|
# ==================== 工具函数 ====================
|
|
26
27
|
check_command() {
|
|
27
28
|
if ! command -v "$1" &> /dev/null; then
|
|
@@ -114,10 +115,10 @@ start_expo() {
|
|
|
114
115
|
pushd "$ROOT_DIR/client"
|
|
115
116
|
|
|
116
117
|
if [ "$offline" = "1" ]; then
|
|
117
|
-
( EXPO_OFFLINE=1
|
|
118
|
+
( EXPO_OFFLINE=1 EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
|
|
118
119
|
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$ROOT_DIR/logs/client.log" ) &
|
|
119
120
|
else
|
|
120
|
-
(
|
|
121
|
+
( EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
|
|
121
122
|
nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$ROOT_DIR/logs/client.log" ) &
|
|
122
123
|
fi
|
|
123
124
|
EXPO_PID=$!
|
|
@@ -150,6 +151,12 @@ if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
|
|
|
150
151
|
python "$PREVIEW_DIR/pre_install.py" || echo "pre_install.py 执行失败"
|
|
151
152
|
fi
|
|
152
153
|
|
|
154
|
+
echo "检查根目录 post_install.py"
|
|
155
|
+
if [ -f "$PREVIEW_DIR/post_install.py" ]; then
|
|
156
|
+
echo "执行:python $PREVIEW_DIR/post_install.py"
|
|
157
|
+
python "$PREVIEW_DIR/post_install.py" || echo "post_install.py 执行失败"
|
|
158
|
+
fi
|
|
159
|
+
|
|
153
160
|
echo "==================== 开始启动 ===================="
|
|
154
161
|
echo "开始执行服务启动脚本(start_dev.sh)..."
|
|
155
162
|
echo "正在检查依赖命令和目录是否存在..."
|
|
@@ -188,6 +195,7 @@ fi
|
|
|
188
195
|
echo "Expo 环境变量配置:"
|
|
189
196
|
echo "EXPO_PUBLIC_BACKEND_BASE_URL=${EXPO_PUBLIC_BACKEND_BASE_URL}"
|
|
190
197
|
echo "EXPO_PACKAGER_PROXY_URL=${EXPO_PACKAGER_PROXY_URL}"
|
|
198
|
+
echo "EXPO_PUBLIC_COZE_PROJECT_ID=${EXPO_PUBLIC_COZE_PROJECT_ID}"
|
|
191
199
|
if [ -z "${EXPO_PID}" ]; then
|
|
192
200
|
echo "无法获取 Expo 后台进程 PID"
|
|
193
201
|
fi
|
|
@@ -15,17 +15,19 @@
|
|
|
15
15
|
| └── package.json # 服务端 package.json
|
|
16
16
|
├── client/ # React Native 前端代码
|
|
17
17
|
│ ├── app/ # Expo Router 路由目录(仅路由配置)
|
|
18
|
-
│ │ ├── _layout.tsx #
|
|
18
|
+
│ │ ├── _layout.tsx # 根布局文件(必需,务必阅读)
|
|
19
19
|
│ │ ├── home.tsx # 首页
|
|
20
20
|
│ │ └── index.tsx # re-export home.tsx
|
|
21
21
|
│ ├── screens/ # 页面实现目录(与 app/ 路由对应)
|
|
22
|
-
│ │ └──
|
|
22
|
+
│ │ └── demo/ # demo 示例页面
|
|
23
23
|
│ │ ├── index.tsx # 页面组件实现
|
|
24
24
|
│ │ └── styles.ts # 页面样式
|
|
25
25
|
│ ├── components/ # 可复用组件
|
|
26
26
|
│ │ └── Screen.tsx # 页面容器组件(必用)
|
|
27
27
|
│ ├── hooks/ # 自定义 Hooks
|
|
28
28
|
│ ├── contexts/ # React Context 代码
|
|
29
|
+
│ ├── constants/ # 常量定义(如主题配置)
|
|
30
|
+
│ ├── utils/ # 工具函数
|
|
29
31
|
│ ├── assets/ # 静态资源
|
|
30
32
|
| └── package.json # Expo 应用 package.json
|
|
31
33
|
├── package.json
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
2
|
+
import { Link } from 'expo-router';
|
|
3
|
+
import { useTheme } from '@/hooks/useTheme';
|
|
4
|
+
import { Spacing } from '@/constants/theme';
|
|
5
|
+
|
|
6
|
+
export default function NotFoundScreen() {
|
|
7
|
+
const { theme } = useTheme();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<View style={[styles.container, { backgroundColor: theme.backgroundRoot }]}>
|
|
11
|
+
<Text>
|
|
12
|
+
页面不存在
|
|
13
|
+
</Text>
|
|
14
|
+
<Link href="/" style={[styles.gohome]}>
|
|
15
|
+
返回首页
|
|
16
|
+
</Link>
|
|
17
|
+
</View>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
container: {
|
|
23
|
+
flex: 1,
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
},
|
|
27
|
+
gohome: {
|
|
28
|
+
marginTop: Spacing['2xl'],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -5,6 +5,7 @@ import { StatusBar } from 'expo-status-bar';
|
|
|
5
5
|
import { LogBox } from 'react-native';
|
|
6
6
|
import Toast from 'react-native-toast-message';
|
|
7
7
|
import { AuthProvider } from "@/contexts/AuthContext";
|
|
8
|
+
import { ColorSchemeProvider } from '@/hooks/useColorScheme';
|
|
8
9
|
|
|
9
10
|
LogBox.ignoreLogs([
|
|
10
11
|
"TurboModuleRegistry.getEnforcing(...): 'RNMapsAirModule' could not be found",
|
|
@@ -14,20 +15,22 @@ LogBox.ignoreLogs([
|
|
|
14
15
|
export default function RootLayout() {
|
|
15
16
|
return (
|
|
16
17
|
<AuthProvider>
|
|
17
|
-
<
|
|
18
|
+
<ColorSchemeProvider>
|
|
19
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
18
20
|
<StatusBar style="dark"></StatusBar>
|
|
19
21
|
<Stack screenOptions={{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
// 设置所有页面的切换动画为从右侧滑入,适用于iOS 和 Android
|
|
23
|
+
animation: 'slide_from_right',
|
|
24
|
+
gestureEnabled: true,
|
|
25
|
+
gestureDirection: 'horizontal',
|
|
26
|
+
// 隐藏自带的头部
|
|
27
|
+
headerShown: false
|
|
26
28
|
}}>
|
|
27
29
|
<Stack.Screen name="index" options={{ title: "" }} />
|
|
28
30
|
</Stack>
|
|
29
31
|
<Toast />
|
|
30
|
-
|
|
32
|
+
</GestureHandlerRootView>
|
|
33
|
+
</ColorSchemeProvider>
|
|
31
34
|
</AuthProvider>
|
|
32
35
|
);
|
|
33
36
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ExpoConfig, ConfigContext } from 'expo/config';
|
|
2
2
|
|
|
3
|
-
const appName =
|
|
4
|
-
const
|
|
3
|
+
const appName = process.env.COZE_PROJECT_NAME || process.env.EXPO_PUBLIC_COZE_PROJECT_NAME || '应用';
|
|
4
|
+
const projectId = process.env.COZE_PROJECT_ID || process.env.EXPO_PUBLIC_COZE_PROJECT_ID;
|
|
5
|
+
const slugAppName = projectId ? `app${projectId}` : 'myapp';
|
|
5
6
|
|
|
6
7
|
export default ({ config }: ConfigContext): ExpoConfig => {
|
|
7
8
|
return {
|
|
@@ -22,7 +23,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
|
|
22
23
|
"foregroundImage": "./assets/images/adaptive-icon.png",
|
|
23
24
|
"backgroundColor": "#ffffff"
|
|
24
25
|
},
|
|
25
|
-
"package":
|
|
26
|
+
"package": `com.anonymous.x${projectId || '0'}`
|
|
26
27
|
},
|
|
27
28
|
"web": {
|
|
28
29
|
"bundler": "metro",
|
|
@@ -197,26 +197,10 @@ export const Screen = ({
|
|
|
197
197
|
// 强制禁用 iOS 自动调整内容区域,完全由手动 padding 控制,消除系统自动计算带来的多余空白
|
|
198
198
|
const contentInsetBehaviorIOS = 'never';
|
|
199
199
|
|
|
200
|
-
// 1. 外层容器样式
|
|
201
|
-
// 负责:背景色、Top/Left/Right 安全区、以及非滚动模式下的 Bottom 安全区
|
|
202
|
-
const childArray = React.Children.toArray(children);
|
|
203
|
-
let firstChild: React.ReactElement<any, any> | null = null;
|
|
204
|
-
for (let i = 0; i < childArray.length; i++) {
|
|
205
|
-
const el = childArray[i];
|
|
206
|
-
if (React.isValidElement(el)) { firstChild = el as React.ReactElement<any, any>; break; }
|
|
207
|
-
}
|
|
208
|
-
const firstChildHasInlinePaddingTop = (() => {
|
|
209
|
-
if (!firstChild) return false;
|
|
210
|
-
const st: any = (firstChild as any).props?.style;
|
|
211
|
-
const arr = Array.isArray(st) ? st : st ? [st] : [];
|
|
212
|
-
return arr.some((s) => s && typeof s === 'object' && typeof (s as any).paddingTop === 'number' && (s as any).paddingTop > 10);
|
|
213
|
-
})();
|
|
214
|
-
const applyTopInset = hasTop && !firstChildHasInlinePaddingTop;
|
|
215
|
-
|
|
216
200
|
const wrapperStyle: ViewStyle = {
|
|
217
201
|
flex: 1,
|
|
218
202
|
backgroundColor,
|
|
219
|
-
paddingTop:
|
|
203
|
+
paddingTop: hasTop ? insets.top : 0,
|
|
220
204
|
paddingLeft: hasLeft ? insets.left : 0,
|
|
221
205
|
paddingRight: hasRight ? insets.right : 0,
|
|
222
206
|
// 当页面不使用外层 ScrollView 时(子树本身可滚动),由外层 View 负责底部安全区
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { View, ViewProps, ViewStyle } from 'react-native';
|
|
3
3
|
import { useTheme } from '@/hooks/useTheme';
|
|
4
4
|
|
|
5
|
-
type BackgroundLevel = 'root' | 'default' | '
|
|
5
|
+
type BackgroundLevel = 'root' | 'default' | 'tertiary';
|
|
6
6
|
|
|
7
7
|
interface ThemedViewProps extends ViewProps {
|
|
8
8
|
level?: BackgroundLevel;
|
|
@@ -12,7 +12,6 @@ interface ThemedViewProps extends ViewProps {
|
|
|
12
12
|
const backgroundMap: Record<BackgroundLevel, string> = {
|
|
13
13
|
root: 'backgroundRoot',
|
|
14
14
|
default: 'backgroundDefault',
|
|
15
|
-
secondary: 'backgroundSecondary',
|
|
16
15
|
tertiary: 'backgroundTertiary',
|
|
17
16
|
};
|
|
18
17
|
|