Symlink the themes public directory so its accesible
by the web.

@return void
556126
protected function symlinkPublicDirectory()
    {
        if (! file_exists(public_path('themes/'.$this->getCurrent()))) {
            if (! file_exists(public_path('themes'))) {
                app()->make('files')->makeDirectory(public_path('themes'));
            }

            app()->make('files')->link(
                $this->path('public'), public_path('themes/'.$this->getCurrent())
            );
        }
    }
518516
protected function registerPublishElements ()
    {
        $directory = $this->homeDirectory . '/../../database/migrations/';

        // Publish your migrations
        if (file_exists ($directory))
            $this->publishes ([
                $this->homeDirectory . '/../../database/migrations/' => database_path ('/migrations'),
            ], 'migrations');

        $directory = $this->homeDirectory . '/../public';

        // Publishing assets
        if (file_exists ($directory))
            $this->publishes ([
                $this->homeDirectory . '/../public' => public_path ('honeycomb'),
            ], 'public');

        $directory = $this->homeDirectory . '/../config';

        // Publishing assets
        if (file_exists ($directory))
            $this->publishes ([
                $this->homeDirectory . '/../config' => config_path('/'),
            ], 'config');
    }
862447
private function registerAllThemes()
    {
        $directories = $this->app['files']->directories(base_path('themes'));

        foreach ($directories as $directory) {
            $this->app['stylist']->registerPath($directory);
        }
    }
258610
protected function publishFiles()
    {
        $this->publishes([
            __DIR__.'/../Config/installer.php' => base_path('config/installer.php'),
        ], 'laravelinstaller');

        $this->publishes([
            __DIR__.'/../assets' => public_path('installer'),
        ], 'laravelinstaller');

        $this->publishes([
            __DIR__.'/../Views' => base_path('resources/views/vendor/installer'),
        ], 'laravelinstaller');

        $this->publishes([
            __DIR__.'/../Lang' => base_path('resources/lang'),
        ], 'laravelinstaller');
    }
244802
public function loadPublic()
    {
        $directory = base_path("public/src");

        if (!File::exists($directory)) {
            File::makeDirectory($directory, 0775, true);
        }

        $basic = $directory."/".$this->name;

        $package = $this->base_path."/Resources/public";

        $this->createLink($package, $basic);
    }
648870
protected function setViewPaths()
    {
        $viewFinder = $this->app->make('view.finder');

        $themePaths = $this->getAvailableThemePaths();

        if (!empty($themePaths)) {
            $viewFinder->setPaths(array_merge($themePaths, $viewFinder->getPaths()));
        }
    }
341342
protected function setPublicDirectory()
    {
        if (! $this->json) {
            $this->readJson();
        }
        
        $this->json['extra']['public-dir'] = $this->plugin->getPublicDirectory();
    }
947673
public function addSymlinks(array $symlinks)
    {
        foreach ($symlinks as $linkPath => $sourcePath) {
            $this->addSymlink($linkPath, $sourcePath);
        }

        return $this;
    }
495841
public function moveTheme()
    {
        $this->destinationDir = base_path('themes') . '/' . $this->getAttribute('namespace');

        // remove hidden directories
        File::deleteDirectory($this->tmpDirectory.'/.git');
        File::deleteDirectory($this->tmpDirectory.'/.idea');

        $success = File::copyDirectory($this->tmpDirectory, $this->destinationDir);
        if (!$success) {
            throw new \Exception("Theme could not be moved to " . $this->destinationDir . ". Check you have all permissions needed!");
        }else{
            File::deleteDirectory($this->tmpDirectory);
        }

        return $this;
    }
939799
public function set($theme)
    {
        list($theme, $parent) = $this->resolveTheme($theme);

        if (! $this->isCurrently($theme->get('slug')) and (! is_null($this->getCurrent()))) {
            $this->removeRegisteredLocation();
        }

        $this->setCurrent($theme->get('slug'));
        
        $this->registerAutoload($this->format($theme->get('slug')));
        $this->addRegisteredLocation($theme, $parent);
        $this->symlinkPublicDirectory();
        $this->registerServiceProvider($this->format($theme->get('slug')));
    }
