@coze-arch/cli 0.1.5-alpha.581217 → 0.1.5

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.
Files changed (43) hide show
  1. package/docs/deploy.md +1 -12
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +3 -3
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +3 -11
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +3 -3
  5. package/lib/__templates__/expo/client/components/Screen.tsx +25 -65
  6. package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +2 -6
  7. package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
  8. package/lib/__templates__/nextjs/.babelrc +15 -0
  9. package/lib/__templates__/nextjs/eslint.config.mjs +5 -11
  10. package/lib/__templates__/nextjs/next.config.ts +0 -10
  11. package/lib/__templates__/nextjs/package.json +6 -3
  12. package/lib/__templates__/nextjs/pnpm-lock.yaml +1071 -136
  13. package/lib/__templates__/nextjs/scripts/build.ps1 +1 -1
  14. package/lib/__templates__/nextjs/scripts/build.sh +2 -2
  15. package/lib/__templates__/nextjs/scripts/dev.ps1 +2 -2
  16. package/lib/__templates__/nextjs/scripts/dev.sh +10 -86
  17. package/lib/__templates__/nextjs/scripts/prepare.sh +4 -1
  18. package/lib/__templates__/nextjs/src/app/layout.tsx +4 -0
  19. package/lib/__templates__/nextjs/src/server.ts +1 -1
  20. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  21. package/lib/__templates__/nuxt-vue/scripts/dev.sh +3 -11
  22. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +4 -1
  23. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +1 -5
  24. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +0 -4
  25. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -3
  26. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.ps1 +2 -4
  27. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +7 -29
  28. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +0 -4
  29. package/lib/__templates__/taro/.cozeproj/scripts/pack.ps1 +1 -3
  30. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +0 -8
  31. package/lib/__templates__/taro/.cozeproj/scripts/validate.ps1 +1 -3
  32. package/lib/__templates__/taro/.cozeproj/scripts/validate.sh +0 -4
  33. package/lib/__templates__/taro/_gitignore +0 -1
  34. package/lib/__templates__/vite/scripts/build.sh +1 -1
  35. package/lib/__templates__/vite/scripts/dev.sh +3 -11
  36. package/lib/__templates__/vite/scripts/prepare.sh +4 -1
  37. package/lib/cli.js +16 -147
  38. package/package.json +2 -2
  39. package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +0 -212
  40. package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +0 -212
  41. package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +0 -212
  42. package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +0 -212
  43. package/lib/__templates__/vite/scripts/prepare-node-modules.sh +0 -212
package/docs/deploy.md CHANGED
@@ -57,7 +57,7 @@ coze-dev deploy app rename <name> --app-id <app_id> --yes
57
57
  coze-dev deploy app delete --app-id <app_id> --yes
58
58
  coze-dev deploy app analytics|metrics --app-id <app_id> [--time-range <range>]
59
59
  coze-dev deploy app usage --app-id <app_id> --bill-month <YYYY-MM>
60
- coze-dev deploy [--lane <ppe_lane>] [--source-root <directory>] [--app-id <app_id>] [--application-type <type>] [--name <name>] [--deploy-config <json>] [--connector-id <id>]
60
+ coze-dev deploy [--lane <ppe_lane>] [--source-root <directory>] [--app-id <app_id>] [--application-type <type>] [--name <name>] [--connector-id <id>]
61
61
  coze-dev deploy status|list|online|rollback-check|cancel|rollback|stop|resume|pause
62
62
  coze-dev deploy logs|log-count|count|build-log|config
63
63
  coze-dev deploy domain list [--unit-type dev|prod]
@@ -76,17 +76,6 @@ coze-dev deploy mini-program status|bind|submit-code|unbind|auth|preview
76
76
  Application;类型不一致时创建新 Application、覆盖 `app_id` 并提示。也可用 `--project-id`
77
77
  或 `--app-id` 显式指定已有资源,显式指定时不会额外创建 Project。
78
78
 
79
- 部署预检默认返回服务端给出的 `deploy_config`。需要调整部署规格时,传入包含完整四个字段的
80
- `--deploy-config` JSON;预检会返回覆盖后的最终配置,确认部署时必须原样复用该参数:
81
-
82
- ```bash
83
- coze-dev deploy --source-root . \
84
- --deploy-config '{"cpu":4,"memory_mb":8192,"max_instance":2,"max_concurrency":100}'
85
- ```
86
-
87
- CPU 与内存必须使用固定组合:`1/2048`、`4/8192`、`8/16384`、`16/32768`;
88
- `max_instance` 为 1–100,`max_concurrency` 为 10–1000。四个值均为整数。
89
-
90
79
  首次部署的应用名称可通过 `--name` 指定;显式参数优先于 `.coze` 的
91
80
  `[project].name`。Pages 部署没有 `.coze` 时,CLI 会先生成最小配置再写入绑定。
92
81
 
@@ -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="$(cd "$(dirname "$0")/../.." && pwd)"
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
- bash "$ROOT_DIR/.cozeproj/scripts/prepare-node-modules.sh" --registry=https://registry.npmmirror.com
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
@@ -123,15 +123,11 @@ wait_port_connectable() {
123
123
  }
124
124
 
125
125
  # detached 出去的进程没人负责回收,超过这个时长就自己退出,避免端口与内存长期泄露。
