@idealyst/cli 1.0.40 → 1.0.43

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 (89) hide show
  1. package/dist/generators/api.js +1 -2
  2. package/dist/generators/api.js.map +1 -1
  3. package/dist/generators/database.js +1 -2
  4. package/dist/generators/database.js.map +1 -1
  5. package/dist/generators/fullstack.js +371 -0
  6. package/dist/generators/fullstack.js.map +1 -0
  7. package/dist/generators/index.js +5 -0
  8. package/dist/generators/index.js.map +1 -1
  9. package/dist/generators/native.js +2 -1
  10. package/dist/generators/native.js.map +1 -1
  11. package/dist/generators/shared.js +1 -2
  12. package/dist/generators/shared.js.map +1 -1
  13. package/dist/generators/utils.js +71 -7
  14. package/dist/generators/utils.js.map +1 -1
  15. package/dist/generators/web.js +1 -2
  16. package/dist/generators/web.js.map +1 -1
  17. package/dist/generators/workspace.js +56 -2
  18. package/dist/generators/workspace.js.map +1 -1
  19. package/dist/index.js +50 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/templates/database/.env.example +1 -8
  22. package/dist/templates/database/README.md +29 -74
  23. package/dist/templates/database/package.json +20 -34
  24. package/dist/templates/database/prisma/seed.ts +11 -11
  25. package/dist/templates/database/schema.prisma +97 -0
  26. package/dist/templates/database/src/index.ts +12 -8
  27. package/dist/templates/database/src/validators.ts +10 -0
  28. package/dist/templates/database/tsconfig.json +9 -23
  29. package/dist/templates/native/src/App-with-trpc-and-shared.tsx +266 -0
  30. package/dist/templates/shared/package.json +28 -3
  31. package/dist/templates/shared/src/components/index.ts +392 -0
  32. package/dist/templates/shared/src/index.ts +59 -1
  33. package/dist/templates/shared/src/types/index.ts +148 -0
  34. package/dist/templates/shared/src/utils/index.ts +278 -0
  35. package/dist/templates/web/package.json +2 -2
  36. package/dist/templates/web/src/App-with-trpc-and-shared.tsx +304 -0
  37. package/dist/templates/workspace/.devcontainer/Dockerfile +1 -1
  38. package/dist/templates/workspace/.devcontainer/devcontainer.json +7 -2
  39. package/dist/templates/workspace/.devcontainer/docker-compose.yml +14 -0
  40. package/dist/templates/workspace/.devcontainer/figma-mcp.sh +32 -0
  41. package/dist/templates/workspace/.devcontainer/setup.sh +3 -0
  42. package/dist/templates/workspace/setup.sh +22 -197
  43. package/dist/templates/workspace/tsconfig.json +32 -0
  44. package/dist/types/generators/fullstack.d.ts +2 -0
  45. package/dist/types/generators/index.d.ts +1 -0
  46. package/dist/types/generators/utils.d.ts +4 -1
  47. package/dist/types/types.d.ts +3 -1
  48. package/package.json +1 -1
  49. package/templates/database/.env.example +1 -8
  50. package/templates/database/README.md +29 -74
  51. package/templates/database/package.json +20 -34
  52. package/templates/database/prisma/seed.ts +11 -11
  53. package/templates/database/schema.prisma +97 -0
  54. package/templates/database/src/index.ts +12 -8
  55. package/templates/database/src/validators.ts +10 -0
  56. package/templates/database/tsconfig.json +9 -23
  57. package/templates/native/src/App-with-trpc-and-shared.tsx +266 -0
  58. package/templates/shared/package.json +28 -3
  59. package/templates/shared/src/components/index.ts +392 -0
  60. package/templates/shared/src/index.ts +59 -1
  61. package/templates/shared/src/types/index.ts +148 -0
  62. package/templates/shared/src/utils/index.ts +278 -0
  63. package/templates/web/package.json +1 -1
  64. package/templates/web/src/App-with-trpc-and-shared.tsx +304 -0
  65. package/templates/workspace/.devcontainer/devcontainer.json +7 -2
  66. package/templates/workspace/.devcontainer/docker-compose.yml +14 -0
  67. package/templates/workspace/.devcontainer/figma-mcp.sh +32 -0
  68. package/templates/workspace/.devcontainer/setup.sh +3 -0
  69. package/templates/workspace/setup.sh +22 -197
  70. package/templates/workspace/tsconfig.json +32 -0
  71. package/dist/templates/database/__tests__/database.test.ts +0 -14
  72. package/dist/templates/database/jest.config.js +0 -19
  73. package/dist/templates/database/jest.setup.js +0 -11
  74. package/dist/templates/database/prisma/schema.prisma +0 -21
  75. package/dist/templates/database/src/client.ts +0 -18
  76. package/dist/templates/database/src/schemas.ts +0 -26
  77. package/dist/templates/workspace/scripts/docker/db-backup.sh +0 -230
  78. package/dist/templates/workspace/scripts/docker/deploy.sh +0 -212
  79. package/dist/templates/workspace/scripts/test-runner.js +0 -120
  80. package/templates/database/__tests__/database.test.ts +0 -14
  81. package/templates/database/jest.config.js +0 -19
  82. package/templates/database/jest.setup.js +0 -11
  83. package/templates/database/prisma/schema.prisma +0 -21
  84. package/templates/database/src/client.ts +0 -18
  85. package/templates/database/src/schemas.ts +0 -26
  86. package/templates/workspace/scripts/docker/db-backup.sh +0 -230
  87. package/templates/workspace/scripts/docker/deploy.sh +0 -212
  88. package/templates/workspace/scripts/docker-build.sh +0 -151
  89. package/templates/workspace/scripts/test-runner.js +0 -120
