@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,2 @@
1
+ packages:
2
+ - 'server'
@@ -0,0 +1,15 @@
1
+ {
2
+ "miniprogramRoot": "./dist",
3
+ "projectname": "<%= appName %>",
4
+ "description": "test",
5
+ "appid": "touristappid",
6
+ "setting": {
7
+ "urlCheck": true,
8
+ "es6": false,
9
+ "enhance": false,
10
+ "compileHotReLoad": false,
11
+ "postcss": false,
12
+ "minified": false
13
+ },
14
+ "compileType": "miniprogram"
15
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
3
+ "collection": "@nestjs/schematics",
4
+ "sourceRoot": "src",
5
+ "compilerOptions": {
6
+ "deleteOutDir": true,
7
+ "exclude": ["node_modules", "dist", ".git", "../dist", "../src"]
8
+ },
9
+ "webpack": true
10
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "server",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "description": "NestJS server application",
6
+ "scripts": {
7
+ "build": "nest build",
8
+ "dev": "nest start --watch",
9
+ "start": "nest start",
10
+ "start:debug": "nest start --debug --watch",
11
+ "start:prod": "node dist/main"
12
+ },
13
+ "dependencies": {
14
+ "@aws-sdk/client-s3": "^3.958.0",
15
+ "@aws-sdk/lib-storage": "^3.958.0",
16
+ "@nestjs/common": "^10.4.15",
17
+ "@nestjs/core": "^10.4.15",
18
+ "@nestjs/platform-express": "^10.4.15",
19
+ "@supabase/supabase-js": "2.95.3",
20
+ "better-sqlite3": "^11.9.1",
21
+ "coze-coding-dev-sdk": "^0.7.16",
22
+ "dotenv": "^17.2.3",
23
+ "drizzle-kit": "^0.31.8",
24
+ "drizzle-orm": "^0.45.1",
25
+ "drizzle-zod": "^0.8.3",
26
+ "express": "5.2.1",
27
+ "pg": "^8.16.3",
28
+ "rxjs": "^7.8.1",
29
+ "zod": "^4.3.5"
30
+ },
31
+ "devDependencies": {
32
+ "@nestjs/cli": "^10.4.9",
33
+ "@nestjs/schematics": "^10.2.3",
34
+ "@types/better-sqlite3": "^7.6.13",
35
+ "@types/express": "5.0.6",
36
+ "@types/node": "^22.10.2",
37
+ "drizzle-kit": "^0.31.8",
38
+ "typescript": "^5.7.2"
39
+ }
40
+ }
@@ -0,0 +1,23 @@
1
+ import { Controller, Get } from '@nestjs/common';
2
+ import { AppService } from '@/app.service';
3
+
4
+ @Controller()
5
+ export class AppController {
6
+ constructor(private readonly appService: AppService) {}
7
+
8
+ @Get('hello')
9
+ getHello(): { status: string; data: string } {
10
+ return {
11
+ status: 'success',
12
+ data: this.appService.getHello()
13
+ };
14
+ }
15
+
16
+ @Get('health')
17
+ getHealth(): { status: string; data: string } {
18
+ return {
19
+ status: 'success',
20
+ data: new Date().toISOString(),
21
+ };
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ import { Module } from '@nestjs/common';
2
+ import { AppController } from '@/app.controller';
3
+ import { AppService } from '@/app.service';
4
+
5
+ @Module({
6
+ imports: [],
7
+ controllers: [AppController],
8
+ providers: [AppService],
9
+ })
10
+ export class AppModule {}
@@ -0,0 +1,8 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ @Injectable()
4
+ export class AppService {
5
+ getHello(): string {
6
+ return 'Hello, welcome to coze coding mini-program server!';
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import {
2
+ Injectable,
3
+ NestInterceptor,
4
+ ExecutionContext,
5
+ CallHandler,
6
+ } from '@nestjs/common';
7
+ import { Observable } from 'rxjs';
8
+ import { map } from 'rxjs/operators';
9
+
10
+ @Injectable()
11
+ export class HttpStatusInterceptor implements NestInterceptor {
12
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
13
+ const request = context.switchToHttp().getRequest();
14
+ const response = context.switchToHttp().getResponse();
15
+
16
+ // 如果是 POST 请求且状态码为 201,改为 200
17
+ if (request.method === 'POST' && response.statusCode === 201) {
18
+ response.status(200);
19
+ }
20
+
21
+ return next.handle();
22
+ }
23
+ }
@@ -0,0 +1,49 @@
1
+ import { NestFactory } from '@nestjs/core';
2
+ import { AppModule } from '@/app.module';
3
+ import * as express from 'express';
4
+ import { HttpStatusInterceptor } from '@/interceptors/http-status.interceptor';
5
+
6
+ function parsePort(): number {
7
+ const args = process.argv.slice(2);
8
+ const portIndex = args.indexOf('-p');
9
+ if (portIndex !== -1 && args[portIndex + 1]) {
10
+ const port = parseInt(args[portIndex + 1], 10);
11
+ if (!isNaN(port) && port > 0 && port < 65536) {
12
+ return port;
13
+ }
14
+ }
15
+ return <%= serverPort %>;
16
+ }
17
+
18
+ async function bootstrap() {
19
+ const app = await NestFactory.create(AppModule);
20
+
21
+ app.enableCors({
22
+ origin: true,
23
+ credentials: true,
24
+ });
25
+ app.setGlobalPrefix('api');
26
+ app.use(express.json({ limit: '50mb' }));
27
+ app.use(express.urlencoded({ limit: '50mb', extended: true }));
28
+
29
+ // 全局拦截器:统一将 POST 请求的 201 状态码改为 200
30
+ app.useGlobalInterceptors(new HttpStatusInterceptor());
31
+ // 1. 开启优雅关闭 Hooks (关键!)
32
+ app.enableShutdownHooks();
33
+
34
+ // 2. 解析端口
35
+ const port = parsePort();
36
+ try {
37
+ await app.listen(port);
38
+ console.log(`Server running on http://localhost:${port}`);
39
+ } catch (err) {
40
+ if (err.code === 'EADDRINUSE') {
41
+ console.error(`❌ 端口 \({port} 被占用! 请运行 'npx kill-port \){port}' 然后重试。`);
42
+ process.exit(1);
43
+ } else {
44
+ throw err;
45
+ }
46
+ }
47
+ console.log(`Application is running on: http://localhost:<%= serverPort %>`);
48
+ }
49
+ bootstrap();
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "target": "ES2021",
10
+ "sourceMap": true,
11
+ "outDir": "./dist",
12
+ "baseUrl": "./",
13
+ "incremental": true,
14
+ "skipLibCheck": true,
15
+ "strictNullChecks": true,
16
+ "noImplicitAny": false,
17
+ "strictBindCallApply": false,
18
+ "forceConsistentCasingInFileNames": false,
19
+ "noFallthroughCasesInSwitch": false,
20
+ "paths": {
21
+ "@/*": ["./src/*"]
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ export default defineAppConfig({
2
+ pages: [
3
+ 'pages/index/index'
4
+ ],
5
+ window: {
6
+ backgroundTextStyle: 'light',
7
+ navigationBarBackgroundColor: '#fff',
8
+ navigationBarTitleText: 'WeChat',
9
+ navigationBarTextStyle: 'black'
10
+ }
11
+ })
@@ -0,0 +1,156 @@
1
+ /* stylelint-disable selector-type-no-unknown */
2
+ /* stylelint-disable at-rule-no-unknown */
3
+ /* stylelint-disable number-max-precision */
4
+ @import url('weapp-tailwindcss');
5
+
6
+ /* 小程序页面容器高度设置,确保垂直居中生效 */
7
+ page {
8
+ height: 100%;
9
+ }
10
+
11
+ :root,
12
+ page,
13
+ root-portal {
14
+ --background: lab(100% 0 0);
15
+ --foreground: lab(2.75381% 0 0);
16
+ --card: lab(100% 0 0);
17
+ --card-foreground: lab(2.75381% 0 0);
18
+ --popover: lab(100% 0 0);
19
+ --popover-foreground: lab(2.75381% 0 0);
20
+ --primary: lab(7.78201% -0.0000149012 0);
21
+ --primary-foreground: lab(98.26% 0 0);
22
+ --secondary: lab(96.52% -0.0000298023 0.0000119209);
23
+ --secondary-foreground: lab(7.78201% -0.0000149012 0);
24
+ --muted: lab(96.52% -0.0000298023 0.0000119209);
25
+ --muted-foreground: lab(48.496% 0 0);
26
+ --accent: lab(96.52% -0.0000298023 0.0000119209);
27
+ --accent-foreground: lab(7.78201% -0.0000149012 0);
28
+ --destructive: lab(48.4493% 77.4328 61.5452);
29
+ --destructive-foreground: lab(96.4152% 3.22586 1.14673);
30
+ --border: lab(90.952% 0 -0.0000119209);
31
+ --input: lab(90.952% 0 -0.0000119209);
32
+ --ring: lab(66.128% -0.0000298023 0.0000119209);
33
+ --sidebar: lab(98.26% 0 0);
34
+ --sidebar-foreground: lab(2.75381% 0 0);
35
+ --sidebar-primary: lab(7.78201% -0.0000149012 0);
36
+ --sidebar-primary-foreground: lab(98.26% 0 0);
37
+ --sidebar-accent: lab(96.52% -0.0000298023 0.0000119209);
38
+ --sidebar-accent-foreground: lab(7.78201% -0.0000149012 0);
39
+ --sidebar-border: lab(90.952% 0 -0.0000119209);
40
+ --sidebar-ring: lab(66.128% -0.0000298023 0.0000119209);
41
+ --surface: lab(97.68% -0.0000298023 0.0000119209);
42
+ --code: var(--surface);
43
+ --code-highlight: lab(95.36% 0 0);
44
+ --code-number: lab(48.96% 0 0);
45
+ --selection: lab(2.75381% 0 0);
46
+ --selection-foreground: lab(100% 0 0);
47
+ --tw-shadow: 0 0 #0000;
48
+ --tw-shadow-color: initial;
49
+ --tw-shadow-alpha: 100%;
50
+ --tw-inset-shadow: 0 0 #0000;
51
+ --tw-inset-shadow-color: initial;
52
+ --tw-inset-shadow-alpha: 100%;
53
+ --tw-ring-color: initial;
54
+ --tw-ring-shadow: 0 0 #0000;
55
+ --tw-inset-ring-color: initial;
56
+ --tw-inset-ring-shadow: 0 0 #0000;
57
+ --tw-ring-inset: initial;
58
+ --tw-ring-offset-width: 0px;
59
+ --tw-ring-offset-color: #fff;
60
+ --tw-ring-offset-shadow: 0 0 #0000;
61
+ }
62
+
63
+ .dark {
64
+ --background: lab(2.75381% 0 0);
65
+ --foreground: lab(98.26% 0 0);
66
+ --card: lab(7.78201% -0.0000149012 0);
67
+ --card-foreground: lab(98.26% 0 0);
68
+ --popover: lab(7.78201% -0.0000149012 0);
69
+ --popover-foreground: lab(98.26% 0 0);
70
+ --primary: lab(90.952% 0 -0.0000119209);
71
+ --primary-foreground: lab(7.78201% -0.0000149012 0);
72
+ --secondary: lab(15.204% 0 -0.00000596046);
73
+ --secondary-foreground: lab(98.26% 0 0);
74
+ --muted: lab(15.204% 0 -0.00000596046);
75
+ --muted-foreground: lab(66.128% -0.0000298023 0.0000119209);
76
+ --accent: lab(27.036% 0 0);
77
+ --accent-foreground: lab(98.26% 0 0);
78
+ --destructive: lab(63.7053% 60.745 31.3109);
79
+ --destructive-foreground: lab(49.0747% 69.3434 49.6251);
80
+ --border: lab(100% 0 0 / 10%);
81
+ --input: lab(100% 0 0 / 15%);
82
+ --ring: lab(48.496% 0 0);
83
+ --sidebar: lab(7.78201% -0.0000149012 0);
84
+ --sidebar-foreground: lab(98.26% 0 0);
85
+ --sidebar-primary: lab(36.9089% 35.0961 -85.6872);
86
+ --sidebar-primary-foreground: lab(98.26% 0 0);
87
+ --sidebar-accent: lab(15.204% 0 -0.00000596046);
88
+ --sidebar-accent-foreground: lab(98.26% 0 0);
89
+ --sidebar-border: lab(100% 0 0 / 10%);
90
+ --sidebar-ring: lab(34.924% 0 0);
91
+ --surface: lab(7.22637% -0.0000149012 0);
92
+ --surface-foreground: lab(66.128% -0.0000298023 0.0000119209);
93
+ --code: var(--surface);
94
+ --code-highlight: lab(15.32% 0 0);
95
+ --code-number: lab(67.52% -0.0000298023 0);
96
+ --selection: lab(90.952% 0 -0.0000119209);
97
+ --selection-foreground: lab(7.78201% -0.0000149012 0);
98
+ }
99
+
100
+ @custom-variant dark (&:is(.dark *));
101
+
102
+ @theme inline {
103
+ --color-sidebar: var(--sidebar);
104
+ --color-sidebar-foreground: var(--sidebar-foreground);
105
+ --color-sidebar-primary: var(--sidebar-primary);
106
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
107
+ --color-sidebar-accent: var(--sidebar-accent);
108
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
109
+ --color-sidebar-border: var(--sidebar-border);
110
+ --color-sidebar-ring: var(--sidebar-ring);
111
+ --color-chart-5: var(--chart-5);
112
+ --color-chart-4: var(--chart-4);
113
+ --color-chart-3: var(--chart-3);
114
+ --color-chart-2: var(--chart-2);
115
+ --color-chart-1: var(--chart-1);
116
+ --color-ring: var(--ring);
117
+ --color-input: var(--input);
118
+ --color-border: var(--border);
119
+ --color-popover-foreground: var(--popover-foreground);
120
+ --color-popover: var(--popover);
121
+ --color-card-foreground: var(--card-foreground);
122
+ --color-card: var(--card);
123
+ --color-muted-foreground: var(--muted-foreground);
124
+ --color-muted: var(--muted);
125
+ --color-destructive-foreground: var(--destructive-foreground);
126
+ --color-destructive: var(--destructive);
127
+ --color-accent-foreground: var(--accent-foreground);
128
+ --color-accent: var(--accent);
129
+ --color-secondary-foreground: var(--secondary-foreground);
130
+ --color-secondary: var(--secondary);
131
+ --color-primary-foreground: var(--primary-foreground);
132
+ --color-primary: var(--primary);
133
+ --color-foreground: var(--foreground);
134
+ --color-background: var(--background);
135
+ --color-selection: var(--selection);
136
+ --color-selection-foreground: var(--selection-foreground);
137
+ --color-code: var(--code);
138
+ --radius-full: 9999px;
139
+ }
140
+
141
+ page,
142
+ view,
143
+ text,
144
+ button,
145
+ input,
146
+ textarea,
147
+ label,
148
+ scroll-view,
149
+ image {
150
+ border-color: var(--border);
151
+ }
152
+
153
+ ::selection {
154
+ background-color: var(--selection);
155
+ color: var(--selection-foreground);
156
+ }
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import '@/app.css';
3
+ import { Preset } from './presets';
4
+
5
+ const App = ({ children }: PropsWithChildren) => {
6
+ return <Preset>{children}</Preset>;
7
+ };
8
+
9
+ export default App;
@@ -0,0 +1,159 @@
1
+ import * as React from "react"
2
+ import { View } from "@tarojs/components"
3
+ import { ChevronsUpDown } from "lucide-react-taro"
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const AccordionContext = React.createContext<{
7
+ value?: string | string[]
8
+ onValueChange?: (value: string | string[]) => void
9
+ type?: "single" | "multiple"
10
+ } | null>(null)
11
+
12
+ const Accordion = React.forwardRef<
13
+ React.ElementRef<typeof View>,
14
+ React.ComponentPropsWithoutRef<typeof View> & {
15
+ type?: "single" | "multiple"
16
+ value?: string | string[]
17
+ defaultValue?: string | string[]
18
+ onValueChange?: (value: string | string[]) => void
19
+ collapsible?: boolean
20
+ }
21
+ >(({ className, type = "single", value: valueProp, defaultValue, onValueChange, collapsible = false, ...props }, ref) => {
22
+ const [valueState, setValueState] = React.useState<string | string[]>(
23
+ defaultValue || (type === "multiple" ? [] : "")
24
+ )
25
+ const value = valueProp !== undefined ? valueProp : valueState
26
+
27
+ const handleValueChange = (itemValue: string) => {
28
+ let newValue: string | string[]
29
+ if (type === "multiple") {
30
+ const current = Array.isArray(value) ? value : []
31
+ if (current.includes(itemValue)) {
32
+ newValue = current.filter(v => v !== itemValue)
33
+ } else {
34
+ newValue = [...current, itemValue]
35
+ }
36
+ } else {
37
+ if (value === itemValue && collapsible) {
38
+ newValue = ""
39
+ } else {
40
+ newValue = itemValue
41
+ }
42
+ }
43
+
44
+ if (valueProp === undefined) {
45
+ setValueState(newValue)
46
+ }
47
+ onValueChange?.(newValue)
48
+ }
49
+
50
+ return (
51
+ <AccordionContext.Provider value={{ value, onValueChange: handleValueChange, type }}>
52
+ <View ref={ref} className={className} {...props} />
53
+ </AccordionContext.Provider>
54
+ )
55
+ })
56
+ Accordion.displayName = "Accordion"
57
+
58
+ const AccordionItem = React.forwardRef<
59
+ React.ElementRef<typeof View>,
60
+ React.ComponentPropsWithoutRef<typeof View> & { value: string }
61
+ >(({ className, value, ...props }, ref) => (
62
+ <View ref={ref} className={cn("border-b", className)} {...props} data-value={value} />
63
+ ))
64
+ AccordionItem.displayName = "AccordionItem"
65
+
66
+ const AccordionTrigger = React.forwardRef<
67
+ React.ElementRef<typeof View>,
68
+ React.ComponentPropsWithoutRef<typeof View>
69
+ >(({ className, children, ...props }, ref) => {
70
+ // Need to find the parent AccordionItem's value.
71
+ // In React Native/Taro we can't easily traverse up DOM.
72
+ // So we assume AccordionItem passes context or we need to explicitly pass value?
73
+ // Radix does this via context nesting.
74
+ // Let's create a context for Item.
75
+ return (
76
+ <AccordionItemContext.Consumer>
77
+ {(itemValue) => <AccordionTriggerInternal itemValue={itemValue} className={className} ref={ref} {...props}>{children}</AccordionTriggerInternal>}
78
+ </AccordionItemContext.Consumer>
79
+ )
80
+ })
81
+ AccordionTrigger.displayName = "AccordionTrigger"
82
+
83
+ // Helper context for Item
84
+ const AccordionItemContext = React.createContext<string>("")
85
+
86
+ // Update AccordionItem to provide context
87
+ const AccordionItemWithContext = React.forwardRef<
88
+ React.ElementRef<typeof View>,
89
+ React.ComponentPropsWithoutRef<typeof View> & { value: string }
90
+ >(({ className, value, children, ...props }, ref) => (
91
+ <AccordionItemContext.Provider value={value}>
92
+ <View ref={ref} className={cn("border-b", className)} {...props}>
93
+ {children}
94
+ </View>
95
+ </AccordionItemContext.Provider>
96
+ ))
97
+ AccordionItemWithContext.displayName = "AccordionItem"
98
+
99
+
100
+ const AccordionTriggerInternal = React.forwardRef<
101
+ React.ElementRef<typeof View>,
102
+ React.ComponentPropsWithoutRef<typeof View> & { itemValue: string }
103
+ >(({ className, children, itemValue, ...props }, ref) => {
104
+ const context = React.useContext(AccordionContext)
105
+ const isOpen = Array.isArray(context?.value)
106
+ ? context?.value.includes(itemValue)
107
+ : context?.value === itemValue
108
+
109
+ return (
110
+ <View className="flex">
111
+ <View
112
+ ref={ref}
113
+ className={cn(
114
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all",
115
+ className
116
+ )}
117
+ onClick={() => context?.onValueChange?.(itemValue)}
118
+ {...props}
119
+ >
120
+ {children}
121
+ <ChevronsUpDown className={cn("shrink-0 transition-transform duration-200", isOpen && "rotate-180")} size={16} />
122
+ </View>
123
+ </View>
124
+ )
125
+ })
126
+
127
+ const AccordionContent = React.forwardRef<
128
+ React.ElementRef<typeof View>,
129
+ React.ComponentPropsWithoutRef<typeof View>
130
+ >(({ className, children, ...props }, ref) => (
131
+ <AccordionItemContext.Consumer>
132
+ {(itemValue) => <AccordionContentInternal itemValue={itemValue} className={className} ref={ref} {...props}>{children}</AccordionContentInternal>}
133
+ </AccordionItemContext.Consumer>
134
+ ))
135
+ AccordionContent.displayName = "AccordionContent"
136
+
137
+ const AccordionContentInternal = React.forwardRef<
138
+ React.ElementRef<typeof View>,
139
+ React.ComponentPropsWithoutRef<typeof View> & { itemValue: string }
140
+ >(({ className, children, itemValue, ...props }, ref) => {
141
+ const context = React.useContext(AccordionContext)
142
+ const isOpen = Array.isArray(context?.value)
143
+ ? context?.value.includes(itemValue)
144
+ : context?.value === itemValue
145
+
146
+ if (!isOpen) return null
147
+
148
+ return (
149
+ <View
150
+ ref={ref}
151
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
152
+ {...props}
153
+ >
154
+ <View className={cn("pb-4 pt-0", className)}>{children}</View>
155
+ </View>
156
+ )
157
+ })
158
+
159
+ export { Accordion, AccordionItemWithContext as AccordionItem, AccordionTrigger, AccordionContent }