@coze-arch/cli 0.0.1-alpha.3002ee → 0.0.1-alpha.344adf

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 (137) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  7. package/lib/__templates__/expo/README.md +68 -7
  8. package/lib/__templates__/expo/_gitignore +1 -1
  9. package/lib/__templates__/expo/_npmrc +3 -5
  10. package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
  11. package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
  12. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  13. package/lib/__templates__/expo/client/app.config.ts +76 -0
  14. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  15. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  16. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  17. package/lib/__templates__/expo/client/constants/theme.ts +117 -58
  18. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  19. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  20. package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +33 -10
  21. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  22. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  23. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  24. package/lib/__templates__/expo/client/metro.config.js +121 -0
  25. package/lib/__templates__/expo/client/package.json +95 -0
  26. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  27. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  28. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
  29. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  30. package/lib/__templates__/expo/client/utils/index.ts +23 -2
  31. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  32. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  33. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  34. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  35. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  36. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  37. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  38. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  39. package/lib/__templates__/expo/package.json +16 -103
  40. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  41. package/lib/__templates__/expo/pnpm-lock.yaml +1622 -3274
  42. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  43. package/lib/__templates__/expo/server/build.js +21 -0
  44. package/lib/__templates__/expo/server/package.json +34 -0
  45. package/lib/__templates__/expo/server/src/index.ts +20 -0
  46. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  47. package/lib/__templates__/expo/template.config.js +58 -1
  48. package/lib/__templates__/expo/tsconfig.json +1 -24
  49. package/lib/__templates__/native-static/.coze +11 -0
  50. package/lib/__templates__/native-static/template.config.js +22 -0
  51. package/lib/__templates__/nextjs/.babelrc +0 -3
  52. package/lib/__templates__/nextjs/.coze +4 -3
  53. package/lib/__templates__/nextjs/_npmrc +2 -1
  54. package/lib/__templates__/nextjs/next.config.ts +12 -0
  55. package/lib/__templates__/nextjs/package.json +17 -1
  56. package/lib/__templates__/nextjs/pnpm-lock.yaml +3352 -1083
  57. package/lib/__templates__/nextjs/scripts/dev.sh +8 -27
  58. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  59. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  60. package/lib/__templates__/nextjs/src/app/layout.tsx +19 -32
  61. package/lib/__templates__/nextjs/src/app/page.tsx +18 -48
  62. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  63. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  64. package/lib/__templates__/nextjs/template.config.js +68 -3
  65. package/lib/__templates__/taro/.coze +14 -0
  66. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  67. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  68. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  69. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +80 -0
  70. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  71. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +1 -0
  72. package/lib/__templates__/taro/README.md +694 -0
  73. package/lib/__templates__/taro/_gitignore +40 -0
  74. package/lib/__templates__/taro/_npmrc +18 -0
  75. package/lib/__templates__/taro/babel.config.js +12 -0
  76. package/lib/__templates__/taro/config/dev.ts +9 -0
  77. package/lib/__templates__/taro/config/index.ts +173 -0
  78. package/lib/__templates__/taro/config/prod.ts +35 -0
  79. package/lib/__templates__/taro/eslint.config.mjs +57 -0
  80. package/lib/__templates__/taro/key/private.appid.key +0 -0
  81. package/lib/__templates__/taro/package.json +97 -0
  82. package/lib/__templates__/taro/pnpm-lock.yaml +22458 -0
  83. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  84. package/lib/__templates__/taro/project.config.json +15 -0
  85. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  86. package/lib/__templates__/taro/server/package.json +41 -0
  87. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  88. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  89. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  90. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  91. package/lib/__templates__/taro/server/src/main.ts +49 -0
  92. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  93. package/lib/__templates__/taro/src/app.config.ts +11 -0
  94. package/lib/__templates__/taro/src/app.css +52 -0
  95. package/lib/__templates__/taro/src/app.ts +14 -0
  96. package/lib/__templates__/taro/src/index.html +39 -0
  97. package/lib/__templates__/taro/src/network.ts +39 -0
  98. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  99. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  100. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  101. package/lib/__templates__/taro/src/utils/h5-styles.ts +33 -0
  102. package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
  103. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  104. package/lib/__templates__/taro/template.config.js +68 -0
  105. package/lib/__templates__/taro/tsconfig.json +29 -0
  106. package/lib/__templates__/taro/types/global.d.ts +32 -0
  107. package/lib/__templates__/templates.json +104 -36
  108. package/lib/__templates__/vite/.coze +4 -3
  109. package/lib/__templates__/vite/README.md +204 -26
  110. package/lib/__templates__/vite/_npmrc +2 -1
  111. package/lib/__templates__/vite/eslint.config.mjs +9 -0
  112. package/lib/__templates__/vite/package.json +15 -2
  113. package/lib/__templates__/vite/pnpm-lock.yaml +1697 -221
  114. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  115. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  116. package/lib/__templates__/vite/src/main.ts +17 -48
  117. package/lib/__templates__/vite/template.config.js +77 -7
  118. package/lib/__templates__/vite/vite.config.ts +3 -3
  119. package/lib/cli.js +1516 -508
  120. package/package.json +10 -4
  121. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -115
  122. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -271
  123. package/lib/__templates__/expo/app.json +0 -63
  124. package/lib/__templates__/expo/babel.config.js +0 -9
  125. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  126. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  127. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  128. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  129. package/lib/__templates__/expo/client/index.js +0 -12
  130. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  131. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  132. package/lib/__templates__/expo/metro.config.js +0 -53
  133. package/lib/__templates__/expo/src/index.ts +0 -12
  134. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  135. package/lib/__templates__/nextjs/server.mjs +0 -50
  136. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  137. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
