Create a CaptainHook configuration

@param  string $path
@return \CaptainHook\App\Config
@throws \Exception
10027
public function createConfig($path = '') : Config
    {
        $path       = $path ?: getcwd() . DIRECTORY_SEPARATOR . CH::CONFIG;
        $json       = new Json($path);
        $fileExists = $json->exists();
        $config     = new Config($path, $fileExists);

        if ($fileExists) {
            $this->configure($config, $json->readAssoc());
        }

        return $config;
    }
175210
protected function defaultConfigStrategy($path, $key)
    {
        $config = $this->app->make('config')->get($key, []);
        $this->app->make('config')->set($key, array_replace_recursive(require $path, $config));
    }
1154076
public static function BuildConfigFromFile($path = null)
    {
        if (empty($path)) {
            $path = getenv('KUBECONFIG');
        }

        if (empty($path)) {
            $path = getenv('HOME').'/.kube/config';
        }

        if (!file_exists($path)) {
            throw new \Exception('Config file does not exist: ' . $path);
        }

        $yaml = yaml_parse_file($path);

        $currentContextName = $yaml['current-context'];
        $context = null;
        foreach ($yaml['contexts'] as $item) {
            if ($item['name'] == $currentContextName) {
                $context = $item['context'];
                break;
            }
        }

        $cluster = null;
        foreach ($yaml['clusters'] as $item) {
            if ($item['name'] == $context['cluster']) {
                $cluster = $item['cluster'];
                break;
            }
        }

        $user = null;
        foreach ($yaml['users'] as $item) {
            if ($item['name'] == $context['user']) {
                $user = $item['user'];
                break;
            }
        }

        $config = new Config();
        $config->setServer($cluster['server']);

        if (!empty($cluster['certificate-authority-data'])) {
            $path = self::writeTempFile(base64_decode($cluster['certificate-authority-data'], true));
            $config->setCertificateAuthorityPath($path);
        }

        if (!empty($user['client-certificate-data'])) {
            $path = self::writeTempFile(base64_decode($user['client-certificate-data']));
            $config->setClientCertificatePath($path);
        }

        if (!empty($user['client-key-data'])) {
            $path = self::writeTempFile(base64_decode($user['client-key-data']));
            $config->setClientKeyPath($path);
        }

        return $config;
    }
966123
protected function configure() : void
    {
        $this->setName('configure')
             ->setDescription('Configure your hooks')
             ->setHelp('This command creates or updates your captainhook configuration')
             ->addOption('extend', 'e', InputOption::VALUE_NONE, 'Extend existing configuration file')
             ->addOption('force', 'f', InputOption::VALUE_NONE, 'Overwrite existing configuration file')
             ->addOption('advanced', 'a', InputOption::VALUE_NONE, 'More options, but more to type')
             ->addOption(
                 'configuration',
                 'c',
                 InputOption::VALUE_OPTIONAL,
                 'Path to your json configuration',
                 './' . CH::CONFIG
             );
    }
470015
public static function init($path, $environment = null)
    {
        if (!static::$instance)
            static::$instance = new Config($path, $environment);
        else {
            static::$instance->path = $path;
            static::$instance->environment = $environment;
            static::$instance->container = array();
        }

        return static::$instance;
    }
904734
public static function create_from_path($path) {
		$e = DNEnvironment::create();
		$e->Filename = $path;
		$e->Name = basename($e->Filename, '.rb');

		// add each administrator member as a deployer of the new environment
		$adminGroup = Group::get()->filter('Code', 'administrators')->first();
		$e->DeployerGroups()->add($adminGroup);
		return $e;
	}
1044418
public function route($path)
    {
        $route = $this->configureSlice()->atData($path);

        if (empty($route))
        {
            throw new Exceptions\NotFound('Route `' . $path . '` not found');
        }

        return $route;
    }
575289
public function getConfigValueFromPath($path)
    {
        /** @var Configuration $node */
        $node = $this->configuration;

        foreach (explode('/', $path) as $nodeName) {
            if (!is_object($node)) {
                return null;
            }

            $node = $node->{'get' . ucfirst($nodeName)}();
        }

        return $node;
    }
544289
public function webDir(string $path): self
    {
        $this->validatePathIsRelativeToProject($path, __METHOD__);
        $this->webDir = rtrim($path, '/');

        return $this;
    }
788404
public static function create($path = 'Staq\Core\Ground', $baseUri = NULL, $platform = NULL)
    {
        return (new \Staq\Server)->createApplication($path, $baseUri, $platform);
    }
923013
public function addCommandDir(string $path) : self
    {
        $declared = get_declared_classes();

        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(rtrim($path)));
        $files = new RegexIterator($iterator, '`^.*\.php$`', RegexIterator::GET_MATCH);

        foreach ($files as $file) {
            if (array_search($file[0], get_included_files()) === false) {
                require $file[0];
            }
        }

        $currentClasses = get_declared_classes();

        foreach (array_diff($currentClasses, $declared) as $class) {
            $reflection = new \ReflectionClass($class);
            if ($reflection->isInstantiable() && is_subclass_of($class, Command::class)) {
                self::$application->add(new $class());
            }
        }

        return $this;
    }
460945
public static function install( $path ) 
	{
		
		// load ship at path
		$ship = CCOrbit_Ship::create( $path );
		
		if ( static::$data->has( 'installed.'.$ship->name ) ) {
			throw new CCException( "CCOrbit::install - {$ship->name} ship already installed." );
		}
		
		if ( $ship->install !== false ) {
			$ship->event( $ship->install );
		}
		
		static::$data->set( 'installed.'.$ship->name, CCStr::strip( $ship->path, CCROOT ) );
		
		// save changes
		static::$data->write( 'json' );
	}
415190
public static function config($path)
    {
        $data = \UtilsSandboxLoader('application/Config/' . strtr($path, '.', '/') . '.php');

        foreach ($data as $key => $value) {
            self::env($key, $value);
        }

        $data = null;
    }
198818
public function findOrCreateNode($path)
    {
        if ($node = $this->getDocumentManager()->find(null, $path)) {
            return $node;
        }

        NodeHelper::createPath($this->getDocumentManager()->getPhpcrSession(), $path);

        return $this->findOrCreateNode($path);
    }
708507
public static function init($path)
    {
        pake_mkdirs($path);

        pake_sh(escapeshellarg(pake_which('hg')).' init -q '.escapeshellarg($path));

        return new pakeMercurial($path);
    }
433190
public function setPath(?string $path): Configuration
    {
        $this->path = realpath($path) ?: $path;

        return $this;
    }
797870
public static function createFromPath($path)
    {
        if (!file_exists($path)) {
            throw new Exception\FactoryException(sprintf('Unable to open file %s', $path));
        }
        $file = new \SplFileInfo($path);
        return static::createFromSplFileInfo($file);
    }