Create from Composer IO.

@param IOInterface $io

@return NutStyle
426005
public static function fromComposer(IOInterface $io)
    {
        $input = new ArrayInput([]);
        $input->setInteractive($io->isInteractive());

        if ($io instanceof ConsoleIO) {
            $ref = new \ReflectionProperty($io, 'output');
            $ref->setAccessible(true);
            $output = $ref->getValue($io);
            if ($output instanceof ConsoleOutputInterface) {
                $output = $output->getErrorOutput();
            }
        } else {
            $output = new NullOutput();
        }

        return new static($input, $output);
    }
1263419
protected static function genSecretConfig(IOInterface $io)
    {
        $dist = getcwd() . '/.env.dist';
        $dest = getcwd() . '/.env';

        $env = file_get_contents($dist);

        if ($io->askConfirmation("\nDo you want to use database? [Y/n]: ", true)) {
            $vars = [];

            $supportedDrivers = [
                1 => 'mysql',
                2 => 'postgresql',
                3 => 'sqlsrv'
            ];

            $io->write('');
            $io->write('Supported database drivers:');

            foreach ($supportedDrivers as $k => $v) {
                $io->write(sprintf('  - [%s] %s', $k, $v));
            }

            $io->write('');

            $driver = $io->ask('Database driver [1]: ', '1');

            $vars['DATABASE_DRIVER']   = $supportedDrivers[$driver] ?? 'mysql';
            $vars['DATABASE_HOST']     = $io->ask('Database host [localhost]: ', 'localhost');
            $vars['DATABASE_NAME']     = $io->ask('Database name [acme]: ', 'acme');
            $vars['DATABASE_USER']     = $io->ask('Database user [root]: ', 'root');
            $vars['DATABASE_PASSWORD'] = $io->askAndHideAnswer('Database password: ');

            foreach ($vars as $key => $value) {
                $env = preg_replace('/' . $key . '=(.*)/', $key . '=' . $value, $env);
            }
        }

        file_put_contents($dest, $env);

        $io->write('');
        $io->write('Database config setting complete.');
        $io->write('');
    }
1002576
protected function setupResources(IOInterface $io)
    {
        // Setup root dir
        $resourcesPath = $this->getResourcesPath();
        $this->filesystem->ensureDirectoryExists($resourcesPath);

        // Copy missing resources
        $files = new DirectoryIterator(__DIR__.'/../resources');
        foreach ($files as $file) {
            $targetPath = $resourcesPath . DIRECTORY_SEPARATOR . $file->getFilename();
            if ($file->isFile() && !file_exists($targetPath)) {
                $name = $file->getFilename();
                $io->write("Writing <info>{$name}</info> to resources folder");
                copy($file->getPathname(), $targetPath);
            }
        }
    }
37351
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
    {
        $this->configure($input);

        $adminClassNameDetails = $generator->createClassNameDetails(
            $this->adminClassBasename,
            'Admin\\',
            'Admin'
        );

        $adminClassFullName = $adminClassNameDetails->getFullName();
        $this->generateAdmin($io, $generator, $adminClassNameDetails);

        $controllerClassFullName = '';
        if ($this->controllerClassBasename) {
            $controllerClassNameDetails = $generator->createClassNameDetails(
                $this->controllerClassBasename,
                'Controller\\',
                'Controller'
            );

            $this->generateController($input, $io, $generator, $controllerClassNameDetails);

            $controllerClassFullName = $controllerClassNameDetails->getFullName();
        }

        $this->generateService($input, $io, $adminClassFullName, $controllerClassFullName);
    }
677052
protected function setIO(InputInterface $input, OutputInterface $output)
    {
        $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
    }
1130745
public function activate(Composer $composer, IOInterface $io) {
    $this->composer = $composer;
    $this->io = $io;
    $this->eventDispatcher = $composer->getEventDispatcher();
    ProcessExecutor::setTimeout(3600);
    $this->executor = new ProcessExecutor($this->io);
  }
466445
public function activate(Composer $composer, IOInterface $io) {
    $this->io = $io;
    $vendor = $composer->getConfig()->get('vendor-dir');

    $this->vendor = $vendor;
    $this->root = dirname($vendor);
  }
1063154
public function activate(Composer $composer, IOInterface $io)
    {
        $package = $composer->getPackage();

        if ($package instanceof CompletePackage) {
            $this->addScriptsTo($package);
        }

        if ($package instanceof RootPackageInterface) {
            $this->addAutoloadTo($package);
        }
    }
762293
public function activate(Composer $composer, IOInterface $io) {
        $manager = $composer->getInstallationManager();
        $manager->addInstaller(new Installer($io, $composer, 'witpact-theme'));
        $manager->addInstaller(new Installer($io, $composer, 'witpact-plugin'));
    }
1016893
public static function getInput(IOInterface $io)
    {
        $ref = new \ReflectionClass($io);

        if ($ref->hasProperty('input')) {
            $prop = $ref->getProperty('input');
            $prop->setAccessible(true);
            $input = $prop->getValue($io);

            if ($input instanceof InputInterface) {
                return $input;
            }
        }

        return new ArgvInput();
    }
238049
public static function build(Composer $composer, array $defaults = array(), $io = null)
    {
        $config = self::getConfigBase($composer, $io);

        return new Config($config, $defaults);
    }
691088
public function activate(Composer $composer, IOInterface $io)
	{
		$this->composer = $composer;
		$this->generator = new AutoloadGenerator($composer->getEventDispatcher(), $io);
	}
