@coze-arch/cli 0.0.1-alpha.26f31a → 0.0.1-alpha.285680

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 (98) 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 +46 -0
  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 +15 -12
  8. package/lib/__templates__/expo/client/app/index.tsx +1 -1
  9. package/lib/__templates__/expo/client/app.config.ts +4 -3
  10. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  11. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  12. package/lib/__templates__/expo/client/constants/theme.ts +23 -700
  13. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  14. package/lib/__templates__/expo/client/eslint.config.mjs +33 -10
  15. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  16. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  17. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  18. package/lib/__templates__/expo/client/package.json +36 -34
  19. package/lib/__templates__/expo/client/screens/{home → demo}/index.tsx +7 -3
  20. package/lib/__templates__/expo/client/screens/{home → demo}/styles.ts +10 -6
  21. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
  22. package/lib/__templates__/expo/client/utils/index.ts +22 -0
  23. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  24. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  25. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  26. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  27. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  28. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  29. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  30. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  31. package/lib/__templates__/expo/package.json +3 -0
  32. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  33. package/lib/__templates__/expo/pnpm-lock.yaml +1270 -2614
  34. package/lib/__templates__/expo/server/build.js +21 -0
  35. package/lib/__templates__/expo/server/package.json +4 -3
  36. package/lib/__templates__/expo/server/src/index.ts +3 -1
  37. package/lib/__templates__/expo/template.config.js +56 -0
  38. package/lib/__templates__/nextjs/.babelrc +15 -0
  39. package/lib/__templates__/nextjs/_npmrc +1 -0
  40. package/lib/__templates__/nextjs/next.config.ts +3 -1
  41. package/lib/__templates__/nextjs/package.json +9 -1
  42. package/lib/__templates__/nextjs/pnpm-lock.yaml +2606 -1723
  43. package/lib/__templates__/nextjs/src/app/globals.css +10 -2
  44. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -14
  45. package/lib/__templates__/nextjs/src/app/page.tsx +17 -46
  46. package/lib/__templates__/nextjs/template.config.js +52 -11
  47. package/lib/__templates__/taro/.coze +14 -0
  48. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  49. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +13 -0
  50. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +17 -0
  51. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +58 -0
  52. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  53. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +1 -0
  54. package/lib/__templates__/taro/README.md +687 -0
  55. package/lib/__templates__/taro/_gitignore +40 -0
  56. package/lib/__templates__/taro/_npmrc +18 -0
  57. package/lib/__templates__/taro/babel.config.js +12 -0
  58. package/lib/__templates__/taro/config/dev.ts +9 -0
  59. package/lib/__templates__/taro/config/index.ts +173 -0
  60. package/lib/__templates__/taro/config/prod.ts +35 -0
  61. package/lib/__templates__/taro/eslint.config.mjs +57 -0
  62. package/lib/__templates__/taro/key/private.appid.key +0 -0
  63. package/lib/__templates__/taro/package.json +95 -0
  64. package/lib/__templates__/taro/pnpm-lock.yaml +22430 -0
  65. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  66. package/lib/__templates__/taro/project.config.json +15 -0
  67. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  68. package/lib/__templates__/taro/server/package.json +38 -0
  69. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  70. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  71. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  72. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  73. package/lib/__templates__/taro/server/src/main.ts +37 -0
  74. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  75. package/lib/__templates__/taro/src/app.config.ts +11 -0
  76. package/lib/__templates__/taro/src/app.css +52 -0
  77. package/lib/__templates__/taro/src/app.ts +14 -0
  78. package/lib/__templates__/taro/src/index.html +20 -0
  79. package/lib/__templates__/taro/src/network.ts +39 -0
  80. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  81. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  82. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  83. package/lib/__templates__/taro/src/utils/h5-styles.ts +22 -0
  84. package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
  85. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  86. package/lib/__templates__/taro/template.config.js +68 -0
  87. package/lib/__templates__/taro/tsconfig.json +29 -0
  88. package/lib/__templates__/taro/types/global.d.ts +32 -0
  89. package/lib/__templates__/templates.json +32 -0
  90. package/lib/__templates__/vite/_npmrc +1 -0
  91. package/lib/__templates__/vite/package.json +7 -1
  92. package/lib/__templates__/vite/pnpm-lock.yaml +2328 -180
  93. package/lib/__templates__/vite/src/main.ts +17 -48
  94. package/lib/__templates__/vite/template.config.js +63 -6
  95. package/lib/cli.js +902 -123
  96. package/package.json +1 -1
  97. package/lib/__templates__/expo/client/app/home.tsx +0 -1
  98. package/lib/__templates__/expo/client/assets/images/coze-logo.png +0 -0
@@ -6,8 +6,6 @@
6
6
  @theme inline {
7
7
  --color-background: var(--background);
8
8
  --color-foreground: var(--foreground);
9
- --font-sans: var(--font-geist-sans);
10
- --font-mono: var(--font-geist-mono);
11
9
  --color-sidebar-ring: var(--sidebar-ring);
12
10
  --color-sidebar-border: var(--sidebar-border);
13
11
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
@@ -44,6 +42,16 @@
44
42
  --radius-2xl: calc(var(--radius) + 8px);
45
43
  --radius-3xl: calc(var(--radius) + 12px);
46
44
  --radius-4xl: calc(var(--radius) + 16px);
45
+ --font-sans:
46
+ 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', ui-sans-serif,
47
+ system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
48
+ 'Helvetica Neue', Arial, sans-serif;
49
+ --font-mono:
50
+ ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
51
+ 'Courier New', monospace;
52
+ --font-serif:
53
+ 'Noto Serif SC', 'Songti SC', 'SimSun', ui-serif, Georgia, Cambria,
54
+ 'Times New Roman', Times, serif;
47
55
  }