41692
protected function buildDirectories()
	{
		$reflection = new \ReflectionClass($this);

		$this->container->setParameter('directories.supra_root', dirname($reflection->getFileName()));
		$this->container->setParameter('directories.project_root', dirname($this->container->getParameter('directories.supra_root')));
		$this->container->setParameter('directories.storage',
			$this->container->getParameter('directories.project_root') .
			DIRECTORY_SEPARATOR .
			'storage'
		);
		$this->container->setParameter('directories.cache',
			$this->container->getParameter('directories.storage') .
			DIRECTORY_SEPARATOR .
			'cache'
		);
		$this->container->setParameter('directories.web',
			$this->container->getParameter('directories.project_root') .
			DIRECTORY_SEPARATOR .
			'web'
		);
		$this->container->setParameter('directories.public',
			$this->container->getParameter('directories.web') .
			DIRECTORY_SEPARATOR .
			'public'
		);
	}
312095
public static function loadThemes()
    {
        $themesFolder = new Folder(ROOT . DS . 'themes');
        $themes = $themesFolder->read()[0];
        $loader = require ROOT . DS . 'vendor' . DS . 'autoload.php';
        foreach ($themes as $theme) {
            $loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
            Plugin::load('WasabiTheme/' . $theme, [
                'path' => $themesFolder->path . DS . $theme . DS,
                'bootstrap' => true,
                'routes' => false
            ]);
        }
    }
1136977
public function run()
    {
        $topdir = $this->getBasePath();

        foreach (scandir($topdir) as $filename) {

            // Skip directory link files
            if (($filename == '.') || ($filename == '..')) {
                continue;
            }

            if (is_dir($topdir . DIRECTORY_SEPARATOR . $filename)) {
                // Recurse into lower level directory, providing the namespace
                $this->loadFiles($filename, $filename);
            }
        }
    }
845916
private function loadPublishable()
    {
        $publishDirectory = __DIR__ . '/../../../publish/';

        $this->publishes([
            $publishDirectory . 'Commands/UserDatabase.php'        => app_path('Console/Commands/JumpGate/UserDatabase.php'),
            $publishDirectory . 'Http/Composers/AdminSidebar.php'  => app_path('Http/Composers/AdminSideBar.php'),
            $publishDirectory . 'Http/Composers/Menu.php'          => app_path('Http/Composers/Menu.php'),
            $publishDirectory . 'Http/Middleware/Authenticate.php' => app_path('Http/Middleware/Authenticate.php'),
            $publishDirectory . 'Http/Kernel.php'                  => app_path('Http/Kernel.php'),
            $publishDirectory . 'Models/User.php'                  => app_path('Models/User.php'),
            $publishDirectory . 'Providers/Auth.php'               => app_path('Providers/AuthServiceProvider.php'),
            $publishDirectory . 'Providers/Composer.php'           => app_path('Providers/ComposerServiceProvider.php'),
            $publishDirectory . 'Providers/Event.php'              => app_path('Providers/EventServiceProvider.php'),
            $publishDirectory . 'Services/Admin/'                  => app_path('Services/Admin/'),
            $publishDirectory . 'config/route.php'                 => base_path('config/route.php'),
        ], 'user_template_files');
    }
1173218
private function linkSubdirectories($src, $to)
	{
		if (is_dir($src))
		{
			$dirHandle = opendir($src);

			while (false !== ($element = readdir($dirHandle)))
			{
				if (substr($element, 0, 1) != '.')
				{
					if (is_dir($src . "/" . $element))
					{
						$this->symlink($src . "/" . $element, $to . '/' . $element);
					}
				}
			}
		}
	}
1158865
public function handle()
    {
        $name = config('cms.frontend-theme');

        $result = 'Symlink failed to generate';

        if (symlink(base_path('resources/themes/'.strtolower($name).'/public'), base_path('public/theme'))) {
            $result = 'Symlink generated';
        }

        $this->info($result);
    }
802096
public function cat(): void
    {
        $paths = $this->getConfigPaths();

        foreach ($paths as $path) {
            WP_CLI::line(
                WP_CLI::colorize("%B====> Printing $path%n")
            );

            // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown
            $contents = file_get_contents($path);

            $contentsWithoutLineBreaks = str_replace(["\r", "\n"], '', $contents);
            if (empty($contentsWithoutLineBreaks)) {
                WP_CLI::error_multi_line([
                    "File '$path' is empty.",
                ]);
            }

            WP_CLI::line($contents);
            // Print a empty line for better UX.
            WP_CLI::line('');
        }
    }