@coze-arch/cli 0.0.1-alpha.81a3cf → 0.0.1-alpha.8389e1

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 (91) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +30 -21
  2. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +2 -2
  3. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +2 -2
  4. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +21 -2
  5. package/lib/__templates__/expo/README.md +4 -2
  6. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  7. package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
  8. package/lib/__templates__/expo/client/app.config.ts +4 -3
  9. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  10. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  11. package/lib/__templates__/expo/client/constants/theme.ts +21 -698
  12. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  13. package/lib/__templates__/expo/client/eslint.config.mjs +33 -10
  14. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  15. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  16. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  17. package/lib/__templates__/expo/client/package.json +3 -1
  18. package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
  19. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
  20. package/lib/__templates__/expo/client/utils/index.ts +22 -0
  21. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  22. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  23. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  24. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  25. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  26. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  27. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  28. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  29. package/lib/__templates__/expo/package.json +3 -0
  30. package/lib/__templates__/expo/patches/expo@54.0.32.patch +45 -0
  31. package/lib/__templates__/expo/pnpm-lock.yaml +1211 -2702
  32. package/lib/__templates__/expo/server/build.js +21 -0
  33. package/lib/__templates__/expo/server/package.json +2 -2
  34. package/lib/__templates__/expo/server/src/index.ts +2 -1
  35. package/lib/__templates__/nextjs/.babelrc +15 -0
  36. package/lib/__templates__/nextjs/next.config.ts +2 -2
  37. package/lib/__templates__/nextjs/package.json +9 -1
  38. package/lib/__templates__/nextjs/pnpm-lock.yaml +2603 -1728
  39. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
  40. package/lib/__templates__/nextjs/src/app/page.tsx +17 -61
  41. package/lib/__templates__/nextjs/template.config.js +5 -5
  42. package/lib/__templates__/taro/.coze +14 -0
  43. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  44. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +13 -0
  45. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +17 -0
  46. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +58 -0
  47. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  48. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +1 -0
  49. package/lib/__templates__/taro/README.md +687 -0
  50. package/lib/__templates__/taro/_gitignore +40 -0
  51. package/lib/__templates__/taro/_npmrc +18 -0
  52. package/lib/__templates__/taro/babel.config.js +12 -0
  53. package/lib/__templates__/taro/config/dev.ts +9 -0
  54. package/lib/__templates__/taro/config/index.ts +173 -0
  55. package/lib/__templates__/taro/config/prod.ts +35 -0
  56. package/lib/__templates__/taro/eslint.config.mjs +57 -0
  57. package/lib/__templates__/taro/key/private.appid.key +0 -0
  58. package/lib/__templates__/taro/package.json +95 -0
  59. package/lib/__templates__/taro/pnpm-lock.yaml +22430 -0
  60. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  61. package/lib/__templates__/taro/project.config.json +15 -0
  62. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  63. package/lib/__templates__/taro/server/package.json +38 -0
  64. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  65. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  66. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  67. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  68. package/lib/__templates__/taro/server/src/main.ts +37 -0
  69. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  70. package/lib/__templates__/taro/src/app.config.ts +11 -0
  71. package/lib/__templates__/taro/src/app.css +52 -0
  72. package/lib/__templates__/taro/src/app.ts +14 -0
  73. package/lib/__templates__/taro/src/index.html +20 -0
  74. package/lib/__templates__/taro/src/network.ts +39 -0
  75. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  76. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  77. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  78. package/lib/__templates__/taro/src/utils/h5-styles.ts +22 -0
  79. package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
  80. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  81. package/lib/__templates__/taro/template.config.js +68 -0
  82. package/lib/__templates__/taro/tsconfig.json +29 -0
  83. package/lib/__templates__/taro/types/global.d.ts +32 -0
  84. package/lib/__templates__/templates.json +10 -15
  85. package/lib/__templates__/vite/package.json +6 -1
  86. package/lib/__templates__/vite/pnpm-lock.yaml +504 -982
  87. package/lib/__templates__/vite/src/main.ts +17 -48
  88. package/lib/__templates__/vite/template.config.js +6 -4
  89. package/lib/cli.js +819 -105
  90. package/package.json +1 -1
  91. package/lib/__templates__/expo/client/app/demo.tsx +0 -1
@@ -1,4 +1,5 @@
1
1
  import type { Metadata } from 'next';
2
+ import { Inspector } from 'react-dev-inspector';
2
3
  import './globals.css';
3
4
 
