better-ts-stack 2.1.1 → 2.2.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 (174) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +16 -8
  3. package/dist/args.js +7 -0
  4. package/dist/builder/buildPlanner.js +7 -1
  5. package/dist/builder/configGenerator.js +28 -3
  6. package/dist/builder/index.js +2 -1
  7. package/dist/builder/moduleSelector.js +6 -1
  8. package/dist/builder/readmeGenerator.js +8 -2
  9. package/dist/builder/templateContext.js +1 -0
  10. package/dist/output/nextSteps.js +2 -4
  11. package/dist/prompts/stack.js +6 -1
  12. package/dist/types/index.js +2 -0
  13. package/dist/ui/messages.js +2 -0
  14. package/package.json +71 -71
  15. package/templates/backend/express/.prettierignore +52 -52
  16. package/templates/backend/express/.prettierrc +16 -16
  17. package/templates/backend/express/gitignore +3 -1
  18. package/templates/backend/express/src/env.ts.hbs +13 -2
  19. package/templates/backend/express/src/index.ts.hbs +31 -2
  20. package/templates/backend/express/tsconfig.eslint.json +9 -9
  21. package/templates/backend/nestjs/.prettierignore +52 -52
  22. package/templates/backend/nestjs/gitignore +3 -1
  23. package/templates/backend/nestjs/src/app.module.ts.hbs +4 -1
  24. package/templates/backend/nestjs/src/env.ts.hbs +13 -2
  25. package/templates/backend/nestjs/src/health/health.controller.ts.hbs +7 -0
  26. package/templates/backend/nestjs/src/{main.ts → main.ts.hbs} +11 -0
  27. package/templates/backend/nestjs/tsconfig.eslint.json +9 -9
  28. package/templates/frontend/nextjs/app/globals.css +129 -89
  29. package/templates/frontend/nextjs/app/layout.tsx +36 -34
  30. package/templates/frontend/nextjs/app/page.tsx.hbs +63 -43
  31. package/templates/frontend/nextjs/components/ui/alert.tsx +75 -0
  32. package/templates/frontend/nextjs/components/ui/badge.tsx +51 -0
  33. package/templates/frontend/nextjs/components/ui/button.tsx +57 -51
  34. package/templates/frontend/nextjs/components/ui/card.tsx +102 -60
  35. package/templates/frontend/nextjs/components/ui/field.tsx +238 -67
  36. package/templates/frontend/nextjs/components/ui/input.tsx +19 -18
  37. package/templates/frontend/nextjs/components/ui/label.tsx +19 -0
  38. package/templates/frontend/nextjs/components/ui/separator.tsx +24 -0
  39. package/templates/frontend/nextjs/components/ui/skeleton.tsx +13 -0
  40. package/templates/frontend/nextjs/components/ui/spinner.tsx +10 -0
  41. package/templates/frontend/nextjs/components.json +11 -5
  42. package/templates/frontend/nextjs/config.json +36 -35
  43. package/templates/frontend/nextjs/eslint.config.mjs +11 -11
  44. package/templates/frontend/nextjs/lib/utils.ts +1 -6
  45. package/templates/frontend/nextjs/next.config.ts.hbs +12 -12
  46. package/templates/frontend/nextjs/postcss.config.mjs +7 -7
  47. package/templates/frontend/nextjs/public/file.svg +1 -1
  48. package/templates/frontend/nextjs/public/globe.svg +1 -1
  49. package/templates/frontend/nextjs/public/window.svg +1 -1
  50. package/templates/frontend/tanstack/components.json +25 -18
  51. package/templates/frontend/tanstack/config.json +5 -2
  52. package/templates/frontend/tanstack/eslint.config.mjs +23 -23
  53. package/templates/frontend/tanstack/gitignore +39 -39
  54. package/templates/frontend/tanstack/public/favicon.svg +7 -7
  55. package/templates/frontend/tanstack/src/components/ui/alert.tsx +75 -0
  56. package/templates/frontend/tanstack/src/components/ui/badge.tsx +51 -0
  57. package/templates/frontend/tanstack/src/components/ui/button.tsx +57 -51
  58. package/templates/frontend/tanstack/src/components/ui/card.tsx +102 -60
  59. package/templates/frontend/tanstack/src/components/ui/field.tsx +236 -67
  60. package/templates/frontend/tanstack/src/components/ui/input.tsx +19 -18
  61. package/templates/frontend/tanstack/src/components/ui/label.tsx +17 -0
  62. package/templates/frontend/tanstack/src/components/ui/separator.tsx +24 -0
  63. package/templates/frontend/tanstack/src/components/ui/skeleton.tsx +13 -0
  64. package/templates/frontend/tanstack/src/components/ui/spinner.tsx +10 -0
  65. package/templates/frontend/tanstack/src/lib/utils.ts +1 -6
  66. package/templates/frontend/tanstack/src/router.tsx +31 -31
  67. package/templates/frontend/tanstack/src/routes/__root.tsx +69 -69
  68. package/templates/frontend/tanstack/src/routes/index.tsx.hbs +64 -45
  69. package/templates/frontend/tanstack/src/styles/app.css +100 -55
  70. package/templates/frontend/tanstack/tsconfig.json +22 -22
  71. package/templates/modules/agents/AGENTS.md.hbs +245 -0
  72. package/templates/modules/agents/CLAUDE.md +1 -0
  73. package/templates/modules/agents/config.json +10 -0
  74. package/templates/modules/auth/express/config.json +12 -11
  75. package/templates/modules/auth/express/src/lib/auth.ts.hbs +143 -0
  76. package/templates/modules/auth/express/src/lib/email.ts +37 -0
  77. package/templates/modules/auth/express/src/middleware/requireAuth.ts +29 -0
  78. package/templates/modules/auth/express/src/routes/me.ts +13 -0
  79. package/templates/modules/auth/nestjs/config.json +13 -11
  80. package/templates/modules/auth/nestjs/src/auth/auth.module.ts.hbs +64 -14
  81. package/templates/modules/auth/nestjs/src/auth/auth.ts.hbs +152 -0
  82. package/templates/modules/auth/nestjs/src/auth/email.ts +37 -0
  83. package/templates/modules/auth/nestjs/src/me/me.controller.ts +15 -0
  84. package/templates/modules/auth/nextjs/app/api/auth/[...all]/route.ts +4 -4
  85. package/templates/modules/auth/nextjs/app/dashboard/page.tsx +101 -45
  86. package/templates/modules/auth/nextjs/app/forgot-password/page.tsx +11 -0
  87. package/templates/modules/auth/nextjs/app/reset-password/page.tsx +17 -0
  88. package/templates/modules/auth/nextjs/app/sign-in/page.tsx +23 -17
  89. package/templates/modules/auth/nextjs/app/sign-up/page.tsx +25 -19
  90. package/templates/modules/auth/nextjs/components/auth/change-password-form.tsx +125 -0
  91. package/templates/modules/auth/nextjs/components/auth/email-verification-card.tsx +91 -0
  92. package/templates/modules/auth/nextjs/components/auth/forgot-password-form.tsx +133 -0
  93. package/templates/modules/auth/nextjs/components/auth/reset-password-form.tsx +155 -0
  94. package/templates/modules/auth/nextjs/components/auth/sign-in-form.tsx +46 -32
  95. package/templates/modules/auth/nextjs/components/auth/sign-out-button.tsx +6 -5
  96. package/templates/modules/auth/nextjs/components/auth/sign-up-form.tsx +36 -30
  97. package/templates/modules/auth/nextjs/components/auth/social-buttons.tsx +73 -0
  98. package/templates/modules/auth/nextjs/config.json +24 -18
  99. package/templates/modules/auth/nextjs/lib/auth-client.ts +3 -3
  100. package/templates/modules/auth/nextjs/lib/auth-schema.ts +27 -2
  101. package/templates/modules/auth/nextjs/lib/auth.ts.hbs +65 -0
  102. package/templates/modules/auth/nextjs/lib/email.ts +43 -0
  103. package/templates/modules/auth/nextjs/lib/session.ts +12 -0
  104. package/templates/modules/auth/tanstack/config.json +25 -19
  105. package/templates/modules/auth/tanstack/src/components/auth/change-password-form.tsx +123 -0
  106. package/templates/modules/auth/tanstack/src/components/auth/email-verification-card.tsx +89 -0
  107. package/templates/modules/auth/tanstack/src/components/auth/forgot-password-form.tsx +131 -0
  108. package/templates/modules/auth/tanstack/src/components/auth/reset-password-form.tsx +149 -0
  109. package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +44 -35
  110. package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +7 -6
  111. package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +37 -34
  112. package/templates/modules/auth/tanstack/src/components/auth/social-buttons.tsx +71 -0
  113. package/templates/modules/auth/tanstack/src/lib/auth-client.ts +2 -2
  114. package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +14 -8
  115. package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +27 -2
  116. package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +98 -38
  117. package/templates/modules/auth/tanstack/src/lib/email.ts +43 -0
  118. package/templates/modules/auth/tanstack/src/routeTree.gen.ts +61 -3
  119. package/templates/modules/auth/tanstack/src/routes/api/auth/$.ts +15 -15
  120. package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +119 -111
  121. package/templates/modules/auth/tanstack/src/routes/forgot-password.tsx +17 -0
  122. package/templates/modules/auth/tanstack/src/routes/reset-password.tsx +25 -0
  123. package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +44 -37
  124. package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +44 -37
  125. package/templates/modules/docker/.dockerignore +2 -0
  126. package/templates/modules/docker/config.json +15 -15
  127. package/templates/modules/drizzle/express/config.json +26 -26
  128. package/templates/modules/drizzle/express/src/lib/schema.ts.hbs +90 -0
  129. package/templates/modules/drizzle/nestjs/config.json +26 -26
  130. package/templates/modules/drizzle/nestjs/src/database/schema.ts.hbs +90 -0
  131. package/templates/modules/drizzle/nextjs/config.json +26 -26
  132. package/templates/modules/drizzle/nextjs/drizzle.config.ts +13 -13
  133. package/templates/modules/drizzle/tanstack/config.json +26 -26
  134. package/templates/modules/drizzle/tanstack/drizzle.config.ts +12 -12
  135. package/templates/modules/drizzle/tanstack/src/lib/db.ts +13 -13
  136. package/templates/modules/mongoose/express/config.json +15 -15
  137. package/templates/modules/mongoose/express/src/lib/db.ts +43 -43
  138. package/templates/modules/mongoose/express/src/models/User.ts +48 -48
  139. package/templates/modules/mongoose/nestjs/config.json +16 -15
  140. package/templates/modules/mongoose/nextjs/config.json +15 -15
  141. package/templates/modules/mongoose/nextjs/models/User.ts +48 -48
  142. package/templates/modules/mongoose/tanstack/config.json +16 -16
  143. package/templates/modules/mongoose/tanstack/src/models/User.ts +48 -48
  144. package/templates/modules/prisma/express/config.json +27 -27
  145. package/templates/modules/prisma/express/prisma/schema.prisma.hbs +92 -0
  146. package/templates/modules/prisma/nestjs/config.json +27 -27
  147. package/templates/modules/prisma/nestjs/prisma/schema.prisma.hbs +91 -0
  148. package/templates/modules/prisma/nextjs/config.json +28 -28
  149. package/templates/modules/prisma/nextjs/lib/prisma.ts +18 -18
  150. package/templates/modules/prisma/nextjs/prisma.config.ts +14 -14
  151. package/templates/modules/prisma/tanstack/config.json +28 -28
  152. package/templates/modules/prisma/tanstack/prisma/schema.prisma.hbs +91 -91
  153. package/templates/modules/prisma/tanstack/prisma.config.ts +14 -14
  154. package/templates/modules/prisma/tanstack/src/lib/prisma.ts +17 -17
  155. package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +0 -8
  156. package/templates/modules/vscode/.vscode/extensions.json.hbs +29 -0
  157. package/templates/modules/vscode/.vscode/settings.json.hbs +22 -0
  158. package/templates/modules/vscode/config.json +10 -0
  159. package/templates/modules/auth/express/src/controllers/authController.ts.hbs +0 -116
  160. package/templates/modules/auth/express/src/lib/jwt.ts.hbs +0 -27
  161. package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +0 -25
  162. package/templates/modules/auth/express/src/routes/auth.ts.hbs +0 -27
  163. package/templates/modules/auth/express/src/services/userStore.ts.hbs +0 -117
  164. package/templates/modules/auth/nestjs/src/auth/auth.controller.ts.hbs +0 -61
  165. package/templates/modules/auth/nestjs/src/auth/auth.guard.ts +0 -36
  166. package/templates/modules/auth/nestjs/src/auth/auth.schemas.ts +0 -35
  167. package/templates/modules/auth/nestjs/src/auth/auth.service.ts +0 -70
  168. package/templates/modules/auth/nestjs/src/auth/jwt.ts +0 -27
  169. package/templates/modules/auth/nestjs/src/auth/users.service.ts.hbs +0 -144
  170. package/templates/modules/auth/nestjs/src/auth/zod-validation.pipe.ts +0 -16
  171. package/templates/modules/drizzle/express/src/lib/schema.ts +0 -12
  172. package/templates/modules/drizzle/nestjs/src/database/schema.ts +0 -12
  173. package/templates/modules/prisma/express/prisma/schema.prisma +0 -24
  174. package/templates/modules/prisma/nestjs/prisma/schema.prisma +0 -23
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Abdullah
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abdullah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -37,6 +37,9 @@ npx better-ts-stack . --framework nextjs --database drizzle --pm pnpm
37
37
  | `--auth` / `--no-auth` | Add authentication |