280577
public function activate(Composer $composer, IOInterface $io)
    {
        $this->composer = $composer;
        $this->io = $io;
        if(isset($this->composer->getPackage()->getExtra()['auto-require']['vendor-name'])) {
            $this->vendorName = $this->composer->getPackage()->getExtra()['auto-require']['vendor-name'];
        } else {
            $this->vendorName = 'yourpackage';
        }
        if(isset($this->composer->getPackage()->getExtra()['auto-require']['path-scheme'])) {
            $this->pathScheme = $this->composer->getPackage()->getExtra()['auto-require']['path-scheme'];
        } else {
            $this->pathScheme = '{vendorName}/{vendorName}.{name}';
        }
    }
1007931
public function io(ConsoleIo $io = null)
    {
        deprecationWarning(
            'Shell::io() is deprecated. ' .
            'Use Shell::setIo()/getIo() instead.'
        );
        if ($io !== null) {
            $this->_io = $io;
        }

        return $this->_io;
    }
962488
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $styles = [
            // ---------------------------------------
            // Style    => [ Color, BgColor, Options ]
            // ---------------------------------------
            'title'     => [ 'white', null, ['bold'] ],
            'info'      => [ 'cyan' ],
            'warn'      => [ 'yellow', null, ['bold'] ],
            'erro'      => [ 'red', null, ['bold'] ],
            'success'   => [ 'green' ],
            'failure'   => [ 'yellow' ],
            'label'     => [ 'cyan', null, ['underscore'] ],
            'comment'   => [ 'white', null, ['reverse'] ],
            'highlight' => [ 'yellow' ],
        ];

        foreach ($styles as $name => $style) {
            $output->getFormatter()->setStyle(
                $name,
                Reflection::newInstance(
                    OutputFormatterStyle::class,
                    $style
                )
            );
        }

        $this->output = new OutputStyle($input, $output);
    }
536779
protected static function genSecretCode(IOInterface $io)
    {
        $file = getcwd() . '/etc/conf/system.php';

        $config = file_get_contents($file);

        $hash = 'Windwalker-' . hrtime(true);

        $salt = $io->ask("\nSalt to generate secret [{$hash}]: ", $hash);

        $config = str_replace('This-token-is-not-safe', md5(hrtime(true) . $salt), $config);

        file_put_contents($file, $config);

        $io->write('Auto created secret key.');
    }
786675
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
    {
        $isCrud = $input->getOption('is-crud');
        
        $formClassNameDetails = $generator->createClassNameDetails(
            $input->getArgument('name'),
            'GraphQL\\Type',
            'Type'
        );

        $formFields = ['fieldFame'];
        $boundClass = $input->getArgument('bound-class');
        $uses = [];
        $boundClassDetails = $generator->createClassNameDetails(
            $boundClass,
            'Entity\\'
        );

        $doctrineEntityDetails = $this->entityHelper->createDoctrineDetails($boundClassDetails->getFullName());
        if (null !== $doctrineEntityDetails) {
            $formFields = $this->mapScalarFields($doctrineEntityDetails->getDisplayFields());

            foreach ($formFields as $fieldUse){
                $uses[$fieldUse['fieldType']] = $fieldUse['fieldType'];
            }
        }

        $boundClassVars = [
            'bounded_class_name' => $boundClassDetails->getShortName(),
            'bounded_full_class_name' => $boundClassDetails->getFullName(),
        ];
    
        $generator->generateClass(
            $formClassNameDetails->getFullName(),
            dirname(dirname(__FILE__)) . '/Resources/skeleton/Type.tpl.php',
            array_merge(
                [
                    'formFields' => $formFields,
                    'uses' => $uses
                ],
                $boundClassVars
            )
        );
    
        $generator->writeChanges();
        
        if(!empty($isCrud)) {
            $serviceClassNameDetails = $this->createService($boundClassVars, $boundClassVars, $input, $generator);
            $resolvers = [
                [
                    'namespace' => 'Query',
                    'suffix' => 'Find',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Create',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Update',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Delete',
                    'template' =>  'Resolver.tpl.php',
                ]
            ];
    
            $actions = [];
            foreach ($resolvers as $resolver) {
                $suffix = $resolver['suffix'] ?? '';
                $queryClassNameDetails = $generator->createClassNameDetails(
                    $input->getArgument('name').$suffix,
                    'GraphQL\\'.$resolver['namespace'].'\\' . $input->getArgument('name')
                );
        
                $generator->generateClass(
                    $queryClassNameDetails->getFullName(),
                    dirname(dirname(__FILE__)) . '/Resources/skeleton/'.$resolver['template'],
                    [
                        'suffix' => $suffix,
                        'entityFullName' => $boundClassDetails->getFullName(),
                        'entityName' => $boundClassDetails->getShortName(),
                        'serviceFullName' => (empty($serviceClassNameDetails))?:$serviceClassNameDetails->getFullName(),
                        'serviceName' => (empty($serviceClassNameDetails))?:$serviceClassNameDetails->getShortName(),
                        'isMutation' => ($resolver['namespace'] == 'Mutation') ? true : false,
                        'form_class_name' => $formClassNameDetails->getShortName(),
                        'form_full_class_name' => $formClassNameDetails->getFullName(),
                        'bounded_class_name' => $boundClassDetails->getShortName(),
                    ]
                );
        
                $actions[$resolver['namespace']][] = [
                    'fullName' => $queryClassNameDetails->getFullName(),
                    'shortName' => Str::getShortClassName($queryClassNameDetails->getFullName())
                ];
        
                $generator->writeChanges();
            }
    
            foreach ($actions as $type => $action){
                $this->registerQueries(
                    $type,
                    $action,
                    $generator
                );
            }
        }
        
        $this->writeSuccessMessage($io);
        $io->text(
            [
                'Next: Create custom query to your type and start using it.',
                'To create custom query or mutation use "maker:graphql:query"',
            ]
        );
    }