4
5
  export const metadata: Metadata = {
@@ -60,11 +61,12 @@ export default function RootLayout({
60
61
  }: Readonly<{
61
62
  children: React.ReactNode;
62
63
  }>) {
64
+ const isDev = process.env.NODE_ENV === 'development';
65
+
63
66
  return (
64
67
  <html lang="en">
65
- <body
66
- className={`antialiased`}
67
- >
68
+ <body className={`antialiased`}>
69
+ {isDev && <Inspector />}
68
70
  {children}
69
71
  </body>
70
72
  </html>
@@ -1,6 +1,4 @@
1
1
  import type { Metadata } from 'next';
2
- import Image from 'next/image';
3
- import { Button } from '@/components/ui/button';
4
2
 
5
3
  export const metadata: Metadata = {
6
4
  title: '扣子编程 - AI 开发伙伴',
@@ -9,68 +7,26 @@ export const metadata: Metadata = {
9
7
 
10
8
  export default function Home() {
11
9
  return (
12
- <div className="flex min-h-screen items-center justify-center bg-background text-foreground transition-colors duration-300 dark:bg-background dark:text-foreground">
10
+ <div className="flex h-full items-center justify-center bg-background text-foreground transition-colors duration-300 dark:bg-background dark:text-foreground overflow-hidden">
13
11
  {/* 主容器 */}
14
- <main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between px-16 py-32 sm:items-start">
15
- {/* 头部:Logo 产品名称 */}
16
- <div className="flex items-center gap-3">
17
- <Image
18
- className="dark:invert"
19
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/hkpzboz/coze_logo.png"
12
+ <main className="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
13
+ <div className="flex flex-col items-center justify-between gap-4">
14
+ <img
15
+ src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
20
16
  alt="扣子编程 Logo"
21
- width={40}
22
- height={40}
17
+ width={156}
18
+ height={130}
23
19
  />
24
- <span className="text-xl font-bold tracking-tight text-foreground dark:text-foreground">
25
- 扣子编程
26
- </span>
27
- </div>
28
-
29
- {/* 中间内容区:主标题和副标题 */}
30
- <div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
31
- <h1 className="max-w-xl text-4xl font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
32
- 扣子编程,你的 AI 开发伙伴已就位
33
- </h1>
34
- <p className="max-w-2xl text-lg leading-8 text-muted-foreground dark:text-muted-foreground">
35
- 当前是空白入口文件,项目正在开发中,请稍候...
36
- <br />
37
- 开发完成后界面将自动更新。如未自动更新成功,可以手动点击右上角刷新或重启按钮查看效果。
38
- </p>
39
- </div>
40
-
41
- {/* 底部按钮区 */}
42
- <div className="flex w-full flex-col gap-4 text-base font-medium sm:w-auto sm:flex-row">
43
- {/* 按钮 1:前往首页 */}
44
- <Button
45
- asChild
46
- variant="default"
47
- size="lg"
48
- className="h-12 min-w-[160px] rounded-full px-8"
49
- >
50
- <a
51
- href="https://code.coze.cn/"
52
- target="_blank"
53
- rel="noopener noreferrer"
54
- >
55
- 前往首页
56
- </a>
57
- </Button>
58
-
59
- {/* 按钮 2:查看文档 */}
60
- <Button
61
- asChild
62
- variant="outline"
63
- size="lg"
64
- className="h-12 min-w-[160px] rounded-full px-8"
65
- >
66
- <a
67
- href="https://docs.coze.cn/"
68
- target="_blank"
69
- rel="noopener noreferrer"
70
- >
71
- 查看文档
72
- </a>
73
- </Button>
20
+ <div>
21
+ <div className="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
22
+ <h1 className="max-w-xl text-base font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
23
+ 应用开发中
24
+ </h1>
25
+ <p className="max-w-2xl text-sm-14 leading-8 text-muted-foreground dark:text-muted-foreground">
26
+ 请稍后,页面即将呈现
27
+ </p>
28
+ </div>
29
+ </div>
74
30
  </div>
75
31
  </main>
76
32
  </div>
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- import { execSync } from 'child_process';
3
+
4
4
  import { resolve } from 'path';
5
5
 
6
6
 
@@ -70,10 +70,10 @@ const config = {
70
70
  console.log(`${cmd}`);
71
71
  try {
72
72
  const projectRoot = resolve(outputPath);
73
- execSync(cmd, {
74
- cwd: projectRoot,
75
- stdio: 'inherit',
76
- });
73
+ // execSync(cmd, {
74
+ // cwd: projectRoot,
75
+ // stdio: 'inherit',
76
+ // });
77
77
  console.log('✓ coze-coding-dev-sdk updated successfully');
78
78
  } catch (error) {
79
79
  console.error('✗ Failed to update coze-coding-dev-sdk:', error);
@@ -0,0 +1,14 @@
1
+ [project]
2
+ entrypoint = "server.js"
3
+ requires = ["nodejs-24"]
4
+
5
+ [dev]
6
+ build = ["bash", ".cozeproj/scripts/dev_build.sh"]
7
+ run = ["bash", ".cozeproj/scripts/dev_run.sh"]
8
+ deps = ["git"] # -> apt install git
9
+ pack = ["bash", "./scripts/pack.sh"]
10
+
11
+ [deploy]
12
+ build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
13
+ run = ["bash", ".cozeproj/scripts/deploy_run.sh"]
14
+ deps = ["git"] # -> apt install git
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ cd "${COZE_WORKSPACE_PATH}"
5
+ if [ -f "./.cozeproj/init_env.sh" ]; then
6
+ echo "⚙️ Initializing environment..."
7
+ # 使用 bash 执行,确保即使没有 x 权限也能跑
8
+ bash ./.cozeproj/init_env.sh
9
+ else
10
+ echo "⚠️ Warning: init_env.sh not found, skipping environment init."
11
+ fi
12
+ echo "Installing dependencies..."
13
+ # 安装所有依赖(包含 Taro 核心和 React)
14
+ pnpm install
15
+
16
+ echo "Building the Taro project..."
17
+ pnpm build
18
+
19
+ echo "Build completed successfully! Assets are in /dist"
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ start_service() {
5
+ cd "${COZE_WORKSPACE_PATH}/server/dist"
6
+
7
+ echo "Starting Static File Server on port 3000 for deploy..."
8
+
9
+ node ./main.js
10
+ }
11
+
12
+ echo "Starting HTTP service on port 3000 for deploy..."
13
+ start_service
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ cd "${COZE_WORKSPACE_PATH}"
5
+ if [ -f "./.cozeproj/init_env.sh" ]; then
6
+ echo "⚙️ Initializing environment..."
7
+ # 使用 bash 执行,确保即使没有 x 权限也能跑
8
+ bash ./.cozeproj/init_env.sh
9
+ else
10
+ echo "⚠️ Warning: init_env.sh not found, skipping environment init."
11
+ fi
12
+
13
+ echo "Installing dependencies..."
14
+ pnpm install --offline --frozen-lockfile --reporter=silent || \
15
+ pnpm install --reporter=silent
16
+
17
+ echo "Dependencies installed successfully!"
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+
3
+ echo "⚙️ dev_run.sh 开始运行"
4
+ set -Eeuo pipefail
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ kill_port_if_listening() {
9
+ local port=$1
10
+ local pids
11
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
12
+ if [[ -z "${pids}" ]]; then
13
+ echo "Port ${port} is free."
14
+ return
15
+ fi
16
+ echo "Port ${port} in use by PIDs: ${pids} (SIGKILL)"
17
+ echo "${pids}" | xargs -I {} kill -9 {}
18
+ sleep 1
19
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
20
+ if [[ -n "${pids}" ]]; then
21
+ echo "Warning: port ${port} still busy after SIGKILL, PIDs: ${pids}"
22
+ else
23
+ echo "Port ${port} cleared."
24
+ fi
25
+ }
26
+
27
+ start_service() {
28
+ cd "${COZE_WORKSPACE_PATH}"
29
+
30
+ # ---------------------------------------------------------
31
+ # 0. 动态注入环境变量
32
+ # ---------------------------------------------------------
33
+ if [ -n "$COZE_PROJECT_DOMAIN_DEFAULT" ]; then
34
+ export PROJECT_DOMAIN="$COZE_PROJECT_DOMAIN_DEFAULT"
35
+ echo "✅ 环境变量已动态注入: PROJECT_DOMAIN=$PROJECT_DOMAIN"
36
+ else
37
+ echo "⚠️ 警告: COZE_PROJECT_DOMAIN_DEFAULT 未设置,使用 .env.local 中的配置"
38
+ fi
39
+
40
+ # ---------------------------------------------------------
41
+ # 启动 Taro H5 和 NestJS Server
42
+ # ---------------------------------------------------------
43
+ echo "Starting Taro H5 Dev Server and NestJS Server..."
44
+
45
+ # ⚠️ 重要:为了让 Taro 使用平台动态分配的端口
46
+ export PORT=${DEPLOY_RUN_PORT}
47
+
48
+ exec pnpm dev
49
+ }
50
+
51
+ SERVER_PORT=<%= serverPort %>
52
+
53
+ echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
54
+ kill_port_if_listening "${DEPLOY_RUN_PORT}"
55
+ echo "Clearing port ${SERVER_PORT} (server) before start."
56
+ kill_port_if_listening "${SERVER_PORT}"
57
+ echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
58
+ start_service
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ cd "${COZE_WORKSPACE_PATH}"
4
+
5
+ echo "✅ 初始化完成"
@@ -0,0 +1 @@
1
+ pnpm build:weapp