@l4yercak3/cli 1.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.
- package/.claude/settings.local.json +18 -0
- package/.cursor/rules.md +203 -0
- package/.eslintrc.js +31 -0
- package/README.md +227 -0
- package/bin/cli.js +61 -0
- package/docs/ADDING_NEW_PROJECT_TYPE.md +156 -0
- package/docs/ARCHITECTURE_RELATIONSHIPS.md +411 -0
- package/docs/CLI_AUTHENTICATION.md +214 -0
- package/docs/DETECTOR_ARCHITECTURE.md +326 -0
- package/docs/DEVELOPMENT.md +194 -0
- package/docs/IMPLEMENTATION_PHASES.md +468 -0
- package/docs/OAUTH_CLARIFICATION.md +258 -0
- package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +211 -0
- package/docs/PHASE_0_PROGRESS.md +120 -0
- package/docs/PHASE_1_COMPLETE.md +366 -0
- package/docs/PHASE_SUMMARY.md +149 -0
- package/docs/PLAN.md +511 -0
- package/docs/README.md +56 -0
- package/docs/STRIPE_INTEGRATION.md +447 -0
- package/docs/SUMMARY.md +230 -0
- package/docs/UPDATED_PLAN.md +447 -0
- package/package.json +53 -0
- package/src/api/backend-client.js +148 -0
- package/src/commands/login.js +146 -0
- package/src/commands/logout.js +24 -0
- package/src/commands/spread.js +364 -0
- package/src/commands/status.js +62 -0
- package/src/config/config-manager.js +205 -0
- package/src/detectors/api-client-detector.js +85 -0
- package/src/detectors/base-detector.js +77 -0
- package/src/detectors/github-detector.js +74 -0
- package/src/detectors/index.js +80 -0
- package/src/detectors/nextjs-detector.js +139 -0
- package/src/detectors/oauth-detector.js +122 -0
- package/src/detectors/registry.js +97 -0
- package/src/generators/api-client-generator.js +197 -0
- package/src/generators/env-generator.js +162 -0
- package/src/generators/gitignore-generator.js +92 -0
- package/src/generators/index.js +50 -0
- package/src/generators/nextauth-generator.js +242 -0
- package/src/generators/oauth-guide-generator.js +277 -0
- package/src/logo.js +116 -0
- package/tests/api-client-detector.test.js +214 -0
- package/tests/api-client-generator.test.js +169 -0
- package/tests/backend-client.test.js +361 -0
- package/tests/base-detector.test.js +101 -0
- package/tests/commands/login.test.js +98 -0
- package/tests/commands/logout.test.js +70 -0
- package/tests/commands/status.test.js +167 -0
- package/tests/config-manager.test.js +313 -0
- package/tests/detector-index.test.js +209 -0
- package/tests/detector-registry.test.js +93 -0
- package/tests/env-generator.test.js +278 -0
- package/tests/generators-index.test.js +215 -0
- package/tests/github-detector.test.js +145 -0
- package/tests/gitignore-generator.test.js +109 -0
- package/tests/logo.test.js +96 -0
- package/tests/nextauth-generator.test.js +231 -0
- package/tests/nextjs-detector.test.js +235 -0
- package/tests/oauth-detector.test.js +264 -0
- package/tests/oauth-guide-generator.test.js +273 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Generators
|
|
3
|
+
* Main entry point for all file generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const apiClientGenerator = require('./api-client-generator');
|
|
7
|
+
const envGenerator = require('./env-generator');
|
|
8
|
+
const nextauthGenerator = require('./nextauth-generator');
|
|
9
|
+
const oauthGuideGenerator = require('./oauth-guide-generator');
|
|
10
|
+
const gitignoreGenerator = require('./gitignore-generator');
|
|
11
|
+
|
|
12
|
+
class FileGenerator {
|
|
13
|
+
/**
|
|
14
|
+
* Generate all files based on configuration
|
|
15
|
+
*/
|
|
16
|
+
async generate(options) {
|
|
17
|
+
const results = {
|
|
18
|
+
apiClient: null,
|
|
19
|
+
envFile: null,
|
|
20
|
+
nextauth: null,
|
|
21
|
+
oauthGuide: null,
|
|
22
|
+
gitignore: null,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Generate API client
|
|
26
|
+
if (options.features && options.features.length > 0) {
|
|
27
|
+
results.apiClient = apiClientGenerator.generate(options);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Generate environment file
|
|
31
|
+
results.envFile = envGenerator.generate(options);
|
|
32
|
+
|
|
33
|
+
// Generate NextAuth.js config if OAuth is enabled
|
|
34
|
+
if (options.features && options.features.includes('oauth') && options.oauthProviders) {
|
|
35
|
+
results.nextauth = nextauthGenerator.generate(options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Generate OAuth guide if OAuth is enabled
|
|
39
|
+
if (options.features && options.features.includes('oauth') && options.oauthProviders) {
|
|
40
|
+
results.oauthGuide = oauthGuideGenerator.generate(options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Update .gitignore
|
|
44
|
+
results.gitignore = gitignoreGenerator.generate(options);
|
|
45
|
+
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = new FileGenerator();
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NextAuth.js Configuration Generator
|
|
3
|
+
* Generates NextAuth.js configuration for OAuth providers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
class NextAuthGenerator {
|
|
10
|
+
/**
|
|
11
|
+
* Generate NextAuth.js configuration
|
|
12
|
+
*/
|
|
13
|
+
generate(options) {
|
|
14
|
+
const {
|
|
15
|
+
projectPath,
|
|
16
|
+
backendUrl,
|
|
17
|
+
oauthProviders,
|
|
18
|
+
routerType,
|
|
19
|
+
isTypeScript,
|
|
20
|
+
} = options;
|
|
21
|
+
|
|
22
|
+
// Determine API route path based on router type
|
|
23
|
+
const apiDir = routerType === 'app'
|
|
24
|
+
? path.join(projectPath, 'app', 'api', 'auth')
|
|
25
|
+
: path.join(projectPath, 'pages', 'api', 'auth');
|
|
26
|
+
|
|
27
|
+
// Ensure directory exists
|
|
28
|
+
if (!fs.existsSync(apiDir)) {
|
|
29
|
+
fs.mkdirSync(apiDir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const extension = isTypeScript ? 'ts' : 'js';
|
|
33
|
+
const routePath = routerType === 'app'
|
|
34
|
+
? path.join(apiDir, `[...nextauth]`, `route.${extension}`)
|
|
35
|
+
: path.join(apiDir, `[...nextauth].${extension}`);
|
|
36
|
+
|
|
37
|
+
// Ensure [...nextauth] directory exists for App Router
|
|
38
|
+
if (routerType === 'app') {
|
|
39
|
+
const nextauthDir = path.join(apiDir, '[...nextauth]');
|
|
40
|
+
if (!fs.existsSync(nextauthDir)) {
|
|
41
|
+
fs.mkdirSync(nextauthDir, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Generate NextAuth configuration
|
|
46
|
+
const code = this.generateCode({
|
|
47
|
+
backendUrl,
|
|
48
|
+
oauthProviders,
|
|
49
|
+
routerType,
|
|
50
|
+
isTypeScript,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
fs.writeFileSync(routePath, code, 'utf8');
|
|
54
|
+
return routePath;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Generate NextAuth.js code
|
|
59
|
+
*/
|
|
60
|
+
generateCode({ oauthProviders, routerType, isTypeScript }) {
|
|
61
|
+
const providers = [];
|
|
62
|
+
const providerImports = [];
|
|
63
|
+
|
|
64
|
+
if (oauthProviders.includes('google')) {
|
|
65
|
+
providerImports.push("import GoogleProvider from 'next-auth/providers/google';");
|
|
66
|
+
providers.push(` GoogleProvider({
|
|
67
|
+
clientId: process.env.GOOGLE_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
68
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
69
|
+
}),`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (oauthProviders.includes('microsoft')) {
|
|
73
|
+
providerImports.push("import AzureADProvider from 'next-auth/providers/azure-ad';");
|
|
74
|
+
providers.push(` AzureADProvider({
|
|
75
|
+
clientId: process.env.AZURE_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
76
|
+
clientSecret: process.env.AZURE_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
77
|
+
tenantId: process.env.AZURE_TENANT_ID${isTypeScript ? '!' : ''},
|
|
78
|
+
}),`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (oauthProviders.includes('github')) {
|
|
82
|
+
providerImports.push("import GitHubProvider from 'next-auth/providers/github';");
|
|
83
|
+
providers.push(` GitHubProvider({
|
|
84
|
+
clientId: process.env.GITHUB_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
85
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
86
|
+
}),`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const providersCode = providers.join('\n');
|
|
90
|
+
|
|
91
|
+
// App Router vs Pages Router
|
|
92
|
+
if (routerType === 'app') {
|
|
93
|
+
return `/**
|
|
94
|
+
* NextAuth.js Configuration
|
|
95
|
+
* Auto-generated by @l4yercak3/cli
|
|
96
|
+
*
|
|
97
|
+
* This file configures OAuth authentication for your frontend application.
|
|
98
|
+
* Users authenticated here are automatically synced to your L4YERCAK3 backend.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
${providerImports.join('\n')}
|
|
102
|
+
import NextAuth from 'next-auth';
|
|
103
|
+
import type { NextAuthOptions } from 'next-auth';
|
|
104
|
+
|
|
105
|
+
const authOptions${isTypeScript ? ': NextAuthOptions' : ''} = {
|
|
106
|
+
providers: [
|
|
107
|
+
${providersCode}
|
|
108
|
+
],
|
|
109
|
+
callbacks: {
|
|
110
|
+
async signIn({ user, account, profile }) {
|
|
111
|
+
if (!account) return false;
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
// Sync user to L4YERCAK3 backend
|
|
115
|
+
const response = await fetch(\`\${process.env.NEXT_PUBLIC_L4YERCAK3_BACKEND_URL}/api/v1/auth/sync-user\`, {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
headers: {
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
'Authorization': \`Bearer \${process.env.L4YERCAK3_API_KEY}\`,
|
|
120
|
+
},
|
|
121
|
+
body: JSON.stringify({
|
|
122
|
+
email: user.email,
|
|
123
|
+
name: user.name,
|
|
124
|
+
image: user.image,
|
|
125
|
+
provider: account.provider,
|
|
126
|
+
providerAccountId: account.providerAccountId,
|
|
127
|
+
accessToken: account.access_token,
|
|
128
|
+
refreshToken: account.refresh_token,
|
|
129
|
+
expiresAt: account.expires_at,
|
|
130
|
+
}),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (!response.ok) {
|
|
134
|
+
console.error('Failed to sync user to backend:', await response.text());
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const backendUser = await response.json();
|
|
139
|
+
|
|
140
|
+
// Add backend user ID to session
|
|
141
|
+
user.id = backendUser.userId;
|
|
142
|
+
user.organizationId = backendUser.organizationId;
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error('Error syncing user to backend:', error);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
async session({ session, user${isTypeScript ? ': any' : ''} }) {
|
|
151
|
+
if (session.user) {
|
|
152
|
+
session.user.id = user.id;
|
|
153
|
+
session.user.organizationId = user.organizationId;
|
|
154
|
+
}
|
|
155
|
+
return session;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
pages: {
|
|
159
|
+
signIn: '/auth/signin',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handler = NextAuth(authOptions);
|
|
164
|
+
|
|
165
|
+
export { handler as GET, handler as POST };
|
|
166
|
+
`;
|
|
167
|
+
} else {
|
|
168
|
+
// Pages Router
|
|
169
|
+
return `/**
|
|
170
|
+
* NextAuth.js Configuration
|
|
171
|
+
* Auto-generated by @l4yercak3/cli
|
|
172
|
+
*
|
|
173
|
+
* This file configures OAuth authentication for your frontend application.
|
|
174
|
+
* Users authenticated here are automatically synced to your L4YERCAK3 backend.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
${providerImports.join('\n')}
|
|
178
|
+
import NextAuth from 'next-auth';
|
|
179
|
+
|
|
180
|
+
export default NextAuth({
|
|
181
|
+
providers: [
|
|
182
|
+
${providersCode}
|
|
183
|
+
],
|
|
184
|
+
callbacks: {
|
|
185
|
+
async signIn({ user, account, profile }) {
|
|
186
|
+
if (!account) return false;
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
// Sync user to L4YERCAK3 backend
|
|
190
|
+
const response = await fetch(\`\${process.env.NEXT_PUBLIC_L4YERCAK3_BACKEND_URL}/api/v1/auth/sync-user\`, {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
headers: {
|
|
193
|
+
'Content-Type': 'application/json',
|
|
194
|
+
'Authorization': \`Bearer \${process.env.L4YERCAK3_API_KEY}\`,
|
|
195
|
+
},
|
|
196
|
+
body: JSON.stringify({
|
|
197
|
+
email: user.email,
|
|
198
|
+
name: user.name,
|
|
199
|
+
image: user.image,
|
|
200
|
+
provider: account.provider,
|
|
201
|
+
providerAccountId: account.providerAccountId,
|
|
202
|
+
accessToken: account.access_token,
|
|
203
|
+
refreshToken: account.refresh_token,
|
|
204
|
+
expiresAt: account.expires_at,
|
|
205
|
+
}),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
if (!response.ok) {
|
|
209
|
+
console.error('Failed to sync user to backend:', await response.text());
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const backendUser = await response.json();
|
|
214
|
+
|
|
215
|
+
// Add backend user ID to session
|
|
216
|
+
user.id = backendUser.userId;
|
|
217
|
+
user.organizationId = backendUser.organizationId;
|
|
218
|
+
|
|
219
|
+
return true;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.error('Error syncing user to backend:', error);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
async session({ session, user }) {
|
|
226
|
+
if (session.user) {
|
|
227
|
+
session.user.id = user.id;
|
|
228
|
+
session.user.organizationId = user.organizationId;
|
|
229
|
+
}
|
|
230
|
+
return session;
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
pages: {
|
|
234
|
+
signIn: '/auth/signin',
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
module.exports = new NextAuthGenerator();
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Setup Guide Generator
|
|
3
|
+
* Generates OAuth setup guide markdown file
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
class OAuthGuideGenerator {
|
|
10
|
+
/**
|
|
11
|
+
* Generate OAuth setup guide
|
|
12
|
+
*/
|
|
13
|
+
generate(options) {
|
|
14
|
+
const {
|
|
15
|
+
projectPath,
|
|
16
|
+
oauthProviders,
|
|
17
|
+
productionDomain,
|
|
18
|
+
appName,
|
|
19
|
+
} = options;
|
|
20
|
+
|
|
21
|
+
const guidePath = path.join(projectPath, 'OAUTH_SETUP_GUIDE.md');
|
|
22
|
+
const content = this.generateGuide({
|
|
23
|
+
oauthProviders,
|
|
24
|
+
productionDomain,
|
|
25
|
+
appName,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
fs.writeFileSync(guidePath, content, 'utf8');
|
|
29
|
+
return guidePath;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generate guide content
|
|
34
|
+
*/
|
|
35
|
+
generateGuide({ oauthProviders, productionDomain, appName }) {
|
|
36
|
+
const hasGoogle = oauthProviders.includes('google');
|
|
37
|
+
const hasMicrosoft = oauthProviders.includes('microsoft');
|
|
38
|
+
const hasGitHub = oauthProviders.includes('github');
|
|
39
|
+
|
|
40
|
+
let content = `# 🔐 OAuth Authentication Setup Guide
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
|
|
44
|
+
This guide will walk you through setting up OAuth authentication for your frontend application. You'll need to create OAuth apps with each provider and add the credentials to your \`.env.local\` file.
|
|
45
|
+
|
|
46
|
+
**Estimated Time:** 15-20 minutes per provider
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ✅ Setup Checklist
|
|
51
|
+
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
if (hasGoogle) content += `- [ ] Google OAuth setup\n`;
|
|
55
|
+
if (hasMicrosoft) content += `- [ ] Microsoft OAuth setup\n`;
|
|
56
|
+
if (hasGitHub) content += `- [ ] GitHub OAuth setup\n`;
|
|
57
|
+
|
|
58
|
+
content += `\n---\n\n`;
|
|
59
|
+
|
|
60
|
+
// Google OAuth section
|
|
61
|
+
if (hasGoogle) {
|
|
62
|
+
content += `## 1. Google OAuth Setup
|
|
63
|
+
|
|
64
|
+
### Step 1: Go to Google Cloud Console
|
|
65
|
+
|
|
66
|
+
1. Navigate to: https://console.cloud.google.com/
|
|
67
|
+
2. Select your project or create a new one
|
|
68
|
+
|
|
69
|
+
### Step 2: Enable Google+ API
|
|
70
|
+
|
|
71
|
+
1. Go to "APIs & Services" → "Enable APIs and Services"
|
|
72
|
+
2. Search for "Google+ API" and enable it
|
|
73
|
+
|
|
74
|
+
### Step 3: Create OAuth Client ID
|
|
75
|
+
|
|
76
|
+
1. Go to "APIs & Services" → "Credentials"
|
|
77
|
+
2. Click "Create Credentials" → "OAuth client ID"
|
|
78
|
+
3. Application type: **Web application**
|
|
79
|
+
4. Name: \`${appName || 'Your App'} - Frontend\`
|
|
80
|
+
|
|
81
|
+
### Step 4: Configure Redirect URIs
|
|
82
|
+
|
|
83
|
+
Add these redirect URIs:
|
|
84
|
+
|
|
85
|
+
**Production:**
|
|
86
|
+
\`\`\`
|
|
87
|
+
https://${productionDomain || 'your-domain.com'}/api/auth/callback/google
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
**Development:**
|
|
91
|
+
\`\`\`
|
|
92
|
+
http://localhost:3000/api/auth/callback/google
|
|
93
|
+
\`\`\`
|
|
94
|
+
|
|
95
|
+
### Step 5: Save Credentials
|
|
96
|
+
|
|
97
|
+
1. Copy the **Client ID** and **Client Secret**
|
|
98
|
+
2. Add them to your \`.env.local\` file (see below)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Microsoft OAuth section
|
|
106
|
+
if (hasMicrosoft) {
|
|
107
|
+
content += `## ${hasGoogle ? '2' : '1'}. Microsoft Entra ID (Azure AD) Setup
|
|
108
|
+
|
|
109
|
+
### Step 1: Go to Azure Portal
|
|
110
|
+
|
|
111
|
+
1. Navigate to: https://portal.azure.com/
|
|
112
|
+
2. Go to "Microsoft Entra ID" (formerly Azure AD)
|
|
113
|
+
|
|
114
|
+
### Step 2: Register Application
|
|
115
|
+
|
|
116
|
+
1. Go to "App registrations" → "New registration"
|
|
117
|
+
2. Name: \`${appName || 'Your App'} - Frontend\`
|
|
118
|
+
3. Supported account types: Choose based on your needs
|
|
119
|
+
4. Redirect URI: **Web**
|
|
120
|
+
|
|
121
|
+
### Step 3: Configure Redirect URIs
|
|
122
|
+
|
|
123
|
+
Add these redirect URIs:
|
|
124
|
+
|
|
125
|
+
**Production:**
|
|
126
|
+
\`\`\`
|
|
127
|
+
https://${productionDomain || 'your-domain.com'}/api/auth/callback/azure-ad
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
**Development:**
|
|
131
|
+
\`\`\`
|
|
132
|
+
http://localhost:3000/api/auth/callback/azure-ad
|
|
133
|
+
\`\`\`
|
|
134
|
+
|
|
135
|
+
### Step 4: Create Client Secret
|
|
136
|
+
|
|
137
|
+
1. Go to "Certificates & secrets" → "New client secret"
|
|
138
|
+
2. Description: \`Frontend OAuth Secret\`
|
|
139
|
+
3. Expires: Choose expiration (recommend 24 months)
|
|
140
|
+
4. Copy the **Value** (not the Secret ID) - you won't see it again!
|
|
141
|
+
|
|
142
|
+
### Step 5: Save Credentials
|
|
143
|
+
|
|
144
|
+
1. Copy the **Application (client) ID**, **Directory (tenant) ID**, and **Client Secret Value**
|
|
145
|
+
2. Add them to your \`.env.local\` file (see below)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// GitHub OAuth section
|
|
153
|
+
if (hasGitHub) {
|
|
154
|
+
const sectionNum = (hasGoogle ? 1 : 0) + (hasMicrosoft ? 1 : 0) + 1;
|
|
155
|
+
content += `## ${sectionNum}. GitHub OAuth Setup
|
|
156
|
+
|
|
157
|
+
### Step 1: Go to GitHub Developer Settings
|
|
158
|
+
|
|
159
|
+
1. Navigate to: https://github.com/settings/developers
|
|
160
|
+
2. Click "New OAuth App"
|
|
161
|
+
|
|
162
|
+
### Step 2: Create OAuth App
|
|
163
|
+
|
|
164
|
+
1. **Application name:** \`${appName || 'Your App'} - Frontend\`
|
|
165
|
+
2. **Homepage URL:** \`https://${productionDomain || 'your-domain.com'}\`
|
|
166
|
+
3. **Authorization callback URL:**
|
|
167
|
+
\`\`\`
|
|
168
|
+
https://${productionDomain || 'your-domain.com'}/api/auth/callback/github
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
### Step 3: Save Credentials
|
|
172
|
+
|
|
173
|
+
1. Copy the **Client ID**
|
|
174
|
+
2. Click "Generate a new client secret"
|
|
175
|
+
3. Copy the **Client Secret** (you won't see it again!)
|
|
176
|
+
4. Add them to your \`.env.local\` file (see below)
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
content += `## ${(hasGoogle ? 1 : 0) + (hasMicrosoft ? 1 : 0) + (hasGitHub ? 1 : 0) + 1}. Update Environment Variables
|
|
184
|
+
|
|
185
|
+
Add these to your \`.env.local\` file:
|
|
186
|
+
|
|
187
|
+
\`\`\`bash
|
|
188
|
+
`;
|
|
189
|
+
|
|
190
|
+
if (hasGoogle) {
|
|
191
|
+
content += `# Google OAuth
|
|
192
|
+
GOOGLE_CLIENT_ID=your_google_client_id_here
|
|
193
|
+
GOOGLE_CLIENT_SECRET=your_google_client_secret_here
|
|
194
|
+
|
|
195
|
+
`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (hasMicrosoft) {
|
|
199
|
+
content += `# Microsoft OAuth
|
|
200
|
+
AZURE_CLIENT_ID=your_azure_client_id_here
|
|
201
|
+
AZURE_CLIENT_SECRET=your_azure_client_secret_value_here
|
|
202
|
+
AZURE_TENANT_ID=your_azure_tenant_id_here
|
|
203
|
+
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (hasGitHub) {
|
|
208
|
+
content += `# GitHub OAuth
|
|
209
|
+
GITHUB_CLIENT_ID=your_github_client_id_here
|
|
210
|
+
GITHUB_CLIENT_SECRET=your_github_client_secret_here
|
|
211
|
+
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
content += `\`\`\`
|
|
216
|
+
|
|
217
|
+
**⚠️ Important:** Never commit \`.env.local\` to git! It's already in \`.gitignore\`.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## ${(hasGoogle ? 1 : 0) + (hasMicrosoft ? 1 : 0) + (hasGitHub ? 1 : 0) + 2}. Test Your Setup
|
|
222
|
+
|
|
223
|
+
1. Start your development server: \`npm run dev\`
|
|
224
|
+
2. Navigate to: \`http://localhost:3000/auth/signin\`
|
|
225
|
+
3. Try signing in with each provider
|
|
226
|
+
4. Verify that users are created in your backend
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Troubleshooting
|
|
231
|
+
|
|
232
|
+
### Redirect URI Mismatch
|
|
233
|
+
|
|
234
|
+
**Error:** "Redirect URI mismatch"
|
|
235
|
+
|
|
236
|
+
**Solution:** Make sure the redirect URI in your OAuth app matches exactly:
|
|
237
|
+
- Check for trailing slashes
|
|
238
|
+
- Check http vs https
|
|
239
|
+
- Check localhost vs 127.0.0.1
|
|
240
|
+
|
|
241
|
+
### Invalid Client Secret
|
|
242
|
+
|
|
243
|
+
**Error:** "Invalid client secret"
|
|
244
|
+
|
|
245
|
+
**Solution:**
|
|
246
|
+
- Make sure you copied the **Value** (not Secret ID) for Azure
|
|
247
|
+
- Regenerate the secret if needed
|
|
248
|
+
- Restart your dev server after updating \`.env.local\`
|
|
249
|
+
|
|
250
|
+
### Provider Not Found
|
|
251
|
+
|
|
252
|
+
**Error:** "Provider not found"
|
|
253
|
+
|
|
254
|
+
**Solution:**
|
|
255
|
+
- Check that the provider is configured in \`app/api/auth/[...nextauth]/route.ts\` (or \`pages/api/auth/[...nextauth].ts\`)
|
|
256
|
+
- Verify environment variables are set correctly
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Next Steps
|
|
261
|
+
|
|
262
|
+
Once OAuth is set up:
|
|
263
|
+
1. ✅ Users can sign in with their Google/Microsoft/GitHub accounts
|
|
264
|
+
2. ✅ User accounts are automatically created in your backend
|
|
265
|
+
3. ✅ Users are linked to CRM contacts
|
|
266
|
+
4. ✅ You can use protected routes and API calls
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
**Need Help?** Check the [L4YERCAK3 Documentation](https://docs.l4yercak3.com) or contact support.
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
return content;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
module.exports = new OAuthGuideGenerator();
|
package/src/logo.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Logo display module
|
|
5
|
+
* Shows the L4YERCAK3 logo with 3D font and rainbow gradient
|
|
6
|
+
* Combined with building/plumbing metaphor
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const chalk = require('chalk');
|
|
10
|
+
const figlet = require('figlet');
|
|
11
|
+
|
|
12
|
+
// Rainbow gradient colors
|
|
13
|
+
const rainbow = [
|
|
14
|
+
'#FF1493', '#FF69B4', '#FF00FF', '#9F7AEA',
|
|
15
|
+
'#8B5CF6', '#3B82F6', '#00BFFF', '#10B981',
|
|
16
|
+
'#F59E0B', '#EF4444', '#FF6B6B'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// Helper function for character-by-character gradient
|
|
20
|
+
function applyCharGradient(line, colors) {
|
|
21
|
+
let result = '';
|
|
22
|
+
for (let i = 0; i < line.length; i++) {
|
|
23
|
+
const colorIndex = Math.min(
|
|
24
|
+
Math.floor((i / line.length) * colors.length),
|
|
25
|
+
colors.length - 1
|
|
26
|
+
);
|
|
27
|
+
result += chalk.hex(colors[colorIndex])(line[i]);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Building/plumbing metaphor
|
|
33
|
+
const buildingMetaphor = [
|
|
34
|
+
" ",
|
|
35
|
+
" ╔═══════════════════════════╗ ",
|
|
36
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Floor 5: Landing Page ",
|
|
37
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ mywebsite.com ",
|
|
38
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ",
|
|
39
|
+
" ╠═══════════════════════════╣ ",
|
|
40
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Floor 4: Client Portal ",
|
|
41
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ clients.mysite.com ",
|
|
42
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ",
|
|
43
|
+
" ╠═══════════════════════════╣ ",
|
|
44
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Floor 3: Mobile App ",
|
|
45
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ iOS + Android ",
|
|
46
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ",
|
|
47
|
+
" ╠═══════════════════════════╣ ",
|
|
48
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Floor 2: E-Commerce ",
|
|
49
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ shop.mysite.com ",
|
|
50
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ",
|
|
51
|
+
" ╠═══════════════════════════╣ ",
|
|
52
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Floor 1: Analytics ",
|
|
53
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ admin.mysite.com ",
|
|
54
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ",
|
|
55
|
+
" ╠═══════════════════════════╣ ",
|
|
56
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ ← Ground: API Layer ",
|
|
57
|
+
" ║▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓║ REST • GraphQL • gRPC ",
|
|
58
|
+
" ╚═══════════════════════════╝ ",
|
|
59
|
+
" │ │ │ │ │ │ │ │ │ │ │ ",
|
|
60
|
+
" │ │ │ │ │ │ │ │ │ │ │ ",
|
|
61
|
+
" │ │ │ │ │ │ │ │ │ │ │ ",
|
|
62
|
+
" ╔═══════════════════════════════════════════════════════════════════════════════════════╗ ",
|
|
63
|
+
" ║ ║ ",
|
|
64
|
+
" ║ 💾 Database 🔐 Auth 💳 Stripe 📧 Email 🔄 Workflows 📇 CRM 📊 Analytics 🔔 ║ ",
|
|
65
|
+
" ║ ║ ",
|
|
66
|
+
" ║ 🏗️ THE PLUMBING - l4yercak3 PLATFORM 🏗️ ║ ",
|
|
67
|
+
" ║ ║ ",
|
|
68
|
+
" ╚═══════════════════════════════════════════════════════════════════════════════════════╝ ",
|
|
69
|
+
" ",
|
|
70
|
+
" 🍰 icing on the l4yercak3 - connect your floors to the plumbing 🍰 ",
|
|
71
|
+
" "
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Display the L4YERCAK3 logo with 3D font and rainbow gradient
|
|
76
|
+
* @param {boolean} showBuilding - Whether to show the building metaphor below
|
|
77
|
+
*/
|
|
78
|
+
function showLogo(showBuilding = true) {
|
|
79
|
+
// Generate ASCII art with figlet using 3D-ASCII font
|
|
80
|
+
const logoText = figlet.textSync('L4YERCAK3', {
|
|
81
|
+
font: '3D-ASCII',
|
|
82
|
+
horizontalLayout: 'default',
|
|
83
|
+
verticalLayout: 'default'
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const logoLines = logoText.split('\n');
|
|
87
|
+
|
|
88
|
+
// Print logo with rainbow gradient
|
|
89
|
+
logoLines.forEach((line) => {
|
|
90
|
+
console.log(applyCharGradient(line, rainbow));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log(''); // spacing
|
|
94
|
+
|
|
95
|
+
// Print building metaphor if requested
|
|
96
|
+
if (showBuilding) {
|
|
97
|
+
buildingMetaphor.forEach((line, i) => {
|
|
98
|
+
if (i >= 1 && i < 23) {
|
|
99
|
+
// Floors - blue gradient
|
|
100
|
+
console.log(applyCharGradient(line, ['#3B82F6', '#60A5FA', '#93C5FD', '#DBEAFE']));
|
|
101
|
+
} else if (i >= 25 && i < 31) {
|
|
102
|
+
// Foundation box - rainbow gradient
|
|
103
|
+
console.log(applyCharGradient(line, rainbow));
|
|
104
|
+
} else {
|
|
105
|
+
console.log(applyCharGradient(line, rainbow));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log(''); // final spacing
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
showLogo,
|
|
115
|
+
rainbow
|
|
116
|
+
};
|