HEX
Server: LiteSpeed
System: Linux s3.sitechai.com 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: workzeni (2217)
PHP: 8.1.32
Disabled: mail, show_source, system, shell_exec, passthru, exec, eval, shell
Upload Files
File: //home/workzeni/agency-erp-05.workzenix.com/vendor/livewire/flux/src/Console/ActivateCommand.php
<?php

namespace Flux\Console;

use RuntimeException;
use function Laravel\Prompts\{ info, text, note, spin, warning, error, alert, intro, outro, suggest };
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Process\Process;
use Illuminate\Support\Facades\Http;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

#[AsCommand(name: 'flux:activate')]
class ActivateCommand extends Command
{
    protected $signature = 'flux:activate {email?} {key?}';

    protected $description = 'Activate Flux, the official UI component library for Livewire';

    public function handle()
    {
        $email = $this->argument('email');
        $key = $this->argument('key');

        if (! $email) {
            $email = text(
                label: 'Enter the email address associated with your license',
                hint: 'Purchase a license key: https://fluxui.dev/pricing',
                required: true,
            );
        }

        if (! $key) {
            $key = text(
                label: 'Enter your license key',
                hint: 'Purchase a license key: https://fluxui.dev/pricing',
                required: true,
            );
        }

        $this->installFluxPro($email, $key);
    }

    public function installFluxPro($email, $key)
    {
        // Add creds to auth.json...
        $process = new Process([
            'composer', 'config', '-a',
            'http-basic.composer.fluxui.dev', $email, $key
        ]);

        $process->run();

        if (! $process->isSuccessful()) {
            echo "Failed to add license to auth.json. Console output: " . $process->getErrorOutput();
            note('Contact support@fluxui.dev for help');
            return;
        }

        info('[√] License key added to auth.json');

        // Add repository to composer.json...
        $process = new Process(['composer', 'config', 'repositories.flux-pro', 'composer', 'https://composer.fluxui.dev']);

        $process->run();

        if (! $process->isSuccessful()) {
            echo "Failed to add repository to composer.json. Console output: " . $process->getErrorOutput();
            note('Contact support@fluxui.dev for help');
            return;
        }

        info('[√] Repository added to composer.json');

        // Run composer require...
        note('Running: composer require livewire/flux-pro...');

        $process = new Process(['composer', 'require', 'livewire/flux-pro']);

        if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
            try {
                $process->setTty(true);
            } catch (RuntimeException $e) {
                $this->output->writeln('  <bg=yellow;fg=black> WARN </> '.$e->getMessage().PHP_EOL);
            }
        }

        $process->setTimeout(null);

        $process->run(function ($type, $line) {
            $this->output->write('    '.$line);
        });

        if (! $process->isSuccessful()) {
            error("We are unable to install Flux automatically. Try running `composer require livewire/flux-pro` manually.");
            note('Contact support@fluxui.dev for help');
            return;
        }

        note('');
        outro('Thanks for using Flux!');
        note('Your support is an investment in the future of Livewire ❤️');
    }
}