stackkit-cli 0.1.0 → 0.1.1

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 (34) hide show
  1. package/modules/auth/nextauth/files/app-router/api/auth/[...nextauth]/route.ts +6 -0
  2. package/modules/auth/nextauth/files/lib/auth.ts +82 -0
  3. package/modules/auth/nextauth/files/pages-router/api/auth/[...nextauth].ts +4 -0
  4. package/modules/auth/nextauth/module.json +50 -0
  5. package/package.json +7 -1
  6. package/templates/next-prisma-postgres-shadcn/.env.example +5 -0
  7. package/templates/next-prisma-postgres-shadcn/.eslintrc.json +7 -0
  8. package/templates/next-prisma-postgres-shadcn/.prettierrc +8 -0
  9. package/templates/next-prisma-postgres-shadcn/README.md +79 -0
  10. package/templates/next-prisma-postgres-shadcn/app/api/health/route.ts +25 -0
  11. package/templates/next-prisma-postgres-shadcn/app/globals.css +1 -0
  12. package/templates/next-prisma-postgres-shadcn/app/layout.tsx +22 -0
  13. package/templates/next-prisma-postgres-shadcn/app/page.tsx +29 -0
  14. package/templates/next-prisma-postgres-shadcn/lib/db.ts +14 -0
  15. package/templates/next-prisma-postgres-shadcn/lib/env.ts +15 -0
  16. package/templates/next-prisma-postgres-shadcn/next.config.ts +7 -0
  17. package/templates/next-prisma-postgres-shadcn/package.json +32 -0
  18. package/templates/next-prisma-postgres-shadcn/prisma/schema.prisma +20 -0
  19. package/templates/next-prisma-postgres-shadcn/public/.gitkeep +1 -0
  20. package/templates/next-prisma-postgres-shadcn/template.json +18 -0
  21. package/templates/next-prisma-postgres-shadcn/tsconfig.json +32 -0
  22. package/src/commands/add.ts +0 -261
  23. package/src/commands/init.ts +0 -182
  24. package/src/commands/list.ts +0 -124
  25. package/src/index.ts +0 -53
  26. package/src/types/index.ts +0 -71
  27. package/src/utils/code-inject.ts +0 -85
  28. package/src/utils/detect.ts +0 -89
  29. package/src/utils/env-editor.ts +0 -127
  30. package/src/utils/files.ts +0 -59
  31. package/src/utils/json-editor.ts +0 -64
  32. package/src/utils/logger.ts +0 -62
  33. package/src/utils/package-manager.ts +0 -85
  34. package/tsconfig.json +0 -9
