@coze-arch/cli 0.1.4-alpha.fb90f3 → 0.1.5-alpha.2e246f
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_build.ps1 +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +3 -3
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.ps1 +3 -3
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +0 -2
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +3 -3
- package/lib/__templates__/expo/client/components/Screen.tsx +25 -65
- package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +2 -6
- package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
- package/lib/__templates__/nextjs/.babelrc +15 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -11
- package/lib/__templates__/nextjs/next.config.ts +0 -10
- package/lib/__templates__/nextjs/package.json +6 -3
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1071 -136
- package/lib/__templates__/nextjs/scripts/build.ps1 +1 -1
- package/lib/__templates__/nextjs/scripts/build.sh +2 -3
- package/lib/__templates__/nextjs/scripts/dev.sh +3 -6
- package/lib/__templates__/nextjs/scripts/prepare.sh +4 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +4 -0
- package/lib/__templates__/nextjs/src/server.ts +1 -1
- package/lib/__templates__/nextjs/template.config.js +59 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +0 -2
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +4 -1
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +2 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +1 -3
- package/lib/__templates__/vite/scripts/build.ps1 +1 -4
- package/lib/__templates__/vite/scripts/build.sh +1 -1
- package/lib/__templates__/vite/scripts/dev.ps1 +23 -7
- package/lib/__templates__/vite/scripts/dev.sh +0 -2
- package/lib/__templates__/vite/scripts/ensure-deps.ps1 +33 -0
- package/lib/__templates__/vite/scripts/prepare.ps1 +1 -6
- package/lib/__templates__/vite/scripts/prepare.sh +4 -1
- package/lib/__templates__/vite/template.config.js +59 -0
- package/lib/cli.js +19 -38
- package/package.json +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/nextjs/scripts/prepare-next-output.sh +0 -62
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +0 -149
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +0 -149
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
|
|
3
3
|
set -euo pipefail
|
|
4
|
-
ROOT_DIR="$(
|
|
4
|
+
ROOT_DIR="$(pwd)"
|
|
5
5
|
PREVIEW_DIR="/source/preview"
|
|
6
6
|
SOURCE_DIR="/source"
|
|
7
7
|
|
|
@@ -34,8 +34,8 @@ echo "==================== 安装项目依赖 ===================="
|
|
|
34
34
|
if [ ! -f "package.json" ]; then
|
|
35
35
|
echo "项目目录下无 package.json,不是合法的 Node.js 项目"
|
|
36
36
|
fi
|
|
37
|
-
# 步骤 2.1/2.2
|
|
38
|
-
|
|
37
|
+
# 步骤 2.1/2.2:安装项目依赖
|
|
38
|
+
pnpm install --registry=https://registry.npmmirror.com || echo "Expo 项目依赖安装失败(pnpm 执行出错)"
|
|
39
39
|
|
|
40
40
|
echo "检查根目录 post_install.py"
|
|
41
41
|
if [ -f "$PREVIEW_DIR/post_install.py" ]; then
|
|
@@ -42,7 +42,7 @@ Stop-ListeningProcess $expoPort
|
|
|
42
42
|
$webUrl = if ($env:COZE_PROJECT_DOMAIN_DEFAULT) {
|
|
43
43
|
$env:COZE_PROJECT_DOMAIN_DEFAULT
|
|
44
44
|
} elseif ($env:COZE_HARDWARE_DID) {
|
|
45
|
-
"https://
|
|
45
|
+
"https://preview-$($env:COZE_HARDWARE_DID)-$expoPort.dev.coze.site"
|
|
46
46
|
} else {
|
|
47
47
|
"http://127.0.0.1:$serverPort"
|
|
48
48
|
}
|
|
@@ -64,11 +64,11 @@ $expo = Start-LoggedProcess (Join-Path $workspace "client") $clientLog @("exec",
|
|
|
64
64
|
|
|
65
65
|
Start-Sleep -Seconds 8
|
|
66
66
|
if ((Test-Path $clientLog) -and (Select-String -Path $clientLog -Pattern "TypeError: fetch failed" -Quiet)) {
|
|
67
|
-
Write-Host "Expo
|
|
67
|
+
Write-Host "Expo startup detected a network error; retrying in offline mode."
|
|
68
68
|
Stop-ProcessTree $expo.Id
|
|
69
69
|
$expoEnvironment.EXPO_OFFLINE = "1"
|
|
70
70
|
$expo = Start-LoggedProcess (Join-Path $workspace "client") $clientLog @("exec", "expo", "start", "--web", "--clear", "--port", "$expoPort") $expoEnvironment
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
Write-Host "
|
|
73
|
+
Write-Host "Services started. Server PID: $($server.Id), Expo PID: $($expo.Id)"
|
|
74
74
|
Write-Host "EXPO_PUBLIC_BACKEND_BASE_URL=$webUrl"
|
|
@@ -135,7 +135,6 @@ shift
|
|
|
135
135
|
child_pid=$!
|
|
136
136
|
|
|
137
137
|
# 先忽略 TERM,才能在向整组发 TERM(自己也在组里)之后存活下来补一发 KILL。
|
|
138
|
-
if [[ -z "${COZE_EVAL:-}" && -z "${COZE_PROJECT_TYPE:-}" ]]; then
|
|
139
138
|
( trap "" TERM
|
|
140
139
|
sleep "${timeout_seconds}"
|
|
141
140
|
echo "[dev] 后台进程运行超过 ${timeout_seconds}s,回收进程组 $$。"
|
|
@@ -143,7 +142,6 @@ if [[ -z "${COZE_EVAL:-}" && -z "${COZE_PROJECT_TYPE:-}" ]]; then
|
|
|
143
142
|
sleep 5
|
|
144
143
|
kill -KILL -- "-$$" 2>/dev/null || true
|
|
145
144
|
) &
|
|
146
|
-
fi
|
|
147
145
|
|
|
148
146
|
wait "${child_pid}"
|
|
149
147
|
kill -KILL -- "-$$" 2>/dev/null || true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
|
|
3
3
|
set -euo pipefail
|
|
4
|
-
ROOT_DIR="$(
|
|
4
|
+
ROOT_DIR="$(pwd)"
|
|
5
5
|
|
|
6
6
|
# ==================== 工具函数 ====================
|
|
7
7
|
info() {
|
|
@@ -32,8 +32,8 @@ info "==================== 安装 Node 依赖 ===================="
|
|
|
32
32
|
info "开始安装 Node 依赖"
|
|
33
33
|
if [ -f "$ROOT_DIR/package.json" ]; then
|
|
34
34
|
info "进入目录:$ROOT_DIR"
|
|
35
|
-
info "
|
|
36
|
-
|
|
35
|
+
info "正在执行:pnpm install"
|
|
36
|
+
(cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
|
|
37
37
|
else
|
|
38
38
|
warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
|
|
39
39
|
fi
|
|
@@ -6,19 +6,13 @@ import {
|
|
|
6
6
|
View,
|
|
7
7
|
TouchableWithoutFeedback,
|
|
8
8
|
Keyboard,
|
|
9
|
-
|
|
9
|
+
ViewStyle,
|
|
10
10
|
FlatList,
|
|
11
|
-
type FlatListProps,
|
|
12
11
|
SectionList,
|
|
13
|
-
type SectionListProps,
|
|
14
|
-
type ScrollViewProps,
|
|
15
12
|
Modal,
|
|
16
13
|
} from 'react-native';
|
|
17
14
|
import { withUniwind } from 'uniwind';
|
|
18
|
-
import {
|
|
19
|
-
useSafeAreaInsets,
|
|
20
|
-
type Edge,
|
|
21
|
-
} from 'react-native-safe-area-context';
|
|
15
|
+
import { useSafeAreaInsets, Edge } from 'react-native-safe-area-context';
|
|
22
16
|
import { StatusBar } from 'expo-status-bar';
|
|
23
17
|
// 引入 KeyboardAware 系列组件
|
|
24
18
|
import {
|
|
@@ -92,92 +86,58 @@ type KeyboardAwareProps = {
|
|
|
92
86
|
contentInsetBehaviorIOS: 'automatic' | 'never';
|
|
93
87
|
};
|
|
94
88
|
|
|
95
|
-
type NativeScrollableProps = Pick<
|
|
96
|
-
ScrollViewProps,
|
|
97
|
-
| 'contentContainerStyle'
|
|
98
|
-
| 'keyboardShouldPersistTaps'
|
|
99
|
-
| 'keyboardDismissMode'
|
|
100
|
-
| 'contentInsetAdjustmentBehavior'
|
|
101
|
-
>;
|
|
102
|
-
|
|
103
89
|
const KeyboardAwareScrollable = ({
|
|
104
90
|
element,
|
|
105
91
|
extraPadding,
|
|
106
92
|
contentInsetBehaviorIOS,
|
|
107
93
|
}: KeyboardAwareProps) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
? mergedStyle.paddingBottom
|
|
115
|
-
: 0;
|
|
94
|
+
// 获取原始组件的 props
|
|
95
|
+
const childAttrs = ((element as React.ReactElement).props ?? {}) as Record<string, unknown>;
|
|
96
|
+
const originStyle = childAttrs['contentContainerStyle'];
|
|
97
|
+
const styleArray = Array.isArray(originStyle) ? originStyle : originStyle ? [originStyle] : [];
|
|
98
|
+
const merged = Object.assign({}, ...styleArray);
|
|
99
|
+
const currentPB = typeof merged.paddingBottom === 'number' ? merged.paddingBottom : 0;
|
|
116
100
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
...mergedStyle,
|
|
120
|
-
paddingBottom: currentPaddingBottom + extraPadding,
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
};
|
|
101
|
+
// 合并 paddingBottom (安全区 + 额外留白)
|
|
102
|
+
const enhancedContentStyle = [{ ...merged, paddingBottom: currentPB + extraPadding }];
|
|
124
103
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
),
|
|
132
|
-
keyboardShouldPersistTaps:
|
|
133
|
-
childProps.keyboardShouldPersistTaps ?? 'handled',
|
|
134
|
-
keyboardDismissMode: childProps.keyboardDismissMode ?? 'on-drag',
|
|
104
|
+
// 基础配置 props,用于传递给 KeyboardAware 组件
|
|
105
|
+
const commonProps = {
|
|
106
|
+
...childAttrs,
|
|
107
|
+
contentContainerStyle: enhancedContentStyle,
|
|
108
|
+
keyboardShouldPersistTaps: childAttrs['keyboardShouldPersistTaps'] ?? 'handled',
|
|
109
|
+
keyboardDismissMode: childAttrs['keyboardDismissMode'] ?? 'on-drag',
|
|
135
110
|
enableOnAndroid: true,
|
|
136
111
|
// 类似于原代码中的 setTimeout/scrollToEnd 逻辑,这里设置额外的滚动高度确保输入框可见
|
|
137
112
|
extraHeight: 100,
|
|
138
113
|
// 禁用自带的 ScrollView 自动 inset,由外部 padding 控制
|
|
139
114
|
enableAutomaticScroll: true,
|
|
140
115
|
...(Platform.OS === 'ios'
|
|
141
|
-
? {
|
|
142
|
-
contentInsetAdjustmentBehavior:
|
|
143
|
-
childProps.contentInsetAdjustmentBehavior ??
|
|
144
|
-
contentInsetBehaviorIOS,
|
|
145
|
-
}
|
|
116
|
+
? { contentInsetAdjustmentBehavior: childAttrs['contentInsetAdjustmentBehavior'] ?? contentInsetBehaviorIOS }
|
|
146
117
|
: {}),
|
|
147
|
-
}
|
|
118
|
+
};
|
|
148
119
|
|
|
149
|
-
const t = element.type;
|
|
120
|
+
const t = (element as React.ReactElement).type;
|
|
150
121
|
|
|
151
122
|
// 根据组件类型返回对应的 KeyboardAware 版本
|
|
152
123
|
// 注意:不再使用 KeyboardAvoidingView,直接替换为增强版 ScrollView
|
|
153
124
|
if (t === ScrollView) {
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<KeyboardAwareScrollView {...createKeyboardAwareProps(childProps)} />
|
|
157
|
-
);
|
|
125
|
+
return <KeyboardAwareScrollView {...commonProps} />;
|
|
158
126
|
}
|
|
159
127
|
|
|
160
128
|
if (t === FlatList) {
|
|
161
|
-
|
|
162
|
-
return <KeyboardAwareFlatList {...createKeyboardAwareProps(childProps)} />;
|
|
129
|
+
return <KeyboardAwareFlatList {...commonProps} />;
|
|
163
130
|
}
|
|
164
131
|
|
|
165
132
|
if (t === SectionList) {
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<KeyboardAwareSectionList {...createKeyboardAwareProps(childProps)} />
|
|
169
|
-
);
|
|
133
|
+
return <KeyboardAwareSectionList {...commonProps} />;
|
|
170
134
|
}
|
|
171
135
|
|
|
172
136
|
// 理论上不应运行到这里,如果是非标准组件则原样返回,仅修改样式
|
|
173
|
-
const childProps = element.props as NativeScrollableProps;
|
|
174
137
|
return React.cloneElement(element, {
|
|
175
|
-
contentContainerStyle:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
keyboardShouldPersistTaps:
|
|
179
|
-
childProps.keyboardShouldPersistTaps ?? 'handled',
|
|
180
|
-
keyboardDismissMode: childProps.keyboardDismissMode ?? 'on-drag',
|
|
138
|
+
contentContainerStyle: enhancedContentStyle,
|
|
139
|
+
keyboardShouldPersistTaps: childAttrs['keyboardShouldPersistTaps'] ?? 'handled',
|
|
140
|
+
keyboardDismissMode: childAttrs['keyboardDismissMode'] ?? 'on-drag',
|
|
181
141
|
});
|
|
182
142
|
};
|
|
183
143
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type GestureResponderEvent,
|
|
4
|
-
View,
|
|
5
|
-
Text as RNText,
|
|
6
|
-
} from 'react-native';
|
|
2
|
+
import { View, Text as RNText } from 'react-native';
|
|
7
3
|
import { GestureDetector } from 'react-native-gesture-handler';
|
|
8
4
|
import Animated from 'react-native-reanimated';
|
|
9
5
|
import { useThemeColor } from '../../helpers/external/hooks';
|
|
@@ -343,7 +339,7 @@ const ToastClose = forwardRef<View, ToastCloseProps>((props, ref) => {
|
|
|
343
339
|
* If hide and id are available from context, use them to hide the toast
|
|
344
340
|
* Otherwise, use the provided onPress handler
|
|
345
341
|
*/
|
|
346
|
-
const handlePress = (event:
|
|
342
|
+
const handlePress = (event: Parameters<NonNullable<React.ComponentProps<typeof Button>['onPress']>>[0]) => {
|
|
347
343
|
if (hide && id) {
|
|
348
344
|
hide(id);
|
|
349
345
|
}
|
package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts
CHANGED
|
@@ -108,7 +108,7 @@ function useUncontrolledState<T>({
|
|
|
108
108
|
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
109
109
|
* prop or avoid re-executing effects when passed as a dependency
|
|
110
110
|
*/
|
|
111
|
-
function useCallbackRef<T extends (...args:
|
|
111
|
+
function useCallbackRef<T extends (...args: unknown[]) => unknown>(
|
|
112
112
|
callback: T | undefined
|
|
113
113
|
): T {
|
|
114
114
|
const callbackRef = useRef(callback);
|
|
@@ -23,11 +23,6 @@ const eslintConfig = defineConfig([
|
|
|
23
23
|
...nextVitals,
|
|
24
24
|
...nextTs,
|
|
25
25
|
{
|
|
26
|
-
settings: {
|
|
27
|
-
// node_modules 里的 barrel 包(lucide-react 等)不参与 ExportMap 构建,
|
|
28
|
-
// import/no-cycle 只需要项目源码的依赖图。
|
|
29
|
-
'import/ignore': ['/node_modules/'],
|
|
30
|
-
},
|
|
31
26
|
rules: {
|
|
32
27
|
'import/no-cycle': ['error', { ignoreExternal: true }],
|
|
33
28
|
'react-hooks/set-state-in-effect': 'off',
|
|
@@ -42,15 +37,14 @@ const eslintConfig = defineConfig([
|
|
|
42
37
|
},
|
|
43
38
|
// Override default ignores of eslint-config-next.
|
|
44
39
|
globalIgnores([
|
|
45
|
-
// Default ignores of eslint-config-next
|
|
46
|
-
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'build/',
|
|
40
|
+
// Default ignores of eslint-config-next:
|
|
41
|
+
'.next/**',
|
|
42
|
+
'out/**',
|
|
43
|
+
'build/**',
|
|
50
44
|
'next-env.d.ts',
|
|
51
45
|
// Build artifacts:
|
|
52
46
|
'server.js',
|
|
53
|
-
'dist
|
|
47
|
+
'dist/**',
|
|
54
48
|
// Script files (CommonJS):
|
|
55
49
|
'scripts/**/*.js',
|
|
56
50
|
]),
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
-
import path from 'path';
|
|
3
2
|
|
|
4
3
|
const nextConfig: NextConfig = {
|
|
5
4
|
// outputFileTracingRoot: path.resolve(__dirname, '../../'), // Uncomment and add 'import path from "path"' if needed
|
|
6
5
|
/* config options here */
|
|
7
|
-
serverExternalPackages: ['coze-coding-dev-sdk'],
|
|
8
|
-
webpack: (config, { dev }) => {
|
|
9
|
-
if (dev && config.cache && config.cache.type === 'filesystem') {
|
|
10
|
-
config.cache.cacheDirectory = path.resolve(
|
|
11
|
-
'node_modules/.cache/next-webpack',
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
return config;
|
|
15
|
-
},
|
|
16
6
|
allowedDevOrigins: ['*.dev.coze.site'],
|
|
17
7
|
images: {
|
|
18
8
|
remotePatterns: [
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"build": "bash ./scripts/build.sh",
|
|
7
7
|
"dev": "bash ./scripts/dev.sh",
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
9
|
-
"lint": "eslint
|
|
9
|
+
"lint": "eslint",
|
|
10
10
|
"lint:build": "eslint . --quiet",
|
|
11
11
|
"lint:style": "stylelint \"src/**/*.css\"",
|
|
12
12
|
"start": "bash ./scripts/start.sh",
|
|
@@ -73,14 +73,17 @@
|
|
|
73
73
|
"zod": "^4.3.5"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
+
"@react-dev-inspector/babel-plugin": "^2.0.1",
|
|
77
|
+
"@react-dev-inspector/middleware": "^2.0.1",
|
|
76
78
|
"@tailwindcss/postcss": "^4",
|
|
77
79
|
"@types/node": "^20",
|
|
78
80
|
"@types/pg": "^8.16.0",
|
|
79
81
|
"@types/react": "^19",
|
|
80
82
|
"@types/react-dom": "^19",
|
|
81
83
|
"eslint": "^9",
|
|
82
|
-
"eslint-config-next": "16.
|
|
84
|
+
"eslint-config-next": "16.3.3",
|
|
83
85
|
"only-allow": "^1.2.2",
|
|
86
|
+
"react-dev-inspector": "^2.0.1",
|
|
84
87
|
"shadcn": "latest",
|
|
85
88
|
"stylelint": "^16.4.0",
|
|
86
89
|
"stylelint-config-standard": "^38.0.0",
|
|
@@ -95,7 +98,7 @@
|
|
|
95
98
|
},
|
|
96
99
|
"pnpm": {
|
|
97
100
|
"overrides": {
|
|
98
|
-
"sharp": "0.35.
|
|
101
|
+
"sharp": "^0.35.4"
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
}
|