@l4yercak3/cli 1.3.1 → 2.0.0-alpha.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/README.md +10 -220
- package/dist/api/client.d.ts +12 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +37 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/platform.d.ts +161 -0
- package/dist/api/platform.d.ts.map +1 -0
- package/dist/api/platform.js +70 -0
- package/dist/api/platform.js.map +1 -0
- package/dist/bin/sevenlayers.d.ts +3 -0
- package/dist/bin/sevenlayers.d.ts.map +1 -0
- package/dist/bin/sevenlayers.js +198 -0
- package/dist/bin/sevenlayers.js.map +1 -0
- package/dist/commands/agent/catalog.d.ts +5 -0
- package/dist/commands/agent/catalog.d.ts.map +1 -0
- package/dist/commands/agent/catalog.js +142 -0
- package/dist/commands/agent/catalog.js.map +1 -0
- package/dist/commands/agent/drift.d.ts +5 -0
- package/dist/commands/agent/drift.d.ts.map +1 -0
- package/dist/commands/agent/drift.js +113 -0
- package/dist/commands/agent/drift.js.map +1 -0
- package/dist/commands/agent/init.d.ts +5 -0
- package/dist/commands/agent/init.d.ts.map +1 -0
- package/dist/commands/agent/init.js +75 -0
- package/dist/commands/agent/init.js.map +1 -0
- package/dist/commands/agent/permissions.d.ts +5 -0
- package/dist/commands/agent/permissions.d.ts.map +1 -0
- package/dist/commands/agent/permissions.js +88 -0
- package/dist/commands/agent/permissions.js.map +1 -0
- package/dist/commands/agent/runner.d.ts +14 -0
- package/dist/commands/agent/runner.d.ts.map +1 -0
- package/dist/commands/agent/runner.js +59 -0
- package/dist/commands/agent/runner.js.map +1 -0
- package/dist/commands/agent/shared.d.ts +13 -0
- package/dist/commands/agent/shared.d.ts.map +1 -0
- package/dist/commands/agent/shared.js +31 -0
- package/dist/commands/agent/shared.js.map +1 -0
- package/dist/commands/agent/template.d.ts +5 -0
- package/dist/commands/agent/template.d.ts.map +1 -0
- package/dist/commands/agent/template.js +104 -0
- package/dist/commands/agent/template.js.map +1 -0
- package/dist/commands/app/connect.d.ts +7 -0
- package/dist/commands/app/connect.d.ts.map +1 -0
- package/dist/commands/app/connect.js +12 -0
- package/dist/commands/app/connect.js.map +1 -0
- package/dist/commands/app/init.d.ts +7 -0
- package/dist/commands/app/init.d.ts.map +1 -0
- package/dist/commands/app/init.js +12 -0
- package/dist/commands/app/init.js.map +1 -0
- package/dist/commands/app/link.d.ts +3 -0
- package/dist/commands/app/link.d.ts.map +1 -0
- package/dist/commands/app/link.js +92 -0
- package/dist/commands/app/link.js.map +1 -0
- package/dist/commands/app/pages.d.ts +15 -0
- package/dist/commands/app/pages.d.ts.map +1 -0
- package/dist/commands/app/pages.js +180 -0
- package/dist/commands/app/pages.js.map +1 -0
- package/dist/commands/app/register.d.ts +3 -0
- package/dist/commands/app/register.d.ts.map +1 -0
- package/dist/commands/app/register.js +120 -0
- package/dist/commands/app/register.js.map +1 -0
- package/dist/commands/app/remote.d.ts +14 -0
- package/dist/commands/app/remote.d.ts.map +1 -0
- package/dist/commands/app/remote.js +44 -0
- package/dist/commands/app/remote.js.map +1 -0
- package/dist/commands/app/setup.d.ts +3 -0
- package/dist/commands/app/setup.d.ts.map +1 -0
- package/dist/commands/app/setup.js +299 -0
- package/dist/commands/app/setup.js.map +1 -0
- package/dist/commands/app/shared.d.ts +9 -0
- package/dist/commands/app/shared.d.ts.map +1 -0
- package/dist/commands/app/shared.js +122 -0
- package/dist/commands/app/shared.js.map +1 -0
- package/dist/commands/app/sync.d.ts +7 -0
- package/dist/commands/app/sync.d.ts.map +1 -0
- package/dist/commands/app/sync.js +107 -0
- package/dist/commands/app/sync.js.map +1 -0
- package/dist/commands/booking/check.d.ts +3 -0
- package/dist/commands/booking/check.d.ts.map +1 -0
- package/dist/commands/booking/check.js +68 -0
- package/dist/commands/booking/check.js.map +1 -0
- package/dist/commands/booking/setup.d.ts +3 -0
- package/dist/commands/booking/setup.d.ts.map +1 -0
- package/dist/commands/booking/setup.js +95 -0
- package/dist/commands/booking/setup.js.map +1 -0
- package/dist/commands/booking/shared.d.ts +31 -0
- package/dist/commands/booking/shared.d.ts.map +1 -0
- package/dist/commands/booking/shared.js +112 -0
- package/dist/commands/booking/shared.js.map +1 -0
- package/dist/commands/booking/smoke.d.ts +3 -0
- package/dist/commands/booking/smoke.d.ts.map +1 -0
- package/dist/commands/booking/smoke.js +101 -0
- package/dist/commands/booking/smoke.js.map +1 -0
- package/dist/commands/cms/bind.d.ts +3 -0
- package/dist/commands/cms/bind.d.ts.map +1 -0
- package/dist/commands/cms/bind.js +212 -0
- package/dist/commands/cms/bind.js.map +1 -0
- package/dist/commands/cms/content.d.ts +40 -0
- package/dist/commands/cms/content.d.ts.map +1 -0
- package/dist/commands/cms/content.js +169 -0
- package/dist/commands/cms/content.js.map +1 -0
- package/dist/commands/cms/doctor.d.ts +3 -0
- package/dist/commands/cms/doctor.d.ts.map +1 -0
- package/dist/commands/cms/doctor.js +69 -0
- package/dist/commands/cms/doctor.js.map +1 -0
- package/dist/commands/cms/migrate.d.ts +3 -0
- package/dist/commands/cms/migrate.d.ts.map +1 -0
- package/dist/commands/cms/migrate.js +78 -0
- package/dist/commands/cms/migrate.js.map +1 -0
- package/dist/commands/cms/registry.d.ts +3 -0
- package/dist/commands/cms/registry.d.ts.map +1 -0
- package/dist/commands/cms/registry.js +161 -0
- package/dist/commands/cms/registry.js.map +1 -0
- package/dist/commands/cms/seed.d.ts +3 -0
- package/dist/commands/cms/seed.d.ts.map +1 -0
- package/dist/commands/cms/seed.js +102 -0
- package/dist/commands/cms/seed.js.map +1 -0
- package/dist/commands/cms/shared.d.ts +22 -0
- package/dist/commands/cms/shared.d.ts.map +1 -0
- package/dist/commands/cms/shared.js +82 -0
- package/dist/commands/cms/shared.js.map +1 -0
- package/dist/commands/doctor/target.d.ts +3 -0
- package/dist/commands/doctor/target.d.ts.map +1 -0
- package/dist/commands/doctor/target.js +46 -0
- package/dist/commands/doctor/target.js.map +1 -0
- package/dist/commands/env/list.d.ts +3 -0
- package/dist/commands/env/list.d.ts.map +1 -0
- package/dist/commands/env/list.js +28 -0
- package/dist/commands/env/list.js.map +1 -0
- package/dist/commands/env/set.d.ts +3 -0
- package/dist/commands/env/set.d.ts.map +1 -0
- package/dist/commands/env/set.js +36 -0
- package/dist/commands/env/set.js.map +1 -0
- package/dist/commands/env/use.d.ts +3 -0
- package/dist/commands/env/use.d.ts.map +1 -0
- package/dist/commands/env/use.js +15 -0
- package/dist/commands/env/use.js.map +1 -0
- package/dist/commands/legacy/connect.d.ts +3 -0
- package/dist/commands/legacy/connect.d.ts.map +1 -0
- package/dist/commands/legacy/connect.js +8 -0
- package/dist/commands/legacy/connect.js.map +1 -0
- package/dist/commands/legacy/pages.d.ts +3 -0
- package/dist/commands/legacy/pages.d.ts.map +1 -0
- package/dist/commands/legacy/pages.js +16 -0
- package/dist/commands/legacy/pages.js.map +1 -0
- package/dist/commands/legacy/spread.d.ts +3 -0
- package/dist/commands/legacy/spread.d.ts.map +1 -0
- package/dist/commands/legacy/spread.js +8 -0
- package/dist/commands/legacy/spread.js.map +1 -0
- package/dist/commands/legacy/sync.d.ts +3 -0
- package/dist/commands/legacy/sync.d.ts.map +1 -0
- package/dist/commands/legacy/sync.js +8 -0
- package/dist/commands/legacy/sync.js.map +1 -0
- package/dist/config/env-diff.d.ts +10 -0
- package/dist/config/env-diff.d.ts.map +1 -0
- package/dist/config/env-diff.js +24 -0
- package/dist/config/env-diff.js.map +1 -0
- package/dist/config/env-parser.d.ts +20 -0
- package/dist/config/env-parser.d.ts.map +1 -0
- package/dist/config/env-parser.js +70 -0
- package/dist/config/env-parser.js.map +1 -0
- package/dist/config/env-writer.d.ts +22 -0
- package/dist/config/env-writer.d.ts.map +1 -0
- package/dist/config/env-writer.js +172 -0
- package/dist/config/env-writer.js.map +1 -0
- package/dist/config/profile-store.d.ts +29 -0
- package/dist/config/profile-store.d.ts.map +1 -0
- package/dist/config/profile-store.js +257 -0
- package/dist/config/profile-store.js.map +1 -0
- package/dist/core/args.d.ts +11 -0
- package/dist/core/args.d.ts.map +1 -0
- package/dist/core/args.js +106 -0
- package/dist/core/args.js.map +1 -0
- package/dist/core/colors.d.ts +6 -0
- package/dist/core/colors.d.ts.map +1 -0
- package/dist/core/colors.js +29 -0
- package/dist/core/colors.js.map +1 -0
- package/dist/safety/target-guard.d.ts +16 -0
- package/dist/safety/target-guard.d.ts.map +1 -0
- package/dist/safety/target-guard.js +55 -0
- package/dist/safety/target-guard.js.map +1 -0
- package/dist/testing/booking-smoke.d.ts +17 -0
- package/dist/testing/booking-smoke.d.ts.map +1 -0
- package/dist/testing/booking-smoke.js +43 -0
- package/dist/testing/booking-smoke.js.map +1 -0
- package/dist/tests/agent-commands.test.d.ts +2 -0
- package/dist/tests/agent-commands.test.d.ts.map +1 -0
- package/dist/tests/agent-commands.test.js +180 -0
- package/dist/tests/agent-commands.test.js.map +1 -0
- package/dist/tests/agent-governance.test.d.ts +2 -0
- package/dist/tests/agent-governance.test.d.ts.map +1 -0
- package/dist/tests/agent-governance.test.js +233 -0
- package/dist/tests/agent-governance.test.js.map +1 -0
- package/dist/tests/app-commands.test.d.ts +2 -0
- package/dist/tests/app-commands.test.d.ts.map +1 -0
- package/dist/tests/app-commands.test.js +462 -0
- package/dist/tests/app-commands.test.js.map +1 -0
- package/dist/tests/booking-commands.test.d.ts +2 -0
- package/dist/tests/booking-commands.test.d.ts.map +1 -0
- package/dist/tests/booking-commands.test.js +204 -0
- package/dist/tests/booking-commands.test.js.map +1 -0
- package/dist/tests/booking-smoke.test.d.ts +2 -0
- package/dist/tests/booking-smoke.test.d.ts.map +1 -0
- package/dist/tests/booking-smoke.test.js +183 -0
- package/dist/tests/booking-smoke.test.js.map +1 -0
- package/dist/tests/cms-commands.test.d.ts +2 -0
- package/dist/tests/cms-commands.test.d.ts.map +1 -0
- package/dist/tests/cms-commands.test.js +254 -0
- package/dist/tests/cms-commands.test.js.map +1 -0
- package/dist/tests/cms-ops.test.d.ts +2 -0
- package/dist/tests/cms-ops.test.d.ts.map +1 -0
- package/dist/tests/cms-ops.test.js +125 -0
- package/dist/tests/cms-ops.test.js.map +1 -0
- package/dist/tests/env-writer.test.d.ts +2 -0
- package/dist/tests/env-writer.test.d.ts.map +1 -0
- package/dist/tests/env-writer.test.js +90 -0
- package/dist/tests/env-writer.test.js.map +1 -0
- package/dist/tests/profile-store.test.d.ts +2 -0
- package/dist/tests/profile-store.test.d.ts.map +1 -0
- package/dist/tests/profile-store.test.js +88 -0
- package/dist/tests/profile-store.test.js.map +1 -0
- package/dist/tests/target-guard.test.d.ts +2 -0
- package/dist/tests/target-guard.test.d.ts.map +1 -0
- package/dist/tests/target-guard.test.js +132 -0
- package/dist/tests/target-guard.test.js.map +1 -0
- package/dist/ui/logo.d.ts +2 -0
- package/dist/ui/logo.d.ts.map +1 -0
- package/dist/ui/logo.js +22 -0
- package/dist/ui/logo.js.map +1 -0
- package/package.json +17 -53
- package/.claude/settings.local.json +0 -36
- package/.cursor/rules.md +0 -203
- package/.eslintrc.js +0 -31
- package/CLAUDE.md +0 -100
- package/bin/cli.js +0 -116
- package/docs/ADDING_FRAMEWORK_DETECTORS.md +0 -391
- package/docs/ADDING_NEW_PROJECT_TYPE.md +0 -156
- package/docs/ARCHITECTURE_RELATIONSHIPS.md +0 -411
- package/docs/CLI_AUTHENTICATION.md +0 -214
- package/docs/CLI_PAGE_DETECTION_REQUIREMENTS.md +0 -519
- package/docs/CRM-PIPELINES-SEQUENCES-SPEC.md +0 -429
- package/docs/DETECTOR_ARCHITECTURE.md +0 -326
- package/docs/DEVELOPMENT.md +0 -194
- package/docs/IMPLEMENTATION_PHASES.md +0 -468
- package/docs/INTEGRATION_PATHS_ARCHITECTURE.md +0 -1543
- package/docs/OAUTH_CLARIFICATION.md +0 -258
- package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +0 -211
- package/docs/PHASE_0_PROGRESS.md +0 -120
- package/docs/PHASE_1_COMPLETE.md +0 -366
- package/docs/PHASE_SUMMARY.md +0 -149
- package/docs/PLAN.md +0 -511
- package/docs/README.md +0 -56
- package/docs/STRIPE_INTEGRATION.md +0 -447
- package/docs/SUMMARY.md +0 -230
- package/docs/UPDATED_PLAN.md +0 -447
- package/docs/mcp_server/MCP_EXTENSION_GUIDE.md +0 -1313
- package/docs/mcp_server/MCP_SERVER_ARCHITECTURE.md +0 -1481
- package/docs/mcp_server/applicationOntology.ts +0 -817
- package/docs/mcp_server/cliApplications.ts +0 -639
- package/docs/mcp_server/crmOntology.ts +0 -1063
- package/docs/mcp_server/eventOntology.ts +0 -1183
- package/docs/mcp_server/formsOntology.ts +0 -1401
- package/docs/mcp_server/ontologySchemas.ts +0 -185
- package/docs/mcp_server/schema.ts +0 -250
- package/docs/microsass_production_machine/CLI_API_REFERENCE.md +0 -1197
- package/docs/microsass_production_machine/CLI_PRODUCT_VISION.md +0 -676
- package/docs/microsass_production_machine/CLI_REQUIREMENTS.md +0 -606
- package/docs/microsass_production_machine/CONNECTED_APPLICATIONS_SPEC.md +0 -390
- package/docs/microsass_production_machine/IMPLEMENTATION_ROADMAP.md +0 -725
- package/docs/microsass_production_machine/OBJECT_MAPPINGS.md +0 -808
- package/docs/microsass_production_machine/REFERENCE_IMPLEMENTATION.md +0 -532
- package/src/api/backend-client.js +0 -449
- package/src/commands/api-keys.js +0 -119
- package/src/commands/connect.js +0 -243
- package/src/commands/login.js +0 -332
- package/src/commands/logout.js +0 -30
- package/src/commands/mcp-server.js +0 -85
- package/src/commands/mcp-setup.js +0 -686
- package/src/commands/pages.js +0 -317
- package/src/commands/scaffold.js +0 -409
- package/src/commands/spread.js +0 -861
- package/src/commands/status.js +0 -62
- package/src/commands/sync.js +0 -169
- package/src/commands/upgrade.js +0 -48
- package/src/config/config-manager.js +0 -206
- package/src/detectors/api-client-detector.js +0 -85
- package/src/detectors/base-detector.js +0 -77
- package/src/detectors/database-detector.js +0 -245
- package/src/detectors/expo-detector.js +0 -166
- package/src/detectors/github-detector.js +0 -74
- package/src/detectors/index.js +0 -106
- package/src/detectors/mapping-suggestor.js +0 -119
- package/src/detectors/model-detector.js +0 -318
- package/src/detectors/nextjs-detector.js +0 -139
- package/src/detectors/oauth-detector.js +0 -122
- package/src/detectors/page-detector.js +0 -480
- package/src/detectors/registry.js +0 -121
- package/src/generators/api-client-generator.js +0 -223
- package/src/generators/api-only/client.js +0 -683
- package/src/generators/api-only/index.js +0 -96
- package/src/generators/api-only/types.js +0 -618
- package/src/generators/api-only/webhooks.js +0 -377
- package/src/generators/env-generator.js +0 -191
- package/src/generators/expo-auth-generator.js +0 -1009
- package/src/generators/gitignore-generator.js +0 -92
- package/src/generators/index.js +0 -166
- package/src/generators/manifest-generator.js +0 -154
- package/src/generators/mcp-guide-generator.js +0 -256
- package/src/generators/nextauth-generator.js +0 -247
- package/src/generators/oauth-guide-generator.js +0 -277
- package/src/generators/quickstart/components/index.js +0 -1699
- package/src/generators/quickstart/components-mobile/index.js +0 -1440
- package/src/generators/quickstart/database/convex.js +0 -1257
- package/src/generators/quickstart/database/index.js +0 -34
- package/src/generators/quickstart/database/supabase.js +0 -1132
- package/src/generators/quickstart/hooks/index.js +0 -1065
- package/src/generators/quickstart/index.js +0 -191
- package/src/generators/quickstart/pages/index.js +0 -1466
- package/src/generators/quickstart/screens/index.js +0 -1498
- package/src/logo.js +0 -116
- package/src/mcp/auth.js +0 -127
- package/src/mcp/registry/domains/applications.js +0 -516
- package/src/mcp/registry/domains/benefits.js +0 -798
- package/src/mcp/registry/domains/codegen.js +0 -894
- package/src/mcp/registry/domains/core.js +0 -324
- package/src/mcp/registry/domains/crm.js +0 -591
- package/src/mcp/registry/domains/events.js +0 -649
- package/src/mcp/registry/domains/forms.js +0 -696
- package/src/mcp/registry/index.js +0 -164
- package/src/mcp/server.js +0 -116
- package/src/utils/file-utils.js +0 -117
- package/src/utils/init-helpers.js +0 -243
- package/src/utils/prompt-utils.js +0 -195
- package/templates/CLAUDE.md +0 -86
- package/tests/api-client-detector.test.js +0 -214
- package/tests/api-client-generator.test.js +0 -176
- package/tests/backend-client.test.js +0 -640
- package/tests/base-detector.test.js +0 -101
- package/tests/commands/login.test.js +0 -143
- package/tests/commands/logout.test.js +0 -84
- package/tests/commands/status.test.js +0 -167
- package/tests/config-manager.test.js +0 -321
- package/tests/database-detector.test.js +0 -221
- package/tests/detector-index.test.js +0 -209
- package/tests/detector-registry.test.js +0 -93
- package/tests/env-generator.test.js +0 -278
- package/tests/expo-detector.test.js +0 -263
- package/tests/file-utils.test.js +0 -194
- package/tests/generators-index.test.js +0 -454
- package/tests/github-detector.test.js +0 -145
- package/tests/gitignore-generator.test.js +0 -109
- package/tests/logo.test.js +0 -96
- package/tests/nextauth-generator.test.js +0 -255
- package/tests/nextjs-detector.test.js +0 -235
- package/tests/oauth-detector.test.js +0 -264
- package/tests/oauth-guide-generator.test.js +0 -273
- package/tests/page-detector.test.js +0 -371
|
@@ -1,247 +0,0 @@
|
|
|
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
|
-
const { checkFileOverwrite, writeFileWithBackup, ensureDir } = require('../utils/file-utils');
|
|
9
|
-
|
|
10
|
-
class NextAuthGenerator {
|
|
11
|
-
/**
|
|
12
|
-
* Generate NextAuth.js configuration
|
|
13
|
-
* @param {Object} options - Generation options
|
|
14
|
-
* @returns {Promise<string|null>} - Path to generated file or null if skipped
|
|
15
|
-
*/
|
|
16
|
-
async generate(options) {
|
|
17
|
-
const {
|
|
18
|
-
projectPath,
|
|
19
|
-
backendUrl,
|
|
20
|
-
oauthProviders,
|
|
21
|
-
routerType,
|
|
22
|
-
isTypeScript,
|
|
23
|
-
} = options;
|
|
24
|
-
|
|
25
|
-
// Determine API route path based on router type
|
|
26
|
-
const apiDir = routerType === 'app'
|
|
27
|
-
? path.join(projectPath, 'app', 'api', 'auth')
|
|
28
|
-
: path.join(projectPath, 'pages', 'api', 'auth');
|
|
29
|
-
|
|
30
|
-
// Ensure directory exists
|
|
31
|
-
ensureDir(apiDir);
|
|
32
|
-
|
|
33
|
-
const extension = isTypeScript ? 'ts' : 'js';
|
|
34
|
-
const routePath = routerType === 'app'
|
|
35
|
-
? path.join(apiDir, `[...nextauth]`, `route.${extension}`)
|
|
36
|
-
: path.join(apiDir, `[...nextauth].${extension}`);
|
|
37
|
-
|
|
38
|
-
// Ensure [...nextauth] directory exists for App Router
|
|
39
|
-
if (routerType === 'app') {
|
|
40
|
-
const nextauthDir = path.join(apiDir, '[...nextauth]');
|
|
41
|
-
ensureDir(nextauthDir);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Check if file exists and get action
|
|
45
|
-
const action = await checkFileOverwrite(routePath);
|
|
46
|
-
|
|
47
|
-
if (action === 'skip') {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Generate NextAuth configuration
|
|
52
|
-
const code = this.generateCode({
|
|
53
|
-
backendUrl,
|
|
54
|
-
oauthProviders,
|
|
55
|
-
routerType,
|
|
56
|
-
isTypeScript,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return writeFileWithBackup(routePath, code, action);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Generate NextAuth.js code
|
|
64
|
-
*/
|
|
65
|
-
generateCode({ oauthProviders, routerType, isTypeScript }) {
|
|
66
|
-
const providers = [];
|
|
67
|
-
const providerImports = [];
|
|
68
|
-
|
|
69
|
-
if (oauthProviders.includes('google')) {
|
|
70
|
-
providerImports.push("import GoogleProvider from 'next-auth/providers/google';");
|
|
71
|
-
providers.push(` GoogleProvider({
|
|
72
|
-
clientId: process.env.GOOGLE_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
73
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
74
|
-
}),`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (oauthProviders.includes('microsoft')) {
|
|
78
|
-
providerImports.push("import AzureADProvider from 'next-auth/providers/azure-ad';");
|
|
79
|
-
providers.push(` AzureADProvider({
|
|
80
|
-
clientId: process.env.AZURE_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
81
|
-
clientSecret: process.env.AZURE_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
82
|
-
tenantId: process.env.AZURE_TENANT_ID${isTypeScript ? '!' : ''},
|
|
83
|
-
}),`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (oauthProviders.includes('github')) {
|
|
87
|
-
providerImports.push("import GitHubProvider from 'next-auth/providers/github';");
|
|
88
|
-
providers.push(` GitHubProvider({
|
|
89
|
-
clientId: process.env.GITHUB_CLIENT_ID${isTypeScript ? '!' : ''},
|
|
90
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET${isTypeScript ? '!' : ''},
|
|
91
|
-
}),`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const providersCode = providers.join('\n');
|
|
95
|
-
|
|
96
|
-
// App Router vs Pages Router
|
|
97
|
-
if (routerType === 'app') {
|
|
98
|
-
return `/**
|
|
99
|
-
* NextAuth.js Configuration
|
|
100
|
-
* Auto-generated by @l4yercak3/cli
|
|
101
|
-
*
|
|
102
|
-
* This file configures OAuth authentication for your frontend application.
|
|
103
|
-
* Users authenticated here are automatically synced to your L4YERCAK3 backend.
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
${providerImports.join('\n')}
|
|
107
|
-
import NextAuth from 'next-auth';
|
|
108
|
-
import type { NextAuthOptions } from 'next-auth';
|
|
109
|
-
|
|
110
|
-
const authOptions${isTypeScript ? ': NextAuthOptions' : ''} = {
|
|
111
|
-
providers: [
|
|
112
|
-
${providersCode}
|
|
113
|
-
],
|
|
114
|
-
callbacks: {
|
|
115
|
-
async signIn({ user, account, profile }) {
|
|
116
|
-
if (!account) return false;
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
// Sync user to L4YERCAK3 backend
|
|
120
|
-
const response = await fetch(\`\${process.env.NEXT_PUBLIC_L4YERCAK3_BACKEND_URL}/api/v1/auth/sync-user\`, {
|
|
121
|
-
method: 'POST',
|
|
122
|
-
headers: {
|
|
123
|
-
'Content-Type': 'application/json',
|
|
124
|
-
'Authorization': \`Bearer \${process.env.L4YERCAK3_API_KEY}\`,
|
|
125
|
-
},
|
|
126
|
-
body: JSON.stringify({
|
|
127
|
-
email: user.email,
|
|
128
|
-
name: user.name,
|
|
129
|
-
image: user.image,
|
|
130
|
-
provider: account.provider,
|
|
131
|
-
providerAccountId: account.providerAccountId,
|
|
132
|
-
accessToken: account.access_token,
|
|
133
|
-
refreshToken: account.refresh_token,
|
|
134
|
-
expiresAt: account.expires_at,
|
|
135
|
-
}),
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
console.error('Failed to sync user to backend:', await response.text());
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const backendUser = await response.json();
|
|
144
|
-
|
|
145
|
-
// Add backend user ID to session
|
|
146
|
-
user.id = backendUser.userId;
|
|
147
|
-
user.organizationId = backendUser.organizationId;
|
|
148
|
-
|
|
149
|
-
return true;
|
|
150
|
-
} catch (error) {
|
|
151
|
-
console.error('Error syncing user to backend:', error);
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
async session({ session, user${isTypeScript ? ': any' : ''} }) {
|
|
156
|
-
if (session.user) {
|
|
157
|
-
session.user.id = user.id;
|
|
158
|
-
session.user.organizationId = user.organizationId;
|
|
159
|
-
}
|
|
160
|
-
return session;
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
pages: {
|
|
164
|
-
signIn: '/auth/signin',
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const handler = NextAuth(authOptions);
|
|
169
|
-
|
|
170
|
-
export { handler as GET, handler as POST };
|
|
171
|
-
`;
|
|
172
|
-
} else {
|
|
173
|
-
// Pages Router
|
|
174
|
-
return `/**
|
|
175
|
-
* NextAuth.js Configuration
|
|
176
|
-
* Auto-generated by @l4yercak3/cli
|
|
177
|
-
*
|
|
178
|
-
* This file configures OAuth authentication for your frontend application.
|
|
179
|
-
* Users authenticated here are automatically synced to your L4YERCAK3 backend.
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
${providerImports.join('\n')}
|
|
183
|
-
import NextAuth from 'next-auth';
|
|
184
|
-
|
|
185
|
-
export default NextAuth({
|
|
186
|
-
providers: [
|
|
187
|
-
${providersCode}
|
|
188
|
-
],
|
|
189
|
-
callbacks: {
|
|
190
|
-
async signIn({ user, account, profile }) {
|
|
191
|
-
if (!account) return false;
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
// Sync user to L4YERCAK3 backend
|
|
195
|
-
const response = await fetch(\`\${process.env.NEXT_PUBLIC_L4YERCAK3_BACKEND_URL}/api/v1/auth/sync-user\`, {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
headers: {
|
|
198
|
-
'Content-Type': 'application/json',
|
|
199
|
-
'Authorization': \`Bearer \${process.env.L4YERCAK3_API_KEY}\`,
|
|
200
|
-
},
|
|
201
|
-
body: JSON.stringify({
|
|
202
|
-
email: user.email,
|
|
203
|
-
name: user.name,
|
|
204
|
-
image: user.image,
|
|
205
|
-
provider: account.provider,
|
|
206
|
-
providerAccountId: account.providerAccountId,
|
|
207
|
-
accessToken: account.access_token,
|
|
208
|
-
refreshToken: account.refresh_token,
|
|
209
|
-
expiresAt: account.expires_at,
|
|
210
|
-
}),
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
if (!response.ok) {
|
|
214
|
-
console.error('Failed to sync user to backend:', await response.text());
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const backendUser = await response.json();
|
|
219
|
-
|
|
220
|
-
// Add backend user ID to session
|
|
221
|
-
user.id = backendUser.userId;
|
|
222
|
-
user.organizationId = backendUser.organizationId;
|
|
223
|
-
|
|
224
|
-
return true;
|
|
225
|
-
} catch (error) {
|
|
226
|
-
console.error('Error syncing user to backend:', error);
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
async session({ session, user }) {
|
|
231
|
-
if (session.user) {
|
|
232
|
-
session.user.id = user.id;
|
|
233
|
-
session.user.organizationId = user.organizationId;
|
|
234
|
-
}
|
|
235
|
-
return session;
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
pages: {
|
|
239
|
-
signIn: '/auth/signin',
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
`;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
module.exports = new NextAuthGenerator();
|
|
@@ -1,277 +0,0 @@
|
|
|
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://www.l4yercak3.com/docs) or contact support.
|
|
271
|
-
`;
|
|
272
|
-
|
|
273
|
-
return content;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
module.exports = new OAuthGuideGenerator();
|