diff --git a/rector.php b/rector.php index af271bb..4edb04c 100644 --- a/rector.php +++ b/rector.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector; @@ -19,7 +20,10 @@ ->withPreparedSets( deadCode: true, codeQuality: true, - earlyReturn: true, + codingStyle: true, typeDeclarations: true, - codingStyle: true - ); + earlyReturn: true + ) + ->withSkip([ + PostIncDecToPreIncDecRector::class, + ]); diff --git a/src/Console/Commands/CheckMarkdown.php b/src/Console/Commands/CheckMarkdown.php index 512d182..c45c970 100644 --- a/src/Console/Commands/CheckMarkdown.php +++ b/src/Console/Commands/CheckMarkdown.php @@ -10,25 +10,23 @@ class CheckMarkdown extends Command { /** - * The name and signature of the console command. - * * @var string */ - protected $signature = 'fusion:check {--dir=}'; + protected $signature = 'fusion:check + {--dir= : the directory of the Markdown files }'; /** - * The console command description. - * * @var string */ - protected $description = 'Check the Markdown files'; + protected $description = 'It shows the list of the frontmatter fields of each Markdown file found'; /** * Execute the console command. */ public function handle(): void { - $this->info('Parsing the Markdown Files'); + + $this->output->title('Parsing the Markdown Files'); $filesystem = new FileSystem(); $contentDirectory = $this->option('dir'); if (is_null($contentDirectory)) { @@ -36,7 +34,10 @@ public function handle(): void } foreach (File::directories($contentDirectory) as $directory) { - $this->info('Directory: '.$directory); + $this->components->twoColumnDetail('Directory', sprintf('%s', $directory)); + //$this->output->->info('Directory: '.$directory); + $numberNoMarkdown = 0; + $numberMarkdown = 0; foreach (File::files($directory) as $file) { $slug = $file->getFilenameWithoutExtension(); $extension = $file->getExtension(); @@ -45,9 +46,23 @@ public function handle(): void $fileContent = $filesystem->get($file->getRealPath()); $object = YamlFrontMatter::parse($fileContent); - $this->components->twoColumnDetail($extension.' - '.$filename, implode('; ', array_keys($object->matter()))); - //dd($object->matter()); + if ($extension == 'md') { + $numberMarkdown++; + $this->components->twoColumnDetail(' - '.$filename, implode('; ', array_keys($object->matter()))); + } else { + $numberNoMarkdown++; + } + } + + if ($numberMarkdown == 0) { + $this->warn('No Markdown files in '.$directory); } + + if ($numberNoMarkdown > 0) { + $this->warn(sprintf('Found %d files, with a no markdown extensions', $numberNoMarkdown)); + } + + $this->output->newLine(); } } } diff --git a/src/Console/Commands/SyncModel.php b/src/Console/Commands/SyncModel.php index 8ace5a2..f4cc865 100644 --- a/src/Console/Commands/SyncModel.php +++ b/src/Console/Commands/SyncModel.php @@ -28,8 +28,24 @@ class SyncModel extends GeneratorCommand */ protected $description = 'Sync the Model file from Markdown definition'; + /** + * The auto-detected model name retrieved from the markdown folder. + * For example for resources/content/article the model name + * will be the folder base name in PascalCase format so Article + * + * @var string + */ protected $modelName = ''; + /** + * The auto-detected frontmatter field names retrieved + * by parsing all the markdown files in a specific folder + * The format of the field list is in string, useful to be used + * in the model for example: + * '"title", "description", "published"' + * + * @var string + */ protected $frontmatterFields = ''; /**