@coze-arch/cli 0.0.1-beta.6 → 0.0.3

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 (239) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.coze +7 -2
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  7. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  8. package/lib/__templates__/expo/README.md +68 -7
  9. package/lib/__templates__/expo/_gitignore +2 -1
  10. package/lib/__templates__/expo/_npmrc +4 -5
  11. package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
  12. package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
  13. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  14. package/lib/__templates__/expo/client/app.config.ts +76 -0
  15. package/lib/__templates__/expo/client/components/Screen.tsx +3 -19
  16. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  17. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  18. package/lib/__templates__/expo/client/constants/theme.ts +117 -58
  19. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  20. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  21. package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +40 -10
  22. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  23. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  24. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  25. package/lib/__templates__/expo/client/metro.config.js +124 -0
  26. package/lib/__templates__/expo/client/package.json +95 -0
  27. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  28. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  29. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +11 -10
  30. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  31. package/lib/__templates__/expo/client/utils/index.ts +23 -2
  32. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  33. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  34. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  35. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  36. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  37. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  38. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  39. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  40. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  41. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  42. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  43. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
  44. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
  45. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
  46. package/lib/__templates__/expo/package.json +16 -101
  47. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  48. package/lib/__templates__/expo/pnpm-lock.yaml +1622 -3274
  49. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  50. package/lib/__templates__/expo/server/build.js +21 -0
  51. package/lib/__templates__/expo/server/package.json +34 -0
  52. package/lib/__templates__/expo/server/src/index.ts +20 -0
  53. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  54. package/lib/__templates__/expo/template.config.js +58 -1
  55. package/lib/__templates__/expo/tsconfig.json +1 -24
  56. package/lib/__templates__/native-static/.coze +11 -0
  57. package/lib/__templates__/native-static/index.html +33 -0
  58. package/lib/__templates__/native-static/styles/main.css +136 -0
  59. package/lib/__templates__/native-static/template.config.js +22 -0
  60. package/lib/__templates__/nextjs/.coze +4 -3
  61. package/lib/__templates__/nextjs/README.md +5 -0
  62. package/lib/__templates__/nextjs/_gitignore +1 -0
  63. package/lib/__templates__/nextjs/_npmrc +2 -1
  64. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  65. package/lib/__templates__/nextjs/next.config.ts +11 -0
  66. package/lib/__templates__/nextjs/package.json +15 -1
  67. package/lib/__templates__/nextjs/pnpm-lock.yaml +7694 -4394
  68. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  69. package/lib/__templates__/nextjs/scripts/dev.sh +15 -28
  70. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  71. package/lib/__templates__/nextjs/scripts/start.sh +7 -1
  72. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  73. package/lib/__templates__/nextjs/src/app/layout.tsx +20 -33
  74. package/lib/__templates__/nextjs/src/app/page.tsx +18 -49
  75. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  76. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  77. package/lib/__templates__/nextjs/src/server.ts +35 -0
  78. package/lib/__templates__/nextjs/template.config.js +68 -3
  79. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  80. package/lib/__templates__/nuxt-vue/.coze +12 -0
  81. package/lib/__templates__/nuxt-vue/README.md +73 -0
  82. package/lib/__templates__/nuxt-vue/_gitignore +25 -0
  83. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  84. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  85. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  86. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  87. package/lib/__templates__/nuxt-vue/nuxt.config.ts +126 -0
  88. package/lib/__templates__/nuxt-vue/package.json +35 -0
  89. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  90. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  91. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  92. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  93. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  94. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  95. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  96. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  97. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  98. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  99. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  100. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  101. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  102. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  103. package/lib/__templates__/taro/.coze +14 -0
  104. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  105. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  106. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  107. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  108. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  109. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  110. package/lib/__templates__/taro/README.md +763 -0
  111. package/lib/__templates__/taro/_gitignore +41 -0
  112. package/lib/__templates__/taro/_npmrc +18 -0
  113. package/lib/__templates__/taro/babel.config.js +12 -0
  114. package/lib/__templates__/taro/config/dev.ts +9 -0
  115. package/lib/__templates__/taro/config/index.ts +238 -0
  116. package/lib/__templates__/taro/config/prod.ts +34 -0
  117. package/lib/__templates__/taro/eslint.config.mjs +135 -0
  118. package/lib/__templates__/taro/key/private.appid.key +0 -0
  119. package/lib/__templates__/taro/package.json +112 -0
  120. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  121. package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
  122. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  123. package/lib/__templates__/taro/project.config.json +15 -0
  124. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  125. package/lib/__templates__/taro/server/package.json +40 -0
  126. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  127. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  128. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  129. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  130. package/lib/__templates__/taro/server/src/main.ts +49 -0
  131. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  132. package/lib/__templates__/taro/src/app.config.ts +11 -0
  133. package/lib/__templates__/taro/src/app.css +156 -0
  134. package/lib/__templates__/taro/src/app.tsx +9 -0
  135. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  136. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  137. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  138. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  139. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  140. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  141. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  142. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  143. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  144. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  145. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  146. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  147. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  148. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  149. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  150. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  151. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  152. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  153. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  154. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  155. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  156. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  157. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  158. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  159. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  160. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  161. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  162. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  163. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  164. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  165. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  166. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  167. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  168. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  169. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  170. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  171. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  172. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  173. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  174. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  175. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  176. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  177. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  178. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  179. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  180. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  181. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  182. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  183. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  184. package/lib/__templates__/taro/src/index.html +39 -0
  185. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  186. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  187. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  188. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  189. package/lib/__templates__/taro/src/network.ts +39 -0
  190. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  191. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  192. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  193. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  194. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  195. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  196. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  197. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  198. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  199. package/lib/__templates__/taro/template.config.js +68 -0
  200. package/lib/__templates__/taro/tsconfig.json +29 -0
  201. package/lib/__templates__/taro/types/global.d.ts +32 -0
  202. package/lib/__templates__/templates.json +173 -36
  203. package/lib/__templates__/vite/.coze +4 -3
  204. package/lib/__templates__/vite/README.md +383 -26
  205. package/lib/__templates__/vite/_gitignore +2 -0
  206. package/lib/__templates__/vite/_npmrc +2 -1
  207. package/lib/__templates__/vite/eslint.config.mjs +14 -0
  208. package/lib/__templates__/vite/package.json +23 -3
  209. package/lib/__templates__/vite/pnpm-lock.yaml +2509 -293
  210. package/lib/__templates__/vite/scripts/build.sh +4 -1
  211. package/lib/__templates__/vite/scripts/dev.sh +16 -28
  212. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  213. package/lib/__templates__/vite/scripts/start.sh +9 -3
  214. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  215. package/lib/__templates__/vite/server/server.ts +65 -0
  216. package/lib/__templates__/vite/server/vite.ts +67 -0
  217. package/lib/__templates__/vite/src/main.ts +17 -48
  218. package/lib/__templates__/vite/template.config.js +77 -7
  219. package/lib/__templates__/vite/tsconfig.json +4 -3
  220. package/lib/__templates__/vite/vite.config.ts +8 -3
  221. package/lib/cli.js +1545 -526
  222. package/package.json +20 -7
  223. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
  224. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
  225. package/lib/__templates__/expo/app.json +0 -63
  226. package/lib/__templates__/expo/babel.config.js +0 -9
  227. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  228. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  229. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  230. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  231. package/lib/__templates__/expo/client/index.js +0 -12
  232. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  233. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  234. package/lib/__templates__/expo/metro.config.js +0 -53
  235. package/lib/__templates__/expo/src/index.ts +0 -12
  236. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  237. package/lib/__templates__/nextjs/server.mjs +0 -50
  238. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  239. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
