protected function detectUiComponents()
    {

        /* @var $extensionsManager Manager */
        $extensionsManager = app()->make(Manager::class);
        $components        = [];
        $directories       = [];

        foreach ($this->paths as $path) {
            try {
                $directories[] = $this->files->directories($path);
            } catch (Exception $ex) {
                continue;
            }
        }

        $directories = count($directories) ? array_merge(...$directories) : [];
        $inner       = [];

        foreach ($directories as $index => $directory) {
            $classBasename = class_basename($directory);

            if (!in_array($classBasename, ['Widgets', 'UiComponents'], true) || !$extensionsManager->getActiveExtensionByPath($directory)) {
                unset($directories[$index]);
                continue;
            }

            if (!empty($componentDirectory = $this->files->directories($directory))) {
                $inner[] = $componentDirectory;
            }
        }

        $inner       = count($inner) ? array_merge(...$inner) : [];
        $directories = array_merge($directories, $inner);

        foreach ($directories as $directory) {
            $components[] = $this->files->files($directory);
        }
        return count($components) ? array_merge(...$components) : [];
    }