@coze-arch/cli 0.0.1-alpha.ef0249 → 0.0.1-alpha.ef8b63

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 +25 -16
  2. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
  3. package/lib/__templates__/expo/README.md +2 -2
  4. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  5. package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
  6. package/lib/__templates__/expo/client/app.config.ts +2 -2
  7. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  8. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  9. package/lib/__templates__/expo/client/constants/theme.ts +21 -698
  10. package/lib/__templates__/expo/client/eslint.config.mjs +20 -0
  11. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  12. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  13. package/lib/__templates__/expo/client/metro.config.js +3 -0
  14. package/lib/__templates__/expo/client/package.json +36 -34
  15. package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
  16. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1886 -2483
  17. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +20 -1
  18. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  19. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  20. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  21. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  22. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  23. package/lib/__templates__/expo/package.json +3 -0
  24. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  25. package/lib/__templates__/expo/pnpm-lock.yaml +1318 -2636
  26. package/lib/__templates__/expo/server/package.json +9 -7
  27. package/lib/__templates__/expo/server/src/index.ts +1 -0
  28. package/lib/__templates__/expo/template.config.js +56 -0
  29. package/lib/__templates__/native-static/.coze +11 -0
  30. package/lib/__templates__/native-static/index.html +33 -0
  31. package/lib/__templates__/native-static/styles/main.css +136 -0
  32. package/lib/__templates__/native-static/template.config.js +22 -0
  33. package/lib/__templates__/nextjs/.babelrc +15 -0
  34. package/lib/__templates__/nextjs/package.json +6 -1
  35. package/lib/__templates__/nextjs/pnpm-lock.yaml +2063 -926
  36. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
  37. package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
  38. package/lib/__templates__/nextjs/template.config.js +49 -14
  39. package/lib/__templates__/taro/.coze +14 -0
  40. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  41. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  42. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  43. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  44. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  45. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  46. package/lib/__templates__/taro/README.md +751 -0
  47. package/lib/__templates__/taro/_gitignore +40 -0
  48. package/lib/__templates__/taro/_npmrc +18 -0
  49. package/lib/__templates__/taro/babel.config.js +12 -0
  50. package/lib/__templates__/taro/config/dev.ts +9 -0
  51. package/lib/__templates__/taro/config/index.ts +174 -0
  52. package/lib/__templates__/taro/config/prod.ts +35 -0
  53. package/lib/__templates__/taro/eslint.config.mjs +80 -0
  54. package/lib/__templates__/taro/key/private.appid.key +0 -0
  55. package/lib/__templates__/taro/package.json +97 -0
  56. package/lib/__templates__/taro/pnpm-lock.yaml +22706 -0
  57. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  58. package/lib/__templates__/taro/project.config.json +15 -0
  59. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  60. package/lib/__templates__/taro/server/package.json +40 -0
  61. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  62. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  63. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  64. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  65. package/lib/__templates__/taro/server/src/main.ts +49 -0
  66. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  67. package/lib/__templates__/taro/src/app.config.ts +11 -0
  68. package/lib/__templates__/taro/src/app.css +52 -0
  69. package/lib/__templates__/taro/src/app.tsx +9 -0
  70. package/lib/__templates__/taro/src/index.html +39 -0
  71. package/lib/__templates__/taro/src/network.ts +39 -0
  72. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  73. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  74. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  75. package/lib/__templates__/taro/src/presets/h5-container.tsx +17 -0
  76. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +167 -0
  77. package/lib/__templates__/taro/src/presets/h5-styles.ts +88 -0
  78. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  79. package/lib/__templates__/taro/src/presets/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 +43 -0
  85. package/lib/__templates__/vite/package.json +5 -1
  86. package/lib/__templates__/vite/pnpm-lock.yaml +146 -1659
  87. package/lib/__templates__/vite/src/main.ts +17 -47
  88. package/lib/__templates__/vite/template.config.js +49 -14
  89. package/lib/__templates__/vite/vite.config.ts +1 -0
  90. package/lib/cli.js +838 -130
  91. package/package.json +2 -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,5 @@
1
1
  import type { Metadata } from 'next';
2
2
  import Image from 'next/image';
3
- import { Button } from '@/components/ui/button';
4
3
 
