codecrypto-cli 1.0.23 → 1.0.25

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.
@@ -399,30 +399,111 @@ echo "✅ Deployment preparation completed inside container"
399
399
  process.exit(1);
400
400
  }
401
401
 
402
- // Paso 4: Verificar/crear builder multi-plataforma
403
- const builderSpinner = ora('Setting up multi-platform builder...').start();
404
- try {
402
+ // Detectar si estamos en Windows (en Windows usamos docker build, no buildx)
403
+ const isWindows = os.platform() === 'win32';
404
+
405
+ // Paso 4: Verificar/crear builder multi-plataforma (solo si NO es Windows)
406
+ if (!isWindows) {
407
+ const builderSpinner = ora('Setting up multi-platform builder...').start();
408
+ try {
409
+
410
+ // Listar builders disponibles, ignorando errores de builders con problemas
405
411
  let buildersOutput = '';
412
+ let currentBuilder = '';
406
413
  try {
407
- buildersOutput = execSync('docker buildx ls 2>/dev/null', {
408
- encoding: 'utf-8',
409
- stdio: 'pipe',
410
- shell: '/bin/sh',
411
- });
414
+ // En Windows, usar un enfoque diferente para redirigir stderr
415
+ if (isWindows) {
416
+ // En Windows, capturar stderr pero ignorarlo si hay errores
417
+ try {
418
+ buildersOutput = execSync('docker buildx ls', {
419
+ encoding: 'utf-8',
420
+ stdio: ['ignore', 'pipe', 'ignore'],
421
+ });
422
+ } catch (error: any) {
423
+ if (error.stdout) {
424
+ buildersOutput = error.stdout.toString();
425
+ }
426
+ console.log(chalk.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
427
+ }
428
+ } else {
429
+ // En Unix/Linux/Mac, usar redirección estándar
430
+ buildersOutput = execSync('docker buildx ls 2>/dev/null', {
431
+ encoding: 'utf-8',
432
+ stdio: 'pipe',
433
+ shell: '/bin/sh',
434
+ });
435
+ }
436
+
437
+ // Obtener el builder actual (marcado con *)
438
+ if (buildersOutput) {
439
+ const lines = buildersOutput.split('\n');
440
+ for (const line of lines) {
441
+ if (line.trim().startsWith('*')) {
442
+ const match = line.match(/\*\s+(\S+)/);
443
+ if (match) {
444
+ currentBuilder = match[1];
445
+ break;
446
+ }
447
+ }
448
+ }
449
+ }
412
450
  } catch (error) {
451
+ // Si hay errores al listar builders (por ejemplo, builder "cc" con problemas SSH),
452
+ // intentar continuar de todas formas
413
453
  console.log(chalk.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
414
454
  }
415
455
 
456
+ // Mostrar información de debugging
457
+ console.log(chalk.gray('\n📋 Buildx Builders Information:'));
458
+ console.log(chalk.gray('─'.repeat(60)));
459
+ if (buildersOutput) {
460
+ const lines = buildersOutput.split('\n').filter(l => l.trim());
461
+ for (const line of lines) {
462
+ if (line.trim().startsWith('*')) {
463
+ console.log(chalk.cyan(line));
464
+ } else {
465
+ console.log(chalk.gray(line));
466
+ }
467
+ }
468
+ } else {
469
+ console.log(chalk.yellow(' No builders found or error listing builders'));
470
+ }
471
+ if (currentBuilder) {
472
+ console.log(chalk.gray(`\n Current builder: ${chalk.cyan(currentBuilder)}`));
473
+ }
474
+ console.log(chalk.gray('─'.repeat(60) + '\n'));
475
+
476
+ // Intentar obtener más detalles del builder actual si existe
477
+ if (currentBuilder) {
478
+ try {
479
+ const inspectOutput = execSync(`docker buildx inspect ${currentBuilder}`, {
480
+ encoding: 'utf-8',
481
+ stdio: 'pipe',
482
+ });
483
+ console.log(chalk.gray('📊 Builder Details:'));
484
+ console.log(chalk.gray('─'.repeat(60)));
485
+ const detailLines = inspectOutput.split('\n').slice(0, 20); // Mostrar primeras 20 líneas
486
+ for (const line of detailLines) {
487
+ console.log(chalk.gray(` ${line}`));
488
+ }
489
+ console.log(chalk.gray('─'.repeat(60) + '\n'));
490
+ } catch (error) {
491
+ // Ignorar errores al inspeccionar
492
+ }
493
+ }
494
+
416
495
  const builderName = 'multiarch-builder';
417
- if (!buildersOutput.includes(builderName)) {
496
+ if (!buildersOutput || !buildersOutput.includes(builderName)) {
418
497
  builderSpinner.text = 'Creating multi-platform builder...';
419
498
  execSync(`docker buildx create --name ${builderName} --use --bootstrap`, {
420
499
  stdio: 'pipe',
421
500
  });
501
+ currentBuilder = builderName;
422
502
  } else {
423
503
  builderSpinner.text = 'Using existing multi-platform builder...';
424
504
  try {
425
505
  execSync(`docker buildx use ${builderName}`, { stdio: 'pipe' });
506
+ currentBuilder = builderName;
426
507
  } catch (error) {
427
508
  builderSpinner.text = 'Recreating multi-platform builder...';
428
509
  try {
@@ -430,14 +511,47 @@ echo "✅ Deployment preparation completed inside container"
430
511
  } catch {
431
512
  // Ignorar si no existe
432
513
  }
433
- execSync(`docker buildx create --name ${builderName} --use --bootstrap`, { stdio: 'pipe' });
514
+ execSync(`docker buildx create --name ${builderName} --use --bootstrap`, {
515
+ stdio: 'pipe'
516
+ });
517
+ currentBuilder = builderName;
434
518
  }
435
519
  }
436
- builderSpinner.succeed('Builder ready');
437
- } catch (error: any) {
438
- builderSpinner.fail('Failed to setup builder');
439
- console.error(chalk.red('Error setting up Docker buildx builder'));
440
- process.exit(1);
520
+
521
+ // Verificar que el builder está activo
522
+ try {
523
+ const verifyOutput = execSync('docker buildx ls', {
524
+ encoding: 'utf-8',
525
+ stdio: 'pipe',
526
+ });
527
+ const verifyLines = verifyOutput.split('\n');
528
+ let activeBuilderFound = false;
529
+ for (const line of verifyLines) {
530
+ if (line.trim().startsWith('*') && line.includes(builderName)) {
531
+ activeBuilderFound = true;
532
+ break;
533
+ }
534
+ }
535
+ if (activeBuilderFound) {
536
+ builderSpinner.succeed(`Builder ready: ${builderName}`);
537
+ console.log(chalk.green(`✓ Using builder: ${chalk.cyan(builderName)}`));
538
+ } else {
539
+ builderSpinner.warn(`Builder created but may not be active`);
540
+ console.log(chalk.yellow(`⚠ Builder created but not confirmed as active`));
541
+ }
542
+ } catch (error) {
543
+ builderSpinner.succeed('Builder ready');
544
+ console.log(chalk.yellow(`⚠ Could not verify builder status`));
545
+ }
546
+ } catch (error: any) {
547
+ builderSpinner.fail('Failed to setup builder');
548
+ console.error(chalk.red('Error setting up Docker buildx builder'));
549
+ process.exit(1);
550
+ }
551
+ } else {
552
+ // En Windows, no usamos buildx, solo docker build normal
553
+ console.log(chalk.blue('\n📦 Using standard Docker build (Windows mode)'));
554
+ console.log(chalk.gray(' Note: Multi-platform builds are disabled on Windows\n'));
441
555
  }
442
556
 
443
557
  // Verificar autenticación de Docker si se va a hacer push
@@ -459,48 +573,88 @@ echo "✅ Deployment preparation completed inside container"
459
573
  }
460
574
 
461
575
  // Paso 5: Construir y hacer push
462
- // Detectar si estamos en Windows (buildx tiene problemas con ARM en Windows)
463
- const isWindows = os.platform() === 'win32';
464
- const platform = isWindows ? 'linux/amd64' : 'linux/amd64,linux/arm64';
465
576
  const platformDisplay = isWindows ? 'linux/amd64' : 'linux/amd64, linux/arm64';
466
577
  const buildSpinnerText = isWindows
467
- ? 'Building Docker image for linux/amd64...'
578
+ ? 'Building Docker image (Windows mode)...'
468
579
  : 'Building Docker image for multiple platforms...';
469
580
 
470
581
  const buildDockerSpinner = ora(buildSpinnerText).start();
471
582
  try {
472
- const tags = shouldPush
473
- ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
474
- : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
475
-
476
- const buildCommand = `docker buildx build \
477
- --platform ${platform} \
478
- ${tags.join(' \\\n ')} \
479
- --progress=plain \
480
- .`;
481
-
482
- console.log(chalk.gray('\n🔨 Build command:'));
483
- console.log(chalk.gray('─'.repeat(60)));
484
- console.log(chalk.cyan(buildCommand));
485
- console.log(chalk.gray('─'.repeat(60)));
486
- console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
487
- console.log(chalk.gray(` Platforms: ${chalk.cyan(platformDisplay)}`));
488
583
  if (isWindows) {
489
- console.log(chalk.yellow(` Note: Building only for linux/amd64 on Windows (ARM builds are disabled)`));
490
- }
491
- console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes') : chalk.yellow('No')}\n`));
584
+ // En Windows, usar docker build normal (no buildx)
585
+ const buildCommand = `docker build \
586
+ --tag ${imageName} \
587
+ --tag ${imageLatest} \
588
+ --progress=plain \
589
+ .`;
590
+
591
+ console.log(chalk.gray('\n🔨 Build command:'));
592
+ console.log(chalk.gray('─'.repeat(60)));
593
+ console.log(chalk.cyan(buildCommand));
594
+ console.log(chalk.gray('─'.repeat(60)));
595
+ console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
596
+ console.log(chalk.gray(` Platform: ${chalk.cyan('linux/amd64')}`));
597
+ console.log(chalk.gray(` Using: ${chalk.cyan('docker build')} (Windows mode)`));
598
+ console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes (after build)') : chalk.yellow('No')}\n`));
599
+
600
+ execSync(buildCommand, {
601
+ cwd: resolvedDestFolder,
602
+ stdio: 'inherit'
603
+ });
604
+
605
+ buildDockerSpinner.succeed('Docker image built successfully');
606
+
607
+ // Si se debe hacer push, hacerlo por separado
608
+ if (shouldPush) {
609
+ const pushSpinner = ora('Pushing Docker images to registry...').start();
610
+ try {
611
+ execSync(`docker push ${imageName}`, {
612
+ cwd: resolvedDestFolder,
613
+ stdio: 'inherit'
614
+ });
615
+ execSync(`docker push ${imageLatest}`, {
616
+ cwd: resolvedDestFolder,
617
+ stdio: 'inherit'
618
+ });
619
+ pushSpinner.succeed('Docker images pushed successfully');
620
+ } catch (error: any) {
621
+ pushSpinner.fail('Failed to push Docker images');
622
+ throw error;
623
+ }
624
+ }
625
+ } else {
626
+ // En otros sistemas, usar docker buildx build
627
+ const platform = 'linux/amd64,linux/arm64';
628
+ const tags = shouldPush
629
+ ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
630
+ : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
631
+
632
+ const buildCommand = `docker buildx build \
633
+ --platform ${platform} \
634
+ ${tags.join(' \\\n ')} \
635
+ --progress=plain \
636
+ .`;
492
637
 
493
- execSync(buildCommand, {
494
- cwd: resolvedDestFolder,
495
- stdio: 'inherit'
496
- });
638
+ console.log(chalk.gray('\n🔨 Build command:'));
639
+ console.log(chalk.gray('─'.repeat(60)));
640
+ console.log(chalk.cyan(buildCommand));
641
+ console.log(chalk.gray('─'.repeat(60)));
642
+ console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
643
+ console.log(chalk.gray(` Platforms: ${chalk.cyan(platformDisplay)}`));
644
+ console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes') : chalk.yellow('No')}\n`));
497
645
 
498
- buildDockerSpinner.succeed('Docker image built successfully');
646
+ execSync(buildCommand, {
647
+ cwd: resolvedDestFolder,
648
+ stdio: 'inherit'
649
+ });
650
+
651
+ buildDockerSpinner.succeed('Docker image built successfully');
652
+ }
499
653
 
500
654
  console.log(chalk.green('\n✅ Image build and push completed successfully!'));
501
655
  console.log(chalk.gray('📦 Image details:'));
502
656
  console.log(chalk.gray('─'.repeat(60)));
503
- console.log(chalk.white(` Platforms: ${chalk.cyan('linux/amd64, linux/arm64')}`));
657
+ console.log(chalk.white(` Platforms: ${chalk.cyan(platformDisplay)}`));
504
658
  console.log(chalk.white(` Version: ${chalk.cyan(version)}`));
505
659
  console.log(chalk.white(` Tags:`));
506
660
  console.log(chalk.white(` - ${chalk.cyan(imageName)}`));
@@ -543,35 +543,112 @@ CMD ${JSON.stringify(startCmd)}
543
543
  console.log(chalk.gray(`\n📄 Dockerfile created for ${projectType} application`));
544
544
  }
545
545
 
546
- // Paso 4: Verificar/crear builder multi-plataforma
547
- const builderSpinner = ora('Setting up multi-platform builder...').start();
548
- try {
546
+ // Detectar si estamos en Windows (en Windows usamos docker build, no buildx)
547
+ const isWindows = os.platform() === 'win32';
548
+
549
+ // Paso 4: Verificar/crear builder multi-plataforma (solo si NO es Windows)
550
+ if (!isWindows) {
551
+ const builderSpinner = ora('Setting up multi-platform builder...').start();
552
+ try {
553
+
549
554
  // Listar builders disponibles, ignorando errores de builders con problemas
550
555
  let buildersOutput = '';
556
+ let currentBuilder = '';
551
557
  try {
552
- // Redirigir stderr a /dev/null para ignorar errores de builders problemáticos
553
- buildersOutput = execSync('docker buildx ls 2>/dev/null', {
554
- encoding: 'utf-8',
555
- stdio: 'pipe',
556
- shell: '/bin/sh',
557
- });
558
+ // En Windows, usar un enfoque diferente para redirigir stderr
559
+ if (isWindows) {
560
+ // En Windows, capturar stderr pero ignorarlo si hay errores
561
+ try {
562
+ buildersOutput = execSync('docker buildx ls', {
563
+ encoding: 'utf-8',
564
+ stdio: ['ignore', 'pipe', 'ignore'],
565
+ });
566
+ } catch (error: any) {
567
+ if (error.stdout) {
568
+ buildersOutput = error.stdout.toString();
569
+ }
570
+ console.log(chalk.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
571
+ }
572
+ } else {
573
+ // En Unix/Linux/Mac, usar redirección estándar
574
+ buildersOutput = execSync('docker buildx ls 2>/dev/null', {
575
+ encoding: 'utf-8',
576
+ stdio: 'pipe',
577
+ shell: '/bin/sh',
578
+ });
579
+ }
580
+
581
+ // Obtener el builder actual (marcado con *)
582
+ if (buildersOutput) {
583
+ const lines = buildersOutput.split('\n');
584
+ for (const line of lines) {
585
+ if (line.trim().startsWith('*')) {
586
+ const match = line.match(/\*\s+(\S+)/);
587
+ if (match) {
588
+ currentBuilder = match[1];
589
+ break;
590
+ }
591
+ }
592
+ }
593
+ }
558
594
  } catch (error) {
559
595
  // Si hay errores al listar builders (por ejemplo, builder "cc" con problemas SSH),
560
596
  // intentar continuar de todas formas
561
597
  console.log(chalk.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
562
598
  }
563
599
 
600
+ // Mostrar información de debugging
601
+ console.log(chalk.gray('\n📋 Buildx Builders Information:'));
602
+ console.log(chalk.gray('─'.repeat(60)));
603
+ if (buildersOutput) {
604
+ const lines = buildersOutput.split('\n').filter(l => l.trim());
605
+ for (const line of lines) {
606
+ if (line.trim().startsWith('*')) {
607
+ console.log(chalk.cyan(line));
608
+ } else {
609
+ console.log(chalk.gray(line));
610
+ }
611
+ }
612
+ } else {
613
+ console.log(chalk.yellow(' No builders found or error listing builders'));
614
+ }
615
+ if (currentBuilder) {
616
+ console.log(chalk.gray(`\n Current builder: ${chalk.cyan(currentBuilder)}`));
617
+ }
618
+ console.log(chalk.gray('─'.repeat(60) + '\n'));
619
+
620
+ // Intentar obtener más detalles del builder actual si existe
621
+ if (currentBuilder) {
622
+ try {
623
+ const inspectOutput = execSync(`docker buildx inspect ${currentBuilder}`, {
624
+ encoding: 'utf-8',
625
+ stdio: 'pipe',
626
+ });
627
+ console.log(chalk.gray('📊 Builder Details:'));
628
+ console.log(chalk.gray('─'.repeat(60)));
629
+ const detailLines = inspectOutput.split('\n').slice(0, 20); // Mostrar primeras 20 líneas
630
+ for (const line of detailLines) {
631
+ console.log(chalk.gray(` ${line}`));
632
+ }
633
+ console.log(chalk.gray('─'.repeat(60) + '\n'));
634
+ } catch (error) {
635
+ // Ignorar errores al inspeccionar
636
+ }
637
+ }
638
+
564
639
  const builderName = 'multiarch-builder';
565
- if (!buildersOutput.includes(builderName)) {
640
+ if (!buildersOutput || !buildersOutput.includes(builderName)) {
566
641
  builderSpinner.text = 'Creating multi-platform builder...';
567
642
  execSync(`docker buildx create --name ${builderName} --use --bootstrap`, {
568
643
  stdio: 'pipe',
569
644
  // No heredar stderr para evitar errores de otros builders
570
645
  });
646
+ currentBuilder = builderName;
571
647
  } else {
572
648
  builderSpinner.text = 'Using existing multi-platform builder...';
573
649
  try {
574
650
  execSync(`docker buildx use ${builderName}`, { stdio: 'pipe' });
651
+ currentBuilder = builderName;
575
652
  } catch (error) {
576
653
  // Si falla, intentar crearlo de nuevo
577
654
  builderSpinner.text = 'Recreating multi-platform builder...';
@@ -580,17 +657,50 @@ CMD ${JSON.stringify(startCmd)}
580
657
  } catch {
581
658
  // Ignorar si no existe
582
659
  }
583
- execSync(`docker buildx create --name ${builderName} --use --bootstrap`, { stdio: 'pipe' });
660
+ execSync(`docker buildx create --name ${builderName} --use --bootstrap`, {
661
+ stdio: 'pipe'
662
+ });
663
+ currentBuilder = builderName;
584
664
  }
585
665
  }
586
- builderSpinner.succeed('Builder ready');
587
- } catch (error: any) {
588
- builderSpinner.fail('Failed to setup builder');
589
- console.error(chalk.red('Error setting up Docker buildx builder'));
590
- console.error(chalk.yellow('💡 Tip: If you have problematic builders configured, you can remove them with:'));
591
- console.error(chalk.cyan(' docker buildx rm <builder-name>'));
592
- console.error(chalk.yellow(' Or inspect them with: docker buildx inspect <builder-name>'));
593
- process.exit(1);
666
+
667
+ // Verificar que el builder está activo
668
+ try {
669
+ const verifyOutput = execSync('docker buildx ls', {
670
+ encoding: 'utf-8',
671
+ stdio: 'pipe',
672
+ });
673
+ const verifyLines = verifyOutput.split('\n');
674
+ let activeBuilderFound = false;
675
+ for (const line of verifyLines) {
676
+ if (line.trim().startsWith('*') && line.includes(builderName)) {
677
+ activeBuilderFound = true;
678
+ break;
679
+ }
680
+ }
681
+ if (activeBuilderFound) {
682
+ builderSpinner.succeed(`Builder ready: ${builderName}`);
683
+ console.log(chalk.green(`✓ Using builder: ${chalk.cyan(builderName)}`));
684
+ } else {
685
+ builderSpinner.warn(`Builder created but may not be active`);
686
+ console.log(chalk.yellow(`⚠ Builder created but not confirmed as active`));
687
+ }
688
+ } catch (error) {
689
+ builderSpinner.succeed('Builder ready');
690
+ console.log(chalk.yellow(`⚠ Could not verify builder status`));
691
+ }
692
+ } catch (error: any) {
693
+ builderSpinner.fail('Failed to setup builder');
694
+ console.error(chalk.red('Error setting up Docker buildx builder'));
695
+ console.error(chalk.yellow('💡 Tip: If you have problematic builders configured, you can remove them with:'));
696
+ console.error(chalk.cyan(' docker buildx rm <builder-name>'));
697
+ console.error(chalk.yellow(' Or inspect them with: docker buildx inspect <builder-name>'));
698
+ process.exit(1);
699
+ }
700
+ } else {
701
+ // En Windows, no usamos buildx, solo docker build normal
702
+ console.log(chalk.blue('\n📦 Using standard Docker build (Windows mode)'));
703
+ console.log(chalk.gray(' Note: Multi-platform builds are disabled on Windows\n'));
594
704
  }
595
705
 
596
706
  // Verificar autenticación de Docker si se va a hacer push
@@ -616,48 +726,88 @@ CMD ${JSON.stringify(startCmd)}
616
726
  }
617
727
 
618
728
  // Paso 5: Construir y hacer push
619
- // Detectar si estamos en Windows (buildx tiene problemas con ARM en Windows)
620
- const isWindows = os.platform() === 'win32';
621
- const platform = isWindows ? 'linux/amd64' : 'linux/amd64,linux/arm64';
622
729
  const platformDisplay = isWindows ? 'linux/amd64' : 'linux/amd64, linux/arm64';
623
730
  const buildSpinnerText = isWindows
624
- ? 'Building Docker image for linux/amd64...'
731
+ ? 'Building Docker image (Windows mode)...'
625
732
  : 'Building Docker image for multiple platforms...';
626
733
 
627
734
  const buildDockerSpinner = ora(buildSpinnerText).start();
628
735
  try {
629
- const tags = shouldPush
630
- ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
631
- : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
632
-
633
- const buildCommand = `docker buildx build \
634
- --platform ${platform} \
635
- ${tags.join(' \\\n ')} \
636
- --progress=plain \
637
- .`;
638
-
639
- console.log(chalk.gray('\n🔨 Build command:'));
640
- console.log(chalk.gray('─'.repeat(60)));
641
- console.log(chalk.cyan(buildCommand));
642
- console.log(chalk.gray('─'.repeat(60)));
643
- console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
644
- console.log(chalk.gray(` Platforms: ${chalk.cyan(platformDisplay)}`));
645
736
  if (isWindows) {
646
- console.log(chalk.yellow(` Note: Building only for linux/amd64 on Windows (ARM builds are disabled)`));
647
- }
648
- console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes') : chalk.yellow('No')}\n`));
737
+ // En Windows, usar docker build normal (no buildx)
738
+ const buildCommand = `docker build \
739
+ --tag ${imageName} \
740
+ --tag ${imageLatest} \
741
+ --progress=plain \
742
+ .`;
743
+
744
+ console.log(chalk.gray('\n🔨 Build command:'));
745
+ console.log(chalk.gray('─'.repeat(60)));
746
+ console.log(chalk.cyan(buildCommand));
747
+ console.log(chalk.gray('─'.repeat(60)));
748
+ console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
749
+ console.log(chalk.gray(` Platform: ${chalk.cyan('linux/amd64')}`));
750
+ console.log(chalk.gray(` Using: ${chalk.cyan('docker build')} (Windows mode)`));
751
+ console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes (after build)') : chalk.yellow('No')}\n`));
752
+
753
+ execSync(buildCommand, {
754
+ cwd: resolvedDestFolder,
755
+ stdio: 'inherit'
756
+ });
757
+
758
+ buildDockerSpinner.succeed('Docker image built successfully');
759
+
760
+ // Si se debe hacer push, hacerlo por separado
761
+ if (shouldPush) {
762
+ const pushSpinner = ora('Pushing Docker images to registry...').start();
763
+ try {
764
+ execSync(`docker push ${imageName}`, {
765
+ cwd: resolvedDestFolder,
766
+ stdio: 'inherit'
767
+ });
768
+ execSync(`docker push ${imageLatest}`, {
769
+ cwd: resolvedDestFolder,
770
+ stdio: 'inherit'
771
+ });
772
+ pushSpinner.succeed('Docker images pushed successfully');
773
+ } catch (error: any) {
774
+ pushSpinner.fail('Failed to push Docker images');
775
+ throw error;
776
+ }
777
+ }
778
+ } else {
779
+ // En otros sistemas, usar docker buildx build
780
+ const platform = 'linux/amd64,linux/arm64';
781
+ const tags = shouldPush
782
+ ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
783
+ : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
784
+
785
+ const buildCommand = `docker buildx build \
786
+ --platform ${platform} \
787
+ ${tags.join(' \\\n ')} \
788
+ --progress=plain \
789
+ .`;
649
790
 
650
- execSync(buildCommand, {
651
- cwd: resolvedDestFolder,
652
- stdio: 'inherit'
653
- });
791
+ console.log(chalk.gray('\n🔨 Build command:'));
792
+ console.log(chalk.gray('─'.repeat(60)));
793
+ console.log(chalk.cyan(buildCommand));
794
+ console.log(chalk.gray('─'.repeat(60)));
795
+ console.log(chalk.gray(`\n Working directory: ${chalk.cyan(resolvedDestFolder)}`));
796
+ console.log(chalk.gray(` Platforms: ${chalk.cyan(platformDisplay)}`));
797
+ console.log(chalk.gray(` Push to registry: ${shouldPush ? chalk.green('Yes') : chalk.yellow('No')}\n`));
654
798
 
655
- buildDockerSpinner.succeed('Docker image built successfully');
799
+ execSync(buildCommand, {
800
+ cwd: resolvedDestFolder,
801
+ stdio: 'inherit'
802
+ });
803
+
804
+ buildDockerSpinner.succeed('Docker image built successfully');
805
+ }
656
806
 
657
807
  console.log(chalk.green('\n✅ Image build and push completed successfully!'));
658
808
  console.log(chalk.gray('📦 Image details:'));
659
809
  console.log(chalk.gray('─'.repeat(60)));
660
- console.log(chalk.white(` Platforms: ${chalk.cyan('linux/amd64, linux/arm64')}`));
810
+ console.log(chalk.white(` Platforms: ${chalk.cyan(platformDisplay)}`));
661
811
  console.log(chalk.white(` Version: ${chalk.cyan(version)}`));
662
812
  console.log(chalk.white(` Tags:`));
663
813
  console.log(chalk.white(` - ${chalk.cyan(imageName)}`));