wexts 4.1.5 → 4.1.6

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 (185) hide show
  1. package/README.md +49 -49
  2. package/bin/wexts.cjs +2 -2
  3. package/dist/chunk-27NEYQD2.mjs +222 -0
  4. package/dist/chunk-27NEYQD2.mjs.map +1 -0
  5. package/dist/chunk-2LJVUMXW.js +228 -0
  6. package/dist/chunk-2LJVUMXW.js.map +1 -0
  7. package/dist/chunk-5DBFN65W.mjs +183 -0
  8. package/dist/chunk-5DBFN65W.mjs.map +1 -0
  9. package/dist/chunk-75HBI2XG.js +504 -0
  10. package/dist/chunk-75HBI2XG.js.map +1 -0
  11. package/dist/chunk-AVMQJWYD.js +95 -0
  12. package/dist/chunk-AVMQJWYD.js.map +1 -0
  13. package/dist/chunk-C2AG7Q3C.mjs +65 -0
  14. package/dist/chunk-C2AG7Q3C.mjs.map +1 -0
  15. package/dist/chunk-DS5KVVWJ.mjs +95 -0
  16. package/dist/chunk-DS5KVVWJ.mjs.map +1 -0
  17. package/dist/chunk-FUPLZMSR.mjs +228 -0
  18. package/dist/chunk-FUPLZMSR.mjs.map +1 -0
  19. package/dist/chunk-HLT3IHJY.js +183 -0
  20. package/dist/chunk-HLT3IHJY.js.map +1 -0
  21. package/dist/chunk-L77ANWWT.mjs +22 -0
  22. package/dist/chunk-L77ANWWT.mjs.map +1 -0
  23. package/dist/chunk-P3Q4I5FD.js +222 -0
  24. package/dist/chunk-P3Q4I5FD.js.map +1 -0
  25. package/dist/chunk-VBIQGUDI.mjs +504 -0
  26. package/dist/chunk-VBIQGUDI.mjs.map +1 -0
  27. package/dist/chunk-WCKSKU3C.js +65 -0
  28. package/dist/chunk-WCKSKU3C.js.map +1 -0
  29. package/dist/chunk-XE4OXN2W.js +12 -0
  30. package/dist/chunk-XE4OXN2W.js.map +1 -0
  31. package/dist/cli/index.d.mts +23 -0
  32. package/dist/cli/index.d.ts +23 -0
  33. package/dist/cli/index.js +745 -0
  34. package/dist/cli/index.js.map +1 -0
  35. package/dist/cli/index.mjs +747 -0
  36. package/dist/cli/index.mjs.map +1 -0
  37. package/dist/client/index.d.mts +43 -0
  38. package/dist/client/index.d.ts +43 -0
  39. package/dist/client/index.js +187 -0
  40. package/dist/client/index.js.map +1 -0
  41. package/dist/client/index.mjs +166 -0
  42. package/dist/client/index.mjs.map +1 -0
  43. package/dist/codegen/index.d.mts +2 -0
  44. package/dist/codegen/index.d.ts +2 -0
  45. package/dist/codegen/index.js +16 -0
  46. package/dist/codegen/index.js.map +1 -0
  47. package/dist/codegen/index.mjs +16 -0
  48. package/dist/codegen/index.mjs.map +1 -0
  49. package/dist/decorators-BiQtOHuF.d.ts +60 -0
  50. package/dist/decorators-vBopODtr.d.mts +60 -0
  51. package/dist/dev-server/index.d.mts +1 -0
  52. package/dist/dev-server/index.d.ts +1 -0
  53. package/dist/dev-server/index.js +13 -0
  54. package/dist/dev-server/index.js.map +1 -0
  55. package/dist/dev-server/index.mjs +13 -0
  56. package/dist/dev-server/index.mjs.map +1 -0
  57. package/dist/errors-D545UvXf.d.mts +37 -0
  58. package/dist/errors-D545UvXf.d.ts +37 -0
  59. package/dist/index-7RvU-jGE.d.mts +66 -0
  60. package/dist/index-7RvU-jGE.d.ts +66 -0
  61. package/dist/index-CJKs4wtN.d.ts +92 -0
  62. package/dist/index-CUR6CnLk.d.ts +27 -0
  63. package/dist/index-h66Vq9dK.d.mts +92 -0
  64. package/dist/index-tqmYsTUn.d.mts +27 -0
  65. package/dist/index.d.mts +289 -0
  66. package/dist/index.d.ts +289 -0
  67. package/dist/index.js +544 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/index.mjs +544 -0
  70. package/dist/index.mjs.map +1 -0
  71. package/dist/nest/index.d.mts +2 -0
  72. package/dist/nest/index.d.ts +2 -0
  73. package/dist/nest/index.js +36 -0
  74. package/dist/nest/index.js.map +1 -0
  75. package/dist/nest/index.mjs +36 -0
  76. package/dist/nest/index.mjs.map +1 -0
  77. package/dist/next/index.d.mts +66 -0
  78. package/dist/next/index.d.ts +66 -0
  79. package/dist/next/index.js +282 -0
  80. package/dist/next/index.js.map +1 -0
  81. package/dist/next/index.mjs +251 -0
  82. package/dist/next/index.mjs.map +1 -0
  83. package/dist/rpc/index.d.mts +32 -0
  84. package/dist/rpc/index.d.ts +32 -0
  85. package/dist/rpc/index.js +19 -0
  86. package/dist/rpc/index.js.map +1 -0
  87. package/dist/rpc/index.mjs +1 -0
  88. package/dist/rpc/index.mjs.map +1 -0
  89. package/dist/runtime/index.d.mts +55 -0
  90. package/dist/runtime/index.d.ts +55 -0
  91. package/dist/runtime/index.js +15 -0
  92. package/dist/runtime/index.js.map +1 -0
  93. package/dist/runtime/index.mjs +15 -0
  94. package/dist/runtime/index.mjs.map +1 -0
  95. package/dist/server/index.d.mts +7 -0
  96. package/dist/server/index.d.ts +7 -0
  97. package/dist/server/index.js +58 -0
  98. package/dist/server/index.js.map +1 -0
  99. package/dist/server/index.mjs +58 -0
  100. package/dist/server/index.mjs.map +1 -0
  101. package/dist/types/index.d.mts +12 -0
  102. package/dist/types/index.d.ts +12 -0
  103. package/dist/types/index.js +19 -0
  104. package/dist/types/index.js.map +1 -0
  105. package/dist/types/index.mjs +1 -0
  106. package/dist/types/index.mjs.map +1 -0
  107. package/dist/types-CQ_aexOX.d.mts +32 -0
  108. package/dist/types-CQ_aexOX.d.ts +32 -0
  109. package/dist/vercel-builder/index.d.mts +58 -0
  110. package/dist/vercel-builder/index.d.ts +58 -0
  111. package/dist/vercel-builder/index.js +330 -0
  112. package/dist/vercel-builder/index.js.map +1 -0
  113. package/dist/vercel-builder/index.mjs +330 -0
  114. package/dist/vercel-builder/index.mjs.map +1 -0
  115. package/package.json +153 -153
  116. package/templates/.dockerignore +43 -43
  117. package/templates/.env.example +17 -17
  118. package/templates/Dockerfile +60 -60
  119. package/templates/Procfile +1 -1
  120. package/templates/README.md +67 -67
  121. package/templates/api-sdk.ts +115 -115
  122. package/templates/docker-compose.yml +34 -34
  123. package/templates/nestjs-api/.env.example +3 -3
  124. package/templates/nestjs-api/README.md +87 -87
  125. package/templates/nestjs-api/nest-cli.json +6 -6
  126. package/templates/nestjs-api/package.json +40 -40
  127. package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
  128. package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
  129. package/templates/nestjs-api/prisma/schema.prisma +29 -29
  130. package/templates/nestjs-api/src/app.module.ts +17 -17
  131. package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
  132. package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
  133. package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
  134. package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
  135. package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
  136. package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
  137. package/templates/nestjs-api/src/main.ts +32 -32
  138. package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
  139. package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
  140. package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
  141. package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
  142. package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
  143. package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
  144. package/templates/nestjs-api/src/users/users.controller.ts +14 -14
  145. package/templates/nestjs-api/src/users/users.module.ts +12 -12
  146. package/templates/nestjs-api/src/users/users.service.ts +19 -19
  147. package/templates/nestjs-api/tsconfig.json +39 -39
  148. package/templates/nextjs-web/README.md +76 -76
  149. package/templates/nextjs-web/app/actions/auth.ts +108 -108
  150. package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
  151. package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
  152. package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
  153. package/templates/nextjs-web/app/globals.css +93 -93
  154. package/templates/nextjs-web/app/layout.tsx +29 -29
  155. package/templates/nextjs-web/app/login/page.tsx +5 -5
  156. package/templates/nextjs-web/app/page.tsx +28 -28
  157. package/templates/nextjs-web/app/register/page.tsx +5 -5
  158. package/templates/nextjs-web/components/ui/button.tsx +56 -56
  159. package/templates/nextjs-web/components/ui/card.tsx +79 -79
  160. package/templates/nextjs-web/components/ui/input.tsx +25 -25
  161. package/templates/nextjs-web/components/ui/label.tsx +24 -24
  162. package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
  163. package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
  164. package/templates/nextjs-web/features/auth/api.ts +35 -35
  165. package/templates/nextjs-web/features/auth/index.ts +3 -3
  166. package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
  167. package/templates/nextjs-web/features/dashboard/api.ts +9 -9
  168. package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
  169. package/templates/nextjs-web/features/dashboard/index.ts +3 -3
  170. package/templates/nextjs-web/hooks/index.ts +4 -4
  171. package/templates/nextjs-web/lib/api-client.ts +89 -89
  172. package/templates/nextjs-web/lib/api.ts +115 -115
  173. package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
  174. package/templates/nextjs-web/lib/utils.ts +6 -6
  175. package/templates/nextjs-web/lib/wexts-client.ts +4 -4
  176. package/templates/nextjs-web/next-env.d.ts +6 -6
  177. package/templates/nextjs-web/next.config.ts +20 -20
  178. package/templates/nextjs-web/package.json +37 -37
  179. package/templates/nextjs-web/postcss.config.js +6 -6
  180. package/templates/nextjs-web/tailwind.config.ts +69 -69
  181. package/templates/nextjs-web/tsconfig.json +41 -41
  182. package/templates/nixpacks.toml +11 -11
  183. package/templates/root-package.json +31 -31
  184. package/templates/server.ts +66 -66
  185. package/templates/tsconfig.json +30 -30
