@l4yercak3/cli 1.2.16 → 1.2.18

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.
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Quick Start Generator
3
+ * Orchestrates full-stack generation for the Quick Start path
4
+ */
5
+
6
+ const databaseGenerator = require('./database');
7
+ const hooksGenerator = require('./hooks');
8
+ const componentGenerator = require('./components');
9
+ const pageGenerator = require('./pages');
10
+ const apiOnlyGenerator = require('../api-only');
11
+ const envGenerator = require('../env-generator');
12
+ const nextauthGenerator = require('../nextauth-generator');
13
+ const oauthGuideGenerator = require('../oauth-guide-generator');
14
+ const gitignoreGenerator = require('../gitignore-generator');
15
+
16
+ class QuickStartGenerator {
17
+ /**
18
+ * Check if framework is a mobile platform
19
+ */
20
+ isMobileFramework(frameworkType) {
21
+ return ['expo', 'react-native'].includes(frameworkType);
22
+ }
23
+
24
+ /**
25
+ * Check if framework is Next.js
26
+ */
27
+ isNextJs(frameworkType) {
28
+ return frameworkType === 'nextjs';
29
+ }
30
+
31
+ /**
32
+ * Generate all Quick Start files
33
+ * @param {Object} options - Generation options
34
+ * @returns {Promise<Object>} - Generated file paths
35
+ */
36
+ async generate(options) {
37
+ const results = {
38
+ // API Client (from api-only generator)
39
+ apiClient: null,
40
+ types: null,
41
+ webhooks: null,
42
+ index: null,
43
+
44
+ // Database
45
+ database: null,
46
+
47
+ // Hooks
48
+ hooks: null,
49
+
50
+ // Components
51
+ components: null,
52
+
53
+ // Pages (Next.js only)
54
+ pages: null,
55
+
56
+ // Common files
57
+ envFile: null,
58
+ nextauth: null,
59
+ oauthGuide: null,
60
+ gitignore: null,
61
+ };
62
+
63
+ const frameworkType = options.frameworkType || 'unknown';
64
+ const isMobile = this.isMobileFramework(frameworkType);
65
+ const isNextJs = this.isNextJs(frameworkType);
66
+
67
+ // 1. Generate the typed API client package
68
+ const apiOnlyResults = await apiOnlyGenerator.generate(options);
69
+ results.apiClient = apiOnlyResults.client;
70
+ results.types = apiOnlyResults.types;
71
+ results.webhooks = apiOnlyResults.webhooks;
72
+ results.index = apiOnlyResults.index;
73
+
74
+ // 2. Generate database files if database selected
75
+ if (options.selectedDatabase && options.selectedDatabase !== 'none' && options.selectedDatabase !== 'existing') {
76
+ results.database = await databaseGenerator.generate(options);
77
+ }
78
+
79
+ // 3. Generate React hooks for data fetching
80
+ if (options.features && options.features.length > 0) {
81
+ results.hooks = await hooksGenerator.generate(options);
82
+ }
83
+
84
+ // 4. Generate React components
85
+ if (options.features && options.features.length > 0) {
86
+ results.components = await componentGenerator.generate(options);
87
+ }
88
+
89
+ // 5. Generate pages (Next.js only)
90
+ if (isNextJs && options.features && options.features.length > 0) {
91
+ results.pages = await pageGenerator.generate(options);
92
+ }
93
+
94
+ // 6. Generate environment file
95
+ results.envFile = envGenerator.generate(this.enhanceEnvOptions(options));
96
+
97
+ // 7. Generate NextAuth.js config if OAuth is enabled (Next.js only)
98
+ if (options.features && options.features.includes('oauth') && options.oauthProviders) {
99
+ if (isNextJs) {
100
+ results.nextauth = await nextauthGenerator.generate(options);
101
+ }
102
+ }
103
+
104
+ // 8. Generate OAuth guide if OAuth is enabled
105
+ if (options.features && options.features.includes('oauth') && options.oauthProviders) {
106
+ results.oauthGuide = oauthGuideGenerator.generate({
107
+ ...options,
108
+ isMobile,
109
+ isNextJs,
110
+ });
111
+ }
112
+
113
+ // 9. Update .gitignore
114
+ results.gitignore = gitignoreGenerator.generate(options);
115
+
116
+ return results;
117
+ }
118
+
119
+ /**
120
+ * Add database-specific env vars to options
121
+ */
122
+ enhanceEnvOptions(options) {
123
+ const enhanced = { ...options };
124
+ enhanced.additionalEnvVars = enhanced.additionalEnvVars || [];
125
+
126
+ if (options.selectedDatabase === 'convex') {
127
+ enhanced.additionalEnvVars.push(
128
+ { key: 'CONVEX_DEPLOYMENT', value: '', comment: 'Convex deployment URL (from npx convex dev)' },
129
+ { key: 'NEXT_PUBLIC_CONVEX_URL', value: '', comment: 'Convex public URL' }
130
+ );
131
+ } else if (options.selectedDatabase === 'supabase') {
132
+ enhanced.additionalEnvVars.push(
133
+ { key: 'NEXT_PUBLIC_SUPABASE_URL', value: '', comment: 'Supabase project URL' },
134
+ { key: 'NEXT_PUBLIC_SUPABASE_ANON_KEY', value: '', comment: 'Supabase anonymous key' },
135
+ { key: 'SUPABASE_SERVICE_ROLE_KEY', value: '', comment: 'Supabase service role key (server only)' }
136
+ );
137
+ }
138
+
139
+ if (options.features && options.features.includes('checkout')) {
140
+ enhanced.additionalEnvVars.push(
141
+ { key: 'STRIPE_SECRET_KEY', value: '', comment: 'Stripe secret key' },
142
+ { key: 'STRIPE_WEBHOOK_SECRET', value: '', comment: 'Stripe webhook signing secret' },
143
+ { key: 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY', value: '', comment: 'Stripe publishable key' }
144
+ );
145
+ }
146
+
147
+ return enhanced;
148
+ }
149
+ }
150
+
151
+ module.exports = new QuickStartGenerator();