@coze-arch/cli 0.0.1-alpha.01c0ee

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 (304) hide show
  1. package/README.md +143 -0
  2. package/bin/main +2 -0
  3. package/lib/__templates__/expo/.coze +12 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  7. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  8. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  9. package/lib/__templates__/expo/README.md +74 -0
  10. package/lib/__templates__/expo/_gitignore +11 -0
  11. package/lib/__templates__/expo/_npmrc +20 -0
  12. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  13. package/lib/__templates__/expo/client/app/_layout.tsx +36 -0
  14. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  15. package/lib/__templates__/expo/client/app.config.ts +76 -0
  16. package/lib/__templates__/expo/client/assets/fonts/SpaceMono-Regular.ttf +0 -0
  17. package/lib/__templates__/expo/client/assets/images/adaptive-icon.png +0 -0
  18. package/lib/__templates__/expo/client/assets/images/default-avatar.png +0 -0
  19. package/lib/__templates__/expo/client/assets/images/favicon.png +0 -0
  20. package/lib/__templates__/expo/client/assets/images/icon.png +0 -0
  21. package/lib/__templates__/expo/client/assets/images/partial-react-logo.png +0 -0
  22. package/lib/__templates__/expo/client/assets/images/react-logo.png +0 -0
  23. package/lib/__templates__/expo/client/assets/images/react-logo@2x.png +0 -0
  24. package/lib/__templates__/expo/client/assets/images/react-logo@3x.png +0 -0
  25. package/lib/__templates__/expo/client/assets/images/splash-icon.png +0 -0
  26. package/lib/__templates__/expo/client/components/Screen.tsx +314 -0
  27. package/lib/__templates__/expo/client/components/SmartDateInput.tsx +238 -0
  28. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  29. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  30. package/lib/__templates__/expo/client/constants/theme.ts +177 -0
  31. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +49 -0
  32. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  33. package/lib/__templates__/expo/client/eslint-formatter-simple.mjs +49 -0
  34. package/lib/__templates__/expo/client/eslint.config.mjs +128 -0
  35. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  36. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  37. package/lib/__templates__/expo/client/hooks/useTheme.ts +33 -0
  38. package/lib/__templates__/expo/client/metro.config.js +124 -0
  39. package/lib/__templates__/expo/client/package.json +95 -0
  40. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  41. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  42. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +105 -0
  43. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  44. package/lib/__templates__/expo/client/utils/index.ts +76 -0
  45. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  46. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  47. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  48. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  49. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  50. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  51. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  52. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  53. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  54. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  55. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  56. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
  57. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
  58. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
  59. package/lib/__templates__/expo/package.json +25 -0
  60. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  61. package/lib/__templates__/expo/pnpm-lock.yaml +12657 -0
  62. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  63. package/lib/__templates__/expo/server/build.js +21 -0
  64. package/lib/__templates__/expo/server/package.json +34 -0
  65. package/lib/__templates__/expo/server/src/index.ts +20 -0
  66. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  67. package/lib/__templates__/expo/template.config.js +106 -0
  68. package/lib/__templates__/expo/tsconfig.json +1 -0
  69. package/lib/__templates__/native-static/.coze +11 -0
  70. package/lib/__templates__/native-static/index.html +33 -0
  71. package/lib/__templates__/native-static/styles/main.css +136 -0
  72. package/lib/__templates__/native-static/template.config.js +22 -0
  73. package/lib/__templates__/nextjs/.babelrc +15 -0
  74. package/lib/__templates__/nextjs/.coze +12 -0
  75. package/lib/__templates__/nextjs/README.md +363 -0
  76. package/lib/__templates__/nextjs/_gitignore +99 -0
  77. package/lib/__templates__/nextjs/_npmrc +23 -0
  78. package/lib/__templates__/nextjs/components.json +21 -0
  79. package/lib/__templates__/nextjs/eslint.config.mjs +23 -0
  80. package/lib/__templates__/nextjs/next-env.d.ts +6 -0
  81. package/lib/__templates__/nextjs/next.config.ts +18 -0
  82. package/lib/__templates__/nextjs/package.json +93 -0
  83. package/lib/__templates__/nextjs/pnpm-lock.yaml +12404 -0
  84. package/lib/__templates__/nextjs/postcss.config.mjs +7 -0
  85. package/lib/__templates__/nextjs/public/file.svg +1 -0
  86. package/lib/__templates__/nextjs/public/globe.svg +1 -0
  87. package/lib/__templates__/nextjs/public/next.svg +1 -0
  88. package/lib/__templates__/nextjs/public/vercel.svg +1 -0
  89. package/lib/__templates__/nextjs/public/window.svg +1 -0
  90. package/lib/__templates__/nextjs/scripts/build.sh +17 -0
  91. package/lib/__templates__/nextjs/scripts/dev.sh +39 -0
  92. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  93. package/lib/__templates__/nextjs/scripts/start.sh +21 -0
  94. package/lib/__templates__/nextjs/src/app/favicon.ico +0 -0
  95. package/lib/__templates__/nextjs/src/app/globals.css +137 -0
  96. package/lib/__templates__/nextjs/src/app/layout.tsx +74 -0
  97. package/lib/__templates__/nextjs/src/app/page.tsx +35 -0
  98. package/lib/__templates__/nextjs/src/app/robots.ts +11 -0
  99. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  100. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  101. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  102. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  103. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  104. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  105. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  106. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  107. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  108. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  109. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  110. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  111. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  112. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  113. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  114. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  115. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  116. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  117. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  118. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  119. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  120. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  121. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  122. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  123. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  124. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  125. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  126. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  127. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  128. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  129. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  130. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  131. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  132. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  133. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  134. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  135. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +63 -0
  136. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  137. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  138. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  139. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  140. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +724 -0
  141. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  142. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  143. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  144. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  145. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  146. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  147. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  148. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  149. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  150. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  151. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  152. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  153. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  154. package/lib/__templates__/nextjs/src/server.ts +35 -0
  155. package/lib/__templates__/nextjs/template.config.js +120 -0
  156. package/lib/__templates__/nextjs/tsconfig.json +34 -0
  157. package/lib/__templates__/nuxt-vue/.coze +12 -0
  158. package/lib/__templates__/nuxt-vue/README.md +73 -0
  159. package/lib/__templates__/nuxt-vue/_gitignore +24 -0
  160. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  161. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  162. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  163. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  164. package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
  165. package/lib/__templates__/nuxt-vue/package.json +35 -0
  166. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  167. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  168. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  169. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  170. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  171. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  172. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  173. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  174. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  175. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  176. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  177. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  178. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  179. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  180. package/lib/__templates__/taro/.coze +14 -0
  181. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  182. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  183. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  184. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  185. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  186. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  187. package/lib/__templates__/taro/README.md +763 -0
  188. package/lib/__templates__/taro/_gitignore +40 -0
  189. package/lib/__templates__/taro/_npmrc +18 -0
  190. package/lib/__templates__/taro/babel.config.js +12 -0
  191. package/lib/__templates__/taro/config/dev.ts +9 -0
  192. package/lib/__templates__/taro/config/index.ts +237 -0
  193. package/lib/__templates__/taro/config/prod.ts +34 -0
  194. package/lib/__templates__/taro/eslint.config.mjs +135 -0
  195. package/lib/__templates__/taro/key/private.appid.key +0 -0
  196. package/lib/__templates__/taro/package.json +112 -0
  197. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  198. package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
  199. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  200. package/lib/__templates__/taro/project.config.json +15 -0
  201. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  202. package/lib/__templates__/taro/server/package.json +40 -0
  203. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  204. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  205. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  206. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  207. package/lib/__templates__/taro/server/src/main.ts +49 -0
  208. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  209. package/lib/__templates__/taro/src/app.config.ts +11 -0
  210. package/lib/__templates__/taro/src/app.css +156 -0
  211. package/lib/__templates__/taro/src/app.tsx +9 -0
  212. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  213. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  214. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  215. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  216. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  217. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  218. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  219. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  220. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  221. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  222. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  223. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  224. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  225. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  226. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  227. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  228. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  229. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  230. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  231. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  232. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  233. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  234. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  235. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  236. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  237. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  238. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  239. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  240. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  241. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  242. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  243. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  244. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  245. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  246. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  247. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  248. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  249. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  250. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  251. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  252. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  253. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  254. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  255. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  256. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  257. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  258. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  259. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  260. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  261. package/lib/__templates__/taro/src/index.html +39 -0
  262. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  263. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  264. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  265. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  266. package/lib/__templates__/taro/src/network.ts +39 -0
  267. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  268. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  269. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  270. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  271. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  272. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  273. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  274. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  275. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  276. package/lib/__templates__/taro/template.config.js +68 -0
  277. package/lib/__templates__/taro/tsconfig.json +29 -0
  278. package/lib/__templates__/taro/types/global.d.ts +32 -0
  279. package/lib/__templates__/templates.json +162 -0
  280. package/lib/__templates__/vite/.coze +12 -0
  281. package/lib/__templates__/vite/README.md +418 -0
  282. package/lib/__templates__/vite/_gitignore +67 -0
  283. package/lib/__templates__/vite/_npmrc +23 -0
  284. package/lib/__templates__/vite/eslint.config.mjs +14 -0
  285. package/lib/__templates__/vite/index.html +13 -0
  286. package/lib/__templates__/vite/package.json +44 -0
  287. package/lib/__templates__/vite/pnpm-lock.yaml +3465 -0
  288. package/lib/__templates__/vite/postcss.config.js +6 -0
  289. package/lib/__templates__/vite/scripts/build.sh +17 -0
  290. package/lib/__templates__/vite/scripts/dev.sh +39 -0
  291. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  292. package/lib/__templates__/vite/scripts/start.sh +21 -0
  293. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  294. package/lib/__templates__/vite/server/server.ts +65 -0
  295. package/lib/__templates__/vite/server/vite.ts +67 -0
  296. package/lib/__templates__/vite/src/index.css +21 -0
  297. package/lib/__templates__/vite/src/index.ts +5 -0
  298. package/lib/__templates__/vite/src/main.ts +34 -0
  299. package/lib/__templates__/vite/tailwind.config.js +9 -0
  300. package/lib/__templates__/vite/template.config.js +127 -0
  301. package/lib/__templates__/vite/tsconfig.json +17 -0
  302. package/lib/__templates__/vite/vite.config.ts +20 -0
  303. package/lib/cli.js +2631 -0
  304. package/package.json +81 -0
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -0,0 +1,17 @@
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 frontend with Vite..."
12
+ npx vite build
13
+
14
+ echo "Bundling server with tsup..."
15
+ npx tsup server/server.ts --format cjs --platform node --target node20 --outDir dist-server --no-splitting --no-minify --external vite
16
+
17
+ 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 express + Vite dev server on port ${PORT}..."
38
+
39
+ PORT=$PORT npx tsx watch server/server.ts
@@ -0,0 +1,9 @@
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
@@ -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 express production server on port ${DEPLOY_RUN_PORT}..."
17
+ PORT=$DEPLOY_RUN_PORT node dist-server/server.js
18
+ }
19
+
20
+ echo "Starting express production server on port ${DEPLOY_RUN_PORT}..."
21
+ start_service
@@ -0,0 +1,31 @@
1
+ import { Router } from 'express';
2
+
3
+ const router = Router();
4
+
5
+ // API 路由示例
6
+ router.get('/api/hello', (req, res) => {
7
+ res.json({
8
+ message: 'Hello from Express + Vite!',
9
+ timestamp: new Date().toISOString(),
10
+ });
11
+ });
12
+
13
+ router.post('/api/data', (req, res) => {
14
+ const requestData = req.body;
15
+ res.json({
16
+ success: true,
17
+ data: requestData,
18
+ receivedAt: new Date().toISOString(),
19
+ });
20
+ });
21
+
22
+ // 健康检查接口
23
+ router.get('/api/health', (req, res) => {
24
+ res.json({
25
+ status: 'ok',
26
+ env: process.env.COZE_PROJECT_ENV,
27
+ timestamp: new Date().toISOString(),
28
+ });
29
+ });
30
+
31
+ export default router;
@@ -0,0 +1,65 @@
1
+ // ABOUTME: Express server with Vite integration
2
+ // ABOUTME: Handles API routes and serves frontend in dev/prod modes
3
+
4
+ import { createServer, type Server } from 'http';
5
+ import express from 'express';
6
+ import router from './routes/index';
7
+ import { setupVite } from './vite';
8
+
9
+ const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
10
+ const port = parseInt(process.env.PORT || '<%= port %>', 10);
11
+ const hostname = process.env.HOSTNAME || 'localhost';
12
+ const app = express();
13
+ // 使用 http.createServer 包装 Express app,以便支持 WebSocket 等协议升级
14
+ const server = createServer(app);
15
+
16
+ async function startServer(): Promise<Server> {
17
+ // 请求日志(仅开发环境)
18
+ if (isDev) {
19
+ app.use((req, res, next) => {
20
+ const start = Date.now();
21
+ res.on('finish', () => {
22
+ const ms = Date.now() - start;
23
+ console.log(`${req.method} ${req.url} - ${ms}ms`);
24
+ });
25
+ next();
26
+ });
27
+ }
28
+
29
+ // 添加请求体解析
30
+ app.use(express.json());
31
+ app.use(express.urlencoded({ extended: true }));
32
+
33
+ // 注册 API 路由
34
+ app.use(router);
35
+
36
+ // 集成 Vite(开发模式)或静态文件服务(生产模式)
37
+ await setupVite(app);
38
+
39
+ // 全局错误处理
40
+ app.use((err: Error, req: express.Request, res: express.Response) => {
41
+ console.error('Server error:', err);
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ const status = 'status' in err ? (err as any).status || 500 : 500;
44
+ res.status(status).json({
45
+ error: err.message || 'Internal server error',
46
+ });
47
+ });
48
+
49
+ server.once('error', err => {
50
+ console.error('Server error:', err);
51
+ process.exit(1);
52
+ });
53
+
54
+ server.listen(port, () => {
55
+ console.log(`\n✨ Server running at http://${hostname}:${port}`);
56
+ console.log(`📝 Environment: ${isDev ? 'development' : 'production'}\n`);
57
+ });
58
+
59
+ return server;
60
+ }
61
+
62
+ startServer().catch(err => {
63
+ console.error('Failed to start server:', err);
64
+ process.exit(1);
65
+ });
@@ -0,0 +1,67 @@
1
+ // ABOUTME: Vite integration for Express server
2
+ // ABOUTME: Handles dev middleware and production static file serving
3
+
4
+ import type { Application, Request, Response } from 'express';
5
+ import express from 'express';
6
+ import path from 'path';
7
+ import fs from 'fs';
8
+ import { createServer as createViteServer } from 'vite';
9
+ import viteConfig from '../vite.config';
10
+
11
+ const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
12
+
13
+ /**
14
+ * 集成 Vite 开发服务器(中间件模式)
15
+ */
16
+ export async function setupViteMiddleware(app: Application) {
17
+ const vite = await createViteServer({
18
+ ...viteConfig,
19
+ server: {
20
+ ...viteConfig.server,
21
+ middlewareMode: true,
22
+ },
23
+ appType: 'spa',
24
+ });
25
+
26
+ // 使用 Vite middleware
27
+ app.use(vite.middlewares);
28
+
29
+ console.log('🚀 Vite dev server initialized');
30
+ }
31
+
32
+ /**
33
+ * 设置生产环境静态文件服务
34
+ */
35
+ export function setupStaticServer(app: Application) {
36
+ const distPath = path.resolve(process.cwd(), 'dist');
37
+
38
+ if (!fs.existsSync(distPath)) {
39
+ console.error('❌ dist folder not found. Please run "pnpm build" first.');
40
+ process.exit(1);
41
+ }
42
+
43
+ // 1. 服务静态文件(如果存在对应文件则直接返回)
44
+ app.use(express.static(distPath));
45
+
46
+ // 2. SPA fallback - 所有未处理的请求返回 index.html
47
+ // 到达这里的请求说明:
48
+ // - 不是 API 请求(已被前面注册的路由处理)
49
+ // - 不是静态文件(express.static 未找到对应文件)
50
+ // - 需要返回 index.html 让前端路由处理
51
+ app.use((_req: Request, res: Response) => {
52
+ res.sendFile(path.join(distPath, 'index.html'));
53
+ });
54
+
55
+ console.log('📦 Serving static files from dist/');
56
+ }
57
+
58
+ /**
59
+ * 根据环境设置 Vite
60
+ */
61
+ export async function setupVite(app: Application) {
62
+ if (isDev) {
63
+ await setupViteMiddleware(app);
64
+ } else {
65
+ setupStaticServer(app);
66
+ }
67
+ }
@@ -0,0 +1,21 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ --background: #ffffff;
7
+ --foreground: #171717;
8
+ }
9
+
10
+ @media (prefers-color-scheme: dark) {
11
+ :root {
12
+ --background: #0a0a0a;
13
+ --foreground: #ededed;
14
+ }
15
+ }
16
+
17
+ body {
18
+ background: var(--background);
19
+ color: var(--foreground);
20
+ font-family: Arial, Helvetica, sans-serif;
21
+ }
@@ -0,0 +1,5 @@
1
+ import './index.css';
2
+ import { initApp } from './main';
3
+
4
+ // Initialize the application
5
+ initApp();
@@ -0,0 +1,34 @@
1
+ export function initApp(): void {
2
+ const app = document.getElementById('app');
3
+
4
+ if (!app) {
5
+ console.error('App element not found');
6
+ return;
7
+ }
8
+
9
+ app.innerHTML = `
10
+ <div class="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">
11
+ <main class="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
12
+ <div class="flex flex-col items-center justify-between gap-4">
13
+ <img
14
+ src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
15
+ alt="扣子编程 Logo"
16
+ width={156}
17
+ height={130}
18
+ style="width: 156px; height: 130px; object-fit: contain;"
19
+ />
20
+ <div>
21
+ <div class="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
22
+ <h1 class="max-w-xl text-base font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
23
+ 应用开发中
24
+ </h1>
25
+ <p class="max-w-2xl text-sm-14 leading-8 text-muted-foreground dark:text-muted-foreground">
26
+ 请稍后,页面即将呈现
27
+ </p>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </main>
32
+ </div>
33
+ `;
34
+ }
@@ -0,0 +1,9 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
4
+ darkMode: 'media',
5
+ theme: {
6
+ extend: {},
7
+ },
8
+ plugins: [],
9
+ };
@@ -0,0 +1,127 @@
1
+
2
+ import { spawn } from 'child_process';
3
+ import { resolve, join, basename } from 'path';
4
+ import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ export const paramsSchema = {
15
+ type: 'object',
16
+ properties: {
17
+ appName: {
18
+ type: 'string',
19
+ minLength: 1,
20
+ pattern: '^[a-z0-9-]+$',
21
+ description:
22
+ 'Application name (lowercase, alphanumeric and hyphens only)',
23
+ },
24
+ port: {
25
+ type: 'number',
26
+ default: 5000,
27
+ minimum: 1024,
28
+ maximum: 65535,
29
+ description: 'Development server port',
30
+ },
31
+ hmrPort: {
32
+ type: 'number',
33
+ default: 6000,
34
+ minimum: 1024,
35
+ maximum: 65535,
36
+ description: 'Development HMR server port',
37
+ },
38
+ },
39
+ required: [],
40
+ additionalProperties: false,
41
+ };
42
+
43
+ const description = `Vite(简单项目):\`coze init \${COZE_WORKSPACE_PATH} --template vite\`
44
+ - 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。`;
45
+
46
+ const config = {
47
+ description: description,
48
+ paramsSchema,
49
+
50
+ defaultParams: {
51
+ port: 5000,
52
+ hmrPort: 6000,
53
+ appName: 'projects',
54
+ },
55
+
56
+ onBeforeRender: async context => {
57
+ console.log(
58
+ `Creating Vanilla TypeScript + Vite project: ${context.appName}`,
59
+ );
60
+ return context;
61
+ },
62
+
63
+ onAfterRender: async (_context, outputPath) => {
64
+ console.log(`\nProject created at: ${outputPath}`);
65
+ console.log('\nConfiguration:');
66
+ console.log(' - Framework: vite');
67
+ console.log(' - TypeScript: enabled');
68
+ console.log(' - App Router: enabled');
69
+ console.log(` - Port: ${_context.port}`);
70
+ },
71
+
72
+ onComplete: async (_context, outputPath) => {
73
+ // Skip pnpm update in test environment to avoid monorepo workspace issues
74
+ if (process.env.NODE_ENV === 'test') {
75
+ console.log('⊘ Skipping dependency update in test environment');
76
+ return;
77
+ }
78
+
79
+ const cmd = 'pnpm';
80
+ const args = ['update', 'coze-coding-dev-sdk@^0.7.0'];
81
+ console.log(
82
+ `\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
83
+ );
84
+
85
+ try {
86
+ const projectRoot = resolve(outputPath);
87
+
88
+ // Determine log directory
89
+ const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
90
+ mkdirSync(logDir, { recursive: true });
91
+
92
+ // Use project name in log file to avoid conflicts
93
+ const projectName = basename(projectRoot);
94
+ const logFile = join(logDir, `${projectName}-init.log`);
95
+
96
+ // Write log header
97
+ const timestamp = new Date().toISOString();
98
+ appendFileSync(
99
+ logFile,
100
+ `\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
101
+ );
102
+
103
+ // Open log file for appending
104
+ const logFd = openSync(logFile, 'a');
105
+
106
+ // Spawn in detached mode
107
+ const child = spawn(cmd, args, {
108
+ cwd: projectRoot,
109
+ detached: true,
110
+ stdio: ['ignore', logFd, logFd],
111
+ });
112
+
113
+ child.unref();
114
+ closeSync(logFd);
115
+
116
+ console.log(
117
+ '✓ coze-coding-dev-sdk update triggered (running in background)',
118
+ );
119
+ console.log(` Log file: ${logFile}`);
120
+ } catch (error) {
121
+ console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
122
+ console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
123
+ }
124
+ },
125
+ };
126
+
127
+ export default config;
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "node",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "noEmit": true,
14
+ "types": ["node"]
15
+ },
16
+ "include": ["src", "server"]
17
+ }
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ export default defineConfig({
4
+ server: {
5
+ port: <%= port %>,
6
+ host: '0.0.0.0',
7
+ allowedHosts: true,
8
+ hmr: {
9
+ overlay: true,
10
+ path: '/hot/vite-hmr',
11
+ port: <%= hmrPort %>,
12
+ clientPort: 443,
13
+ timeout: 30000,
14
+ },
15
+ watch: {
16
+ usePolling: true,
17
+ interval: 100,
18
+ }
19
+ },
20
+ });