wexts 3.0.2 → 4.1.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 (288) 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-342VRT25.mjs +504 -0
  8. package/dist/chunk-342VRT25.mjs.map +1 -0
  9. package/dist/chunk-7HNQWJWV.js +504 -0
  10. package/dist/chunk-7HNQWJWV.js.map +1 -0
  11. package/dist/chunk-7QKLIVRF.js +94 -0
  12. package/dist/chunk-7QKLIVRF.js.map +1 -0
  13. package/dist/chunk-7SSCNCTW.mjs +137 -0
  14. package/dist/chunk-7SSCNCTW.mjs.map +1 -0
  15. package/dist/chunk-7TLSPR65.mjs +95 -0
  16. package/dist/chunk-7TLSPR65.mjs.map +1 -0
  17. package/dist/{chunk-FCEZDH42.mjs → chunk-7WULUGLH.mjs} +5 -3
  18. package/dist/chunk-7WULUGLH.mjs.map +1 -0
  19. package/dist/chunk-AVMQJWYD.js +95 -0
  20. package/dist/chunk-AVMQJWYD.js.map +1 -0
  21. package/dist/{chunk-WF65EDRZ.js → chunk-BG56B4DE.js} +20 -2
  22. package/dist/chunk-BG56B4DE.js.map +1 -0
  23. package/dist/chunk-CLM5PNSG.mjs +496 -0
  24. package/dist/chunk-CLM5PNSG.mjs.map +1 -0
  25. package/dist/chunk-DNLGCKTT.js +31 -0
  26. package/dist/chunk-DNLGCKTT.js.map +1 -0
  27. package/dist/{chunk-VNNVLQLJ.mjs → chunk-JHOVXH3X.mjs} +2 -2
  28. package/dist/chunk-JHOVXH3X.mjs.map +1 -0
  29. package/dist/chunk-MXINIFPC.js +105 -0
  30. package/dist/chunk-MXINIFPC.js.map +1 -0
  31. package/dist/chunk-O4II6N34.js +137 -0
  32. package/dist/chunk-O4II6N34.js.map +1 -0
  33. package/dist/chunk-SE32ZPOZ.js +496 -0
  34. package/dist/chunk-SE32ZPOZ.js.map +1 -0
  35. package/dist/{chunk-STTOPUZ2.mjs → chunk-UAL54DVV.mjs} +21 -3
  36. package/dist/chunk-UAL54DVV.mjs.map +1 -0
  37. package/dist/{chunk-3OM7CHCA.js → chunk-WCKSKU3C.js} +1 -1
  38. package/dist/chunk-WCKSKU3C.js.map +1 -0
  39. package/dist/chunk-WU6FW77M.mjs +105 -0
  40. package/dist/chunk-WU6FW77M.mjs.map +1 -0
  41. package/dist/chunk-XE4OXN2W.js +0 -0
  42. package/dist/chunk-XE4OXN2W.js.map +1 -1
  43. package/dist/chunk-YBM3IJEA.mjs +94 -0
  44. package/dist/chunk-YBM3IJEA.mjs.map +1 -0
  45. package/dist/{chunk-KXYLEUSW.mjs → chunk-YN6WIWNQ.mjs} +69 -83
  46. package/dist/chunk-YN6WIWNQ.mjs.map +1 -0
  47. package/dist/chunk-YSLEF5C5.mjs +0 -0
  48. package/dist/chunk-YSLEF5C5.mjs.map +0 -0
  49. package/dist/chunk-ZX7QIN24.mjs +31 -0
  50. package/dist/chunk-ZX7QIN24.mjs.map +1 -0
  51. package/dist/cli/index.d.mts +22 -0
  52. package/dist/cli/index.d.ts +22 -0
  53. package/dist/cli/index.js +676 -292
  54. package/dist/cli/index.js.map +1 -1
  55. package/dist/cli/index.mjs +678 -293
  56. package/dist/cli/index.mjs.map +1 -1
  57. package/dist/client/index.d.mts +10 -1
  58. package/dist/client/index.d.ts +10 -1
  59. package/dist/client/index.js +5 -2
  60. package/dist/client/index.js.map +1 -1
  61. package/dist/client/index.mjs +7 -4
  62. package/dist/client/index.mjs.map +0 -0
  63. package/dist/codegen/index.d.mts +2 -1
  64. package/dist/codegen/index.d.ts +2 -1
  65. package/dist/codegen/index.js +6 -3
  66. package/dist/codegen/index.js.map +1 -1
  67. package/dist/codegen/index.mjs +8 -5
  68. package/dist/codegen/index.mjs.map +0 -0
  69. package/dist/decorators-BT1FFqN0.d.mts +29 -0
  70. package/dist/decorators-DvS58PqC.d.ts +29 -0
  71. package/dist/dev-server/index.d.mts +1 -1
  72. package/dist/dev-server/index.d.ts +1 -1
  73. package/dist/dev-server/index.js +3 -3
  74. package/dist/dev-server/index.js.map +1 -1
  75. package/dist/dev-server/index.mjs +3 -3
  76. package/dist/dev-server/index.mjs.map +0 -0
  77. package/dist/{index-SjUaHgFr.d.ts → index-7QeQEf37.d.ts} +27 -10
  78. package/dist/{index-tFGPFVfQ.d.mts → index-7RvU-jGE.d.mts} +0 -1
  79. package/dist/{index-tFGPFVfQ.d.ts → index-7RvU-jGE.d.ts} +0 -1
  80. package/dist/{index-SjUaHgFr.d.mts → index-8nzxy0NN.d.mts} +27 -10
  81. package/dist/index-Co5ZsLqq.d.ts +58 -0
  82. package/dist/index-D94W1__r.d.mts +58 -0
  83. package/dist/index-DQmyVp6F.d.mts +27 -0
  84. package/dist/index-KL_1BrQb.d.ts +27 -0
  85. package/dist/index.d.mts +54 -7
  86. package/dist/index.d.ts +54 -7
  87. package/dist/index.js +70 -29
  88. package/dist/index.js.map +1 -1
  89. package/dist/index.mjs +62 -21
  90. package/dist/index.mjs.map +1 -1
  91. package/dist/nest/index.d.mts +3 -1
  92. package/dist/nest/index.d.ts +3 -1
  93. package/dist/nest/index.js +20 -2
  94. package/dist/nest/index.js.map +1 -1
  95. package/dist/nest/index.mjs +21 -3
  96. package/dist/nest/index.mjs.map +0 -0
  97. package/dist/next/index.d.mts +7 -2
  98. package/dist/next/index.d.ts +7 -2
  99. package/dist/next/index.js +135 -5
  100. package/dist/next/index.js.map +1 -1
  101. package/dist/next/index.mjs +133 -4
  102. package/dist/next/index.mjs.map +1 -1
  103. package/dist/rpc/index.d.mts +2 -0
  104. package/dist/rpc/index.d.ts +2 -0
  105. package/dist/rpc/index.js +23 -0
  106. package/dist/rpc/index.js.map +1 -0
  107. package/dist/rpc/index.mjs +23 -0
  108. package/dist/{chunk-7NSRDJ5C.mjs.map → rpc/index.mjs.map} +0 -0
  109. package/dist/runtime/index.d.mts +55 -0
  110. package/dist/runtime/index.d.ts +55 -0
  111. package/dist/runtime/index.js +221 -0
  112. package/dist/runtime/index.js.map +1 -0
  113. package/dist/runtime/index.mjs +221 -0
  114. package/dist/runtime/index.mjs.map +1 -0
  115. package/dist/types/index.d.mts +0 -0
  116. package/dist/types/index.d.ts +0 -0
  117. package/dist/types/index.js +0 -0
  118. package/dist/types/index.js.map +1 -1
  119. package/dist/types/index.mjs +1 -1
  120. package/dist/types/index.mjs.map +0 -0
  121. package/dist/types-7d_fC-C3.d.mts +32 -0
  122. package/dist/types-7d_fC-C3.d.ts +32 -0
  123. package/dist/vercel-builder/index.d.mts +58 -0
  124. package/dist/vercel-builder/index.d.ts +58 -0
  125. package/dist/vercel-builder/index.js +330 -0
  126. package/dist/vercel-builder/index.js.map +1 -0
  127. package/dist/vercel-builder/index.mjs +330 -0
  128. package/dist/vercel-builder/index.mjs.map +1 -0
  129. package/package.json +37 -16
  130. package/templates/.dockerignore +43 -43
  131. package/templates/.env.example +0 -0
  132. package/templates/Dockerfile +60 -60
  133. package/templates/Procfile +1 -1
  134. package/templates/README.md +67 -58
  135. package/templates/api-sdk.ts +115 -115
  136. package/templates/docker-compose.yml +34 -34
  137. package/templates/nestjs-api/.env.example +0 -0
  138. package/templates/nestjs-api/README.md +87 -79
  139. package/templates/nestjs-api/nest-cli.json +6 -6
  140. package/templates/nestjs-api/package.json +40 -40
  141. package/templates/nestjs-api/prisma/dev.db +0 -0
  142. package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +0 -0
  143. package/templates/nestjs-api/prisma/migrations/migration_lock.toml +0 -0
  144. package/templates/nestjs-api/prisma/schema.prisma +29 -29
  145. package/templates/nestjs-api/src/app.module.ts +17 -17
  146. package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
  147. package/templates/nestjs-api/src/auth/auth.module.ts +37 -29
  148. package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
  149. package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
  150. package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
  151. package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -19
  152. package/templates/nestjs-api/src/main.ts +32 -32
  153. package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
  154. package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
  155. package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
  156. package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
  157. package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
  158. package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
  159. package/templates/nestjs-api/src/users/users.controller.ts +14 -14
  160. package/templates/nestjs-api/src/users/users.module.ts +12 -12
  161. package/templates/nestjs-api/src/users/users.service.ts +19 -19
  162. package/templates/nestjs-api/tsconfig.json +39 -39
  163. package/templates/nextjs-web/README.md +76 -68
  164. package/templates/nextjs-web/app/actions/auth.ts +108 -108
  165. package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
  166. package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
  167. package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
  168. package/templates/nextjs-web/app/globals.css +93 -93
  169. package/templates/nextjs-web/app/layout.tsx +29 -29
  170. package/templates/nextjs-web/app/login/page.tsx +5 -5
  171. package/templates/nextjs-web/app/page.tsx +28 -28
  172. package/templates/nextjs-web/app/register/page.tsx +5 -5
  173. package/templates/nextjs-web/components/ui/button.tsx +56 -56
  174. package/templates/nextjs-web/components/ui/card.tsx +79 -79
  175. package/templates/nextjs-web/components/ui/input.tsx +25 -25
  176. package/templates/nextjs-web/components/ui/label.tsx +24 -24
  177. package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
  178. package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
  179. package/templates/nextjs-web/features/auth/api.ts +35 -35
  180. package/templates/nextjs-web/features/auth/index.ts +3 -3
  181. package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
  182. package/templates/nextjs-web/features/dashboard/api.ts +9 -9
  183. package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
  184. package/templates/nextjs-web/features/dashboard/index.ts +3 -3
  185. package/templates/nextjs-web/hooks/index.ts +4 -4
  186. package/templates/nextjs-web/lib/api-client.ts +89 -89
  187. package/templates/nextjs-web/lib/api.ts +115 -115
  188. package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
  189. package/templates/nextjs-web/lib/utils.ts +6 -6
  190. package/templates/nextjs-web/lib/wexts-client.ts +4 -4
  191. package/templates/nextjs-web/next-env.d.ts +6 -6
  192. package/templates/nextjs-web/next.config.ts +20 -20
  193. package/templates/nextjs-web/package.json +37 -37
  194. package/templates/nextjs-web/postcss.config.js +6 -6
  195. package/templates/nextjs-web/tailwind.config.ts +69 -69
  196. package/templates/nextjs-web/tsconfig.json +1 -1
  197. package/templates/nixpacks.toml +11 -11
  198. package/templates/root-package.json +31 -31
  199. package/templates/server.ts +66 -66
  200. package/templates/tsconfig.json +30 -30
  201. package/dist/chunk-2MCBBWEA.js +0 -1
  202. package/dist/chunk-2MCBBWEA.js.map +0 -1
  203. package/dist/chunk-3OM7CHCA.js.map +0 -1
  204. package/dist/chunk-63MTCWU2.mjs +0 -361
  205. package/dist/chunk-63MTCWU2.mjs.map +0 -1
  206. package/dist/chunk-667BQCEM.js +0 -375
  207. package/dist/chunk-667BQCEM.js.map +0 -1
  208. package/dist/chunk-67IJ6H4J.mjs +0 -44
  209. package/dist/chunk-67IJ6H4J.mjs.map +0 -1
  210. package/dist/chunk-6SVQEGEX.mjs +0 -44
  211. package/dist/chunk-6SVQEGEX.mjs.map +0 -1
  212. package/dist/chunk-7NSRDJ5C.mjs +0 -1
  213. package/dist/chunk-ASDXAK6G.js +0 -44
  214. package/dist/chunk-ASDXAK6G.js.map +0 -1
  215. package/dist/chunk-CKZ4VSCB.mjs +0 -18
  216. package/dist/chunk-CKZ4VSCB.mjs.map +0 -1
  217. package/dist/chunk-DW6GOKMF.js +0 -57
  218. package/dist/chunk-DW6GOKMF.js.map +0 -1
  219. package/dist/chunk-EFZPSZWO.mjs +0 -1
  220. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  221. package/dist/chunk-FCEZDH42.mjs.map +0 -1
  222. package/dist/chunk-FYGXL4V7.js +0 -361
  223. package/dist/chunk-FYGXL4V7.js.map +0 -1
  224. package/dist/chunk-GKVPGKAH.js +0 -66
  225. package/dist/chunk-GKVPGKAH.js.map +0 -1
  226. package/dist/chunk-GWP6PNSP.js +0 -225
  227. package/dist/chunk-GWP6PNSP.js.map +0 -1
  228. package/dist/chunk-HQKTXE7E.mjs +0 -225
  229. package/dist/chunk-HQKTXE7E.mjs.map +0 -1
  230. package/dist/chunk-HSFLZUJN.mjs +0 -57
  231. package/dist/chunk-HSFLZUJN.mjs.map +0 -1
  232. package/dist/chunk-HU63F22V.js +0 -361
  233. package/dist/chunk-HU63F22V.js.map +0 -1
  234. package/dist/chunk-J5LGTIGS.mjs +0 -10
  235. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  236. package/dist/chunk-JMBD6DOP.js +0 -225
  237. package/dist/chunk-JMBD6DOP.js.map +0 -1
  238. package/dist/chunk-K7EIJSYQ.js +0 -1
  239. package/dist/chunk-K7EIJSYQ.js.map +0 -1
  240. package/dist/chunk-KXYLEUSW.mjs.map +0 -1
  241. package/dist/chunk-MTHKZO55.js +0 -44
  242. package/dist/chunk-MTHKZO55.js.map +0 -1
  243. package/dist/chunk-NNQFLD7O.mjs +0 -361
  244. package/dist/chunk-NNQFLD7O.mjs.map +0 -1
  245. package/dist/chunk-NU2UB242.js +0 -82
  246. package/dist/chunk-NU2UB242.js.map +0 -1
  247. package/dist/chunk-NULGSZFE.mjs +0 -57
  248. package/dist/chunk-NULGSZFE.mjs.map +0 -1
  249. package/dist/chunk-O42L6HOX.js.map +0 -1
  250. package/dist/chunk-ONXNE2A6.mjs +0 -375
  251. package/dist/chunk-ONXNE2A6.mjs.map +0 -1
  252. package/dist/chunk-OTBYRUBE.mjs +0 -225
  253. package/dist/chunk-OTBYRUBE.mjs.map +0 -1
  254. package/dist/chunk-OTSAVKLY.mjs +0 -66
  255. package/dist/chunk-OTSAVKLY.mjs.map +0 -1
  256. package/dist/chunk-PZ5AY32C.js +0 -10
  257. package/dist/chunk-PZ5AY32C.js.map +0 -1
  258. package/dist/chunk-QP2TMRLG.js +0 -57
  259. package/dist/chunk-QP2TMRLG.js.map +0 -1
  260. package/dist/chunk-RS23R3ZQ.mjs +0 -82
  261. package/dist/chunk-RS23R3ZQ.mjs.map +0 -1
  262. package/dist/chunk-STTOPUZ2.mjs.map +0 -1
  263. package/dist/chunk-VMT3LALB.mjs +0 -51
  264. package/dist/chunk-VMT3LALB.mjs.map +0 -1
  265. package/dist/chunk-VNNVLQLJ.mjs.map +0 -1
  266. package/dist/chunk-W3YRVEFQ.js +0 -66
  267. package/dist/chunk-W3YRVEFQ.js.map +0 -1
  268. package/dist/chunk-WF65EDRZ.js.map +0 -1
  269. package/dist/chunk-WMHVXEYQ.mjs +0 -66
  270. package/dist/chunk-WMHVXEYQ.mjs.map +0 -1
  271. package/dist/chunk-XVKTIYHY.js +0 -51
  272. package/dist/chunk-XVKTIYHY.js.map +0 -1
  273. package/dist/codegen-MRZDLCYI.js +0 -13
  274. package/dist/codegen-MRZDLCYI.js.map +0 -1
  275. package/dist/codegen-UI5HTMXE.mjs +0 -13
  276. package/dist/codegen-UI5HTMXE.mjs.map +0 -1
  277. package/dist/dev-server-JKRVBWPY.mjs +0 -13
  278. package/dist/dev-server-JKRVBWPY.mjs.map +0 -1
  279. package/dist/dev-server-TLL7UQMR.js +0 -13
  280. package/dist/dev-server-TLL7UQMR.js.map +0 -1
  281. package/dist/index-BsNaOUtH.d.mts +0 -44
  282. package/dist/index-BsNaOUtH.d.ts +0 -44
  283. package/dist/index-CrbXnXsO.d.ts +0 -62
  284. package/dist/index-kEbGExWM.d.mts +0 -62
  285. package/templates/nestjs-api/.env +0 -4
  286. package/templates/nestjs-api/package-lock.json +0 -5623
  287. package/templates/nextjs-web/.env +0 -1
  288. package/templates/nextjs-web/package-lock.json +0 -3254