@@ -1,11 +1,21 @@
1
1
 
2
2
 
3
+ import { spawn } from 'child_process';
4
+ import { resolve, join, basename } from 'path';
5
+ import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
3
6
 
4
7
 
5
8
 
6
9
 
7
10
 
8
11
 
12
+ const description = `Next.js(复杂项目):\`coze init \${COZE_WORKSPACE_PATH} --template nextjs\`
13
+ - 适用:全栈应用、复杂多页面等复杂项目
14
+ - 使用默认nextjs项目规范
15
+ - **目录规范**: 默认开启src目录(打开--src-dir选项):项目文件(如 app 目录、pages 目录、components 等)初始化到 src/ 目录下。
16
+ - **项目理解加速**:初始可以依赖项目下 \`package.json\` 文件理解项目类型,如果没有或无法理解退化成阅读其他文件。
17
+ - **UI设计与组件规范**:Next.js项目**必须默认**采用 shadcn/ui 风格和规范,\`shadcn/ui\`组件默认完整的预装在\`src/components/ui/\`目录下`;
18
+
9
19
  export const paramsSchema = {
10
20
  type: 'object',
11
21
  properties: {
@@ -29,12 +39,13 @@ export const paramsSchema = {
29
39
  };
30
40
 
31
41
  const config = {
42
+ description: description,
32
43
  paramsSchema,
33
44
 
34
45
  // 显式定义默认参数,确保在渲染时可用
35
46
  defaultParams: {
36
47
  port: 5000,
37
- appName: 'my-nextjs-app',
48
+ appName: 'projects',
38
49
  },
39
50
 
40
51
  onBeforeRender: async context => {
@@ -42,13 +53,67 @@ const config = {
42
53
  return context;
43
54
  },
44
55
 
45
- onAfterRender: async (context, outputPath) => {
56
+ onAfterRender: async (_context, outputPath) => {
46
57
  console.log(`\nProject created at: ${outputPath}`);
47
58
  console.log('\nConfiguration:');
48
59
  console.log(' - Framework: Next.js');
49
60
  console.log(' - TypeScript: enabled');
50
61
  console.log(' - App Router: enabled');
51
- 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
+ );
77
+
78
+ try {
79
+ const projectRoot = resolve(outputPath);
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}`);
113
+ } catch (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');
116
+ }
52
117
  },
53
118
  };
54
119
 
@@ -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,80 @@
1
+ #!/bin/bash
2
+
3
+ echo "⚙️ dev_run.sh 开始运行"
4
+ set -Eeuo pipefail
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "📦 Installing dependencies..."
9
+ pnpm install
10
+ echo "✅ Dependencies installed successfully!"
11
+
12
+ kill_port_if_listening() {
13
+ local port=$1
14
+ local pids
15
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
16
+ if [[ -z "${pids}" ]]; then
17
+ echo "Port ${port} is free."
18
+ return
19
+ fi
20
+ echo "Port ${port} in use by PIDs: ${pids}"
21
+ for pid in ${pids}; do
22
+ kill_process_tree "${pid}"
23
+ done
24
+ sleep 1
25
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
26
+ if [[ -n "${pids}" ]]; then
27
+ echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
28
+ else
29
+ echo "Port ${port} cleared."
30
+ fi
31
+ }
32
+
33
+ kill_process_tree() {
34
+ local pid=$1
35
+ local children
36
+ children=$(pgrep -P "${pid}" 2>/dev/null || true)
37
+ for child in ${children}; do
38
+ kill_process_tree "${child}"
39
+ done
40
+ if kill -0 "${pid}" 2>/dev/null; then
41
+ echo "Killing PID ${pid}"
42
+ kill -9 "${pid}" 2>/dev/null || true
43
+ fi
44
+ }
45
+
46
+ start_service() {
47
+ cd "${COZE_WORKSPACE_PATH}"
48
+
49
+ # ---------------------------------------------------------
50
+ # 0. 动态注入环境变量
51
+ # ---------------------------------------------------------
52
+ if [ -n "$COZE_PROJECT_DOMAIN_DEFAULT" ]; then
53
+ export PROJECT_DOMAIN="$COZE_PROJECT_DOMAIN_DEFAULT"
54
+ echo "✅ 环境变量已动态注入: PROJECT_DOMAIN=$PROJECT_DOMAIN"
55
+ else
56
+ echo "⚠️ 警告: COZE_PROJECT_DOMAIN_DEFAULT 未设置,使用 .env.local 中的配置"
57
+ fi
58
+
59
+ # ---------------------------------------------------------
60
+ # 启动 Taro H5 和 NestJS Server
61
+ # ---------------------------------------------------------
62
+ echo "Starting Taro H5 Dev Server and NestJS Server..."
63
+
64
+ # ⚠️ 重要:为了让 Taro 使用平台动态分配的端口
65
+ export PORT=${DEPLOY_RUN_PORT}
66
+
67
+ rm -f /tmp/coze-logs/dev.log
68
+ mkdir -p /tmp/coze-logs
69
+
70
+ exec pnpm dev 2>&1 | tee /tmp/coze-logs/dev.log
71
+ }
72
+
73
+ SERVER_PORT=<%= serverPort %>
74
+
75
+ echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
76
+ kill_port_if_listening "${DEPLOY_RUN_PORT}"
77
+ echo "Clearing port ${SERVER_PORT} (server) before start."
78
+ kill_port_if_listening "${SERVER_PORT}"
79
+ echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
80
+ 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