5
4
  export const metadata: Metadata = {
6
5
  title: '扣子编程 - AI 开发伙伴',
@@ -9,68 +8,27 @@ export const metadata: Metadata = {
9
8
 
10
9
  export default function Home() {
11
10
  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">
11
+ <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 min-h-screen">
13
12
  {/* 主容器 */}
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
- src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/favicon.svg"
13
+ <main className="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
14
+ <div className="flex flex-col items-center justify-between gap-4">
15
+ <Image
16
+ className="dark:invert"
17
+ src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
19
18
  alt="扣子编程 Logo"
20
- width={40}
21
- height={40}
22
- unoptimized
19
+ width={156}
20
+ height={130}
23
21
  />
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>
22
+ <div>
23
+ <div className="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
24
+ <h1 className="max-w-xl text-base font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
25
+ 应用开发中
26
+ </h1>
27
+ <p className="max-w-2xl text-sm-14 leading-8 text-muted-foreground dark:text-muted-foreground">
28
+ 请稍后,页面即将呈现
29
+ </p>
30
+ </div>
31
+ </div>
74
32
  </div>
75
33
  </main>
76
34
  </div>
@@ -1,7 +1,8 @@
1
1
 
2
2
 
3
-
4
- import { resolve } from 'path';
3
+ import { spawn } from 'child_process';
4
+ import { resolve, join, basename } from 'path';
5
+ import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
5
6
 
6
7
 
7
8
 
@@ -52,32 +53,66 @@ const config = {
52
53
  return context;
53
54
  },
54
55
 
55
- onAfterRender: async (context, outputPath) => {
56
+ onAfterRender: async (_context, outputPath) => {
56
57
  console.log(`\nProject created at: ${outputPath}`);
57
58
  console.log('\nConfiguration:');
58
59
  console.log(' - Framework: Next.js');
59
60
  console.log(' - TypeScript: enabled');
60
61
  console.log(' - App Router: enabled');
61
- console.log(` - Port: ${context.port}`);
62
+ console.log(` - Port: ${_context.port}`);
63
+ },
62
64
 
63
- // Skip pnpm add in test environment to avoid monorepo workspace issues
65
+ onComplete: async (_context, outputPath) => {
66
+ // Skip pnpm update in test environment to avoid monorepo workspace issues
64
67
  if (process.env.NODE_ENV === 'test') {
65
68
  console.log('⊘ Skipping dependency update in test environment');
66
69
  return;
67
70
  }
68
71
 
69
- const cmd = `pnpm add coze-coding-dev-sdk@"^0.7.0"`;
70
- console.log(`${cmd}`);
72
+ const cmd = 'pnpm';
73
+ const args = ['update', 'coze-coding-dev-sdk@^0.7.0'];
74
+ console.log(
75
+ `\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
76
+ );
77
+
71
78
  try {
72
79
  const projectRoot = resolve(outputPath);
73
- // execSync(cmd, {
74
- // cwd: projectRoot,
75
- // stdio: 'inherit',
76
- // });
77
- console.log('✓ coze-coding-dev-sdk updated successfully');
80
+
81
+ // Determine log directory
82
+ const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
83
+ mkdirSync(logDir, { recursive: true });
84
+
85
+ // Use project name in log file to avoid conflicts
86
+ const projectName = basename(projectRoot);
87
+ const logFile = join(logDir, `${projectName}-init.log`);
88
+
89
+ // Write log header
90
+ const timestamp = new Date().toISOString();
91
+ appendFileSync(
92
+ logFile,
93
+ `\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
94
+ );
95
+
96
+ // Open log file for appending
97
+ const logFd = openSync(logFile, 'a');
98
+
99
+ // Spawn in detached mode
100
+ const child = spawn(cmd, args, {
101
+ cwd: projectRoot,
102
+ detached: true,
103
+ stdio: ['ignore', logFd, logFd],
104
+ });
105
+
106
+ child.unref();
107
+ closeSync(logFd);
108
+
109
+ console.log(
110
+ '✓ coze-coding-dev-sdk update triggered (running in background)',
111
+ );
112
+ console.log(` Log file: ${logFile}`);
78
113
  } catch (error) {
79
- console.error('✗ Failed to update coze-coding-dev-sdk:', error);
80
- throw error;
114
+ console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
115
+ console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
81
116
  }
82
117
  },
83
118
  };
@@ -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", ".cozeproj/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/scripts/init_env.sh" ]; then
6
+ echo "⚙️ Initializing environment..."
7
+ # 使用 bash 执行,确保即使没有 x 权限也能跑
8
+ bash ./.cozeproj/scripts/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,14 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ start_service() {
5
+ cd "${COZE_WORKSPACE_PATH}/server/dist"
6
+
7
+ local port="${DEPLOY_RUN_PORT:-3000}"
8
+ echo "Starting Static File Server on port ${port} for deploy..."
9
+
10
+ node ./main.js -p "${port}"
11
+ }
12
+
13
+ echo "Starting HTTP service for deploy..."
14
+ start_service
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
@@ -0,0 +1,151 @@
1
+ #!/bin/bash
2
+ echo "⚙️ dev_run.sh 开始运行"
3
+ set -Eeuo pipefail
4
+
5
+ cd "${COZE_WORKSPACE_PATH}"
6
+
7
+ # ---------------------------------------------------------
8
+ # PID 文件,用于追踪上一次启动的进程树
9
+ # ---------------------------------------------------------
10
+ PID_FILE="/tmp/coze-dev-run.pid"
11
+
12
+ # ---------------------------------------------------------
13
+ # 工具函数
14
+ # ---------------------------------------------------------
15
+ kill_process_tree() {
16
+ local pid=$1
17
+ local children
18
+ children=$(pgrep -P "${pid}" 2>/dev/null || true)
19
+ for child in ${children}; do
20
+ kill_process_tree "${child}"
21
+ done
22
+ if kill -0 "${pid}" 2>/dev/null; then
23
+ echo "Killing PID ${pid}"
24
+ kill -9 "${pid}" 2>/dev/null || true
25
+ fi
26
+ }
27
+
28
+ kill_port_if_listening() {
29
+ local port=$1
30
+ local pids
31
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
32
+ if [[ -z "${pids}" ]]; then
33
+ echo "Port ${port} is free."
34
+ return
35
+ fi
36
+ echo "Port ${port} in use by PIDs: ${pids}"
37
+ for pid in ${pids}; do
38
+ kill_process_tree "${pid}"
39
+ done
40
+ sleep 1
41
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
42
+ if [[ -n "${pids}" ]]; then
43
+ echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
44
+ else
45
+ echo "Port ${port} cleared."
46
+ fi
47
+ }
48
+
49
+ # ---------------------------------------------------------
50
+ # 1. 清理上一次运行残留的整棵进程树
51
+ # ---------------------------------------------------------
52
+ cleanup_previous_run() {
53
+ # 1a. 通过 PID 文件清理上次的进程树
54
+ if [[ -f "${PID_FILE}" ]]; then
55
+ local old_pid
56
+ old_pid=$(cat "${PID_FILE}" 2>/dev/null || true)
57
+ if [[ -n "${old_pid}" ]] && kill -0 "${old_pid}" 2>/dev/null; then
58
+ echo "🧹 Killing previous dev process tree (root PID: ${old_pid})..."
59
+ kill_process_tree "${old_pid}"
60
+ fi
61
+ rm -f "${PID_FILE}"
62
+ fi
63
+
64
+ # 1b. 兜底:按特征匹配清理所有残留的相关进程(排除自身)
65
+ echo "🧹 Cleaning up any orphaned dev processes..."
66
+ local patterns=(
67
+ "pnpm dev"
68
+ "concurrently.*dev:web.*dev:server"
69
+ "nest start --watch"
70
+ "taro build --type h5 --watch"
71
+ "node --enable-source-maps.*/workspace/projects/server/dist/main"
72
+ "esbuild --service.*--ping"
73
+ )
74
+ for pattern in "${patterns[@]}"; do
75
+ local pids
76
+ pids=$(pgrep -f "${pattern}" 2>/dev/null || true)
77
+ for pid in ${pids}; do
78
+ # 不杀自己和自己的父进程链
79
+ if [[ "${pid}" != "$$" ]] && [[ "${pid}" != "${PPID}" ]]; then
80
+ echo " Killing orphan PID ${pid} matching '${pattern}'"
81
+ kill -9 "${pid}" 2>/dev/null || true
82
+ fi
83
+ done
84
+ done
85
+ sleep 1
86
+ }
87
+
88
+ # ---------------------------------------------------------
89
+ # 2. 安装依赖
90
+ # ---------------------------------------------------------
91
+ echo "📦 Installing dependencies..."
92
+ pnpm install
93
+ echo "✅ Dependencies installed successfully!"
94
+
95
+ # ---------------------------------------------------------
96
+ # 3. 清理旧进程 + 端口
97
+ # ---------------------------------------------------------
98
+ SERVER_PORT=3000
99
+
100
+ cleanup_previous_run
101
+
102
+ echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
103
+ kill_port_if_listening "${DEPLOY_RUN_PORT}"
104
+ echo "Clearing port ${SERVER_PORT} (server) before start."
105
+ kill_port_if_listening "${SERVER_PORT}"
106
+
107
+ # ---------------------------------------------------------
108
+ # 4. 退出时自动清理子进程(信号 trap)
109
+ # ---------------------------------------------------------
110
+ cleanup_on_exit() {
111
+ echo "🛑 dev_run.sh exiting, cleaning up child processes..."
112
+ # 杀掉当前脚本的所有子进程
113
+ kill -- -$$ 2>/dev/null || true
114
+ rm -f "${PID_FILE}"
115
+ exit 0
116
+ }
117
+ trap cleanup_on_exit EXIT INT TERM HUP
118
+
119
+ # ---------------------------------------------------------
120
+ # 5. 启动服务
121
+ # ---------------------------------------------------------
122
+ start_service() {
123
+ cd "${COZE_WORKSPACE_PATH}"
124
+
125
+ # 动态注入环境变量
126
+ if [ -n "${COZE_PROJECT_DOMAIN_DEFAULT:-}" ]; then
127
+ export PROJECT_DOMAIN="$COZE_PROJECT_DOMAIN_DEFAULT"
128
+ echo "✅ 环境变量已动态注入: PROJECT_DOMAIN=$PROJECT_DOMAIN"
129
+ else
130
+ echo "⚠️ 警告: COZE_PROJECT_DOMAIN_DEFAULT 未设置,使用 .env.local 中的配置"
131
+ fi
132
+
133
+ # 启动 Taro H5 和 NestJS Server
134
+ echo "Starting Taro H5 Dev Server and NestJS Server..."
135
+
136
+ export PORT=${DEPLOY_RUN_PORT}
137
+ rm -f /tmp/coze-logs/dev.log
138
+ mkdir -p /tmp/coze-logs
139
+
140
+ # 后台启动并记录 PID
141
+ pnpm dev 2>&1 | tee /tmp/coze-logs/dev.log &
142
+ local dev_pid=$!
143
+ echo "${dev_pid}" > "${PID_FILE}"
144
+ echo "📝 Dev process started with PID: ${dev_pid} (saved to ${PID_FILE})"
145
+
146
+ # 前台等待,保证 trap 能正常捕获信号
147
+ wait "${dev_pid}" || true
148
+ }
149
+
150
+ echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
151
+ start_service
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ cd "${COZE_WORKSPACE_PATH}"
4
+
5
+ echo "✅ 初始化完成"
@@ -0,0 +1,24 @@
1
+ # build_weapp.sh - 通过 PID 文件精确杀掉自己上次的构建进程
2
+ export OUTPUT_ROOT=dist
3
+ PID_FILE="/tmp/coze-build_weapp.pid"
4
+
5
+ # 杀掉上次的构建进程组
6
+ if [ -f "$PID_FILE" ]; then
7
+ OLD_PID=$(cat "$PID_FILE")
8
+ if kill -0 "$OLD_PID" 2>/dev/null; then
9
+ echo "正在终止上次的构建进程组 (PID: $OLD_PID)..."
10
+ # 关键:kill 负数 PID = 杀掉整个进程组
11
+ kill -9 -"$OLD_PID" 2>/dev/null
12
+ sleep 1
13
+ fi
14
+ rm -f "$PID_FILE"
15
+ fi
16
+
17
+ # 用 setsid 创建新的进程组,方便下次整组杀掉
18
+ setsid pnpm build:weapp &
19
+ echo $! > "$PID_FILE"
20
+
21
+ echo "构建已启动 (PID: $(cat $PID_FILE))"
22
+
23
+ wait $!
24
+ rm -f "$PID_FILE"