@@ -1,205 +1,30 @@
1
1
  #!/bin/bash
2
2
 
3
- # Quick setup script for Idealyst workspace
4
- # Usage: ./setup.sh [development|production]
3
+ # Idealyst Framework Workspace Setup Script
4
+ # This script sets up the development environment for your workspace
5
5
 
6
- set -e
6
+ echo "🏗️ Setting up Idealyst Framework workspace..."
7
7
 
8
- ENVIRONMENT=${1:-development}
9
- PROJECT_NAME="{{packageName}}"
8
+ # Install dependencies
9
+ echo "📦 Installing dependencies..."
10
+ yarn install
10
11
 
11
- echo "🚀 Setting up Idealyst workspace..."
12
- echo "Environment: $ENVIRONMENT"
13
- echo "Project: $PROJECT_NAME"
14
- echo ""
15
-
16
- # Function to generate random password
17
- generate_password() {
18
- openssl rand -base64 32 | tr -d "=+/" | cut -c1-25
19
- }
20
-
21
- # Function to generate JWT secret
22
- generate_jwt_secret() {
23
- openssl rand -base64 64 | tr -d "=+/" | cut -c1-50
24
- }
25
-
26
- # Function to setup development environment
27
- setup_development() {
28
- echo "🔧 Setting up development environment..."
29
-
30
- if [ ! -f ".env" ]; then
31
- echo "📝 Creating .env from template..."
32
- cp .env.example .env
33
- echo "✅ Created .env file"
34
- else
35
- echo "⚠️ .env file already exists, skipping..."
36
- fi
37
-
38
- echo ""
39
- echo "🐳 Starting development containers..."
40
- if command -v docker-compose &> /dev/null; then
41
- docker-compose up -d postgres redis
42
- echo "✅ Database and Redis started"
43
-
44
- echo "⏳ Waiting for services to be ready..."
45
- sleep 10
46
-
47
- echo "🚀 Starting development environment..."
48
- echo "💡 You can now:"
49
- echo " - Run 'docker-compose up -d dev' for full dev container"
50
- echo " - Run 'yarn dev' for local development"
51
- echo " - Open in VS Code and select 'Reopen in Container'"
52
- else
53
- echo "❌ Docker Compose not found. Please install Docker and Docker Compose."
54
- exit 1
55
- fi
56
- }
57
-
58
- # Function to setup production environment
59
- setup_production() {
60
- echo "🏭 Setting up production environment..."
61
-
62
- if [ ! -f ".env" ]; then
63
- echo "📝 Creating .env from production template..."
64
- cp .env.production .env
65
-
66
- # Generate secure passwords and secrets
67
- echo "🔐 Generating secure credentials..."
68
-
69
- DB_PASSWORD=$(generate_password)
70
- JWT_SECRET=$(generate_jwt_secret)
71
- SESSION_SECRET=$(generate_jwt_secret)
72
- ENCRYPTION_KEY=$(openssl rand -base64 32 | cut -c1-32)
73
- GRAFANA_PASSWORD=$(generate_password)
74
-
75
- # Replace placeholders in .env file
76
- sed -i "s/CHANGE_THIS_STRONG_PASSWORD/$DB_PASSWORD/g" .env
77
- sed -i "s/CHANGE_THIS_VERY_STRONG_JWT_SECRET_MINIMUM_32_CHARACTERS/$JWT_SECRET/g" .env
78
- sed -i "s/CHANGE_THIS_VERY_STRONG_SESSION_SECRET/$SESSION_SECRET/g" .env
79
- sed -i "s/CHANGE_THIS_32_CHARACTER_ENCRYPTION_KEY/$ENCRYPTION_KEY/g" .env
80
- sed -i "s/CHANGE_THIS_STRONG_PASSWORD/$GRAFANA_PASSWORD/g" .env
81
-
82
- echo "✅ Created .env with secure credentials"
83
- echo ""
84
- echo "🔐 Generated Credentials (save these securely!):"
85
- echo " Database Password: $DB_PASSWORD"
86
- echo " JWT Secret: $JWT_SECRET"
87
- echo " Grafana Password: $GRAFANA_PASSWORD"
88
- echo ""
89
- echo "⚠️ IMPORTANT: Edit .env to configure your domain and other settings!"
90
-
91
- else
92
- echo "⚠️ .env file already exists. Please verify production settings."
93
- fi
94
-
95
- echo ""
96
- echo "📋 Production Checklist:"
97
- echo " [ ] Edit .env with your domain name"
98
- echo " [ ] Configure SSL certificates"
99
- echo " [ ] Set up DNS records"
100
- echo " [ ] Configure firewall rules"
101
- echo " [ ] Set up monitoring (optional)"
102
- echo ""
103
- echo "🚀 Deploy with: ./scripts/docker/deploy.sh production"
104
- }
12
+ # Build all packages
13
+ echo "🔨 Building packages..."
14
+ yarn build:packages
105
15
 
