create-next-app-niena 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/bin/index.js +5 -0
  4. package/jest.config.js +7 -0
  5. package/package.json +35 -0
  6. package/src/index.js +409 -0
  7. package/template/.env +16 -0
  8. package/template/README.md +94 -0
  9. package/template/app/account/[path]/page.tsx +29 -0
  10. package/template/app/api/auth/[...all]/route.ts +4 -0
  11. package/template/app/api/trpc/[trpc]/route.ts +11 -0
  12. package/template/app/auth/[path]/page.tsx +45 -0
  13. package/template/app/favicon.ico +0 -0
  14. package/template/app/globals.css +126 -0
  15. package/template/app/layout.tsx +40 -0
  16. package/template/app/page.tsx +22 -0
  17. package/template/app/privacy/page.tsx +663 -0
  18. package/template/app/terms/page.tsx +468 -0
  19. package/template/components/ui/accordion.tsx +66 -0
  20. package/template/components/ui/alert-dialog.tsx +157 -0
  21. package/template/components/ui/alert.tsx +66 -0
  22. package/template/components/ui/aspect-ratio.tsx +11 -0
  23. package/template/components/ui/avatar.tsx +53 -0
  24. package/template/components/ui/badge.tsx +46 -0
  25. package/template/components/ui/breadcrumb.tsx +109 -0
  26. package/template/components/ui/button-group.tsx +83 -0
  27. package/template/components/ui/button.tsx +62 -0
  28. package/template/components/ui/calendar.tsx +220 -0
  29. package/template/components/ui/card.tsx +92 -0
  30. package/template/components/ui/carousel.tsx +241 -0
  31. package/template/components/ui/chart.tsx +357 -0
  32. package/template/components/ui/checkbox.tsx +32 -0
  33. package/template/components/ui/collapsible.tsx +33 -0
  34. package/template/components/ui/command.tsx +184 -0
  35. package/template/components/ui/context-menu.tsx +252 -0
  36. package/template/components/ui/dialog.tsx +143 -0
  37. package/template/components/ui/drawer.tsx +135 -0
  38. package/template/components/ui/dropdown-menu.tsx +257 -0
  39. package/template/components/ui/empty.tsx +104 -0
  40. package/template/components/ui/field.tsx +248 -0
  41. package/template/components/ui/form.tsx +167 -0
  42. package/template/components/ui/hover-card.tsx +44 -0
  43. package/template/components/ui/input-group.tsx +170 -0
  44. package/template/components/ui/input-otp.tsx +77 -0
  45. package/template/components/ui/input.tsx +21 -0
  46. package/template/components/ui/item.tsx +193 -0
  47. package/template/components/ui/kbd.tsx +28 -0
  48. package/template/components/ui/label.tsx +24 -0
  49. package/template/components/ui/menubar.tsx +276 -0
  50. package/template/components/ui/navigation-menu.tsx +168 -0
  51. package/template/components/ui/pagination.tsx +127 -0
  52. package/template/components/ui/popover.tsx +48 -0
  53. package/template/components/ui/progress.tsx +31 -0
  54. package/template/components/ui/radio-group.tsx +45 -0
  55. package/template/components/ui/resizable.tsx +56 -0
  56. package/template/components/ui/scroll-area.tsx +58 -0
  57. package/template/components/ui/select.tsx +190 -0
  58. package/template/components/ui/separator.tsx +28 -0
  59. package/template/components/ui/sheet.tsx +139 -0
  60. package/template/components/ui/sidebar.tsx +726 -0
  61. package/template/components/ui/skeleton.tsx +13 -0
  62. package/template/components/ui/slider.tsx +63 -0
  63. package/template/components/ui/sonner.tsx +40 -0
  64. package/template/components/ui/spinner.tsx +16 -0
  65. package/template/components/ui/switch.tsx +31 -0
  66. package/template/components/ui/table.tsx +116 -0
  67. package/template/components/ui/tabs.tsx +66 -0
  68. package/template/components/ui/textarea.tsx +18 -0
  69. package/template/components/ui/toggle-group.tsx +83 -0
  70. package/template/components/ui/toggle.tsx +47 -0
  71. package/template/components/ui/tooltip.tsx +61 -0
  72. package/template/components.json +22 -0
  73. package/template/lib/auth-client.ts +6 -0
  74. package/template/lib/auth.ts +24 -0
  75. package/template/lib/generated/prisma/browser.ts +20 -0
  76. package/template/lib/generated/prisma/client.ts +42 -0
  77. package/template/lib/generated/prisma/commonInputTypes.ts +18 -0
  78. package/template/lib/generated/prisma/enums.ts +15 -0
  79. package/template/lib/generated/prisma/internal/class.ts +182 -0
  80. package/template/lib/generated/prisma/internal/prismaNamespace.ts +603 -0
  81. package/template/lib/generated/prisma/internal/prismaNamespaceBrowser.ts +71 -0
  82. package/template/lib/generated/prisma/models.ts +11 -0
  83. package/template/lib/prisma.ts +10 -0
  84. package/template/lib/utils.ts +6 -0
  85. package/template/package.json +85 -0
  86. package/template/prisma/schema.prisma +77 -0
  87. package/template/prisma.config.ts +14 -0
  88. package/template/providers/better-auth-ui-provider.tsx +30 -0
  89. package/template/proxy.ts +22 -0
  90. package/template/trpc/client.tsx +57 -0
  91. package/template/trpc/init.ts +24 -0
  92. package/template/trpc/query-client.ts +23 -0
  93. package/template/trpc/routers/_app.ts +17 -0
  94. package/template/trpc/server.tsx +14 -0
  95. package/tests/cli.test.js +13 -0
  96. package/tests/logic.test.js +169 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NienaLabs
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 ADDED
@@ -0,0 +1,101 @@
1
+ # Nienalabs Starter Kit
2
+
3
+ This is a [Next.js](https://nextjs.org) starter kit designed for developers who want to use **Better Auth + Better Auth UI + Prisma + Shadcn + TRPC**. This template saves you time on authentication setup and TRPC backend configuration so you can focus on building your product without worrying about boilerplates.
4
+
5
+ ## Getting Started
6
+
7
+ Follow these steps to get your project up and running:
8
+
9
+ ### 1. Clone the repository
10
+
11
+ ```bash
12
+ git clone <your-repo-url>
13
+ cd <your-repo-name>
14
+ ```
15
+
16
+ ### 2. Install dependencies
17
+
18
+ ```bash
19
+ npm install
20
+ # or
21
+ yarn install
22
+ # or
23
+ pnpm install
24
+ ```
25
+
26
+ ### 3. Set up Environment Variables
27
+
28
+ Create a `.env` file in the root directory and add the following variables:
29
+
30
+ ```env
31
+ # Postgres Database URL (e.g., Neon or Supabase)
32
+ DATABASE_URL=""
33
+
34
+ # Better Auth Secret
35
+ # Run command: npx @better-auth/cli@latest secret
36
+ # Or visit Better Auth docs to generate one
37
+ BETTER_AUTH_SECRET=""
38
+
39
+ # GitHub OAuth Credentials
40
+ GITHUB_CLIENT_ID=""
41
+ GITHUB_CLIENT_SECRET=""
42
+
43
+ # Google OAuth Credentials
44
+ GOOGLE_CLIENT_ID=""
45
+ GOOGLE_CLIENT_SECRET=""
46
+
47
+ # Base URL
48
+ NEXT_PUBLIC_BASE_URL="http://localhost:3000"
49
+ ```
50
+
51
+ ### 4. Database Setup
52
+
53
+ Run the following command to migrate your database schema(a client is created automatically):
54
+
55
+ ```bash
56
+ npx prisma migrate dev
57
+ ```
58
+
59
+ ### 5. Run Development Server
60
+
61
+ ```bash
62
+ npm run dev
63
+ # or
64
+ yarn dev
65
+ # or
66
+ pnpm dev
67
+ ```
68
+
69
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
70
+
71
+ ## Special Notes
72
+
73
+ - **Shadcn Components**: All shadcn components have been added for your convenience. Please feel free to remove those you do not need when your project is complete.
74
+ - **Protected Routes**: Update the `proxy.ts` file to configure additional protected routes for your application.
75
+ - **Legal Pages**: Update `app/terms/page.tsx` and `app/privacy/page.tsx` to fit your specific business needs and legal requirements.
76
+
77
+ ## OAuth Setup Guide
78
+
79
+ ### Google OAuth
80
+ 1. Go to the [Google Cloud Console](https://console.cloud.google.com/).
81
+ 2. Navigate to **APIs & Services** > **Credentials**.
82
+ 3. Click **Create Credentials** -> **OAuth Client ID**.
83
+ 4. Application type: **Web application**.
84
+ 5. Add Authorized redirect URIs (e.g., `http://localhost:3000/api/auth/callback/google`).
85
+ 6. Copy the **Client ID** and **Client Secret** to your `.env` file.
86
+
87
+ ### GitHub OAuth
88
+ 1. Go to your GitHub **Settings**.
89
+ 2. Navigate to **Developer settings** > **OAuth Apps**.
90
+ 3. Click **New OAuth App**.
91
+ 4. Fill in the specific details. Authorization callback URL should be `http://localhost:3000/api/auth/callback/github`.
92
+ 5. Register application and copy **Client ID** and **Client Secret** to your `.env` file.
93
+
94
+ ## Learn More
95
+
96
+ - [Next.js Documentation](https://nextjs.org/docs)
97
+ - [Better Auth Documentation](https://www.better-auth.com/docs)
98
+ - [Shadcn UI](https://ui.shadcn.com/)
99
+ - [Better Auth UI Documentation](https://www.better-auth-ui.com)
100
+ - [Prisma ORM Documentation](https://prisma.io/docs)
101
+ - [TRPC Documentation](https://trpc.io/docs)
package/bin/index.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { run } from '../src/index.js';
4
+
5
+ run();
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ export default {
2
+ transform: {},
3
+ moduleNameMapper: {
4
+ "^(\\.{1,2}/.*)\\.js$": "$1",
5
+ },
6
+ testEnvironment: "node",
7
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "create-next-app-niena",
3
+ "version": "1.0.0",
4
+ "description": "CLI to bootstrap a Next.js app with Better Auth, Shadcn, Prisma, and TRPC",
5
+ "main": "bin/index.js",
6
+ "bin": {
7
+ "create-next-app-niena": "bin/index.js",
8
+ "niena-starter-kit": "bin/index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "cross-env NODE_ENV=test node --experimental-vm-modules ./node_modules/jest/bin/jest.js"
12
+ },
13
+ "keywords": [
14
+ "nextjs",
15
+ "cli",
16
+ "starter",
17
+ "template"
18
+ ],
19
+ "author": "NienaLabs",
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "chalk": "^5.3.0",
23
+ "commander": "^13.0.0",
24
+ "cross-spawn": "^7.0.6",
25
+ "figlet": "^1.9.4",
26
+ "fs-extra": "^11.2.0",
27
+ "ora": "^8.1.0",
28
+ "prompts": "^2.4.2"
29
+ },
30
+ "type": "module",
31
+ "devDependencies": {
32
+ "cross-env": "^10.1.0",
33
+ "jest": "^30.2.0"
34
+ }
35
+ }
package/src/index.js ADDED
@@ -0,0 +1,409 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import prompts from 'prompts';
4
+ import path from 'path';
5
+ import fs from 'fs-extra';
6
+ import { fileURLToPath, pathToFileURL } from 'url';
7
+ import spawn from 'cross-spawn';
8
+ import ora from 'ora';
9
+ import figlet from 'figlet';
10
+
11
+ // Helper to get __dirname in ESM
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+
15
+ const program = new Command();
16
+
17
+ program
18
+ .name('niena-starter-kit')
19
+ .description('CLI to bootstrap a Next.js app with NienaLabs stack')
20
+ .version('1.0.0')
21
+ .argument('[project-name]', 'Name of the project')
22
+ .action((projectName) => runScaffold(projectName));
23
+
24
+ export const runScaffold = async (projectName, injectedPrompts = prompts, injectedSpawn = spawn) => {
25
+ console.log(chalk.cyan(figlet.textSync('Niena\nStarter\nKit', { horizontalLayout: 'fitted' })));
26
+ console.log(chalk.bold.blue('\n🚀 The Ultimate Next.js Starter Kit\n'));
27
+
28
+ let targetDir = projectName;
29
+
30
+ if (!targetDir) {
31
+ const response = await injectedPrompts({
32
+ type: 'text',
33
+ name: 'projectName',
34
+ message: 'What is your project named?',
35
+ initial: 'my-app'
36
+ });
37
+ targetDir = response.projectName;
38
+ }
39
+
40
+ if (!targetDir) {
41
+ console.log(chalk.red('Project name is required.'));
42
+ // process.exit(1); // Don't exit in testable function, strictly.
43
+ return;
44
+ }
45
+
46
+ const questions = [
47
+ {
48
+ type: 'select',
49
+ name: 'packageManager',
50
+ message: 'Select Package Manager:',
51
+ choices: [
52
+ { title: 'npm', value: 'npm' },
53
+ { title: 'pnpm', value: 'pnpm' },
54
+ { title: 'yarn', value: 'yarn' },
55
+ { title: 'bun', value: 'bun' }
56
+ ],
57
+ initial: 0
58
+ },
59
+ {
60
+ type: 'select',
61
+ name: 'auth',
62
+ message: 'Select Authentication Provider:',
63
+ choices: [
64
+ { title: 'Better-auth', value: 'better-auth' },
65
+ { title: 'None', value: 'none' }
66
+ ],
67
+ initial: 0
68
+ },
69
+ {
70
+ type: (prev) => prev === 'better-auth' ? 'toggle' : null,
71
+ name: 'betterAuthUi',
72
+ message: 'Add Better-Auth UI?',
73
+ initial: true,
74
+ active: 'Yes',
75
+ inactive: 'No'
76
+ },
77
+ {
78
+ type: (prev, values) => {
79
+ // If betterAuthUi is true, Shadcn is compulsory, so we skip asking but can inform user
80
+ if (values.betterAuthUi) return null;
81
+ return 'toggle';
82
+ },
83
+ name: 'shadcn',
84
+ message: 'Add Shadcn UI?',
85
+ initial: true,
86
+ active: 'Yes',
87
+ inactive: 'No'
88
+ },
89
+ {
90
+ type: 'select',
91
+ name: 'orm',
92
+ message: 'Select ORM:',
93
+ choices: [
94
+ { title: 'Prisma', value: 'prisma' }
95
+ ],
96
+ initial: 0
97
+ },
98
+ {
99
+ type: 'toggle',
100
+ name: 'trpc',
101
+ message: 'Add tRPC?',
102
+ initial: false,
103
+ active: 'Yes',
104
+ inactive: 'No'
105
+ }
106
+ ];
107
+
108
+ const answers = await injectedPrompts(questions);
109
+
110
+ // Normalize Shadcn choice
111
+ if (answers.betterAuthUi) {
112
+ answers.shadcn = true;
113
+ console.log(chalk.cyan('ℹ️ Better-Auth UI requires Shadcn UI. Shadcn UI has been automatically enabled.'));
114
+ } else if (answers.shadcn === undefined) {
115
+ // Handle undefined if toggled off/skipped
116
+ if (answers.auth !== 'better-auth') {
117
+ // If auth is none, shadcn wasn't skipped by betterAuthUi check, but basic prompts logic
118
+ }
119
+ }
120
+
121
+ const packageManager = answers.packageManager || 'npm';
122
+ const pmRunCommand = packageManager === 'npm' ? 'npm run' : packageManager;
123
+
124
+ console.log(chalk.gray('\nScaffolding project in ') + chalk.bold.white(targetDir) + '...');
125
+
126
+ // 1. Create Next App
127
+ console.log(chalk.blue('Creating Next.js app...'));
128
+ try {
129
+ const createNextAppFlags = [
130
+ '-y',
131
+ 'create-next-app@latest',
132
+ targetDir,
133
+ '--typescript',
134
+ '--tailwind',
135
+ '--eslint',
136
+ '--app',
137
+ '--skip-install',
138
+ '--no-src-dir',
139
+ '--import-alias', '@/*',
140
+ ];
141
+
142
+ if (packageManager === 'npm') createNextAppFlags.push('--use-npm');
143
+ else if (packageManager === 'pnpm') createNextAppFlags.push('--use-pnpm');
144
+ else if (packageManager === 'yarn') createNextAppFlags.push('--use-yarn');
145
+ else if (packageManager === 'bun') createNextAppFlags.push('--use-bun');
146
+
147
+ await new Promise((resolve, reject) => {
148
+ const child = injectedSpawn('npx', createNextAppFlags, { stdio: 'inherit' });
149
+
150
+ child.on('close', (code) => {
151
+ if (code !== 0) reject(new Error('create-next-app failed'));
152
+ else resolve();
153
+ });
154
+ });
155
+ console.log(chalk.green('Next.js app created.'));
156
+ } catch (e) {
157
+ console.error(chalk.red('Failed to create Next.js app.'));
158
+ console.error(e);
159
+ // process.exit(1);
160
+ return;
161
+ }
162
+
163
+ // 2. Prepare Template Paths
164
+ const templateDir = path.join(__dirname, '../template');
165
+ const projectRoot = path.resolve(process.cwd(), targetDir);
166
+
167
+ // 3. Copy Files logic
168
+ const copySpinner = ora('Copying template files...').start();
169
+
170
+ try {
171
+ await fs.copy(templateDir, projectRoot, {
172
+ overwrite: true,
173
+ filter: (src, dest) => {
174
+ const rel = path.relative(templateDir, src);
175
+
176
+ // Exclude stuff
177
+ // Exclude stuff
178
+ if (rel.includes('node_modules') || rel.includes('.git') || rel.includes('.next')) return false;
179
+
180
+ // Exclude package manager files to prevent overwriting
181
+ if (rel === 'package.json' || rel === 'package-lock.json' || rel === 'bun.lockb' || rel === 'yarn.lock' || rel === 'pnpm-lock.yaml') return false;
182
+
183
+ // Feature flags exclusions
184
+
185
+ // 1. Better-Auth UI exclusions
186
+ if (!answers.betterAuthUi) {
187
+ // Exclude better-auth-ui-provider
188
+ if (rel.includes('better-auth-ui-provider')) return false;
189
+ // Exclude app/account
190
+ if (rel.startsWith('app/account') || rel.startsWith('app\\account')) return false;
191
+ if (rel.startsWith('app/auth') || rel.startsWith('app\\auth')) return false;
192
+ }
193
+
194
+ // 2. Auth exclusions (General)
195
+ if (answers.auth !== 'better-auth') {
196
+ if (rel.startsWith('lib/auth.ts') || rel.startsWith('lib\\auth.ts')) return false;
197
+ if (rel.includes('api/auth')) return false;
198
+ if (rel.includes('better-auth-ui-provider')) return false;
199
+ if (rel.startsWith('app/account') || rel.startsWith('app\\account')) return false;
200
+ if (rel.startsWith('app/auth') || rel.startsWith('app\\auth')) return false;
201
+ }
202
+
203
+ // 3. Shadcn exclusions
204
+ if (!answers.shadcn) {
205
+ // Exclude components/ui
206
+ if (rel.startsWith('components/ui') || rel.startsWith('components\\ui')) return false;
207
+ // Exclude globals.css from template if shadcn is OFF (keep create-next-app version)
208
+ if (rel === 'app/globals.css' || rel === 'app\\globals.css') return false;
209
+ // Exclude components.json
210
+ if (rel === 'components.json') return false;
211
+ // Start with removing providers dir if empty/unused? Handled in cleanup.
212
+ }
213
+
214
+ // 4. tRPC exclusions
215
+ if (!answers.trpc) {
216
+ if (rel.startsWith('trpc') || rel.startsWith('trpc\\')) return false;
217
+ if (rel.startsWith('app/api/trpc') || rel.startsWith('app\\api\\trpc')) return false;
218
+ }
219
+
220
+ if (answers.orm !== 'prisma') {
221
+ if (rel.startsWith('prisma') || rel.startsWith('prisma\\')) return false;
222
+ if (rel.includes('lib/prisma.ts') || rel.includes('lib\\prisma.ts')) return false;
223
+ }
224
+
225
+ return true;
226
+ }
227
+ });
228
+ copySpinner.succeed('Template files copied.');
229
+ } catch (e) {
230
+ copySpinner.fail('Failed to copy files.');
231
+ console.error(e);
232
+ }
233
+
234
+ // 4. Post-processing files (Layout, CSS, etc.)
235
+ const processSpinner = ora('Configuring files...').start();
236
+ try {
237
+ const layoutPath = path.join(projectRoot, 'app/layout.tsx');
238
+ if (fs.existsSync(layoutPath)) {
239
+ let layoutContent = await fs.readFile(layoutPath, 'utf-8');
240
+
241
+ if (!answers.betterAuthUi) {
242
+ // Remove provider import
243
+ layoutContent = layoutContent.replace(/import BetterAuthUIProvider from "@\/providers\/better-auth-ui-provider"/g, '');
244
+ // Remove wrapping component
245
+ layoutContent = layoutContent.replace(/<BetterAuthUIProvider>{children}<\/BetterAuthUIProvider>/g, '{children}');
246
+ // Remove Toaster import
247
+ layoutContent = layoutContent.replace(/import { Toaster } from "@\/components\/ui\/sonner"/g, '');
248
+ // Remove Toaster component
249
+ layoutContent = layoutContent.replace(/<Toaster \/>/g, '');
250
+ }
251
+
252
+ if (!answers.trpc) {
253
+ // Remove TRPC import
254
+ layoutContent = layoutContent.replace(/import {TRPCProvider} from '@\/trpc\/client'/g, ''); // Handle simple case
255
+ layoutContent = layoutContent.replace(/import\s+{\s*TRPCProvider\s*}\s+from\s+['"]@\/trpc\/client['"];?/g, ''); // Regex for better match
256
+
257
+ // Remove TRPCProvider wrapper
258
+ layoutContent = layoutContent.replace(/<TRPCProvider>/g, '');
259
+ layoutContent = layoutContent.replace(/<\/TRPCProvider>/g, '');
260
+ }
261
+
262
+ await fs.writeFile(layoutPath, layoutContent);
263
+ }
264
+
265
+
266
+
267
+ // Post-process globals.css if Shadcn is ON but Better-Auth UI is OFF
268
+ if (answers.shadcn && !answers.betterAuthUi) {
269
+ const cssPath = path.join(projectRoot, 'app/globals.css');
270
+ if (fs.existsSync(cssPath)) {
271
+ let cssContent = await fs.readFile(cssPath, 'utf-8');
272
+ cssContent = cssContent.replace('@import "@daveyplate/better-auth-ui/css";', '');
273
+ await fs.writeFile(cssPath, cssContent);
274
+ }
275
+ }
276
+
277
+ // Cleanup directories
278
+ // Remove 'providers' if betterAuthUi is false
279
+ if (!answers.betterAuthUi) {
280
+ await fs.remove(path.join(projectRoot, 'providers'));
281
+ }
282
+
283
+ // Cleanup components/ui if !shadcn
284
+ if (!answers.shadcn) {
285
+ const componentsUiPath = path.join(projectRoot, 'components/ui');
286
+ await fs.remove(componentsUiPath);
287
+ // Also remove components.json if it snuck in (though filtered)
288
+ await fs.remove(path.join(projectRoot, 'components.json'));
289
+ }
290
+
291
+ // Remove empty components dir if empty
292
+ const componentsPath = path.join(projectRoot, 'components');
293
+ if (fs.existsSync(componentsPath)) {
294
+ const files = await fs.readdir(componentsPath);
295
+ if (files.length === 0) await fs.remove(componentsPath);
296
+ }
297
+
298
+ processSpinner.succeed('Files configured.');
299
+ } catch(e) {
300
+ processSpinner.fail('File configuration failed.');
301
+ console.error(e);
302
+ }
303
+
304
+ // 5. Merge package.json
305
+ const depSpinner = ora('Updating dependencies...').start();
306
+ try {
307
+ const templatePkg = await fs.readJson(path.join(templateDir, 'package.json'));
308
+ const targetPkgPath = path.join(projectRoot, 'package.json');
309
+ const targetPkg = await fs.readJson(targetPkgPath);
310
+
311
+ const dependenciesToAdd = {};
312
+ const devDependenciesToAdd = {};
313
+
314
+ // Always add basic utils from template (clsx, tailwind-merge, etc)
315
+ const commonDeps = ['clsx', 'tailwind-merge', 'lucide-react', 'class-variance-authority'];
316
+ commonDeps.forEach(d => {
317
+ if (templatePkg.dependencies[d]) dependenciesToAdd[d] = templatePkg.dependencies[d];
318
+ });
319
+
320
+ // Auth
321
+ if (answers.auth === 'better-auth') {
322
+ dependenciesToAdd['better-auth'] = templatePkg.dependencies['better-auth'];
323
+ dependenciesToAdd['@prisma/client'] = templatePkg.dependencies['@prisma/client'];
324
+ dependenciesToAdd['@prisma/adapter-pg'] = templatePkg.dependencies['@prisma/adapter-pg'];
325
+
326
+ if (answers.betterAuthUi) {
327
+ dependenciesToAdd['@daveyplate/better-auth-ui'] = templatePkg.dependencies['@daveyplate/better-auth-ui'];
328
+ }
329
+ }
330
+
331
+ // Shadcn
332
+ if (answers.shadcn) {
333
+ // copy all radix-ui, cmdk, etc.
334
+ Object.keys(templatePkg.dependencies).forEach(key => {
335
+ if (key.startsWith('@radix-ui') ||
336
+ ['cmdk', 'date-fns', 'embla-carousel-react', 'input-otp', 'react-day-picker', 'react-hook-form', 'react-resizable-panels', 'recharts', 'sonner', 'vaul', 'zod', '@hookform/resolvers'].includes(key)) {
337
+ dependenciesToAdd[key] = templatePkg.dependencies[key];
338
+ }
339
+ });
340
+ if (templatePkg.devDependencies['tw-animate-css']) devDependenciesToAdd['tw-animate-css'] = templatePkg.devDependencies['tw-animate-css'];
341
+ }
342
+
343
+ // Prisma
344
+ if (answers.orm === 'prisma') {
345
+ dependenciesToAdd['@prisma/client'] = templatePkg.dependencies['@prisma/client'];
346
+ dependenciesToAdd['@prisma/adapter-pg'] = templatePkg.dependencies['@prisma/adapter-pg'];
347
+ devDependenciesToAdd['prisma'] = templatePkg.devDependencies['prisma'];
348
+ devDependenciesToAdd['@types/pg'] = templatePkg.devDependencies['@types/pg'];
349
+ dependenciesToAdd['pg'] = templatePkg.dependencies['pg'];
350
+ }
351
+
352
+ // tRPC
353
+ if (answers.trpc) {
354
+ Object.keys(templatePkg.dependencies).forEach(key => {
355
+ if (key.startsWith('@trpc') ||
356
+ ['@tanstack/react-query', 'superjson', 'server-only', 'client-only'].includes(key)) {
357
+ dependenciesToAdd[key] = templatePkg.dependencies[key];
358
+ }
359
+ });
360
+ }
361
+
362
+ targetPkg.dependencies = { ...targetPkg.dependencies, ...dependenciesToAdd };
363
+ targetPkg.devDependencies = { ...targetPkg.devDependencies, ...devDependenciesToAdd };
364
+
365
+ await fs.writeJson(targetPkgPath, targetPkg, { spaces: 2 });
366
+ depSpinner.succeed('Dependencies updated.');
367
+
368
+ } catch (e) {
369
+ depSpinner.fail('Dependencies update failed.');
370
+ console.error(e);
371
+ }
372
+
373
+ // 6. Install Deps
374
+ const installSpinner = ora('Installing dependencies...').start();
375
+ try {
376
+ await new Promise((resolve, reject) => {
377
+ const child = injectedSpawn(packageManager, ['install'], { cwd: projectRoot, stdio: 'ignore' });
378
+ child.on('close', (code) => {
379
+ if (code !== 0) reject(new Error(`${packageManager} install failed`));
380
+ else resolve();
381
+ });
382
+ });
383
+ installSpinner.succeed('Dependencies installed.');
384
+ } catch(e) {
385
+ installSpinner.fail('Failed to install dependencies.');
386
+ console.error(e);
387
+ }
388
+
389
+ console.log(chalk.bold.green('\n✅ Project setup complete!'));
390
+ console.log(`\nTo get started:\n cd ${targetDir}\n ${pmRunCommand} dev`);
391
+ };
392
+
393
+
394
+
395
+ // Only run if called directly (this logic might need checking for ESM)
396
+ // Commander handles execution when .parse() is called.
397
+ // To make it testable, we might just export the "program" or the action handler.
398
+
399
+ export const run = async () => {
400
+ program.parse(process.argv);
401
+ };
402
+
403
+ // Optional: Keep this if you want `node src/index.js` to work, but strict check fails for bin usage
404
+ if (import.meta.url === pathToFileURL(process.argv[1]).href && process.env.NODE_ENV !== 'test') {
405
+ run();
406
+ }
407
+
408
+ export { program }; // Export program for potential testing invocation
409
+
package/template/.env ADDED
@@ -0,0 +1,16 @@
1
+ #postgres database url eg;neon or supabase
2
+ DATABASE_URL=""
3
+
4
+ #better-auth
5
+ BETTER_AUTH_SECRET=""
6
+
7
+ #github
8
+ GITHUB_CLIENT_ID=""
9
+ GITHUB_CLIENT_SECRET=""
10
+
11
+ #google
12
+ GOOGLE_CLIENT_ID=""
13
+ GOOGLE_CLIENT_SECRET=""
14
+
15
+ #base-url
16
+ NEXT_PUBLIC_BASE_URL="http://localhost:3000"