@digilogiclabs/create-saas-app 1.20.1 → 2.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 (35) hide show
  1. package/CHANGELOG.md +27 -388
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli/commands/create.d.ts +10 -0
  4. package/dist/cli/commands/create.d.ts.map +1 -1
  5. package/dist/cli/commands/create.js +10 -0
  6. package/dist/cli/commands/create.js.map +1 -1
  7. package/dist/cli/prompts/project-setup.d.ts.map +1 -1
  8. package/dist/cli/prompts/project-setup.js +28 -0
  9. package/dist/cli/prompts/project-setup.js.map +1 -1
  10. package/dist/generators/template-generator.d.ts +13 -1
  11. package/dist/generators/template-generator.d.ts.map +1 -1
  12. package/dist/generators/template-generator.js +128 -52
  13. package/dist/generators/template-generator.js.map +1 -1
  14. package/dist/templates/web/base/template/package.json +5 -4
  15. package/dist/templates/web/base/template/src/lib/platform.ts +146 -0
  16. package/dist/templates/web/ui-auth/template/package.json +4 -3
  17. package/dist/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
  18. package/dist/templates/web/ui-auth-payments/template/.env.example +51 -15
  19. package/dist/templates/web/ui-auth-payments/template/package.json +5 -4
  20. package/dist/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
  21. package/dist/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
  22. package/dist/templates/web/ui-auth-payments-ai/template/package.json +6 -5
  23. package/dist/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
  24. package/package.json +6 -6
  25. package/src/templates/web/base/template/package.json +5 -4
  26. package/src/templates/web/base/template/src/lib/platform.ts +146 -0
  27. package/src/templates/web/ui-auth/template/package.json +4 -3
  28. package/src/templates/web/ui-auth/template/src/lib/platform.ts +137 -0
  29. package/src/templates/web/ui-auth-payments/template/.env.example +51 -15
  30. package/src/templates/web/ui-auth-payments/template/package.json +5 -4
  31. package/src/templates/web/ui-auth-payments/template/src/lib/platform.ts +146 -0
  32. package/src/templates/web/ui-auth-payments-ai/template/.env.example +60 -22
  33. package/src/templates/web/ui-auth-payments-ai/template/package.json +6 -5
  34. package/src/templates/web/ui-auth-payments-ai/template/src/lib/platform.ts +155 -0
  35. package/bin/index.js +0 -36
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Platform Core Integration
3
+ *
4
+ * This file sets up the @digilogiclabs/platform-core integration for
5
+ * unified infrastructure services across your application.
6
+ *
7
+ * Platform-core provides:
8
+ * - Database abstraction (Supabase, PostgreSQL)
9
+ * - Cache abstraction (Redis, Upstash, Memory)
10
+ * - Storage abstraction (S3, MinIO, R2)
11
+ * - Email abstraction (Resend, SMTP)
12
+ * - Queue abstraction (BullMQ)
13
+ * - Logging and Metrics
14
+ * - Resilience patterns (retry, circuit breaker, timeout)
15
+ */
16
+
17
+ import { createPlatform, createPlatformAsync, type IPlatform } from '@digilogiclabs/platform-core';
18
+ import { setPlatform as setAuthPlatform } from '@digilogiclabs/saas-factory-auth';
19
+ import { setPlatform as setPaymentsPlatform } from '@digilogiclabs/saas-factory-payments';
20
+
21
+ // Singleton platform instance
22
+ let platformInstance: IPlatform | null = null;
23
+
24
+ /**
25
+ * Get the platform instance (creates a new one if needed)
26
+ *
27
+ * For testing or development without external services,
28
+ * this uses in-memory adapters.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const platform = getPlatform();
33
+ * await platform.cache.set('key', 'value', 3600);
34
+ * ```
35
+ */
36
+ export function getPlatform(): IPlatform {
37
+ if (!platformInstance) {
38
+ platformInstance = createPlatform();
39
+ initializePackageIntegrations(platformInstance);
40
+ }
41
+ return platformInstance;
42
+ }
43
+
44
+ /**
45
+ * Initialize platform with production adapters (async)
46
+ *
47
+ * Call this once at application startup to configure
48
+ * production services based on environment variables.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // In app/layout.tsx or a server initialization file
53
+ * await initializePlatform();
54
+ * ```
55
+ */
56
+ export async function initializePlatform(): Promise<IPlatform> {
57
+ if (platformInstance) {
58
+ return platformInstance;
59
+ }
60
+
61
+ // Use createPlatformAsync for production adapters
62
+ // Falls back to memory adapters if env vars are not set
63
+ platformInstance = await createPlatformAsync();
64
+ initializePackageIntegrations(platformInstance);
65
+
66
+ return platformInstance;
67
+ }
68
+
69
+ /**
70
+ * Initialize package integrations with platform services
71
+ */
72
+ function initializePackageIntegrations(platform: IPlatform): void {
73
+ // Connect saas-factory-auth to platform-core
74
+ // Enables: logging, metrics, and email for auth events
75
+ setAuthPlatform({
76
+ email: platform.email,
77
+ logger: platform.logger,
78
+ metrics: platform.metrics,
79
+ });
80
+
81
+ // Connect saas-factory-payments to platform-core
82
+ // Enables: logging, metrics, and caching for payment events
83
+ setPaymentsPlatform({
84
+ logger: platform.logger,
85
+ metrics: platform.metrics,
86
+ cache: platform.cache,
87
+ });
88
+ }
89
+
90
+ /**
91
+ * Reset platform instance (useful for testing)
92
+ */
93
+ export function resetPlatform(): void {
94
+ platformInstance = null;
95
+ }
96
+
97
+ /**
98
+ * Example: Using platform services
99
+ *
100
+ * Database:
101
+ * ```ts
102
+ * const users = await platform.db
103
+ * .from('users')
104
+ * .where('active', '=', true)
105
+ * .execute();
106
+ * ```
107
+ *
108
+ * Cache:
109
+ * ```ts
110
+ * await platform.cache.set('user:123', userData, 3600);
111
+ * const cached = await platform.cache.get<User>('user:123');
112
+ * ```
113
+ *
114
+ * Storage:
115
+ * ```ts
116
+ * await platform.storage.upload('avatars/user-123.png', buffer, {
117
+ * contentType: 'image/png',
118
+ * public: true,
119
+ * });
120
+ * ```
121
+ *
122
+ * Email:
123
+ * ```ts
124
+ * await platform.email.send({
125
+ * to: { email: 'user@example.com', name: 'John' },
126
+ * subject: 'Welcome!',
127
+ * html: '<h1>Welcome to {{titleCaseName}}</h1>',
128
+ * });
129
+ * ```
130
+ *
131
+ * Queue:
132
+ * ```ts
133
+ * await platform.queue.add('sendWelcomeEmail', { userId: '123' });
134
+ * ```
135
+ *
136
+ * Logging:
137
+ * ```ts
138
+ * platform.logger.info('User signed up', { userId: '123' });
139
+ * ```
140
+ *
141
+ * Metrics:
142
+ * ```ts
143
+ * platform.metrics.increment('user.signup');
144
+ * platform.metrics.timing('api.response_time', 150);
145
+ * ```
146
+ */
@@ -1,22 +1,60 @@
1
- # Auth Configuration
2
- NEXT_PUBLIC_AUTH_PROVIDER=supabase|firebase
3
-
4
- # Supabase
5
- NEXT_PUBLIC_SUPABASE_URL=
6
- NEXT_PUBLIC_SUPABASE_ANON_KEY=
7
-
8
- # Firebase
9
- NEXT_PUBLIC_FIREBASE_API_KEY=
10
- NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
11
- NEXT_PUBLIC_FIREBASE_PROJECT_ID=
12
-
13
- # Payments
14
- NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
15
- STRIPE_SECRET_KEY=
16
-
17
- # AI Configuration (Client-side accessible)
18
- NEXT_PUBLIC_OPENAI_API_KEY=your_openai_key_here
19
- NEXT_PUBLIC_ANTHROPIC_API_KEY=your_anthropic_key_here
20
- NEXT_PUBLIC_GOOGLE_AI_API_KEY=your_google_key_here
21
- NEXT_PUBLIC_ELEVENLABS_API_KEY=your_elevenlabs_key_here
22
- NEXT_PUBLIC_REPLICATE_API_TOKEN=your_replicate_token_here
1
+ # ═══════════════════════════════════════════════════════════════
2
+ # Auth Configuration
3
+ # ═══════════════════════════════════════════════════════════════
4
+ NEXT_PUBLIC_AUTH_PROVIDER=supabase|firebase
5
+
6
+ # Supabase
7
+ NEXT_PUBLIC_SUPABASE_URL=
8
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=
9
+ SUPABASE_SERVICE_ROLE_KEY=
10
+
11
+ # Firebase
12
+ NEXT_PUBLIC_FIREBASE_API_KEY=
13
+ NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
14
+ NEXT_PUBLIC_FIREBASE_PROJECT_ID=
15
+
16
+ # ═══════════════════════════════════════════════════════════════
17
+ # Payments (Stripe)
18
+ # ═══════════════════════════════════════════════════════════════
19
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
20
+ STRIPE_SECRET_KEY=
21
+ STRIPE_WEBHOOK_SECRET=
22
+
23
+ # ═══════════════════════════════════════════════════════════════
24
+ # AI Providers
25
+ # ═══════════════════════════════════════════════════════════════
26
+ OPENAI_API_KEY=
27
+ ANTHROPIC_API_KEY=
28
+ GOOGLE_AI_API_KEY=
29
+ ELEVENLABS_API_KEY=
30
+ REPLICATE_API_TOKEN=
31
+
32
+ # ═══════════════════════════════════════════════════════════════
33
+ # Platform Core - Infrastructure Services (Optional)
34
+ # Configure these for production. Memory adapters used if not set.
35
+ # ═══════════════════════════════════════════════════════════════
36
+
37
+ # Cache (Upstash Redis - great for AI response caching)
38
+ UPSTASH_REDIS_REST_URL=
39
+ UPSTASH_REDIS_REST_TOKEN=
40
+
41
+ # Storage (S3-compatible: AWS S3, MinIO, Cloudflare R2)
42
+ S3_ENDPOINT=
43
+ S3_REGION=
44
+ S3_ACCESS_KEY_ID=
45
+ S3_SECRET_ACCESS_KEY=
46
+ S3_BUCKET=
47
+
48
+ # Email (Resend)
49
+ RESEND_API_KEY=
50
+ EMAIL_FROM=noreply@example.com
51
+
52
+ # Queue (BullMQ - for AI background processing)
53
+ REDIS_URL=redis://localhost:6379
54
+
55
+ # ═══════════════════════════════════════════════════════════════
56
+ # Application
57
+ # ═══════════════════════════════════════════════════════════════
58
+ NEXT_PUBLIC_APP_URL=http://localhost:3000
59
+ NEXT_PUBLIC_APP_NAME={{titleCaseName}}
60
+ NODE_ENV=development
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "{{packageName}}",
3
3
  "version": "0.1.0",