106
- # Function to check prerequisites
107
- check_prerequisites() {
108
- echo "🔍 Checking prerequisites..."
109
-
110
- # Check Docker
111
- if ! command -v docker &> /dev/null; then
112
- echo "❌ Docker not found. Please install Docker."
113
- exit 1
114
- fi
115
-
116
- # Check Docker Compose
117
- if ! command -v docker-compose &> /dev/null; then
118
- echo "❌ Docker Compose not found. Please install Docker Compose."
119
- exit 1
120
- fi
121
-
122
- # Check if Docker is running
123
- if ! docker info &> /dev/null; then
124
- echo "❌ Docker is not running. Please start Docker."
125
- exit 1
126
- fi
127
-
128
- echo "✅ Prerequisites check passed"
129
- echo ""
130
- }
131
-
132
- # Function to show post-setup instructions
133
- show_instructions() {
134
- echo ""
135
- echo "🎉 Setup complete!"
136
- echo ""
137
- echo "Next steps:"
138
-
139
- if [ "$ENVIRONMENT" = "development" ]; then
140
- echo " 1. Install dependencies: yarn install"
141
- echo " 2. Start development:"
142
- echo " - Full container: docker-compose up -d dev"
143
- echo " - VS Code: Open in Container"
144
- echo " - Local: yarn dev"
145
- echo " 3. Access your app:"
146
- echo " - Web: http://localhost:3000"
147
- echo " - API: http://localhost:3001"
148
- echo " - Database: postgresql://postgres:postgres@localhost:5432/idealyst_db"
149
- else
150
- echo " 1. Edit .env with your production settings"
151
- echo " 2. Configure SSL certificates"
152
- echo " 3. Deploy: ./scripts/docker/deploy.sh production"
153
- echo " 4. Set up monitoring (optional)"
154
- fi
155
-
156
- echo ""
157
- echo "📚 Documentation:"
158
- echo " - DOCKER.md - Complete Docker guide"
159
- echo " - TESTING.md - Testing documentation"
160
- echo " - README.md - General workspace info"
161
- echo ""
162
- echo "🆘 Need help? Check the documentation or run:"
163
- echo " ./scripts/docker/deploy.sh --help"
164
- }
165
-
166
- # Main setup process
167
- main() {
168
- check_prerequisites
169
-
170
- case $ENVIRONMENT in
171
- "development"|"dev")
172
- setup_development
173
- ;;
174
- "production"|"prod")
175
- setup_production
176
- ;;
177
- *)
178
- echo "❌ Invalid environment. Use 'development' or 'production'"
179
- echo "Usage: $0 [development|production]"
180
- exit 1
181
- ;;
182
- esac
183
-
184
- show_instructions
185
- }
186
-
187
- # Handle help
188
- if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "help" ]]; then
189
- echo "Idealyst Workspace Setup Script"
190
- echo ""
191
- echo "Usage: $0 [environment]"
192
- echo ""
193
- echo "Environments:"
194
- echo " development (default) - Set up for local development"
195
- echo " production - Set up for production deployment"
196
- echo ""
197
- echo "Examples:"
198
- echo " $0 # Development setup"
199
- echo " $0 development # Development setup"
200
- echo " $0 production # Production setup"
201
- echo ""
202
- exit 0
16
+ # Set up git hooks (if using husky)
17
+ if [ -f "package.json" ] && grep -q "husky" package.json; then
18
+ echo "🪝 Setting up git hooks..."
19
+ yarn prepare
203
20
  fi