38
38
  | `--docker` / `--no-docker` | Add Docker files |
39
39
  | `--rate-limit` / `--no-rate-limit` | Add rate limiting (Express and NestJS) |
40
+ | `--ci` / `--no-ci` | Add a GitHub Actions workflow |
41
+ | `--no-agents` | Leave out AGENTS.md (added by default) |
42
+ | `--vscode` / `--no-vscode` | Add VS Code settings and extensions |
40
43
  | `--git` / `--no-git` | Initialize a git repository |
41
44
  | `--install` / `--no-install` | Install dependencies |
42
45
  | `-y`, `--yes` | Use defaults for missing options, no prompts |
@@ -46,7 +49,7 @@ npx better-ts-stack . --framework nextjs --database drizzle --pm pnpm
46
49
 
47
50
  `--database` names the ORM, which also selects the database: `prisma` and `drizzle` use PostgreSQL, `mongoose` uses MongoDB.
48
51
 
49
- With `--yes`, the defaults are Express, no database, no auth, no rate limiting, no Docker, git initialized, and dependencies not installed. The package manager defaults to the one that ran the CLI: `pnpm` for `pnpm dlx`, `bun` for `bunx`, and `npm` otherwise.
52
+ With `--yes`, the defaults are Express, no database, no auth, no rate limiting, no Docker, no CI, no VS Code settings, an `AGENTS.md`, git initialized, and dependencies not installed. The package manager defaults to the one that ran the CLI: `pnpm` for `pnpm dlx`, `bun` for `bunx`, and `npm` otherwise.
50
53
 
