@l4yercak3/cli 1.2.7 → 1.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@l4yercak3/cli",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Icing on the L4yercak3 - The sweet finishing touch for your Layer Cake integration",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -490,6 +490,44 @@ async function handleSpread() {
490
490
  // Check if application already exists for this project
491
491
  const existingApp = await backendClient.checkExistingApplication(organizationId, projectPathHash);
492
492
 
493
+ // Helper to register a new application
494
+ const registerNewApplication = async () => {
495
+ // Build source object, only including routerType if it has a value
496
+ const sourceData = {
497
+ type: 'cli',
498
+ projectPathHash,
499
+ cliVersion: pkg.version,
500
+ framework: detection.framework.type || 'unknown',
501
+ frameworkVersion: detection.framework.metadata?.version,
502
+ hasTypeScript: detection.framework.metadata?.hasTypeScript || false,
503
+ };
504
+
505
+ // Only add routerType if it exists
506
+ if (detection.framework.metadata?.routerType) {
507
+ sourceData.routerType = detection.framework.metadata.routerType;
508
+ }
509
+
510
+ const registrationData = {
511
+ organizationId,
512
+ name: projectName,
513
+ description: `Connected via CLI from ${detection.framework.type || 'unknown'} project`,
514
+ source: sourceData,
515
+ connection: {
516
+ features,
517
+ hasFrontendDatabase: !!detection.framework.metadata?.hasPrisma,
518
+ frontendDatabaseType: detection.framework.metadata?.hasPrisma ? 'prisma' : undefined,
519
+ },
520
+ deployment: {
521
+ productionUrl: productionDomain ? `https://${productionDomain}` : undefined,
522
+ githubRepo: detection.github.isGitHub ? `${detection.github.owner}/${detection.github.repo}` : undefined,
523
+ githubBranch: detection.github.branch || 'main',
524
+ },
525
+ };
526
+
527
+ const registrationResult = await backendClient.registerApplication(registrationData);
528
+ return registrationResult;
529
+ };
530
+
493
531
  if (existingApp.found && existingApp.application) {
494
532
  // Application already registered
495
533
  console.log(chalk.yellow(` ⚠️ This project is already registered as "${existingApp.application.name}"`));
@@ -501,6 +539,7 @@ async function handleSpread() {
501
539
  message: 'What would you like to do?',
502
540
  choices: [
503
541
  { name: 'Update existing registration', value: 'update' },
542
+ { name: 'Register as new application', value: 'new' },
504
543
  { name: 'Skip registration (keep existing)', value: 'skip' },
505
544
  ],
506
545
  },
@@ -509,6 +548,7 @@ async function handleSpread() {
509
548
  if (updateAction === 'update') {
510
549
  // Update existing application
511
550
  const updateData = {
551
+ name: projectName, // Update name too
512
552
  connection: {
513
553
  features,
514
554
  hasFrontendDatabase: !!detection.framework.metadata?.hasPrisma,
@@ -524,45 +564,22 @@ async function handleSpread() {
524
564
  applicationId = existingApp.application.id;
525
565
  isUpdate = true;
526
566
  console.log(chalk.green(` ✅ Application registration updated\n`));
567
+ } else if (updateAction === 'new') {
568
+ // Register as new application
569
+ const registrationResult = await registerNewApplication();
570
+ applicationId = registrationResult.applicationId;
571
+ console.log(chalk.green(` ✅ New application registered with L4YERCAK3\n`));
572
+
573
+ if (registrationResult.apiKey && registrationResult.apiKey.key) {
574
+ console.log(chalk.gray(` API key generated: ${registrationResult.apiKey.prefix}`));
575
+ }
527
576
  } else {
528
577
  applicationId = existingApp.application.id;
529
578
  console.log(chalk.gray(` Skipped registration update\n`));
530
579
  }
531
580
  } else {
532
581
  // Register new application
533
- // Build source object, only including routerType if it has a value
534
- const sourceData = {
535
- type: 'cli',
536
- projectPathHash,
537
- cliVersion: pkg.version,
538
- framework: detection.framework.type || 'unknown',
539
- frameworkVersion: detection.framework.metadata?.version,
540
- hasTypeScript: detection.framework.metadata?.hasTypeScript || false,
541
- };
542
-
543
- // Only add routerType if it exists (Next.js has 'app'/'pages', Expo has 'expo-router'/'react-navigation')
544
- if (detection.framework.metadata?.routerType) {
545
- sourceData.routerType = detection.framework.metadata.routerType;
546
- }
547
-
548
- const registrationData = {
549
- organizationId,
550
- name: projectName,
551
- description: `Connected via CLI from ${detection.framework.type || 'unknown'} project`,
552
- source: sourceData,
553
- connection: {
554
- features,
555
- hasFrontendDatabase: !!detection.framework.metadata?.hasPrisma,
556
- frontendDatabaseType: detection.framework.metadata?.hasPrisma ? 'prisma' : undefined,
557
- },
558
- deployment: {
559
- productionUrl: productionDomain ? `https://${productionDomain}` : undefined,
560
- githubRepo: detection.github.isGitHub ? `${detection.github.owner}/${detection.github.repo}` : undefined,
561
- githubBranch: detection.github.branch || 'main',
562
- },
563
- };
564
-
565
- const registrationResult = await backendClient.registerApplication(registrationData);
582
+ const registrationResult = await registerNewApplication();
566
583
  applicationId = registrationResult.applicationId;
567
584
  console.log(chalk.green(` ✅ Application registered with L4YERCAK3\n`));
568
585