wexts 3.0.2 → 4.0.0

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 (276) hide show
  1. package/README.md +49 -346
  2. package/bin/wexts.cjs +2 -0
  3. package/dist/chunk-2KAQYLVN.js +0 -0
  4. package/dist/chunk-2KAQYLVN.js.map +1 -1
  5. package/dist/{chunk-O42L6HOX.js → chunk-2LJVUMXW.js} +79 -93
  6. package/dist/chunk-2LJVUMXW.js.map +1 -0
  7. package/dist/chunk-7QKLIVRF.js +94 -0
  8. package/dist/chunk-7QKLIVRF.js.map +1 -0
  9. package/dist/{chunk-FCEZDH42.mjs → chunk-7WULUGLH.mjs} +5 -3
  10. package/dist/chunk-7WULUGLH.mjs.map +1 -0
  11. package/dist/{chunk-WF65EDRZ.js → chunk-BG56B4DE.js} +20 -2
  12. package/dist/chunk-BG56B4DE.js.map +1 -0
  13. package/dist/chunk-CLM5PNSG.mjs +496 -0
  14. package/dist/chunk-CLM5PNSG.mjs.map +1 -0
  15. package/dist/chunk-DNLGCKTT.js +31 -0
  16. package/dist/chunk-DNLGCKTT.js.map +1 -0
  17. package/dist/{chunk-VNNVLQLJ.mjs → chunk-JHOVXH3X.mjs} +2 -2
  18. package/dist/chunk-JHOVXH3X.mjs.map +1 -0
  19. package/dist/chunk-MXINIFPC.js +105 -0
  20. package/dist/chunk-MXINIFPC.js.map +1 -0
  21. package/dist/chunk-SE32ZPOZ.js +496 -0
  22. package/dist/chunk-SE32ZPOZ.js.map +1 -0
  23. package/dist/{chunk-STTOPUZ2.mjs → chunk-UAL54DVV.mjs} +21 -3
  24. package/dist/chunk-UAL54DVV.mjs.map +1 -0
  25. package/dist/{chunk-3OM7CHCA.js → chunk-WCKSKU3C.js} +1 -1
  26. package/dist/chunk-WCKSKU3C.js.map +1 -0
  27. package/dist/chunk-WU6FW77M.mjs +105 -0
  28. package/dist/chunk-WU6FW77M.mjs.map +1 -0
  29. package/dist/chunk-XE4OXN2W.js +0 -0
  30. package/dist/chunk-XE4OXN2W.js.map +1 -1
  31. package/dist/chunk-YBM3IJEA.mjs +94 -0
  32. package/dist/chunk-YBM3IJEA.mjs.map +1 -0
  33. package/dist/{chunk-KXYLEUSW.mjs → chunk-YN6WIWNQ.mjs} +69 -83
  34. package/dist/chunk-YN6WIWNQ.mjs.map +1 -0
  35. package/dist/chunk-YSLEF5C5.mjs +0 -0
  36. package/dist/chunk-YSLEF5C5.mjs.map +0 -0
  37. package/dist/chunk-ZX7QIN24.mjs +31 -0
  38. package/dist/chunk-ZX7QIN24.mjs.map +1 -0
  39. package/dist/cli/index.d.mts +10 -0
  40. package/dist/cli/index.d.ts +10 -0
  41. package/dist/cli/index.js +292 -292
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/cli/index.mjs +294 -293
  44. package/dist/cli/index.mjs.map +1 -1
  45. package/dist/client/index.d.mts +10 -1
  46. package/dist/client/index.d.ts +10 -1
  47. package/dist/client/index.js +4 -2
  48. package/dist/client/index.js.map +1 -1
  49. package/dist/client/index.mjs +6 -4
  50. package/dist/client/index.mjs.map +0 -0
  51. package/dist/codegen/index.d.mts +2 -1
  52. package/dist/codegen/index.d.ts +2 -1
  53. package/dist/codegen/index.js +5 -3
  54. package/dist/codegen/index.js.map +1 -1
  55. package/dist/codegen/index.mjs +7 -5
  56. package/dist/codegen/index.mjs.map +0 -0
  57. package/dist/decorators-BT1FFqN0.d.mts +29 -0
  58. package/dist/decorators-DvS58PqC.d.ts +29 -0
  59. package/dist/dev-server/index.d.mts +1 -1
  60. package/dist/dev-server/index.d.ts +1 -1
  61. package/dist/dev-server/index.js +3 -3
  62. package/dist/dev-server/index.js.map +1 -1
  63. package/dist/dev-server/index.mjs +3 -3
  64. package/dist/dev-server/index.mjs.map +0 -0
  65. package/dist/{index-SjUaHgFr.d.ts → index-7QeQEf37.d.ts} +27 -10
  66. package/dist/{index-tFGPFVfQ.d.mts → index-7RvU-jGE.d.mts} +0 -1
  67. package/dist/{index-tFGPFVfQ.d.ts → index-7RvU-jGE.d.ts} +0 -1
  68. package/dist/{index-SjUaHgFr.d.mts → index-8nzxy0NN.d.mts} +27 -10
  69. package/dist/index-Co5ZsLqq.d.ts +58 -0
  70. package/dist/index-D94W1__r.d.mts +58 -0
  71. package/dist/index-DQmyVp6F.d.mts +27 -0
  72. package/dist/index-KL_1BrQb.d.ts +27 -0
  73. package/dist/index.d.mts +17 -6
  74. package/dist/index.d.ts +17 -6
  75. package/dist/index.js +57 -30
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +48 -21
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/nest/index.d.mts +3 -1
  80. package/dist/nest/index.d.ts +3 -1
  81. package/dist/nest/index.js +20 -2
  82. package/dist/nest/index.js.map +1 -1
  83. package/dist/nest/index.mjs +21 -3
  84. package/dist/nest/index.mjs.map +0 -0
  85. package/dist/next/index.d.mts +7 -2
  86. package/dist/next/index.d.ts +7 -2
  87. package/dist/next/index.js +72 -5
  88. package/dist/next/index.js.map +1 -1
  89. package/dist/next/index.mjs +70 -4
  90. package/dist/next/index.mjs.map +1 -1
  91. package/dist/rpc/index.d.mts +2 -0
  92. package/dist/rpc/index.d.ts +2 -0
  93. package/dist/rpc/index.js +23 -0
  94. package/dist/rpc/index.js.map +1 -0
  95. package/dist/rpc/index.mjs +23 -0
  96. package/dist/{chunk-7NSRDJ5C.mjs.map → rpc/index.mjs.map} +0 -0
  97. package/dist/runtime/index.d.mts +55 -0
  98. package/dist/runtime/index.d.ts +55 -0
  99. package/dist/runtime/index.js +213 -0
  100. package/dist/runtime/index.js.map +1 -0
  101. package/dist/runtime/index.mjs +213 -0
  102. package/dist/runtime/index.mjs.map +1 -0
  103. package/dist/types/index.d.mts +0 -0
  104. package/dist/types/index.d.ts +0 -0
  105. package/dist/types/index.js +0 -0
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/index.mjs +1 -1
  108. package/dist/types/index.mjs.map +0 -0
  109. package/dist/types-7d_fC-C3.d.mts +32 -0
  110. package/dist/types-7d_fC-C3.d.ts +32 -0
  111. package/dist/vercel-builder/index.d.mts +58 -0
  112. package/dist/vercel-builder/index.d.ts +58 -0
  113. package/dist/vercel-builder/index.js +330 -0
  114. package/dist/vercel-builder/index.js.map +1 -0
  115. package/dist/vercel-builder/index.mjs +330 -0
  116. package/dist/vercel-builder/index.mjs.map +1 -0
  117. package/package.json +37 -16
  118. package/templates/.dockerignore +43 -43
  119. package/templates/.env.example +0 -0
  120. package/templates/Dockerfile +60 -60
  121. package/templates/Procfile +1 -1
  122. package/templates/README.md +67 -58
  123. package/templates/api-sdk.ts +115 -115
  124. package/templates/docker-compose.yml +34 -34
  125. package/templates/nestjs-api/.env.example +0 -0
  126. package/templates/nestjs-api/README.md +87 -79
  127. package/templates/nestjs-api/nest-cli.json +6 -6
  128. package/templates/nestjs-api/package-lock.json +5623 -5623
  129. package/templates/nestjs-api/package.json +40 -40
  130. package/templates/nestjs-api/prisma/dev.db +0 -0
  131. package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +0 -0
  132. package/templates/nestjs-api/prisma/migrations/migration_lock.toml +0 -0
  133. package/templates/nestjs-api/prisma/schema.prisma +29 -29
  134. package/templates/nestjs-api/src/app.module.ts +17 -17
  135. package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
  136. package/templates/nestjs-api/src/auth/auth.module.ts +37 -29
  137. package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
  138. package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
  139. package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
  140. package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -19
  141. package/templates/nestjs-api/src/main.ts +32 -32
  142. package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
  143. package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
  144. package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
  145. package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
  146. package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
  147. package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
  148. package/templates/nestjs-api/src/users/users.controller.ts +14 -14
  149. package/templates/nestjs-api/src/users/users.module.ts +12 -12
  150. package/templates/nestjs-api/src/users/users.service.ts +19 -19
  151. package/templates/nestjs-api/tsconfig.json +39 -39
  152. package/templates/nextjs-web/README.md +76 -68
  153. package/templates/nextjs-web/app/actions/auth.ts +108 -108
  154. package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
  155. package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
  156. package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
  157. package/templates/nextjs-web/app/globals.css +93 -93
  158. package/templates/nextjs-web/app/layout.tsx +29 -29
  159. package/templates/nextjs-web/app/login/page.tsx +5 -5
  160. package/templates/nextjs-web/app/page.tsx +28 -28
  161. package/templates/nextjs-web/app/register/page.tsx +5 -5
  162. package/templates/nextjs-web/components/ui/button.tsx +56 -56
  163. package/templates/nextjs-web/components/ui/card.tsx +79 -79
  164. package/templates/nextjs-web/components/ui/input.tsx +25 -25
  165. package/templates/nextjs-web/components/ui/label.tsx +24 -24
  166. package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
  167. package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
  168. package/templates/nextjs-web/features/auth/api.ts +35 -35
  169. package/templates/nextjs-web/features/auth/index.ts +3 -3
  170. package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
  171. package/templates/nextjs-web/features/dashboard/api.ts +9 -9
  172. package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
  173. package/templates/nextjs-web/features/dashboard/index.ts +3 -3
  174. package/templates/nextjs-web/hooks/index.ts +4 -4
  175. package/templates/nextjs-web/lib/api-client.ts +89 -89
  176. package/templates/nextjs-web/lib/api.ts +115 -115
  177. package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
  178. package/templates/nextjs-web/lib/utils.ts +6 -6
  179. package/templates/nextjs-web/lib/wexts-client.ts +4 -4
  180. package/templates/nextjs-web/next-env.d.ts +6 -6
  181. package/templates/nextjs-web/next.config.ts +20 -20
  182. package/templates/nextjs-web/package-lock.json +3254 -3254
  183. package/templates/nextjs-web/package.json +37 -37
  184. package/templates/nextjs-web/postcss.config.js +6 -6
  185. package/templates/nextjs-web/tailwind.config.ts +69 -69
  186. package/templates/nextjs-web/tsconfig.json +1 -1
  187. package/templates/nixpacks.toml +11 -11
  188. package/templates/root-package.json +31 -31
  189. package/templates/server.ts +66 -66
  190. package/templates/tsconfig.json +30 -30
  191. package/dist/chunk-2MCBBWEA.js +0 -1
  192. package/dist/chunk-2MCBBWEA.js.map +0 -1
  193. package/dist/chunk-3OM7CHCA.js.map +0 -1
  194. package/dist/chunk-63MTCWU2.mjs +0 -361
  195. package/dist/chunk-63MTCWU2.mjs.map +0 -1
  196. package/dist/chunk-667BQCEM.js +0 -375
  197. package/dist/chunk-667BQCEM.js.map +0 -1
  198. package/dist/chunk-67IJ6H4J.mjs +0 -44
  199. package/dist/chunk-67IJ6H4J.mjs.map +0 -1
  200. package/dist/chunk-6SVQEGEX.mjs +0 -44
  201. package/dist/chunk-6SVQEGEX.mjs.map +0 -1
  202. package/dist/chunk-7NSRDJ5C.mjs +0 -1
  203. package/dist/chunk-ASDXAK6G.js +0 -44
  204. package/dist/chunk-ASDXAK6G.js.map +0 -1
  205. package/dist/chunk-CKZ4VSCB.mjs +0 -18
  206. package/dist/chunk-CKZ4VSCB.mjs.map +0 -1
  207. package/dist/chunk-DW6GOKMF.js +0 -57
  208. package/dist/chunk-DW6GOKMF.js.map +0 -1
  209. package/dist/chunk-EFZPSZWO.mjs +0 -1
  210. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  211. package/dist/chunk-FCEZDH42.mjs.map +0 -1
  212. package/dist/chunk-FYGXL4V7.js +0 -361
  213. package/dist/chunk-FYGXL4V7.js.map +0 -1
  214. package/dist/chunk-GKVPGKAH.js +0 -66
  215. package/dist/chunk-GKVPGKAH.js.map +0 -1
  216. package/dist/chunk-GWP6PNSP.js +0 -225
  217. package/dist/chunk-GWP6PNSP.js.map +0 -1
  218. package/dist/chunk-HQKTXE7E.mjs +0 -225
  219. package/dist/chunk-HQKTXE7E.mjs.map +0 -1
  220. package/dist/chunk-HSFLZUJN.mjs +0 -57
  221. package/dist/chunk-HSFLZUJN.mjs.map +0 -1
  222. package/dist/chunk-HU63F22V.js +0 -361
  223. package/dist/chunk-HU63F22V.js.map +0 -1
  224. package/dist/chunk-J5LGTIGS.mjs +0 -10
  225. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  226. package/dist/chunk-JMBD6DOP.js +0 -225
  227. package/dist/chunk-JMBD6DOP.js.map +0 -1
  228. package/dist/chunk-K7EIJSYQ.js +0 -1
  229. package/dist/chunk-K7EIJSYQ.js.map +0 -1
  230. package/dist/chunk-KXYLEUSW.mjs.map +0 -1
  231. package/dist/chunk-MTHKZO55.js +0 -44
  232. package/dist/chunk-MTHKZO55.js.map +0 -1
  233. package/dist/chunk-NNQFLD7O.mjs +0 -361
  234. package/dist/chunk-NNQFLD7O.mjs.map +0 -1
  235. package/dist/chunk-NU2UB242.js +0 -82
  236. package/dist/chunk-NU2UB242.js.map +0 -1
  237. package/dist/chunk-NULGSZFE.mjs +0 -57
  238. package/dist/chunk-NULGSZFE.mjs.map +0 -1
  239. package/dist/chunk-O42L6HOX.js.map +0 -1
  240. package/dist/chunk-ONXNE2A6.mjs +0 -375
  241. package/dist/chunk-ONXNE2A6.mjs.map +0 -1
  242. package/dist/chunk-OTBYRUBE.mjs +0 -225
  243. package/dist/chunk-OTBYRUBE.mjs.map +0 -1
  244. package/dist/chunk-OTSAVKLY.mjs +0 -66
  245. package/dist/chunk-OTSAVKLY.mjs.map +0 -1
  246. package/dist/chunk-PZ5AY32C.js +0 -10
  247. package/dist/chunk-PZ5AY32C.js.map +0 -1
  248. package/dist/chunk-QP2TMRLG.js +0 -57
  249. package/dist/chunk-QP2TMRLG.js.map +0 -1
  250. package/dist/chunk-RS23R3ZQ.mjs +0 -82
  251. package/dist/chunk-RS23R3ZQ.mjs.map +0 -1
  252. package/dist/chunk-STTOPUZ2.mjs.map +0 -1
  253. package/dist/chunk-VMT3LALB.mjs +0 -51
  254. package/dist/chunk-VMT3LALB.mjs.map +0 -1
  255. package/dist/chunk-VNNVLQLJ.mjs.map +0 -1
  256. package/dist/chunk-W3YRVEFQ.js +0 -66
  257. package/dist/chunk-W3YRVEFQ.js.map +0 -1
  258. package/dist/chunk-WF65EDRZ.js.map +0 -1
  259. package/dist/chunk-WMHVXEYQ.mjs +0 -66
  260. package/dist/chunk-WMHVXEYQ.mjs.map +0 -1
  261. package/dist/chunk-XVKTIYHY.js +0 -51
  262. package/dist/chunk-XVKTIYHY.js.map +0 -1
  263. package/dist/codegen-MRZDLCYI.js +0 -13
  264. package/dist/codegen-MRZDLCYI.js.map +0 -1
  265. package/dist/codegen-UI5HTMXE.mjs +0 -13
  266. package/dist/codegen-UI5HTMXE.mjs.map +0 -1
  267. package/dist/dev-server-JKRVBWPY.mjs +0 -13
  268. package/dist/dev-server-JKRVBWPY.mjs.map +0 -1
  269. package/dist/dev-server-TLL7UQMR.js +0 -13
  270. package/dist/dev-server-TLL7UQMR.js.map +0 -1
  271. package/dist/index-BsNaOUtH.d.mts +0 -44
  272. package/dist/index-BsNaOUtH.d.ts +0 -44
  273. package/dist/index-CrbXnXsO.d.ts +0 -62
  274. package/dist/index-kEbGExWM.d.mts +0 -62
  275. package/templates/nestjs-api/.env +0 -4
  276. package/templates/nextjs-web/.env +0 -1