51
54
  The project path can be a name (`my-app`), a nested path (`apps/api`), or `.` for the current directory.
52
55
 
@@ -54,12 +57,12 @@ The project path can be a name (`my-app`), a nested path (`apps/api`), or `.` fo
54
57
 
55
58
  | Project type | Stack | Optional setup |
56
59
  | -------------- | --------------------------------------- | ------------------------------------------------------------------------ |
57
- | Backend API | Express 5 or NestJS 12 + TypeScript | PostgreSQL, MongoDB, Prisma, Drizzle, Mongoose, JWT auth, Docker, git |
60
+ | Backend API | Express 5 or NestJS 12 + TypeScript | PostgreSQL, MongoDB, Prisma, Drizzle, Mongoose, Better Auth, Docker, git |
58
61
  | Full-stack app | Next.js 16 or TanStack Start + React 19 | PostgreSQL, MongoDB, Prisma, Drizzle, Mongoose, Better Auth, Docker, git |
59
62
 
60
63
  Notes:
61
64
 
62
- - Better Auth is only offered for full-stack projects that use a database.
65
+ - Better Auth is offered for every framework; full-stack projects need a database for it.
63
66
 
64
67
  ## Interactive Prompt Flow
65
68
 
@@ -77,10 +80,15 @@ Without flags, the CLI asks, in order:
77
80
  6. Package manager: `npm`, `pnpm`, or `bun`