48
56
 
49
57
  :root {
@@ -1,17 +1,7 @@
1
1
  import type { Metadata } from 'next';
2
- import { Geist, Geist_Mono } from 'next/font/google';
2
+ import { Inspector } from 'react-dev-inspector';
3
3
  import './globals.css';
4
4
 
5
- const geistSans = Geist({
6
- variable: '--font-geist-sans',
7
- subsets: ['latin'],
8
- });
9
-
10
- const geistMono = Geist_Mono({
11
- variable: '--font-geist-mono',
12
- subsets: ['latin'],
13
- });
14
-
15
5
  export const metadata: Metadata = {
16
6
  title: {
17
7
  default: '新应用 | 扣子编程',
@@ -71,11 +61,12 @@ export default function RootLayout({
71
61
  }: Readonly<{
72
62
  children: React.ReactNode;
73
63
  }>) {
64
+ const isDev = process.env.NODE_ENV === 'development';
65
+
74
66
  return (
75
67
  <html lang="en">
76
- <body
77
- className={`${geistSans.variable} ${geistMono.variable} antialiased`}
78
- >
68
+ <body className={`antialiased`}>
69
+ {isDev && <Inspector />}
79
70
  {children}
80
71
  </body>
81
72
  </html>
@@ -8,56 +8,27 @@ export const metadata: Metadata = {
8
8
 
9
9
  export default function Home() {
10
10
  return (
11
- <div className="flex min-h-screen items-center justify-center bg-white text-black transition-colors duration-300 dark:bg-black dark:text-white">
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">
12
12
  {/* 主容器 */}
13
- <main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between px-16 py-32 sm:items-start">
14
- {/* 头部:Logo 产品名称 */}
15
- <div className="flex items-center gap-3">
16
- <Image
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
17
16
  className="dark:invert"
18
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/hkpzboz/coze_logo.png"
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}
19
+ width={156}
20
+ height={130}
22
21
  />
23
- <span className="text-xl font-bold tracking-tight text-black dark:text-zinc-50">
24
- 扣子编程
25
- </span>
26
- </div>
27
-
28
- {/* 中间内容区:主标题和副标题 */}
29
- <div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
30
- <h1 className="max-w-xl text-4xl font-semibold leading-tight tracking-tight text-black dark:text-zinc-50">
31
- 扣子编程,你的 AI 开发伙伴已就位
32
- </h1>
33
- <p className="max-w-2xl text-lg leading-8 text-zinc-600 dark:text-zinc-400">
34
- 当前是空白入口文件,项目正在开发中,请稍候...
35
- <br />
36
- 开发完成后界面将自动更新。如未自动更新成功,可以手动点击右上角刷新或重启按钮查看效果。
37
- </p>
38
- </div>
39
-
40
- {/* 底部按钮区 */}
41
- <div className="flex w-full flex-col gap-4 text-base font-medium sm:w-auto sm:flex-row">
42
- {/* 按钮 1:前往首页 */}
43
- <a
44
- className="flex h-12 w-full min-w-[160px] items-center justify-center gap-2 rounded-full bg-black px-8 text-white transition-colors hover:bg-zinc-800 dark:bg-white dark:text-black dark:hover:bg-zinc-200 md:w-auto"
45
- href="https://code.coze.cn/"
46
- target="_blank"
47
- rel="noopener noreferrer"
48
- >
49
- 前往首页
50
- </a>
51
-
52
- {/* 按钮 2:查看文档 */}
53
- <a
54
- className="flex h-12 w-full min-w-[160px] items-center justify-center rounded-full border border-solid border-black/[.08] px-8 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-auto"
55
- href="https://docs.coze.cn/"
56
- target="_blank"
57
- rel="noopener noreferrer"
58
- >
59
- 查看文档
60
- </a>
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>
61
32
  </div>
62
33
  </main>
63
34
  </div>
@@ -1,7 +1,8 @@
1
1
 
2
2
 
3
- import { execSync } from 'child_process';
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,26 +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
+ },
64
+
65
+ onComplete: async (_context, outputPath) => {
66
+ // Skip pnpm update in test environment to avoid monorepo workspace issues
67
+ if (process.env.NODE_ENV === 'test') {
68
+ console.log('⊘ Skipping dependency update in test environment');
69
+ return;
70
+ }
71
+
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
+ );
62
77
 
63
- // Update coze-coding-dev-sdk to ^0.5.2
64
- console.log('\nUpdating coze-coding-dev-sdk to ^0.5.2...');
65
78
  try {
66
79
  const projectRoot = resolve(outputPath);
67
- execSync('pnpm add coze-coding-dev-sdk@^0.5.2', {
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, {
68
101
  cwd: projectRoot,
69
- stdio: 'inherit',
102
+ detached: true,
103
+ stdio: ['ignore', logFd, logFd],
70
104
  });
71
- console.log('✓ coze-coding-dev-sdk updated successfully');
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}`);
72
113
  } catch (error) {
73
- console.error('✗ Failed to update coze-coding-dev-sdk:', error);
74
- 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');
75
116
  }
76
117
  },
77
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/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