4
- "description": "{{description}} - Full-Stack AI Platform (with UI v0.18.2 + Auth v1.0.0 + Payments + AI v1.0.0)",
4
+ "description": "{{description}} - Full-Stack AI Platform (with Platform Core + UI + Auth + Payments + AI)",
5
5
  "private": true,
6
6
  "scripts": {
7
7
  "dev": "next dev",
@@ -17,10 +17,11 @@
17
17
  "next": "^15.0.0",
18
18
  "react": "^19.0.0",
19
19
  "react-dom": "^19.0.0",
20
- "@digilogiclabs/saas-factory-ui": "^0.26.1",
21
- "@digilogiclabs/saas-factory-auth": "^1.0.3",
22
- "@digilogiclabs/saas-factory-payments": "^1.2.3",
23
- "@digilogiclabs/saas-factory-ai": "^4.0.2",
20
+ "@digilogiclabs/platform-core": "^0.1.0",
21
+ "@digilogiclabs/saas-factory-ui": "^0.27.3",
22
+ "@digilogiclabs/saas-factory-auth": "^1.0.6",
23
+ "@digilogiclabs/saas-factory-payments": "^1.2.8",
24
+ "@digilogiclabs/saas-factory-ai": "^4.0.4",
24
25
  "stripe": "^14.0.0",
25
26
  "@stripe/react-stripe-js": "^2.0.0",
26
27
  "@stripe/stripe-js": "^2.0.0",
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Platform Core Integration
3
+ *
4
+ * This file sets up the @digilogiclabs/platform-core integration for
5
+ * unified infrastructure services across your application.
6
+ *
7
+ * Platform-core provides:
8
+ * - Database abstraction (Supabase, PostgreSQL)
9
+ * - Cache abstraction (Redis, Upstash, Memory)
10
+ * - Storage abstraction (S3, MinIO, R2)
11
+ * - Email abstraction (Resend, SMTP)
12
+ * - Queue abstraction (BullMQ)
13
+ * - Logging and Metrics
14
+ * - Resilience patterns (retry, circuit breaker, timeout)
15
+ */
16
+
17
+ import { createPlatform, createPlatformAsync, type IPlatform } from '@digilogiclabs/platform-core';
18
+ import { setPlatform as setAuthPlatform } from '@digilogiclabs/saas-factory-auth';
19
+ import { setPlatform as setPaymentsPlatform } from '@digilogiclabs/saas-factory-payments';
20
+ import { setPlatform as setAIPlatform } from '@digilogiclabs/saas-factory-ai';
21
+
22
+ // Singleton platform instance
23
+ let platformInstance: IPlatform | null = null;
24
+
25
+ /**
26
+ * Get the platform instance (creates a new one if needed)
27
+ *
28
+ * For testing or development without external services,
29
+ * this uses in-memory adapters.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const platform = getPlatform();
34
+ * await platform.cache.set('key', 'value', 3600);
35
+ * ```
36
+ */
37
+ export function getPlatform(): IPlatform {
38
+ if (!platformInstance) {
39
+ platformInstance = createPlatform();
40
+ initializePackageIntegrations(platformInstance);
41
+ }
42
+ return platformInstance;
43
+ }
44
+
45
+ /**
46
+ * Initialize platform with production adapters (async)
47
+ *
48
+ * Call this once at application startup to configure
49
+ * production services based on environment variables.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // In app/layout.tsx or a server initialization file
54
+ * await initializePlatform();
55
+ * ```
56
+ */
57
+ export async function initializePlatform(): Promise<IPlatform> {
58
+ if (platformInstance) {
59
+ return platformInstance;
60
+ }
61
+
62
+ // Use createPlatformAsync for production adapters
63
+ // Falls back to memory adapters if env vars are not set
64
+ platformInstance = await createPlatformAsync();
65
+ initializePackageIntegrations(platformInstance);
66
+
67
+ return platformInstance;
68
+ }
69
+
70
+ /**
71
+ * Initialize package integrations with platform services
72
+ */
73
+ function initializePackageIntegrations(platform: IPlatform): void {
74
+ // Connect saas-factory-auth to platform-core
75
+ // Enables: logging, metrics, and email for auth events
76
+ setAuthPlatform({
77
+ email: platform.email,
78
+ logger: platform.logger,
79
+ metrics: platform.metrics,
80
+ });
81
+
82
+ // Connect saas-factory-payments to platform-core
83
+ // Enables: logging, metrics, and caching for payment events
84
+ setPaymentsPlatform({
85
+ logger: platform.logger,
86
+ metrics: platform.metrics,
87
+ cache: platform.cache,
88
+ });
89
+
90
+ // Connect saas-factory-ai to platform-core
91
+ // Enables: logging, metrics, and caching for AI operations
92
+ setAIPlatform({
93
+ logger: platform.logger,
94
+ metrics: platform.metrics,
95
+ cache: platform.cache,
96
+ });
97
+ }
98
+
99
+ /**
100
+ * Reset platform instance (useful for testing)
101
+ */
102
+ export function resetPlatform(): void {
103
+ platformInstance = null;
104
+ }
105
+
106
+ /**
107
+ * Example: Using platform services
108
+ *
109
+ * Database:
110
+ * ```ts
111
+ * const users = await platform.db
112
+ * .from('users')
113
+ * .where('active', '=', true)
114
+ * .execute();
115
+ * ```
116
+ *
117
+ * Cache (great for AI response caching):
118
+ * ```ts
119
+ * await platform.cache.set('ai:response:123', response, 3600);
120
+ * const cached = await platform.cache.get<AIResponse>('ai:response:123');
121
+ * ```
122
+ *
123
+ * Storage (for file uploads, AI assets):
124
+ * ```ts
125
+ * await platform.storage.upload('uploads/file-123.pdf', buffer, {
126
+ * contentType: 'application/pdf',
127
+ * });
128
+ * ```
129
+ *
130
+ * Email:
131
+ * ```ts
132
+ * await platform.email.send({
133
+ * to: { email: 'user@example.com', name: 'John' },
134
+ * subject: 'Welcome!',
135
+ * html: '<h1>Welcome to {{titleCaseName}}</h1>',
136
+ * });
137
+ * ```
138
+ *
139
+ * Queue (for AI background jobs):
140
+ * ```ts
141
+ * await platform.queue.add('processDocument', { documentId: '123' });
142
+ * ```
143
+ *
144
+ * Logging:
145
+ * ```ts
146
+ * platform.logger.info('AI request completed', { tokens: 150, model: 'gpt-4' });
147
+ * ```
148
+ *
149
+ * Metrics (track AI usage):
150
+ * ```ts
151
+ * platform.metrics.increment('ai.requests');
152
+ * platform.metrics.histogram('ai.tokens_used', tokenCount);
153
+ * platform.metrics.timing('ai.response_time', responseMs);
154
+ * ```
155
+ */
package/bin/index.js DELETED
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync } = require('child_process');
4
- const path = require('path');
5
- const fs = require('fs');
6
-
7
- // Check Node version
8
- const nodeVersion = process.version;
9
- const majorVersion = parseInt(nodeVersion.split('.')[0].substring(1));
10
-
11
- if (majorVersion < 18) {
12
- console.error(`❌ Node.js 18.0.0 or higher is required. You have ${nodeVersion}.`);
13
- console.error('Please upgrade Node.js: https://nodejs.org/');
14
- process.exit(1);
15
- }
16
-
17
- // Check if dist directory exists
18
- const distPath = path.join(__dirname, '..', 'dist');
19
- if (!fs.existsSync(distPath)) {
20
- console.error('❌ CLI not built. Please run: npm run build');
21
- process.exit(1);
22
- }
23
-
24
- // Run the compiled CLI
25
- try {
26
- require('../dist/cli/index.js');
27
- } catch (error) {
28
- console.error('❌ Error running create-saas-app:');
29
- console.error(error.message);
30
-
31
- if (error.code === 'MODULE_NOT_FOUND') {
32
- console.error('\n💡 Try running: npm install -g @digilogiclabs/create-saas-app');
33
- }
34
-
35
- process.exit(1);
36
- }