78
81
  7. Docker setup
79
82
  8. Authentication
80
- - Express and NestJS apps: JWT-based auth
81
- - Next.js and TanStack Start apps: Better Auth, only when a database is selected
82
- 9. Git initialization
83
- 10. Dependency installation
83
+ - Better Auth for every framework
84
+ - Next.js and TanStack Start apps: only when a database is selected
85
+ 9. Rate limiting (Express and NestJS)
86
+ 10. GitHub Actions CI
87
+ 11. VS Code settings
88
+ 12. Git initialization
89
+ 13. Dependency installation
90
+
91
+ `AGENTS.md` and `CLAUDE.md` are added without a question; pass `--no-agents` to leave them out.
84
92
 
85
93
  The CLI does not ask for a port. Backend projects default to `PORT=3000`.
86
94
 
@@ -93,7 +101,7 @@ Every generated project includes:
93
101
  - `.env.example` and `.env` setup
94
102
  - Ready-to-run project scripts
95
103
  - Health check endpoint at `/health` for backend projects
96
- - shadcn-compatible UI components for Next.js and TanStack Start projects
104
+ - shadcn/ui components built on Base UI for Next.js and TanStack Start projects
97
105
  - Database wiring and schema setup when selected
98
106
  - Authentication scaffolding when selected
99
107
  - Docker files when selected
package/dist/args.js CHANGED
@@ -23,6 +23,9 @@ Options left out are asked interactively, unless --yes is given.
23
23
  --rate-limit, --no-rate-limit
24
24
  Add rate limiting (Express and NestJS)
25
25
  --ci, --no-ci Add a GitHub Actions workflow
26
+ --no-agents Leave out AGENTS.md for AI coding agents (added by
27
+ default)
28
+ --vscode, --no-vscode Add VS Code settings and recommended extensions
26
29
  --git, --no-git Initialize a git repository
27
30
  --install, --no-install Install dependencies
28
31
  -y, --yes Use defaults for missing options and skip confirmation