@@ -0,0 +1,6 @@
1
+ import { authOptions } from '@/lib/auth';
2
+ import NextAuth from 'next-auth';
3
+
4
+ const handler = NextAuth(authOptions);
5
+
6
+ export { handler as GET, handler as POST };
@@ -0,0 +1,82 @@
1
+ import { AuthOptions } from 'next-auth';
2
+ import CredentialsProvider from 'next-auth/providers/credentials';
3
+
4
+ /**
5
+ * NextAuth.js Configuration
6
+ *
7
+ * Configure authentication providers and options here.
8
+ * See: https://next-auth.js.org/configuration/options
9
+ */
10
+ export const authOptions: AuthOptions = {
11
+ providers: [
12
+ // GitHub OAuth Provider
13
+ // Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
14
+ // GithubProvider({
15
+ // clientId: process.env.GITHUB_ID!,
16
+ // clientSecret: process.env.GITHUB_SECRET!,
17
+ // }),
18
+
19
+ // Google OAuth Provider
20
+ // Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
21
+ // GoogleProvider({
22
+ // clientId: process.env.GOOGLE_ID!,
23
+ // clientSecret: process.env.GOOGLE_SECRET!,
24
+ // }),
25
+
26
+ // Credentials Provider (email/password)
27
+ // Replace with your own authentication logic
28
+ CredentialsProvider({
29
+ name: 'Credentials',
30
+ credentials: {
31
+ email: { label: 'Email', type: 'email', placeholder: 'user@example.com' },
32
+ password: { label: 'Password', type: 'password' },
33
+ },
34
+ async authorize(credentials) {
35
+ // Add your own authentication logic here
36
+ // This is just a demo - DO NOT use in production
37
+ if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
38
+ return {
39
+ id: '1',
40
+ name: 'Demo User',
41
+ email: 'demo@example.com',
42
+ };
43
+ }
44
+ return null;
45
+ },
46
+ }),
47
+ ],
48
+
49
+ // Database adapter (optional)
50
+ // Uncomment to persist sessions in database
51
+ // adapter: PrismaAdapter(prisma),
52
+
53
+ session: {
54
+ strategy: 'jwt',
55
+ },
56
+
57
+ pages: {
58
+ signIn: '/auth/signin',
59
+ // signOut: '/auth/signout',
60
+ // error: '/auth/error',
61
+ // verifyRequest: '/auth/verify-request',
62
+ // newUser: '/auth/new-user'
63
+ },
64
+
65
+ callbacks: {
66
+ async jwt({ token, user }) {
67
+ if (user) {
68
+ token.id = user.id;
69
+ }
70
+ return token;
71
+ },
72
+ async session({ session, token }) {
73
+ if (session.user) {
74
+ session.user.id = token.id as string;
75
+ }
76
+ return session;
77
+ },
78
+ },
79
+
80
+ // Enable debug messages in development
81
+ debug: process.env.NODE_ENV === 'development',
82
+ };
@@ -0,0 +1,4 @@
1
+ import { authOptions } from '@/lib/auth';
2
+ import NextAuth from 'next-auth';
3
+
4
+ export default NextAuth(authOptions);
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "auth",
3
+ "displayName": "NextAuth.js Authentication",
4
+ "description": "Add authentication with NextAuth.js (supports multiple providers)",
5
+ "category": "auth",
6
+ "supportedFrameworks": ["nextjs"],
7
+ "dependencies": {
8
+ "next-auth": "^4.24.5"
9
+ },
10
+ "envVars": [
11
+ {
12
+ "key": "NEXTAUTH_URL",
13
+ "value": "http://localhost:3000",
14
+ "description": "The URL of your application (change in production)",
15
+ "required": true
16
+ },
17
+ {
18
+ "key": "NEXTAUTH_SECRET",
19
+ "value": "",
20
+ "description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32",
21
+ "required": true
22
+ }
23
+ ],
24
+ "patches": [
25
+ {
26
+ "type": "create-file",
27
+ "description": "Create NextAuth API route for App Router",
28
+ "source": "app-router/api/auth/[...nextauth]/route.ts",
29
+ "destination": "{{router}}/api/auth/[...nextauth]/route.ts",
30
+ "condition": {
31
+ "router": "app"
32
+ }
33
+ },
34
+ {
35
+ "type": "create-file",
36
+ "description": "Create NextAuth API route for Pages Router",
37
+ "source": "pages-router/api/auth/[...nextauth].ts",
38
+ "destination": "{{router}}/api/auth/[...nextauth].ts",
39
+ "condition": {
40
+ "router": "pages"
41
+ }
42
+ },
43
+ {
44
+ "type": "create-file",
45
+ "description": "Create auth configuration",
46
+ "source": "lib/auth.ts",
47
+ "destination": "{{lib}}/auth.ts"
48
+ }
49
+ ]
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackkit-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI for StackKit - Production-ready project generator and module system",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -29,6 +29,12 @@
29
29
  "nextjs",
30
30
  "template"
31
31
  ],
32
+ "files": [
33
+ "dist",
34
+ "bin",
35
+ "templates",
36
+ "modules"
37
+ ],
32
38
  "author": "Your Name",
33
39
  "license": "MIT",