@@ -0,0 +1,8 @@
1
+ const config = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
7
+
8
+ export default config;
@@ -0,0 +1,2 @@
1
+ User-Agent: *
2
+ Disallow:
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "Installing dependencies..."
9
+ pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
10
+
11
+ echo "Building the Nuxt.js project..."
12
+ npx nuxt build
13
+
14
+ echo "Build completed successfully!"
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ <% if (process.env.NODE_ENV === 'test') { %>
5
+ # 测试环境:支持环境变量覆盖端口
6
+ PORT="${PORT:-<%= port %>}"
7
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
8
+ DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
9
+ <% } else { %>
10
+ PORT=<%= port %>
11
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
12
+ DEPLOY_RUN_PORT=<%= port %>
13
+ <% } %>
14
+
15
+ cd "${COZE_WORKSPACE_PATH}"
16
+
17
+ kill_port_if_listening() {
18
+ local pids
19
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
20
+ if [[ -z "${pids}" ]]; then
21
+ echo "Port ${DEPLOY_RUN_PORT} is free."
22
+ return
23
+ fi
24
+ echo "Port ${DEPLOY_RUN_PORT} in use by PIDs: ${pids} (SIGKILL)"
25
+ echo "${pids}" | xargs -I {} kill -9 {}
26
+ sleep 1
27
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
28
+ if [[ -n "${pids}" ]]; then
29
+ echo "Warning: port ${DEPLOY_RUN_PORT} still busy after SIGKILL, PIDs: ${pids}"
30
+ else
31
+ echo "Port ${DEPLOY_RUN_PORT} cleared."
32
+ fi
33
+ }
34
+
35
+ echo "Clearing port ${PORT} before start."
36
+ kill_port_if_listening
37
+ echo "Starting Nuxt dev server on port ${PORT}..."
38
+
39
+ PORT=$PORT npx nuxt dev
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "Installing dependencies..."
9
+ pnpm install --prefer-frozen-lockfile --prefer-offline
10
+
11
+ echo "Preparing Nuxt project..."
12
+ pnpm exec nuxt prepare
13
+
14
+ echo "Preparation completed successfully!"
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+ <% if (process.env.NODE_ENV === 'test') { %>
6
+ # 测试环境:支持环境变量覆盖端口
7
+ PORT="${PORT:-<%= port %>}"
8
+ DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
9
+ <% } else { %>
10
+ PORT=<%= port %>
11
+ DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-$PORT}"
12
+ <% } %>
13
+
14
+ start_service() {
15
+ cd "${COZE_WORKSPACE_PATH}"
16
+ echo "Starting Nuxt.js service on port ${DEPLOY_RUN_PORT} for production..."
17
+ PORT=${DEPLOY_RUN_PORT} node .output/server/index.mjs
18
+ }
19
+
20
+ echo "Starting Nuxt.js service on port ${DEPLOY_RUN_PORT} for production..."
21
+ start_service
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Hello API 示例
3
+ * 访问: http://localhost:<%= port %>/api/hello
4
+ */
5
+ export default defineEventHandler(() => {
6
+ return {
7
+ message: 'Hello from Nuxt API',
8
+ timestamp: new Date().toISOString(),
9
+ };
10
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 请求日志中间件(仅开发环境)
3
+ */
4
+ export default defineEventHandler((event) => {
5
+ const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
6
+
7
+ if (isDev) {
8
+ console.log(`${event.method} ${event.path}`);
9
+ }
10
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 健康检查路由
3
+ * 访问: http://localhost:<%= port %>/health
4
+ */
5
+ export default defineEventHandler(() => {
6
+ return {
7
+ status: 'ok',
8
+ timestamp: new Date().toISOString(),
9
+ };
10
+ });
@@ -0,0 +1,13 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: [
4
+ './app/**/*.{js,ts,jsx,tsx,vue}',
5
+ './pages/**/*.{js,ts,jsx,tsx,vue}',
6
+ './components/**/*.{js,ts,jsx,tsx,vue}',
7
+ ],
8
+ darkMode: 'media',
9
+ theme: {
10
+ extend: {},
11
+ },
12
+ plugins: [],
13
+ };
@@ -0,0 +1,87 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ const description = `Nuxt.js(服务端 + Vue):\`coze init \${COZE_WORKSPACE_PATH} --template nuxt-vue\`
11
+ - 适用:全栈应用、需要服务端接口能力的 Vue 项目
12
+ - 特点:
13
+ - **服务端能力**:内置服务端 API 路由,可直接创建后端接口
14
+ - **Vue 3**:基于最新的 Vue 3 Composition API
15
+ - **Vite**:使用 Vite 作为构建工具,开发体验极佳
16
+ - **TypeScript**:完整的 TypeScript 支持
17
+ - **文件路由**:基于文件系统的自动路由
18
+ - **项目理解加速**:可依赖项目下 \`package.json\` 和 \`nuxt.config.ts\` 理解项目配置`;
19
+
20
+ export const paramsSchema = {
21
+ type: 'object',
22
+ properties: {
23
+ appName: {
24
+ type: 'string',
25
+ minLength: 1,
26
+ pattern: '^[a-z0-9-]+$',
27
+ description:
28
+ 'Application name (lowercase, alphanumeric and hyphens only)',
29
+ },
30
+ port: {
31
+ type: 'number',
32
+ default: 5000,
33
+ minimum: 1024,
34
+ maximum: 65535,
35
+ description: 'Development server port (for Nuxt dev server)',
36
+ },
37
+ hmrPort: {
38
+ type: 'number',
39
+ default: 6000,
40
+ minimum: 1024,
41
+ maximum: 65535,
42
+ description: 'Hot Module Replacement (HMR) port',
43
+ },
44
+ },
45
+ required: [],
46
+ additionalProperties: false,
47
+ };
48
+
49
+ const config = {
50
+ description: description,
51
+ paramsSchema,
52
+
53
+ // 显式定义默认参数,确保在渲染时可用
54
+ defaultParams: {
55
+ port: 5000,
56
+ hmrPort: 6000,
57
+ appName: 'nuxt-vue',
58
+ },
59
+
60
+ onBeforeRender: async context => {
61
+ console.log(`Creating Nuxt.js project: ${context.appName}`);
62
+ return context;
63
+ },
64
+
65
+ onAfterRender: async (_context, outputPath) => {
66
+ console.log(`\nProject created at: ${outputPath}`);
67
+ console.log('\nConfiguration:');
68
+ console.log(' - Framework: Nuxt.js');
69
+ console.log(' - TypeScript: enabled');
70
+ console.log(' - Vue: 3.x');
71
+ console.log(' - Build Tool: Vite');
72
+ console.log(` - Port: ${_context.port}`);
73
+ },
74
+
75
+ onComplete: async (_context, _outputPath) => {
76
+ // Skip additional setup in test environment
77
+ if (process.env.NODE_ENV === 'test') {
78
+ console.log('⊘ Skipping additional setup in test environment');
79
+ return;
80
+ }
81
+
82
+ console.log('\n✓ Nuxt.js project setup completed!');
83
+ console.log(' You can now start the development server');
84
+ },
85
+ };
86
+
87
+ export default config;
@@ -0,0 +1,18 @@
1
+ {
2
+ // https://nuxt.com/docs/guide/concepts/typescript
3
+ "files": [],
4
+ "references": [
5
+ {
6
+ "path": "./.nuxt/tsconfig.app.json"
7
+ },
8
+ {
9
+ "path": "./.nuxt/tsconfig.server.json"
10
+ },
11
+ {
12
+ "path": "./.nuxt/tsconfig.shared.json"
13
+ },
14
+ {
15
+ "path": "./.nuxt/tsconfig.node.json"
16
+ }
17
+ ]
18
+ }
@@ -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"