@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,454 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Generators Index (FileGenerator)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
|
|
7
|
-
jest.mock('fs');
|
|
8
|
-
jest.mock('../src/utils/file-utils', () => ({
|
|
9
|
-
checkFileOverwrite: jest.fn().mockResolvedValue('write'),
|
|
10
|
-
writeFileWithBackup: jest.fn((filePath, content, action) => {
|
|
11
|
-
if (action === 'skip') return null;
|
|
12
|
-
return filePath;
|
|
13
|
-
}),
|
|
14
|
-
ensureDir: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const FileGenerator = require('../src/generators/index');
|
|
18
|
-
|
|
19
|
-
describe('FileGenerator', () => {
|
|
20
|
-
const mockProjectPath = '/test/project';
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
jest.clearAllMocks();
|
|
24
|
-
fs.existsSync.mockReturnValue(false);
|
|
25
|
-
fs.mkdirSync.mockReturnValue(undefined);
|
|
26
|
-
fs.writeFileSync.mockReturnValue(undefined);
|
|
27
|
-
fs.readFileSync.mockReturnValue('');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('legacy generate (backward compatibility)', () => {
|
|
31
|
-
it('returns results object with expected structure', async () => {
|
|
32
|
-
const options = {
|
|
33
|
-
projectPath: mockProjectPath,
|
|
34
|
-
apiKey: 'test-key',
|
|
35
|
-
backendUrl: 'https://backend.test.com',
|
|
36
|
-
organizationId: 'org-123',
|
|
37
|
-
features: [],
|
|
38
|
-
oauthProviders: [],
|
|
39
|
-
isTypeScript: false,
|
|
40
|
-
routerType: 'app',
|
|
41
|
-
integrationPath: 'legacy', // Use legacy path for backward compatibility tests
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const result = await FileGenerator.generate(options);
|
|
45
|
-
|
|
46
|
-
expect(result).toHaveProperty('apiClient');
|
|
47
|
-
expect(result).toHaveProperty('envFile');
|
|
48
|
-
expect(result).toHaveProperty('nextauth');
|
|
49
|
-
expect(result).toHaveProperty('oauthGuide');
|
|
50
|
-
expect(result).toHaveProperty('gitignore');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('generates API client when features are provided', async () => {
|
|
54
|
-
const options = {
|
|
55
|
-
projectPath: mockProjectPath,
|
|
56
|
-
apiKey: 'test-key',
|
|
57
|
-
backendUrl: 'https://backend.test.com',
|
|
58
|
-
organizationId: 'org-123',
|
|
59
|
-
features: ['crm'],
|
|
60
|
-
oauthProviders: [],
|
|
61
|
-
isTypeScript: false,
|
|
62
|
-
integrationPath: 'legacy',
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const result = await FileGenerator.generate(options);
|
|
66
|
-
|
|
67
|
-
expect(result.apiClient).not.toBeNull();
|
|
68
|
-
expect(result.apiClient).toContain('api-client');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('does not generate API client when no features', async () => {
|
|
72
|
-
const options = {
|
|
73
|
-
projectPath: mockProjectPath,
|
|
74
|
-
apiKey: 'test-key',
|
|
75
|
-
backendUrl: 'https://backend.test.com',
|
|
76
|
-
organizationId: 'org-123',
|
|
77
|
-
features: [],
|
|
78
|
-
oauthProviders: [],
|
|
79
|
-
isTypeScript: false,
|
|
80
|
-
integrationPath: 'legacy',
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const result = await FileGenerator.generate(options);
|
|
84
|
-
|
|
85
|
-
expect(result.apiClient).toBeNull();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('always generates env file', async () => {
|
|
89
|
-
const options = {
|
|
90
|
-
projectPath: mockProjectPath,
|
|
91
|
-
apiKey: 'test-key',
|
|
92
|
-
backendUrl: 'https://backend.test.com',
|
|
93
|
-
organizationId: 'org-123',
|
|
94
|
-
features: [],
|
|
95
|
-
oauthProviders: [],
|
|
96
|
-
integrationPath: 'legacy',
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const result = await FileGenerator.generate(options);
|
|
100
|
-
|
|
101
|
-
expect(result.envFile).not.toBeNull();
|
|
102
|
-
expect(result.envFile).toContain('.env.local');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('generates NextAuth config when oauth feature enabled (Next.js)', async () => {
|
|
106
|
-
const options = {
|
|
107
|
-
projectPath: mockProjectPath,
|
|
108
|
-
apiKey: 'test-key',
|
|
109
|
-
backendUrl: 'https://backend.test.com',
|
|
110
|
-
organizationId: 'org-123',
|
|
111
|
-
features: ['oauth'],
|
|
112
|
-
oauthProviders: ['google'],
|
|
113
|
-
isTypeScript: false,
|
|
114
|
-
routerType: 'app',
|
|
115
|
-
frameworkType: 'nextjs',
|
|
116
|
-
integrationPath: 'legacy',
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const result = await FileGenerator.generate(options);
|
|
120
|
-
|
|
121
|
-
expect(result.nextauth).not.toBeNull();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('does not generate NextAuth for Expo/mobile apps', async () => {
|
|
125
|
-
const options = {
|
|
126
|
-
projectPath: mockProjectPath,
|
|
127
|
-
apiKey: 'test-key',
|
|
128
|
-
backendUrl: 'https://backend.test.com',
|
|
129
|
-
organizationId: 'org-123',
|
|
130
|
-
features: ['oauth'],
|
|
131
|
-
oauthProviders: ['google'],
|
|
132
|
-
isTypeScript: true,
|
|
133
|
-
frameworkType: 'expo',
|
|
134
|
-
integrationPath: 'legacy',
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const result = await FileGenerator.generate(options);
|
|
138
|
-
|
|
139
|
-
expect(result.nextauth).toBeNull();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('does not generate NextAuth when oauth not in features', async () => {
|
|
143
|
-
const options = {
|
|
144
|
-
projectPath: mockProjectPath,
|
|
145
|
-
apiKey: 'test-key',
|
|
146
|
-
backendUrl: 'https://backend.test.com',
|
|
147
|
-
organizationId: 'org-123',
|
|
148
|
-
features: ['crm'],
|
|
149
|
-
oauthProviders: ['google'],
|
|
150
|
-
isTypeScript: false,
|
|
151
|
-
routerType: 'app',
|
|
152
|
-
integrationPath: 'legacy',
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const result = await FileGenerator.generate(options);
|
|
156
|
-
|
|
157
|
-
expect(result.nextauth).toBeNull();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('does not generate NextAuth when no oauthProviders', async () => {
|
|
161
|
-
const options = {
|
|
162
|
-
projectPath: mockProjectPath,
|
|
163
|
-
apiKey: 'test-key',
|
|
164
|
-
backendUrl: 'https://backend.test.com',
|
|
165
|
-
organizationId: 'org-123',
|
|
166
|
-
features: ['oauth'],
|
|
167
|
-
oauthProviders: null,
|
|
168
|
-
isTypeScript: false,
|
|
169
|
-
routerType: 'app',
|
|
170
|
-
integrationPath: 'legacy',
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const result = await FileGenerator.generate(options);
|
|
174
|
-
|
|
175
|
-
expect(result.nextauth).toBeNull();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('generates OAuth guide when oauth feature enabled', async () => {
|
|
179
|
-
const options = {
|
|
180
|
-
projectPath: mockProjectPath,
|
|
181
|
-
apiKey: 'test-key',
|
|
182
|
-
backendUrl: 'https://backend.test.com',
|
|
183
|
-
organizationId: 'org-123',
|
|
184
|
-
features: ['oauth'],
|
|
185
|
-
oauthProviders: ['google'],
|
|
186
|
-
productionDomain: 'example.com',
|
|
187
|
-
appName: 'Test App',
|
|
188
|
-
integrationPath: 'legacy',
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const result = await FileGenerator.generate(options);
|
|
192
|
-
|
|
193
|
-
expect(result.oauthGuide).not.toBeNull();
|
|
194
|
-
expect(result.oauthGuide).toContain('OAUTH_SETUP_GUIDE.md');
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('does not generate OAuth guide when oauth not enabled', async () => {
|
|
198
|
-
const options = {
|
|
199
|
-
projectPath: mockProjectPath,
|
|
200
|
-
apiKey: 'test-key',
|
|
201
|
-
backendUrl: 'https://backend.test.com',
|
|
202
|
-
organizationId: 'org-123',
|
|
203
|
-
features: ['crm'],
|
|
204
|
-
oauthProviders: [],
|
|
205
|
-
integrationPath: 'legacy',
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const result = await FileGenerator.generate(options);
|
|
209
|
-
|
|
210
|
-
expect(result.oauthGuide).toBeNull();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('always attempts to update gitignore', async () => {
|
|
214
|
-
const options = {
|
|
215
|
-
projectPath: mockProjectPath,
|
|
216
|
-
apiKey: 'test-key',
|
|
217
|
-
backendUrl: 'https://backend.test.com',
|
|
218
|
-
organizationId: 'org-123',
|
|
219
|
-
features: [],
|
|
220
|
-
oauthProviders: [],
|
|
221
|
-
integrationPath: 'legacy',
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const result = await FileGenerator.generate(options);
|
|
225
|
-
|
|
226
|
-
expect(result).toHaveProperty('gitignore');
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('generates all files when all features enabled (Next.js)', async () => {
|
|
230
|
-
const options = {
|
|
231
|
-
projectPath: mockProjectPath,
|
|
232
|
-
apiKey: 'test-key',
|
|
233
|
-
backendUrl: 'https://backend.test.com',
|
|
234
|
-
organizationId: 'org-123',
|
|
235
|
-
features: ['crm', 'oauth', 'stripe'],
|
|
236
|
-
oauthProviders: ['google', 'github'],
|
|
237
|
-
isTypeScript: true,
|
|
238
|
-
routerType: 'app',
|
|
239
|
-
productionDomain: 'example.com',
|
|
240
|
-
appName: 'Full App',
|
|
241
|
-
frameworkType: 'nextjs',
|
|
242
|
-
integrationPath: 'legacy',
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const result = await FileGenerator.generate(options);
|
|
246
|
-
|
|
247
|
-
expect(result.apiClient).not.toBeNull();
|
|
248
|
-
expect(result.envFile).not.toBeNull();
|
|
249
|
-
expect(result.nextauth).not.toBeNull();
|
|
250
|
-
expect(result.oauthGuide).not.toBeNull();
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
describe('api-only integration path', () => {
|
|
255
|
-
it('returns results object with expected structure', async () => {
|
|
256
|
-
const options = {
|
|
257
|
-
projectPath: mockProjectPath,
|
|
258
|
-
apiKey: 'test-key',
|
|
259
|
-
backendUrl: 'https://backend.test.com',
|
|
260
|
-
organizationId: 'org-123',
|
|
261
|
-
features: ['crm'],
|
|
262
|
-
oauthProviders: [],
|
|
263
|
-
isTypeScript: true,
|
|
264
|
-
integrationPath: 'api-only',
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
const result = await FileGenerator.generate(options);
|
|
268
|
-
|
|
269
|
-
expect(result).toHaveProperty('apiClient');
|
|
270
|
-
expect(result).toHaveProperty('types');
|
|
271
|
-
expect(result).toHaveProperty('webhooks');
|
|
272
|
-
expect(result).toHaveProperty('index');
|
|
273
|
-
expect(result).toHaveProperty('envFile');
|
|
274
|
-
expect(result).toHaveProperty('gitignore');
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('generates typed client file', async () => {
|
|
278
|
-
const options = {
|
|
279
|
-
projectPath: mockProjectPath,
|
|
280
|
-
apiKey: 'test-key',
|
|
281
|
-
backendUrl: 'https://backend.test.com',
|
|
282
|
-
organizationId: 'org-123',
|
|
283
|
-
features: ['crm'],
|
|
284
|
-
oauthProviders: [],
|
|
285
|
-
isTypeScript: true,
|
|
286
|
-
integrationPath: 'api-only',
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const result = await FileGenerator.generate(options);
|
|
290
|
-
|
|
291
|
-
expect(result.apiClient).not.toBeNull();
|
|
292
|
-
expect(result.apiClient).toContain('client.ts');
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('generates types file for TypeScript projects', async () => {
|
|
296
|
-
const options = {
|
|
297
|
-
projectPath: mockProjectPath,
|
|
298
|
-
apiKey: 'test-key',
|
|
299
|
-
backendUrl: 'https://backend.test.com',
|
|
300
|
-
organizationId: 'org-123',
|
|
301
|
-
features: ['crm'],
|
|
302
|
-
oauthProviders: [],
|
|
303
|
-
isTypeScript: true,
|
|
304
|
-
integrationPath: 'api-only',
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const result = await FileGenerator.generate(options);
|
|
308
|
-
|
|
309
|
-
expect(result.types).not.toBeNull();
|
|
310
|
-
expect(result.types).toContain('types.ts');
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('does not generate types file for JavaScript projects', async () => {
|
|
314
|
-
const options = {
|
|
315
|
-
projectPath: mockProjectPath,
|
|
316
|
-
apiKey: 'test-key',
|
|
317
|
-
backendUrl: 'https://backend.test.com',
|
|
318
|
-
organizationId: 'org-123',
|
|
319
|
-
features: ['crm'],
|
|
320
|
-
oauthProviders: [],
|
|
321
|
-
isTypeScript: false,
|
|
322
|
-
integrationPath: 'api-only',
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
const result = await FileGenerator.generate(options);
|
|
326
|
-
|
|
327
|
-
expect(result.types).toBeNull();
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
it('generates webhooks utility file', async () => {
|
|
331
|
-
const options = {
|
|
332
|
-
projectPath: mockProjectPath,
|
|
333
|
-
apiKey: 'test-key',
|
|
334
|
-
backendUrl: 'https://backend.test.com',
|
|
335
|
-
organizationId: 'org-123',
|
|
336
|
-
features: ['crm'],
|
|
337
|
-
oauthProviders: [],
|
|
338
|
-
isTypeScript: true,
|
|
339
|
-
integrationPath: 'api-only',
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const result = await FileGenerator.generate(options);
|
|
343
|
-
|
|
344
|
-
expect(result.webhooks).not.toBeNull();
|
|
345
|
-
expect(result.webhooks).toContain('webhooks.ts');
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
describe('quickstart integration path', () => {
|
|
350
|
-
it('returns results object with expected structure', async () => {
|
|
351
|
-
const options = {
|
|
352
|
-
projectPath: mockProjectPath,
|
|
353
|
-
apiKey: 'test-key',
|
|
354
|
-
backendUrl: 'https://backend.test.com',
|
|
355
|
-
organizationId: 'org-123',
|
|
356
|
-
features: ['crm', 'oauth'],
|
|
357
|
-
oauthProviders: ['google'],
|
|
358
|
-
isTypeScript: true,
|
|
359
|
-
frameworkType: 'nextjs',
|
|
360
|
-
integrationPath: 'quickstart',
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const result = await FileGenerator.generate(options);
|
|
364
|
-
|
|
365
|
-
expect(result).toHaveProperty('apiClient');
|
|
366
|
-
expect(result).toHaveProperty('types');
|
|
367
|
-
expect(result).toHaveProperty('webhooks');
|
|
368
|
-
expect(result).toHaveProperty('envFile');
|
|
369
|
-
expect(result).toHaveProperty('nextauth');
|
|
370
|
-
expect(result).toHaveProperty('oauthGuide');
|
|
371
|
-
expect(result).toHaveProperty('gitignore');
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it('generates NextAuth for Next.js with oauth feature', async () => {
|
|
375
|
-
const options = {
|
|
376
|
-
projectPath: mockProjectPath,
|
|
377
|
-
apiKey: 'test-key',
|
|
378
|
-
backendUrl: 'https://backend.test.com',
|
|
379
|
-
organizationId: 'org-123',
|
|
380
|
-
features: ['crm', 'oauth'],
|
|
381
|
-
oauthProviders: ['google'],
|
|
382
|
-
isTypeScript: true,
|
|
383
|
-
frameworkType: 'nextjs',
|
|
384
|
-
integrationPath: 'quickstart',
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
const result = await FileGenerator.generate(options);
|
|
388
|
-
|
|
389
|
-
expect(result.nextauth).not.toBeNull();
|
|
390
|
-
expect(result.oauthGuide).not.toBeNull();
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
describe('mcp-assisted integration path', () => {
|
|
395
|
-
it('returns results object with expected structure', async () => {
|
|
396
|
-
const options = {
|
|
397
|
-
projectPath: mockProjectPath,
|
|
398
|
-
apiKey: 'test-key',
|
|
399
|
-
backendUrl: 'https://backend.test.com',
|
|
400
|
-
organizationId: 'org-123',
|
|
401
|
-
organizationName: 'Test Org',
|
|
402
|
-
features: ['crm'],
|
|
403
|
-
oauthProviders: [],
|
|
404
|
-
isTypeScript: true,
|
|
405
|
-
integrationPath: 'mcp-assisted',
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const result = await FileGenerator.generate(options);
|
|
409
|
-
|
|
410
|
-
expect(result).toHaveProperty('mcpConfig');
|
|
411
|
-
expect(result).toHaveProperty('mcpGuide');
|
|
412
|
-
expect(result).toHaveProperty('envFile');
|
|
413
|
-
expect(result).toHaveProperty('gitignore');
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('generates MCP config file', async () => {
|
|
417
|
-
const options = {
|
|
418
|
-
projectPath: mockProjectPath,
|
|
419
|
-
apiKey: 'test-key',
|
|
420
|
-
backendUrl: 'https://backend.test.com',
|
|
421
|
-
organizationId: 'org-123',
|
|
422
|
-
organizationName: 'Test Org',
|
|
423
|
-
features: ['crm'],
|
|
424
|
-
oauthProviders: [],
|
|
425
|
-
isTypeScript: true,
|
|
426
|
-
integrationPath: 'mcp-assisted',
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const result = await FileGenerator.generate(options);
|
|
430
|
-
|
|
431
|
-
expect(result.mcpConfig).not.toBeNull();
|
|
432
|
-
expect(result.mcpConfig).toContain('mcp.json');
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it('generates MCP guide file', async () => {
|
|
436
|
-
const options = {
|
|
437
|
-
projectPath: mockProjectPath,
|
|
438
|
-
apiKey: 'test-key',
|
|
439
|
-
backendUrl: 'https://backend.test.com',
|
|
440
|
-
organizationId: 'org-123',
|
|
441
|
-
organizationName: 'Test Org',
|
|
442
|
-
features: ['crm'],
|
|
443
|
-
oauthProviders: [],
|
|
444
|
-
isTypeScript: true,
|
|
445
|
-
integrationPath: 'mcp-assisted',
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
const result = await FileGenerator.generate(options);
|
|
449
|
-
|
|
450
|
-
expect(result.mcpGuide).not.toBeNull();
|
|
451
|
-
expect(result.mcpGuide).toContain('L4YERCAK3_MCP_GUIDE.md');
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
});
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for GitHub Detector
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const { execSync } = require('child_process');
|
|
7
|
-
|
|
8
|
-
jest.mock('fs');
|
|
9
|
-
jest.mock('child_process');
|
|
10
|
-
|
|
11
|
-
const GitHubDetector = require('../src/detectors/github-detector');
|
|
12
|
-
|
|
13
|
-
describe('GitHubDetector', () => {
|
|
14
|
-
const mockProjectPath = '/test/project';
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('detect', () => {
|
|
21
|
-
it('returns hasGit false when no .git directory exists', () => {
|
|
22
|
-
fs.existsSync.mockReturnValue(false);
|
|
23
|
-
|
|
24
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
25
|
-
|
|
26
|
-
expect(result.hasGit).toBe(false);
|
|
27
|
-
expect(result.isGitHub).toBe(false);
|
|
28
|
-
expect(result.owner).toBeNull();
|
|
29
|
-
expect(result.repo).toBeNull();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('returns hasGit true when .git directory exists', () => {
|
|
33
|
-
fs.existsSync.mockReturnValue(true);
|
|
34
|
-
execSync.mockReturnValue('https://github.com/owner/repo.git\n');
|
|
35
|
-
|
|
36
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
37
|
-
|
|
38
|
-
expect(result.hasGit).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('parses HTTPS GitHub URL correctly', () => {
|
|
42
|
-
fs.existsSync.mockReturnValue(true);
|
|
43
|
-
execSync
|
|
44
|
-
.mockReturnValueOnce('https://github.com/myorg/myrepo.git\n')
|
|
45
|
-
.mockReturnValueOnce('main\n');
|
|
46
|
-
|
|
47
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
48
|
-
|
|
49
|
-
expect(result.isGitHub).toBe(true);
|
|
50
|
-
expect(result.owner).toBe('myorg');
|
|
51
|
-
expect(result.repo).toBe('myrepo');
|
|
52
|
-
expect(result.url).toBe('https://github.com/myorg/myrepo');
|
|
53
|
-
expect(result.branch).toBe('main');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('parses SSH GitHub URL correctly', () => {
|
|
57
|
-
fs.existsSync.mockReturnValue(true);
|
|
58
|
-
execSync
|
|
59
|
-
.mockReturnValueOnce('git@github.com:myorg/myrepo.git\n')
|
|
60
|
-
.mockReturnValueOnce('develop\n');
|
|
61
|
-
|
|
62
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
63
|
-
|
|
64
|
-
expect(result.isGitHub).toBe(true);
|
|
65
|
-
expect(result.owner).toBe('myorg');
|
|
66
|
-
expect(result.repo).toBe('myrepo');
|
|
67
|
-
expect(result.url).toBe('https://github.com/myorg/myrepo');
|
|
68
|
-
expect(result.branch).toBe('develop');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('parses GitHub URL without .git extension', () => {
|
|
72
|
-
fs.existsSync.mockReturnValue(true);
|
|
73
|
-
execSync
|
|
74
|
-
.mockReturnValueOnce('https://github.com/owner/repo\n')
|
|
75
|
-
.mockReturnValueOnce('main\n');
|
|
76
|
-
|
|
77
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
78
|
-
|
|
79
|
-
expect(result.isGitHub).toBe(true);
|
|
80
|
-
expect(result.owner).toBe('owner');
|
|
81
|
-
expect(result.repo).toBe('repo');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('returns isGitHub false for non-GitHub remote', () => {
|
|
85
|
-
fs.existsSync.mockReturnValue(true);
|
|
86
|
-
execSync.mockReturnValue('https://gitlab.com/owner/repo.git\n');
|
|
87
|
-
|
|
88
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
89
|
-
|
|
90
|
-
expect(result.hasGit).toBe(true);
|
|
91
|
-
expect(result.isGitHub).toBe(false);
|
|
92
|
-
expect(result.owner).toBeNull();
|
|
93
|
-
expect(result.repo).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('handles empty remote URL', () => {
|
|
97
|
-
fs.existsSync.mockReturnValue(true);
|
|
98
|
-
execSync.mockReturnValue('\n');
|
|
99
|
-
|
|
100
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
101
|
-
|
|
102
|
-
expect(result.hasGit).toBe(true);
|
|
103
|
-
expect(result.isGitHub).toBe(false);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('handles git command failure gracefully', () => {
|
|
107
|
-
fs.existsSync.mockReturnValue(true);
|
|
108
|
-
execSync.mockImplementation(() => {
|
|
109
|
-
throw new Error('git command failed');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
113
|
-
|
|
114
|
-
expect(result.hasGit).toBe(true);
|
|
115
|
-
expect(result.isGitHub).toBe(false);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('handles branch detection failure gracefully', () => {
|
|
119
|
-
fs.existsSync.mockReturnValue(true);
|
|
120
|
-
execSync
|
|
121
|
-
.mockReturnValueOnce('https://github.com/owner/repo.git\n')
|
|
122
|
-
.mockImplementationOnce(() => {
|
|
123
|
-
throw new Error('branch command failed');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const result = GitHubDetector.detect(mockProjectPath);
|
|
127
|
-
|
|
128
|
-
expect(result.isGitHub).toBe(true);
|
|
129
|
-
expect(result.owner).toBe('owner');
|
|
130
|
-
expect(result.branch).toBeNull();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('uses correct working directory for git commands', () => {
|
|
134
|
-
fs.existsSync.mockReturnValue(true);
|
|
135
|
-
execSync.mockReturnValue('https://github.com/owner/repo.git\n');
|
|
136
|
-
|
|
137
|
-
GitHubDetector.detect(mockProjectPath);
|
|
138
|
-
|
|
139
|
-
expect(execSync).toHaveBeenCalledWith(
|
|
140
|
-
'git config --get remote.origin.url',
|
|
141
|
-
expect.objectContaining({ cwd: mockProjectPath })
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Gitignore Generator
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
jest.mock('fs');
|
|
9
|
-
|
|
10
|
-
const GitignoreGenerator = require('../src/generators/gitignore-generator');
|
|
11
|
-
|
|
12
|
-
describe('GitignoreGenerator', () => {
|
|
13
|
-
const mockProjectPath = '/test/project';
|
|
14
|
-
const mockGitignorePath = path.join(mockProjectPath, '.gitignore');
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
fs.existsSync.mockReturnValue(false);
|
|
19
|
-
fs.writeFileSync.mockReturnValue(undefined);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('generate', () => {
|
|
23
|
-
it('creates new .gitignore with L4YERCAK3 entries', () => {
|
|
24
|
-
fs.existsSync.mockReturnValue(false);
|
|
25
|
-
|
|
26
|
-
const result = GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
27
|
-
|
|
28
|
-
expect(result).toBe(mockGitignorePath);
|
|
29
|
-
expect(fs.writeFileSync).toHaveBeenCalled();
|
|
30
|
-
|
|
31
|
-
const writtenContent = fs.writeFileSync.mock.calls[0][1];
|
|
32
|
-
expect(writtenContent).toContain('# L4YERCAK3 Configuration');
|
|
33
|
-
expect(writtenContent).toContain('.env.local');
|
|
34
|
-
expect(writtenContent).toContain('.env*.local');
|
|
35
|
-
expect(writtenContent).toContain('.l4yercak3/');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('appends to existing .gitignore', () => {
|
|
39
|
-
fs.existsSync.mockReturnValue(true);
|
|
40
|
-
fs.readFileSync.mockReturnValue(`# Existing gitignore
|
|
41
|
-
node_modules/
|
|
42
|
-
.DS_Store
|
|
43
|
-
`);
|
|
44
|
-
|
|
45
|
-
const result = GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
46
|
-
|
|
47
|
-
expect(result).toBe(mockGitignorePath);
|
|
48
|
-
|
|
49
|
-
const writtenContent = fs.writeFileSync.mock.calls[0][1];
|
|
50
|
-
expect(writtenContent).toContain('node_modules/');
|
|
51
|
-
expect(writtenContent).toContain('.DS_Store');
|
|
52
|
-
expect(writtenContent).toContain('# L4YERCAK3 Configuration');
|
|
53
|
-
expect(writtenContent).toContain('.env.local');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('returns null when all entries already exist', () => {
|
|
57
|
-
fs.existsSync.mockReturnValue(true);
|
|
58
|
-
fs.readFileSync.mockReturnValue(`# L4YERCAK3 Configuration
|
|
59
|
-
# Auto-generated by @l4yercak3/cli
|
|
60
|
-
.env.local
|
|
61
|
-
.env*.local
|
|
62
|
-
.l4yercak3/
|
|
63
|
-
`);
|
|
64
|
-
|
|
65
|
-
const result = GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
66
|
-
|
|
67
|
-
expect(result).toBeNull();
|
|
68
|
-
expect(fs.writeFileSync).not.toHaveBeenCalled();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('adds missing entries when some already exist', () => {
|
|
72
|
-
fs.existsSync.mockReturnValue(true);
|
|
73
|
-
fs.readFileSync.mockReturnValue(`# L4YERCAK3 Configuration
|
|
74
|
-
.env.local
|
|
75
|
-
`);
|
|
76
|
-
|
|
77
|
-
GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
78
|
-
|
|
79
|
-
const writtenContent = fs.writeFileSync.mock.calls[0][1];
|
|
80
|
-
expect(writtenContent).toContain('.env*.local');
|
|
81
|
-
expect(writtenContent).toContain('.l4yercak3/');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('adds newline before section if file does not end with newline', () => {
|
|
85
|
-
fs.existsSync.mockReturnValue(true);
|
|
86
|
-
fs.readFileSync.mockReturnValue('node_modules/');
|
|
87
|
-
|
|
88
|
-
GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
89
|
-
|
|
90
|
-
const writtenContent = fs.writeFileSync.mock.calls[0][1];
|
|
91
|
-
// Should have newline between existing content and new section
|
|
92
|
-
expect(writtenContent).toMatch(/node_modules\/\n\n# L4YERCAK3 Configuration/);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('handles whitespace variations in existing entries', () => {
|
|
96
|
-
fs.existsSync.mockReturnValue(true);
|
|
97
|
-
fs.readFileSync.mockReturnValue(`# Some config
|
|
98
|
-
.env.local
|
|
99
|
-
.env*.local
|
|
100
|
-
.l4yercak3/
|
|
101
|
-
# L4YERCAK3 Configuration
|
|
102
|
-
`);
|
|
103
|
-
|
|
104
|
-
const result = GitignoreGenerator.generate({ projectPath: mockProjectPath });
|
|
105
|
-
|
|
106
|
-
expect(result).toBeNull();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|