@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.
Files changed (61) hide show
  1. package/.claude/settings.local.json +18 -0
  2. package/.cursor/rules.md +203 -0
  3. package/.eslintrc.js +31 -0
  4. package/README.md +227 -0
  5. package/bin/cli.js +61 -0
  6. package/docs/ADDING_NEW_PROJECT_TYPE.md +156 -0
  7. package/docs/ARCHITECTURE_RELATIONSHIPS.md +411 -0
  8. package/docs/CLI_AUTHENTICATION.md +214 -0
  9. package/docs/DETECTOR_ARCHITECTURE.md +326 -0
  10. package/docs/DEVELOPMENT.md +194 -0
  11. package/docs/IMPLEMENTATION_PHASES.md +468 -0
  12. package/docs/OAUTH_CLARIFICATION.md +258 -0
  13. package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +211 -0
  14. package/docs/PHASE_0_PROGRESS.md +120 -0
  15. package/docs/PHASE_1_COMPLETE.md +366 -0
  16. package/docs/PHASE_SUMMARY.md +149 -0
  17. package/docs/PLAN.md +511 -0
  18. package/docs/README.md +56 -0
  19. package/docs/STRIPE_INTEGRATION.md +447 -0
  20. package/docs/SUMMARY.md +230 -0
  21. package/docs/UPDATED_PLAN.md +447 -0
  22. package/package.json +53 -0
  23. package/src/api/backend-client.js +148 -0
  24. package/src/commands/login.js +146 -0
  25. package/src/commands/logout.js +24 -0
  26. package/src/commands/spread.js +364 -0
  27. package/src/commands/status.js +62 -0
  28. package/src/config/config-manager.js +205 -0
  29. package/src/detectors/api-client-detector.js +85 -0
  30. package/src/detectors/base-detector.js +77 -0
  31. package/src/detectors/github-detector.js +74 -0
  32. package/src/detectors/index.js +80 -0
  33. package/src/detectors/nextjs-detector.js +139 -0
  34. package/src/detectors/oauth-detector.js +122 -0
  35. package/src/detectors/registry.js +97 -0
  36. package/src/generators/api-client-generator.js +197 -0
  37. package/src/generators/env-generator.js +162 -0
  38. package/src/generators/gitignore-generator.js +92 -0
  39. package/src/generators/index.js +50 -0
  40. package/src/generators/nextauth-generator.js +242 -0
  41. package/src/generators/oauth-guide-generator.js +277 -0
  42. package/src/logo.js +116 -0
  43. package/tests/api-client-detector.test.js +214 -0
  44. package/tests/api-client-generator.test.js +169 -0
  45. package/tests/backend-client.test.js +361 -0
  46. package/tests/base-detector.test.js +101 -0
  47. package/tests/commands/login.test.js +98 -0
  48. package/tests/commands/logout.test.js +70 -0
  49. package/tests/commands/status.test.js +167 -0
  50. package/tests/config-manager.test.js +313 -0
  51. package/tests/detector-index.test.js +209 -0
  52. package/tests/detector-registry.test.js +93 -0
  53. package/tests/env-generator.test.js +278 -0
  54. package/tests/generators-index.test.js +215 -0
  55. package/tests/github-detector.test.js +145 -0
  56. package/tests/gitignore-generator.test.js +109 -0
  57. package/tests/logo.test.js +96 -0
  58. package/tests/nextauth-generator.test.js +231 -0
  59. package/tests/nextjs-detector.test.js +235 -0
  60. package/tests/oauth-detector.test.js +264 -0
  61. package/tests/oauth-guide-generator.test.js +273 -0
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Tests for OAuth Guide Generator
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ jest.mock('fs');
9
+
10
+ const OAuthGuideGenerator = require('../src/generators/oauth-guide-generator');
11
+
12
+ describe('OAuthGuideGenerator', () => {
13
+ const mockProjectPath = '/test/project';
14
+ const mockGuidePath = path.join(mockProjectPath, 'OAUTH_SETUP_GUIDE.md');
15
+
16
+ beforeEach(() => {
17
+ jest.clearAllMocks();
18
+ fs.writeFileSync.mockReturnValue(undefined);
19
+ });
20
+
21
+ describe('generate', () => {
22
+ it('creates OAUTH_SETUP_GUIDE.md in project root', () => {
23
+ const options = {
24
+ projectPath: mockProjectPath,
25
+ oauthProviders: ['google'],
26
+ productionDomain: 'example.com',
27
+ appName: 'Test App',
28
+ };
29
+
30
+ const result = OAuthGuideGenerator.generate(options);
31
+
32
+ expect(result).toBe(mockGuidePath);
33
+ expect(fs.writeFileSync).toHaveBeenCalledWith(
34
+ mockGuidePath,
35
+ expect.any(String),
36
+ 'utf8'
37
+ );
38
+ });
39
+ });
40
+
41
+ describe('generateGuide', () => {
42
+ describe('header and overview', () => {
43
+ it('includes title and overview', () => {
44
+ const guide = OAuthGuideGenerator.generateGuide({
45
+ oauthProviders: ['google'],
46
+ productionDomain: 'example.com',
47
+ appName: 'Test App',
48
+ });
49
+
50
+ expect(guide).toContain('# 🔐 OAuth Authentication Setup Guide');
51
+ expect(guide).toContain('## Overview');
52
+ expect(guide).toContain('Estimated Time');
53
+ });
54
+
55
+ it('includes checklist for selected providers', () => {
56
+ const guide = OAuthGuideGenerator.generateGuide({
57
+ oauthProviders: ['google', 'microsoft', 'github'],
58
+ productionDomain: 'example.com',
59
+ appName: 'Test App',
60
+ });
61
+
62
+ expect(guide).toContain('- [ ] Google OAuth setup');
63
+ expect(guide).toContain('- [ ] Microsoft OAuth setup');
64
+ expect(guide).toContain('- [ ] GitHub OAuth setup');
65
+ });
66
+
67
+ it('only includes checklist items for selected providers', () => {
68
+ const guide = OAuthGuideGenerator.generateGuide({
69
+ oauthProviders: ['google'],
70
+ productionDomain: 'example.com',
71
+ appName: 'Test App',
72
+ });
73
+
74
+ expect(guide).toContain('- [ ] Google OAuth setup');
75
+ expect(guide).not.toContain('- [ ] Microsoft OAuth setup');
76
+ expect(guide).not.toContain('- [ ] GitHub OAuth setup');
77
+ });
78
+ });
79
+
80
+ describe('Google OAuth section', () => {
81
+ it('includes Google setup instructions', () => {
82
+ const guide = OAuthGuideGenerator.generateGuide({
83
+ oauthProviders: ['google'],
84
+ productionDomain: 'example.com',
85
+ appName: 'My App',
86
+ });
87
+
88
+ expect(guide).toContain('## 1. Google OAuth Setup');
89
+ expect(guide).toContain('https://console.cloud.google.com/');
90
+ expect(guide).toContain('Google+ API');
91
+ expect(guide).toContain('My App - Frontend');
92
+ });
93
+
94
+ it('includes correct redirect URIs', () => {
95
+ const guide = OAuthGuideGenerator.generateGuide({
96
+ oauthProviders: ['google'],
97
+ productionDomain: 'myapp.com',
98
+ appName: 'Test',
99
+ });
100
+
101
+ expect(guide).toContain('https://myapp.com/api/auth/callback/google');
102
+ expect(guide).toContain('http://localhost:3000/api/auth/callback/google');
103
+ });
104
+
105
+ it('uses placeholder when no domain provided', () => {
106
+ const guide = OAuthGuideGenerator.generateGuide({
107
+ oauthProviders: ['google'],
108
+ productionDomain: undefined,
109
+ appName: undefined,
110
+ });
111
+
112
+ expect(guide).toContain('your-domain.com');
113
+ expect(guide).toContain('Your App');
114
+ });
115
+ });
116
+
117
+ describe('Microsoft OAuth section', () => {
118
+ it('includes Microsoft/Azure setup instructions', () => {
119
+ const guide = OAuthGuideGenerator.generateGuide({
120
+ oauthProviders: ['microsoft'],
121
+ productionDomain: 'example.com',
122
+ appName: 'My App',
123
+ });
124
+
125
+ expect(guide).toContain('Microsoft Entra ID (Azure AD) Setup');
126
+ expect(guide).toContain('https://portal.azure.com/');
127
+ expect(guide).toContain('Certificates & secrets');
128
+ expect(guide).toContain('AZURE_TENANT_ID');
129
+ });
130
+
131
+ it('includes correct redirect URIs', () => {
132
+ const guide = OAuthGuideGenerator.generateGuide({
133
+ oauthProviders: ['microsoft'],
134
+ productionDomain: 'myapp.com',
135
+ appName: 'Test',
136
+ });
137
+
138
+ expect(guide).toContain('https://myapp.com/api/auth/callback/azure-ad');
139
+ expect(guide).toContain('http://localhost:3000/api/auth/callback/azure-ad');
140
+ });
141
+ });
142
+
143
+ describe('GitHub OAuth section', () => {
144
+ it('includes GitHub setup instructions', () => {
145
+ const guide = OAuthGuideGenerator.generateGuide({
146
+ oauthProviders: ['github'],
147
+ productionDomain: 'example.com',
148
+ appName: 'My App',
149
+ });
150
+
151
+ expect(guide).toContain('GitHub OAuth Setup');
152
+ expect(guide).toContain('https://github.com/settings/developers');
153
+ expect(guide).toContain('New OAuth App');
154
+ });
155
+
156
+ it('includes correct redirect URIs', () => {
157
+ const guide = OAuthGuideGenerator.generateGuide({
158
+ oauthProviders: ['github'],
159
+ productionDomain: 'myapp.com',
160
+ appName: 'Test',
161
+ });
162
+
163
+ expect(guide).toContain('https://myapp.com/api/auth/callback/github');
164
+ });
165
+ });
166
+
167
+ describe('section numbering', () => {
168
+ it('numbers sections correctly for single provider', () => {
169
+ const guide = OAuthGuideGenerator.generateGuide({
170
+ oauthProviders: ['github'],
171
+ productionDomain: 'example.com',
172
+ appName: 'Test',
173
+ });
174
+
175
+ expect(guide).toContain('## 1. GitHub OAuth Setup');
176
+ expect(guide).toContain('## 2. Update Environment Variables');
177
+ expect(guide).toContain('## 3. Test Your Setup');
178
+ });
179
+
180
+ it('numbers sections correctly for all providers', () => {
181
+ const guide = OAuthGuideGenerator.generateGuide({
182
+ oauthProviders: ['google', 'microsoft', 'github'],
183
+ productionDomain: 'example.com',
184
+ appName: 'Test',
185
+ });
186
+
187
+ expect(guide).toContain('## 1. Google OAuth Setup');
188
+ expect(guide).toContain('## 2. Microsoft Entra ID');
189
+ expect(guide).toContain('## 3. GitHub OAuth Setup');
190
+ expect(guide).toContain('## 4. Update Environment Variables');
191
+ expect(guide).toContain('## 5. Test Your Setup');
192
+ });
193
+ });
194
+
195
+ describe('environment variables section', () => {
196
+ it('includes Google env vars', () => {
197
+ const guide = OAuthGuideGenerator.generateGuide({
198
+ oauthProviders: ['google'],
199
+ productionDomain: 'example.com',
200
+ appName: 'Test',
201
+ });
202
+
203
+ expect(guide).toContain('# Google OAuth');
204
+ expect(guide).toContain('GOOGLE_CLIENT_ID=');
205
+ expect(guide).toContain('GOOGLE_CLIENT_SECRET=');
206
+ });
207
+
208
+ it('includes Microsoft env vars', () => {
209
+ const guide = OAuthGuideGenerator.generateGuide({
210
+ oauthProviders: ['microsoft'],
211
+ productionDomain: 'example.com',
212
+ appName: 'Test',
213
+ });
214
+
215
+ expect(guide).toContain('# Microsoft OAuth');
216
+ expect(guide).toContain('AZURE_CLIENT_ID=');
217
+ expect(guide).toContain('AZURE_CLIENT_SECRET=');
218
+ expect(guide).toContain('AZURE_TENANT_ID=');
219
+ });
220
+
221
+ it('includes GitHub env vars', () => {
222
+ const guide = OAuthGuideGenerator.generateGuide({
223
+ oauthProviders: ['github'],
224
+ productionDomain: 'example.com',
225
+ appName: 'Test',
226
+ });
227
+
228
+ expect(guide).toContain('# GitHub OAuth');
229
+ expect(guide).toContain('GITHUB_CLIENT_ID=');
230
+ expect(guide).toContain('GITHUB_CLIENT_SECRET=');
231
+ });
232
+
233
+ it('includes security warning', () => {
234
+ const guide = OAuthGuideGenerator.generateGuide({
235
+ oauthProviders: ['google'],
236
+ productionDomain: 'example.com',
237
+ appName: 'Test',
238
+ });
239
+
240
+ expect(guide).toContain('Never commit `.env.local` to git');
241
+ });
242
+ });
243
+
244
+ describe('troubleshooting section', () => {
245
+ it('includes common troubleshooting tips', () => {
246
+ const guide = OAuthGuideGenerator.generateGuide({
247
+ oauthProviders: ['google'],
248
+ productionDomain: 'example.com',
249
+ appName: 'Test',
250
+ });
251
+
252
+ expect(guide).toContain('## Troubleshooting');
253
+ expect(guide).toContain('Redirect URI Mismatch');
254
+ expect(guide).toContain('Invalid Client Secret');
255
+ expect(guide).toContain('Provider Not Found');
256
+ });
257
+ });
258
+
259
+ describe('next steps section', () => {
260
+ it('includes next steps and help link', () => {
261
+ const guide = OAuthGuideGenerator.generateGuide({
262
+ oauthProviders: ['google'],
263
+ productionDomain: 'example.com',
264
+ appName: 'Test',
265
+ });
266
+
267
+ expect(guide).toContain('## Next Steps');
268
+ expect(guide).toContain('L4YERCAK3 Documentation');
269
+ expect(guide).toContain('docs.l4yercak3.com');
270
+ });
271
+ });
272
+ });
273
+ });