@coze-arch/cli 0.0.1-beta.5 → 0.0.2

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 (324) 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 +1 -1
  10. package/lib/__templates__/{react-rsbuild → 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 +22 -38
  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 +47 -22
  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 -91
  47. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  48. package/lib/__templates__/expo/pnpm-lock.yaml +1805 -3126
  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/.babelrc +15 -0
  61. package/lib/__templates__/nextjs/.coze +4 -3
  62. package/lib/__templates__/nextjs/README.md +346 -19
  63. package/lib/__templates__/nextjs/_npmrc +2 -1
  64. package/lib/__templates__/nextjs/components.json +21 -0
  65. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  66. package/lib/__templates__/nextjs/next.config.ts +11 -0
  67. package/lib/__templates__/nextjs/package.json +63 -2
  68. package/lib/__templates__/nextjs/pnpm-lock.yaml +10053 -1710
  69. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  70. package/lib/__templates__/nextjs/scripts/dev.sh +15 -27
  71. package/lib/__templates__/{react-rsbuild/scripts/build.sh → nextjs/scripts/prepare.sh} +0 -5
  72. package/lib/__templates__/nextjs/scripts/start.sh +7 -1
  73. package/lib/__templates__/nextjs/src/app/globals.css +124 -13
  74. package/lib/__templates__/nextjs/src/app/layout.tsx +56 -16
  75. package/lib/__templates__/nextjs/src/app/page.tsx +18 -49
  76. package/lib/__templates__/nextjs/src/app/robots.ts +11 -0
  77. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  78. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  79. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  80. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  81. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  82. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  83. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  84. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  85. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  86. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  87. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  88. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  89. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  90. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  91. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  92. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  93. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  94. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  95. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  96. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  97. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  98. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  99. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  100. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  101. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  102. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  103. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  104. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  105. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  106. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  107. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  108. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  109. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  110. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  111. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  112. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  113. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +63 -0
  114. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  115. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  116. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  117. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  118. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +724 -0
  119. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  120. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  121. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  122. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  123. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  124. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  125. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  126. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  127. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  128. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  129. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  130. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  131. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  132. package/lib/__templates__/nextjs/src/server.ts +35 -0
  133. package/lib/__templates__/nextjs/template.config.js +70 -5
  134. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  135. package/lib/__templates__/nuxt-vue/.coze +12 -0
  136. package/lib/__templates__/nuxt-vue/README.md +73 -0
  137. package/lib/__templates__/nuxt-vue/_gitignore +24 -0
  138. package/lib/__templates__/{rsbuild → nuxt-vue}/_npmrc +2 -1
  139. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  140. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  141. package/lib/__templates__/{rsbuild/src/index.css → nuxt-vue/assets/css/main.css} +7 -4
  142. package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
  143. package/lib/__templates__/nuxt-vue/package.json +35 -0
  144. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  145. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  146. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  147. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  148. package/lib/__templates__/{rsbuild → nuxt-vue}/scripts/build.sh +2 -2
  149. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  150. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  151. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  152. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  153. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  154. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  155. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  156. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  157. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  158. package/lib/__templates__/taro/.coze +14 -0
  159. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  160. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  161. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  162. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  163. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  164. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  165. package/lib/__templates__/taro/README.md +763 -0
  166. package/lib/__templates__/taro/_gitignore +40 -0
  167. package/lib/__templates__/taro/_npmrc +18 -0
  168. package/lib/__templates__/taro/babel.config.js +12 -0
  169. package/lib/__templates__/taro/config/dev.ts +9 -0
  170. package/lib/__templates__/taro/config/index.ts +238 -0
  171. package/lib/__templates__/taro/config/prod.ts +34 -0
  172. package/lib/__templates__/taro/eslint.config.mjs +135 -0
  173. package/lib/__templates__/taro/key/private.appid.key +0 -0
  174. package/lib/__templates__/taro/package.json +112 -0
  175. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  176. package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
  177. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  178. package/lib/__templates__/taro/project.config.json +15 -0
  179. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  180. package/lib/__templates__/taro/server/package.json +40 -0
  181. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  182. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  183. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  184. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  185. package/lib/__templates__/taro/server/src/main.ts +49 -0
  186. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  187. package/lib/__templates__/taro/src/app.config.ts +11 -0
  188. package/lib/__templates__/taro/src/app.css +156 -0
  189. package/lib/__templates__/taro/src/app.tsx +9 -0
  190. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  191. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  192. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  193. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  194. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  195. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  196. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  197. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  198. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  199. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  200. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  201. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  202. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  203. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  204. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  205. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  206. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  207. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  208. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  209. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  210. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  211. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  212. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  213. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  214. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  215. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  216. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  217. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  218. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  219. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  220. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  221. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  222. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  223. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  224. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  225. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  226. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  227. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  228. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  229. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  230. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  231. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  232. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  233. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  234. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  235. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  236. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  237. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  238. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  239. package/lib/__templates__/taro/src/index.html +39 -0
  240. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  241. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  242. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  243. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  244. package/lib/__templates__/taro/src/network.ts +39 -0
  245. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  246. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  247. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  248. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  249. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  250. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  251. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  252. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  253. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  254. package/lib/__templates__/taro/template.config.js +68 -0
  255. package/lib/__templates__/taro/tsconfig.json +29 -0
  256. package/lib/__templates__/taro/types/global.d.ts +32 -0
  257. package/lib/__templates__/templates.json +126 -64
  258. package/lib/__templates__/vite/.coze +4 -3
  259. package/lib/__templates__/vite/README.md +383 -26
  260. package/lib/__templates__/vite/_gitignore +1 -0
  261. package/lib/__templates__/vite/_npmrc +2 -1
  262. package/lib/__templates__/vite/eslint.config.mjs +14 -0
  263. package/lib/__templates__/vite/package.json +23 -3
  264. package/lib/__templates__/vite/pnpm-lock.yaml +2509 -293
  265. package/lib/__templates__/vite/scripts/build.sh +4 -1
  266. package/lib/__templates__/vite/scripts/dev.sh +16 -28
  267. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  268. package/lib/__templates__/vite/scripts/start.sh +9 -3
  269. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  270. package/lib/__templates__/vite/server/server.ts +65 -0
  271. package/lib/__templates__/vite/server/vite.ts +67 -0
  272. package/lib/__templates__/vite/src/main.ts +17 -48
  273. package/lib/__templates__/vite/template.config.js +82 -10
  274. package/lib/__templates__/vite/tsconfig.json +4 -3
  275. package/lib/__templates__/vite/vite.config.ts +8 -3
  276. package/lib/cli.js +1544 -488
  277. package/package.json +18 -7
  278. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
  279. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
  280. package/lib/__templates__/expo/app.json +0 -63
  281. package/lib/__templates__/expo/babel.config.js +0 -9
  282. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  283. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  284. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  285. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  286. package/lib/__templates__/expo/client/index.js +0 -11
  287. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  288. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  289. package/lib/__templates__/expo/metro.config.js +0 -53
  290. package/lib/__templates__/expo/src/index.ts +0 -12
  291. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  292. package/lib/__templates__/react-rsbuild/.coze +0 -11
  293. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  294. package/lib/__templates__/react-rsbuild/README.md +0 -61
  295. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  296. package/lib/__templates__/react-rsbuild/package.json +0 -31
  297. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  298. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  299. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  300. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  301. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  302. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  303. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  304. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  305. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  306. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  307. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  308. package/lib/__templates__/rsbuild/.coze +0 -11
  309. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  310. package/lib/__templates__/rsbuild/README.md +0 -61
  311. package/lib/__templates__/rsbuild/_gitignore +0 -97
  312. package/lib/__templates__/rsbuild/package.json +0 -24
  313. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  314. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  315. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  316. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  317. package/lib/__templates__/rsbuild/src/index.html +0 -12
  318. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  319. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  320. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  321. package/lib/__templates__/rsbuild/template.config.js +0 -54
  322. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
  323. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  324. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
package/README.md CHANGED
@@ -14,6 +14,7 @@ Coze Coding 的项目模板引擎,提供基于前端技术栈的项目初始
14
14
 
15
15
  ```bash
16
16
  rush update
17
+
17
18
  ```
18
19
 
19
20
  ## 使用
@@ -3,5 +3,10 @@ entrypoint = "server.js"
3
3
  requires = ["nodejs-24"]
4
4
 
5
5
  [dev]
6
- build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
7
- run = ["bash", ".cozeproj/scripts/deploy_run.sh"]
6
+ build = ["bash", ".cozeproj/scripts/dev_build.sh"]
7
+ run = ["bash", ".cozeproj/scripts/dev_run.sh"]
8
+
9
+ [deploy]
10
+ build = ["bash", ".cozeproj/scripts/prod_build.sh"]
11
+ run = ["bash", ".cozeproj/scripts/prod_run.sh"]
12
+ build_app_dir = "./client"
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
+ set -euo pipefail
4
+ ROOT_DIR="$(pwd)"
5
+ PREVIEW_DIR="${COZE_PREVIEW_DIR:-/source/preview}"
6
+
7
+ # ==================== 配置项 ====================
8
+ SERVER_DIR="app"
9
+ EXPO_DIR="expo"
10
+ CHECK_HASH_SCRIPT="$ROOT_DIR/check_hash.py"
11
+
12
+ check_command() {
13
+ if ! command -v "$1" &> /dev/null; then
14
+ echo "error:命令 $1 未找到,请先安装"
15
+ fi
16
+ }
17
+
18
+ echo "==================== 开始构建 ===================="
19
+
20
+ echo "检查根目录 pre_install.py"
21
+ if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
22
+ echo "执行:python $PREVIEW_DIR/pre_install.py"
23
+ python "$PREVIEW_DIR/pre_install.py" || echo "pre_install.py 执行失败"
24
+ fi
25
+
26
+ echo "开始执行构建脚本(build_dev.sh)..."
27
+ echo "正在检查依赖命令是否存在..."
28
+ # 检查核心命令
29
+ check_command "pnpm"
30
+ check_command "npm"
31
+
32
+ echo "==================== 安装项目依赖 ===================="
33
+ if [ ! -f "package.json" ]; then
34
+ echo "项目目录下无 package.json,不是合法的 Node.js 项目"
35
+ fi
36
+ # 步骤 2.1/2.2:安装项目依赖
37
+ pnpm install --registry=https://registry.npmmirror.com || echo "Expo 项目依赖安装失败(pnpm 执行出错)"
38
+
39
+ echo "检查根目录 post_install.py"
40
+ if [ -f "$PREVIEW_DIR/post_install.py" ]; then
41
+ echo "执行:python $PREVIEW_DIR/post_install.py"
42
+ python "$PREVIEW_DIR/post_install.py" || echo "post_install.py 执行失败"
43
+ fi
44
+
45
+ echo "==================== 依赖安装完成!====================\n"
46
+ echo "下一步:执行 ./deploy_run.sh 启动服务"
@@ -0,0 +1,229 @@
1
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
2
+ PREVIEW_DIR="${COZE_PREVIEW_DIR:-/source/preview}"
3
+ LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
4
+ LOG_CLIENT_FILE="$LOG_DIR/client.log"
5
+ mkdir -p "$LOG_DIR"
6
+
7
+ # ==================== 配置项 ====================
8
+ # Server 服务配置
9
+ SERVER_HOST="0.0.0.0"
10
+ SERVER_PORT="9091"
11
+ # Expo 项目配置
12
+ EXPO_HOST="0.0.0.0"
13
+ EXPO_DIR="expo"
14
+ EXPO_PORT="5000"
15
+ WEB_URL="${COZE_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
16
+ ASSUME_YES="1"
17
+ EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
18
+ EXPO_PUBLIC_COZE_PROJECT_ID="${COZE_PROJECT_ID:-}"
19
+
20
+ EXPO_PACKAGER_PROXY_URL="${EXPO_PUBLIC_BACKEND_BASE_URL}"
21
+ export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL EXPO_PUBLIC_COZE_PROJECT_ID
22
+ # 运行时变量(为避免 set -u 的未绑定错误,预置为空)
23
+ SERVER_PID=""
24
+ EXPO_PID=""
25
+
26
+ # ==================== 工具函数 ====================
27
+ check_command() {
28
+ if ! command -v "$1" &> /dev/null; then
29
+ echo "error:命令 $1 未找到,请先安装"
30
+ fi
31
+ }
32
+ while [ $# -gt 0 ]; do
33
+ case "$1" in
34
+ -y|--yes)
35
+ ASSUME_YES="1"
36
+ shift
37
+ ;;
38
+ *)
39
+ shift
40
+ ;;
41
+ esac
42
+ done
43
+ is_port_free() {
44
+ ! lsof -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1
45
+ }
46
+ choose_next_free_port() {
47
+ local start=$1
48
+ local p=$start
49
+ while ! is_port_free "$p"; do
50
+ p=$((p+1))
51
+ done
52
+ echo "$p"
53
+ }
54
+ ensure_port() {
55
+ local var_name=$1
56
+ local port_val=$2
57
+ if is_port_free "$port_val"; then
58
+ echo "端口未占用:$port_val"
59
+ eval "$var_name=$port_val"
60
+ else
61
+ echo "端口已占用:$port_val"
62
+ local choice
63
+ if [ "$ASSUME_YES" = "1" ]; then choice="Y"; else read -r -p "是否关闭该端口的进程?[Y/n] " choice || choice="Y"; fi
64
+ if [ -z "$choice" ] || [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
65
+ if command -v lsof &> /dev/null; then
66
+ local pids
67
+ pids=$(lsof -t -i tcp:"$port_val" -sTCP:LISTEN 2>/dev/null || true)
68
+ if [ -n "$pids" ]; then
69
+ echo "正在关闭进程:$pids"
70
+ kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
71
+ eval "$var_name=$port_val"
72
+ else
73
+ echo "未获取到占用该端口的进程"
74
+ eval "$var_name=$port_val"
75
+ fi
76
+ else
77
+ echo "缺少 lsof,无法自动关闭进程"
78
+ eval "$var_name=$port_val"
79
+ fi
80
+ else
81
+ local new_port
82
+ new_port=$(choose_next_free_port "$port_val")
83
+ info "使用新的端口:$new_port"
84
+ eval "$var_name=$new_port"
85
+ fi
86
+ fi
87
+ }
88
+
89
+ pipe_to_log() {
90
+ local source="${1:-CLIENT}"
91
+ local raw_log="${2:-}"
92
+ local line clean_line timestamp
93
+ while IFS= read -r line || [ -n "$line" ]; do
94
+ clean_line=$(printf '%s' "$line" | sed 's/\x1b\[[0-9;]*[mA-Za-z]//g')
95
+ if echo "$clean_line" | grep -qE '(^(Web|iOS|Android) node_modules/.*expo-router.*entry\.js.*%|^(Web|iOS|Android) Bundled [0-9]+ms node_modules/.*expo-router.*entry\.js|Logs will appear in the browser)'; then
96
+ continue
97
+ fi
98
+ if [ -n "$raw_log" ]; then
99
+ timestamp=$(date '+%Y-%m-%d %H:%M:%S')
100
+ echo "[$timestamp] $clean_line" >> "$raw_log"
101
+ fi
102
+ printf '[%s] %s\n' "$source" "$clean_line"
103
+ done
104
+ }
105
+
106
+ wait_port_connectable() {
107
+ local host=$1 port=$2 retries=${3:-10}
108
+ for _ in $(seq 1 "$retries"); do
109
+ nc -z -w 1 "$host" "$port" >/dev/null 2>&1 && return 0
110
+ sleep 1
111
+ done
112
+ return 1
113
+ }
114
+
115
+ start_expo() {
116
+ local offline="${1:-0}"
117
+
118
+ pushd "$ROOT_DIR/client"
119
+
120
+ if [ "$offline" = "1" ]; then
121
+ ( EXPO_OFFLINE=1 EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
122
+ nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
123
+ else
124
+ ( EXPO_NO_DEPENDENCY_VALIDATION=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" EXPO_PUBLIC_COZE_PROJECT_ID="$EXPO_PUBLIC_COZE_PROJECT_ID" \
125
+ nohup npx expo start --clear --port "$EXPO_PORT" 2>&1 | pipe_to_log "CLIENT" "$LOG_CLIENT_FILE" ) &
126
+ fi
127
+ EXPO_PID=$!
128
+ disown $EXPO_PID 2>/dev/null || true
129
+
130
+ popd
131
+ }
132
+
133
+ detect_expo_fetch_failed() {
134
+ local timeout="${1:-8}"
135
+ local waited=0
136
+ local log_file="$LOG_CLIENT_FILE"
137
+ while [ "$waited" -lt "$timeout" ]; do
138
+ if [ -f "$log_file" ] && tail -n 100 "$log_file" 2>/dev/null | grep -q "TypeError: fetch failed"; then
139
+ return 0
140
+ fi
141
+ sleep 1
142
+ waited=$((waited+1))
143
+ done
144
+ return 1
145
+ }
146
+
147
+ # ==================== 前置检查 ====================
148
+ # 关掉nginx进程
149
+ ps -ef | grep nginx | grep -v grep | awk '{print $2}' | xargs -r kill -9
150
+
151
+ echo "检查根目录 pre_install.py"
152
+ if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
153
+ echo "执行:python $PREVIEW_DIR/pre_install.py"
154
+ python "$PREVIEW_DIR/pre_install.py" || echo "pre_install.py 执行失败"
155
+ fi
156
+
157
+ echo "检查根目录 post_install.py"
158
+ if [ -f "$PREVIEW_DIR/post_install.py" ]; then
159
+ echo "执行:python $PREVIEW_DIR/post_install.py"
160
+ python "$PREVIEW_DIR/post_install.py" || echo "post_install.py 执行失败"
161
+ fi
162
+
163
+ echo "==================== 开始启动 ===================="
164
+ echo "开始执行服务启动脚本(start_dev.sh)..."
165
+ echo "正在检查依赖命令和目录是否存在..."
166
+ # 检查核心命令
167
+ check_command "npm"
168
+ check_command "pnpm"
169
+ check_command "lsof"
170
+ check_command "bash"
171
+
172
+ # 端口占用预检查与处理
173
+ ensure_port SERVER_PORT "$SERVER_PORT"
174
+ ensure_port EXPO_PORT "$EXPO_PORT"
175
+
176
+ echo "==================== 启动 server 服务 ===================="
177
+ echo "正在执行:pnpm run dev (server)"
178
+ ( pushd "$ROOT_DIR/server" > /dev/null && SERVER_PORT="$SERVER_PORT" nohup pnpm run dev; popd > /dev/null ) &
179
+ SERVER_PID=$!
180
+ disown $SERVER_PID 2>/dev/null || true
181
+ if [ -z "${SERVER_PID}" ]; then
182
+ echo "无法获取 server 后台进程 PID"
183
+ fi
184
+ echo "server 服务已启动,进程 ID:${SERVER_PID:-unknown}"
185
+
186
+ echo "==================== 启动 Expo 项目 ===================="
187
+ echo "开始启动 Expo 服务,端口 ${EXPO_PORT}"
188
+ start_expo 0
189
+ if detect_expo_fetch_failed 8; then
190
+ echo "Expo 启动检测到网络错误:TypeError: fetch failed,启用离线模式重试"
191
+ if [ -n "${EXPO_PID}" ]; then kill -9 "$EXPO_PID" 2>/dev/null || true; fi
192
+ : > "$ROOT_DIR/logs/client.log"
193
+ start_expo 1
194
+ fi
195
+ # 输出以下环境变量,确保 Expo 项目能正确连接到 Server 服务
196
+ echo "Expo 环境变量配置:"
197
+ echo "EXPO_PUBLIC_BACKEND_BASE_URL=${EXPO_PUBLIC_BACKEND_BASE_URL}"
198
+ echo "EXPO_PACKAGER_PROXY_URL=${EXPO_PACKAGER_PROXY_URL}"
199
+ echo "EXPO_PUBLIC_COZE_PROJECT_ID=${EXPO_PUBLIC_COZE_PROJECT_ID}"
200
+ if [ -z "${EXPO_PID}" ]; then
201
+ echo "无法获取 Expo 后台进程 PID"
202
+ fi
203
+
204
+ echo "所有服务已启动。Server PID: ${SERVER_PID}, Expo PID: ${EXPO_PID}"
205
+
206
+ echo "检查 Server 服务端口:$SERVER_HOST:$SERVER_PORT"
207
+ if wait_port_connectable "$SERVER_HOST" "$SERVER_PORT" 10 2; then
208
+ echo "端口可连接:$SERVER_HOST:$SERVER_PORT"
209
+ else
210
+ echo "端口不可连接:$SERVER_HOST:$SERVER_PORT 10 次)"
211
+ fi
212
+
213
+ echo "检查 Expo 服务端口:$EXPO_HOST:$EXPO_PORT"
214
+ if wait_port_connectable "$EXPO_HOST" "$EXPO_PORT" 10 2; then
215
+ echo "端口可连接:$EXPO_HOST:$EXPO_PORT"
216
+ else
217
+ echo "端口不可连接:$EXPO_HOST:$EXPO_PORT(已尝试 10 次)"
218
+ fi
219
+
220
+ echo "服务端口检查完成"
221
+
222
+ echo "检查根目录 post_run.py"
223
+ if [ -f "$ROOT_DIR/post_run.py" ]; then
224
+ echo "启动检查中"
225
+ python "$ROOT_DIR/post_run.py" --port "$EXPO_PORT" || echo "post_run.py 执行失败"
226
+ echo "启动检查结束"
227
+ fi
228
+
229
+ echo "==================== 服务启动完成 ===================="
@@ -0,0 +1,47 @@
1
+ #!/bin/bash
2
+ if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
+ set -euo pipefail
4
+ ROOT_DIR="$(pwd)"
5
+
6
+ # ==================== 工具函数 ====================
7
+ info() {
8
+ echo "[INFO] $1"
9
+ }
10
+ warn() {
11
+ echo "[WARN] $1"
12
+ }
13
+ error() {
14
+ echo "[ERROR] $1"
15
+ exit 1
16
+ }
17
+ check_command() {
18
+ if ! command -v "$1" &> /dev/null; then
19
+ error "命令 $1 未找到,请先安装"
20
+ fi
21
+ }
22
+
23
+ info "==================== 开始构建 ===================="
24
+ info "开始执行构建脚本(build_prod.sh)..."
25
+ info "正在检查依赖命令是否存在..."
26
+ # 检查核心命令
27
+ check_command "pnpm"
28
+ check_command "npm"
29
+
30
+ # ==================== 安装 Node 依赖 ====================
31
+ info "==================== 安装 Node 依赖 ===================="
32
+ info "开始安装 Node 依赖"
33
+ if [ -f "$ROOT_DIR/package.json" ]; then
34
+ info "进入目录:$ROOT_DIR"
35
+ info "正在执行:pnpm install"
36
+ (cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
37
+ else
38
+ warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
39
+ fi
40
+ info "==================== 依赖安装完成!====================\n"
41
+
42
+ info "==================== dist打包 ===================="
43
+ info "开始执行:pnpm run build (server)"
44
+ (pushd "$ROOT_DIR/server" > /dev/null && pnpm run build; popd > /dev/null) || error "dist打包失败"
45
+ info "==================== dist打包完成!====================\n"
46
+
47
+ info "下一步:执行 ./prod_run.sh 启动服务"
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+ # 产物部署使用
3
+ set -euo pipefail
4
+
5
+ ROOT_DIR="$(pwd)"
6
+
7
+ HOST="${HOST:-0.0.0.0}"
8
+ PORT="${PORT:-5000}"
9
+
10
+ # ==================== 工具函数 ====================
11
+ info() {
12
+ echo "[INFO] $1"
13
+ }
14
+ warn() {
15
+ echo "[WARN] $1"
16
+ }
17
+ error() {
18
+ echo "[ERROR] $1"
19
+ exit 1
20
+ }
21
+ check_command() {
22
+ if ! command -v "$1" &> /dev/null; then
23
+ error "命令 $1 未找到,请先安装"
24
+ fi
25
+ }
26
+
27
+ # ============== 启动服务 ======================
28
+ # 检查核心命令
29
+ check_command "pnpm"
30
+ check_command "npm"
31
+
32
+ info "开始执行:pnpm run start (server)"
33
+ (pushd "$ROOT_DIR/server" > /dev/null && PORT="$PORT" pnpm run start; popd > /dev/null) || error "服务启动失败"
34
+ info "服务启动完成!\n"
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+
3
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
+ SERVER_DIR="$ROOT_DIR/server"
5
+ LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
6
+ LOG_SERVER_FILE="$LOG_DIR/server.log"
7
+ SERVER_PORT="${SERVER_PORT:-9091}"
8
+
9
+ mkdir -p "$LOG_DIR"
10
+
11
+ pipe_to_log() {
12
+ local source="${1:-SERVER}"
13
+ local raw_log="${2:-}"
14
+ local line clean_line timestamp
15
+ while IFS= read -r line || [ -n "$line" ]; do
16
+ clean_line=$(printf '%s' "$line" | sed 's/\x1b\[[0-9;]*[mA-Za-z]//g')
17
+ if [ -n "$raw_log" ]; then
18
+ timestamp=$(date '+%Y-%m-%d %H:%M:%S')
19
+ echo "[$timestamp] $clean_line" >> "$raw_log"
20
+ fi
21
+ printf '[%s] %s\n' "$source" "$clean_line"
22
+ done
23
+ }
24
+
25
+ kill_old_server() {
26
+ if command -v lsof &> /dev/null; then
27
+ local pids
28
+ pids=$(lsof -t -i tcp:"$SERVER_PORT" -sTCP:LISTEN 2>/dev/null || true)
29
+ if [ -n "$pids" ]; then
30
+ echo "正在关闭旧的 server 进程:$pids"
31
+ kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
32
+ sleep 1
33
+ fi
34
+ fi
35
+ }
36
+
37
+ echo "==================== Server Dev Run ===================="
38
+ echo "Server 目录:$SERVER_DIR"
39
+ echo "Server 端口:$SERVER_PORT"
40
+ echo "日志文件:$LOG_SERVER_FILE"
41
+
42
+ kill_old_server
43
+
44
+ echo "启动 server 服务..."
45
+ cd "$SERVER_DIR"
46
+ NODE_ENV=development PORT="$SERVER_PORT" npx tsx watch ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
@@ -1,13 +1,74 @@
1
- # Expo App Template
1
+ # Expo App + Express.js
2
+
3
+ ## 目录结构规范(严格遵循)
4
+
5
+ 当前仓库是一个 monorepo(基于 pnpm 的 workspace)
6
+
7
+ - Expo 代码在 client 目录,Express.js 代码在 server 目录
8
+ - 本模板默认无 Tab Bar,可按需改造
9
+
10
+ 目录结构说明
11
+
12
+ ├── server/ # 服务端代码根目录 (Express.js)
13
+ | ├── src/
14
+ │ │ └── index.ts # Express 入口文件
15
+ | └── package.json # 服务端 package.json
16
+ ├── client/ # React Native 前端代码
17
+ │ ├── app/ # Expo Router 路由目录(仅路由配置)
18
+ │ │ ├── _layout.tsx # 根布局文件(必需,务必阅读)
19
+ │ │ ├── home.tsx # 首页
20
+ │ │ └── index.tsx # re-export home.tsx
21
+ │ ├── screens/ # 页面实现目录(与 app/ 路由对应)
22
+ │ │ └── demo/ # demo 示例页面
23
+ │ │ ├── index.tsx # 页面组件实现
24
+ │ │ └── styles.ts # 页面样式
25
+ │ ├── components/ # 可复用组件
26
+ │ │ └── Screen.tsx # 页面容器组件(必用)
27
+ │ ├── hooks/ # 自定义 Hooks
28
+ │ ├── contexts/ # React Context 代码
29
+ │ ├── constants/ # 常量定义(如主题配置)
30
+ │ ├── utils/ # 工具函数
31
+ │ ├── assets/ # 静态资源
32
+ | └── package.json # Expo 应用 package.json
33
+ ├── package.json
34
+ ├── .cozeproj # 预置脚手架脚本(禁止修改)
35
+ └── .coze # 配置文件(禁止修改)
36
+
2
37
  ## 安装依赖
38
+
39
+ ### 命令
40
+
3
41
  ```bash
4
- pnpm install
42
+ pnpm i
5
43
  ```
6
- ## 启动 Metro 服务
7
- ```bash
8
- npx expo start
44
+
45
+ ### 新增依赖约束
46
+
47
+ 如果需要新增依赖,需在 client 和 server 各自的目录添加(原因:隔离前后端的依赖),禁止在根目录直接安装依赖
48
+
49
+ ### 新增依赖标准流程
50
+
51
+ - 编辑 `client/package.json` 或 `server/package.json`
52
+ - 在根目录执行 `pnpm i`
53
+
54
+ ## Expo 开发规范
55
+
56
+ ### 路径别名
57
+
58
+ Expo 配置了 `@/` 路径别名指向 `client/` 目录:
59
+
60
+ ```tsx
61
+ // 正确
62
+ import { Screen } from '@/components/Screen';
63
+
64
+ // 避免相对路径
65
+ import { Screen } from '../../../components/Screen';
9
66
  ```
10
- ## 启动 Node 服务器
67
+
68
+ ## 本地开发
69
+
70
+ 运行 coze dev 可以同时启动前端和后端服务,如果端口已占用,该命令会先杀掉占用端口的进程再启动,也可以用来重启前端和后端服务
71
+
11
72
  ```bash
12
- npm run server
73
+ coze dev
13
74
  ```
@@ -8,4 +8,4 @@ expo/expo-env.d.ts
8
8
  expo-env.d.ts
9
9
  .DS_Store
10
10
  logs/
11
- tsconfig.tsbuildinfo
11
+ *.tsbuildinfo
@@ -1,4 +1,5 @@
1
- registry=https://registry.npmjs.org
1
+ loglevel=error
2
+ registry=https://registry.npmmirror.com
2
3
 
3
4
  strictStorePkgContentCheck=false
4
5
  verifyStoreIntegrity=false
@@ -8,15 +9,13 @@ network-concurrency=16
8
9
  fetch-retries=3
9
10
  fetch-timeout=60000
10
11
 
11
- # 严格使用 peer dependencies
12
+ # peerDependencies
12
13
  strict-peer-dependencies=false
13
-
14
- # 自动生成 lockfile
15
14
  auto-install-peers=true
16
15
 
17
16
  # lockfile 配置
18
17
  lockfile=true
19
18
  prefer-frozen-lockfile=true
20
19
 
21
- # 如果 lockfile 存在但过期,更新而不是失败
20
+ # semver 选择最高版本
22
21
  resolution-mode=highest
@@ -1,25 +1,19 @@
1
- import { useRouter } from 'expo-router';
2
- import { StyleSheet, View, Text, Pressable, Platform } from 'react-native';
1
+ import { View, Text, StyleSheet } from 'react-native';
2
+ import { Link } from 'expo-router';
3
+ import { useTheme } from '@/hooks/useTheme';
4
+ import { Spacing } from '@/constants/theme';
3
5
 
4
6
  export default function NotFoundScreen() {
5
- const router = useRouter();
6
-
7
- const goBack = () => {
8
- if (router.canGoBack()) {
9
- router.back();
10
- }
11
- };
7
+ const { theme } = useTheme();
12
8
 
13
9
  return (
14
- <View style={styles.container}>
15
- <Text style={styles.heading}>404</Text>
16
- <Text style={styles.textStyle}>页面未找到</Text>
17
- <Text style={styles.subTextStyle}>
18
- 抱歉!您访问的页面不存在,当前页面功能待完善。
10
+ <View style={[styles.container, { backgroundColor: theme.backgroundRoot }]}>
11
+ <Text>
12
+ 页面不存在
19
13
  </Text>
20
- <Pressable onPress={goBack} style={styles.button}>
21
- <Text style={styles.buttonText}>返回上一页</Text>
22
- </Pressable>
14
+ <Link href="/" style={[styles.gohome]}>
15
+ 返回首页
16
+ </Link>
23
17
  </View>
24
18
  );
25
19
  }
@@ -27,53 +21,10 @@ export default function NotFoundScreen() {
27
21
  const styles = StyleSheet.create({
28
22
  container: {
29
23
  flex: 1,
30
- alignItems: 'center',
31
24
  justifyContent: 'center',
32
- backgroundColor: '#f3f5ff',
33
- padding: 16,
34
- },
35
- heading: {
36
- fontSize: 120,
37
- fontWeight: '900',
38
- color: '#4a5568',
39
- textShadowColor: 'rgba(0, 0, 0, 0.05)',
40
- textShadowOffset: { width: 0, height: 4 },
41
- textShadowRadius: 8,
42
- },
43
- textStyle: {
44
- fontSize: 24,
45
- fontWeight: '500',
46
- marginTop: -16,
47
- marginBottom: 16,
48
- color: '#4a5568',
49
- },
50
- subTextStyle: {
51
- fontSize: 16,
52
- color: '#718096',
53
- marginBottom: 32,
54
- maxWidth: 400,
55
- textAlign: 'center',
56
- },
57
- button: {
58
- paddingVertical: 12,
59
- paddingHorizontal: 24,
60
- backgroundColor: '#6366f1',
61
- borderRadius: 9999,
62
- ...Platform.select({
63
- ios: {
64
- shadowColor: 'rgba(0, 0, 0, 0.1)',
65
- shadowOffset: { width: 0, height: 10 },
66
- shadowOpacity: 1,
67
- shadowRadius: 15,
68
- },
69
- android: {
70
- elevation: 5,
71
- },
72
- }),
25
+ alignItems: 'center',
73
26
  },
74
- buttonText: {
75
- fontSize: 16,
76
- fontWeight: '600',
77
- color: '#ffffff',
27
+ gohome: {
28
+ marginTop: Spacing['2xl'],
78
29
  },
79
- });
30
+ });
@@ -5,6 +5,7 @@ import { StatusBar } from 'expo-status-bar';
5
5
  import { LogBox } from 'react-native';
6
6
  import Toast from 'react-native-toast-message';
7
7
  import { AuthProvider } from "@/contexts/AuthContext";
8
+ import { ColorSchemeProvider } from '@/hooks/useColorScheme';
8
9
 
9
10
  LogBox.ignoreLogs([
10
11
  "TurboModuleRegistry.getEnforcing(...): 'RNMapsAirModule' could not be found",
@@ -14,20 +15,22 @@ LogBox.ignoreLogs([
14
15
  export default function RootLayout() {
15
16
  return (
16
17
  <AuthProvider>
18
+ <ColorSchemeProvider>
17
19
  <GestureHandlerRootView style={{ flex: 1 }}>
18
- <StatusBar style="dark"></StatusBar>
19
- <Stack screenOptions={{
20
- // 设置所有页面的切换动画为从右侧滑入,适用于iOS 和 Android
21
- animation: 'slide_from_right',
22
- gestureEnabled: true,
23
- gestureDirection: 'horizontal',
24
- // 隐藏自带的头部
25
- headerShown: false
26
- }}>
27
- <Stack.Screen name="(tabs)" options={{ title: "" }} />
28
- </Stack>
29
- <Toast />
20
+ <StatusBar style="dark"></StatusBar>
21
+ <Stack screenOptions={{
22
+ // 设置所有页面的切换动画为从右侧滑入,适用于iOS 和 Android
23
+ animation: 'slide_from_right',
24
+ gestureEnabled: true,
25
+ gestureDirection: 'horizontal',
26
+ // 隐藏自带的头部
27
+ headerShown: false
28
+ }}>
29
+ <Stack.Screen name="index" options={{ title: "" }} />
30
+ </Stack>
31
+ <Toast />
30
32
  </GestureHandlerRootView>
33
+ </ColorSchemeProvider>
31
34
  </AuthProvider>
32
35
  );
33
36
  }
@@ -0,0 +1 @@
1
+ export { default } from '@/screens/demo';