34
40
  "dependencies": {
@@ -0,0 +1,5 @@
1
+ # Database
2
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
3
+
4
+ # App
5
+ NODE_ENV="development"
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "next/core-web-vitals",
3
+ "rules": {
4
+ "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
5
+ "@typescript-eslint/no-explicit-any": "warn"
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false
8
+ }
@@ -0,0 +1,79 @@
1
+ # StackKit Project
2
+
3
+ This project was created with [StackKit](https://github.com/yourusername/stackkit).
4
+
5
+ ## Getting Started
6
+
7
+ 1. Install dependencies:
8
+
9
+ ```bash
10
+ pnpm install
11
+ ```
12
+
13
+ 2. Copy the environment variables:
14
+
15
+ ```bash
16
+ cp .env.example .env
17
+ ```
18
+
19
+ 3. Update the `DATABASE_URL` in `.env` with your PostgreSQL connection string.
20
+
21
+ 4. Run database migrations:
22
+
23
+ ```bash
24
+ pnpm prisma migrate dev --name init
25
+ ```
26
+
27
+ 5. Start the development server:
28
+
29
+ ```bash
30
+ pnpm dev
31
+ ```
32
+
33
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
34
+
35
+ ## Tech Stack
36
+
37
+ - **Next.js 15** - React framework with App Router
38
+ - **TypeScript** - Type-safe JavaScript
39
+ - **Prisma** - Next-generation ORM
40
+ - **PostgreSQL** - Robust relational database
41
+ - **Tailwind CSS** - Utility-first CSS framework
42
+ - **Zod** - TypeScript-first schema validation
43
+
44
+ ## Project Structure
45
+
46
+ ```
47
+ ├── app/ # Next.js App Router
48
+ │ ├── api/ # API routes
49
+ │ ├── layout.tsx # Root layout
50
+ │ └── page.tsx # Home page
51
+ ├── lib/ # Shared utilities
52
+ │ ├── db.ts # Prisma client
53
+ │ └── env.ts # Environment validation
54
+ ├── prisma/ # Database schema
55
+ │ └── schema.prisma
56
+ └── public/ # Static assets
57
+ ```
58
+
59
+ ## Available Commands
60
+
61
+ - `pnpm dev` - Start development server
62
+ - `pnpm build` - Build for production
63
+ - `pnpm start` - Start production server
64
+ - `pnpm lint` - Run ESLint
65
+ - `pnpm format` - Format code with Prettier
66
+
67
+ ## Adding Features
68
+
69
+ Use StackKit to add more features to your project:
70
+
71
+ ```bash
72
+ npx stackkit add auth
73
+ ```
74
+
75
+ ## Learn More
76
+
77
+ - [Next.js Documentation](https://nextjs.org/docs)
78
+ - [Prisma Documentation](https://www.prisma.io/docs)
79
+ - [StackKit Documentation](https://github.com/yourusername/stackkit)
@@ -0,0 +1,25 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { prisma } from '@/lib/db';
3
+
4
+ export async function GET() {
5
+ try {
6
+ // Test database connection
7
+ await prisma.$queryRaw`SELECT 1`;
8
+
9
+ return NextResponse.json({
10
+ status: 'ok',
11
+ timestamp: new Date().toISOString(),
12
+ database: 'connected',
13
+ });
14
+ } catch (error) {
15
+ return NextResponse.json(
16
+ {
17
+ status: 'error',
18
+ timestamp: new Date().toISOString(),
19
+ database: 'disconnected',
20
+ error: error instanceof Error ? error.message : 'Unknown error',
21
+ },
22
+ { status: 500 }
23
+ );
24
+ }
25
+ }
@@ -0,0 +1 @@
1
+ @import 'tailwindcss';
@@ -0,0 +1,22 @@
1
+ import type { Metadata } from 'next';
2
+ import { Inter } from 'next/font/google';
3
+ import './globals.css';
4
+
5
+ const inter = Inter({ subsets: ['latin'] });
6
+
7
+ export const metadata: Metadata = {
8
+ title: 'StackKit App',
9
+ description: 'Created with StackKit',
10
+ };
11
+
12
+ export default function RootLayout({
13
+ children,
14
+ }: Readonly<{
15
+ children: React.ReactNode;
16
+ }>) {
17
+ return (
18
+ <html lang="en">
19
+ <body className={inter.className}>{children}</body>
20
+ </html>
21
+ );
22
+ }
@@ -0,0 +1,29 @@
1
+ export default function HomePage() {
2
+ return (
3
+ <main className="flex min-h-screen flex-col items-center justify-center p-24">
4
+ <div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm">
5
+ <h1 className="text-4xl font-bold mb-4">Welcome to StackKit</h1>
6
+ <p className="text-lg text-gray-600 dark:text-gray-400">
7
+ Your production-ready Next.js starter
8
+ </p>
9
+ <div className="mt-8 space-y-2">
10
+ <p>✅ Next.js 15 App Router</p>
11
+ <p>✅ TypeScript</p>
12
+ <p>✅ Prisma + PostgreSQL</p>
13
+ <p>✅ Tailwind CSS</p>
14
+ <p>✅ Environment validation</p>
15
+ </div>
16
+ <div className="mt-8">
17
+ <a
18
+ href="/api/health"
19
+ className="text-blue-600 hover:underline"
20
+ target="_blank"
21
+ rel="noopener noreferrer"
22
+ >
23
+ Check API Health →
24
+ </a>
25
+ </div>
26
+ </div>
27
+ </main>
28
+ );
29
+ }
@@ -0,0 +1,14 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+ import { env } from './env';
3
+
4
+ const globalForPrisma = globalThis as unknown as {
5
+ prisma: PrismaClient | undefined;
6
+ };
7
+
8
+ export const prisma =
9
+ globalForPrisma.prisma ??
10
+ new PrismaClient({
11
+ log: env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
12
+ });
13
+
14
+ if (env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ const envSchema = z.object({
4
+ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
5
+ DATABASE_URL: z.string().url(),
6
+ });
7
+
8
+ const parsedEnv = envSchema.safeParse(process.env);
9
+
10
+ if (!parsedEnv.success) {
11
+ console.error('❌ Invalid environment variables:', parsedEnv.error.format());
12
+ throw new Error('Invalid environment variables');
13
+ }
14
+
15
+ export const env = parsedEnv.data;
@@ -0,0 +1,7 @@
1
+ import type { NextConfig } from 'next';
2
+
3
+ const nextConfig: NextConfig = {
4
+ /* config options here */
5
+ };
6
+
7
+ export default nextConfig;
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "my-app",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "eslint . --ext .ts,.tsx",
10
+ "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
11
+ "postinstall": "prisma generate"
12
+ },
13
+ "dependencies": {
14
+ "@prisma/client": "^5.8.0",
15
+ "next": "16.1.1",
16
+ "react": "19.2.3",
17
+ "react-dom": "19.2.3",
18
+ "zod": "^3.22.4"
19
+ },
20
+ "devDependencies": {
21
+ "@tailwindcss/postcss": "^4",
22
+ "@types/node": "^20",
23
+ "@types/react": "^19",
24
+ "@types/react-dom": "^19",
25
+ "eslint": "^9",
26
+ "eslint-config-next": "16.1.1",
27
+ "prettier": "^3.2.4",
28
+ "prisma": "^5.8.0",
29
+ "tailwindcss": "^4",
30
+ "typescript": "^5"
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ // This is your Prisma schema file
2
+ // Learn more about it in the docs: https://pris.ly/d/prisma-schema
3
+
4
+ generator client {
5
+ provider = "prisma-client-js"
6
+ }
7
+
8
+ datasource db {
9
+ provider = "postgresql"
10
+ url = env("DATABASE_URL")
11
+ }
12
+
13
+ // Example model - replace with your own
14
+ model User {
15
+ id String @id @default(cuid())
16
+ email String @unique
17
+ name String?
18
+ createdAt DateTime @default(now())
19
+ updatedAt DateTime @updatedAt
20
+ }
@@ -0,0 +1 @@
1
+ # This file is used to keep the public directory in git
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "next-prisma-postgres-shadcn",
3
+ "displayName": "Next.js + Prisma + PostgreSQL + shadcn/ui",
4
+ "description": "Production-ready Next.js App Router with Prisma, PostgreSQL, shadcn/ui, and best practices",
5
+ "tags": ["nextjs", "prisma", "postgresql", "shadcn", "typescript"],
6
+ "defaultPackageManager": "pnpm",
7
+ "features": [
8
+ "Next.js 15 App Router",
9
+ "TypeScript",
10
+ "Prisma ORM",
11
+ "PostgreSQL",
12
+ "shadcn/ui components",
13
+ "Tailwind CSS",
14
+ "Environment validation (Zod)",
15
+ "ESLint + Prettier",
16
+ "Health check API route"
17
+ ]
18
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ }
24
+ },
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts"
30
+ ],
31
+ "exclude": ["node_modules"]
32
+ }