public static function repository(?string $app = null): Repository
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }

        // Autoload default "config" in project root.
        if ($app === '*' && !isset(self::$repositories[$app])) {
            $path = Path::root('config');
            if (!is_dir($path)) {
                throw new ConfigException('Path ' . $path . ' does not exist.');
            }
            self::$repositories[$app] = new Repository($path);
        }

        if (!isset(self::$repositories[$app])) {
            throw new ConfigException('Application ' . $app . ' not registered.');
        }
        return self::$repositories[$app];
    }