126
- MAX_RUNTIME_SECONDS=3600
127
-
128
- timeout_watchdog_enabled() {
129
- [[ -z "${COZE_EVAL:-}" && -z "${COZE_PROJECT_TYPE:-}" ]]
130
- }
126
+ MAX_RUNTIME_SECONDS=1200
131
127
 
132
128
  # 真正被 detach 的是这层 bash wrapper:它是进程组 leader,组内 watchdog 到点回收整组
133
129
  # (wrapper -> pnpm -> expo/node);被包的进程自己先退出时也顺手清空进程组,不留残余。
134
- RUN_WITH_TIMEOUT="$(declare -f timeout_watchdog_enabled)"'
130
+ RUN_WITH_TIMEOUT='
135
131
  timeout_seconds=$1
136
132
  shift
137
133
 
@@ -139,7 +135,6 @@ shift
139
135
  child_pid=$!
140
136
 
141
137
  # 先忽略 TERM,才能在向整组发 TERM(自己也在组里)之后存活下来补一发 KILL。
142
- if timeout_watchdog_enabled; then
143
138
  ( trap "" TERM
144
139
  sleep "${timeout_seconds}"
145
140
  echo "[dev] 后台进程运行超过 ${timeout_seconds}s,回收进程组 $$。"
@@ -147,7 +142,6 @@ if timeout_watchdog_enabled; then
147
142
  sleep 5
148
143
  kill -KILL -- "-$$" 2>/dev/null || true
149
144
  ) &
150
- fi
151
145
 
152
146
  wait "${child_pid}"
153
147
  kill -KILL -- "-$$" 2>/dev/null || true
@@ -296,9 +290,7 @@ if [ -z "${EXPO_PID}" ]; then
296
290
  fi
297
291
 
298
292
  echo "所有服务已启动。Server PID: ${SERVER_PID}, Expo PID: ${EXPO_PID}"
299
- if timeout_watchdog_enabled; then
300
- echo "两个服务均在 ${MAX_RUNTIME_SECONDS}s 后自动退出。"
301
- fi
293
+ echo "两个服务均在 ${MAX_RUNTIME_SECONDS}s 后自动退出。"
302
294
 
303
295
  echo "检查 Server 服务端口:$SERVER_HOST:$SERVER_PORT"
304
296
  if wait_port_connectable "$SERVER_HOST" "$SERVER_PORT" 10 2; then
@@ -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="$(cd "$(dirname "$0")/../.." && pwd)"
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
- bash "$ROOT_DIR/.cozeproj/scripts/prepare-node-modules.sh" --registry=https://registry.npmmirror.com || error "Node 依赖安装失败"
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
- type ViewStyle,
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
- const createEnhancedContentStyle = (
109
- contentContainerStyle: ScrollViewProps['contentContainerStyle'],
110
- ) => {
111
- const mergedStyle = StyleSheet.flatten(contentContainerStyle) ?? {};
112
- const currentPaddingBottom =
113
- typeof mergedStyle.paddingBottom === 'number'
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
- return [
118
- {
119
- ...mergedStyle,
120
- paddingBottom: currentPaddingBottom + extraPadding,
121
- },
122
- ];
123
- };
101
+ // 合并 paddingBottom (安全区 + 额外留白)
102
+ const enhancedContentStyle = [{ ...merged, paddingBottom: currentPB + extraPadding }];
124
103
 
125
- const createKeyboardAwareProps = <Props extends NativeScrollableProps>(
126
- childProps: Props,
127
- ) => ({
128
- ...childProps,
129
- contentContainerStyle: createEnhancedContentStyle(
130
- childProps.contentContainerStyle,
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
- const childProps = element.props as ScrollViewProps;
155
- return (
156
- <KeyboardAwareScrollView {...createKeyboardAwareProps(childProps)} />
157
- );
125
+ return <KeyboardAwareScrollView {...commonProps} />;
158
126
  }
159
127
 
160
128
  if (t === FlatList) {
161
- const childProps = element.props as FlatListProps<unknown>;
162
- return <KeyboardAwareFlatList {...createKeyboardAwareProps(childProps)} />;
129
+ return <KeyboardAwareFlatList {...commonProps} />;
163
130
  }
164
131
 
165
132
  if (t === SectionList) {
166
- const childProps = element.props as SectionListProps<unknown>;
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: createEnhancedContentStyle(
176
- childProps.contentContainerStyle,
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: GestureResponderEvent) => {
342
+ const handlePress = (event: Parameters<NonNullable<React.ComponentProps<typeof Button>['onPress']>>[0]) => {
347
343
  if (hide && id) {
348
344
  hide(id);
349
345
  }
@@ -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: never[]) => unknown>(
111
+ function useCallbackRef<T extends (...args: unknown[]) => unknown>(
112
112
  callback: T | undefined
113
113
  ): T {
114
114
  const callbackRef = useRef(callback);
@@ -0,0 +1,15 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "next/babel",
5
+ {
6
+ "preset-react": {
7
+ "development": true
8
+ }
9
+ }
10
+ ]
11
+ ],
12
+ "plugins": [
13
+ "@react-dev-inspector/babel-plugin"
14
+ ]
15
+ }
@@ -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 (trailing slash prunes the whole
46
- // directory instead of walking into it):
47
- '.next/',
48
- 'out/',
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 --cache --cache-location node_modules/.cache/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.1.1",
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.3"
101
+ "sharp": "^0.35.4"
99
102
  }
100
103
  }
101
104
  }