@@ -0,0 +1,745 @@
1
+ #!/usr/bin/env node
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
+
4
+
5
+ var _chunkAVMQJWYDjs = require('../chunk-AVMQJWYD.js');
6
+
7
+
8
+ var _chunkWCKSKU3Cjs = require('../chunk-WCKSKU3C.js');
9
+
10
+
11
+ var _chunkXE4OXN2Wjs = require('../chunk-XE4OXN2W.js');
12
+
13
+ // src/cli/index.ts
14
+ var _commander = require('commander');
15
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
16
+ var _path = require('path'); var path = _interopRequireWildcard(_path);
17
+ var _child_process = require('child_process');
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();
30
+ await server.start({
31
+ apiPath: options.api,
32
+ webPath: options.web,
33
+ webPort: Number(options.port),
34
+ apiPort: Number(options.apiPort),
35
+ useProxy: options.proxy
36
+ });
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)
67
+ });
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)
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.");
147
+ }
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) {
164
+ const projectPath = path.join(process.cwd(), projectName);
165
+ if (fs.existsSync(projectPath)) {
166
+ throw new Error(`Directory already exists: ${projectName}`);
167
+ }
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"
218
+ }
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}!\`;
253
+ }
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 start
391
+ \`\`\`
392
+ `,
393
+ ".cursorrules": `# Wexts Project AI Rules
394
+
395
+ You are an expert full-stack developer working on a Wexts application.
396
+ Wexts is a unified single-runtime toolkit that combines Next.js (frontend) and NestJS (backend) using a highly typed RPC bridge.
397
+
398
+ ## Project Structure
399
+ - \`apps/api/\`: The NestJS backend. Contains business logic, database models, and RPC services.
400
+ - \`apps/web/\`: The Next.js frontend. Contains UI components, pages, and consumes the RPC client.
401
+ - \`apps/web/lib/wexts\`: The auto-generated typed RPC client (DO NOT EDIT MANUALLY).
402
+
403
+ ## Backend Guidelines (NestJS)
404
+ 1. **RPC Services**: To create an API endpoint, create a NestJS provider decorated with \`@RpcService({ name: 'serviceName' })\` and methods decorated with \`@RpcMethod()\`.
405
+ 2. **Imports**: Import \`@RpcService\` and \`@RpcMethod\` from \`wexts/nest\`.
406
+ 3. Do NOT manually create REST controllers unless explicitly needed for webhooks. Use the RPC bridge for all internal frontend-backend communication.
407
+ 4. **Auth**: If a service requires authentication, set \`@RpcService({ requireAuth: true })\`.
408
+
409
+ ## Frontend Guidelines (Next.js)
410
+ 1. **RPC Usage**: To call the backend, import the \`api\` client from \`@/lib/wexts\` or your designated Wexts client file (e.g., \`useWexts()\`).
411
+ 2. **Syntax**: \`const data = await api.serviceName.methodName(args);\`
412
+ 3. The \`api\` object is fully type-safe. Rely on TypeScript autocomplete rather than guessing endpoints.
413
+
414
+ ## Development Workflow
415
+ - When asked to add a new full-stack feature:
416
+ 1. Add the database model (Prisma).
417
+ 2. Create/update the NestJS RPC service in \`apps/api\`.
418
+ 3. Remind the user to run \`wexts generate\` (or \`pnpm generate\`) so the types sync.
419
+ 4. Build the UI in Next.js using the new \`api\` methods.
420
+ - **Never** hardcode \`fetch('http://localhost:3000/...')\`. ALWAYS use the generated \`api\` SDK.
421
+ `
422
+ };
423
+ for (const [relativePath, content] of Object.entries(files)) {
424
+ const absolutePath = path.join(projectPath, relativePath);
425
+ fs.mkdirSync(path.dirname(absolutePath), {
426
+ recursive: true
427
+ });
428
+ fs.writeFileSync(absolutePath, content);
429
+ }
430
+ const { generateRpcClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("../codegen/index.js")));
431
+ await generateRpcClient({
432
+ projectPath: path.join(projectPath, "apps/api"),
433
+ outputPath: path.join(projectPath, "apps/web/lib/wexts")
434
+ });
435
+ }
436
+ _chunkXE4OXN2Wjs.__name.call(void 0, createVerifiedStarter, "createVerifiedStarter");
437
+ function createLegacyProject(projectPath, projectName) {
438
+ const templatePath = findTemplatePath();
439
+ if (!templatePath) {
440
+ throw new Error("Template directory not found in package.");
441
+ }
442
+ fs.mkdirSync(path.join(projectPath, "apps"), {
443
+ recursive: true
444
+ });
445
+ fs.cpSync(path.join(templatePath, "nestjs-api"), path.join(projectPath, "apps/api"), {
446
+ recursive: true
447
+ });
448
+ fs.cpSync(path.join(templatePath, "nextjs-web"), path.join(projectPath, "apps/web"), {
449
+ recursive: true
450
+ });
451
+ fs.rmSync(path.join(projectPath, "apps/web/package-lock.json"), {
452
+ force: true
453
+ });
454
+ fs.rmSync(path.join(projectPath, "apps/api/package-lock.json"), {
455
+ force: true
456
+ });
457
+ fs.writeFileSync(path.join(projectPath, "pnpm-workspace.yaml"), "packages:\n - 'apps/*'\n");
458
+ fs.writeFileSync(path.join(projectPath, "package.json"), JSON.stringify({
459
+ name: projectName,
460
+ private: true,
461
+ packageManager: "pnpm@10.22.0",
462
+ scripts: {
463
+ dev: "wexts dev",
464
+ generate: "wexts generate",
465
+ build: "wexts build",
466
+ start: "wexts start",
467
+ doctor: "wexts doctor"
468
+ },
469
+ devDependencies: {
470
+ wexts: `^${readPackageVersion()}`
471
+ }
472
+ }, null, 2));
473
+ }
474
+ _chunkXE4OXN2Wjs.__name.call(void 0, createLegacyProject, "createLegacyProject");
475
+ function resolveCreateWextsDependency(projectPath) {
476
+ const packageRoot = path.resolve(__dirname, "../..");
477
+ const cwdLocalPackage = path.join(process.cwd(), "node_modules/wexts");
478
+ try {
479
+ if (fs.existsSync(cwdLocalPackage) && fs.realpathSync(cwdLocalPackage) === fs.realpathSync(packageRoot)) {
480
+ return `file:${path.relative(projectPath, cwdLocalPackage)}`;
481
+ }
482
+ } catch (e) {
483
+ }
484
+ return `^${readPackageVersion()}`;
485
+ }
486
+ _chunkXE4OXN2Wjs.__name.call(void 0, resolveCreateWextsDependency, "resolveCreateWextsDependency");
487
+ async function scaffoldGenerator(options) {
488
+ if (options.type !== "config" && !options.name) {
489
+ throw new (0, _chunkAVMQJWYDjs.WextsError)({
490
+ code: "WEXTS_CLI_GENERATOR_NAME_REQUIRED",
491
+ message: `Generator "${options.type}" requires a name.`,
492
+ suggestedFix: `Run \`wexts generate ${options.type} hello\` or use \`wexts generate config\`.`,
493
+ docsSlug: "cli"
494
+ });
495
+ }
496
+ if (options.type === "config") {
497
+ return writeGeneratedFiles(options.targetRoot, [
498
+ {
499
+ relativePath: "wexts.runtime.js",
500
+ content: `/** @type {import('wexts/runtime').WextsRuntimeConfig} */
501
+ module.exports = {
502
+ rootDir: __dirname,
503
+ port: Number(process.env.PORT || 3000),
504
+ rpcManifestPath: 'apps/web/lib/wexts/wexts.rpc.manifest.json',
505
+ security: {
506
+ enabled: true,
507
+ production: process.env.NODE_ENV === 'production',
508
+ allowedOrigins: process.env.WEXTS_ALLOWED_ORIGINS?.split(',').filter(Boolean) || [],
509
+ },
510
+ };
511
+ `
512
+ }
513
+ ], Boolean(options.force));
514
+ }
515
+ const rawName = options.name;
516
+ const name = toKebabCase(rawName);
517
+ const classBase = toPascalCase(name);
518
+ const srcRoot = path.join(options.targetRoot, "src");
519
+ const filesByType = {
520
+ rpc: rpcServiceFiles(name, classBase),
521
+ service: [
522
+ {
523
+ relativePath: path.join("src", name, `${name}.service.ts`),
524
+ content: `import { Injectable } from '@nestjs/common';
525
+
526
+ @Injectable()
527
+ export class ${classBase}Service {
528
+ async execute(): Promise<string> {
529
+ return '${toCamelCase(name)}';
530
+ }
531
+ }
532
+ `
533
+ }
534
+ ],
535
+ module: [
536
+ {
537
+ relativePath: path.join("src", name, `${name}.module.ts`),
538
+ content: `import { Module } from '@nestjs/common';
539
+
540
+ @Module({})
541
+ export class ${classBase}Module {}
542
+ `
543
+ }
544
+ ],
545
+ entity: [
546
+ {
547
+ relativePath: path.join("src", name, `${name}.entity.ts`),
548
+ content: `export interface ${classBase}Entity {
549
+ id: string;
550
+ createdAt: Date;
551
+ updatedAt: Date;
552
+ }
553
+ `
554
+ }
555
+ ],
556
+ guard: [
557
+ {
558
+ relativePath: path.join("src", name, `${name}.guard.ts`),
559
+ content: `import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
560
+
561
+ @Injectable()
562
+ export class ${classBase}Guard implements CanActivate {
563
+ canActivate(_context: ExecutionContext): boolean {
564
+ return true;
565
+ }
566
+ }
567
+ `
568
+ }
569
+ ]
570
+ };
571
+ fs.mkdirSync(srcRoot, {
572
+ recursive: true
573
+ });
574
+ return writeGeneratedFiles(options.targetRoot, filesByType[options.type], Boolean(options.force));
575
+ }
576
+ _chunkXE4OXN2Wjs.__name.call(void 0, scaffoldGenerator, "scaffoldGenerator");
577
+ function isScaffoldGenerator(type) {
578
+ return [
579
+ "rpc",
580
+ "service",
581
+ "module",
582
+ "entity",
583
+ "guard",
584
+ "config"
585
+ ].includes(type);
586
+ }
587
+ _chunkXE4OXN2Wjs.__name.call(void 0, isScaffoldGenerator, "isScaffoldGenerator");
588
+ function rpcServiceFiles(serviceName, classBase) {
589
+ return [
590
+ {
591
+ relativePath: path.join("src", serviceName, `${serviceName}.service.ts`),
592
+ content: `import { Injectable } from '@nestjs/common';
593
+ import { RpcMethod, RpcService } from 'wexts/nest';
594
+
595
+ @Injectable()
596
+ @RpcService({ name: '${toCamelCase(serviceName)}', requireAuth: false })
597
+ export class ${classBase}Service {
598
+ @RpcMethod()
599
+ async sayHello(name: string): Promise<string> {
600
+ return \`Hello, \${name}!\`;
601
+ }
602
+ }
603
+ `
604
+ }
605
+ ];
606
+ }
607
+ _chunkXE4OXN2Wjs.__name.call(void 0, rpcServiceFiles, "rpcServiceFiles");
608
+ function writeGeneratedFiles(root, files, force) {
609
+ const changedFiles = [];
610
+ for (const file of files) {
611
+ const absolutePath = path.join(root, file.relativePath);
612
+ if (fs.existsSync(absolutePath) && !force) {
613
+ throw new (0, _chunkAVMQJWYDjs.WextsError)({
614
+ code: "WEXTS_CLI_GENERATOR_FILE_EXISTS",
615
+ message: `Refusing to overwrite existing file: ${absolutePath}`,
616
+ suggestedFix: "Review the file, then rerun with --force if overwriting is intentional.",
617
+ docsSlug: "cli"
618
+ });
619
+ }
620
+ fs.mkdirSync(path.dirname(absolutePath), {
621
+ recursive: true
622
+ });
623
+ fs.writeFileSync(absolutePath, file.content);
624
+ changedFiles.push(absolutePath);
625
+ }
626
+ return changedFiles;
627
+ }
628
+ _chunkXE4OXN2Wjs.__name.call(void 0, writeGeneratedFiles, "writeGeneratedFiles");
629
+ function runScript(script, options) {
630
+ const cwd = _nullishCoalesce(options.cwd, () => ( process.cwd()));
631
+ const packageManager = detectPackageManager(cwd);
632
+ const args = packageManager === "npm" ? [
633
+ "run",
634
+ script
635
+ ] : [
636
+ "run",
637
+ script
638
+ ];
639
+ runCommand(packageManager, args, cwd);
640
+ }
641
+ _chunkXE4OXN2Wjs.__name.call(void 0, runScript, "runScript");
642
+ function runCommand(command, args, cwd) {
643
+ const result = _child_process.spawnSync.call(void 0, command, args, {
644
+ cwd,
645
+ stdio: "inherit",
646
+ shell: process.platform === "win32"
647
+ });
648
+ if (result.status !== 0) {
649
+ throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}`);
650
+ }
651
+ }
652
+ _chunkXE4OXN2Wjs.__name.call(void 0, runCommand, "runCommand");
653
+ function detectPackageManager(cwd) {
654
+ const packageJsonPath = path.join(cwd, "package.json");
655
+ if (fs.existsSync(packageJsonPath)) {
656
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
657
+ if (_optionalChain([pkg, 'access', _4 => _4.packageManager, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("pnpm@")])) return "pnpm";
658
+ }
659
+ if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
660
+ if (fs.existsSync(path.join(cwd, "pnpm-workspace.yaml"))) return "pnpm";
661
+ return "npm";
662
+ }
663
+ _chunkXE4OXN2Wjs.__name.call(void 0, detectPackageManager, "detectPackageManager");
664
+ function findTemplatePath() {
665
+ const candidates = [
666
+ path.resolve(__dirname, "../../templates"),
667
+ path.resolve(__dirname, "../templates"),
668
+ path.resolve(process.cwd(), "packages/templates")
669
+ ];
670
+ return candidates.find((candidate) => fs.existsSync(candidate));
671
+ }
672
+ _chunkXE4OXN2Wjs.__name.call(void 0, findTemplatePath, "findTemplatePath");
673
+ function readPackageVersion() {
674
+ const packageJsonPath = path.resolve(__dirname, "../../package.json");
675
+ if (!fs.existsSync(packageJsonPath)) return "0.0.0";
676
+ return JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version;
677
+ }
678
+ _chunkXE4OXN2Wjs.__name.call(void 0, readPackageVersion, "readPackageVersion");
679
+ function readAllText(cwd, dirs) {
680
+ let text = "";
681
+ for (const dir of dirs) {
682
+ const absolute = path.join(cwd, dir);
683
+ if (!fs.existsSync(absolute)) continue;
684
+ for (const file of walk(absolute)) {
685
+ if (file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".js")) {
686
+ text += fs.readFileSync(file, "utf8");
687
+ }
688
+ }
689
+ }
690
+ return text;
691
+ }
692
+ _chunkXE4OXN2Wjs.__name.call(void 0, readAllText, "readAllText");
693
+ function walk(dir) {
694
+ return fs.readdirSync(dir, {
695
+ withFileTypes: true
696
+ }).flatMap((entry) => {
697
+ const absolute = path.join(dir, entry.name);
698
+ if (entry.isDirectory()) return walk(absolute);
699
+ return [
700
+ absolute
701
+ ];
702
+ });
703
+ }
704
+ _chunkXE4OXN2Wjs.__name.call(void 0, walk, "walk");
705
+ function toKebabCase(value) {
706
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
707
+ }
708
+ _chunkXE4OXN2Wjs.__name.call(void 0, toKebabCase, "toKebabCase");
709
+ function toPascalCase(value) {
710
+ return toKebabCase(value).split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
711
+ }
712
+ _chunkXE4OXN2Wjs.__name.call(void 0, toPascalCase, "toPascalCase");
713
+ function toCamelCase(value) {
714
+ const pascal = toPascalCase(value);
715
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
716
+ }
717
+ _chunkXE4OXN2Wjs.__name.call(void 0, toCamelCase, "toCamelCase");
718
+ function pathToFileUrl(filePath) {
719
+ return `file://${filePath}`;
720
+ }
721
+ _chunkXE4OXN2Wjs.__name.call(void 0, pathToFileUrl, "pathToFileUrl");
722
+ async function loadRuntimeConfig(configPath) {
723
+ if (configPath.endsWith(".mjs")) {
724
+ const mod2 = await Promise.resolve().then(() => _interopRequireWildcard(require(pathToFileUrl(configPath))));
725
+ return _nullishCoalesce(mod2.default, () => ( mod2));
726
+ }
727
+ const require2 = _module.createRequire.call(void 0, __filename);
728
+ const mod = require2(configPath);
729
+ return _nullishCoalesce(mod.default, () => ( mod));
730
+ }
731
+ _chunkXE4OXN2Wjs.__name.call(void 0, loadRuntimeConfig, "loadRuntimeConfig");
732
+ 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`));
733
+ if (invokedAsCli && !process.env.VITEST) {
734
+ createCliProgram().parseAsync(process.argv).catch((error) => {
735
+ _chunkWCKSKU3Cjs.logger.error(_chunkAVMQJWYDjs.formatWextsError.call(void 0, error));
736
+ process.exit(1);
737
+ });
738
+ }
739
+
740
+
741
+
742
+
743
+
744
+ exports.createCliProgram = createCliProgram; exports.createProject = createProject; exports.runDoctor = runDoctor; exports.scaffoldGenerator = scaffoldGenerator;
745
+ //# sourceMappingURL=index.js.map