diff --git a/src/Commands/GenerateBlocks.php b/src/Commands/GenerateBlocks.php deleted file mode 100644 index b9a166a4b..000000000 --- a/src/Commands/GenerateBlocks.php +++ /dev/null @@ -1,124 +0,0 @@ -filesystem = $filesystem; - $this->viewFactory = $viewFactory; - } - - /** - * Executes the console command. - * - * @return mixed - */ - public function handle() - { - if (!$this->filesystem->exists($path = resource_path('views/admin/blocks'))) { - $this->error(self::NO_BLOCKS_DEFINED); - - return; - } - - $this->info(self::SCANNING_BLOCKS); - - Collection::make($this->filesystem->files($path))->each(function ($viewFile) { - $blockName = $viewFile->getBasename('.blade.php'); - - $vueBlockTemplate = $this->viewFactory->make('admin.blocks.' . $blockName, ['renderForBlocks' => true])->render(); - - $vueBlockContent = $this->viewFactory->make('twill::blocks.builder', [ - 'render' => $this->sanitize($vueBlockTemplate), - ])->render(); - - $vueBlockPath = $this->makeDirectory(resource_path(config('twill.block_editor.custom_vue_blocks_resource_path', 'assets/js/blocks'))) . '/Block' . Str::title($blockName) . '.vue'; - - $this->filesystem->put($vueBlockPath, $vueBlockContent); - - $this->info("Block " . Str::title($blockName) . " generated successfully"); - }); - - $this->info("All blocks have been generated!"); - } - - /** - * Recursively make a directory. - * - * @param string $directory - * @return string - */ - public function makeDirectory($directory) - { - if (!$this->filesystem->exists($directory)) { - $this->filesystem->makeDirectory($directory, 0755, true); - } - return $directory; - } - - /** - * Sanitizes the given HTML code by removing redundant spaces and comments. - * - * @param string $html - * @return string - */ - private function sanitize($html) - { - $search = array( - '/\>[^\S ]+/s', // strip whitespaces after tags, except space - '/[^\S ]+\/', // Remove HTML comments - ); - - $replace = array( - '>', - '<', - '\\1', - '', - ); - - return preg_replace($search, $replace, $html); - } -} diff --git a/src/TwillServiceProvider.php b/src/TwillServiceProvider.php index cd1cc777f..d82494db2 100644 --- a/src/TwillServiceProvider.php +++ b/src/TwillServiceProvider.php @@ -5,7 +5,6 @@ use A17\Twill\Commands\Build; use A17\Twill\Commands\CreateSuperAdmin; use A17\Twill\Commands\Dev; -use A17\Twill\Commands\GenerateBlocks; use A17\Twill\Commands\Install; use A17\Twill\Commands\ModuleMake; use A17\Twill\Commands\BlockMake; @@ -276,7 +275,6 @@ private function registerCommands() ListBlocks::class, CreateSuperAdmin::class, RefreshLQIP::class, - GenerateBlocks::class, Build::class, Update::class, Dev::class,