@@ -58,6 +61,8 @@ function parseCliArgs(argv) {
58
61
  docker: { type: "boolean" },
59
62
  "rate-limit": { type: "boolean" },
60
63
  ci: { type: "boolean" },
64
+ agents: { type: "boolean" },
65
+ vscode: { type: "boolean" },
61
66
  git: { type: "boolean" },
62
67
  install: { type: "boolean" },
63
68
  yes: { type: "boolean", short: "y" },
@@ -82,6 +87,8 @@ function parseCliArgs(argv) {
82
87
  useDocker: values.docker,
83
88
  useRateLimit: values["rate-limit"],
84
89
  useCi: values.ci,
90
+ useAgents: values.agents,
91
+ useVscode: values.vscode,
85
92
  initGit: values.git,
86
93
  installDeps: values.install,
87
94
  };
@@ -15,7 +15,13 @@ const gitInitializer_1 = require("./gitInitializer");
15
15
  const moduleSelector_1 = require("./moduleSelector");
16
16
  const templateContext_1 = require("./templateContext");
17
17
  // Files the builder writes itself instead of copying them from a module
18
- const GENERATED_FILES = ["package.json", ".env", ".env.example", "README.md"];
18
+ const GENERATED_FILES = [
19
+ "package.json",
20
+ ".env",
21
+ ".env.example",
22
+ "README.md",
23
+ configGenerator_1.STACK_FILE,
24
+ ];
19
25
  // Loads the selected modules and merges their configurations
20
26
  async function loadBuildInputs(config) {
21
27
  const selection = (0, moduleSelector_1.selectModules)(config);
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GENERATED_SECRETS = void 0;
6
+ exports.STACK_FILE = exports.GENERATED_SECRETS = void 0;
7
7
  exports.processScriptVariables = processScriptVariables;
8
8
  exports.mergeConfigurations = mergeConfigurations;
9
9
  exports.generatePackageJson = generatePackageJson;
10
10
  exports.generatePnpmWorkspace = generatePnpmWorkspace;
11
+ exports.generateStackFile = generateStackFile;
11
12
  exports.generateEnvFile = generateEnvFile;
12
13
  // Utilities for merging module configurations and generating project files
13
14
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -96,7 +97,6 @@ async function generatePackageJson(targetDir, mergedConfig, config) {
96
97
  // these are not approved; entries for packages a project lacks are ignored.
97
98
  const PNPM_BUILD_DEPENDENCIES = [
98
99
  "@prisma/engines",
99
- "bcrypt",
100
100
  "esbuild",
101
101
  "prisma",
102
102
  "unrs-resolver",
@@ -128,7 +128,32 @@ async function generatePnpmWorkspace(targetDir, overrides) {
128
128
  }
129
129
  }
130
130
  // Variables that get a random value in .env instead of the module's default
131
- exports.GENERATED_SECRETS = ["JWT_SECRET", "BETTER_AUTH_SECRET"];
131
+ exports.GENERATED_SECRETS = ["BETTER_AUTH_SECRET"];
132
+ // Name of the file that records how a project was generated
133
+ exports.STACK_FILE = "better-ts-stack.json";
134
+ // Records the stack choices, so later commands (such as adding a module to the
135
+ // project) know what the project was generated with
136
+ async function generateStackFile(targetDir, config) {
137
+ try {
138
+ const { version } = (await fs_extra_1.default.readJson(node_path_1.default.join(__dirname, "../../package.json")));
139
+ const stack = {
140
+ cliVersion: version,
141
+ framework: config.framework,
142
+ database: config.database,
143
+ packageManager: config.packageManager,
144
+ auth: config.useAuth,
145
+ docker: config.useDocker,
146
+ rateLimit: config.useRateLimit,
147
+ ci: config.useCi,
148
+ agents: config.useAgents,
149
+ vscode: config.useVscode,
150
+ };
151
+ await fs_extra_1.default.writeFile(node_path_1.default.join(targetDir, exports.STACK_FILE), JSON.stringify(stack, null, 2) + "\n", "utf-8");
152
+ }
153
+ catch (error) {
154
+ throw (0, types_1.buildError)(error, "STACK_FILE_ERROR", `Failed to write ${exports.STACK_FILE}`);
155
+ }
156
+ }
132
157
  // Generates .env and .env.example files from merged environment variables
133
158
  async function generateEnvFile(targetDir, envVars) {
134
159
  try {
@@ -52,9 +52,10 @@ async function build(config, targetDir) {
52
52
  if (config.packageManager === "pnpm") {
53
53
  await (0, configGenerator_1.generatePnpmWorkspace)(targetDir, mergedConfig.overrides);
54
54
  }
55
- // 7. Generate environment files and the README
55
+ // 7. Generate environment files, the README, and the stack file
56
56
  await (0, configGenerator_1.generateEnvFile)(targetDir, mergedConfig.envVars);
57
57
  await (0, readmeGenerator_1.generateReadme)(targetDir, config, mergedConfig);
58
+ await (0, configGenerator_1.generateStackFile)(targetDir, config);
58
59
  // 8. Install dependencies and initialize git (both optional); a failure
59
60
  // in either is reported as a warning and does not fail the build
60
61
  const depsInstalled = config.installDeps &&
@@ -10,7 +10,8 @@ function selectModules(config) {
10
10
  : `frontend/${framework}`;
11
11
  const modules = [];
12
12
  // Database, auth, and rate-limit modules have one variant per framework
13
- // (prisma/express, auth/nextjs, ...); the Docker and CI modules are shared
13
+ // (prisma/express, auth/nextjs, ...); the Docker, CI, and agents modules are
14
+ // shared
14
15
  if (config.database !== "none")
15
16
  modules.push(`${config.database}/${framework}`);
16
17
  if (config.useDocker)
@@ -21,5 +22,9 @@ function selectModules(config) {
21
22
  modules.push(`rate-limit/${framework}`);
22
23
  if (config.useCi)
23
24
  modules.push("ci");
25
+ if (config.useAgents)
26
+ modules.push("agents");
27
+ if (config.useVscode)
28
+ modules.push("vscode");
24
29
  return { base, modules };
25
30
  }
@@ -49,8 +49,8 @@ function renderReadme(config, mergedConfig, targetDir) {
49
49
  }
50
50
  if (config.useAuth) {
51
51
  lines.push(isFullstack
52
- ? "- **Auth:** Better Auth with email and password"
53
- : "- **Auth:** JWT with `/auth/register`, `/auth/login`, and `/auth/me`");
52
+ ? "- **Auth:** Better Auth with email and password, email verification, password reset, and GitHub and Google sign-in"
53
+ : "- **Auth:** Better Auth on `/api/auth` with email and password, email verification, password reset, GitHub and Google sign-in, and bearer tokens; `GET /api/me` is a protected example");
54
54
  }
55
55
  if (config.useRateLimit) {
56
56
  lines.push(`- **Rate limiting:** 100 requests per client IP in 15 minutes${config.useAuth ? ", and 10 sign-up or login attempts" : ""}`);
@@ -60,6 +60,12 @@ function renderReadme(config, mergedConfig, targetDir) {
60
60
  if (config.useCi) {
61
61
  lines.push("- **CI:** GitHub Actions builds, type-checks, and lints every push to `main` and every pull request");
62
62
  }
63
+ if (config.useVscode) {
64
+ lines.push("- **VS Code:** workspace settings and recommended extensions in `.vscode/`");
65
+ }
66
+ if (config.useAgents) {
67
+ lines.push("- **AI agents:** `AGENTS.md` describes the stack, commands, and rules for coding agents");
68
+ }
63
69
  lines.push(`- **Package manager:** ${config.packageManager}`, "");
64
70
  const steps = (0, nextSteps_1.generateNextSteps)(config, targetDir, false, true);
65
71
  lines.push("## Getting started", "", ...steps.map((step, index) => {
@@ -63,6 +63,7 @@ function buildTemplateContext(config) {
63
63
  useDocker: config.useDocker,
64
64
  useAuth: config.useAuth,
65
65
  useRateLimit: config.useRateLimit,
66
+ useCi: config.useCi,
66
67
  docker: DOCKER_COMMANDS[config.packageManager],
67
68
  ciBuildEnv: getCiBuildEnv(config),
68
69
  helpers: {
@@ -24,9 +24,7 @@ function generateNextSteps(config, targetDir, depsInstalled, isForReadme = false
24
24
  steps.push("Review the generated .env and set your database connection details");
25
25
  }
26
26
  if (config.useAuth) {
27
- steps.push(isFullstack
28
- ? "Review BETTER_AUTH_SECRET and BETTER_AUTH_URL in .env"
29
- : "Review the generated JWT_SECRET in .env");
27
+ steps.push("Review BETTER_AUTH_URL in .env, and add GitHub, Google, or Resend keys when you need them");
30
28
  }
31
29
  // Step 3: Install dependencies if not already done
32
30
  if (!depsInstalled) {
@@ -66,7 +64,7 @@ function generateNextSteps(config, targetDir, depsInstalled, isForReadme = false
66
64
  if (config.useAuth) {
67
65
  steps.push(isFullstack
68
66
  ? "Visit /sign-up to create your first account"
69
- : "Create a user via POST /auth/register then login with /auth/login");
67
+ : "Create a user with POST /api/auth/sign-up/email, then call GET /api/me with the set-auth-token header as a bearer token");
70
68
  }
71
69
  if (config.useDocker) {
72
70
  steps.push(`To run the app in Docker instead: ${config.packageManager} run docker:up`);
@@ -84,7 +84,7 @@ async function collectStackChoices(preset) {
84
84
  }
85
85
  const useAuth = isAuthAvailable
86
86
  ? await ask(preset.useAuth, () => (0, ui_1.confirm)({
87
- message: isFullstack ? "Add Better Auth?" : "Add JWT authentication?",
87
+ message: "Add authentication (Better Auth)?",
88
88
  initialValue: false,
89
89
  }))
90
90
  : false;
@@ -96,6 +96,9 @@ async function collectStackChoices(preset) {
96
96
  ? false
97
97
  : await ask(preset.useRateLimit, () => (0, ui_1.confirm)({ message: "Add rate limiting?", initialValue: false }));
98
98
  const useCi = await ask(preset.useCi, () => (0, ui_1.confirm)({ message: "Add GitHub Actions CI?", initialValue: false }));
99
+ // AGENTS.md is always added without asking; --no-agents leaves it out
100
+ const useAgents = preset.useAgents ?? true;
101
+ const useVscode = await ask(preset.useVscode, () => (0, ui_1.confirm)({ message: "Add VS Code settings?", initialValue: false }));
99
102
  const initGit = await ask(preset.initGit, () => (0, ui_1.confirm)({ message: "Initialize a git repository?", initialValue: true }));
100
103
  const installDeps = await ask(preset.installDeps, () => (0, ui_1.confirm)({ message: "Install dependencies now?", initialValue: false }));
101
104
  return {
@@ -106,6 +109,8 @@ async function collectStackChoices(preset) {
106
109
  useAuth,
107
110
  useRateLimit,
108
111
  useCi,
112
+ useAgents,
113
+ useVscode,
109
114
  initGit,
110
115
  installDeps,
111
116
  };
@@ -13,6 +13,8 @@ exports.DEFAULT_CHOICES = {
13
13
  useAuth: false,
14
14
  useRateLimit: false,
15
15
  useCi: false,
16
+ useAgents: true,
17
+ useVscode: false,
16
18
  packageManager: "npm",
17
19
  initGit: true,
18
20
  installDeps: false,
@@ -76,6 +76,8 @@ function showSummary(config, targetDir) {
76
76
  config.useRateLimit && "rate limit",
77
77
  config.useDocker && "docker",
78
78
  config.useCi && "ci",
79
+ config.useAgents && "agents",
80
+ config.useVscode && "vscode",
79
81
  ];
80
82
  const setup = [
81
83
  config.packageManager,
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
- {
2
- "name": "better-ts-stack",
3
- "version": "2.1.1",
4
- "description": "A CLI that scaffolds Express, NestJS, Next.js, and TanStack Start projects with a database, authentication, and Docker already set up.",
5
- "keywords": [
6
- "cli",
7
- "builder",
8
- "backend",
9
- "typescript",
10
- "express",
11
- "nestjs",
12
- "nextjs",
13
- "tanstack-start",
14
- "prisma",
15
- "drizzle",
16
- "mongoose",
17
- "template"
18
- ],
19
- "homepage": "https://better-ts-stack.abdullahtech.me",
20
- "bugs": {
21
- "url": "https://github.com/Abdullah-dev0/better-ts-stack/issues"
22
- },
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/Abdullah-dev0/better-ts-stack.git"
26
- },
27
- "license": "MIT",
28
- "author": "Abdullah",
29
- "type": "commonjs",
30
- "main": "dist/index.js",
31
- "bin": {
32
- "better-ts-stack": "dist/index.js"
33
- },
34
- "files": [
35
- "dist",
36
- "templates"
37
- ],
38
- "scripts": {
39
- "dev": "tsx src/index.ts",
40
- "prebuild": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
41
- "build": "tsc",
42
- "postbuild": "node -e \"const fs=require('fs');const p='dist/index.js';fs.writeFileSync(p,'#!/usr/bin/env node\\n'+fs.readFileSync(p,'utf8'))\"",
43
- "prepack": "npm run build",
44
- "start": "node dist/index.js",
45
- "lint": "eslint src",
46
- "lint:fix": "eslint src --fix",
47
- "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md,mdx,css}\"",
48
- "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md,mdx,css}\"",
49
- "type:check": "tsc --noEmit"
50
- },
51
- "dependencies": {
52
- "@clack/core": "^1.4.3",
53
- "fs-extra": "^11.4.0",
54
- "handlebars": "^4.7.10",
55
- "zod": "^4.6.7"
56
- },
57
- "devDependencies": {
58
- "@better-ts-stack/eslint-config": "*",
59
- "@better-ts-stack/prettier-config": "*",
60
- "@types/fs-extra": "^11.0.4",
61
- "@types/node": "^24.13.3",
62
- "eslint": "^10.10.0",
63
- "prettier": "^3.9.6",
64
- "tsx": "^4.23.13",
65
- "typescript": "^6.0.3"
66
- },
67
- "engines": {
68
- "node": ">=24.0.0"
69
- },
70
- "prettier": "@better-ts-stack/prettier-config"
71
- }
1
+ {
2
+ "name": "better-ts-stack",
3
+ "version": "2.2.0",
4
+ "description": "A CLI that scaffolds Express, NestJS, Next.js, and TanStack Start projects with a database, authentication, and Docker already set up.",
5
+ "keywords": [
6
+ "cli",
7
+ "builder",
8
+ "backend",
9
+ "typescript",
10
+ "express",
11
+ "nestjs",
12
+ "nextjs",
13
+ "tanstack-start",
14
+ "prisma",
15
+ "drizzle",
16
+ "mongoose",
17
+ "template"
18
+ ],
19
+ "homepage": "https://better-ts-stack.abdullahtech.me",
20
+ "bugs": {
21
+ "url": "https://github.com/Abdullah-dev0/better-ts-stack/issues"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Abdullah-dev0/better-ts-stack.git"
26
+ },
27
+ "license": "MIT",
28
+ "author": "Abdullah",
29
+ "type": "commonjs",
30
+ "main": "dist/index.js",
31
+ "bin": {
32
+ "better-ts-stack": "dist/index.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "templates"
37
+ ],
38
+ "scripts": {
39
+ "dev": "tsx src/index.ts",
40
+ "prebuild": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
41
+ "build": "tsc",
42
+ "postbuild": "node -e \"const fs=require('fs');const p='dist/index.js';fs.writeFileSync(p,'#!/usr/bin/env node\\n'+fs.readFileSync(p,'utf8'))\"",
43
+ "prepack": "npm run build",
44
+ "start": "node dist/index.js",
45
+ "lint": "eslint src",
46
+ "lint:fix": "eslint src --fix",
47
+ "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md,mdx,css}\"",
48
+ "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md,mdx,css}\"",
49
+ "type:check": "tsc --noEmit"
50
+ },
51
+ "dependencies": {
52
+ "@clack/core": "^1.4.3",
53
+ "fs-extra": "^11.4.0",
54
+ "handlebars": "^4.7.10",
55
+ "zod": "^4.6.7"
56
+ },
57
+ "devDependencies": {
58
+ "@better-ts-stack/eslint-config": "*",
59
+ "@better-ts-stack/prettier-config": "*",
60
+ "@types/fs-extra": "^11.0.4",
61
+ "@types/node": "^24.13.3",
62
+ "eslint": "^10.10.0",
63
+ "prettier": "^3.9.6",
64
+ "tsx": "^4.23.13",
65
+ "typescript": "^6.0.3"
66
+ },
67
+ "engines": {
68
+ "node": ">=24.0.0"
69
+ },
70
+ "prettier": "@better-ts-stack/prettier-config"
71
+ }
@@ -1,52 +1,52 @@
1
- # Dependencies
2
- node_modules
3
- **/node_modules
4
-
5
- # Build outputs
6
- .next
7
- out
8
- dist
9
- build
10
- **/dist
11
- **/.next
12
- **/out
13
- **/build
14
-
15
- # Generated files
16
- *.min.js
17
- *.min.css
18
- coverage
19
- .nyc_output
20
-
21
- # Lock files
22
- package-lock.json
23
- yarn.lock
24
- pnpm-lock.yaml
25
- bun.lock
26
-
27
- # Logs
28
- *.log
29
- npm-debug.log*
30
- yarn-debug.log*
31
- yarn-error.log*
32
-
33
- # Environment files
34
- .env
35
- .env.local
36
- .env.*.local
37
-
38
- # IDE
39
- .vscode
40
- .idea
41
- *.swp
42
- *.swo
43
- *~
44
-
45
- # OS
46
- .DS_Store
47
- Thumbs.db
48
-
49
- # Templates (do not format generated/scaffold content)
50
- templates
51
- **/templates/**
52
- *.hbs
1
+ # Dependencies
2
+ node_modules
3
+ **/node_modules
4
+
5
+ # Build outputs
6
+ .next
7
+ out
8
+ dist
9
+ build
10
+ **/dist
11
+ **/.next
12
+ **/out
13
+ **/build
14
+
15
+ # Generated files
16
+ *.min.js
17
+ *.min.css
18
+ coverage
19
+ .nyc_output
20
+
21
+ # Lock files
22
+ package-lock.json
23
+ yarn.lock
24
+ pnpm-lock.yaml
25
+ bun.lock
26
+
27
+ # Logs
28
+ *.log
29
+ npm-debug.log*
30
+ yarn-debug.log*
31
+ yarn-error.log*
32
+
33
+ # Environment files
34
+ .env
35
+ .env.local
36
+ .env.*.local
37
+
38
+ # IDE
39
+ .vscode
40
+ .idea
41
+ *.swp
42
+ *.swo
43
+ *~
44
+
45
+ # OS
46
+ .DS_Store
47
+ Thumbs.db
48
+
49
+ # Templates (do not format generated/scaffold content)
50
+ templates
51
+ **/templates/**
52
+ *.hbs
@@ -1,16 +1,16 @@
1
- {
2
- "semi": true,
3
- "trailingComma": "es5",
4
- "singleQuote": false,
5
- "printWidth": 80,
6
- "tabWidth": 2,
7
- "useTabs": false,
8
- "arrowParens": "always",
9
- "endOfLine": "lf",
10
- "plugins": ["@trivago/prettier-plugin-sort-imports"],
11
- "importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
12
- "importOrderSeparation": true,
13
- "importOrderSortSpecifiers": true,
14
- "importOrderGroupNamespaceSpecifiers": true,
15
- "importOrderCaseInsensitive": true
16
- }
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": false,
5
+ "printWidth": 80,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf",
10
+ "plugins": ["@trivago/prettier-plugin-sort-imports"],
11
+ "importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
12
+ "importOrderSeparation": true,
13
+ "importOrderSortSpecifiers": true,
14
+ "importOrderGroupNamespaceSpecifiers": true,
15
+ "importOrderCaseInsensitive": true
16
+ }
@@ -18,7 +18,9 @@ yarn-debug.log*
18
18
  yarn-error.log*
19
19
 
20
20
  # IDE
21
- .vscode/
21
+ .vscode/*
22
+ !.vscode/settings.json
23
+ !.vscode/extensions.json
22
24
  .idea/
23
25
  *.swp
24
26
  *.swo