@@ -1,333 +1,334 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  logger
4
- } from "../chunk-VNNVLQLJ.mjs";
4
+ } from "../chunk-JHOVXH3X.mjs";
5
5
  import {
6
6
  __dirname,
7
+ __filename,
7
8
  __name
8
- } from "../chunk-FCEZDH42.mjs";
9
+ } from "../chunk-7WULUGLH.mjs";
9
10
 
10
11
  // src/cli/index.ts
11
12
  import { Command } from "commander";
12
- import * as pc from "picocolors";
13
- import inquirer from "inquirer";
14
13
  import * as fs from "fs";
15
14
  import * as path from "path";
16
- import { execSync } from "child_process";
17
- var program = new Command();
18
- program.name("wexts").description("Wexts Framework - Next.js 16 + NestJS 11").version("2.0.0");
19
- program.action(async () => {
20
- console.log(pc.cyan(`
21
- \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
22
- \u2551 \u2551
23
- \u2551 ${pc.bold("\u{1F680} Wexts Framework v2.0")} \u2551
24
- \u2551 \u2551
25
- \u2551 Next.js 16 + NestJS 11 Full-Stack \u2551
26
- \u2551 \u2551
27
- \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
28
- `));
29
- const { action } = await inquirer.prompt([
30
- {
31
- type: "list",
32
- name: "action",
33
- message: "What would you like to do?",
34
- choices: [
35
- {
36
- name: "\u{1F4E6} Create a new project",
37
- value: "create"
38
- },
39
- {
40
- name: "\u{1F680} Start development server",
41
- value: "dev"
42
- },
43
- {
44
- name: "\u{1F528} Build for production",
45
- value: "build"
46
- },
47
- {
48
- name: "\u26A1 Generate code",
49
- value: "generate"
50
- },
51
- {
52
- name: "\u{1F916} Generate API client",
53
- value: "codegen"
54
- },
55
- {
56
- name: "\u274C Exit",
57
- value: "exit"
58
- }
59
- ]
60
- }
61
- ]);
62
- if (action === "exit") {
63
- logger.info("Goodbye! \u{1F44B}");
64
- process.exit(0);
65
- }
66
- if (action === "create") {
67
- const { projectName, template } = await inquirer.prompt([
68
- {
69
- type: "input",
70
- name: "projectName",
71
- message: "Project name:",
72
- default: "my-wexts-app"
73
- },
74
- {
75
- type: "list",
76
- name: "template",
77
- message: "Select template:",
78
- choices: [
79
- {
80
- name: "\u{1F4E6} Monorepo (Next.js + NestJS)",
81
- value: "monorepo"
82
- },
83
- {
84
- name: "\u{1F3AF} API only (NestJS)",
85
- value: "api"
86
- },
87
- {
88
- name: "\u{1F310} Web only (Next.js)",
89
- value: "web"
90
- }
91
- ]
92
- }
93
- ]);
94
- await createProject(projectName, template);
95
- } else if (action === "dev") {
96
- logger.info(pc.green("\u{1F680} Starting development servers...\n"));
97
- logger.warn("Dev server not yet implemented");
98
- } else if (action === "build") {
99
- logger.info(pc.blue("\u{1F528} Building project...\n"));
100
- logger.warn("Build not yet implemented");
101
- } else if (action === "generate") {
102
- const { type, name } = await inquirer.prompt([
103
- {
104
- type: "list",
105
- name: "type",
106
- message: "What to generate?",
107
- choices: [
108
- "controller",
109
- "module",
110
- "service",
111
- "page"
112
- ]
113
- },
114
- {
115
- type: "input",
116
- name: "name",
117
- message: "Name:"
118
- }
119
- ]);
120
- logger.info(pc.magenta(`
121
- \u26A1 Generating ${type}: ${name}
122
- `));
123
- logger.warn("Code generation not yet implemented");
124
- } else if (action === "codegen") {
125
- logger.info(pc.cyan("\n\u{1F916} Generating API client...\n"));
126
- logger.warn("Codegen not yet implemented");
127
- }
128
- });
129
- program.command("create <project-name>").description("Create a new wexts project").option("-t, --template <template>", "Template to use (monorepo|api|web)", "monorepo").action(async (projectName, options) => {
130
- await createProject(projectName, options.template);
131
- });
132
- program.command("dev").description("Start development servers").option("-a, --api <path>", "Path to API project", "./apps/api").option("-w, --web <path>", "Path to Web project", "./apps/web").option("-p, --port <port>", "Port for web server", "3000").option("--api-port <port>", "Port for API server", "5050").option("--no-proxy", "Disable proxy server").action(async (options) => {
133
- logger.info(pc.green("\u{1F680} Starting Wexts development servers...\n"));
134
- const { FusionDevServer } = await import("../dev-server/index.mjs");
135
- const server = new FusionDevServer();
136
- try {
15
+ import { spawnSync } from "child_process";
16
+ import { createRequire } from "module";
17
+ function createCliProgram() {
18
+ const program = new Command();
19
+ program.name("wexts").description("Wexts - production-focused single-runtime Next.js + NestJS toolkit").version("3.0.3");
20
+ program.command("create <project-name>").description("Create a compatibility project from bundled legacy templates").option("-t, --template <template>", "Legacy template to use (monorepo|api|web)", "monorepo").option("--skip-install", "Skip dependency installation", false).action(async (projectName, options) => {
21
+ await createProject(projectName, options.template, {
22
+ skipInstall: options.skipInstall
23
+ });
24
+ });
25
+ program.command("dev").description("Start local development processes").option("-a, --api <path>", "Path to API project", "./apps/api").option("-w, --web <path>", "Path to Web project", "./apps/web").option("-p, --port <port>", "Port for web server", "3000").option("--api-port <port>", "Port for API server", "5050").option("--proxy", "Enable development proxy on a separate proxy port", false).action(async (options) => {
26
+ const { FusionDevServer } = await import("../dev-server/index.mjs");
27
+ const server = new FusionDevServer();
137
28
  await server.start({
138
29
  apiPath: options.api,
139
30
  webPath: options.web,
140
- webPort: parseInt(options.port),
141
- apiPort: parseInt(options.apiPort),
31
+ webPort: Number(options.port),
32
+ apiPort: Number(options.apiPort),
142
33
  useProxy: options.proxy
143
34
  });
144
- } catch (error) {
145
- logger.error("Failed to start dev server:", error.message);
146
- process.exit(1);
147
- }
148
- });
149
- program.command("build").description("Build for production").action(async () => {
150
- logger.info(pc.blue("Building Wexts project..."));
151
- logger.warn("Build not yet implemented");
152
- });
153
- program.command("generate <type> <name>").alias("g").description("Generate code (controller|module|page)").action(async (type, name) => {
154
- logger.info(pc.magenta(`Generating ${type}: ${name}`));
155
- logger.warn("Code generation not yet implemented");
156
- });
157
- program.command("codegen").description("Generate API client from NestJS controllers").option("-w, --watch", "Watch mode - regenerate on changes").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output path for generated client", "./packages/api-client/src").action(async (options) => {
158
- const { NestJSParser, ClientGenerator, CodegenWatcher } = await import("../codegen/index.mjs");
159
- if (options.watch) {
160
- logger.info(pc.cyan("Starting codegen in watch mode..."));
161
- const watcher = new CodegenWatcher();
162
- await watcher.watch({
163
- projectPath: options.project,
164
- outputPath: options.output
35
+ });
36
+ program.command("generate [type] [name]").alias("g").description("Generate RPC manifest/client, or scaffold a minimal RPC service").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").action(async (type, name, options) => {
37
+ if (!type || type === "rpc") {
38
+ const { generateRpcClient } = await import("../codegen/index.mjs");
39
+ const manifest = await generateRpcClient({
40
+ projectPath: path.resolve(options.project),
41
+ outputPath: path.resolve(options.output)
42
+ });
43
+ logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
44
+ return;
45
+ }
46
+ if (type === "service") {
47
+ if (!name) throw new Error("Service name is required: wexts generate service hello");
48
+ await scaffoldRpcService(path.resolve(options.project), name);
49
+ logger.success(`Created RPC service ${name}. Run wexts generate to update the client.`);
50
+ return;
51
+ }
52
+ throw new Error(`Unknown generator "${type}". Supported generators: rpc, service.`);
53
+ });
54
+ program.command("codegen").description("Alias for wexts generate rpc").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").action(async (options) => {
55
+ const { generateRpcClient } = await import("../codegen/index.mjs");
56
+ const manifest = await generateRpcClient({
57
+ projectPath: path.resolve(options.project),
58
+ outputPath: path.resolve(options.output)
165
59
  });
166
- } else {
167
- logger.info(pc.cyan("Generating API client..."));
168
- const parser = new NestJSParser(options.project);
169
- const controllers = parser.findFusionControllers();
170
- const generator = new ClientGenerator();
171
- await generator.generate({
172
- controllers,
173
- outputPath: options.output
60
+ logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
61
+ });
62
+ program.command("build").description("Build a Wexts project for production").option("--skip-generate", "Skip RPC generation before build", false).option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output directory for generated RPC client", "./apps/web/lib/wexts").action(async (options) => {
63
+ if (!options.skipGenerate && fs.existsSync(options.project)) {
64
+ const { generateRpcClient } = await import("../codegen/index.mjs");
65
+ await generateRpcClient({
66
+ projectPath: path.resolve(options.project),
67
+ outputPath: path.resolve(options.output)
68
+ });
69
+ }
70
+ runScript("build", {
71
+ cwd: process.cwd()
72
+ });
73
+ });
74
+ program.command("start").description("Start the production Wexts runtime").option("-c, --config <path>", "Runtime config module path", "./wexts.runtime.js").option("-p, --port <port>", "Port to listen on", process.env.PORT ?? "3000").action(async (options) => {
75
+ const { startWextsRuntime } = await import("../runtime/index.mjs");
76
+ const configPath = path.resolve(options.config);
77
+ const runtimeConfig = fs.existsSync(configPath) ? await loadRuntimeConfig(configPath) : {};
78
+ await startWextsRuntime({
79
+ ...runtimeConfig,
80
+ port: Number(options.port),
81
+ dev: false
174
82
  });
83
+ });
84
+ program.command("vercel-build").description("Build for Vercel using Build Output API v3").option("-p, --project <path>", "Path to NestJS project", "./apps/api").option("-o, --output <path>", "Output dir for RPC client", "./apps/web/lib/wexts").option("-c, --config <path>", "Runtime config module path", "./wexts.runtime.js").option("--skip-codegen", "Skip RPC generation", false).option("--skip-build", "Skip project build step", false).option("--node-version <version>", "Node.js version for Vercel function", "20").option("--max-duration <seconds>", "Max duration for serverless function", "30").action(async (options) => {
85
+ const { buildVercelOutput } = await import("../vercel-builder/index.mjs");
86
+ const result = await buildVercelOutput({
87
+ rootDir: process.cwd(),
88
+ apiProjectPath: options.project,
89
+ rpcOutputPath: options.output,
90
+ runtimeConfigPath: options.config,
91
+ skipCodegen: options.skipCodegen,
92
+ skipBuild: options.skipBuild,
93
+ nodeVersion: options.nodeVersion,
94
+ maxDuration: Number(options.maxDuration)
95
+ });
96
+ if (result.warnings.length > 0) {
97
+ for (const warning of result.warnings) logger.warn(warning);
98
+ }
99
+ if (result.errors.length > 0) {
100
+ for (const error of result.errors) logger.error(error);
101
+ process.exit(1);
102
+ }
103
+ logger.success("Vercel build output ready at .vercel/output");
104
+ });
105
+ program.command("doctor").description("Validate Wexts project configuration").option("--security", "Run security-specific checks", false).action(async (options) => {
106
+ const result = runDoctor(process.cwd(), options.security);
107
+ for (const warning of result.warnings) logger.warn(warning);
108
+ for (const error of result.errors) logger.error(error);
109
+ if (result.errors.length > 0) process.exit(1);
110
+ logger.success(options.security ? "Security doctor passed." : "Doctor passed.");
111
+ });
112
+ return program;
113
+ }
114
+ __name(createCliProgram, "createCliProgram");
115
+ function runDoctor(cwd, security = false) {
116
+ const result = {
117
+ errors: [],
118
+ warnings: []
119
+ };
120
+ const pkgPath = path.join(cwd, "package.json");
121
+ if (!fs.existsSync(pkgPath)) {
122
+ result.errors.push("package.json not found.");
123
+ return result;
175
124
  }
176
- });
177
- async function createProject(projectName, template) {
178
- logger.info(pc.cyan(`Creating wexts project: ${pc.bold(projectName)}`));
179
- logger.info(`Template: ${template}`);
180
- const projectPath = path.join(process.cwd(), projectName);
181
- if (fs.existsSync(projectPath)) {
182
- logger.error(`Directory ${projectName} already exists!`);
183
- process.exit(1);
125
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
126
+ if (!pkg.packageManager?.startsWith("pnpm@")) {
127
+ result.warnings.push("packageManager should pin pnpm.");
184
128
  }
185
- function getTemplatePath() {
186
- const possiblePaths = [
187
- path.join(__dirname, "../../templates"),
188
- path.join(__dirname, "../templates"),
189
- path.join(process.cwd(), "templates"),
190
- path.resolve(__dirname, "..", "..", "templates")
191
- // Absolute resolve
192
- ];
193
- for (const p of possiblePaths) {
194
- if (fs.existsSync(p)) {
195
- return p;
196
- }
129
+ for (const dir of [
130
+ "apps/api",
131
+ "apps/web"
132
+ ]) {
133
+ if (!fs.existsSync(path.join(cwd, dir))) {
134
+ result.warnings.push(`${dir} not found; some Wexts commands may need explicit paths.`);
197
135
  }
198
- return "";
199
136
  }
200
- __name(getTemplatePath, "getTemplatePath");
201
- const templatePath = getTemplatePath();
137
+ if (fs.existsSync(path.join(cwd, "apps/api")) && fs.existsSync(path.join(cwd, "apps/web"))) {
138
+ result.warnings.push("Development mode starts separate web/API processes. Single-port serving is the production `wexts start` runtime path.");
139
+ }
140
+ if (security) {
141
+ const source = readAllText(cwd, [
142
+ "apps/api/src",
143
+ "packages/templates/nestjs-api/src"
144
+ ]);
145
+ if (source.includes("default-secret")) {
146
+ result.errors.push('JWT fallback "default-secret" found. Production apps must fail without a strong JWT_SECRET.');
147
+ }
148
+ if (/origin:\s*['"]\*['"]/.test(source)) {
149
+ result.errors.push("Wildcard CORS origin found. Use an explicit origin allowlist.");
150
+ }
151
+ }
152
+ return result;
153
+ }
154
+ __name(runDoctor, "runDoctor");
155
+ async function createProject(projectName, template, options) {
156
+ const projectPath = path.join(process.cwd(), projectName);
157
+ if (fs.existsSync(projectPath)) {
158
+ throw new Error(`Directory already exists: ${projectName}`);
159
+ }
160
+ const templatePath = findTemplatePath();
202
161
  if (!templatePath) {
203
- logger.error(`\u274C Template directory not found!`);
204
- logger.info(`Searched in:`);
205
- logger.info(` - ${path.join(__dirname, "../../templates")}`);
206
- logger.info(` - ${path.join(__dirname, "../templates")}`);
207
- logger.info(` - ${path.join(process.cwd(), "templates")}`);
208
- logger.warn("\u26A0\uFE0F Using fallback scaffolding (empty structure)");
209
- fs.mkdirSync(projectPath, {
210
- recursive: true
211
- });
162
+ throw new Error("Template directory not found in package.");
163
+ }
164
+ fs.mkdirSync(projectPath, {
165
+ recursive: true
166
+ });
167
+ if (template === "monorepo") {
212
168
  fs.mkdirSync(path.join(projectPath, "apps"), {
213
169
  recursive: true
214
170
  });
215
- fs.mkdirSync(path.join(projectPath, "packages"), {
171
+ fs.cpSync(path.join(templatePath, "nestjs-api"), path.join(projectPath, "apps/api"), {
216
172
  recursive: true
217
173
  });
218
- } else {
219
- logger.info(`\u{1F4E6} Copying templates from: ${templatePath}`);
220
- fs.mkdirSync(projectPath, {
174
+ fs.cpSync(path.join(templatePath, "nextjs-web"), path.join(projectPath, "apps/web"), {
221
175
  recursive: true
222
176
  });
223
- fs.mkdirSync(path.join(projectPath, "apps"), {
177
+ fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), "packages:\n - 'apps/*'\n");
178
+ fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify({
179
+ name: projectName,
180
+ private: true,
181
+ packageManager: "pnpm@10.22.0",
182
+ scripts: {
183
+ dev: "wexts dev",
184
+ generate: "wexts generate",
185
+ build: "wexts build",
186
+ start: "wexts start",
187
+ doctor: "wexts doctor"
188
+ },
189
+ devDependencies: {
190
+ wexts: "latest"
191
+ }
192
+ }, null, 2));
193
+ } else if (template === "api") {
194
+ fs.cpSync(path.join(templatePath, "nestjs-api"), projectPath, {
224
195
  recursive: true
225
196
  });
226
- fs.mkdirSync(path.join(projectPath, "packages"), {
197
+ } else if (template === "web") {
198
+ fs.cpSync(path.join(templatePath, "nextjs-web"), projectPath, {
227
199
  recursive: true
228
200
  });
229
- const apiTemplatePath = path.join(templatePath, "nestjs-api");
230
- const apiDestPath = path.join(projectPath, "apps/api");
231
- if (fs.existsSync(apiTemplatePath)) {
232
- fs.cpSync(apiTemplatePath, apiDestPath, {
233
- recursive: true
234
- });
235
- logger.success(" - Copied API template");
236
- const envExamplePath = path.join(apiDestPath, ".env.example");
237
- const envPath = path.join(apiDestPath, ".env");
238
- if (fs.existsSync(envExamplePath) && !fs.existsSync(envPath)) {
239
- fs.copyFileSync(envExamplePath, envPath);
240
- logger.success(" - Created .env from .env.example");
241
- }
242
- } else {
243
- logger.warn(` \u26A0\uFE0F API template not found at ${apiTemplatePath}`);
244
- }
245
- const webTemplatePath = path.join(templatePath, "nextjs-web");
246
- const webDestPath = path.join(projectPath, "apps/web");
247
- if (fs.existsSync(webTemplatePath)) {
248
- fs.cpSync(webTemplatePath, webDestPath, {
249
- recursive: true
250
- });
251
- logger.success(" - Copied Web template");
252
- } else {
253
- logger.warn(` \u26A0\uFE0F Web template not found at ${webTemplatePath}`);
254
- }
201
+ } else {
202
+ throw new Error(`Unknown template "${template}".`);
255
203
  }
256
- const packageJson = {
257
- name: projectName,
258
- version: "0.0.0",
259
- private: true,
260
- scripts: {
261
- "build": "pnpm exec turbo build",
262
- "dev": "pnpm exec turbo dev",
263
- "lint": "pnpm exec turbo lint",
264
- "format": 'prettier --write "**/*.{ts,tsx,md}"'
265
- },
266
- devDependencies: {
267
- "turbo": "^2.6.1",
268
- "prettier": "latest",
269
- "typescript": "^5.9.3",
270
- "wexts": "latest"
271
- },
272
- packageManager: "pnpm@10.0.0"
273
- };
274
- fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify(packageJson, null, 2));
275
- const turboJson = {
276
- "$schema": "https://turbo.build/schema.json",
277
- "tasks": {
278
- "build": {
279
- "dependsOn": [
280
- "^build"
281
- ],
282
- "outputs": [
283
- ".next/**",
284
- "!.next/cache/**",
285
- "dist/**"
286
- ]
287
- },
288
- "lint": {},
289
- "dev": {
290
- "cache": false,
291
- "persistent": true
204
+ if (!options.skipInstall) {
205
+ runCommand(detectPackageManager(projectPath), [
206
+ "install"
207
+ ], projectPath);
208
+ }
209
+ }
210
+ __name(createProject, "createProject");
211
+ async function scaffoldRpcService(apiProjectPath, rawName) {
212
+ const serviceName = toKebabCase(rawName);
213
+ const className = `${toPascalCase(serviceName)}Service`;
214
+ const dir = path.join(apiProjectPath, "src", serviceName);
215
+ fs.mkdirSync(dir, {
216
+ recursive: true
217
+ });
218
+ fs.writeFileSync(path.join(dir, `${serviceName}.service.ts`), `import { Injectable } from '@nestjs/common';
219
+ import { RpcMethod, RpcService } from 'wexts/nest';
220
+
221
+ @Injectable()
222
+ @RpcService({ name: '${toCamelCase(serviceName)}', requireAuth: false })
223
+ export class ${className} {
224
+ @RpcMethod()
225
+ async sayHello(name: string): Promise<string> {
226
+ return \`Hello, \${name}!\`;
227
+ }
228
+ }
229
+ `);
230
+ }
231
+ __name(scaffoldRpcService, "scaffoldRpcService");
232
+ function runScript(script, options) {
233
+ const cwd = options.cwd ?? process.cwd();
234
+ const packageManager = detectPackageManager(cwd);
235
+ const args = packageManager === "npm" ? [
236
+ "run",
237
+ script
238
+ ] : [
239
+ "run",
240
+ script
241
+ ];
242
+ runCommand(packageManager, args, cwd);
243
+ }
244
+ __name(runScript, "runScript");
245
+ function runCommand(command, args, cwd) {
246
+ const result = spawnSync(command, args, {
247
+ cwd,
248
+ stdio: "inherit",
249
+ shell: process.platform === "win32"
250
+ });
251
+ if (result.status !== 0) {
252
+ throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}`);
253
+ }
254
+ }
255
+ __name(runCommand, "runCommand");
256
+ function detectPackageManager(cwd) {
257
+ if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
258
+ return "npm";
259
+ }
260
+ __name(detectPackageManager, "detectPackageManager");
261
+ function findTemplatePath() {
262
+ const candidates = [
263
+ path.resolve(__dirname, "../../templates"),
264
+ path.resolve(__dirname, "../templates"),
265
+ path.resolve(process.cwd(), "packages/templates")
266
+ ];
267
+ return candidates.find((candidate) => fs.existsSync(candidate));
268
+ }
269
+ __name(findTemplatePath, "findTemplatePath");
270
+ function readAllText(cwd, dirs) {
271
+ let text = "";
272
+ for (const dir of dirs) {
273
+ const absolute = path.join(cwd, dir);
274
+ if (!fs.existsSync(absolute)) continue;
275
+ for (const file of walk(absolute)) {
276
+ if (file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".js")) {
277
+ text += fs.readFileSync(file, "utf8");
292
278
  }
293
279
  }
294
- };
295
- fs.writeFileSync(path.join(projectPath, "turbo.json"), JSON.stringify(turboJson, null, 2));
296
- const pnpmWorkspace = `packages:
297
- - 'apps/*'
298
- - 'packages/*'
299
- `;
300
- fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), pnpmWorkspace);
301
- logger.success("\u2705 Project structure created");
302
- logger.info("\u{1F4E6} Installing dependencies...");
303
- try {
304
- try {
305
- execSync("pnpm --version", {
306
- stdio: "ignore"
307
- });
308
- } catch {
309
- logger.info("Installing pnpm...");
310
- execSync("npm install -g pnpm", {
311
- stdio: "ignore"
312
- });
313
- }
314
- execSync("pnpm install", {
315
- cwd: projectPath,
316
- stdio: "inherit"
317
- });
318
- logger.success("\u2705 Dependencies installed");
319
- logger.info(pc.green(`
320
- \u{1F389} Project ${projectName} created successfully!`));
321
- logger.info(`
322
- To get started:
323
- `);
324
- logger.info(pc.cyan(` cd ${projectName}`));
325
- logger.info(pc.cyan(` pnpm dev
326
- `));
327
- } catch (error) {
328
- logger.error("Failed to install dependencies");
329
280
  }
281
+ return text;
330
282
  }
331
- __name(createProject, "createProject");
332
- program.parse();
283
+ __name(readAllText, "readAllText");
284
+ function walk(dir) {
285
+ return fs.readdirSync(dir, {
286
+ withFileTypes: true
287
+ }).flatMap((entry) => {
288
+ const absolute = path.join(dir, entry.name);
289
+ if (entry.isDirectory()) return walk(absolute);
290
+ return [
291
+ absolute
292
+ ];
293
+ });
294
+ }
295
+ __name(walk, "walk");
296
+ function toKebabCase(value) {
297
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
298
+ }
299
+ __name(toKebabCase, "toKebabCase");
300
+ function toPascalCase(value) {
301
+ return toKebabCase(value).split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
302
+ }
303
+ __name(toPascalCase, "toPascalCase");
304
+ function toCamelCase(value) {
305
+ const pascal = toPascalCase(value);
306
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
307
+ }
308
+ __name(toCamelCase, "toCamelCase");
309
+ function pathToFileUrl(filePath) {
310
+ return `file://${filePath}`;
311
+ }
312
+ __name(pathToFileUrl, "pathToFileUrl");
313
+ async function loadRuntimeConfig(configPath) {
314
+ if (configPath.endsWith(".mjs")) {
315
+ const mod2 = await import(pathToFileUrl(configPath));
316
+ return mod2.default ?? mod2;
317
+ }
318
+ const require2 = createRequire(__filename);
319
+ const mod = require2(configPath);
320
+ return mod.default ?? mod;
321
+ }
322
+ __name(loadRuntimeConfig, "loadRuntimeConfig");
323
+ var invokedAsCli = process.argv[1] && (path.basename(process.argv[1]) === "wexts" || path.basename(process.argv[1]) === "wexts.cjs" || path.resolve(process.argv[1]).includes(`${path.sep}dist${path.sep}cli${path.sep}index`));
324
+ if (invokedAsCli && !process.env.VITEST) {
325
+ createCliProgram().parseAsync(process.argv).catch((error) => {
326
+ logger.error(error instanceof Error ? error.message : String(error));
327
+ process.exit(1);
328
+ });
329
+ }
330
+ export {
331
+ createCliProgram,
332
+ runDoctor
333
+ };
333
334
  //# sourceMappingURL=index.mjs.map