codecrypto-cli 1.0.24 → 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.
@@ -538,163 +538,170 @@ CMD ${JSON.stringify(startCmd)}
538
538
  else {
539
539
  console.log(chalk_1.default.gray(`\n📄 Dockerfile created for ${projectType} application`));
540
540
  }
541
- // Paso 4: Verificar/crear builder multi-plataforma
542
- const builderSpinner = (0, ora_1.default)('Setting up multi-platform builder...').start();
543
- try {
544
- // Detectar si estamos en Windows para usar el comando apropiado
545
- const isWindows = os.platform() === 'win32';
546
- // Listar builders disponibles, ignorando errores de builders con problemas
547
- let buildersOutput = '';
548
- let currentBuilder = '';
541
+ // Detectar si estamos en Windows (en Windows usamos docker build, no buildx)
542
+ const isWindows = os.platform() === 'win32';
543
+ // Paso 4: Verificar/crear builder multi-plataforma (solo si NO es Windows)
544
+ if (!isWindows) {
545
+ const builderSpinner = (0, ora_1.default)('Setting up multi-platform builder...').start();
549
546
  try {
550
- // En Windows, usar un enfoque diferente para redirigir stderr
551
- if (isWindows) {
552
- // En Windows, capturar stderr pero ignorarlo si hay errores
553
- try {
554
- buildersOutput = (0, child_process_1.execSync)('docker buildx ls', {
547
+ // Listar builders disponibles, ignorando errores de builders con problemas
548
+ let buildersOutput = '';
549
+ let currentBuilder = '';
550
+ try {
551
+ // En Windows, usar un enfoque diferente para redirigir stderr
552
+ if (isWindows) {
553
+ // En Windows, capturar stderr pero ignorarlo si hay errores
554
+ try {
555
+ buildersOutput = (0, child_process_1.execSync)('docker buildx ls', {
556
+ encoding: 'utf-8',
557
+ stdio: ['ignore', 'pipe', 'ignore'],
558
+ });
559
+ }
560
+ catch (error) {
561
+ if (error.stdout) {
562
+ buildersOutput = error.stdout.toString();
563
+ }
564
+ console.log(chalk_1.default.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
565
+ }
566
+ }
567
+ else {
568
+ // En Unix/Linux/Mac, usar redirección estándar
569
+ buildersOutput = (0, child_process_1.execSync)('docker buildx ls 2>/dev/null', {
555
570
  encoding: 'utf-8',
556
- stdio: ['ignore', 'pipe', 'ignore'],
571
+ stdio: 'pipe',
572
+ shell: '/bin/sh',
557
573
  });
558
574
  }
559
- catch (error) {
560
- if (error.stdout) {
561
- buildersOutput = error.stdout.toString();
575
+ // Obtener el builder actual (marcado con *)
576
+ if (buildersOutput) {
577
+ const lines = buildersOutput.split('\n');
578
+ for (const line of lines) {
579
+ if (line.trim().startsWith('*')) {
580
+ const match = line.match(/\*\s+(\S+)/);
581
+ if (match) {
582
+ currentBuilder = match[1];
583
+ break;
584
+ }
585
+ }
562
586
  }
563
- console.log(chalk_1.default.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
564
587
  }
565
588
  }
566
- else {
567
- // En Unix/Linux/Mac, usar redirección estándar
568
- buildersOutput = (0, child_process_1.execSync)('docker buildx ls 2>/dev/null', {
569
- encoding: 'utf-8',
570
- stdio: 'pipe',
571
- shell: '/bin/sh',
572
- });
589
+ catch (error) {
590
+ // Si hay errores al listar builders (por ejemplo, builder "cc" con problemas SSH),
591
+ // intentar continuar de todas formas
592
+ console.log(chalk_1.default.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
573
593
  }
574
- // Obtener el builder actual (marcado con *)
594
+ // Mostrar información de debugging
595
+ console.log(chalk_1.default.gray('\n📋 Buildx Builders Information:'));
596
+ console.log(chalk_1.default.gray('─'.repeat(60)));
575
597
  if (buildersOutput) {
576
- const lines = buildersOutput.split('\n');
598
+ const lines = buildersOutput.split('\n').filter(l => l.trim());
577
599
  for (const line of lines) {
578
600
  if (line.trim().startsWith('*')) {
579
- const match = line.match(/\*\s+(\S+)/);
580
- if (match) {
581
- currentBuilder = match[1];
582
- break;
583
- }
601
+ console.log(chalk_1.default.cyan(line));
602
+ }
603
+ else {
604
+ console.log(chalk_1.default.gray(line));
584
605
  }
585
606
  }
586
607
  }
587
- }
588
- catch (error) {
589
- // Si hay errores al listar builders (por ejemplo, builder "cc" con problemas SSH),
590
- // intentar continuar de todas formas
591
- console.log(chalk_1.default.yellow('⚠️ Warning: Some builders have connection issues, continuing...'));
592
- }
593
- // Mostrar información de debugging
594
- console.log(chalk_1.default.gray('\n📋 Buildx Builders Information:'));
595
- console.log(chalk_1.default.gray('─'.repeat(60)));
596
- if (buildersOutput) {
597
- const lines = buildersOutput.split('\n').filter(l => l.trim());
598
- for (const line of lines) {
599
- if (line.trim().startsWith('*')) {
600
- console.log(chalk_1.default.cyan(line));
608
+ else {
609
+ console.log(chalk_1.default.yellow(' No builders found or error listing builders'));
610
+ }
611
+ if (currentBuilder) {
612
+ console.log(chalk_1.default.gray(`\n Current builder: ${chalk_1.default.cyan(currentBuilder)}`));
613
+ }
614
+ console.log(chalk_1.default.gray('─'.repeat(60) + '\n'));
615
+ // Intentar obtener más detalles del builder actual si existe
616
+ if (currentBuilder) {
617
+ try {
618
+ const inspectOutput = (0, child_process_1.execSync)(`docker buildx inspect ${currentBuilder}`, {
619
+ encoding: 'utf-8',
620
+ stdio: 'pipe',
621
+ });
622
+ console.log(chalk_1.default.gray('📊 Builder Details:'));
623
+ console.log(chalk_1.default.gray('─'.repeat(60)));
624
+ const detailLines = inspectOutput.split('\n').slice(0, 20); // Mostrar primeras 20 líneas
625
+ for (const line of detailLines) {
626
+ console.log(chalk_1.default.gray(` ${line}`));
627
+ }
628
+ console.log(chalk_1.default.gray('─'.repeat(60) + '\n'));
601
629
  }
602
- else {
603
- console.log(chalk_1.default.gray(line));
630
+ catch (error) {
631
+ // Ignorar errores al inspeccionar
604
632
  }
605
633
  }
606
- }
607
- else {
608
- console.log(chalk_1.default.yellow(' No builders found or error listing builders'));
609
- }
610
- if (currentBuilder) {
611
- console.log(chalk_1.default.gray(`\n Current builder: ${chalk_1.default.cyan(currentBuilder)}`));
612
- }
613
- console.log(chalk_1.default.gray('─'.repeat(60) + '\n'));
614
- // Intentar obtener más detalles del builder actual si existe
615
- if (currentBuilder) {
616
- try {
617
- const inspectOutput = (0, child_process_1.execSync)(`docker buildx inspect ${currentBuilder}`, {
618
- encoding: 'utf-8',
634
+ const builderName = 'multiarch-builder';
635
+ if (!buildersOutput || !buildersOutput.includes(builderName)) {
636
+ builderSpinner.text = 'Creating multi-platform builder...';
637
+ (0, child_process_1.execSync)(`docker buildx create --name ${builderName} --use --bootstrap`, {
619
638
  stdio: 'pipe',
639
+ // No heredar stderr para evitar errores de otros builders
620
640
  });
621
- console.log(chalk_1.default.gray('📊 Builder Details:'));
622
- console.log(chalk_1.default.gray('─'.repeat(60)));
623
- const detailLines = inspectOutput.split('\n').slice(0, 20); // Mostrar primeras 20 líneas
624
- for (const line of detailLines) {
625
- console.log(chalk_1.default.gray(` ${line}`));
626
- }
627
- console.log(chalk_1.default.gray('─'.repeat(60) + '\n'));
628
- }
629
- catch (error) {
630
- // Ignorar errores al inspeccionar
631
- }
632
- }
633
- const builderName = 'multiarch-builder';
634
- if (!buildersOutput || !buildersOutput.includes(builderName)) {
635
- builderSpinner.text = 'Creating multi-platform builder...';
636
- (0, child_process_1.execSync)(`docker buildx create --name ${builderName} --use --bootstrap`, {
637
- stdio: 'pipe',
638
- // No heredar stderr para evitar errores de otros builders
639
- });
640
- currentBuilder = builderName;
641
- }
642
- else {
643
- builderSpinner.text = 'Using existing multi-platform builder...';
644
- try {
645
- (0, child_process_1.execSync)(`docker buildx use ${builderName}`, { stdio: 'pipe' });
646
641
  currentBuilder = builderName;
647
642
  }
648
- catch (error) {
649
- // Si falla, intentar crearlo de nuevo
650
- builderSpinner.text = 'Recreating multi-platform builder...';
643
+ else {
644
+ builderSpinner.text = 'Using existing multi-platform builder...';
651
645
  try {
652
- (0, child_process_1.execSync)(`docker buildx rm ${builderName}`, { stdio: 'pipe' });
646
+ (0, child_process_1.execSync)(`docker buildx use ${builderName}`, { stdio: 'pipe' });
647
+ currentBuilder = builderName;
653
648
  }
654
- catch {
655
- // Ignorar si no existe
649
+ catch (error) {
650
+ // Si falla, intentar crearlo de nuevo
651
+ builderSpinner.text = 'Recreating multi-platform builder...';
652
+ try {
653
+ (0, child_process_1.execSync)(`docker buildx rm ${builderName}`, { stdio: 'pipe' });
654
+ }
655
+ catch {
656
+ // Ignorar si no existe
657
+ }
658
+ (0, child_process_1.execSync)(`docker buildx create --name ${builderName} --use --bootstrap`, {
659
+ stdio: 'pipe'
660
+ });
661
+ currentBuilder = builderName;
656
662
  }
657
- (0, child_process_1.execSync)(`docker buildx create --name ${builderName} --use --bootstrap`, {
658
- stdio: 'pipe'
659
- });
660
- currentBuilder = builderName;
661
663
  }
662
- }
663
- // Verificar que el builder está activo
664
- try {
665
- const verifyOutput = (0, child_process_1.execSync)('docker buildx ls', {
666
- encoding: 'utf-8',
667
- stdio: 'pipe',
668
- });
669
- const verifyLines = verifyOutput.split('\n');
670
- let activeBuilderFound = false;
671
- for (const line of verifyLines) {
672
- if (line.trim().startsWith('*') && line.includes(builderName)) {
673
- activeBuilderFound = true;
674
- break;
664
+ // Verificar que el builder está activo
665
+ try {
666
+ const verifyOutput = (0, child_process_1.execSync)('docker buildx ls', {
667
+ encoding: 'utf-8',
668
+ stdio: 'pipe',
669
+ });
670
+ const verifyLines = verifyOutput.split('\n');
671
+ let activeBuilderFound = false;
672
+ for (const line of verifyLines) {
673
+ if (line.trim().startsWith('*') && line.includes(builderName)) {
674
+ activeBuilderFound = true;
675
+ break;
676
+ }
677
+ }
678
+ if (activeBuilderFound) {
679
+ builderSpinner.succeed(`Builder ready: ${builderName}`);
680
+ console.log(chalk_1.default.green(`✓ Using builder: ${chalk_1.default.cyan(builderName)}`));
681
+ }
682
+ else {
683
+ builderSpinner.warn(`Builder created but may not be active`);
684
+ console.log(chalk_1.default.yellow(`⚠ Builder created but not confirmed as active`));
675
685
  }
676
686
  }
677
- if (activeBuilderFound) {
678
- builderSpinner.succeed(`Builder ready: ${builderName}`);
679
- console.log(chalk_1.default.green(`✓ Using builder: ${chalk_1.default.cyan(builderName)}`));
680
- }
681
- else {
682
- builderSpinner.warn(`Builder created but may not be active`);
683
- console.log(chalk_1.default.yellow(`⚠ Builder created but not confirmed as active`));
687
+ catch (error) {
688
+ builderSpinner.succeed('Builder ready');
689
+ console.log(chalk_1.default.yellow(`⚠ Could not verify builder status`));
684
690
  }
685
691
  }
686
692
  catch (error) {
687
- builderSpinner.succeed('Builder ready');
688
- console.log(chalk_1.default.yellow(`⚠ Could not verify builder status`));
693
+ builderSpinner.fail('Failed to setup builder');
694
+ console.error(chalk_1.default.red('Error setting up Docker buildx builder'));
695
+ console.error(chalk_1.default.yellow('💡 Tip: If you have problematic builders configured, you can remove them with:'));
696
+ console.error(chalk_1.default.cyan(' docker buildx rm <builder-name>'));
697
+ console.error(chalk_1.default.yellow(' Or inspect them with: docker buildx inspect <builder-name>'));
698
+ process.exit(1);
689
699
  }
690
700
  }
691
- catch (error) {
692
- builderSpinner.fail('Failed to setup builder');
693
- console.error(chalk_1.default.red('Error setting up Docker buildx builder'));
694
- console.error(chalk_1.default.yellow('💡 Tip: If you have problematic builders configured, you can remove them with:'));
695
- console.error(chalk_1.default.cyan(' docker buildx rm <builder-name>'));
696
- console.error(chalk_1.default.yellow(' Or inspect them with: docker buildx inspect <builder-name>'));
697
- process.exit(1);
701
+ else {
702
+ // En Windows, no usamos buildx, solo docker build normal
703
+ console.log(chalk_1.default.blue('\n📦 Using standard Docker build (Windows mode)'));
704
+ console.log(chalk_1.default.gray(' Note: Multi-platform builds are disabled on Windows\n'));
698
705
  }
699
706
  // Verificar autenticación de Docker si se va a hacer push
700
707
  if (shouldPush) {
@@ -720,42 +727,80 @@ CMD ${JSON.stringify(startCmd)}
720
727
  }
721
728
  }
722
729
  // Paso 5: Construir y hacer push
723
- // Detectar si estamos en Windows (buildx tiene problemas con ARM en Windows)
724
- const isWindows = os.platform() === 'win32';
725
- const platform = isWindows ? 'linux/amd64' : 'linux/amd64,linux/arm64';
726
730
  const platformDisplay = isWindows ? 'linux/amd64' : 'linux/amd64, linux/arm64';
727
731
  const buildSpinnerText = isWindows
728
- ? 'Building Docker image for linux/amd64...'
732
+ ? 'Building Docker image (Windows mode)...'
729
733
  : 'Building Docker image for multiple platforms...';
730
734
  const buildDockerSpinner = (0, ora_1.default)(buildSpinnerText).start();
731
735
  try {
732
- const tags = shouldPush
733
- ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
734
- : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
735
- const buildCommand = `docker buildx build \
736
- --platform ${platform} \
737
- ${tags.join(' \\\n ')} \
738
- --progress=plain \
739
- .`;
740
- console.log(chalk_1.default.gray('\n🔨 Build command:'));
741
- console.log(chalk_1.default.gray('─'.repeat(60)));
742
- console.log(chalk_1.default.cyan(buildCommand));
743
- console.log(chalk_1.default.gray('─'.repeat(60)));
744
- console.log(chalk_1.default.gray(`\n Working directory: ${chalk_1.default.cyan(resolvedDestFolder)}`));
745
- console.log(chalk_1.default.gray(` Platforms: ${chalk_1.default.cyan(platformDisplay)}`));
746
736
  if (isWindows) {
747
- console.log(chalk_1.default.yellow(` Note: Building only for linux/amd64 on Windows (ARM builds are disabled)`));
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
+ console.log(chalk_1.default.gray('\n🔨 Build command:'));
744
+ console.log(chalk_1.default.gray('─'.repeat(60)));
745
+ console.log(chalk_1.default.cyan(buildCommand));
746
+ console.log(chalk_1.default.gray('─'.repeat(60)));
747
+ console.log(chalk_1.default.gray(`\n Working directory: ${chalk_1.default.cyan(resolvedDestFolder)}`));
748
+ console.log(chalk_1.default.gray(` Platform: ${chalk_1.default.cyan('linux/amd64')}`));
749
+ console.log(chalk_1.default.gray(` Using: ${chalk_1.default.cyan('docker build')} (Windows mode)`));
750
+ console.log(chalk_1.default.gray(` Push to registry: ${shouldPush ? chalk_1.default.green('Yes (after build)') : chalk_1.default.yellow('No')}\n`));
751
+ (0, child_process_1.execSync)(buildCommand, {
752
+ cwd: resolvedDestFolder,
753
+ stdio: 'inherit'
754
+ });
755
+ buildDockerSpinner.succeed('Docker image built successfully');
756
+ // Si se debe hacer push, hacerlo por separado
757
+ if (shouldPush) {
758
+ const pushSpinner = (0, ora_1.default)('Pushing Docker images to registry...').start();
759
+ try {
760
+ (0, child_process_1.execSync)(`docker push ${imageName}`, {
761
+ cwd: resolvedDestFolder,
762
+ stdio: 'inherit'
763
+ });
764
+ (0, child_process_1.execSync)(`docker push ${imageLatest}`, {
765
+ cwd: resolvedDestFolder,
766
+ stdio: 'inherit'
767
+ });
768
+ pushSpinner.succeed('Docker images pushed successfully');
769
+ }
770
+ catch (error) {
771
+ pushSpinner.fail('Failed to push Docker images');
772
+ throw error;
773
+ }
774
+ }
775
+ }
776
+ else {
777
+ // En otros sistemas, usar docker buildx build
778
+ const platform = 'linux/amd64,linux/arm64';
779
+ const tags = shouldPush
780
+ ? [`--tag ${imageName}`, `--tag ${imageLatest}`, '--push']
781
+ : [`--tag ${imageName}`, `--tag ${imageLatest}`, '--load'];
782
+ const buildCommand = `docker buildx build \
783
+ --platform ${platform} \
784
+ ${tags.join(' \\\n ')} \
785
+ --progress=plain \
786
+ .`;
787
+ console.log(chalk_1.default.gray('\n🔨 Build command:'));
788
+ console.log(chalk_1.default.gray('─'.repeat(60)));
789
+ console.log(chalk_1.default.cyan(buildCommand));
790
+ console.log(chalk_1.default.gray('─'.repeat(60)));
791
+ console.log(chalk_1.default.gray(`\n Working directory: ${chalk_1.default.cyan(resolvedDestFolder)}`));
792
+ console.log(chalk_1.default.gray(` Platforms: ${chalk_1.default.cyan(platformDisplay)}`));
793
+ console.log(chalk_1.default.gray(` Push to registry: ${shouldPush ? chalk_1.default.green('Yes') : chalk_1.default.yellow('No')}\n`));
794
+ (0, child_process_1.execSync)(buildCommand, {
795
+ cwd: resolvedDestFolder,
796
+ stdio: 'inherit'
797
+ });
798
+ buildDockerSpinner.succeed('Docker image built successfully');
748
799
  }
749
- console.log(chalk_1.default.gray(` Push to registry: ${shouldPush ? chalk_1.default.green('Yes') : chalk_1.default.yellow('No')}\n`));
750
- (0, child_process_1.execSync)(buildCommand, {
751
- cwd: resolvedDestFolder,
752
- stdio: 'inherit'
753
- });
754
- buildDockerSpinner.succeed('Docker image built successfully');
755
800
  console.log(chalk_1.default.green('\n✅ Image build and push completed successfully!'));
756
801
  console.log(chalk_1.default.gray('📦 Image details:'));
757
802
  console.log(chalk_1.default.gray('─'.repeat(60)));
758
- console.log(chalk_1.default.white(` Platforms: ${chalk_1.default.cyan('linux/amd64, linux/arm64')}`));
803
+ console.log(chalk_1.default.white(` Platforms: ${chalk_1.default.cyan(platformDisplay)}`));
759
804
  console.log(chalk_1.default.white(` Version: ${chalk_1.default.cyan(version)}`));
760
805
  console.log(chalk_1.default.white(` Tags:`));
761
806
  console.log(chalk_1.default.white(` - ${chalk_1.default.cyan(imageName)}`));