@idealyst/cli 1.0.37 → 1.0.38

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 (56) hide show
  1. package/dist/generators/api.js +3 -4
  2. package/dist/generators/api.js.map +1 -1
  3. package/dist/generators/database.js +32 -0
  4. package/dist/generators/database.js.map +1 -0
  5. package/dist/generators/index.js +5 -0
  6. package/dist/generators/index.js.map +1 -1
  7. package/dist/generators/utils.js +2 -1
  8. package/dist/generators/utils.js.map +1 -1
  9. package/dist/index.js +9 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/templates/api/.env.example +6 -0
  12. package/dist/templates/api/README.md +25 -35
  13. package/dist/templates/api/package.json +0 -8
  14. package/dist/templates/api/src/context.ts +4 -8
  15. package/dist/templates/database/.env.example +8 -0
  16. package/dist/templates/database/README.md +93 -0
  17. package/dist/templates/database/__tests__/database.test.ts +14 -0
  18. package/dist/templates/database/jest.config.js +19 -0
  19. package/dist/templates/database/jest.setup.js +11 -0
  20. package/dist/templates/database/package.json +61 -0
  21. package/dist/templates/{api → database}/prisma/schema.prisma +1 -1
  22. package/dist/templates/database/prisma/seed.ts +28 -0
  23. package/dist/templates/database/src/client.ts +18 -0
  24. package/dist/templates/database/src/index.ts +11 -0
  25. package/dist/templates/database/src/schemas.ts +26 -0
  26. package/dist/templates/database/tsconfig.json +32 -0
  27. package/dist/templates/workspace/.devcontainer/README.md +0 -0
  28. package/dist/templates/workspace/.devcontainer/fix-permissions.sh +0 -0
  29. package/dist/templates/workspace/.devcontainer/post-create.sh +0 -89
  30. package/dist/types/generators/database.d.ts +2 -0
  31. package/dist/types/generators/index.d.ts +1 -0
  32. package/dist/types/types.d.ts +1 -1
  33. package/package.json +8 -3
  34. package/templates/api/.env.example +6 -0
  35. package/templates/api/README.md +25 -35
  36. package/templates/api/package.json +0 -8
  37. package/templates/api/src/context.ts +4 -8
  38. package/templates/database/.env.example +8 -0
  39. package/templates/database/README.md +93 -0
  40. package/templates/database/__tests__/database.test.ts +14 -0
  41. package/templates/database/jest.config.js +19 -0
  42. package/templates/database/jest.setup.js +11 -0
  43. package/templates/database/package.json +61 -0
  44. package/templates/{api → database}/prisma/schema.prisma +1 -1
  45. package/templates/database/prisma/seed.ts +28 -0
  46. package/templates/database/src/client.ts +18 -0
  47. package/templates/database/src/index.ts +11 -0
  48. package/templates/database/src/schemas.ts +26 -0
  49. package/templates/database/tsconfig.json +32 -0
  50. package/templates/workspace/.devcontainer/README.md +0 -0
  51. package/templates/workspace/.devcontainer/fix-permissions.sh +0 -0
  52. package/templates/workspace/.devcontainer/post-create.sh +0 -0
  53. package/dist/templates/api/env.example +0 -12
  54. package/dist/templates/workspace/.env.production +0 -56
  55. package/dist/templates/workspace/scripts/docker-build.sh +0 -151
  56. package/templates/api/env.example +0 -12
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "{{packageName}}",
3
+ "version": "{{version}}",
4
+ "description": "{{description}}",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/client.d.ts",
15
+ "import": "./dist/client.js"
16
+ },
17
+ "./schemas": {
18
+ "types": "./dist/schemas.d.ts",
19
+ "import": "./dist/schemas.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "test": "jest",
25
+ "test:watch": "jest --watch",
26
+ "test:coverage": "jest --coverage",
27
+ "db:generate": "prisma generate",
28
+ "db:push": "prisma db push",
29
+ "db:studio": "prisma studio",
30
+ "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"
37
+ },
38
+ "dependencies": {
39
+ "@prisma/client": "^5.7.1",
40
+ "zod": "^3.22.4"
41
+ },
42
+ "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",
53
+ "typescript": "^5.3.3"
54
+ },
55
+ "keywords": [
56
+ "database",
57
+ "prisma",
58
+ "typescript",
59
+ "orm"
60
+ ]
61
+ }
@@ -18,4 +18,4 @@ datasource db {
18
18
  // name String?
19
19
  // createdAt DateTime @default(now())
20
20
  // updatedAt DateTime @updatedAt
21
- // }
21
+ // }
@@ -0,0 +1,28 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+
3
+ const prisma = new PrismaClient();
4
+
5
+ async function main() {
6
+ console.log('🌱 Seeding database...');
7
+
8
+ // Add your seed data here
9
+ // Example:
10
+ // const user = await prisma.user.create({
11
+ // data: {
12
+ // email: 'admin@example.com',
13
+ // name: 'Admin User',
14
+ // },
15
+ // });
16
+ // console.log('Created user:', user);
17
+
18
+ console.log('✅ Database seeded successfully!');
19
+ }
20
+
21
+ main()
22
+ .catch((e) => {
23
+ console.error('❌ Error seeding database:', e);
24
+ process.exit(1);
25
+ })
26
+ .finally(async () => {
27
+ await prisma.$disconnect();
28
+ });
@@ -0,0 +1,18 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+
3
+ declare global {
4
+ // Prevent multiple instances of Prisma Client in development
5
+ var __globalPrisma: PrismaClient | undefined;
6
+ }
7
+
8
+ const prisma =
9
+ globalThis.__globalPrisma ??
10
+ new PrismaClient({
11
+ log: ['query', 'error', 'warn'],
12
+ });
13
+
14
+ if (process.env.NODE_ENV !== 'production') {
15
+ globalThis.__globalPrisma = prisma;
16
+ }
17
+
18
+ export default prisma;
@@ -0,0 +1,11 @@
1
+ // Export Prisma client
2
+ export { PrismaClient } from '@prisma/client';
3
+
4
+ // Export database client instance
5
+ export { default as db } from './client';
6
+
7
+ // Export Zod schemas
8
+ export * from './schemas';
9
+
10
+ // Export types from Prisma
11
+ export type * from '@prisma/client';
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+
3
+ // Add your Zod schemas here to match your Prisma models
4
+ // Example:
5
+ // export const UserSchema = z.object({
6
+ // id: z.string().cuid(),
7
+ // email: z.string().email(),
8
+ // name: z.string().optional(),
9
+ // createdAt: z.date(),
10
+ // updatedAt: z.date(),
11
+ // });
12
+
13
+ // export const CreateUserSchema = UserSchema.omit({
14
+ // id: true,
15
+ // createdAt: true,
16
+ // updatedAt: true,
17
+ // });
18
+
19
+ // export const UpdateUserSchema = CreateUserSchema.partial();
20
+
21
+ // Export all your schemas
22
+ export const schemas = {
23
+ // user: UserSchema,
24
+ // createUser: CreateUserSchema,
25
+ // updateUser: UpdateUserSchema,
26
+ } as const;
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "node",
7
+ "allowSyntheticDefaultImports": true,
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./src",
17
+ "resolveJsonModule": true,
18
+ "allowJs": false,
19
+ "noUncheckedIndexedAccess": true,
20
+ "experimentalDecorators": true,
21
+ "emitDecoratorMetadata": true
22
+ },
23
+ "include": [
24
+ "src/**/*",
25
+ "prisma/**/*"
26
+ ],
27
+ "exclude": [
28
+ "node_modules",
29
+ "dist",
30
+ "__tests__"
31
+ ]
32
+ }
File without changes
@@ -1,12 +0,0 @@
1
- # Database
2
- DATABASE_URL="file:./dev.db"
3
-
4
- # Server
5
- PORT=3000
6
- NODE_ENV=development
7
-
8
- # CORS
9
- CORS_ORIGIN="http://localhost:3000"
10
-
11
- # Optional: Database for production (uncomment and configure as needed)
12
- # DATABASE_URL="postgresql://username:password@localhost:5432/{{projectName}}"
@@ -1,56 +0,0 @@
1
- # Production Environment Variables
2
- # Copy this file to .env for production deployment
3
-
4
- # Project Configuration
5
- PROJECT_NAME={{packageName}}
6
- NODE_ENV=production
7
-
8
- # Database Configuration (use strong passwords!)
9
- POSTGRES_DB={{packageName}}_production
10
- POSTGRES_USER={{packageName}}_user
11
- POSTGRES_PASSWORD=CHANGE_THIS_STRONG_PASSWORD
12
- POSTGRES_PORT=5432
13
-
14
- # Redis Configuration
15
- REDIS_PORT=6379
16
-
17
- # API Configuration
18
- API_PORT=3001
19
- JWT_SECRET=CHANGE_THIS_VERY_STRONG_JWT_SECRET_MINIMUM_32_CHARACTERS
20
-
21
- # Web Configuration
22
- WEB_PORT=80
23
-
24
- # SSL/Domain Configuration
25
- DOMAIN_NAME=yourdomain.com
26
- SSL_EMAIL=admin@yourdomain.com
27
-
28
- # Monitoring
29
- GRAFANA_PASSWORD=CHANGE_THIS_STRONG_PASSWORD
30
-
31
- # Logging
32
- LOG_LEVEL=warn
33
-
34
- # Rate Limiting (more restrictive for production)
35
- RATE_LIMIT_WINDOW_MS=900000
36
- RATE_LIMIT_MAX_REQUESTS=50
37
-
38
- # Security Settings
39
- SESSION_SECRET=CHANGE_THIS_VERY_STRONG_SESSION_SECRET
40
- ENCRYPTION_KEY=CHANGE_THIS_32_CHARACTER_ENCRYPTION_KEY
41
-
42
- # External Services (configure as needed)
43
- # SMTP_HOST=smtp.yourdomain.com
44
- # SMTP_PORT=587
45
- # SMTP_USER=noreply@yourdomain.com
46
- # SMTP_PASS=smtp_password
47
-
48
- # AWS/Cloud Storage (if using)
49
- # AWS_ACCESS_KEY_ID=your_access_key
50
- # AWS_SECRET_ACCESS_KEY=your_secret_key
51
- # AWS_REGION=us-east-1
52
- # S3_BUCKET=your-bucket-name
53
-
54
- # Analytics/Monitoring
55
- # SENTRY_DSN=your_sentry_dsn
56
- # GOOGLE_ANALYTICS_ID=your_ga_id
@@ -1,151 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Docker build helper script for Idealyst workspace
4
- # Handles common issues like missing yarn.lock files
5
-
6
- set -e
7
-
8
- # Colors for output
9
- RED='\033[0;31m'
10
- GREEN='\033[0;32m'
11
- YELLOW='\033[1;33m'
12
- BLUE='\033[0;34m'
13
- NC='\033[0m' # No Color
14
-
15
- echo -e "${BLUE}🐳 Idealyst Docker Build Helper${NC}"
16
- echo ""
17
-
18
- # Check if yarn.lock exists
19
- if [ ! -f "yarn.lock" ]; then
20
- echo -e "${YELLOW}⚠️ yarn.lock not found${NC}"
21
- echo "This can cause Docker build failures with 'immutable' installs."
22
- echo ""
23
- read -p "Would you like to generate yarn.lock now? (y/N): " -n 1 -r
24
- echo ""
25
-
26
- if [[ $REPLY =~ ^[Yy]$ ]]; then
27
- echo -e "${BLUE}📦 Installing dependencies to generate yarn.lock...${NC}"
28
- yarn install
29
- echo -e "${GREEN}✅ yarn.lock generated${NC}"
30
- else
31
- echo -e "${YELLOW}⚠️ Continuing without yarn.lock (may cause build issues)${NC}"
32
- fi
33
- echo ""
34
- fi
35
-
36
- # Check if .env exists
37
- if [ ! -f ".env" ]; then
38
- echo -e "${YELLOW}⚠️ .env file not found${NC}"
39
- if [ -f ".env.example" ]; then
40
- read -p "Would you like to copy .env.example to .env? (y/N): " -n 1 -r
41
- echo ""
42
- if [[ $REPLY =~ ^[Yy]$ ]]; then
43
- cp .env.example .env
44
- echo -e "${GREEN}✅ .env file created from .env.example${NC}"
45
- echo -e "${YELLOW}📝 Please review and update .env with your settings${NC}"
46
- fi
47
- else
48
- echo -e "${YELLOW}📝 Please create a .env file with your configuration${NC}"
49
- fi
50
- echo ""
51
- fi
52
-
53
- # Determine what to build
54
- if [ $# -eq 0 ]; then
55
- echo "What would you like to do?"
56
- echo "1) Build and start development environment"
57
- echo "2) Build and start production services"
58
- echo "3) Build specific service"
59
- echo "4) Just build (no start)"
60
- echo ""
61
- read -p "Choice (1-4): " -n 1 -r
62
- echo ""
63
-
64
- case $REPLY in
65
- 1)
66
- echo -e "${BLUE}🚀 Building and starting development environment...${NC}"
67
- docker-compose build dev
68
- docker-compose up -d postgres redis
69
- docker-compose up dev
70
- ;;
71
- 2)
72
- echo -e "${BLUE}🚀 Building and starting production services...${NC}"
73
- docker-compose build
74
- docker-compose up -d
75
- ;;
76
- 3)
77
- echo "Available services: api, web, dev, postgres, redis"
78
- read -p "Service name: " service
79
- echo -e "${BLUE}🚀 Building ${service}...${NC}"
80
- docker-compose build $service
81
- ;;
82
- 4)
83
- echo -e "${BLUE}🏗️ Building all services...${NC}"
84
- docker-compose build
85
- ;;
86
- *)
87
- echo -e "${RED}❌ Invalid choice${NC}"
88
- exit 1
89
- ;;
90
- esac
91
- else
92
- # Handle command line arguments
93
- case "$1" in
94
- "dev")
95
- echo -e "${BLUE}🚀 Building and starting development environment...${NC}"
96
- docker-compose build dev
97
- docker-compose up -d postgres redis
98
- docker-compose up dev
99
- ;;
100
- "prod"|"production")
101
- echo -e "${BLUE}🚀 Building and starting production services...${NC}"
102
- docker-compose build
103
- docker-compose up -d
104
- ;;
105
- "build")
106
- if [ -n "$2" ]; then
107
- echo -e "${BLUE}🏗️ Building ${2}...${NC}"
108
- docker-compose build $2
109
- else
110
- echo -e "${BLUE}🏗️ Building all services...${NC}"
111
- docker-compose build
112
- fi
113
- ;;
114
- "help"|"-h"|"--help")
115
- echo "Usage: $0 [command] [service]"
116
- echo ""
117
- echo "Commands:"
118
- echo " dev Build and start development environment"
119
- echo " prod Build and start production services"
120
- echo " build [svc] Build all services or specific service"
121
- echo " help Show this help"
122
- echo ""
123
- echo "Services: api, web, dev, postgres, redis"
124
- ;;
125
- *)
126
- echo -e "${RED}❌ Unknown command: $1${NC}"
127
- echo "Use '$0 help' for usage information"
128
- exit 1
129
- ;;
130
- esac
131
- fi
132
-
133
- echo ""
134
- echo -e "${GREEN}🎉 Done!${NC}"
135
-
136
- # Show helpful information
137
- if docker-compose ps | grep -q "Up"; then
138
- echo ""
139
- echo -e "${BLUE}📋 Running services:${NC}"
140
- docker-compose ps
141
- echo ""
142
- echo -e "${BLUE}🔗 Access your application:${NC}"
143
- echo "• Web: http://localhost:3000"
144
- echo "• API: http://localhost:3001"
145
- echo "• Vite Dev: http://localhost:5173"
146
- echo ""
147
- echo -e "${BLUE}💡 Useful commands:${NC}"
148
- echo "• View logs: docker-compose logs -f"
149
- echo "• Stop services: docker-compose down"
150
- echo "• Access dev container: docker-compose exec dev bash"
151
- fi
@@ -1,12 +0,0 @@
1
- # Database
2
- DATABASE_URL="file:./dev.db"
3
-
4
- # Server
5
- PORT=3000
6
- NODE_ENV=development
7
-
8
- # CORS
9
- CORS_ORIGIN="http://localhost:3000"
10
-
11
- # Optional: Database for production (uncomment and configure as needed)
12
- # DATABASE_URL="postgresql://username:password@localhost:5432/{{projectName}}"