@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,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompt Utilities
|
|
3
|
-
* Shared prompt helpers for consistent CLI UX
|
|
4
|
-
* Auto-generated by @l4yercak3/cli
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const inquirer = require('inquirer');
|
|
8
|
-
const chalk = require('chalk');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Show a menu with options and handle selection
|
|
12
|
-
* Always includes an Exit option at the end
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} options - Menu configuration
|
|
15
|
-
* @param {string} options.message - Menu header message
|
|
16
|
-
* @param {Array<{name: string, value: string}>} options.choices - Menu choices
|
|
17
|
-
* @returns {Promise<string>} The selected action value
|
|
18
|
-
*/
|
|
19
|
-
async function showActionMenu(options) {
|
|
20
|
-
const { message = 'What would you like to do?', choices = [] } = options;
|
|
21
|
-
|
|
22
|
-
// Always include exit option at the end
|
|
23
|
-
const menuChoices = [
|
|
24
|
-
...choices,
|
|
25
|
-
new inquirer.Separator(),
|
|
26
|
-
{ name: 'Exit', value: 'exit' },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const { action } = await inquirer.prompt([
|
|
30
|
-
{
|
|
31
|
-
type: 'list',
|
|
32
|
-
name: 'action',
|
|
33
|
-
message,
|
|
34
|
-
choices: menuChoices,
|
|
35
|
-
},
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
// Handle exit
|
|
39
|
-
if (action === 'exit') {
|
|
40
|
-
console.log(chalk.gray('\n Goodbye!\n'));
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return action;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the full list of available CLI commands as menu choices
|
|
49
|
-
* @param {Object} context - Context for filtering options
|
|
50
|
-
* @param {boolean} context.isLoggedIn - Whether user is logged in
|
|
51
|
-
* @param {boolean} context.isInProject - Whether CLI is running in a project directory
|
|
52
|
-
* @param {boolean} context.hasExistingConfig - Whether project already has L4YERCAK3 config
|
|
53
|
-
*/
|
|
54
|
-
function getCommandChoices(context = {}) {
|
|
55
|
-
const { isLoggedIn = true, isInProject = false, hasExistingConfig = false } = context;
|
|
56
|
-
|
|
57
|
-
const choices = [];
|
|
58
|
-
|
|
59
|
-
// Project setup commands (when in a project)
|
|
60
|
-
if (isInProject) {
|
|
61
|
-
if (hasExistingConfig) {
|
|
62
|
-
choices.push({
|
|
63
|
-
name: 'Reconfigure project l4yercak3 spread',
|
|
64
|
-
value: 'spread',
|
|
65
|
-
});
|
|
66
|
-
} else {
|
|
67
|
-
choices.push({
|
|
68
|
-
name: 'Set up L4YERCAK3 l4yercak3 spread',
|
|
69
|
-
value: 'spread',
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
choices.push({
|
|
74
|
-
name: 'Initialize project l4yercak3 spread',
|
|
75
|
-
value: 'spread',
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Always available commands (when logged in)
|
|
80
|
-
if (isLoggedIn) {
|
|
81
|
-
choices.push(
|
|
82
|
-
{ name: 'View account status l4yercak3 status', value: 'status' },
|
|
83
|
-
{ name: 'Manage API keys l4yercak3 api-keys', value: 'api-keys' },
|
|
84
|
-
{ name: 'Set up MCP server l4yercak3 mcp-setup', value: 'mcp-setup' },
|
|
85
|
-
{ name: 'Check for updates l4yercak3 upgrade', value: 'upgrade' },
|
|
86
|
-
new inquirer.Separator(),
|
|
87
|
-
{ name: 'Log out l4yercak3 logout', value: 'logout' },
|
|
88
|
-
);
|
|
89
|
-
} else {
|
|
90
|
-
choices.push(
|
|
91
|
-
{ name: 'Log in l4yercak3 login', value: 'login' },
|
|
92
|
-
{ name: 'Check for updates l4yercak3 upgrade', value: 'upgrade' },
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return choices;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Show main menu with all available commands
|
|
101
|
-
* @param {Object} context - Context for menu options
|
|
102
|
-
* @param {boolean} context.isLoggedIn - Whether user is logged in
|
|
103
|
-
* @param {boolean} context.isInProject - Whether CLI is running in a project directory
|
|
104
|
-
* @param {boolean} context.hasExistingConfig - Whether project already has L4YERCAK3 config
|
|
105
|
-
* @returns {Promise<string>} The selected action value
|
|
106
|
-
*/
|
|
107
|
-
async function showMainMenu(context = {}) {
|
|
108
|
-
const choices = getCommandChoices(context);
|
|
109
|
-
|
|
110
|
-
return await showActionMenu({
|
|
111
|
-
message: 'What would you like to do?',
|
|
112
|
-
choices,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Show post-login menu with common actions
|
|
118
|
-
* @param {Object} context - Context for menu options
|
|
119
|
-
* @param {boolean} context.isInProject - Whether CLI is running in a project directory
|
|
120
|
-
* @param {boolean} context.hasExistingConfig - Whether project already has L4YERCAK3 config
|
|
121
|
-
*/
|
|
122
|
-
async function showPostLoginMenu(context = {}) {
|
|
123
|
-
return await showMainMenu({ ...context, isLoggedIn: true });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Execute a menu action by calling the appropriate command handler
|
|
128
|
-
* @param {string} action - The action to execute
|
|
129
|
-
* @returns {Promise<void>}
|
|
130
|
-
*/
|
|
131
|
-
async function executeMenuAction(action) {
|
|
132
|
-
console.log('');
|
|
133
|
-
|
|
134
|
-
switch (action) {
|
|
135
|
-
case 'spread': {
|
|
136
|
-
const { handler } = require('../commands/spread');
|
|
137
|
-
await handler();
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case 'status': {
|
|
141
|
-
const { handler } = require('../commands/status');
|
|
142
|
-
await handler();
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
case 'api-keys': {
|
|
146
|
-
const { handler } = require('../commands/api-keys');
|
|
147
|
-
await handler();
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
case 'logout': {
|
|
151
|
-
const { handler } = require('../commands/logout');
|
|
152
|
-
await handler();
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case 'login': {
|
|
156
|
-
const { handler } = require('../commands/login');
|
|
157
|
-
await handler();
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
case 'mcp-setup': {
|
|
161
|
-
const { handler } = require('../commands/mcp-setup');
|
|
162
|
-
await handler();
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
case 'upgrade': {
|
|
166
|
-
const { handler } = require('../commands/upgrade');
|
|
167
|
-
await handler();
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
default:
|
|
171
|
-
// Unknown action, just return
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Show menu and execute selected action
|
|
178
|
-
* Convenience function that combines showMainMenu + executeMenuAction
|
|
179
|
-
* @param {Object} context - Context for menu options
|
|
180
|
-
* @returns {Promise<string>} The selected action value
|
|
181
|
-
*/
|
|
182
|
-
async function showMenuAndExecute(context = {}) {
|
|
183
|
-
const action = await showMainMenu(context);
|
|
184
|
-
await executeMenuAction(action);
|
|
185
|
-
return action;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
module.exports = {
|
|
189
|
-
showActionMenu,
|
|
190
|
-
showMainMenu,
|
|
191
|
-
showPostLoginMenu,
|
|
192
|
-
getCommandChoices,
|
|
193
|
-
executeMenuAction,
|
|
194
|
-
showMenuAndExecute,
|
|
195
|
-
};
|
package/templates/CLAUDE.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# L4YERCAK3 Integration - Claude Code Configuration
|
|
2
|
-
|
|
3
|
-
## About This Integration
|
|
4
|
-
|
|
5
|
-
This project uses **L4YERCAK3** for backend services. The integration was set up using `@l4yercak3/cli`.
|
|
6
|
-
|
|
7
|
-
## L4YERCAK3 CLI
|
|
8
|
-
|
|
9
|
-
Install the CLI globally to manage your L4YERCAK3 integration:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install -g @l4yercak3/cli
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Commands
|
|
16
|
-
|
|
17
|
-
| Command | Description |
|
|
18
|
-
|---------|-------------|
|
|
19
|
-
| `l4yercak3 login` | Authenticate with L4YERCAK3 platform |
|
|
20
|
-
| `l4yercak3 logout` | Log out from L4YERCAK3 |
|
|
21
|
-
| `l4yercak3 status` | Check authentication and session status |
|
|
22
|
-
| `l4yercak3 spread` | Re-run setup wizard to add/update features |
|
|
23
|
-
| `icing` | Shorthand alias for `l4yercak3` |
|
|
24
|
-
|
|
25
|
-
## Generated Files
|
|
26
|
-
|
|
27
|
-
The CLI generates these files based on selected features:
|
|
28
|
-
|
|
29
|
-
| File | Purpose |
|
|
30
|
-
|------|---------|
|
|
31
|
-
| `.env.local` | Environment variables (API keys, secrets) |
|
|
32
|
-
| `src/lib/api-client.js` | API client for L4YERCAK3 backend (or `.ts` for TypeScript) |
|
|
33
|
-
| `src/app/api/auth/[...nextauth]/route.js` | NextAuth.js configuration (if OAuth enabled) |
|
|
34
|
-
| `OAUTH_SETUP_GUIDE.md` | OAuth provider setup instructions (if OAuth enabled) |
|
|
35
|
-
|
|
36
|
-
## Environment Variables
|
|
37
|
-
|
|
38
|
-
Required variables in `.env.local`:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
L4YERCAK3_API_KEY= # Your L4YERCAK3 API key
|
|
42
|
-
L4YERCAK3_BACKEND_URL= # Backend API URL
|
|
43
|
-
L4YERCAK3_ORG_ID= # Your organization ID
|
|
44
|
-
NEXTAUTH_SECRET= # NextAuth secret (if using OAuth)
|
|
45
|
-
NEXTAUTH_URL= # Your app URL (if using OAuth)
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Using the API Client
|
|
49
|
-
|
|
50
|
-
```javascript
|
|
51
|
-
import L4YERCAK3Client from '@/lib/api-client';
|
|
52
|
-
|
|
53
|
-
// Create client instance (uses env defaults if no args)
|
|
54
|
-
const client = new L4YERCAK3Client();
|
|
55
|
-
|
|
56
|
-
// CRM Methods
|
|
57
|
-
const contacts = await client.getContacts();
|
|
58
|
-
const contact = await client.getContact('contact-id');
|
|
59
|
-
const newContact = await client.createContact({ email: 'user@example.com', name: 'John Doe' });
|
|
60
|
-
await client.updateContact('contact-id', { name: 'Jane Doe' });
|
|
61
|
-
await client.deleteContact('contact-id');
|
|
62
|
-
|
|
63
|
-
// Projects Methods
|
|
64
|
-
const projects = await client.getProjects();
|
|
65
|
-
const project = await client.createProject({ name: 'New Project' });
|
|
66
|
-
|
|
67
|
-
// Invoices Methods
|
|
68
|
-
const invoices = await client.getInvoices();
|
|
69
|
-
const invoice = await client.createInvoice({ amount: 100, contactId: 'contact-id' });
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Re-running Setup
|
|
73
|
-
|
|
74
|
-
To add new features or update configuration:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
l4yercak3 spread
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
This will detect existing setup and allow you to add additional features without overwriting current configuration.
|
|
81
|
-
|
|
82
|
-
## Support
|
|
83
|
-
|
|
84
|
-
- Documentation: https://docs.l4yercak3.com
|
|
85
|
-
- CLI GitHub: https://github.com/voundbrand/l4yercak3-cli
|
|
86
|
-
- npm: https://www.npmjs.com/package/@l4yercak3/cli
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for API Client Detector
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
jest.mock('fs');
|
|
9
|
-
|
|
10
|
-
const ApiClientDetector = require('../src/detectors/api-client-detector');
|
|
11
|
-
|
|
12
|
-
describe('ApiClientDetector', () => {
|
|
13
|
-
const mockProjectPath = '/test/project';
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
jest.clearAllMocks();
|
|
17
|
-
fs.existsSync.mockReturnValue(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('detect', () => {
|
|
21
|
-
it('returns hasApiClient false when no API client exists', () => {
|
|
22
|
-
fs.existsSync.mockReturnValue(false);
|
|
23
|
-
|
|
24
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
25
|
-
|
|
26
|
-
expect(result.hasApiClient).toBe(false);
|
|
27
|
-
expect(result.clientPath).toBeNull();
|
|
28
|
-
expect(result.clientType).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('API client path detection', () => {
|
|
32
|
-
const testPaths = [
|
|
33
|
-
'lib/api-client.ts',
|
|
34
|
-
'lib/api-client.js',
|
|
35
|
-
'lib/api.ts',
|
|
36
|
-
'lib/api.js',
|
|
37
|
-
'src/lib/api-client.ts',
|
|
38
|
-
'src/lib/api-client.js',
|
|
39
|
-
'utils/api-client.ts',
|
|
40
|
-
'utils/api.js',
|
|
41
|
-
'src/utils/api-client.ts',
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
testPaths.forEach((clientPath) => {
|
|
45
|
-
it(`detects API client at ${clientPath}`, () => {
|
|
46
|
-
fs.existsSync.mockImplementation((p) =>
|
|
47
|
-
p === path.join(mockProjectPath, clientPath)
|
|
48
|
-
);
|
|
49
|
-
fs.readFileSync.mockReturnValue('fetch()');
|
|
50
|
-
|
|
51
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
52
|
-
|
|
53
|
-
expect(result.hasApiClient).toBe(true);
|
|
54
|
-
expect(result.clientPath).toBe(clientPath);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('client type detection', () => {
|
|
60
|
-
it('detects axios client', () => {
|
|
61
|
-
fs.existsSync.mockImplementation((p) =>
|
|
62
|
-
p === path.join(mockProjectPath, 'lib/api-client.ts')
|
|
63
|
-
);
|
|
64
|
-
fs.readFileSync.mockReturnValue(`
|
|
65
|
-
import axios from 'axios';
|
|
66
|
-
export const api = axios.create({});
|
|
67
|
-
`);
|
|
68
|
-
|
|
69
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
70
|
-
|
|
71
|
-
expect(result.clientType).toBe('axios');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('detects fetch client', () => {
|
|
75
|
-
fs.existsSync.mockImplementation((p) =>
|
|
76
|
-
p === path.join(mockProjectPath, 'lib/api-client.ts')
|
|
77
|
-
);
|
|
78
|
-
fs.readFileSync.mockReturnValue(`
|
|
79
|
-
export async function request(url) {
|
|
80
|
-
return fetch(url);
|
|
81
|
-
}
|
|
82
|
-
`);
|
|
83
|
-
|
|
84
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
85
|
-
|
|
86
|
-
expect(result.clientType).toBe('fetch');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('detects custom client (no axios or fetch)', () => {
|
|
90
|
-
fs.existsSync.mockImplementation((p) =>
|
|
91
|
-
p === path.join(mockProjectPath, 'lib/api-client.ts')
|
|
92
|
-
);
|
|
93
|
-
fs.readFileSync.mockReturnValue(`
|
|
94
|
-
import { request } from 'custom-http';
|
|
95
|
-
export const api = request;
|
|
96
|
-
`);
|
|
97
|
-
|
|
98
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
99
|
-
|
|
100
|
-
expect(result.clientType).toBe('custom');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('prefers axios over fetch when both present', () => {
|
|
104
|
-
fs.existsSync.mockImplementation((p) =>
|
|
105
|
-
p === path.join(mockProjectPath, 'lib/api-client.ts')
|
|
106
|
-
);
|
|
107
|
-
fs.readFileSync.mockReturnValue(`
|
|
108
|
-
import axios from 'axios';
|
|
109
|
-
// also uses fetch as fallback
|
|
110
|
-
const fallback = fetch;
|
|
111
|
-
`);
|
|
112
|
-
|
|
113
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
114
|
-
|
|
115
|
-
expect(result.clientType).toBe('axios');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('returns unknown on read error', () => {
|
|
119
|
-
fs.existsSync.mockImplementation((p) =>
|
|
120
|
-
p === path.join(mockProjectPath, 'lib/api-client.ts')
|
|
121
|
-
);
|
|
122
|
-
fs.readFileSync.mockImplementation(() => {
|
|
123
|
-
throw new Error('Read failed');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
127
|
-
|
|
128
|
-
expect(result.hasApiClient).toBe(true);
|
|
129
|
-
expect(result.clientType).toBe('unknown');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('environment file detection', () => {
|
|
134
|
-
it('detects .env.local', () => {
|
|
135
|
-
fs.existsSync.mockImplementation((p) =>
|
|
136
|
-
p === path.join(mockProjectPath, '.env.local')
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
140
|
-
|
|
141
|
-
expect(result.hasEnvFile).toBe(true);
|
|
142
|
-
expect(result.envFilePath).toBe('.env.local');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('detects .env', () => {
|
|
146
|
-
fs.existsSync.mockImplementation((p) =>
|
|
147
|
-
p === path.join(mockProjectPath, '.env')
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
151
|
-
|
|
152
|
-
expect(result.hasEnvFile).toBe(true);
|
|
153
|
-
expect(result.envFilePath).toBe('.env');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('detects .env.development', () => {
|
|
157
|
-
fs.existsSync.mockImplementation((p) =>
|
|
158
|
-
p === path.join(mockProjectPath, '.env.development')
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
162
|
-
|
|
163
|
-
expect(result.hasEnvFile).toBe(true);
|
|
164
|
-
expect(result.envFilePath).toBe('.env.development');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('detects .env.production', () => {
|
|
168
|
-
fs.existsSync.mockImplementation((p) =>
|
|
169
|
-
p === path.join(mockProjectPath, '.env.production')
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
173
|
-
|
|
174
|
-
expect(result.hasEnvFile).toBe(true);
|
|
175
|
-
expect(result.envFilePath).toBe('.env.production');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('prefers .env.local over other env files', () => {
|
|
179
|
-
fs.existsSync.mockImplementation((p) =>
|
|
180
|
-
p === path.join(mockProjectPath, '.env.local') ||
|
|
181
|
-
p === path.join(mockProjectPath, '.env')
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
185
|
-
|
|
186
|
-
expect(result.envFilePath).toBe('.env.local');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('returns hasEnvFile false when no env file exists', () => {
|
|
190
|
-
fs.existsSync.mockReturnValue(false);
|
|
191
|
-
|
|
192
|
-
const result = ApiClientDetector.detect(mockProjectPath);
|
|
193
|
-
|
|
194
|
-
expect(result.hasEnvFile).toBe(false);
|
|
195
|
-
expect(result.envFilePath).toBeNull();
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('stops at first found API client', () => {
|
|
200
|
-
let callCount = 0;
|
|
201
|
-
fs.existsSync.mockImplementation((p) => {
|
|
202
|
-
callCount++;
|
|
203
|
-
return p === path.join(mockProjectPath, 'lib/api-client.ts');
|
|
204
|
-
});
|
|
205
|
-
fs.readFileSync.mockReturnValue('fetch');
|
|
206
|
-
|
|
207
|
-
ApiClientDetector.detect(mockProjectPath);
|
|
208
|
-
|
|
209
|
-
// Should stop checking after finding first client
|
|
210
|
-
// (only checks up to lib/api-client.ts which is index 0)
|
|
211
|
-
expect(callCount).toBeLessThan(20);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for API Client Generator
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
jest.mock('fs');
|
|
9
|
-
jest.mock('../src/utils/file-utils', () => ({
|
|
10
|
-
checkFileOverwrite: jest.fn().mockResolvedValue('write'),
|
|
11
|
-
writeFileWithBackup: jest.fn((filePath, content, action) => {
|
|
12
|
-
if (action === 'skip') return null;
|
|
13
|
-
return filePath;
|
|
14
|
-
}),
|
|
15
|
-
ensureDir: jest.fn(),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
const ApiClientGenerator = require('../src/generators/api-client-generator');
|
|
19
|
-
const { checkFileOverwrite, writeFileWithBackup, ensureDir } = require('../src/utils/file-utils');
|
|
20
|
-
|
|
21
|
-
describe('ApiClientGenerator', () => {
|
|
22
|
-
const mockProjectPath = '/test/project';
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
jest.clearAllMocks();
|
|
26
|
-
fs.existsSync.mockReturnValue(false);
|
|
27
|
-
fs.mkdirSync.mockReturnValue(undefined);
|
|
28
|
-
fs.writeFileSync.mockReturnValue(undefined);
|
|
29
|
-
checkFileOverwrite.mockResolvedValue('write');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('generate', () => {
|
|
33
|
-
it('creates api-client.js in lib folder when no src exists', async () => {
|
|
34
|
-
fs.existsSync.mockReturnValue(false);
|
|
35
|
-
|
|
36
|
-
const options = {
|
|
37
|
-
projectPath: mockProjectPath,
|
|
38
|
-
apiKey: 'test-api-key',
|
|
39
|
-
backendUrl: 'https://backend.test.com',
|
|
40
|
-
organizationId: 'org-123',
|
|
41
|
-
isTypeScript: false,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const result = await ApiClientGenerator.generate(options);
|
|
45
|
-
|
|
46
|
-
expect(result).toBe(path.join(mockProjectPath, 'lib', 'api-client.js'));
|
|
47
|
-
expect(ensureDir).toHaveBeenCalledWith(path.join(mockProjectPath, 'lib'));
|
|
48
|
-
expect(writeFileWithBackup).toHaveBeenCalled();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('creates api-client.ts in src/lib folder when src exists', async () => {
|
|
52
|
-
fs.existsSync.mockImplementation((p) =>
|
|
53
|
-
p === path.join(mockProjectPath, 'src')
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const options = {
|
|
57
|
-
projectPath: mockProjectPath,
|
|
58
|
-
apiKey: 'test-api-key',
|
|
59
|
-
backendUrl: 'https://backend.test.com',
|
|
60
|
-
organizationId: 'org-123',
|
|
61
|
-
isTypeScript: true,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const result = await ApiClientGenerator.generate(options);
|
|
65
|
-
|
|
66
|
-
expect(result).toBe(path.join(mockProjectPath, 'src', 'lib', 'api-client.ts'));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('returns null when user skips overwrite', async () => {
|
|
70
|
-
checkFileOverwrite.mockResolvedValue('skip');
|
|
71
|
-
|
|
72
|
-
const options = {
|
|
73
|
-
projectPath: mockProjectPath,
|
|
74
|
-
apiKey: 'test-api-key',
|
|
75
|
-
backendUrl: 'https://backend.test.com',
|
|
76
|
-
organizationId: 'org-123',
|
|
77
|
-
isTypeScript: false,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const result = await ApiClientGenerator.generate(options);
|
|
81
|
-
|
|
82
|
-
expect(result).toBeNull();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe('generateCode', () => {
|
|
87
|
-
it('generates JavaScript code without type annotations', () => {
|
|
88
|
-
const code = ApiClientGenerator.generateCode({
|
|
89
|
-
apiKey: 'my-api-key',
|
|
90
|
-
backendUrl: 'https://api.example.com',
|
|
91
|
-
organizationId: 'org-456',
|
|
92
|
-
isTypeScript: false,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
expect(code).toContain('L4YERCAK3 API Client');
|
|
96
|
-
expect(code).toContain("apiKey = 'my-api-key'");
|
|
97
|
-
expect(code).toContain("baseUrl = 'https://api.example.com'");
|
|
98
|
-
expect(code).toContain("this.organizationId = 'org-456'");
|
|
99
|
-
expect(code).toContain('module.exports = L4YERCAK3Client;');
|
|
100
|
-
expect(code).not.toContain(': string');
|
|
101
|
-
expect(code).not.toContain(': Promise<any>');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('generates TypeScript code with type annotations', () => {
|
|
105
|
-
const code = ApiClientGenerator.generateCode({
|
|
106
|
-
apiKey: 'my-api-key',
|
|
107
|
-
backendUrl: 'https://api.example.com',
|
|
108
|
-
organizationId: 'org-456',
|
|
109
|
-
isTypeScript: true,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(code).toContain(': string');
|
|
113
|
-
expect(code).toContain(': Promise<any>');
|
|
114
|
-
expect(code).toContain(': RequestInit');
|
|
115
|
-
expect(code).toContain('export default L4YERCAK3Client;');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('includes CRM methods', () => {
|
|
119
|
-
const code = ApiClientGenerator.generateCode({
|
|
120
|
-
apiKey: 'key',
|
|
121
|
-
backendUrl: 'url',
|
|
122
|
-
organizationId: 'org',
|
|
123
|
-
isTypeScript: false,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
expect(code).toContain('getContacts()');
|
|
127
|
-
expect(code).toContain('getContact(contactId');
|
|
128
|
-
expect(code).toContain('createContact(data');
|
|
129
|
-
expect(code).toContain('updateContact(contactId');
|
|
130
|
-
expect(code).toContain('deleteContact(contactId');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('includes Projects methods', () => {
|
|
134
|
-
const code = ApiClientGenerator.generateCode({
|
|
135
|
-
apiKey: 'key',
|
|
136
|
-
backendUrl: 'url',
|
|
137
|
-
organizationId: 'org',
|
|
138
|
-
isTypeScript: false,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
expect(code).toContain('getProjects()');
|
|
142
|
-
expect(code).toContain('getProject(projectId');
|
|
143
|
-
expect(code).toContain('createProject(data');
|
|
144
|
-
expect(code).toContain('updateProject(projectId');
|
|
145
|
-
expect(code).toContain('deleteProject(projectId');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('includes Invoices methods', () => {
|
|
149
|
-
const code = ApiClientGenerator.generateCode({
|
|
150
|
-
apiKey: 'key',
|
|
151
|
-
backendUrl: 'url',
|
|
152
|
-
organizationId: 'org',
|
|
153
|
-
isTypeScript: false,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
expect(code).toContain('getInvoices()');
|
|
157
|
-
expect(code).toContain('getInvoice(invoiceId');
|
|
158
|
-
expect(code).toContain('createInvoice(data');
|
|
159
|
-
expect(code).toContain('updateInvoice(invoiceId');
|
|
160
|
-
expect(code).toContain('deleteInvoice(invoiceId');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('includes request method with proper headers', () => {
|
|
164
|
-
const code = ApiClientGenerator.generateCode({
|
|
165
|
-
apiKey: 'key',
|
|
166
|
-
backendUrl: 'url',
|
|
167
|
-
organizationId: 'org',
|
|
168
|
-
isTypeScript: false,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
expect(code).toContain("'Content-Type': 'application/json'");
|
|
172
|
-
expect(code).toContain('Authorization');
|
|
173
|
-
expect(code).toContain('X-Organization-Id');
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|