204
21
 
205
- main
22
+ echo "✅ Workspace setup complete!"
23
+ echo ""
24
+ echo "🚀 Quick start:"
25
+ echo " • Run 'yarn dev' to start development mode"
26
+ echo " • Run 'yarn build' to build all packages"
27
+ echo " • Run 'yarn test' to run tests"
28
+ echo " • Use 'idealyst create <type> <name>' to add new projects"
29
+ echo ""
30
+ echo "📚 Check README.md and DOCKER.md for more information."
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020"],
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src"
17
+ },
18
+ "include": [
19
+ "packages/*/src/**/*"
20
+ ],
21
+ "exclude": [
22
+ "node_modules",
23
+ "dist",
24
+ "**/*.test.ts",
25
+ "**/*.spec.ts"
26
+ ],
27
+ "references": [
28
+ {
29
+ "path": "./packages/*"
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,2 @@
1
+ import { GenerateProjectOptions } from '../types';
2
+ export declare function generateFullStackWorkspace(options: GenerateProjectOptions): Promise<void>;
@@ -6,3 +6,4 @@ export * from './shared';
6
6
  export * from './workspace';
7
7
  export * from './api';
8
8
  export * from './database';
9
+ export * from './fullstack';
@@ -1,5 +1,6 @@
1
1
  import { TemplateData } from '../types';
2
2
  export declare function validateProjectName(name: string): boolean;
3
+ export declare function getTemplatePath(templateName: string): string;
3
4
  export declare function createPackageName(name: string): string;
4
5
  export declare function updateWorkspacePackageJson(workspacePath: string, directory: string): Promise<void>;
5
6
  export declare function copyTemplate(templatePath: string, destPath: string, data: TemplateData): Promise<void>;
@@ -16,7 +17,8 @@ export declare function getTemplateData(projectName: string, description?: strin
16
17
  */
17
18
  export declare function isWorkspaceRoot(directory: string): Promise<boolean>;
18
19
  /**
19
- * Gets the workspace name from the workspace root's package.json
20
+ * Gets the workspace scope from the workspace root's package.json
21
+ * Extracts just the scope name (without @) from scoped package names
20
22
  */
21
23
  export declare function getWorkspaceName(directory: string): Promise<string | null>;
22
24
  /**
@@ -38,5 +40,6 @@ export declare function promptForAppName(projectName: string): Promise<string>;
38
40
  export declare function promptForTrpcIntegration(): Promise<boolean>;
39
41
  export declare function copyTrpcFiles(templatePath: string, projectPath: string, data: TemplateData): Promise<void>;
40
42
  export declare function copyTrpcAppComponent(templatePath: string, projectPath: string, data: TemplateData): Promise<void>;
43
+ export declare function addTrpcDependencies(projectPath: string): Promise<void>;
41
44
  export declare function removeTrpcDependencies(projectPath: string): Promise<void>;
42
45
  export declare function configureAndroidVectorIcons(projectPath: string): Promise<void>;
@@ -1,4 +1,4 @@
1
- export type ProjectType = 'native' | 'web' | 'shared' | 'workspace' | 'api' | 'database';
1
+ export type ProjectType = 'native' | 'web' | 'shared' | 'workspace' | 'api' | 'database' | 'fullstack';
2
2
  export interface GenerateProjectOptions {
3
3
  name: string;
4
4
  type: ProjectType;
@@ -6,6 +6,7 @@ export interface GenerateProjectOptions {
6
6
  skipInstall: boolean;
7
7
  appName?: string;
8
8
  withTrpc?: boolean;
9
+ figmaToken?: string;
9
10
  }
10
11
  export interface TemplateData {
11
12
  projectName: string;
@@ -13,4 +14,5 @@ export interface TemplateData {
13
14
  version: string;
14
15
  description: string;
15
16
  appName?: string;
17
+ workspaceScope?: string;
16
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/cli",
3
- "version": "1.0.40",
3
+ "version": "1.0.43",
4
4
  "description": "CLI tool for generating Idealyst Framework projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,8 +1 @@
1
- # Database
2
- DATABASE_URL="file:./dev.db"
3
-
4
- # Optional: PostgreSQL example
5
- # DATABASE_URL="postgresql://username:password@localhost:5432/mydb?schema=public"
6
-
7
- # Optional: MySQL example
8
- # DATABASE_URL="mysql://username:password@localhost:3306/mydb"
1
+ DATABASE_URL="sqlite:./dev.db"
@@ -1,93 +1,48 @@
1
- # {{projectName}}
1
+ # Database Package
2
2
 
3
- {{description}}
3
+ This package provides database access and validation schemas for the workspace.
4
4
 
5
- A database layer built with Prisma and TypeScript, designed to be shared across multiple applications in your monorepo.
5
+ ## Setup
6
6
 
7
- ## Features
8
-
9
- - 🗄️ **Prisma ORM** - Type-safe database access
10
- - 📝 **Zod Schemas** - Runtime validation matching your database models
11
- - 📦 **Exportable Client** - Share database access across packages
12
- - 🔒 **TypeScript** - Full type safety
13
- - 🧪 **Testing Setup** - Jest configuration for database testing
14
- - 🔄 **Migration Scripts** - Database versioning and seeding
15
-
16
- ## Getting Started
17
-
18
- 1. **Environment Setup**
19
- ```bash
20
- cp .env.example .env
21
- # Edit .env with your database URL
22
- ```
7
+ 1. Install dependencies:
8
+ ```bash
9
+ yarn install
10
+ ```
23
11
 
24
- 2. **Generate Prisma Client**
25
- ```bash
26
- yarn db:generate
27
- ```
12
+ 2. Set up your environment:
13
+ ```bash
14
+ cp .env.example .env
15
+ # Edit .env with your database URL
16
+ ```
28
17
 
29
- 3. **Push Schema to Database**
30
- ```bash
31
- yarn db:push
32
- ```
18
+ 3. Generate the Prisma client:
19
+ ```bash
20
+ yarn db:generate
21
+ ```
33
22
 
34
- 4. **Open Prisma Studio** (Optional)
35
- ```bash
36
- yarn db:studio
37
- ```
23
+ 4. Push the schema to your database:
24
+ ```bash
25
+ yarn db:push
26
+ ```
38
27
 
39
28
  ## Usage
40
29
 
41
- ### In Other Packages
42
-
43
30
  ```typescript
44
- import { db, schemas } from '@your-org/{{projectName}}';
31
+ import { prisma, User, TestValidator } from '@{{workspaceScope}}/{{name}}';
45
32
 
46
33
  // Use the database client
47
- const users = await db.user.findMany();
34
+ const users = await prisma.user.findMany();
48
35
 
49
- // Use Zod schemas for validation
50
- const userData = schemas.createUser.parse(input);
36
+ // Use validators
37
+ const validatedData = TestValidator.parse(userData);
51
38
  ```
52
39
 
53
- ### Adding Models
54
-
55
- 1. Update `prisma/schema.prisma` with your models
56
- 2. Update `src/schemas.ts` with corresponding Zod schemas
57
- 3. Run `yarn db:generate` to update the client
58
- 4. Run `yarn db:push` to update the database
59
-
60
40
  ## Scripts
61
41
 
62
- - `yarn build` - Build the package for distribution
63
- - `yarn dev` - Run in development mode with file watching
64
- - `yarn test` - Run tests
65
- - `yarn test:watch` - Run tests in watch mode
66
42
  - `yarn db:generate` - Generate Prisma client
67
- - `yarn db:push` - Push schema changes to database
43
+ - `yarn db:push` - Push schema to database
44
+ - `yarn db:migrate` - Create and run migrations
68
45
  - `yarn db:studio` - Open Prisma Studio
69
- - `yarn db:migrate` - Create and apply migrations
70
- - `yarn db:reset` - Reset database and apply migrations
71
- - `yarn db:seed` - Seed the database
72
-
73
- ## Project Structure
74
-
75
- ```
76
- src/
77
- ├── index.ts # Main exports
78
- ├── client.ts # Prisma client setup
79
- └── schemas.ts # Zod validation schemas
80
- prisma/
81
- ├── schema.prisma # Database schema
82
- └── migrations/ # Database migrations
83
- __tests__/
84
- └── database.test.ts # Database tests
85
- ```
86
-
87
- ## Best Practices
88
-
89
- - Always update Zod schemas when changing Prisma models
90
- - Use meaningful migration names
91
- - Test database operations
92
- - Export only what's needed from the main index
93
- - Keep the client singleton pattern for performance
46
+ - `yarn db:reset` - Reset the database
47
+ - `yarn build` - Build the package
48
+ - `yarn dev` - Build in watch mode
@@ -1,61 +1,47 @@
1
1
  {
2
2
  "name": "{{packageName}}",
3
- "version": "{{version}}",
4
- "description": "{{description}}",
5
- "type": "module",
3
+ "version": "1.0.0",
4
+ "description": "Database layer with Prisma",
6
5
  "main": "dist/index.js",
7
6
  "types": "dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
9
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
12
  },
13
13
  "./client": {
14
- "types": "./dist/client.d.ts",
15
- "import": "./dist/client.js"
14
+ "types": "./generated/client/index.d.ts",
15
+ "import": "./generated/client/index.js",
16
+ "require": "./generated/client/index.js"
16
17
  },
17
18
  "./schemas": {
18
- "types": "./dist/schemas.d.ts",
19
- "import": "./dist/schemas.js"
19
+ "types": "./dist/validators.d.ts",
20
+ "import": "./dist/validators.js",
21
+ "require": "./dist/validators.js"
20
22
  }
21
23
  },
22
24
  "scripts": {
23
25
  "build": "tsc",
24
- "test": "jest",
25
- "test:watch": "jest --watch",
26
- "test:coverage": "jest --coverage",
26
+ "dev": "tsc --watch",
27
27
  "db:generate": "prisma generate",
28
28
  "db:push": "prisma db push",
29
- "db:studio": "prisma studio",
30
29
  "db:migrate": "prisma migrate dev",
31
- "db:reset": "prisma migrate reset",
32
- "db:seed": "tsx prisma/seed.ts",
33
- "lint": "eslint src --ext .ts,.tsx",
34
- "lint:fix": "eslint src --ext .ts,.tsx --fix",
35
- "type-check": "tsc --noEmit",
36
- "dev": "tsx watch src/index.ts"
30
+ "db:studio": "prisma studio",
31
+ "db:reset": "prisma migrate reset"
37
32
  },
38
33
  "dependencies": {
39
- "@prisma/client": "^5.7.1",
34
+ "@prisma/client": "^5.19.1",
40
35
  "zod": "^3.22.4"
41
36
  },
42
37
  "devDependencies": {
43
- "@types/jest": "^29.5.12",
44
- "@types/node": "^20.10.4",
45
- "@typescript-eslint/eslint-plugin": "^6.13.1",
46
- "@typescript-eslint/parser": "^6.13.1",
47
- "dotenv": "^16.3.1",
48
- "eslint": "^8.54.0",
49
- "jest": "^29.7.0",
50
- "prisma": "^5.7.1",
51
- "ts-jest": "^29.1.2",
52
- "tsx": "^4.6.2",
38
+ "@types/node": "^20.10.0",
39
+ "prisma": "^5.19.1",
53
40
  "typescript": "^5.3.3"
54
41
  },
55
- "keywords": [
56
- "database",
57
- "prisma",
58
- "typescript",
59
- "orm"
42
+ "files": [
43
+ "dist/**/*",
44
+ "prisma/**/*",
45
+ "generated/**/*"
60
46
  ]
61
47
  }
@@ -1,28 +1,28 @@
1
- import { PrismaClient } from '@prisma/client';
1
+ import { PrismaClient } from '../generated/client';
2
2
 
3
3
  const prisma = new PrismaClient();
4
4
 
5
5
  async function main() {
6
- console.log('🌱 Seeding database...');
7
-
8
6
  // Add your seed data here
9
- // Example:
7
+ console.log('🌱 Seeding database...');
8
+
9
+ // Example seed data
10
10
  // const user = await prisma.user.create({
11
11
  // data: {
12
12
  // email: 'admin@example.com',
13
13
  // name: 'Admin User',
14
14
  // },
15
15
  // });
16
- // console.log('Created user:', user);
17
-
18
- console.log('✅ Database seeded successfully!');
16
+
17
+ console.log('✅ Seeding completed');
19
18
  }
20
19
 
21
20
  main()
22
- .catch((e) => {
23
- console.error('❌ Error seeding database:', e);
24
- process.exit(1);
21
+ .then(async () => {
22
+ await prisma.$disconnect();
25
23
  })
26
- .finally(async () => {
24
+ .catch(async (e) => {
25
+ console.error(e);
27
26
  await prisma.$disconnect();
27
+ process.exit(1);
28
28
  });
@@ -0,0 +1,97 @@
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
+ output = "./generated/client"
7
+ }
8
+
9
+ datasource db {
10
+ provider = "sqlite"
11
+ url = env("DATABASE_URL")
12
+ }
13
+
14
+ // Demo User model with profile information
15
+ model User {
16
+ id String @id @default(cuid())
17
+ email String @unique
18
+ name String?
19
+ avatar String? // URL to profile image
20
+ bio String? // User biography
21
+ location String? // User location
22
+ website String? // Personal website
23
+
24
+ // Posts created by this user
25
+ posts Post[]
26
+
27
+ // Comments made by this user
28
+ comments Comment[]
29
+
30
+ // User preferences and settings
31
+ settings UserSettings?
32
+
33
+ createdAt DateTime @default(now())
34
+ updatedAt DateTime @updatedAt
35
+ }
36
+
37
+ // Demo Post model for a simple blog/social feed
38
+ model Post {
39
+ id String @id @default(cuid())
40
+ title String
41
+ content String
42
+ excerpt String? // Short description
43
+ published Boolean @default(false)
44
+ tags String? // Comma-separated tag strings
45
+
46
+ // Author relationship
47
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
48
+ authorId String
49
+
50
+ // Comments on this post
51
+ comments Comment[]
52
+
53
+ // Post metadata
54
+ views Int @default(0)
55
+ likes Int @default(0)
56
+
57
+ createdAt DateTime @default(now())
58
+ updatedAt DateTime @updatedAt
59
+ }
60
+
61
+ // Demo Comment model
62
+ model Comment {
63
+ id String @id @default(cuid())
64
+ content String
65
+
66
+ // Author relationship
67
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
68
+ authorId String
69
+
70
+ // Post relationship
71
+ post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
72
+ postId String
73
+
74
+ // Parent comment for nested threading
75
+ parent Comment? @relation("CommentThread", fields: [parentId], references: [id])
76
+ parentId String?
77
+ children Comment[] @relation("CommentThread")
78
+
79
+ createdAt DateTime @default(now())
80
+ updatedAt DateTime @updatedAt
81
+ }
82
+
83
+ // User settings and preferences
84
+ model UserSettings {
85
+ id String @id @default(cuid())
86
+ theme String @default("auto") // "light", "dark", "auto"
87
+ notifications Boolean @default(true)
88
+ emailUpdates Boolean @default(false)
89
+ publicProfile Boolean @default(true)
90
+
91
+ // User relationship (one-to-one)
92
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
93
+ userId String @unique
94
+
95
+ createdAt DateTime @default(now())
96
+ updatedAt DateTime @updatedAt
97
+ }