package/dist/cli/index.js CHANGED
@@ -1,332 +1,716 @@
1
1
  #!/usr/bin/env node
2
- "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3
3
 
4
- var _chunk3OM7CHCAjs = require('../chunk-3OM7CHCA.js');
4
+ var _chunkWCKSKU3Cjs = require('../chunk-WCKSKU3C.js');
5
+
6
+
7
+
8
+ var _chunkAVMQJWYDjs = require('../chunk-AVMQJWYD.js');
5
9
 
6
10
 
7
11
  var _chunkXE4OXN2Wjs = require('../chunk-XE4OXN2W.js');
8
12
 
9
13
  // src/cli/index.ts
10
14
  var _commander = require('commander');
11
- var _picocolors = require('picocolors'); var pc = _interopRequireWildcard(_picocolors);
12
- var _inquirer = require('inquirer'); var _inquirer2 = _interopRequireDefault(_inquirer);
13
15
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
14
16
  var _path = require('path'); var path = _interopRequireWildcard(_path);
15
17
  var _child_process = require('child_process');
16
- var program = new (0, _commander.Command)();
17
- program.name("wexts").description("Wexts Framework - Next.js 16 + NestJS 11").version("2.0.0");
18
- program.action(async () => {
19
- console.log(pc.cyan(`
20
- \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
21
- \u2551 \u2551
22
- \u2551 ${pc.bold("\u{1F680} Wexts Framework v2.0")} \u2551
23
- \u2551 \u2551
24
- \u2551 Next.js 16 + NestJS 11 Full-Stack \u2551
25
- \u2551 \u2551
26
- \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
27
- `));
28
- const { action } = await _inquirer2.default.prompt([
29
- {
30
- type: "list",
31
- name: "action",
32
- message: "What would you like to do?",
33
- choices: [
34
- {
35
- name: "\u{1F4E6} Create a new project",
36
- value: "create"
37
- },
38
- {
39
- name: "\u{1F680} Start development server",
40
- value: "dev"
41
- },
42
- {
43
- name: "\u{1F528} Build for production",
44
- value: "build"
45
- },
46
- {
47
- name: "\u26A1 Generate code",
48
- value: "generate"
49
- },
50
- {
51
- name: "\u{1F916} Generate API client",
52
- value: "codegen"
53
- },
54
- {
55
- name: "\u274C Exit",
56
- value: "exit"
57
- }
58
- ]
59
- }
60
- ]);
61
- if (action === "exit") {
62
- _chunk3OM7CHCAjs.logger.info("Goodbye! \u{1F44B}");
63
- process.exit(0);
64
- }
65
- if (action === "create") {
66
- const { projectName, template } = await _inquirer2.default.prompt([
67
- {
68
- type: "input",
69
- name: "projectName",
70
- message: "Project name:",
71
- default: "my-wexts-app"
72
- },
73
- {
74
- type: "list",
75
- name: "template",
76
- message: "Select template:",
77
- choices: [
78
- {
79
- name: "\u{1F4E6} Monorepo (Next.js + NestJS)",
80
- value: "monorepo"
81
- },
82
- {
83
- name: "\u{1F3AF} API only (NestJS)",
84
- value: "api"
85
- },
86
- {
87
- name: "\u{1F310} Web only (Next.js)",
88
- value: "web"
89
- }
90
- ]
91
- }
92
- ]);
93
- await createProject(projectName, template);
94
- } else if (action === "dev") {
95
- _chunk3OM7CHCAjs.logger.info(pc.green("\u{1F680} Starting development servers...\n"));
96
- _chunk3OM7CHCAjs.logger.warn("Dev server not yet implemented");
97
- } else if (action === "build") {
98
- _chunk3OM7CHCAjs.logger.info(pc.blue("\u{1F528} Building project...\n"));
99
- _chunk3OM7CHCAjs.logger.warn("Build not yet implemented");
100
- } else if (action === "generate") {
101
- const { type, name } = await _inquirer2.default.prompt([
102
- {
103
- type: "list",
104
- name: "type",
105
- message: "What to generate?",
106
- choices: [
107
- "controller",
108
- "module",
109
- "service",
110
- "page"
111
- ]
112
- },
113
- {
114
- type: "input",
115
- name: "name",
116
- message: "Name:"
117
- }
118
- ]);
119
- _chunk3OM7CHCAjs.logger.info(pc.magenta(`
120
- \u26A1 Generating ${type}: ${name}
121
- `));
122
- _chunk3OM7CHCAjs.logger.warn("Code generation not yet implemented");
123
- } else if (action === "codegen") {
124
- _chunk3OM7CHCAjs.logger.info(pc.cyan("\n\u{1F916} Generating API client...\n"));
125
- _chunk3OM7CHCAjs.logger.warn("Codegen not yet implemented");
126
- }
127
- });
128
- 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) => {
129
- await createProject(projectName, options.template);
130
- });
131
- 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) => {
132
- _chunk3OM7CHCAjs.logger.info(pc.green("\u{1F680} Starting Wexts development servers...\n"));
133
- const { FusionDevServer } = await Promise.resolve().then(() => _interopRequireWildcard(require("../dev-server/index.js")));
134
- const server = new FusionDevServer();
135
- try {
18
+ var _module = require('module');
19
+ function createCliProgram() {
20
+ const program = new (0, _commander.Command)();
21
+ program.name("wexts").description("Wexts - production-focused single-runtime Next.js + NestJS toolkit").version(readPackageVersion());
22
+ program.command("create <project-name>").description("Create a verified Wexts starter").option("-t, --template <template>", "Template to use (starter|legacy)", "starter").option("--skip-install", "Skip dependency installation", false).action(async (projectName, options) => {
23
+ await createProject(projectName, options.template, {
24
+ skipInstall: options.skipInstall
25
+ });
26
+ });
27
+ 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) => {
28
+ const { FusionDevServer } = await Promise.resolve().then(() => _interopRequireWildcard(require("../dev-server/index.js")));
29
+ const server = new FusionDevServer();
136
30
  await server.start({
137
31
  apiPath: options.api,
138
32
  webPath: options.web,
139
- webPort: parseInt(options.port),
140
- apiPort: parseInt(options.apiPort),
33
+ webPort: Number(options.port),
34
+ apiPort: Number(options.apiPort),
141
35
  useProxy: options.proxy
142
36
  });
143
- } catch (error) {
144
- _chunk3OM7CHCAjs.logger.error("Failed to start dev server:", error.message);
145
- process.exit(1);
146
- }
147
- });
148
- program.command("build").description("Build for production").action(async () => {
149
- _chunk3OM7CHCAjs.logger.info(pc.blue("Building Wexts project..."));
150
- _chunk3OM7CHCAjs.logger.warn("Build not yet implemented");
151
- });
152
- program.command("generate <type> <name>").alias("g").description("Generate code (controller|module|page)").action(async (type, name) => {
153
- _chunk3OM7CHCAjs.logger.info(pc.magenta(`Generating ${type}: ${name}`));
154
- _chunk3OM7CHCAjs.logger.warn("Code generation not yet implemented");
155
- });
156
- 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) => {
157
- const { NestJSParser, ClientGenerator, CodegenWatcher } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
158
- if (options.watch) {
159
- _chunk3OM7CHCAjs.logger.info(pc.cyan("Starting codegen in watch mode..."));
160
- const watcher = new CodegenWatcher();
161
- await watcher.watch({
162
- projectPath: options.project,
163
- outputPath: options.output
37
+ });
38
+ 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").option("--force", "Overwrite generated files if they already exist", false).action(async (type, name, options) => {
39
+ if (!type || type === "rpc" && !name) {
40
+ const { generateRpcClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
41
+ const manifest = await generateRpcClient({
42
+ projectPath: path.resolve(options.project),
43
+ outputPath: path.resolve(options.output)
44
+ });
45
+ _chunkWCKSKU3Cjs.logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
46
+ return;
47
+ }
48
+ if (isScaffoldGenerator(type)) {
49
+ const targetRoot = type === "config" ? process.cwd() : path.resolve(options.project);
50
+ const changedFiles = await scaffoldGenerator({
51
+ type,
52
+ name,
53
+ targetRoot,
54
+ force: options.force
55
+ });
56
+ for (const file of changedFiles) _chunkWCKSKU3Cjs.logger.info(`created ${path.relative(process.cwd(), file)}`);
57
+ _chunkWCKSKU3Cjs.logger.success(`Generated ${type}${name ? ` ${name}` : ""}.`);
58
+ return;
59
+ }
60
+ throw new Error(`Unknown generator "${type}". Supported generators: rpc, service, module, entity, guard, config.`);
61
+ });
62
+ 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) => {
63
+ const { generateRpcClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
64
+ const manifest = await generateRpcClient({
65
+ projectPath: path.resolve(options.project),
66
+ outputPath: path.resolve(options.output)
164
67
  });
165
- } else {
166
- _chunk3OM7CHCAjs.logger.info(pc.cyan("Generating API client..."));
167
- const parser = new NestJSParser(options.project);
168
- const controllers = parser.findFusionControllers();
169
- const generator = new ClientGenerator();
170
- await generator.generate({
171
- controllers,
172
- outputPath: options.output
68
+ _chunkWCKSKU3Cjs.logger.success(`Generated Wexts RPC client for ${manifest.services.length} service(s).`);
69
+ });
70
+ 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) => {
71
+ if (!options.skipGenerate && fs.existsSync(options.project)) {
72
+ const { generateRpcClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
73
+ await generateRpcClient({
74
+ projectPath: path.resolve(options.project),
75
+ outputPath: path.resolve(options.output)
76
+ });
77
+ }
78
+ runScript("build", {
79
+ cwd: process.cwd()
80
+ });
81
+ });
82
+ 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", _nullishCoalesce(process.env.PORT, () => ( "3000"))).action(async (options) => {
83
+ const { startWextsRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../runtime/index.js")));
84
+ const configPath = path.resolve(options.config);
85
+ const runtimeConfig = fs.existsSync(configPath) ? await loadRuntimeConfig(configPath) : {};
86
+ await startWextsRuntime({
87
+ ...runtimeConfig,
88
+ port: Number(options.port),
89
+ dev: false
90
+ });
91
+ });
92
+ 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) => {
93
+ const { buildVercelOutput } = await Promise.resolve().then(() => _interopRequireWildcard(require("../vercel-builder/index.js")));
94
+ const result = await buildVercelOutput({
95
+ rootDir: process.cwd(),
96
+ apiProjectPath: options.project,
97
+ rpcOutputPath: options.output,
98
+ runtimeConfigPath: options.config,
99
+ skipCodegen: options.skipCodegen,
100
+ skipBuild: options.skipBuild,
101
+ nodeVersion: options.nodeVersion,
102
+ maxDuration: Number(options.maxDuration)
173
103
  });
104
+ if (result.warnings.length > 0) {
105
+ for (const warning of result.warnings) _chunkWCKSKU3Cjs.logger.warn(warning);
106
+ }
107
+ if (result.errors.length > 0) {
108
+ for (const error of result.errors) _chunkWCKSKU3Cjs.logger.error(error);
109
+ process.exit(1);
110
+ }
111
+ _chunkWCKSKU3Cjs.logger.success("Vercel build output ready at .vercel/output");
112
+ });
113
+ program.command("doctor").description("Validate Wexts project configuration").option("--security", "Run security-specific checks", false).action(async (options) => {
114
+ const result = runDoctor(process.cwd(), options.security);
115
+ for (const warning of result.warnings) _chunkWCKSKU3Cjs.logger.warn(warning);
116
+ for (const error of result.errors) _chunkWCKSKU3Cjs.logger.error(error);
117
+ if (result.errors.length > 0) process.exit(1);
118
+ _chunkWCKSKU3Cjs.logger.success(options.security ? "Security doctor passed." : "Doctor passed.");
119
+ });
120
+ return program;
121
+ }
122
+ _chunkXE4OXN2Wjs.__name.call(void 0, createCliProgram, "createCliProgram");
123
+ function runDoctor(cwd, security = false) {
124
+ const result = {
125
+ errors: [],
126
+ warnings: []
127
+ };
128
+ const pkgPath = path.join(cwd, "package.json");
129
+ if (!fs.existsSync(pkgPath)) {
130
+ result.errors.push("package.json not found.");
131
+ return result;
132
+ }
133
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
134
+ if (!_optionalChain([pkg, 'access', _ => _.packageManager, 'optionalAccess', _2 => _2.startsWith, 'call', _3 => _3("pnpm@")])) {
135
+ result.warnings.push("packageManager should pin pnpm.");
136
+ }
137
+ for (const dir of [
138
+ "apps/api",
139
+ "apps/web"
140
+ ]) {
141
+ if (!fs.existsSync(path.join(cwd, dir))) {
142
+ result.warnings.push(`${dir} not found; some Wexts commands may need explicit paths.`);
143
+ }
144
+ }
145
+ if (fs.existsSync(path.join(cwd, "apps/api")) && fs.existsSync(path.join(cwd, "apps/web"))) {
146
+ result.warnings.push("Development mode starts separate web/API processes. Single-port serving is the production `wexts start` runtime path.");
174
147
  }
175
- });
176
- async function createProject(projectName, template) {
177
- _chunk3OM7CHCAjs.logger.info(pc.cyan(`Creating wexts project: ${pc.bold(projectName)}`));
178
- _chunk3OM7CHCAjs.logger.info(`Template: ${template}`);
148
+ if (security) {
149
+ const source = readAllText(cwd, [
150
+ "apps/api/src",
151
+ "packages/templates/nestjs-api/src"
152
+ ]);
153
+ if (source.includes("default-secret")) {
154
+ result.errors.push('JWT fallback "default-secret" found. Production apps must fail without a strong JWT_SECRET.');
155
+ }
156
+ if (/origin:\s*['"]\*['"]/.test(source)) {
157
+ result.errors.push("Wildcard CORS origin found. Use an explicit origin allowlist.");
158
+ }
159
+ }
160
+ return result;
161
+ }
162
+ _chunkXE4OXN2Wjs.__name.call(void 0, runDoctor, "runDoctor");
163
+ async function createProject(projectName, template, options) {
179
164
  const projectPath = path.join(process.cwd(), projectName);
180
165
  if (fs.existsSync(projectPath)) {
181
- _chunk3OM7CHCAjs.logger.error(`Directory ${projectName} already exists!`);
182
- process.exit(1);
166
+ throw new Error(`Directory already exists: ${projectName}`);
183
167
  }
184
- function getTemplatePath() {
185
- const possiblePaths = [
186
- path.join(__dirname, "../../templates"),
187
- path.join(__dirname, "../templates"),
188
- path.join(process.cwd(), "templates"),
189
- path.resolve(__dirname, "..", "..", "templates")
190
- // Absolute resolve
191
- ];
192
- for (const p of possiblePaths) {
193
- if (fs.existsSync(p)) {
194
- return p;
168
+ fs.mkdirSync(projectPath, {
169
+ recursive: true
170
+ });
171
+ if (template === "starter") {
172
+ await createVerifiedStarter(projectPath, projectName, _nullishCoalesce(options.wextsDependency, () => ( resolveCreateWextsDependency(projectPath))));
173
+ } else if (template === "legacy") {
174
+ createLegacyProject(projectPath, projectName);
175
+ } else {
176
+ throw new Error(`Unknown template "${template}". Supported templates: starter, legacy.`);
177
+ }
178
+ if (!options.skipInstall) {
179
+ runCommand(detectPackageManager(projectPath), [
180
+ "install"
181
+ ], projectPath);
182
+ }
183
+ }
184
+ _chunkXE4OXN2Wjs.__name.call(void 0, createProject, "createProject");
185
+ async function createVerifiedStarter(projectPath, projectName, wextsDependency) {
186
+ const files = {
187
+ "pnpm-workspace.yaml": "packages:\n - 'apps/*'\n",
188
+ "package.json": JSON.stringify({
189
+ name: projectName,
190
+ version: "0.1.0",
191
+ private: true,
192
+ packageManager: "pnpm@10.22.0",
193
+ scripts: {
194
+ dev: "wexts dev",
195
+ generate: "wexts generate -p apps/api -o apps/web/lib/wexts",
196
+ build: "pnpm run generate && tsc -p apps/api/tsconfig.json && next build apps/web",
197
+ start: "wexts start -c ./wexts.runtime.js",
198
+ "vercel-build": "wexts vercel-build -p apps/api -o apps/web/lib/wexts -c ./wexts.runtime.js",
199
+ doctor: "wexts doctor",
200
+ "doctor:security": "wexts doctor --security"
201
+ },
202
+ dependencies: {
203
+ "@nestjs/common": "^11.1.19",
204
+ "@nestjs/core": "^11.1.19",
205
+ "@nestjs/platform-fastify": "^11.1.19",
206
+ next: "16.2.4",
207
+ react: "^19.2.5",
208
+ "react-dom": "^19.2.5",
209
+ "reflect-metadata": "^0.2.2",
210
+ rxjs: "^7.8.1",
211
+ wexts: wextsDependency
212
+ },
213
+ devDependencies: {
214
+ "@types/node": "^22.19.1",
215
+ "@types/react": "^19.2.14",
216
+ "@types/react-dom": "^19.2.3",
217
+ typescript: "^5.9.3"
195
218
  }
196
- }
197
- return "";
219
+ }, null, 2),
220
+ "apps/api/package.json": JSON.stringify({
221
+ name: `${projectName}-api`,
222
+ private: true,
223
+ scripts: {
224
+ "start:dev": "tsc -w -p tsconfig.json"
225
+ }
226
+ }, null, 2),
227
+ "apps/api/tsconfig.json": JSON.stringify({
228
+ compilerOptions: {
229
+ target: "ES2023",
230
+ module: "NodeNext",
231
+ moduleResolution: "NodeNext",
232
+ experimentalDecorators: true,
233
+ emitDecoratorMetadata: true,
234
+ strict: true,
235
+ esModuleInterop: true,
236
+ skipLibCheck: true,
237
+ outDir: "dist",
238
+ rootDir: "src"
239
+ },
240
+ include: [
241
+ "src/**/*.ts"
242
+ ]
243
+ }, null, 2),
244
+ "apps/api/src/hello.service.ts": `import { Injectable } from '@nestjs/common';
245
+ import { RpcMethod, RpcService } from 'wexts/nest';
246
+
247
+ @Injectable()
248
+ @RpcService({ name: 'hello', requireAuth: false })
249
+ export class HelloService {
250
+ @RpcMethod()
251
+ async sayHello(name: string): Promise<string> {
252
+ return \`Hello, \${name}!\`;
198
253
  }
199
- _chunkXE4OXN2Wjs.__name.call(void 0, getTemplatePath, "getTemplatePath");
200
- const templatePath = getTemplatePath();
201
- if (!templatePath) {
202
- _chunk3OM7CHCAjs.logger.error(`\u274C Template directory not found!`);
203
- _chunk3OM7CHCAjs.logger.info(`Searched in:`);
204
- _chunk3OM7CHCAjs.logger.info(` - ${path.join(__dirname, "../../templates")}`);
205
- _chunk3OM7CHCAjs.logger.info(` - ${path.join(__dirname, "../templates")}`);
206
- _chunk3OM7CHCAjs.logger.info(` - ${path.join(process.cwd(), "templates")}`);
207
- _chunk3OM7CHCAjs.logger.warn("\u26A0\uFE0F Using fallback scaffolding (empty structure)");
208
- fs.mkdirSync(projectPath, {
209
- recursive: true
210
- });
211
- fs.mkdirSync(path.join(projectPath, "apps"), {
212
- recursive: true
213
- });
214
- fs.mkdirSync(path.join(projectPath, "packages"), {
215
- recursive: true
216
- });
217
- } else {
218
- _chunk3OM7CHCAjs.logger.info(`\u{1F4E6} Copying templates from: ${templatePath}`);
219
- fs.mkdirSync(projectPath, {
220
- recursive: true
221
- });
222
- fs.mkdirSync(path.join(projectPath, "apps"), {
223
- recursive: true
224
- });
225
- fs.mkdirSync(path.join(projectPath, "packages"), {
254
+ }
255
+ `,
256
+ "apps/web/package.json": JSON.stringify({
257
+ name: `${projectName}-web`,
258
+ private: true,
259
+ scripts: {
260
+ dev: "next dev -p 3000"
261
+ }
262
+ }, null, 2),
263
+ "apps/web/tsconfig.json": JSON.stringify({
264
+ compilerOptions: {
265
+ target: "ES2022",
266
+ lib: [
267
+ "dom",
268
+ "dom.iterable",
269
+ "es2022"
270
+ ],
271
+ allowJs: false,
272
+ skipLibCheck: true,
273
+ strict: true,
274
+ noEmit: true,
275
+ esModuleInterop: true,
276
+ module: "esnext",
277
+ moduleResolution: "bundler",
278
+ resolveJsonModule: true,
279
+ isolatedModules: true,
280
+ jsx: "react-jsx",
281
+ incremental: true,
282
+ plugins: [
283
+ {
284
+ name: "next"
285
+ }
286
+ ]
287
+ },
288
+ include: [
289
+ "next-env.d.ts",
290
+ "**/*.ts",
291
+ "**/*.tsx",
292
+ ".next/types/**/*.ts",
293
+ ".next/dev/types/**/*.ts"
294
+ ],
295
+ exclude: [
296
+ "node_modules"
297
+ ]
298
+ }, null, 2),
299
+ "apps/web/next-env.d.ts": `/// <reference types="next" />
300
+ /// <reference types="next/image-types/global" />
301
+
302
+ // This file is generated by Next.js. Do not edit.
303
+ `,
304
+ "apps/web/next.config.ts": `import type { NextConfig } from 'next';
305
+
306
+ const nextConfig: NextConfig = {
307
+ output: 'standalone',
308
+ };
309
+
310
+ export default nextConfig;
311
+ `,
312
+ "apps/web/app/layout.tsx": `import type { ReactNode } from 'react';
313
+ import { WextsProvider } from '../lib/wexts-provider';
314
+
315
+ export default function RootLayout({ children }: { children: ReactNode }) {
316
+ return (
317
+ <html lang="en">
318
+ <body>
319
+ <WextsProvider>{children}</WextsProvider>
320
+ </body>
321
+ </html>
322
+ );
323
+ }
324
+ `,
325
+ "apps/web/app/page.tsx": `'use client';
326
+
327
+ import { useState } from 'react';
328
+ import { useWexts } from '../lib/wexts-provider';
329
+
330
+ export default function Page() {
331
+ const wexts = useWexts();
332
+ const [message, setMessage] = useState('Not called yet');
333
+
334
+ return (
335
+ <main>
336
+ <h1>Wexts Hello RPC</h1>
337
+ <button
338
+ type="button"
339
+ onClick={async () => {
340
+ setMessage(await wexts.hello.sayHello('Bob'));
341
+ }}
342
+ >
343
+ Call RPC
344
+ </button>
345
+ <p>{message}</p>
346
+ </main>
347
+ );
348
+ }
349
+ `,
350
+ "apps/web/lib/wexts-provider.tsx": `'use client';
351
+
352
+ import { FusionProvider, useWexts as useGeneratedWexts } from 'wexts/next';
353
+ import { createWextsClient, type WextsClient } from './wexts/client';
354
+
355
+ export function WextsProvider({ children }: { children: React.ReactNode }) {
356
+ return (
357
+ <FusionProvider rpcClient={createWextsClient({ baseUrl: '/rpc' })}>
358
+ {children}
359
+ </FusionProvider>
360
+ );
361
+ }
362
+
363
+ export function useWexts(): WextsClient {
364
+ return useGeneratedWexts<WextsClient>();
365
+ }
366
+ `,
367
+ "wexts.runtime.js": `const { HelloService } = require('./apps/api/dist/hello.service.js');
368
+
369
+ module.exports = {
370
+ nextDir: './apps/web',
371
+ rpcManifestPath: './apps/web/lib/wexts/wexts.rpc.manifest.json',
372
+ rpcServices: {
373
+ hello: new HelloService(),
374
+ },
375
+ security: {
376
+ allowedOrigins: ['http://localhost:3000'],
377
+ },
378
+ };
379
+ `,
380
+ "README.md": `# ${projectName}
381
+
382
+ Verified Wexts starter with a generated Hello RPC client.
383
+
384
+ \`\`\`bash
385
+ pnpm install
386
+ pnpm run generate
387
+ pnpm run build
388
+ pnpm run doctor
389
+ pnpm run doctor:security
390
+ pnpm run start
391
+ \`\`\`
392
+ `
393
+ };
394
+ for (const [relativePath, content] of Object.entries(files)) {
395
+ const absolutePath = path.join(projectPath, relativePath);
396
+ fs.mkdirSync(path.dirname(absolutePath), {
226
397
  recursive: true
227
398
  });
228
- const apiTemplatePath = path.join(templatePath, "nestjs-api");
229
- const apiDestPath = path.join(projectPath, "apps/api");
230
- if (fs.existsSync(apiTemplatePath)) {
231
- fs.cpSync(apiTemplatePath, apiDestPath, {
232
- recursive: true
233
- });
234
- _chunk3OM7CHCAjs.logger.success(" - Copied API template");
235
- const envExamplePath = path.join(apiDestPath, ".env.example");
236
- const envPath = path.join(apiDestPath, ".env");
237
- if (fs.existsSync(envExamplePath) && !fs.existsSync(envPath)) {
238
- fs.copyFileSync(envExamplePath, envPath);
239
- _chunk3OM7CHCAjs.logger.success(" - Created .env from .env.example");
240
- }
241
- } else {
242
- _chunk3OM7CHCAjs.logger.warn(` \u26A0\uFE0F API template not found at ${apiTemplatePath}`);
243
- }
244
- const webTemplatePath = path.join(templatePath, "nextjs-web");
245
- const webDestPath = path.join(projectPath, "apps/web");
246
- if (fs.existsSync(webTemplatePath)) {
247
- fs.cpSync(webTemplatePath, webDestPath, {
248
- recursive: true
249
- });
250
- _chunk3OM7CHCAjs.logger.success(" - Copied Web template");
251
- } else {
252
- _chunk3OM7CHCAjs.logger.warn(` \u26A0\uFE0F Web template not found at ${webTemplatePath}`);
253
- }
399
+ fs.writeFileSync(absolutePath, content);
254
400
  }
255
- const packageJson = {
401
+ const { generateRpcClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
402
+ await generateRpcClient({
403
+ projectPath: path.join(projectPath, "apps/api"),
404
+ outputPath: path.join(projectPath, "apps/web/lib/wexts")
405
+ });
406
+ }
407
+ _chunkXE4OXN2Wjs.__name.call(void 0, createVerifiedStarter, "createVerifiedStarter");
408
+ function createLegacyProject(projectPath, projectName) {
409
+ const templatePath = findTemplatePath();
410
+ if (!templatePath) {
411
+ throw new Error("Template directory not found in package.");
412
+ }
413
+ fs.mkdirSync(path.join(projectPath, "apps"), {
414
+ recursive: true
415
+ });
416
+ fs.cpSync(path.join(templatePath, "nestjs-api"), path.join(projectPath, "apps/api"), {
417
+ recursive: true
418
+ });
419
+ fs.cpSync(path.join(templatePath, "nextjs-web"), path.join(projectPath, "apps/web"), {
420
+ recursive: true
421
+ });
422
+ fs.rmSync(path.join(projectPath, "apps/web/package-lock.json"), {
423
+ force: true
424
+ });
425
+ fs.rmSync(path.join(projectPath, "apps/api/package-lock.json"), {
426
+ force: true
427
+ });
428
+ fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), "packages:\n - 'apps/*'\n");
429
+ fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify({
256
430
  name: projectName,
257
- version: "0.0.0",
258
431
  private: true,
432
+ packageManager: "pnpm@10.22.0",
259
433
  scripts: {
260
- "build": "pnpm exec turbo build",
261
- "dev": "pnpm exec turbo dev",
262
- "lint": "pnpm exec turbo lint",
263
- "format": 'prettier --write "**/*.{ts,tsx,md}"'
434
+ dev: "wexts dev",
435
+ generate: "wexts generate",
436
+ build: "wexts build",
437
+ start: "wexts start",
438
+ doctor: "wexts doctor"
264
439
  },
265
440
  devDependencies: {
266
- "turbo": "^2.6.1",
267
- "prettier": "latest",
268
- "typescript": "^5.9.3",
269
- "wexts": "latest"
270
- },
271
- packageManager: "pnpm@10.0.0"
272
- };
273
- fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify(packageJson, null, 2));
274
- const turboJson = {
275
- "$schema": "https://turbo.build/schema.json",
276
- "tasks": {
277
- "build": {
278
- "dependsOn": [
279
- "^build"
280
- ],
281
- "outputs": [
282
- ".next/**",
283
- "!.next/cache/**",
284
- "dist/**"
285
- ]
286
- },
287
- "lint": {},
288
- "dev": {
289
- "cache": false,
290
- "persistent": true
291
- }
441
+ wexts: `^${readPackageVersion()}`
292
442
  }
293
- };
294
- fs.writeFileSync(path.join(projectPath, "turbo.json"), JSON.stringify(turboJson, null, 2));
295
- const pnpmWorkspace = `packages:
296
- - 'apps/*'
297
- - 'packages/*'
298
- `;
299
- fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), pnpmWorkspace);
300
- _chunk3OM7CHCAjs.logger.success("\u2705 Project structure created");
301
- _chunk3OM7CHCAjs.logger.info("\u{1F4E6} Installing dependencies...");
443
+ }, null, 2));
444
+ }
445
+ _chunkXE4OXN2Wjs.__name.call(void 0, createLegacyProject, "createLegacyProject");
446
+ function resolveCreateWextsDependency(projectPath) {
447
+ const packageRoot = path.resolve(__dirname, "../..");
448
+ const cwdLocalPackage = path.join(process.cwd(), "node_modules/wexts");
302
449
  try {
303
- try {
304
- _child_process.execSync.call(void 0, "pnpm --version", {
305
- stdio: "ignore"
306
- });
307
- } catch (e) {
308
- _chunk3OM7CHCAjs.logger.info("Installing pnpm...");
309
- _child_process.execSync.call(void 0, "npm install -g pnpm", {
310
- stdio: "ignore"
450
+ if (fs.existsSync(cwdLocalPackage) && fs.realpathSync(cwdLocalPackage) === fs.realpathSync(packageRoot)) {
451
+ return `file:${path.relative(projectPath, cwdLocalPackage)}`;
452
+ }
453
+ } catch (e) {
454
+ }
455
+ return `^${readPackageVersion()}`;
456
+ }
457
+ _chunkXE4OXN2Wjs.__name.call(void 0, resolveCreateWextsDependency, "resolveCreateWextsDependency");
458
+ async function scaffoldGenerator(options) {
459
+ if (options.type !== "config" && !options.name) {
460
+ throw new (0, _chunkAVMQJWYDjs.WextsError)({
461
+ code: "WEXTS_CLI_GENERATOR_NAME_REQUIRED",
462
+ message: `Generator "${options.type}" requires a name.`,
463
+ suggestedFix: `Run \`wexts generate ${options.type} hello\` or use \`wexts generate config\`.`,
464
+ docsSlug: "cli"
465
+ });
466
+ }
467
+ if (options.type === "config") {
468
+ return writeGeneratedFiles(options.targetRoot, [
469
+ {
470
+ relativePath: "wexts.runtime.js",
471
+ content: `/** @type {import('wexts/runtime').WextsRuntimeConfig} */
472
+ module.exports = {
473
+ rootDir: __dirname,
474
+ port: Number(process.env.PORT || 3000),
475
+ rpcManifestPath: 'apps/web/lib/wexts/wexts.rpc.manifest.json',
476
+ security: {
477
+ enabled: true,
478
+ production: process.env.NODE_ENV === 'production',
479
+ allowedOrigins: process.env.WEXTS_ALLOWED_ORIGINS?.split(',').filter(Boolean) || [],
480
+ },
481
+ };
482
+ `
483
+ }
484
+ ], Boolean(options.force));
485
+ }
486
+ const rawName = options.name;
487
+ const name = toKebabCase(rawName);
488
+ const classBase = toPascalCase(name);
489
+ const srcRoot = path.join(options.targetRoot, "src");
490
+ const filesByType = {
491
+ rpc: rpcServiceFiles(name, classBase),
492
+ service: [
493
+ {
494
+ relativePath: path.join("src", name, `${name}.service.ts`),
495
+ content: `import { Injectable } from '@nestjs/common';
496
+
497
+ @Injectable()
498
+ export class ${classBase}Service {
499
+ async execute(): Promise<string> {
500
+ return '${toCamelCase(name)}';
501
+ }
502
+ }
503
+ `
504
+ }
505
+ ],
506
+ module: [
507
+ {
508
+ relativePath: path.join("src", name, `${name}.module.ts`),
509
+ content: `import { Module } from '@nestjs/common';
510
+
511
+ @Module({})
512
+ export class ${classBase}Module {}
513
+ `
514
+ }
515
+ ],
516
+ entity: [
517
+ {
518
+ relativePath: path.join("src", name, `${name}.entity.ts`),
519
+ content: `export interface ${classBase}Entity {
520
+ id: string;
521
+ createdAt: Date;
522
+ updatedAt: Date;
523
+ }
524
+ `
525
+ }
526
+ ],
527
+ guard: [
528
+ {
529
+ relativePath: path.join("src", name, `${name}.guard.ts`),
530
+ content: `import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
531
+
532
+ @Injectable()
533
+ export class ${classBase}Guard implements CanActivate {
534
+ canActivate(_context: ExecutionContext): boolean {
535
+ return true;
536
+ }
537
+ }
538
+ `
539
+ }
540
+ ]
541
+ };
542
+ fs.mkdirSync(srcRoot, {
543
+ recursive: true
544
+ });
545
+ return writeGeneratedFiles(options.targetRoot, filesByType[options.type], Boolean(options.force));
546
+ }
547
+ _chunkXE4OXN2Wjs.__name.call(void 0, scaffoldGenerator, "scaffoldGenerator");
548
+ function isScaffoldGenerator(type) {
549
+ return [
550
+ "rpc",
551
+ "service",
552
+ "module",
553
+ "entity",
554
+ "guard",
555
+ "config"
556
+ ].includes(type);
557
+ }
558
+ _chunkXE4OXN2Wjs.__name.call(void 0, isScaffoldGenerator, "isScaffoldGenerator");
559
+ function rpcServiceFiles(serviceName, classBase) {
560
+ return [
561
+ {
562
+ relativePath: path.join("src", serviceName, `${serviceName}.service.ts`),
563
+ content: `import { Injectable } from '@nestjs/common';
564
+ import { RpcMethod, RpcService } from 'wexts/nest';
565
+
566
+ @Injectable()
567
+ @RpcService({ name: '${toCamelCase(serviceName)}', requireAuth: false })
568
+ export class ${classBase}Service {
569
+ @RpcMethod()
570
+ async sayHello(name: string): Promise<string> {
571
+ return \`Hello, \${name}!\`;
572
+ }
573
+ }
574
+ `
575
+ }
576
+ ];
577
+ }
578
+ _chunkXE4OXN2Wjs.__name.call(void 0, rpcServiceFiles, "rpcServiceFiles");
579
+ function writeGeneratedFiles(root, files, force) {
580
+ const changedFiles = [];
581
+ for (const file of files) {
582
+ const absolutePath = path.join(root, file.relativePath);
583
+ if (fs.existsSync(absolutePath) && !force) {
584
+ throw new (0, _chunkAVMQJWYDjs.WextsError)({
585
+ code: "WEXTS_CLI_GENERATOR_FILE_EXISTS",
586
+ message: `Refusing to overwrite existing file: ${absolutePath}`,
587
+ suggestedFix: "Review the file, then rerun with --force if overwriting is intentional.",
588
+ docsSlug: "cli"
311
589
  });
312
590
  }
313
- _child_process.execSync.call(void 0, "pnpm install", {
314
- cwd: projectPath,
315
- stdio: "inherit"
591
+ fs.mkdirSync(path.dirname(absolutePath), {
592
+ recursive: true
316
593
  });
317
- _chunk3OM7CHCAjs.logger.success("\u2705 Dependencies installed");
318
- _chunk3OM7CHCAjs.logger.info(pc.green(`
319
- \u{1F389} Project ${projectName} created successfully!`));
320
- _chunk3OM7CHCAjs.logger.info(`
321
- To get started:
322
- `);
323
- _chunk3OM7CHCAjs.logger.info(pc.cyan(` cd ${projectName}`));
324
- _chunk3OM7CHCAjs.logger.info(pc.cyan(` pnpm dev
325
- `));
326
- } catch (error) {
327
- _chunk3OM7CHCAjs.logger.error("Failed to install dependencies");
594
+ fs.writeFileSync(absolutePath, file.content);
595
+ changedFiles.push(absolutePath);
328
596
  }
597
+ return changedFiles;
329
598
  }
330
- _chunkXE4OXN2Wjs.__name.call(void 0, createProject, "createProject");
331
- program.parse();
599
+ _chunkXE4OXN2Wjs.__name.call(void 0, writeGeneratedFiles, "writeGeneratedFiles");
600
+ function runScript(script, options) {
601
+ const cwd = _nullishCoalesce(options.cwd, () => ( process.cwd()));
602
+ const packageManager = detectPackageManager(cwd);
603
+ const args = packageManager === "npm" ? [
604
+ "run",
605
+ script
606
+ ] : [
607
+ "run",
608
+ script
609
+ ];
610
+ runCommand(packageManager, args, cwd);
611
+ }
612
+ _chunkXE4OXN2Wjs.__name.call(void 0, runScript, "runScript");
613
+ function runCommand(command, args, cwd) {
614
+ const result = _child_process.spawnSync.call(void 0, command, args, {
615
+ cwd,
616
+ stdio: "inherit",
617
+ shell: process.platform === "win32"
618
+ });
619
+ if (result.status !== 0) {
620
+ throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}`);
621
+ }
622
+ }
623
+ _chunkXE4OXN2Wjs.__name.call(void 0, runCommand, "runCommand");
624
+ function detectPackageManager(cwd) {
625
+ const packageJsonPath = path.join(cwd, "package.json");
626
+ if (fs.existsSync(packageJsonPath)) {
627
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
628
+ if (_optionalChain([pkg, 'access', _4 => _4.packageManager, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("pnpm@")])) return "pnpm";
629
+ }
630
+ if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
631
+ if (fs.existsSync(path.join(cwd, "pnpm-workspace.yaml"))) return "pnpm";
632
+ return "npm";
633
+ }
634
+ _chunkXE4OXN2Wjs.__name.call(void 0, detectPackageManager, "detectPackageManager");
635
+ function findTemplatePath() {
636
+ const candidates = [
637
+ path.resolve(__dirname, "../../templates"),
638
+ path.resolve(__dirname, "../templates"),
639
+ path.resolve(process.cwd(), "packages/templates")
640
+ ];
641
+ return candidates.find((candidate) => fs.existsSync(candidate));
642
+ }
643
+ _chunkXE4OXN2Wjs.__name.call(void 0, findTemplatePath, "findTemplatePath");
644
+ function readPackageVersion() {
645
+ const packageJsonPath = path.resolve(__dirname, "../../package.json");
646
+ if (!fs.existsSync(packageJsonPath)) return "0.0.0";
647
+ return JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version;
648
+ }
649
+ _chunkXE4OXN2Wjs.__name.call(void 0, readPackageVersion, "readPackageVersion");
650
+ function readAllText(cwd, dirs) {
651
+ let text = "";
652
+ for (const dir of dirs) {
653
+ const absolute = path.join(cwd, dir);
654
+ if (!fs.existsSync(absolute)) continue;
655
+ for (const file of walk(absolute)) {
656
+ if (file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".js")) {
657
+ text += fs.readFileSync(file, "utf8");
658
+ }
659
+ }
660
+ }
661
+ return text;
662
+ }
663
+ _chunkXE4OXN2Wjs.__name.call(void 0, readAllText, "readAllText");
664
+ function walk(dir) {
665
+ return fs.readdirSync(dir, {
666
+ withFileTypes: true
667
+ }).flatMap((entry) => {
668
+ const absolute = path.join(dir, entry.name);
669
+ if (entry.isDirectory()) return walk(absolute);
670
+ return [
671
+ absolute
672
+ ];
673
+ });
674
+ }
675
+ _chunkXE4OXN2Wjs.__name.call(void 0, walk, "walk");
676
+ function toKebabCase(value) {
677
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
678
+ }
679
+ _chunkXE4OXN2Wjs.__name.call(void 0, toKebabCase, "toKebabCase");
680
+ function toPascalCase(value) {
681
+ return toKebabCase(value).split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
682
+ }
683
+ _chunkXE4OXN2Wjs.__name.call(void 0, toPascalCase, "toPascalCase");
684
+ function toCamelCase(value) {
685
+ const pascal = toPascalCase(value);
686
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
687
+ }
688
+ _chunkXE4OXN2Wjs.__name.call(void 0, toCamelCase, "toCamelCase");
689
+ function pathToFileUrl(filePath) {
690
+ return `file://${filePath}`;
691
+ }
692
+ _chunkXE4OXN2Wjs.__name.call(void 0, pathToFileUrl, "pathToFileUrl");
693
+ async function loadRuntimeConfig(configPath) {
694
+ if (configPath.endsWith(".mjs")) {
695
+ const mod2 = await Promise.resolve().then(() => _interopRequireWildcard(require(pathToFileUrl(configPath))));
696
+ return _nullishCoalesce(mod2.default, () => ( mod2));
697
+ }
698
+ const require2 = _module.createRequire.call(void 0, __filename);
699
+ const mod = require2(configPath);
700
+ return _nullishCoalesce(mod.default, () => ( mod));
701
+ }
702
+ _chunkXE4OXN2Wjs.__name.call(void 0, loadRuntimeConfig, "loadRuntimeConfig");
703
+ 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`));
704
+ if (invokedAsCli && !process.env.VITEST) {
705
+ createCliProgram().parseAsync(process.argv).catch((error) => {
706
+ _chunkWCKSKU3Cjs.logger.error(_chunkAVMQJWYDjs.formatWextsError.call(void 0, error));
707
+ process.exit(1);
708
+ });
709
+ }
710
+
711
+
712
+
713
+
714
+
715
+ exports.createCliProgram = createCliProgram; exports.createProject = createProject; exports.runDoctor = runDoctor; exports.scaffoldGenerator = scaffoldGenerator;
332
716
  //# sourceMappingURL=index.js.map