@l4yercak3/cli 1.2.6 → 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 +1 -1
- package/src/commands/spread.js +66 -34
package/package.json
CHANGED
package/src/commands/spread.js
CHANGED
|
@@ -135,6 +135,21 @@ async function handleSpread() {
|
|
|
135
135
|
|
|
136
136
|
console.log('');
|
|
137
137
|
|
|
138
|
+
// Step 1.5: Project name
|
|
139
|
+
const folderName = path.basename(detection.projectPath);
|
|
140
|
+
const defaultProjectName = detection.github.repo || folderName;
|
|
141
|
+
|
|
142
|
+
const { projectName } = await inquirer.prompt([
|
|
143
|
+
{
|
|
144
|
+
type: 'input',
|
|
145
|
+
name: 'projectName',
|
|
146
|
+
message: 'Project name:',
|
|
147
|
+
default: defaultProjectName,
|
|
148
|
+
validate: (input) => input.trim().length > 0 || 'Project name is required',
|
|
149
|
+
},
|
|
150
|
+
]);
|
|
151
|
+
console.log(chalk.green(` ✅ Project: ${projectName}\n`));
|
|
152
|
+
|
|
138
153
|
// Step 2: Organization selection
|
|
139
154
|
console.log(chalk.cyan(' 📦 Organization Setup\n'));
|
|
140
155
|
let organizationId;
|
|
@@ -438,7 +453,7 @@ async function handleSpread() {
|
|
|
438
453
|
features,
|
|
439
454
|
oauthProviders,
|
|
440
455
|
productionDomain,
|
|
441
|
-
appName:
|
|
456
|
+
appName: projectName,
|
|
442
457
|
isTypeScript,
|
|
443
458
|
routerType,
|
|
444
459
|
frameworkType: detection.framework.type || 'unknown',
|
|
@@ -475,6 +490,44 @@ async function handleSpread() {
|
|
|
475
490
|
// Check if application already exists for this project
|
|
476
491
|
const existingApp = await backendClient.checkExistingApplication(organizationId, projectPathHash);
|
|
477
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
|
+
|
|
478
531
|
if (existingApp.found && existingApp.application) {
|
|
479
532
|
// Application already registered
|
|
480
533
|
console.log(chalk.yellow(` ⚠️ This project is already registered as "${existingApp.application.name}"`));
|
|
@@ -486,6 +539,7 @@ async function handleSpread() {
|
|
|
486
539
|
message: 'What would you like to do?',
|
|
487
540
|
choices: [
|
|
488
541
|
{ name: 'Update existing registration', value: 'update' },
|
|
542
|
+
{ name: 'Register as new application', value: 'new' },
|
|
489
543
|
{ name: 'Skip registration (keep existing)', value: 'skip' },
|
|
490
544
|
],
|
|
491
545
|
},
|
|
@@ -494,6 +548,7 @@ async function handleSpread() {
|
|
|
494
548
|
if (updateAction === 'update') {
|
|
495
549
|
// Update existing application
|
|
496
550
|
const updateData = {
|
|
551
|
+
name: projectName, // Update name too
|
|
497
552
|
connection: {
|
|
498
553
|
features,
|
|
499
554
|
hasFrontendDatabase: !!detection.framework.metadata?.hasPrisma,
|
|
@@ -509,45 +564,22 @@ async function handleSpread() {
|
|
|
509
564
|
applicationId = existingApp.application.id;
|
|
510
565
|
isUpdate = true;
|
|
511
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
|
+
}
|
|
512
576
|
} else {
|
|
513
577
|
applicationId = existingApp.application.id;
|
|
514
578
|
console.log(chalk.gray(` Skipped registration update\n`));
|
|
515
579
|
}
|
|
516
580
|
} else {
|
|
517
581
|
// Register new application
|
|
518
|
-
|
|
519
|
-
const sourceData = {
|
|
520
|
-
type: 'cli',
|
|
521
|
-
projectPathHash,
|
|
522
|
-
cliVersion: pkg.version,
|
|
523
|
-
framework: detection.framework.type || 'unknown',
|
|
524
|
-
frameworkVersion: detection.framework.metadata?.version,
|
|
525
|
-
hasTypeScript: detection.framework.metadata?.hasTypeScript || false,
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
// Only add routerType if it exists (Next.js has 'app'/'pages', Expo has 'expo-router'/'react-navigation')
|
|
529
|
-
if (detection.framework.metadata?.routerType) {
|
|
530
|
-
sourceData.routerType = detection.framework.metadata.routerType;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
const registrationData = {
|
|
534
|
-
organizationId,
|
|
535
|
-
name: detection.github.repo || organizationName || 'My Application',
|
|
536
|
-
description: `Connected via CLI from ${detection.framework.type || 'unknown'} project`,
|
|
537
|
-
source: sourceData,
|
|
538
|
-
connection: {
|
|
539
|
-
features,
|
|
540
|
-
hasFrontendDatabase: !!detection.framework.metadata?.hasPrisma,
|
|
541
|
-
frontendDatabaseType: detection.framework.metadata?.hasPrisma ? 'prisma' : undefined,
|
|
542
|
-
},
|
|
543
|
-
deployment: {
|
|
544
|
-
productionUrl: productionDomain ? `https://${productionDomain}` : undefined,
|
|
545
|
-
githubRepo: detection.github.isGitHub ? `${detection.github.owner}/${detection.github.repo}` : undefined,
|
|
546
|
-
githubBranch: detection.github.branch || 'main',
|
|
547
|
-
},
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
const registrationResult = await backendClient.registerApplication(registrationData);
|
|
582
|
+
const registrationResult = await registerNewApplication();
|
|
551
583
|
applicationId = registrationResult.applicationId;
|
|
552
584
|
console.log(chalk.green(` ✅ Application registered with L4YERCAK3\n`));
|
|
553
585
|
|