From 48e83ee578ccb4c579545990692e72a919f58935 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 2 Nov 2022 13:31:15 +0100 Subject: [PATCH 01/31] Adding MakePublicationTypeCommand --- .../Commands/MakePublicationTypeCommand.php | 102 ++++++++++++++++++ .../Console/HydeConsoleServiceProvider.php | 1 + 2 files changed, 103 insertions(+) create mode 100644 packages/framework/src/Console/Commands/MakePublicationTypeCommand.php diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php new file mode 100644 index 00000000000..5e45b6b57e4 --- /dev/null +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -0,0 +1,102 @@ +title('Creating a new Publication Type!'); + + $this->title = $this->argument('title') + ?? $this->ask('What is the name of the Publication Type?') + ?? 'My new Publication Type'; + + //$this->line('Creating a new '.ucwords($this->selectedType).' page with title: '.$this->title."\n"); + + //$this->force = $this->option('force') ?? false; + + $this->fields = $this->getFieldsDefinitions(); + + $this->output->writeln('Now please choose the field you wish to sort by:'); + foreach ($this->fields as $k=>$v) { + $_k = $k+1; + $this->line(" $_k: $v[name]"); + } + $this->sortField = $this->ask("Sort field: (1-$_k)"); + $this->sortField = $this->fields[((int)$this->sortField)-1]['name']; + + $creator = new CreatesNewPublicationType($this->title, $this->fields, $this->sortField); + + return Command::SUCCESS; + } + + private function getFieldsDefinitions(): array + { + $this->output->writeln('You now need to define the fields in your publication type:'); + $count = 1; + $fields = []; + do { + $this->line(''); + $this->output->writeln("Field #$count:"); + + $field = []; + $field['name'] = $this->ask('Field name'); + $this->line('Field type:'); + $this->line(' 1 - String'); + $this->line(' 2 - Integer'); + $this->line(' 3 - Float'); + $this->line(' 4 - Datetime'); + $field['type'] = $this->ask('Field type (1-4)'); + $field['min'] = $this->ask('Min value (for strings, this refers to string length)'); + $field['max'] = $this->ask('Max value (for strings, this refers to string length)'); + $addAnother = $this->ask('Add another field (y/n)'); + + // map field choice to actual field type + $field['type'] = match((int)$field['type']) { + 1 => 'string', + 2 => 'integer', + 3 => 'float', + 4 => 'datetime', + }; + + $fields[] = $field; + $count++; + } while ($addAnother && strtolower($addAnother) != 'n'); + + return $fields; + } +} diff --git a/packages/framework/src/Console/HydeConsoleServiceProvider.php b/packages/framework/src/Console/HydeConsoleServiceProvider.php index 8099e7526c7..9c76d94f061 100644 --- a/packages/framework/src/Console/HydeConsoleServiceProvider.php +++ b/packages/framework/src/Console/HydeConsoleServiceProvider.php @@ -25,6 +25,7 @@ public function register(): void Commands\MakePageCommand::class, Commands\MakePostCommand::class, + Commands\MakePublicationTypeCommand::class, Commands\PublishHomepageCommand::class, Commands\PublishViewsCommand::class, From 5869d4d9a152d8ef5490943cacedf5327ec1fd2e Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 2 Nov 2022 13:36:53 +0100 Subject: [PATCH 02/31] Adding CreatesNewPublicationType --- .../Actions/CreatesNewPublicationType.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 packages/framework/src/Framework/Actions/CreatesNewPublicationType.php diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php new file mode 100644 index 00000000000..32d76546e50 --- /dev/null +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php @@ -0,0 +1,57 @@ +createPage(); + } + + protected function canSaveFile(string $path): void + { + if (file_exists($path) && ! $this->force) { + throw new FileConflictException($path); + } + } + + protected function createPage(): int|false + { + $subDir = $this->name; + if ($subDir !== '') { + $subDir = '/'.rtrim($subDir, '/\\'); + } + + @mkdir($this->name); + + $data = []; + $data['name'] = $this->name; + $data['sortField'] = $this->sortField; + $data['fields'] = $this->fields; + $json = json_encode($data, JSON_PRETTY_PRINT); + + return file_put_contents("$this->name/schema.json", $json); + } +} From ca456a514c880b5d3fccc1456db81ca3b3cf4810 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 2 Nov 2022 13:50:29 +0100 Subject: [PATCH 03/31] Cleanup + code reformatting --- .../Commands/MakePublicationTypeCommand.php | 28 ++++++------------ .../Actions/CreatesNewPublicationType.php | 29 +++++++------------ 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 5e45b6b57e4..a42e7786b3e 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -4,12 +4,7 @@ namespace Hyde\Console\Commands; -use Hyde\Framework\Actions\CreatesNewPageSourceFile; use Hyde\Framework\Actions\CreatesNewPublicationType; -use Hyde\Framework\Exceptions\UnsupportedPageTypeException; -use Hyde\Pages\BladePage; -use Hyde\Pages\DocumentationPage; -use Hyde\Pages\MarkdownPage; use LaravelZero\Framework\Commands\Command; /** @@ -21,8 +16,7 @@ class MakePublicationTypeCommand extends Command { /** @var string */ protected $signature = 'make:publicationType - {title? : The name of the publication tye to create. Will be used to generate the storage directory} - {--force : Overwrite any existing files}'; + {title? : The name of the Publication Type to create. Will be used to generate the storage directory}'; /** @var string */ protected $description = 'Create a new publication type definition'; @@ -45,19 +39,15 @@ public function handle(): int ?? $this->ask('What is the name of the Publication Type?') ?? 'My new Publication Type'; - //$this->line('Creating a new '.ucwords($this->selectedType).' page with title: '.$this->title."\n"); - - //$this->force = $this->option('force') ?? false; - $this->fields = $this->getFieldsDefinitions(); $this->output->writeln('Now please choose the field you wish to sort by:'); - foreach ($this->fields as $k=>$v) { - $_k = $k+1; - $this->line(" $_k: $v[name]"); + foreach ($this->fields as $k => $v) { + $humanCount = $k + 1; + $this->line(" $humanCount: $v[name]"); } - $this->sortField = $this->ask("Sort field: (1-$_k)"); - $this->sortField = $this->fields[((int)$this->sortField)-1]['name']; + $this->sortField = $this->ask("Sort field: (1-$humanCount)"); + $this->sortField = $this->fields[((int)$this->sortField) - 1]['name']; $creator = new CreatesNewPublicationType($this->title, $this->fields, $this->sortField); @@ -67,13 +57,13 @@ public function handle(): int private function getFieldsDefinitions(): array { $this->output->writeln('You now need to define the fields in your publication type:'); - $count = 1; + $count = 1; $fields = []; do { $this->line(''); $this->output->writeln("Field #$count:"); - $field = []; + $field = []; $field['name'] = $this->ask('Field name'); $this->line('Field type:'); $this->line(' 1 - String'); @@ -86,7 +76,7 @@ private function getFieldsDefinitions(): array $addAnother = $this->ask('Add another field (y/n)'); // map field choice to actual field type - $field['type'] = match((int)$field['type']) { + $field['type'] = match ((int)$field['type']) { 1 => 'string', 2 => 'integer', 3 => 'float', diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php index 32d76546e50..5d342c3cafb 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php @@ -6,12 +6,6 @@ use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Framework\Exceptions\FileConflictException; -use Hyde\Framework\Exceptions\UnsupportedPageTypeException; -use Hyde\Hyde; -use Hyde\Pages\BladePage; -use Hyde\Pages\DocumentationPage; -use Hyde\Pages\MarkdownPage; -use Illuminate\Support\Str; /** * Scaffold a new Markdown, Blade, or documentation page. @@ -25,32 +19,29 @@ class CreatesNewPublicationType public function __construct( protected string $name, protected array $fields, - protected string $sortField) - { + protected string $sortField + ) { $this->createPage(); } protected function canSaveFile(string $path): void { - if (file_exists($path) && ! $this->force) { + if (file_exists($path) && !$this->force) { throw new FileConflictException($path); } } protected function createPage(): int|false { - $subDir = $this->name; - if ($subDir !== '') { - $subDir = '/'.rtrim($subDir, '/\\'); - } - @mkdir($this->name); - $data = []; - $data['name'] = $this->name; - $data['sortField'] = $this->sortField; - $data['fields'] = $this->fields; - $json = json_encode($data, JSON_PRETTY_PRINT); + $data = []; + $data['name'] = $this->name; + $data['sortField'] = $this->sortField; + $data['detailTemplate'] = "{$this->name}.detail.blade.php"; + $data['listTemplate'] = "{$this->name}.list.blade.php"; + $data['fields'] = $this->fields; + $json = json_encode($data, JSON_PRETTY_PRINT); return file_put_contents("$this->name/schema.json", $json); } From 84b37a0a274dcd8c3a58baa73997dea40020cbf2 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 2 Nov 2022 13:57:54 +0100 Subject: [PATCH 04/31] Adding .editorconfig file --- .editorconfig | 902 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 902 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..83f43e36661 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,902 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 160 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.blade.php] +ij_blade_keep_indents_on_empty_lines = false + +[*.css] +ij_css_align_closing_brace_with_properties = false +ij_css_blank_lines_around_nested_selector = 1 +ij_css_blank_lines_between_blocks = 1 +ij_css_block_comment_add_space = false +ij_css_brace_placement = end_of_line +ij_css_enforce_quotes_on_format = false +ij_css_hex_color_long_format = false +ij_css_hex_color_lower_case = false +ij_css_hex_color_short_format = false +ij_css_hex_color_upper_case = false +ij_css_keep_blank_lines_in_code = 2 +ij_css_keep_indents_on_empty_lines = false +ij_css_keep_single_line_blocks = false +ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_css_space_after_colon = true +ij_css_space_before_opening_brace = true +ij_css_use_double_quotes = true +ij_css_value_alignment = do_not_align + +[*.feature] +indent_size = 2 +ij_gherkin_keep_indents_on_empty_lines = false + +[*.haml] +indent_size = 2 +ij_haml_keep_indents_on_empty_lines = false + +[*.less] +indent_size = 2 +ij_less_align_closing_brace_with_properties = false +ij_less_blank_lines_around_nested_selector = 1 +ij_less_blank_lines_between_blocks = 1 +ij_less_block_comment_add_space = false +ij_less_brace_placement = 0 +ij_less_enforce_quotes_on_format = false +ij_less_hex_color_long_format = false +ij_less_hex_color_lower_case = false +ij_less_hex_color_short_format = false +ij_less_hex_color_upper_case = false +ij_less_keep_blank_lines_in_code = 2 +ij_less_keep_indents_on_empty_lines = false +ij_less_keep_single_line_blocks = false +ij_less_line_comment_add_space = false +ij_less_line_comment_at_first_column = false +ij_less_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_less_space_after_colon = true +ij_less_space_before_opening_brace = true +ij_less_use_double_quotes = true +ij_less_value_alignment = 0 + +[*.sass] +indent_size = 2 +ij_sass_align_closing_brace_with_properties = false +ij_sass_blank_lines_around_nested_selector = 1 +ij_sass_blank_lines_between_blocks = 1 +ij_sass_brace_placement = 0 +ij_sass_enforce_quotes_on_format = false +ij_sass_hex_color_long_format = false +ij_sass_hex_color_lower_case = false +ij_sass_hex_color_short_format = false +ij_sass_hex_color_upper_case = false +ij_sass_keep_blank_lines_in_code = 2 +ij_sass_keep_indents_on_empty_lines = false +ij_sass_keep_single_line_blocks = false +ij_sass_line_comment_add_space = false +ij_sass_line_comment_at_first_column = false +ij_sass_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_sass_space_after_colon = true +ij_sass_space_before_opening_brace = true +ij_sass_use_double_quotes = true +ij_sass_value_alignment = 0 + +[*.scss] +indent_size = 2 +ij_scss_align_closing_brace_with_properties = false +ij_scss_blank_lines_around_nested_selector = 1 +ij_scss_blank_lines_between_blocks = 1 +ij_scss_block_comment_add_space = false +ij_scss_brace_placement = 0 +ij_scss_enforce_quotes_on_format = false +ij_scss_hex_color_long_format = false +ij_scss_hex_color_lower_case = false +ij_scss_hex_color_short_format = false +ij_scss_hex_color_upper_case = false +ij_scss_keep_blank_lines_in_code = 2 +ij_scss_keep_indents_on_empty_lines = false +ij_scss_keep_single_line_blocks = false +ij_scss_line_comment_add_space = false +ij_scss_line_comment_at_first_column = false +ij_scss_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_scss_space_after_colon = true +ij_scss_space_before_opening_brace = true +ij_scss_use_double_quotes = true +ij_scss_value_alignment = 0 + +[*.twig] +ij_twig_keep_indents_on_empty_lines = false +ij_twig_spaces_inside_comments_delimiters = true +ij_twig_spaces_inside_delimiters = true +ij_twig_spaces_inside_variable_delimiters = true + +[*.vue] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 4 +ij_vue_indent_children_of_top_level = template +ij_vue_interpolation_new_line_after_start_delimiter = true +ij_vue_interpolation_new_line_before_end_delimiter = true +ij_vue_interpolation_wrap = off +ij_vue_keep_indents_on_empty_lines = false +ij_vue_spaces_within_interpolation_expressions = true + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal + +[{*.ats,*.cts,*.mts,*.ts}] +ij_continuation_indent_size = 4 +ij_typescript_align_imports = false +ij_typescript_align_multiline_array_initializer_expression = false +ij_typescript_align_multiline_binary_operation = false +ij_typescript_align_multiline_chained_methods = false +ij_typescript_align_multiline_extends_list = false +ij_typescript_align_multiline_for = true +ij_typescript_align_multiline_parameters = true +ij_typescript_align_multiline_parameters_in_calls = false +ij_typescript_align_multiline_ternary_operation = false +ij_typescript_align_object_properties = 0 +ij_typescript_align_union_types = false +ij_typescript_align_var_statements = 0 +ij_typescript_array_initializer_new_line_after_left_brace = false +ij_typescript_array_initializer_right_brace_on_new_line = false +ij_typescript_array_initializer_wrap = off +ij_typescript_assignment_wrap = off +ij_typescript_binary_operation_sign_on_next_line = false +ij_typescript_binary_operation_wrap = off +ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_typescript_blank_lines_after_imports = 1 +ij_typescript_blank_lines_around_class = 1 +ij_typescript_blank_lines_around_field = 0 +ij_typescript_blank_lines_around_field_in_interface = 0 +ij_typescript_blank_lines_around_function = 1 +ij_typescript_blank_lines_around_method = 1 +ij_typescript_blank_lines_around_method_in_interface = 1 +ij_typescript_block_brace_style = end_of_line +ij_typescript_block_comment_add_space = false +ij_typescript_block_comment_at_first_column = true +ij_typescript_call_parameters_new_line_after_left_paren = false +ij_typescript_call_parameters_right_paren_on_new_line = false +ij_typescript_call_parameters_wrap = off +ij_typescript_catch_on_new_line = false +ij_typescript_chained_call_dot_on_new_line = true +ij_typescript_class_brace_style = end_of_line +ij_typescript_comma_on_new_line = false +ij_typescript_do_while_brace_force = never +ij_typescript_else_on_new_line = false +ij_typescript_enforce_trailing_comma = keep +ij_typescript_enum_constants_wrap = on_every_item +ij_typescript_extends_keyword_wrap = off +ij_typescript_extends_list_wrap = off +ij_typescript_field_prefix = _ +ij_typescript_file_name_style = relaxed +ij_typescript_finally_on_new_line = false +ij_typescript_for_brace_force = never +ij_typescript_for_statement_new_line_after_left_paren = false +ij_typescript_for_statement_right_paren_on_new_line = false +ij_typescript_for_statement_wrap = off +ij_typescript_force_quote_style = false +ij_typescript_force_semicolon_style = false +ij_typescript_function_expression_brace_style = end_of_line +ij_typescript_if_brace_force = never +ij_typescript_import_merge_members = global +ij_typescript_import_prefer_absolute_path = global +ij_typescript_import_sort_members = true +ij_typescript_import_sort_module_name = false +ij_typescript_import_use_node_resolution = true +ij_typescript_imports_wrap = on_every_item +ij_typescript_indent_case_from_switch = true +ij_typescript_indent_chained_calls = true +ij_typescript_indent_package_children = 0 +ij_typescript_jsdoc_include_types = false +ij_typescript_jsx_attribute_value = braces +ij_typescript_keep_blank_lines_in_code = 2 +ij_typescript_keep_first_column_comment = true +ij_typescript_keep_indents_on_empty_lines = false +ij_typescript_keep_line_breaks = true +ij_typescript_keep_simple_blocks_in_one_line = false +ij_typescript_keep_simple_methods_in_one_line = false +ij_typescript_line_comment_add_space = true +ij_typescript_line_comment_at_first_column = false +ij_typescript_method_brace_style = end_of_line +ij_typescript_method_call_chain_wrap = off +ij_typescript_method_parameters_new_line_after_left_paren = false +ij_typescript_method_parameters_right_paren_on_new_line = false +ij_typescript_method_parameters_wrap = off +ij_typescript_object_literal_wrap = on_every_item +ij_typescript_parentheses_expression_new_line_after_left_paren = false +ij_typescript_parentheses_expression_right_paren_on_new_line = false +ij_typescript_place_assignment_sign_on_next_line = false +ij_typescript_prefer_as_type_cast = false +ij_typescript_prefer_explicit_types_function_expression_returns = false +ij_typescript_prefer_explicit_types_function_returns = false +ij_typescript_prefer_explicit_types_vars_fields = false +ij_typescript_prefer_parameters_wrap = false +ij_typescript_reformat_c_style_comments = false +ij_typescript_space_after_colon = true +ij_typescript_space_after_comma = true +ij_typescript_space_after_dots_in_rest_parameter = false +ij_typescript_space_after_generator_mult = true +ij_typescript_space_after_property_colon = true +ij_typescript_space_after_quest = true +ij_typescript_space_after_type_colon = true +ij_typescript_space_after_unary_not = false +ij_typescript_space_before_async_arrow_lparen = true +ij_typescript_space_before_catch_keyword = true +ij_typescript_space_before_catch_left_brace = true +ij_typescript_space_before_catch_parentheses = true +ij_typescript_space_before_class_lbrace = true +ij_typescript_space_before_class_left_brace = true +ij_typescript_space_before_colon = true +ij_typescript_space_before_comma = false +ij_typescript_space_before_do_left_brace = true +ij_typescript_space_before_else_keyword = true +ij_typescript_space_before_else_left_brace = true +ij_typescript_space_before_finally_keyword = true +ij_typescript_space_before_finally_left_brace = true +ij_typescript_space_before_for_left_brace = true +ij_typescript_space_before_for_parentheses = true +ij_typescript_space_before_for_semicolon = false +ij_typescript_space_before_function_left_parenth = true +ij_typescript_space_before_generator_mult = false +ij_typescript_space_before_if_left_brace = true +ij_typescript_space_before_if_parentheses = true +ij_typescript_space_before_method_call_parentheses = false +ij_typescript_space_before_method_left_brace = true +ij_typescript_space_before_method_parentheses = false +ij_typescript_space_before_property_colon = false +ij_typescript_space_before_quest = true +ij_typescript_space_before_switch_left_brace = true +ij_typescript_space_before_switch_parentheses = true +ij_typescript_space_before_try_left_brace = true +ij_typescript_space_before_type_colon = false +ij_typescript_space_before_unary_not = false +ij_typescript_space_before_while_keyword = true +ij_typescript_space_before_while_left_brace = true +ij_typescript_space_before_while_parentheses = true +ij_typescript_spaces_around_additive_operators = true +ij_typescript_spaces_around_arrow_function_operator = true +ij_typescript_spaces_around_assignment_operators = true +ij_typescript_spaces_around_bitwise_operators = true +ij_typescript_spaces_around_equality_operators = true +ij_typescript_spaces_around_logical_operators = true +ij_typescript_spaces_around_multiplicative_operators = true +ij_typescript_spaces_around_relational_operators = true +ij_typescript_spaces_around_shift_operators = true +ij_typescript_spaces_around_unary_operator = false +ij_typescript_spaces_within_array_initializer_brackets = false +ij_typescript_spaces_within_brackets = false +ij_typescript_spaces_within_catch_parentheses = false +ij_typescript_spaces_within_for_parentheses = false +ij_typescript_spaces_within_if_parentheses = false +ij_typescript_spaces_within_imports = false +ij_typescript_spaces_within_interpolation_expressions = false +ij_typescript_spaces_within_method_call_parentheses = false +ij_typescript_spaces_within_method_parentheses = false +ij_typescript_spaces_within_object_literal_braces = false +ij_typescript_spaces_within_object_type_braces = true +ij_typescript_spaces_within_parentheses = false +ij_typescript_spaces_within_switch_parentheses = false +ij_typescript_spaces_within_type_assertion = false +ij_typescript_spaces_within_union_types = true +ij_typescript_spaces_within_while_parentheses = false +ij_typescript_special_else_if_treatment = true +ij_typescript_ternary_operation_signs_on_next_line = false +ij_typescript_ternary_operation_wrap = off +ij_typescript_union_types_wrap = on_every_item +ij_typescript_use_chained_calls_group_indents = false +ij_typescript_use_double_quotes = true +ij_typescript_use_explicit_js_extension = auto +ij_typescript_use_path_mapping = always +ij_typescript_use_public_modifier = false +ij_typescript_use_semicolon_after_statement = true +ij_typescript_var_declaration_wrap = normal +ij_typescript_while_brace_force = never +ij_typescript_while_on_new_line = false +ij_typescript_wrap_comments = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true + +[{*.cjs,*.js}] +ij_continuation_indent_size = 4 +ij_javascript_align_imports = false +ij_javascript_align_multiline_array_initializer_expression = false +ij_javascript_align_multiline_binary_operation = false +ij_javascript_align_multiline_chained_methods = false +ij_javascript_align_multiline_extends_list = false +ij_javascript_align_multiline_for = true +ij_javascript_align_multiline_parameters = true +ij_javascript_align_multiline_parameters_in_calls = false +ij_javascript_align_multiline_ternary_operation = false +ij_javascript_align_object_properties = 0 +ij_javascript_align_union_types = false +ij_javascript_align_var_statements = 0 +ij_javascript_array_initializer_new_line_after_left_brace = false +ij_javascript_array_initializer_right_brace_on_new_line = false +ij_javascript_array_initializer_wrap = off +ij_javascript_assignment_wrap = off +ij_javascript_binary_operation_sign_on_next_line = false +ij_javascript_binary_operation_wrap = off +ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_javascript_blank_lines_after_imports = 1 +ij_javascript_blank_lines_around_class = 1 +ij_javascript_blank_lines_around_field = 0 +ij_javascript_blank_lines_around_function = 1 +ij_javascript_blank_lines_around_method = 1 +ij_javascript_block_brace_style = end_of_line +ij_javascript_block_comment_add_space = false +ij_javascript_block_comment_at_first_column = true +ij_javascript_call_parameters_new_line_after_left_paren = false +ij_javascript_call_parameters_right_paren_on_new_line = false +ij_javascript_call_parameters_wrap = off +ij_javascript_catch_on_new_line = false +ij_javascript_chained_call_dot_on_new_line = true +ij_javascript_class_brace_style = end_of_line +ij_javascript_comma_on_new_line = false +ij_javascript_do_while_brace_force = never +ij_javascript_else_on_new_line = false +ij_javascript_enforce_trailing_comma = keep +ij_javascript_extends_keyword_wrap = off +ij_javascript_extends_list_wrap = off +ij_javascript_field_prefix = _ +ij_javascript_file_name_style = relaxed +ij_javascript_finally_on_new_line = false +ij_javascript_for_brace_force = never +ij_javascript_for_statement_new_line_after_left_paren = false +ij_javascript_for_statement_right_paren_on_new_line = false +ij_javascript_for_statement_wrap = off +ij_javascript_force_quote_style = false +ij_javascript_force_semicolon_style = false +ij_javascript_function_expression_brace_style = end_of_line +ij_javascript_if_brace_force = never +ij_javascript_import_merge_members = global +ij_javascript_import_prefer_absolute_path = global +ij_javascript_import_sort_members = true +ij_javascript_import_sort_module_name = false +ij_javascript_import_use_node_resolution = true +ij_javascript_imports_wrap = on_every_item +ij_javascript_indent_case_from_switch = true +ij_javascript_indent_chained_calls = true +ij_javascript_indent_package_children = 0 +ij_javascript_jsx_attribute_value = braces +ij_javascript_keep_blank_lines_in_code = 2 +ij_javascript_keep_first_column_comment = true +ij_javascript_keep_indents_on_empty_lines = false +ij_javascript_keep_line_breaks = true +ij_javascript_keep_simple_blocks_in_one_line = false +ij_javascript_keep_simple_methods_in_one_line = false +ij_javascript_line_comment_add_space = true +ij_javascript_line_comment_at_first_column = false +ij_javascript_method_brace_style = end_of_line +ij_javascript_method_call_chain_wrap = off +ij_javascript_method_parameters_new_line_after_left_paren = false +ij_javascript_method_parameters_right_paren_on_new_line = false +ij_javascript_method_parameters_wrap = off +ij_javascript_object_literal_wrap = on_every_item +ij_javascript_parentheses_expression_new_line_after_left_paren = false +ij_javascript_parentheses_expression_right_paren_on_new_line = false +ij_javascript_place_assignment_sign_on_next_line = false +ij_javascript_prefer_as_type_cast = false +ij_javascript_prefer_explicit_types_function_expression_returns = false +ij_javascript_prefer_explicit_types_function_returns = false +ij_javascript_prefer_explicit_types_vars_fields = false +ij_javascript_prefer_parameters_wrap = false +ij_javascript_reformat_c_style_comments = false +ij_javascript_space_after_colon = true +ij_javascript_space_after_comma = true +ij_javascript_space_after_dots_in_rest_parameter = false +ij_javascript_space_after_generator_mult = true +ij_javascript_space_after_property_colon = true +ij_javascript_space_after_quest = true +ij_javascript_space_after_type_colon = true +ij_javascript_space_after_unary_not = false +ij_javascript_space_before_async_arrow_lparen = true +ij_javascript_space_before_catch_keyword = true +ij_javascript_space_before_catch_left_brace = true +ij_javascript_space_before_catch_parentheses = true +ij_javascript_space_before_class_lbrace = true +ij_javascript_space_before_class_left_brace = true +ij_javascript_space_before_colon = true +ij_javascript_space_before_comma = false +ij_javascript_space_before_do_left_brace = true +ij_javascript_space_before_else_keyword = true +ij_javascript_space_before_else_left_brace = true +ij_javascript_space_before_finally_keyword = true +ij_javascript_space_before_finally_left_brace = true +ij_javascript_space_before_for_left_brace = true +ij_javascript_space_before_for_parentheses = true +ij_javascript_space_before_for_semicolon = false +ij_javascript_space_before_function_left_parenth = true +ij_javascript_space_before_generator_mult = false +ij_javascript_space_before_if_left_brace = true +ij_javascript_space_before_if_parentheses = true +ij_javascript_space_before_method_call_parentheses = false +ij_javascript_space_before_method_left_brace = true +ij_javascript_space_before_method_parentheses = false +ij_javascript_space_before_property_colon = false +ij_javascript_space_before_quest = true +ij_javascript_space_before_switch_left_brace = true +ij_javascript_space_before_switch_parentheses = true +ij_javascript_space_before_try_left_brace = true +ij_javascript_space_before_type_colon = false +ij_javascript_space_before_unary_not = false +ij_javascript_space_before_while_keyword = true +ij_javascript_space_before_while_left_brace = true +ij_javascript_space_before_while_parentheses = true +ij_javascript_spaces_around_additive_operators = true +ij_javascript_spaces_around_arrow_function_operator = true +ij_javascript_spaces_around_assignment_operators = true +ij_javascript_spaces_around_bitwise_operators = true +ij_javascript_spaces_around_equality_operators = true +ij_javascript_spaces_around_logical_operators = true +ij_javascript_spaces_around_multiplicative_operators = true +ij_javascript_spaces_around_relational_operators = true +ij_javascript_spaces_around_shift_operators = true +ij_javascript_spaces_around_unary_operator = false +ij_javascript_spaces_within_array_initializer_brackets = false +ij_javascript_spaces_within_brackets = false +ij_javascript_spaces_within_catch_parentheses = false +ij_javascript_spaces_within_for_parentheses = false +ij_javascript_spaces_within_if_parentheses = false +ij_javascript_spaces_within_imports = false +ij_javascript_spaces_within_interpolation_expressions = false +ij_javascript_spaces_within_method_call_parentheses = false +ij_javascript_spaces_within_method_parentheses = false +ij_javascript_spaces_within_object_literal_braces = false +ij_javascript_spaces_within_object_type_braces = true +ij_javascript_spaces_within_parentheses = false +ij_javascript_spaces_within_switch_parentheses = false +ij_javascript_spaces_within_type_assertion = false +ij_javascript_spaces_within_union_types = true +ij_javascript_spaces_within_while_parentheses = false +ij_javascript_special_else_if_treatment = true +ij_javascript_ternary_operation_signs_on_next_line = false +ij_javascript_ternary_operation_wrap = off +ij_javascript_union_types_wrap = on_every_item +ij_javascript_use_chained_calls_group_indents = false +ij_javascript_use_double_quotes = true +ij_javascript_use_explicit_js_extension = auto +ij_javascript_use_path_mapping = always +ij_javascript_use_public_modifier = false +ij_javascript_use_semicolon_after_statement = true +ij_javascript_var_declaration_wrap = normal +ij_javascript_while_brace_force = never +ij_javascript_while_on_new_line = false +ij_javascript_wrap_comments = false + +[{*.cjsx,*.coffee}] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 2 +ij_coffeescript_align_function_body = false +ij_coffeescript_align_imports = false +ij_coffeescript_align_multiline_array_initializer_expression = true +ij_coffeescript_align_multiline_parameters = true +ij_coffeescript_align_multiline_parameters_in_calls = false +ij_coffeescript_align_object_properties = 0 +ij_coffeescript_align_union_types = false +ij_coffeescript_align_var_statements = 0 +ij_coffeescript_array_initializer_new_line_after_left_brace = false +ij_coffeescript_array_initializer_right_brace_on_new_line = false +ij_coffeescript_array_initializer_wrap = normal +ij_coffeescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_coffeescript_blank_lines_around_function = 1 +ij_coffeescript_call_parameters_new_line_after_left_paren = false +ij_coffeescript_call_parameters_right_paren_on_new_line = false +ij_coffeescript_call_parameters_wrap = normal +ij_coffeescript_chained_call_dot_on_new_line = true +ij_coffeescript_comma_on_new_line = false +ij_coffeescript_enforce_trailing_comma = keep +ij_coffeescript_field_prefix = _ +ij_coffeescript_file_name_style = relaxed +ij_coffeescript_force_quote_style = false +ij_coffeescript_force_semicolon_style = false +ij_coffeescript_function_expression_brace_style = end_of_line +ij_coffeescript_import_merge_members = global +ij_coffeescript_import_prefer_absolute_path = global +ij_coffeescript_import_sort_members = true +ij_coffeescript_import_sort_module_name = false +ij_coffeescript_import_use_node_resolution = true +ij_coffeescript_imports_wrap = on_every_item +ij_coffeescript_indent_chained_calls = true +ij_coffeescript_indent_package_children = 0 +ij_coffeescript_jsx_attribute_value = braces +ij_coffeescript_keep_blank_lines_in_code = 2 +ij_coffeescript_keep_first_column_comment = true +ij_coffeescript_keep_indents_on_empty_lines = false +ij_coffeescript_keep_line_breaks = true +ij_coffeescript_keep_simple_methods_in_one_line = false +ij_coffeescript_method_parameters_new_line_after_left_paren = false +ij_coffeescript_method_parameters_right_paren_on_new_line = false +ij_coffeescript_method_parameters_wrap = off +ij_coffeescript_object_literal_wrap = on_every_item +ij_coffeescript_prefer_as_type_cast = false +ij_coffeescript_prefer_explicit_types_function_expression_returns = false +ij_coffeescript_prefer_explicit_types_function_returns = false +ij_coffeescript_prefer_explicit_types_vars_fields = false +ij_coffeescript_reformat_c_style_comments = false +ij_coffeescript_space_after_comma = true +ij_coffeescript_space_after_dots_in_rest_parameter = false +ij_coffeescript_space_after_generator_mult = true +ij_coffeescript_space_after_property_colon = true +ij_coffeescript_space_after_type_colon = true +ij_coffeescript_space_after_unary_not = false +ij_coffeescript_space_before_async_arrow_lparen = true +ij_coffeescript_space_before_class_lbrace = true +ij_coffeescript_space_before_comma = false +ij_coffeescript_space_before_function_left_parenth = true +ij_coffeescript_space_before_generator_mult = false +ij_coffeescript_space_before_property_colon = false +ij_coffeescript_space_before_type_colon = false +ij_coffeescript_space_before_unary_not = false +ij_coffeescript_spaces_around_additive_operators = true +ij_coffeescript_spaces_around_arrow_function_operator = true +ij_coffeescript_spaces_around_assignment_operators = true +ij_coffeescript_spaces_around_bitwise_operators = true +ij_coffeescript_spaces_around_equality_operators = true +ij_coffeescript_spaces_around_logical_operators = true +ij_coffeescript_spaces_around_multiplicative_operators = true +ij_coffeescript_spaces_around_relational_operators = true +ij_coffeescript_spaces_around_shift_operators = true +ij_coffeescript_spaces_around_unary_operator = false +ij_coffeescript_spaces_within_array_initializer_braces = false +ij_coffeescript_spaces_within_array_initializer_brackets = false +ij_coffeescript_spaces_within_imports = false +ij_coffeescript_spaces_within_index_brackets = false +ij_coffeescript_spaces_within_interpolation_expressions = false +ij_coffeescript_spaces_within_method_call_parentheses = false +ij_coffeescript_spaces_within_method_parentheses = false +ij_coffeescript_spaces_within_object_braces = false +ij_coffeescript_spaces_within_object_literal_braces = false +ij_coffeescript_spaces_within_object_type_braces = true +ij_coffeescript_spaces_within_range_brackets = false +ij_coffeescript_spaces_within_type_assertion = false +ij_coffeescript_spaces_within_union_types = true +ij_coffeescript_union_types_wrap = on_every_item +ij_coffeescript_use_chained_calls_group_indents = false +ij_coffeescript_use_double_quotes = true +ij_coffeescript_use_explicit_js_extension = auto +ij_coffeescript_use_path_mapping = always +ij_coffeescript_use_public_modifier = false +ij_coffeescript_use_semicolon_after_statement = false +ij_coffeescript_var_declaration_wrap = normal + +[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}] +ij_continuation_indent_size = 4 +ij_php_align_assignments = true +ij_php_align_class_constants = true +ij_php_align_group_field_declarations = false +ij_php_align_inline_comments = false +ij_php_align_key_value_pairs = true +ij_php_align_match_arm_bodies = false +ij_php_align_multiline_array_initializer_expression = true +ij_php_align_multiline_binary_operation = false +ij_php_align_multiline_chained_methods = true +ij_php_align_multiline_extends_list = true +ij_php_align_multiline_for = true +ij_php_align_multiline_parameters = false +ij_php_align_multiline_parameters_in_calls = true +ij_php_align_multiline_ternary_operation = true +ij_php_align_named_arguments = false +ij_php_align_phpdoc_comments = false +ij_php_align_phpdoc_param_names = false +ij_php_anonymous_brace_style = end_of_line +ij_php_api_weight = 28 +ij_php_array_initializer_new_line_after_left_brace = true +ij_php_array_initializer_right_brace_on_new_line = true +ij_php_array_initializer_wrap = on_every_item +ij_php_assignment_wrap = off +ij_php_attributes_wrap = off +ij_php_author_weight = 28 +ij_php_binary_operation_sign_on_next_line = false +ij_php_binary_operation_wrap = off +ij_php_blank_lines_after_class_header = 0 +ij_php_blank_lines_after_function = 1 +ij_php_blank_lines_after_imports = 1 +ij_php_blank_lines_after_opening_tag = 1 +ij_php_blank_lines_after_package = 1 +ij_php_blank_lines_around_class = 1 +ij_php_blank_lines_around_constants = 0 +ij_php_blank_lines_around_field = 0 +ij_php_blank_lines_around_method = 1 +ij_php_blank_lines_before_class_end = 0 +ij_php_blank_lines_before_imports = 1 +ij_php_blank_lines_before_method_body = 0 +ij_php_blank_lines_before_package = 1 +ij_php_blank_lines_before_return_statement = 0 +ij_php_blank_lines_between_imports = 1 +ij_php_block_brace_style = end_of_line +ij_php_call_parameters_new_line_after_left_paren = true +ij_php_call_parameters_right_paren_on_new_line = true +ij_php_call_parameters_wrap = on_every_item +ij_php_catch_on_new_line = false +ij_php_category_weight = 28 +ij_php_class_brace_style = next_line +ij_php_comma_after_last_argument = false +ij_php_comma_after_last_array_element = false +ij_php_comma_after_last_closure_use_var = false +ij_php_comma_after_last_parameter = false +ij_php_concat_spaces = true +ij_php_copyright_weight = 28 +ij_php_deprecated_weight = 28 +ij_php_do_while_brace_force = always +ij_php_else_if_style = combine +ij_php_else_on_new_line = false +ij_php_example_weight = 28 +ij_php_extends_keyword_wrap = off +ij_php_extends_list_wrap = on_every_item +ij_php_fields_default_visibility = private +ij_php_filesource_weight = 28 +ij_php_finally_on_new_line = false +ij_php_for_brace_force = always +ij_php_for_statement_new_line_after_left_paren = true +ij_php_for_statement_right_paren_on_new_line = true +ij_php_for_statement_wrap = off +ij_php_force_empty_methods_in_one_line = false +ij_php_force_short_declaration_array_style = false +ij_php_getters_setters_naming_style = camel_case +ij_php_getters_setters_order_style = getters_first +ij_php_global_weight = 28 +ij_php_group_use_wrap = on_every_item +ij_php_if_brace_force = always +ij_php_if_lparen_on_next_line = false +ij_php_if_rparen_on_next_line = false +ij_php_ignore_weight = 28 +ij_php_import_sorting = alphabetic +ij_php_indent_break_from_case = true +ij_php_indent_case_from_switch = true +ij_php_indent_code_in_php_tags = false +ij_php_internal_weight = 28 +ij_php_keep_blank_lines_after_lbrace = 0 +ij_php_keep_blank_lines_before_right_brace = 0 +ij_php_keep_blank_lines_in_code = 2 +ij_php_keep_blank_lines_in_declarations = 2 +ij_php_keep_control_statement_in_one_line = true +ij_php_keep_first_column_comment = true +ij_php_keep_indents_on_empty_lines = false +ij_php_keep_line_breaks = true +ij_php_keep_rparen_and_lbrace_on_one_line = true +ij_php_keep_simple_classes_in_one_line = false +ij_php_keep_simple_methods_in_one_line = false +ij_php_lambda_brace_style = end_of_line +ij_php_license_weight = 28 +ij_php_line_comment_add_space = false +ij_php_line_comment_at_first_column = true +ij_php_link_weight = 28 +ij_php_lower_case_boolean_const = true +ij_php_lower_case_keywords = true +ij_php_lower_case_null_const = true +ij_php_method_brace_style = next_line +ij_php_method_call_chain_wrap = off +ij_php_method_parameters_new_line_after_left_paren = true +ij_php_method_parameters_right_paren_on_new_line = true +ij_php_method_parameters_wrap = on_every_item +ij_php_method_weight = 28 +ij_php_modifier_list_wrap = false +ij_php_multiline_chained_calls_semicolon_on_new_line = false +ij_php_namespace_brace_style = 1 +ij_php_new_line_after_php_opening_tag = true +ij_php_null_type_position = in_the_end +ij_php_package_weight = 28 +ij_php_param_weight = 0 +ij_php_parameters_attributes_wrap = off +ij_php_parentheses_expression_new_line_after_left_paren = false +ij_php_parentheses_expression_right_paren_on_new_line = false +ij_php_phpdoc_blank_line_before_tags = false +ij_php_phpdoc_blank_lines_around_parameters = false +ij_php_phpdoc_keep_blank_lines = true +ij_php_phpdoc_param_spaces_between_name_and_description = 1 +ij_php_phpdoc_param_spaces_between_tag_and_type = 1 +ij_php_phpdoc_param_spaces_between_type_and_name = 1 +ij_php_phpdoc_use_fqcn = false +ij_php_phpdoc_wrap_long_lines = false +ij_php_place_assignment_sign_on_next_line = false +ij_php_place_parens_for_constructor = 0 +ij_php_property_read_weight = 28 +ij_php_property_weight = 28 +ij_php_property_write_weight = 28 +ij_php_return_type_on_new_line = false +ij_php_return_weight = 1 +ij_php_see_weight = 28 +ij_php_since_weight = 28 +ij_php_sort_phpdoc_elements = true +ij_php_space_after_colon = true +ij_php_space_after_colon_in_enum_backed_type = true +ij_php_space_after_colon_in_named_argument = true +ij_php_space_after_colon_in_return_type = true +ij_php_space_after_comma = true +ij_php_space_after_for_semicolon = true +ij_php_space_after_quest = true +ij_php_space_after_type_cast = false +ij_php_space_after_unary_not = false +ij_php_space_before_array_initializer_left_brace = false +ij_php_space_before_catch_keyword = true +ij_php_space_before_catch_left_brace = true +ij_php_space_before_catch_parentheses = true +ij_php_space_before_class_left_brace = true +ij_php_space_before_closure_left_parenthesis = true +ij_php_space_before_colon = true +ij_php_space_before_colon_in_enum_backed_type = false +ij_php_space_before_colon_in_named_argument = false +ij_php_space_before_colon_in_return_type = false +ij_php_space_before_comma = false +ij_php_space_before_do_left_brace = true +ij_php_space_before_else_keyword = true +ij_php_space_before_else_left_brace = true +ij_php_space_before_finally_keyword = true +ij_php_space_before_finally_left_brace = true +ij_php_space_before_for_left_brace = true +ij_php_space_before_for_parentheses = true +ij_php_space_before_for_semicolon = false +ij_php_space_before_if_left_brace = true +ij_php_space_before_if_parentheses = true +ij_php_space_before_method_call_parentheses = false +ij_php_space_before_method_left_brace = true +ij_php_space_before_method_parentheses = false +ij_php_space_before_quest = true +ij_php_space_before_short_closure_left_parenthesis = false +ij_php_space_before_switch_left_brace = true +ij_php_space_before_switch_parentheses = true +ij_php_space_before_try_left_brace = true +ij_php_space_before_unary_not = false +ij_php_space_before_while_keyword = true +ij_php_space_before_while_left_brace = true +ij_php_space_before_while_parentheses = true +ij_php_space_between_ternary_quest_and_colon = false +ij_php_spaces_around_additive_operators = true +ij_php_spaces_around_arrow = false +ij_php_spaces_around_assignment_in_declare = false +ij_php_spaces_around_assignment_operators = true +ij_php_spaces_around_bitwise_operators = true +ij_php_spaces_around_equality_operators = true +ij_php_spaces_around_logical_operators = true +ij_php_spaces_around_multiplicative_operators = true +ij_php_spaces_around_null_coalesce_operator = true +ij_php_spaces_around_pipe_in_union_type = false +ij_php_spaces_around_relational_operators = true +ij_php_spaces_around_shift_operators = true +ij_php_spaces_around_unary_operator = false +ij_php_spaces_around_var_within_brackets = false +ij_php_spaces_within_array_initializer_braces = false +ij_php_spaces_within_brackets = false +ij_php_spaces_within_catch_parentheses = false +ij_php_spaces_within_for_parentheses = false +ij_php_spaces_within_if_parentheses = false +ij_php_spaces_within_method_call_parentheses = false +ij_php_spaces_within_method_parentheses = false +ij_php_spaces_within_parentheses = false +ij_php_spaces_within_short_echo_tags = true +ij_php_spaces_within_switch_parentheses = false +ij_php_spaces_within_while_parentheses = false +ij_php_special_else_if_treatment = false +ij_php_subpackage_weight = 28 +ij_php_ternary_operation_signs_on_next_line = false +ij_php_ternary_operation_wrap = off +ij_php_throws_weight = 2 +ij_php_todo_weight = 28 +ij_php_treat_multiline_arrays_and_lambdas_multiline = false +ij_php_unknown_tag_weight = 28 +ij_php_upper_case_boolean_const = false +ij_php_upper_case_null_const = false +ij_php_uses_weight = 28 +ij_php_var_weight = 28 +ij_php_variable_naming_style = mixed +ij_php_version_weight = 28 +ij_php_while_brace_force = always +ij_php_while_on_new_line = false + +[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,composer.lock,jest.config}] +indent_size = 2 +ij_json_array_wrapping = split_into_lines +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_keep_trailing_comma = false +ij_json_object_wrapping = split_into_lines +ij_json_property_alignment = do_not_align +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_add_space = false +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p +ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span,pre,textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal + +[{*.markdown,*.md}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_insert_quote_arrows_on_wrap = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true From 95140fe13d4ddc307e67597e22492356c6ace8d7 Mon Sep 17 00:00:00 2001 From: rgasch Date: Thu, 3 Nov 2022 12:16:52 +0100 Subject: [PATCH 05/31] Added MakeNewPublication job + support file + related fixes --- .../Commands/MakePublicationCommand.php | 81 +++++++++++++++++++ .../Commands/MakePublicationTypeCommand.php | 36 ++++++++- .../Console/HydeConsoleServiceProvider.php | 39 ++++----- .../Actions/CreatesNewPublicationFile.php | 44 ++++++++++ ...hp => CreatesNewPublicationTypeSchema.php} | 18 +++-- 5 files changed, 190 insertions(+), 28 deletions(-) create mode 100644 packages/framework/src/Console/Commands/MakePublicationCommand.php create mode 100644 packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php rename packages/framework/src/Framework/Actions/{CreatesNewPublicationType.php => CreatesNewPublicationTypeSchema.php} (64%) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php new file mode 100644 index 00000000000..b08e821b0c2 --- /dev/null +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -0,0 +1,81 @@ +title('Creating a new Publication Item!'); + + $pubType = $this->argument('publicationType'); + $pubTypes = $this->getPublicationTypes(); + if (!$pubType) { + $this->output->writeln('Now please choose the Publication Type to create an item for:'); + foreach ($pubTypes as $k => $pubType) { + $humanCount = $k + 1; + $this->line(" $humanCount: $pubType->name"); + } + $selected = $this->ask("Publication type: (1-$humanCount)"); + $this->pubType = $pubTypes[((int)$selected) - 1]; + } + + $this->output->writeln('You now need to enter the fields data:'); + foreach ($this->pubType->fields as $field) { + $this->fieldData[$field->name] = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); + } + + $creator = new CreatesNewPublicationFile($this->pubType, $this->fieldData); + + return Command::SUCCESS; + } + + // Fixme: this should probably be moved to a generic util/helper class + private function getPublicationTypes(): array + { + $root = base_path(); + + $data = []; + $schemaFiles = glob("$root/*/schema.json", GLOB_BRACE); + foreach ($schemaFiles as $schemaFile) { + $schema = json_decode(file_get_contents($schemaFile)); + $schema->file = $schemaFile; + $data[] = $schema; + } + + return $data; + } +} diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index a42e7786b3e..e6d46f84e45 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -4,7 +4,7 @@ namespace Hyde\Console\Commands; -use Hyde\Framework\Actions\CreatesNewPublicationType; +use Hyde\Framework\Actions\CreatesNewPublicationTypeSchema; use LaravelZero\Framework\Commands\Command; /** @@ -27,10 +27,21 @@ class MakePublicationTypeCommand extends Command protected string $title; /** - * The page title. + * The default field to sort by + */ + protected string $canonicalField; + + /** + * The default field to sort by */ protected string $sortField; + /** + * The default sort direction + */ + protected string $sortDirection; + + public function handle(): int { $this->title('Creating a new Publication Type!'); @@ -41,7 +52,7 @@ public function handle(): int $this->fields = $this->getFieldsDefinitions(); - $this->output->writeln('Now please choose the field you wish to sort by:'); + $this->output->writeln('Now please choose the default field you wish to sort by:'); foreach ($this->fields as $k => $v) { $humanCount = $k + 1; $this->line(" $humanCount: $v[name]"); @@ -49,7 +60,24 @@ public function handle(): int $this->sortField = $this->ask("Sort field: (1-$humanCount)"); $this->sortField = $this->fields[((int)$this->sortField) - 1]['name']; - $creator = new CreatesNewPublicationType($this->title, $this->fields, $this->sortField); + $this->output->writeln('Now please choose the default sort direction:'); + $this->line(' 1 - Ascending (ASC)'); + $this->line(' 2 - Descending (DESC)'); + $this->sortDirection = $this->ask('Sort direction (1-2)'); + $this->sortDirection = match ((int)$this->sortDirection) { + 1 => 'ASC', + 2 => 'DESC', + }; + + $this->output->writeln('Choose a canonical name field (the values of this field have to be unique!):'); + foreach ($this->fields as $k => $v) { + $humanCount = $k + 1; + $this->line(" $humanCount: $v[name]"); + } + $this->canonicalField = $this->ask("Canonical field: (1-$humanCount)"); + $this->canonicalField = $this->fields[((int)$this->canonicalField) - 1]['name']; + + $creator = new CreatesNewPublicationTypeSchema($this->title, $this->fields, $this->canonicalField, $this->sortField, $this->sortDirection); return Command::SUCCESS; } diff --git a/packages/framework/src/Console/HydeConsoleServiceProvider.php b/packages/framework/src/Console/HydeConsoleServiceProvider.php index 9c76d94f061..2a34d84405f 100644 --- a/packages/framework/src/Console/HydeConsoleServiceProvider.php +++ b/packages/framework/src/Console/HydeConsoleServiceProvider.php @@ -16,26 +16,29 @@ class HydeConsoleServiceProvider extends ServiceProvider */ public function register(): void { - $this->commands([ - Commands\BuildRssFeedCommand::class, - Commands\BuildSearchCommand::class, - Commands\BuildSiteCommand::class, - Commands\BuildSitemapCommand::class, - Commands\RebuildStaticSiteCommand::class, + $this->commands( + [ + Commands\BuildRssFeedCommand::class, + Commands\BuildSearchCommand::class, + Commands\BuildSiteCommand::class, + Commands\BuildSitemapCommand::class, + Commands\RebuildStaticSiteCommand::class, - Commands\MakePageCommand::class, - Commands\MakePostCommand::class, - Commands\MakePublicationTypeCommand::class, + Commands\MakePageCommand::class, + Commands\MakePostCommand::class, + Commands\MakePublicationTypeCommand::class, + Commands\MakePublicationCommand::class, - Commands\PublishHomepageCommand::class, - Commands\PublishViewsCommand::class, - Commands\UpdateConfigsCommand::class, - Commands\PackageDiscoverCommand::class, + Commands\PublishHomepageCommand::class, + Commands\PublishViewsCommand::class, + Commands\UpdateConfigsCommand::class, + Commands\PackageDiscoverCommand::class, - Commands\RouteListCommand::class, - Commands\ValidateCommand::class, - Commands\ServeCommand::class, - Commands\DebugCommand::class, - ]); + Commands\RouteListCommand::class, + Commands\ValidateCommand::class, + Commands\ServeCommand::class, + Commands\DebugCommand::class, + ] + ); } } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php new file mode 100644 index 00000000000..46d0f0aa9b9 --- /dev/null +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -0,0 +1,44 @@ +createPage(); + } + + protected function createPage(): int|false + { + $dir = dirname($this->pubType->file); + @mkdir($dir); + $canonical = Str::camel($this->fieldData[$this->pubType->canonicalField]); + $slug = Str::slug($this->fieldData[$this->pubType->canonicalField]); + + $output = "---\n"; + $output .= "__canonical: {$canonical}\n"; + $output .= "__slug: {$slug}\n"; + foreach ($this->fieldData as $k => $v) { + $output .= "{$k}: {$v}\n"; + } + $output .= "---\n"; + $output .= "Raw MD text ...\n"; + + return file_put_contents("$dir/$canonical.md", $output); + } +} diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php similarity index 64% rename from packages/framework/src/Framework/Actions/CreatesNewPublicationType.php rename to packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 5d342c3cafb..cc393d3c112 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationType.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -6,20 +6,23 @@ use Hyde\Framework\Concerns\InteractsWithDirectories; use Hyde\Framework\Exceptions\FileConflictException; +use Illuminate\Support\Str; /** * Scaffold a new Markdown, Blade, or documentation page. * * @see \Hyde\Framework\Testing\Feature\Actions\CreatesNewPageSourceFileTest */ -class CreatesNewPublicationType +class CreatesNewPublicationTypeSchema { use InteractsWithDirectories; public function __construct( protected string $name, protected array $fields, - protected string $sortField + protected string $canonicalField, + protected string $sortField, + protected string $sortDirection ) { $this->createPage(); } @@ -33,16 +36,19 @@ protected function canSaveFile(string $path): void protected function createPage(): int|false { - @mkdir($this->name); + $name = Str::camel($this->name); + @mkdir($name); $data = []; $data['name'] = $this->name; + $data['canonicalField'] = $this->canonicalField; $data['sortField'] = $this->sortField; - $data['detailTemplate'] = "{$this->name}.detail.blade.php"; - $data['listTemplate'] = "{$this->name}.list.blade.php"; + $data['sortDirection'] = $this->sortDirection; + $data['detailTemplate'] = "{$name}.detail.blade.php"; + $data['listTemplate'] = "{$name}.list.blade.php"; $data['fields'] = $this->fields; $json = json_encode($data, JSON_PRETTY_PRINT); - return file_put_contents("$this->name/schema.json", $json); + return file_put_contents("$name/schema.json", $json); } } From 31e5b00f450dd42fbb1f0afef5d4e0f38fdc4f12 Mon Sep 17 00:00:00 2001 From: rgasch Date: Thu, 3 Nov 2022 14:10:15 +0100 Subject: [PATCH 06/31] Added rector composer.json + config file. --- composer.json | 2 ++ rector.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 rector.php diff --git a/composer.json b/composer.json index b77dc442181..3d999e837e0 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,13 @@ "laravel-zero/framework": "^9.1" }, "require-dev": { + "driftingly/rector-laravel": "^0.14.0", "hyde/realtime-compiler": "dev-master", "hyde/testing": "dev-master", "laravel/tinker": "^2.7", "php-parallel-lint/php-parallel-lint": "^1.3", "phpstan/phpstan": "^1.8", + "rector/rector": "^0.14.6", "squizlabs/php_codesniffer": "^3.7", "vimeo/psalm": "^4.24" }, diff --git a/rector.php b/rector.php new file mode 100644 index 00000000000..535dfab3613 --- /dev/null +++ b/rector.php @@ -0,0 +1,17 @@ +paths([__DIR__ . '/packages']); + $rectorConfig->sets([ + LaravelSetList::LARAVEL_90, + \Rector\Set\ValueObject\SetList::PHP_80, + \Rector\Set\ValueObject\SetList::PHP_81, + ]); + $rectorConfig->rule(Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class); +}; + From 8be6a6fff2a1c9003b2717d448326f86b9faf9a2 Mon Sep 17 00:00:00 2001 From: rgasch Date: Fri, 4 Nov 2022 23:23:30 +0100 Subject: [PATCH 07/31] Code cleanup + added interfaces --- .../Interfaces/CommandHandleInterface.php | 8 +++ .../Commands/MakePublicationCommand.php | 33 ++++------ .../Commands/MakePublicationTypeCommand.php | 63 +++++++------------ .../Actions/CreatesNewPublicationFile.php | 10 +-- .../CreatesNewPublicationTypeSchema.php | 15 ++--- .../Interfaces/CreateActionInterface.php | 8 +++ 6 files changed, 62 insertions(+), 75 deletions(-) create mode 100644 packages/framework/src/Console/Commands/Interfaces/CommandHandleInterface.php create mode 100644 packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php diff --git a/packages/framework/src/Console/Commands/Interfaces/CommandHandleInterface.php b/packages/framework/src/Console/Commands/Interfaces/CommandHandleInterface.php new file mode 100644 index 00000000000..3673cbd785c --- /dev/null +++ b/packages/framework/src/Console/Commands/Interfaces/CommandHandleInterface.php @@ -0,0 +1,8 @@ +line(" $humanCount: $pubType->name"); } - $selected = $this->ask("Publication type: (1-$humanCount)"); - $this->pubType = $pubTypes[((int)$selected) - 1]; + $selected = (int)$this->ask("Publication type: (1-$humanCount)"); + $pubType = $pubTypes[$selected - 1]; } + $fieldData = []; $this->output->writeln('You now need to enter the fields data:'); - foreach ($this->pubType->fields as $field) { - $this->fieldData[$field->name] = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); + foreach ($pubType->fields as $field) { + $fieldData[$field->name] = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); } - $creator = new CreatesNewPublicationFile($this->pubType, $this->fieldData); + $creator = new CreatesNewPublicationFile($pubType, $fieldData); + if (!$creator->create()) { + return Command::FAILURE; + } return Command::SUCCESS; } + // Fixme: this should probably be moved to a generic util/helper class private function getPublicationTypes(): array { diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index e6d46f84e45..736180d706b 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -4,6 +4,7 @@ namespace Hyde\Console\Commands; +use Hyde\Console\Commands\Interfaces\CommandHandleInterface; use Hyde\Framework\Actions\CreatesNewPublicationTypeSchema; use LaravelZero\Framework\Commands\Command; @@ -12,7 +13,7 @@ * * @see \Hyde\Framework\Testing\Feature\Commands\MakePageCommandTest */ -class MakePublicationTypeCommand extends Command +class MakePublicationTypeCommand extends Command implements CommandHandleInterface { /** @var string */ protected $signature = 'make:publicationType @@ -21,67 +22,51 @@ class MakePublicationTypeCommand extends Command /** @var string */ protected $description = 'Create a new publication type definition'; - /** - * The page title. - */ - protected string $title; - - /** - * The default field to sort by - */ - protected string $canonicalField; - - /** - * The default field to sort by - */ - protected string $sortField; - - /** - * The default sort direction - */ - protected string $sortDirection; - public function handle(): int { $this->title('Creating a new Publication Type!'); - $this->title = $this->argument('title') + $title = $this->argument('title') ?? $this->ask('What is the name of the Publication Type?') ?? 'My new Publication Type'; - $this->fields = $this->getFieldsDefinitions(); + $fields = $this->getFieldsDefinitions(); $this->output->writeln('Now please choose the default field you wish to sort by:'); - foreach ($this->fields as $k => $v) { + foreach ($fields as $k => $v) { $humanCount = $k + 1; $this->line(" $humanCount: $v[name]"); } - $this->sortField = $this->ask("Sort field: (1-$humanCount)"); - $this->sortField = $this->fields[((int)$this->sortField) - 1]['name']; + $sortField = $this->ask("Sort field: (1-$humanCount)"); + $sortField = $fields[((int)$sortField) - 1]['name']; $this->output->writeln('Now please choose the default sort direction:'); $this->line(' 1 - Ascending (ASC)'); $this->line(' 2 - Descending (DESC)'); - $this->sortDirection = $this->ask('Sort direction (1-2)'); - $this->sortDirection = match ((int)$this->sortDirection) { + $sortDirection = $this->ask('Sort direction (1-2)'); + $sortDirection = match ((int)$sortDirection) { 1 => 'ASC', 2 => 'DESC', }; $this->output->writeln('Choose a canonical name field (the values of this field have to be unique!):'); - foreach ($this->fields as $k => $v) { + foreach ($fields as $k => $v) { $humanCount = $k + 1; $this->line(" $humanCount: $v[name]"); } - $this->canonicalField = $this->ask("Canonical field: (1-$humanCount)"); - $this->canonicalField = $this->fields[((int)$this->canonicalField) - 1]['name']; + $canonicalField = $this->ask("Canonical field: (1-$humanCount)"); + $canonicalField = $fields[((int)$canonicalField) - 1]['name']; - $creator = new CreatesNewPublicationTypeSchema($this->title, $this->fields, $this->canonicalField, $this->sortField, $this->sortDirection); + $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection); + if (!$creator->create()) { + return Command::FAILURE; + } return Command::SUCCESS; } + private function getFieldsDefinitions(): array { $this->output->writeln('You now need to define the fields in your publication type:'); @@ -98,14 +83,14 @@ private function getFieldsDefinitions(): array $this->line(' 2 - Integer'); $this->line(' 3 - Float'); $this->line(' 4 - Datetime'); - $field['type'] = $this->ask('Field type (1-4)'); - $field['min'] = $this->ask('Min value (for strings, this refers to string length)'); - $field['max'] = $this->ask('Max value (for strings, this refers to string length)'); - $addAnother = $this->ask('Add another field (y/n)'); + $field['type'] = (int)$this->ask('Field type (1-4)'); + $field['min'] = (int)$this->ask('Min value (for strings, this refers to string length)'); + $field['max'] = (int)$this->ask('Max value (for strings, this refers to string length)'); + $addAnother = (string)$this->ask('Add another field (y/n)'); // map field choice to actual field type - $field['type'] = match ((int)$field['type']) { - 1 => 'string', + $field['type'] = match ($field['type']) { + 0, 1 => 'string', 2 => 'integer', 3 => 'float', 4 => 'datetime', @@ -113,7 +98,7 @@ private function getFieldsDefinitions(): array $fields[] = $field; $count++; - } while ($addAnother && strtolower($addAnother) != 'n'); + } while (strtolower($addAnother) != 'n'); return $fields; } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 46d0f0aa9b9..ba143761c8e 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Actions; +use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; use Illuminate\Support\Str; @@ -12,7 +13,7 @@ * * @see \Hyde\Framework\Testing\Feature\Actions\CreatesNewPageSourceFileTest */ -class CreatesNewPublicationFile +class CreatesNewPublicationFile implements CreateActionInterface { use InteractsWithDirectories; @@ -20,15 +21,15 @@ public function __construct( protected \stdclass $pubType, protected array $fieldData ) { - $this->createPage(); } - protected function createPage(): int|false + public function create(): string|bool { $dir = dirname($this->pubType->file); @mkdir($dir); $canonical = Str::camel($this->fieldData[$this->pubType->canonicalField]); $slug = Str::slug($this->fieldData[$this->pubType->canonicalField]); + $outFile = "$dir/$canonical.md"; $output = "---\n"; $output .= "__canonical: {$canonical}\n"; @@ -39,6 +40,7 @@ protected function createPage(): int|false $output .= "---\n"; $output .= "Raw MD text ...\n"; - return file_put_contents("$dir/$canonical.md", $output); + print "Saving page data to [$outFile]\n"; + return (bool)file_put_contents($outFile, $output); } } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index cc393d3c112..1c997049a76 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -4,8 +4,8 @@ namespace Hyde\Framework\Actions; +use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; -use Hyde\Framework\Exceptions\FileConflictException; use Illuminate\Support\Str; /** @@ -13,7 +13,7 @@ * * @see \Hyde\Framework\Testing\Feature\Actions\CreatesNewPageSourceFileTest */ -class CreatesNewPublicationTypeSchema +class CreatesNewPublicationTypeSchema implements CreateActionInterface { use InteractsWithDirectories; @@ -24,17 +24,10 @@ public function __construct( protected string $sortField, protected string $sortDirection ) { - $this->createPage(); } - protected function canSaveFile(string $path): void - { - if (file_exists($path) && !$this->force) { - throw new FileConflictException($path); - } - } - protected function createPage(): int|false + public function create(): string|bool { $name = Str::camel($this->name); @mkdir($name); @@ -49,6 +42,6 @@ protected function createPage(): int|false $data['fields'] = $this->fields; $json = json_encode($data, JSON_PRETTY_PRINT); - return file_put_contents("$name/schema.json", $json); + return (bool)file_put_contents("$name/schema.json", $json); } } diff --git a/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php new file mode 100644 index 00000000000..f1fecb0d257 --- /dev/null +++ b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php @@ -0,0 +1,8 @@ + Date: Mon, 7 Nov 2022 10:53:12 +0100 Subject: [PATCH 08/31] Converting code to use custom collection class. --- composer.json | 135 ++--- composer.lock | 470 ++++++++++++------ .../Commands/MakePublicationCommand.php | 20 +- .../Commands/MakePublicationTypeCommand.php | 21 +- .../Actions/CreatesNewPublicationFile.php | 5 +- .../CreatesNewPublicationTypeSchema.php | 3 +- 6 files changed, 413 insertions(+), 241 deletions(-) diff --git a/composer.json b/composer.json index 3d999e837e0..e89f41e9384 100644 --- a/composer.json +++ b/composer.json @@ -1,67 +1,74 @@ { - "name": "hyde/hyde", - "description": "Static Site Generator to rapidly create Blogs, Documentation, and more, using Markdown and Blade.", - "keywords": ["framework", "hyde", "hyde framework"], - "homepage": "https://hydephp.com", - "type": "project", - "license": "MIT", - "support": { - "issues": "https://github.com/hydephp/hyde/issues", - "source": "https://github.com/hydephp/hyde" - }, - "authors": [ - { - "name": "Caen De Silva", - "email": "caen@desilva.se" - } - ], - "require": { - "php": "^8.1", - "hyde/framework": "dev-master", - "laravel-zero/framework": "^9.1" - }, - "require-dev": { - "driftingly/rector-laravel": "^0.14.0", - "hyde/realtime-compiler": "dev-master", - "hyde/testing": "dev-master", - "laravel/tinker": "^2.7", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpstan/phpstan": "^1.8", - "rector/rector": "^0.14.6", - "squizlabs/php_codesniffer": "^3.7", - "vimeo/psalm": "^4.24" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } - }, - "scripts": { - "post-autoload-dump": [ - "@php -r \"@unlink('./storage/framework/cache/packages.php');\"", - "@php hyde package:discover --ansi" - ] - }, - "config": { - "preferred-install": "dist", - "sort-packages": true, - "optimize-autoloader": false, - "allow-plugins": { - "pestphp/pest-plugin": true - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "bin": ["hyde"], - "repositories": [ - { - "type": "path", - "url": "./packages/*" - } + "name": "hyde/hyde", + "description": "Static Site Generator to rapidly create Blogs, Documentation, and more, using Markdown and Blade.", + "keywords": [ + "framework", + "hyde", + "hyde framework" + ], + "homepage": "https://hydephp.com", + "type": "project", + "license": "MIT", + "support": { + "issues": "https://github.com/hydephp/hyde/issues", + "source": "https://github.com/hydephp/hyde" + }, + "authors": [ + { + "name": "Caen De Silva", + "email": "caen@desilva.se" + } + ], + "require": { + "php": "^8.1", + "hyde/framework": "dev-master", + "laravel-zero/framework": "^9.1", + "rgasch/illuminate-collection-extended": "^1.0" + }, + "require-dev": { + "driftingly/rector-laravel": "^0.14.0", + "hyde/realtime-compiler": "dev-master", + "hyde/testing": "dev-master", + "laravel/tinker": "^2.7", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpstan/phpstan": "^1.8", + "rector/rector": "^0.14.6", + "squizlabs/php_codesniffer": "^3.7", + "vimeo/psalm": "^4.24" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "scripts": { + "post-autoload-dump": [ + "@php -r \"@unlink('./storage/framework/cache/packages.php');\"", + "@php hyde package:discover --ansi" ] + }, + "config": { + "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": false, + "allow-plugins": { + "pestphp/pest-plugin": true + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "bin": [ + "hyde" + ], + "repositories": [ + { + "type": "path", + "url": "./packages/*" + } + ] } diff --git a/composer.lock b/composer.lock index da4f7b9b416..cc404ddce0b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2ac2aceff68548ae63bdcb9ef19842ae", + "content-hash": "5c017f1c4c2ee25db1fab6c830f16bca", "packages": [ { "name": "brick/math", @@ -64,16 +64,16 @@ }, { "name": "dflydev/dot-access-data", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/dflydev/dflydev-dot-access-data.git", - "reference": "0992cc19268b259a39e86f296da5f0677841f42c" + "reference": "f41715465d65213d644d3141a6a93081be5d3549" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/dflydev/dflydev-dot-access-data/zipball/0992cc19268b259a39e86f296da5f0677841f42c", - "reference": "0992cc19268b259a39e86f296da5f0677841f42c", + "url": "https://github.com/gitapi/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549", + "reference": "f41715465d65213d644d3141a6a93081be5d3549", "shasum": "" }, "require": { @@ -84,7 +84,7 @@ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.3", "scrutinizer/ocular": "1.6.0", "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^3.14" + "vimeo/psalm": "^4.0.0" }, "type": "library", "extra": { @@ -133,9 +133,9 @@ ], "support": { "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues", - "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.1" + "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2" }, - "time": "2021-08-13T13:06:58+00:00" + "time": "2022-10-27T11:44:00+00:00" }, { "name": "doctrine/inflector", @@ -291,16 +291,16 @@ }, { "name": "filp/whoops", - "version": "2.14.5", + "version": "2.14.6", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc" + "reference": "f7948baaa0330277c729714910336383286305da" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/filp/whoops/zipball/a63e5e8f26ebbebf8ed3c5c691637325512eb0dc", - "reference": "a63e5e8f26ebbebf8ed3c5c691637325512eb0dc", + "url": "https://github.com/gitapi/repos/filp/whoops/zipball/f7948baaa0330277c729714910336383286305da", + "reference": "f7948baaa0330277c729714910336383286305da", "shasum": "" }, "require": { @@ -350,7 +350,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.14.5" + "source": "https://github.com/filp/whoops/tree/2.14.6" }, "funding": [ { @@ -358,7 +358,7 @@ "type": "github" } ], - "time": "2022-01-07T12:00:00+00:00" + "time": "2022-11-02T16:23:29+00:00" }, { "name": "fruitcake/php-cors", @@ -830,7 +830,7 @@ "dist": { "type": "path", "url": "./packages/framework", - "reference": "6d64cb61b879f53097eda4cf1ae4ad9845ba7390" + "reference": "d798597286187fa0bb7163f498909f1a0b976f24" }, "require": { "illuminate/support": "^9.5", @@ -876,7 +876,7 @@ }, { "name": "illuminate/bus", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/bus.git", @@ -929,7 +929,7 @@ }, { "name": "illuminate/cache", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", @@ -989,16 +989,16 @@ }, { "name": "illuminate/collections", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "32e3cd051cf1d12c1e7d5f7bb5a52d0dae8b7a8b" + "reference": "9d98beda3f50251321565b77455687794e47dfcc" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/collections/zipball/32e3cd051cf1d12c1e7d5f7bb5a52d0dae8b7a8b", - "reference": "32e3cd051cf1d12c1e7d5f7bb5a52d0dae8b7a8b", + "url": "https://github.com/gitapi/repos/illuminate/collections/zipball/9d98beda3f50251321565b77455687794e47dfcc", + "reference": "9d98beda3f50251321565b77455687794e47dfcc", "shasum": "" }, "require": { @@ -1040,11 +1040,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-06T14:13:23+00:00" + "time": "2022-10-29T16:25:53+00:00" }, { "name": "illuminate/conditionable", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -1090,7 +1090,7 @@ }, { "name": "illuminate/config", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/config.git", @@ -1138,16 +1138,16 @@ }, { "name": "illuminate/console", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", - "reference": "a8a91de48aa316259b36079b4eec536690a80d7d" + "reference": "dc6b00cbb4ad165973beec7298bcc6b5ba7082ae" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/console/zipball/a8a91de48aa316259b36079b4eec536690a80d7d", - "reference": "a8a91de48aa316259b36079b4eec536690a80d7d", + "url": "https://github.com/gitapi/repos/illuminate/console/zipball/dc6b00cbb4ad165973beec7298bcc6b5ba7082ae", + "reference": "dc6b00cbb4ad165973beec7298bcc6b5ba7082ae", "shasum": "" }, "require": { @@ -1196,11 +1196,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-17T18:39:13+00:00" + "time": "2022-11-01T14:00:25+00:00" }, { "name": "illuminate/container", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", @@ -1251,16 +1251,16 @@ }, { "name": "illuminate/contracts", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "d57130115694b4f6a98d064bea31cdb09d7784f8" + "reference": "c7cc6e6198cac6dfdead111f9758de25413188b7" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/contracts/zipball/d57130115694b4f6a98d064bea31cdb09d7784f8", - "reference": "d57130115694b4f6a98d064bea31cdb09d7784f8", + "url": "https://github.com/gitapi/repos/illuminate/contracts/zipball/c7cc6e6198cac6dfdead111f9758de25413188b7", + "reference": "c7cc6e6198cac6dfdead111f9758de25413188b7", "shasum": "" }, "require": { @@ -1295,11 +1295,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-09-15T13:31:42+00:00" + "time": "2022-10-31T22:25:40+00:00" }, { "name": "illuminate/events", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", @@ -1354,7 +1354,7 @@ }, { "name": "illuminate/filesystem", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", @@ -1416,16 +1416,16 @@ }, { "name": "illuminate/http", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", - "reference": "211d9d77707adc1773ead9dba30537ad571c3c8e" + "reference": "db30eb18605b9fb387e6abe4650edb09cdae37c5" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/http/zipball/211d9d77707adc1773ead9dba30537ad571c3c8e", - "reference": "211d9d77707adc1773ead9dba30537ad571c3c8e", + "url": "https://github.com/gitapi/repos/illuminate/http/zipball/db30eb18605b9fb387e6abe4650edb09cdae37c5", + "reference": "db30eb18605b9fb387e6abe4650edb09cdae37c5", "shasum": "" }, "require": { @@ -1471,11 +1471,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-24T13:29:55+00:00" + "time": "2022-10-31T13:48:14+00:00" }, { "name": "illuminate/macroable", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -1521,7 +1521,7 @@ }, { "name": "illuminate/pipeline", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/pipeline.git", @@ -1569,16 +1569,16 @@ }, { "name": "illuminate/session", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", - "reference": "f62b89cee04d93852365d606040790ce90701fdf" + "reference": "97d27f60c0860e2850b86b57a5cd14b31c8b7833" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/session/zipball/f62b89cee04d93852365d606040790ce90701fdf", - "reference": "f62b89cee04d93852365d606040790ce90701fdf", + "url": "https://github.com/gitapi/repos/illuminate/session/zipball/97d27f60c0860e2850b86b57a5cd14b31c8b7833", + "reference": "97d27f60c0860e2850b86b57a5cd14b31c8b7833", "shasum": "" }, "require": { @@ -1621,20 +1621,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-09-29T14:02:36+00:00" + "time": "2022-10-25T18:53:21+00:00" }, { "name": "illuminate/support", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "f194a3b1435ed4f2542d127efb8652c7d41980ea" + "reference": "25df0f2140bc4aaf078e455decc0fe9d857ad6cc" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/support/zipball/f194a3b1435ed4f2542d127efb8652c7d41980ea", - "reference": "f194a3b1435ed4f2542d127efb8652c7d41980ea", + "url": "https://github.com/gitapi/repos/illuminate/support/zipball/25df0f2140bc4aaf078e455decc0fe9d857ad6cc", + "reference": "25df0f2140bc4aaf078e455decc0fe9d857ad6cc", "shasum": "" }, "require": { @@ -1691,11 +1691,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-24T09:54:34+00:00" + "time": "2022-10-28T13:37:39+00:00" }, { "name": "illuminate/testing", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/testing.git", @@ -1753,16 +1753,16 @@ }, { "name": "illuminate/view", - "version": "v9.37.0", + "version": "v9.38.0", "source": { "type": "git", "url": "https://github.com/illuminate/view.git", - "reference": "935608accf327a1c1cb20376a831aa419bcc64e5" + "reference": "54cead2bd72843fea77f1a274676defd5ecb3804" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/view/zipball/935608accf327a1c1cb20376a831aa419bcc64e5", - "reference": "935608accf327a1c1cb20376a831aa419bcc64e5", + "url": "https://github.com/gitapi/repos/illuminate/view/zipball/54cead2bd72843fea77f1a274676defd5ecb3804", + "reference": "54cead2bd72843fea77f1a274676defd5ecb3804", "shasum": "" }, "require": { @@ -1803,7 +1803,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-19T13:21:05+00:00" + "time": "2022-10-31T13:55:05+00:00" }, { "name": "jolicode/jolinotif", @@ -2014,16 +2014,16 @@ }, { "name": "league/commonmark", - "version": "2.3.5", + "version": "2.3.7", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "84d74485fdb7074f4f9dd6f02ab957b1de513257" + "reference": "a36bd2be4f5387c0f3a8792a0d76b7d68865abbf" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/thephpleague/commonmark/zipball/84d74485fdb7074f4f9dd6f02ab957b1de513257", - "reference": "84d74485fdb7074f4f9dd6f02ab957b1de513257", + "url": "https://github.com/gitapi/repos/thephpleague/commonmark/zipball/a36bd2be4f5387c0f3a8792a0d76b7d68865abbf", + "reference": "a36bd2be4f5387c0f3a8792a0d76b7d68865abbf", "shasum": "" }, "require": { @@ -2043,7 +2043,7 @@ "erusev/parsedown": "^1.0", "ext-json": "*", "github/gfm": "0.29.0", - "michelf/php-markdown": "^1.4", + "michelf/php-markdown": "^1.4 || ^2.0", "nyholm/psr7": "^1.5", "phpstan/phpstan": "^1.8.2", "phpunit/phpunit": "^9.5.21", @@ -2116,7 +2116,7 @@ "type": "tidelift" } ], - "time": "2022-07-29T10:59:45+00:00" + "time": "2022-11-03T17:29:46+00:00" }, { "name": "league/config", @@ -2877,16 +2877,16 @@ }, { "name": "nunomaduro/termwind", - "version": "v1.14.1", + "version": "v1.14.2", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "86fc30eace93b9b6d4c844ba6de76db84184e01b" + "reference": "9a8218511eb1a0965629ff820dda25985440aefc" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/nunomaduro/termwind/zipball/86fc30eace93b9b6d4c844ba6de76db84184e01b", - "reference": "86fc30eace93b9b6d4c844ba6de76db84184e01b", + "url": "https://github.com/gitapi/repos/nunomaduro/termwind/zipball/9a8218511eb1a0965629ff820dda25985440aefc", + "reference": "9a8218511eb1a0965629ff820dda25985440aefc", "shasum": "" }, "require": { @@ -2943,7 +2943,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v1.14.1" + "source": "https://github.com/nunomaduro/termwind/tree/v1.14.2" }, "funding": [ { @@ -2959,7 +2959,7 @@ "type": "github" } ], - "time": "2022-10-17T15:20:29+00:00" + "time": "2022-10-28T22:51:32+00:00" }, { "name": "phpoption/phpoption", @@ -3525,21 +3525,20 @@ }, { "name": "ramsey/uuid", - "version": "4.5.1", + "version": "4.6.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d" + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/ramsey/uuid/zipball/a161a26d917604dc6d3aa25100fddf2556e9f35d", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d", + "url": "https://github.com/gitapi/repos/ramsey/uuid/zipball/ad63bc700e7d021039e30ce464eba384c4a1d40f", + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f", "shasum": "" }, "require": { "brick/math": "^0.8.8 || ^0.9 || ^0.10", - "ext-ctype": "*", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.0" @@ -3571,7 +3570,6 @@ }, "suggest": { "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", - "ext-ctype": "Enables faster processing of character classification using ctype functions.", "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", @@ -3603,7 +3601,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.5.1" + "source": "https://github.com/ramsey/uuid/tree/4.6.0" }, "funding": [ { @@ -3615,7 +3613,60 @@ "type": "tidelift" } ], - "time": "2022-09-16T03:22:46+00:00" + "time": "2022-11-05T23:03:38+00:00" + }, + { + "name": "rgasch/illuminate-collection-extended", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/rgasch/illuminate-collection-extended.git", + "reference": "c9b4839e1ed57448ec721bbd3db7f8452aa20613" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/rgasch/illuminate-collection-extended/zipball/c9b4839e1ed57448ec721bbd3db7f8452aa20613", + "reference": "c9b4839e1ed57448ec721bbd3db7f8452aa20613", + "shasum": "" + }, + "require": { + "illuminate/support": "^9.0", + "php": "^8.1" + }, + "require-dev": { + "nunomaduro/larastan": "^2.2", + "pestphp/pest": "^1.16", + "pestphp/pest-plugin-laravel": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Rgasch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Robert Gasch", + "email": "rgasch@gmail.com" + } + ], + "description": "Extension class for Laravel's Collection class with some extra functionality.", + "homepage": "https://github.com/rgasch/illuminate-collection-extended", + "keywords": [ + "collection", + "framework", + "illuminate", + "laravel" + ], + "support": { + "issues": "https://github.com/rgasch/illuminate-collection-extended/issues", + "source": "https://github.com/rgasch/illuminate-collection-extended/tree/v1.0.0" + }, + "time": "2022-11-06T22:28:52+00:00" }, { "name": "spatie/yaml-front-matter", @@ -3681,16 +3732,16 @@ }, { "name": "symfony/console", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "7fa3b9cf17363468795e539231a5c91b02b608fc" + "reference": "a1282bd0c096e0bdb8800b104177e2ce404d8815" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/console/zipball/7fa3b9cf17363468795e539231a5c91b02b608fc", - "reference": "7fa3b9cf17363468795e539231a5c91b02b608fc", + "url": "https://github.com/gitapi/repos/symfony/console/zipball/a1282bd0c096e0bdb8800b104177e2ce404d8815", + "reference": "a1282bd0c096e0bdb8800b104177e2ce404d8815", "shasum": "" }, "require": { @@ -3757,7 +3808,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.1.6" + "source": "https://github.com/symfony/console/tree/v6.1.7" }, "funding": [ { @@ -3773,7 +3824,7 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:04:03+00:00" + "time": "2022-10-26T21:42:49+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3844,16 +3895,16 @@ }, { "name": "symfony/error-handler", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "49f718e41f1b6f0fd5730895ca5b1c37defd828d" + "reference": "699a26ce5ec656c198bf6e26398b0f0818c7e504" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/error-handler/zipball/49f718e41f1b6f0fd5730895ca5b1c37defd828d", - "reference": "49f718e41f1b6f0fd5730895ca5b1c37defd828d", + "url": "https://github.com/gitapi/repos/symfony/error-handler/zipball/699a26ce5ec656c198bf6e26398b0f0818c7e504", + "reference": "699a26ce5ec656c198bf6e26398b0f0818c7e504", "shasum": "" }, "require": { @@ -3895,7 +3946,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v6.1.6" + "source": "https://github.com/symfony/error-handler/tree/v6.1.7" }, "funding": [ { @@ -3911,7 +3962,7 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:04:03+00:00" + "time": "2022-10-28T16:23:08+00:00" }, { "name": "symfony/event-dispatcher", @@ -4141,16 +4192,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "3ae8e9c57155fc48930493a629da293b32efbde0" + "reference": "792a1856d2b95273f0e1c3435785f1d01a60ecc6" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/http-foundation/zipball/3ae8e9c57155fc48930493a629da293b32efbde0", - "reference": "3ae8e9c57155fc48930493a629da293b32efbde0", + "url": "https://github.com/gitapi/repos/symfony/http-foundation/zipball/792a1856d2b95273f0e1c3435785f1d01a60ecc6", + "reference": "792a1856d2b95273f0e1c3435785f1d01a60ecc6", "shasum": "" }, "require": { @@ -4196,7 +4247,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.1.6" + "source": "https://github.com/symfony/http-foundation/tree/v6.1.7" }, "funding": [ { @@ -4212,20 +4263,20 @@ "type": "tidelift" } ], - "time": "2022-10-02T08:30:52+00:00" + "time": "2022-10-12T09:44:59+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "102f99bf81799e93f61b9a73b2f38b309c587a94" + "reference": "8fc1ffe753948c47a103a809cdd6a4a8458b3254" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/http-kernel/zipball/102f99bf81799e93f61b9a73b2f38b309c587a94", - "reference": "102f99bf81799e93f61b9a73b2f38b309c587a94", + "url": "https://github.com/gitapi/repos/symfony/http-kernel/zipball/8fc1ffe753948c47a103a809cdd6a4a8458b3254", + "reference": "8fc1ffe753948c47a103a809cdd6a4a8458b3254", "shasum": "" }, "require": { @@ -4306,7 +4357,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.1.6" + "source": "https://github.com/symfony/http-kernel/tree/v6.1.7" }, "funding": [ { @@ -4322,20 +4373,20 @@ "type": "tidelift" } ], - "time": "2022-10-12T07:48:47+00:00" + "time": "2022-10-28T18:06:36+00:00" }, { "name": "symfony/mime", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "5ae192b9a39730435cfec025a499f79d05ac68a3" + "reference": "f440f066d57691088d998d6e437ce98771144618" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/mime/zipball/5ae192b9a39730435cfec025a499f79d05ac68a3", - "reference": "5ae192b9a39730435cfec025a499f79d05ac68a3", + "url": "https://github.com/gitapi/repos/symfony/mime/zipball/f440f066d57691088d998d6e437ce98771144618", + "reference": "f440f066d57691088d998d6e437ce98771144618", "shasum": "" }, "require": { @@ -4347,8 +4398,7 @@ "egulias/email-validator": "~3.0.0", "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", - "symfony/mailer": "<5.4", - "symfony/serializer": "<5.4.14|>=6.0,<6.0.14|>=6.1,<6.1.6" + "symfony/mailer": "<5.4" }, "require-dev": { "egulias/email-validator": "^2.1.10|^3.1", @@ -4356,7 +4406,7 @@ "symfony/dependency-injection": "^5.4|^6.0", "symfony/property-access": "^5.4|^6.0", "symfony/property-info": "^5.4|^6.0", - "symfony/serializer": "^5.4.14|~6.0.14|^6.1.6" + "symfony/serializer": "^5.2|^6.0" }, "type": "library", "autoload": { @@ -4388,7 +4438,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v6.1.6" + "source": "https://github.com/symfony/mime/tree/v6.1.7" }, "funding": [ { @@ -4404,7 +4454,7 @@ "type": "tidelift" } ], - "time": "2022-10-07T08:04:03+00:00" + "time": "2022-10-19T08:10:53+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5209,16 +5259,16 @@ }, { "name": "symfony/string", - "version": "v6.1.6", + "version": "v6.1.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864" + "reference": "823f143370880efcbdfa2dbca946b3358c4707e5" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/symfony/string/zipball/7e7e0ff180d4c5a6636eaad57b65092014b61864", - "reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864", + "url": "https://github.com/gitapi/repos/symfony/string/zipball/823f143370880efcbdfa2dbca946b3358c4707e5", + "reference": "823f143370880efcbdfa2dbca946b3358c4707e5", "shasum": "" }, "require": { @@ -5274,7 +5324,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.1.6" + "source": "https://github.com/symfony/string/tree/v6.1.7" }, "funding": [ { @@ -6210,16 +6260,16 @@ }, { "name": "composer/pcre", - "version": "3.0.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd" + "reference": "4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/composer/pcre/zipball/e300eb6c535192decd27a85bc72a9290f0d6b3bd", - "reference": "e300eb6c535192decd27a85bc72a9290f0d6b3bd", + "url": "https://github.com/gitapi/repos/composer/pcre/zipball/4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb", + "reference": "4482b6409ca6bfc2af043a5711cd21ac3e7a8dfb", "shasum": "" }, "require": { @@ -6261,7 +6311,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.0.0" + "source": "https://github.com/composer/pcre/tree/3.0.2" }, "funding": [ { @@ -6277,7 +6327,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T20:21:48+00:00" + "time": "2022-11-03T20:24:16+00:00" }, { "name": "composer/semver", @@ -6582,6 +6632,55 @@ ], "time": "2022-03-03T08:28:38+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "0.14.1", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "077a1d72aef3166216f632b273d449235c6e8866" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/driftingly/rector-laravel/zipball/077a1d72aef3166216f632b273d449235c6e8866", + "reference": "077a1d72aef3166216f632b273d449235c6e8866", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8.2", + "phpstan/phpstan-strict-rules": "^1.2", + "phpstan/phpstan-webmozart-assert": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/phpstan-rules": "^0.6", + "rector/rector": "^0.14.7", + "rector/rector-debugging": "dev-main", + "symplify/easy-coding-standard": "^11.0", + "symplify/phpstan-extensions": "^11.0", + "symplify/phpstan-rules": "^11.0", + "symplify/rule-doc-generator": "^11.0", + "symplify/vendor-patches": "^11.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/0.14.1" + }, + "time": "2022-11-05T17:05:59+00:00" + }, { "name": "felixfbecker/advanced-json-rpc", "version": "v3.2.1", @@ -6740,7 +6839,7 @@ "dist": { "type": "path", "url": "./packages/realtime-compiler", - "reference": "26180f50d68466f8a256fbf61b5386be830ecc54" + "reference": "905709e5320f7bfc053dea8e5eac64ebd8ec320f" }, "require": { "desilva/microserve": "^1.0", @@ -6778,7 +6877,7 @@ "dist": { "type": "path", "url": "./packages/testing", - "reference": "676a590d21664501707bf4d214ad532ab26a2061" + "reference": "05ca2f663e04439be77799bf5e1e1701faaf23c3" }, "require": { "illuminate/support": "^9.5", @@ -7838,16 +7937,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.11", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "46e223dd68a620da18855c23046ddb00940b4014" + "reference": "a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014", - "reference": "46e223dd68a620da18855c23046ddb00940b4014", + "url": "https://github.com/gitapi/repos/phpstan/phpstan/zipball/a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f", + "reference": "a59c8b5bfd4a236f27efc8b5ce72c313c2b54b5f", "shasum": "" }, "require": { @@ -7877,7 +7976,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.11" + "source": "https://github.com/phpstan/phpstan/tree/1.9.1" }, "funding": [ { @@ -7893,20 +7992,20 @@ "type": "tidelift" } ], - "time": "2022-10-24T15:45:13+00:00" + "time": "2022-11-04T13:35:59+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.17", + "version": "9.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", + "url": "https://github.com/gitapi/repos/sebastianbergmann/php-code-coverage/zipball/12fddc491826940cf9b7e88ad9664cf51f0f6d0a", + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a", "shasum": "" }, "require": { @@ -7962,7 +8061,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.18" }, "funding": [ { @@ -7970,7 +8069,7 @@ "type": "github" } ], - "time": "2022-08-30T12:24:04+00:00" + "time": "2022-10-27T13:35:33+00:00" }, { "name": "phpunit/php-file-iterator", @@ -8215,16 +8314,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.25", + "version": "9.5.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", + "url": "https://github.com/gitapi/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2", + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2", "shasum": "" }, "require": { @@ -8297,7 +8396,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26" }, "funding": [ { @@ -8313,20 +8412,20 @@ "type": "tidelift" } ], - "time": "2022-09-25T03:44:45+00:00" + "time": "2022-10-28T06:00:21+00:00" }, { "name": "psy/psysh", - "version": "v0.11.8", + "version": "v0.11.9", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "f455acf3645262ae389b10e9beba0c358aa6994e" + "reference": "1acec99d6684a54ff92f8b548a4e41b566963778" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/bobthecow/psysh/zipball/f455acf3645262ae389b10e9beba0c358aa6994e", - "reference": "f455acf3645262ae389b10e9beba0c358aa6994e", + "url": "https://github.com/gitapi/repos/bobthecow/psysh/zipball/1acec99d6684a54ff92f8b548a4e41b566963778", + "reference": "1acec99d6684a54ff92f8b548a4e41b566963778", "shasum": "" }, "require": { @@ -8387,9 +8486,66 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.8" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.9" + }, + "time": "2022-11-06T15:29:46+00:00" + }, + { + "name": "rector/rector", + "version": "0.14.7", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "3553aaba0e820083fc6d7f0dc78d8d789226a398" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/rectorphp/rector/zipball/3553aaba0e820083fc6d7f0dc78d8d789226a398", + "reference": "3553aaba0e820083fc6d7f0dc78d8d789226a398", + "shasum": "" }, - "time": "2022-07-28T14:25:11+00:00" + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-php-parser": "*", + "rector/rector-phpoffice": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.14-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.14.7" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2022-11-04T08:48:40+00:00" }, { "name": "sebastian/cli-parser", @@ -9463,16 +9619,16 @@ }, { "name": "vimeo/psalm", - "version": "4.29.0", + "version": "4.30.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3" + "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/vimeo/psalm/zipball/7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", - "reference": "7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3", + "url": "https://github.com/gitapi/repos/vimeo/psalm/zipball/d0bc6e25d89f649e4f36a534f330f8bb4643dd69", + "reference": "d0bc6e25d89f649e4f36a534f330f8bb4643dd69", "shasum": "" }, "require": { @@ -9565,9 +9721,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.29.0" + "source": "https://github.com/vimeo/psalm/tree/4.30.0" }, - "time": "2022-10-11T17:09:17+00:00" + "time": "2022-11-06T20:37:08+00:00" }, { "name": "webmozart/path-util", @@ -9634,5 +9790,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index 793779ca74e..07d5a82752c 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -7,6 +7,7 @@ use Hyde\Console\Commands\Interfaces\CommandHandleInterface; use Hyde\Framework\Actions\CreatesNewPublicationFile; use LaravelZero\Framework\Commands\Command; +use Rgasch\Collection; /** * Hyde Command to scaffold a new Markdown or Blade page file. @@ -39,10 +40,10 @@ public function handle(): int $pubType = $pubTypes[$selected - 1]; } - $fieldData = []; + $fieldData = Collection::create(); $this->output->writeln('You now need to enter the fields data:'); foreach ($pubType->fields as $field) { - $fieldData[$field->name] = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); + $fieldData->{$field->name} = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); } $creator = new CreatesNewPublicationFile($pubType, $fieldData); @@ -55,18 +56,23 @@ public function handle(): int // Fixme: this should probably be moved to a generic util/helper class - private function getPublicationTypes(): array + private function getPublicationTypes(): Collection { $root = base_path(); - $data = []; + $pubTypes = Collection::create(); $schemaFiles = glob("$root/*/schema.json", GLOB_BRACE); foreach ($schemaFiles as $schemaFile) { - $schema = json_decode(file_get_contents($schemaFile)); + $fileData = file_get_contents($schemaFile); + if (!$fileData) { + throw new \Exception("Unable to read schema file [$schemaFile]"); + } + + $schema = Collection::create(json_decode($fileData, true)); $schema->file = $schemaFile; - $data[] = $schema; + $pubTypes->add($schema); } - return $data; + return $pubTypes; } } diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 736180d706b..addb3046aeb 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -7,6 +7,7 @@ use Hyde\Console\Commands\Interfaces\CommandHandleInterface; use Hyde\Framework\Actions\CreatesNewPublicationTypeSchema; use LaravelZero\Framework\Commands\Command; +use Rgasch\Collection; /** * Hyde Command to scaffold a new Markdown or Blade page file. @@ -67,36 +68,36 @@ public function handle(): int } - private function getFieldsDefinitions(): array + private function getFieldsDefinitions(): Collection { $this->output->writeln('You now need to define the fields in your publication type:'); $count = 1; - $fields = []; + $fields = Collection::create(); do { $this->line(''); $this->output->writeln("Field #$count:"); - $field = []; - $field['name'] = $this->ask('Field name'); + $field = Collection::create(); + $field->name = $this->ask('Field name'); $this->line('Field type:'); $this->line(' 1 - String'); $this->line(' 2 - Integer'); $this->line(' 3 - Float'); $this->line(' 4 - Datetime'); - $field['type'] = (int)$this->ask('Field type (1-4)'); - $field['min'] = (int)$this->ask('Min value (for strings, this refers to string length)'); - $field['max'] = (int)$this->ask('Max value (for strings, this refers to string length)'); - $addAnother = (string)$this->ask('Add another field (y/n)'); + $type = (int)$this->ask('Field type (1-4)'); + $field->min = (int)$this->ask('Min value (for strings, this refers to string length)'); + $field->max = (int)$this->ask('Max value (for strings, this refers to string length)'); + $addAnother = (string)$this->ask('Add another field (y/n)'); // map field choice to actual field type - $field['type'] = match ($field['type']) { + $field->type = match ($type) { 0, 1 => 'string', 2 => 'integer', 3 => 'float', 4 => 'datetime', }; - $fields[] = $field; + $fields->add($field); $count++; } while (strtolower($addAnother) != 'n'); diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index ba143761c8e..305b42f9941 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -7,6 +7,7 @@ use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; use Illuminate\Support\Str; +use Rgasch\Collection; /** * Scaffold a new Markdown, Blade, or documentation page. @@ -18,8 +19,8 @@ class CreatesNewPublicationFile implements CreateActionInterface use InteractsWithDirectories; public function __construct( - protected \stdclass $pubType, - protected array $fieldData + protected Collection $pubType, + protected Collection $fieldData ) { } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 1c997049a76..4861abe248a 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -7,6 +7,7 @@ use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; use Illuminate\Support\Str; +use Rgasch\Collection; /** * Scaffold a new Markdown, Blade, or documentation page. @@ -19,7 +20,7 @@ class CreatesNewPublicationTypeSchema implements CreateActionInterface public function __construct( protected string $name, - protected array $fields, + protected Collection $fields, protected string $canonicalField, protected string $sortField, protected string $sortDirection From e492155ee71df338f52ae23c1144297ef9694a5b Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 12:28:16 +0100 Subject: [PATCH 09/31] Added validation + lots of minor improvements. --- composer.json | 1 + composer.lock | 354 +++++++++++++++--- config/app.php | 18 +- .../Commands/MakePublicationCommand.php | 87 +++-- .../Commands/MakePublicationTypeCommand.php | 75 ++-- .../Actions/CreatesNewPublicationFile.php | 40 +- .../CreatesNewPublicationTypeSchema.php | 28 +- .../Interfaces/CreateActionInterface.php | 2 +- packages/framework/src/HydeHelper.php | 120 ++++++ 9 files changed, 589 insertions(+), 136 deletions(-) create mode 100644 packages/framework/src/HydeHelper.php diff --git a/composer.json b/composer.json index e89f41e9384..b3c9012545f 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php": "^8.1", "hyde/framework": "dev-master", "laravel-zero/framework": "^9.1", + "illuminate/validation": "^9.0.0", "rgasch/illuminate-collection-extended": "^1.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index cc404ddce0b..3b94a3362b3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5c017f1c4c2ee25db1fab6c830f16bca", + "content-hash": "4cda7afa468b8dbfe0ad2f7c388c8be8", "packages": [ { "name": "brick/math", @@ -228,6 +228,82 @@ ], "time": "2022-10-20T09:10:12+00:00" }, + { + "name": "doctrine/lexer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/doctrine/lexer/zipball/c268e882d4dbdd85e36e4ad69e02dc284f89d229", + "reference": "c268e882d4dbdd85e36e4ad69e02dc284f89d229", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "^1.3", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2022-02-28T11:07:21+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v3.3.2", @@ -289,6 +365,74 @@ ], "time": "2022-09-10T18:51:20+00:00" }, + { + "name": "egulias/email-validator", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "f88dcf4b14af14a98ad96b14b2b317969eab6715" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/egulias/EmailValidator/zipball/f88dcf4b14af14a98ad96b14b2b317969eab6715", + "reference": "f88dcf4b14af14a98ad96b14b2b317969eab6715", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^1.2", + "php": ">=7.2", + "symfony/polyfill-intl-idn": "^1.15" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^8.5.8|^9.3.3", + "vimeo/psalm": "^4" + }, + "suggest": { + "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Egulias\\EmailValidator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eduardo Gulias Davis" + } + ], + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": [ + "email", + "emailvalidation", + "emailvalidator", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/egulias/EmailValidator/issues", + "source": "https://github.com/egulias/EmailValidator/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/egulias", + "type": "github" + } + ], + "time": "2022-06-18T20:57:19+00:00" + }, { "name": "filp/whoops", "version": "2.14.6", @@ -876,16 +1020,16 @@ }, { "name": "illuminate/bus", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/bus.git", - "reference": "baccdba32ec4e7d3492cfd991806a8ead397f77f" + "reference": "91f8c74ea873f552681b9f1961df808d2a37def2" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/bus/zipball/baccdba32ec4e7d3492cfd991806a8ead397f77f", - "reference": "baccdba32ec4e7d3492cfd991806a8ead397f77f", + "url": "https://github.com/gitapi/repos/illuminate/bus/zipball/91f8c74ea873f552681b9f1961df808d2a37def2", + "reference": "91f8c74ea873f552681b9f1961df808d2a37def2", "shasum": "" }, "require": { @@ -925,11 +1069,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-09-16T19:09:47+00:00" + "time": "2022-11-03T13:05:20+00:00" }, { "name": "illuminate/cache", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", @@ -989,16 +1133,16 @@ }, { "name": "illuminate/collections", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "9d98beda3f50251321565b77455687794e47dfcc" + "reference": "1729899f8e37840738d1c37bb110da5b09509990" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/collections/zipball/9d98beda3f50251321565b77455687794e47dfcc", - "reference": "9d98beda3f50251321565b77455687794e47dfcc", + "url": "https://github.com/gitapi/repos/illuminate/collections/zipball/1729899f8e37840738d1c37bb110da5b09509990", + "reference": "1729899f8e37840738d1c37bb110da5b09509990", "shasum": "" }, "require": { @@ -1040,11 +1184,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-29T16:25:53+00:00" + "time": "2022-11-07T11:40:33+00:00" }, { "name": "illuminate/conditionable", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -1090,7 +1234,7 @@ }, { "name": "illuminate/config", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/config.git", @@ -1138,16 +1282,16 @@ }, { "name": "illuminate/console", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", - "reference": "dc6b00cbb4ad165973beec7298bcc6b5ba7082ae" + "reference": "a3627c454e0e97c3cb0b45c998f4481448706766" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/console/zipball/dc6b00cbb4ad165973beec7298bcc6b5ba7082ae", - "reference": "dc6b00cbb4ad165973beec7298bcc6b5ba7082ae", + "url": "https://github.com/gitapi/repos/illuminate/console/zipball/a3627c454e0e97c3cb0b45c998f4481448706766", + "reference": "a3627c454e0e97c3cb0b45c998f4481448706766", "shasum": "" }, "require": { @@ -1196,11 +1340,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-11-01T14:00:25+00:00" + "time": "2022-11-07T14:46:16+00:00" }, { "name": "illuminate/container", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", @@ -1251,7 +1395,7 @@ }, { "name": "illuminate/contracts", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -1299,7 +1443,7 @@ }, { "name": "illuminate/events", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", @@ -1354,7 +1498,7 @@ }, { "name": "illuminate/filesystem", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", @@ -1416,7 +1560,7 @@ }, { "name": "illuminate/http", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", @@ -1475,7 +1619,7 @@ }, { "name": "illuminate/macroable", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -1521,7 +1665,7 @@ }, { "name": "illuminate/pipeline", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/pipeline.git", @@ -1569,7 +1713,7 @@ }, { "name": "illuminate/session", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", @@ -1625,16 +1769,16 @@ }, { "name": "illuminate/support", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "25df0f2140bc4aaf078e455decc0fe9d857ad6cc" + "reference": "e613ecd3e9351328e64b7e748804aaf85f4a48c1" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/support/zipball/25df0f2140bc4aaf078e455decc0fe9d857ad6cc", - "reference": "25df0f2140bc4aaf078e455decc0fe9d857ad6cc", + "url": "https://github.com/gitapi/repos/illuminate/support/zipball/e613ecd3e9351328e64b7e748804aaf85f4a48c1", + "reference": "e613ecd3e9351328e64b7e748804aaf85f4a48c1", "shasum": "" }, "require": { @@ -1691,20 +1835,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-28T13:37:39+00:00" + "time": "2022-11-02T13:45:32+00:00" }, { "name": "illuminate/testing", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/testing.git", - "reference": "86e6618722fefa1059fb32518268199e6f267782" + "reference": "5466e79da52edeeea960b1d87b6474003ddc79b4" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/testing/zipball/86e6618722fefa1059fb32518268199e6f267782", - "reference": "86e6618722fefa1059fb32518268199e6f267782", + "url": "https://github.com/gitapi/repos/illuminate/testing/zipball/5466e79da52edeeea960b1d87b6474003ddc79b4", + "reference": "5466e79da52edeeea960b1d87b6474003ddc79b4", "shasum": "" }, "require": { @@ -1749,20 +1893,132 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-25T13:12:24+00:00" + "time": "2022-11-03T21:24:23+00:00" + }, + { + "name": "illuminate/translation", + "version": "v9.39.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/translation.git", + "reference": "53d0cd548a8ad64eaf12d539bf39ee4189dcee56" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/illuminate/translation/zipball/53d0cd548a8ad64eaf12d539bf39ee4189dcee56", + "reference": "53d0cd548a8ad64eaf12d539bf39ee4189dcee56", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/collections": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/filesystem": "^9.0", + "illuminate/macroable": "^9.0", + "illuminate/support": "^9.0", + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Translation package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-10-09T13:21:28+00:00" + }, + { + "name": "illuminate/validation", + "version": "v9.39.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/validation.git", + "reference": "89dba4d3a6fdb867796773c6c227554bbf0e0580" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/illuminate/validation/zipball/89dba4d3a6fdb867796773c6c227554bbf0e0580", + "reference": "89dba4d3a6fdb867796773c6c227554bbf0e0580", + "shasum": "" + }, + "require": { + "egulias/email-validator": "^3.2.1", + "ext-json": "*", + "illuminate/collections": "^9.0", + "illuminate/container": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/macroable": "^9.0", + "illuminate/support": "^9.0", + "illuminate/translation": "^9.0", + "php": "^8.0.2", + "symfony/http-foundation": "^6.0", + "symfony/mime": "^6.0" + }, + "suggest": { + "ext-bcmath": "Required to use the multiple_of validation rule.", + "illuminate/database": "Required to use the database presence verifier (^9.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Validation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Validation package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-10-07T19:07:25+00:00" }, { "name": "illuminate/view", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/view.git", - "reference": "54cead2bd72843fea77f1a274676defd5ecb3804" + "reference": "0d8094e3f826220d26d1d509d154beb114ee7bea" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/illuminate/view/zipball/54cead2bd72843fea77f1a274676defd5ecb3804", - "reference": "54cead2bd72843fea77f1a274676defd5ecb3804", + "url": "https://github.com/gitapi/repos/illuminate/view/zipball/0d8094e3f826220d26d1d509d154beb114ee7bea", + "reference": "0d8094e3f826220d26d1d509d154beb114ee7bea", "shasum": "" }, "require": { @@ -1803,7 +2059,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-31T13:55:05+00:00" + "time": "2022-11-02T15:46:09+00:00" }, { "name": "jolicode/jolinotif", @@ -3617,16 +3873,16 @@ }, { "name": "rgasch/illuminate-collection-extended", - "version": "v1.0.0", + "version": "v1.0.1", "source": { "type": "git", "url": "https://github.com/rgasch/illuminate-collection-extended.git", - "reference": "c9b4839e1ed57448ec721bbd3db7f8452aa20613" + "reference": "9be1e1cf4cbd996e24c07f7cde7a9a5ec28ab709" }, "dist": { "type": "zip", - "url": "https://github.com/gitapi/repos/rgasch/illuminate-collection-extended/zipball/c9b4839e1ed57448ec721bbd3db7f8452aa20613", - "reference": "c9b4839e1ed57448ec721bbd3db7f8452aa20613", + "url": "https://github.com/gitapi/repos/rgasch/illuminate-collection-extended/zipball/9be1e1cf4cbd996e24c07f7cde7a9a5ec28ab709", + "reference": "9be1e1cf4cbd996e24c07f7cde7a9a5ec28ab709", "shasum": "" }, "require": { @@ -3641,7 +3897,7 @@ "type": "library", "autoload": { "psr-4": { - "Rgasch\\": "src/" + "Rgasch\\Collection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -3664,9 +3920,9 @@ ], "support": { "issues": "https://github.com/rgasch/illuminate-collection-extended/issues", - "source": "https://github.com/rgasch/illuminate-collection-extended/tree/v1.0.0" + "source": "https://github.com/rgasch/illuminate-collection-extended/tree/v1.0.1" }, - "time": "2022-11-06T22:28:52+00:00" + "time": "2022-11-08T09:13:24+00:00" }, { "name": "spatie/yaml-front-matter", diff --git a/config/app.php b/config/app.php index 640003d9db5..5356fc5234a 100644 --- a/config/app.php +++ b/config/app.php @@ -78,6 +78,8 @@ 'providers' => [ App\Providers\AppServiceProvider::class, + Illuminate\Translation\TranslationServiceProvider::class, + Illuminate\Validation\ValidationServiceProvider::class, Hyde\Framework\HydeServiceProvider::class, ], @@ -93,14 +95,14 @@ */ 'aliases' => [ - 'Hyde' => Hyde\Hyde::class, - 'Site' => \Hyde\Facades\Site::class, - 'Route' => \Hyde\Facades\Route::class, - 'Asset' => \Hyde\Facades\Asset::class, - 'BladePage' => \Hyde\Pages\BladePage::class, - 'MarkdownPage' => \Hyde\Pages\MarkdownPage::class, - 'MarkdownPost' => \Hyde\Pages\MarkdownPost::class, - 'DocumentationPage' => \Hyde\Pages\DocumentationPage::class, + 'Hyde' => Hyde\Hyde::class, + 'Site' => Hyde\Facades\Site::class, + 'Route' => Hyde\Facades\Route::class, + 'Asset' => Hyde\Facades\Asset::class, + 'BladePage' => Hyde\Pages\BladePage::class, + 'MarkdownPage' => Hyde\Pages\MarkdownPage::class, + 'MarkdownPost' => Hyde\Pages\MarkdownPost::class, + 'DocumentationPage' => Hyde\Pages\DocumentationPage::class, ], ]; diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index 07d5a82752c..f390b847215 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -6,11 +6,13 @@ use Hyde\Console\Commands\Interfaces\CommandHandleInterface; use Hyde\Framework\Actions\CreatesNewPublicationFile; +use Hyde\HydeHelper; +use Illuminate\Support\Str; use LaravelZero\Framework\Commands\Command; -use Rgasch\Collection; +use Rgasch\Collection\Collection; /** - * Hyde Command to scaffold a new Markdown or Blade page file. + * Hyde Command to create a new publication for a given publication type * * @see \Hyde\Framework\Testing\Feature\Commands\MakePageCommandTest */ @@ -29,21 +31,66 @@ public function handle(): int $this->title('Creating a new Publication Item!'); $pubType = $this->argument('publicationType'); - $pubTypes = $this->getPublicationTypes(); + $pubTypes = HydeHelper::getPublicationTypes(); if (!$pubType) { $this->output->writeln('Now please choose the Publication Type to create an item for:'); + $offset = 0; foreach ($pubTypes as $k => $pubType) { - $humanCount = $k + 1; - $this->line(" $humanCount: $pubType->name"); + $offset++; + $this->line(" $offset: $pubType->name"); } - $selected = (int)$this->ask("Publication type: (1-$humanCount)"); - $pubType = $pubTypes[$selected - 1]; + $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Publication type (1-$offset)", ['required', 'integer', "between:1,$offset"]); + $pubType = $pubTypes->{$pubTypes->keys()[$selected - 1]}; } + $rulesPerType = Collection::create( + [ + 'string' => ['required', 'string', 'between'], + 'boolean' => ['required', 'boolean'], + 'integer' => ['required', 'integer', 'between'], + 'float' => ['required', 'numeric', 'between'], + 'datetime' => ['required', 'datetime', 'between'], + 'url' => ['required', 'url'], + 'text' => ['required', 'string', 'between'], + ] + ); + $fieldData = Collection::create(); - $this->output->writeln('You now need to enter the fields data:'); + $this->output->writeln('Now please enter the field data:'); foreach ($pubType->fields as $field) { - $fieldData->{$field->name} = $this->ask(" $field->name ($field->type, min=$field->min, max=$field->max): "); + // Need to capture text line-by-line + if ($field->type === 'text') { + $lines = []; + $this->output->writeln($field->name . " (end with a line containing only '<<<')"); + do { + $line = Str::replace("\n", '', fgets(STDIN)); + $lines[] = $line; + } while ($line != '<<<'); + + $fieldData->{$field->name} = implode("\n", $lines); + continue; + } + + // Non-text block fields + $fieldRules = $rulesPerType->{$field->type}; + if ($fieldRules->contains('between')) { + $fieldRules->forget($fieldRules->search('between')); + if ($field->min && $field->max) { + switch ($field->type) { + case 'string': + case 'integer': + case 'float': + $fieldRules->add("between:$field->min,$field->max"); + break; + case 'datetime': + $fieldRules->add("after:$field->min"); + $fieldRules->add("before:$field->max"); + break; + } + } + } + dump($fieldRules); + $fieldData->{$field->name} = HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules); } $creator = new CreatesNewPublicationFile($pubType, $fieldData); @@ -53,26 +100,4 @@ public function handle(): int return Command::SUCCESS; } - - - // Fixme: this should probably be moved to a generic util/helper class - private function getPublicationTypes(): Collection - { - $root = base_path(); - - $pubTypes = Collection::create(); - $schemaFiles = glob("$root/*/schema.json", GLOB_BRACE); - foreach ($schemaFiles as $schemaFile) { - $fileData = file_get_contents($schemaFile); - if (!$fileData) { - throw new \Exception("Unable to read schema file [$schemaFile]"); - } - - $schema = Collection::create(json_decode($fileData, true)); - $schema->file = $schemaFile; - $pubTypes->add($schema); - } - - return $pubTypes; - } } diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index addb3046aeb..462c8b986c2 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -6,11 +6,12 @@ use Hyde\Console\Commands\Interfaces\CommandHandleInterface; use Hyde\Framework\Actions\CreatesNewPublicationTypeSchema; +use Hyde\HydeHelper; use LaravelZero\Framework\Commands\Command; -use Rgasch\Collection; +use Rgasch\Collection\Collection; /** - * Hyde Command to scaffold a new Markdown or Blade page file. + * Hyde Command to create a new publication type * * @see \Hyde\Framework\Testing\Feature\Commands\MakePageCommandTest */ @@ -28,38 +29,46 @@ public function handle(): int { $this->title('Creating a new Publication Type!'); - $title = $this->argument('title') - ?? $this->ask('What is the name of the Publication Type?') - ?? 'My new Publication Type'; + $title = $this->argument('title'); + if (!$title) { + $title = trim(HydeHelper::askWithValidation($this, 'nanme', 'Publication type name', ['required', 'string'])); + $dirname = HydeHelper::formatNameForStorage($title); + if (file_exists($dirname)) { + throw new \InvalidArgumentException("Storage path [$dirname] already exists"); + } + } $fields = $this->getFieldsDefinitions(); - $this->output->writeln('Now please choose the default field you wish to sort by:'); + $this->output->writeln('Choose the default field you wish to sort by:'); + $this->line(" 0: dateCreated (meta field)"); foreach ($fields as $k => $v) { - $humanCount = $k + 1; - $this->line(" $humanCount: $v[name]"); + $offset = $k + 1; + $this->line(" $offset: $v[name]"); } - $sortField = $this->ask("Sort field: (1-$humanCount)"); - $sortField = $fields[((int)$sortField) - 1]['name']; + $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Sort field (0-$offset)", ['required', 'integer', "between:0,$offset"], 0); + $sortField = $selected ? $fields[$selected - 1]['name'] : '__createdAt'; - $this->output->writeln('Now please choose the default sort direction:'); + $this->output->writeln('Choose the default sort direction:'); $this->line(' 1 - Ascending (ASC)'); $this->line(' 2 - Descending (DESC)'); - $sortDirection = $this->ask('Sort direction (1-2)'); - $sortDirection = match ((int)$sortDirection) { + $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Sort field (1-2)", ['required', 'integer', "between:1,2"], 2); + $sortDirection = match ($selected) { 1 => 'ASC', 2 => 'DESC', }; + $pagesize = (int)HydeHelper::askWithValidation($this, 'pagesize', "Enter the pagesize (0 for no limit)", ['required', 'integer', 'between:0,100'], 25); + $this->output->writeln('Choose a canonical name field (the values of this field have to be unique!):'); foreach ($fields as $k => $v) { - $humanCount = $k + 1; - $this->line(" $humanCount: $v[name]"); + $offset = $k + 1; + $this->line(" $offset: $v[name]"); } - $canonicalField = $this->ask("Canonical field: (1-$humanCount)"); - $canonicalField = $fields[((int)$canonicalField) - 1]['name']; + $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Canonical field (1-$offset)", ['required', 'integer', "between:1,$offset"], 1); + $canonicalField = $fields[$selected - 1]['name']; - $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection); + $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection, $pagesize); if (!$creator->create()) { return Command::FAILURE; } @@ -78,23 +87,29 @@ private function getFieldsDefinitions(): Collection $this->output->writeln("Field #$count:"); $field = Collection::create(); - $field->name = $this->ask('Field name'); + $field->name = HydeHelper::askWithValidation($this, 'name', 'Field name', ['required']); $this->line('Field type:'); $this->line(' 1 - String'); - $this->line(' 2 - Integer'); - $this->line(' 3 - Float'); - $this->line(' 4 - Datetime'); - $type = (int)$this->ask('Field type (1-4)'); - $field->min = (int)$this->ask('Min value (for strings, this refers to string length)'); - $field->max = (int)$this->ask('Max value (for strings, this refers to string length)'); - $addAnother = (string)$this->ask('Add another field (y/n)'); + $this->line(' 2 - Boolean '); + $this->line(' 3 - Integer'); + $this->line(' 4 - Float'); + $this->line(' 5 - Datetime'); + $this->line(' 6 - URL'); + $this->line(' 7 - Text'); + $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,7'], 1); + $field->min = HydeHelper::askWithValidation($this, 'min', 'Min value (for strings, this refers to string length)', ['required', 'string'], 0); + $field->max = HydeHelper::askWithValidation($this, 'max', 'Max value (for strings, this refers to string length)', ['required', 'string'], 0); + $addAnother = HydeHelper::askWithValidation($this, 'addAnother', 'Add another field (y/n)', ['required', 'string', "in:y,n"], 'y'); // map field choice to actual field type $field->type = match ($type) { - 0, 1 => 'string', - 2 => 'integer', - 3 => 'float', - 4 => 'datetime', + 1 => 'string', + 2 => 'boolean', + 3 => 'integer', + 4 => 'float', + 5 => 'datetime', + 6 => 'url', + 7 => 'text', }; $fields->add($field); diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 305b42f9941..43727b31688 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -6,8 +6,9 @@ use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; +use Hyde\HydeHelper; use Illuminate\Support\Str; -use Rgasch\Collection; +use Rgasch\Collection\Collection; /** * Scaffold a new Markdown, Blade, or documentation page. @@ -18,30 +19,53 @@ class CreatesNewPublicationFile implements CreateActionInterface { use InteractsWithDirectories; + protected string $result; + public function __construct( protected Collection $pubType, protected Collection $fieldData ) { } - public function create(): string|bool + public function create(): bool { - $dir = dirname($this->pubType->file); + $dir = dirname($this->pubType->schemaFile); @mkdir($dir); - $canonical = Str::camel($this->fieldData[$this->pubType->canonicalField]); - $slug = Str::slug($this->fieldData[$this->pubType->canonicalField]); - $outFile = "$dir/$canonical.md"; + $slug = Str::of($this->fieldData[$this->pubType->canonicalField]) + ->substr(0, 64) + ->slug() + ->toString(); + $fileName = HydeHelper::formatNameForStorage($slug); + $outFile = "$dir/$fileName.md"; + $now = date('Y-m-d H:i:s'); $output = "---\n"; - $output .= "__canonical: {$canonical}\n"; + $output .= "__canonical: {$fileName}\n"; $output .= "__slug: {$slug}\n"; + $output .= "__createdAt: {$now}\n"; foreach ($this->fieldData as $k => $v) { - $output .= "{$k}: {$v}\n"; + $field = $this->pubType->fields->where('name', $k)->first(); + if ($field->type !== 'text') { + $output .= "{$k}: {$v}\n"; + continue; + } + + // Text fields have different syntax + $output .= "{$k}: |\n"; + foreach ($v as $line) { + $output .= " $line\n"; + } } $output .= "---\n"; $output .= "Raw MD text ...\n"; + $this->result = $output; print "Saving page data to [$outFile]\n"; return (bool)file_put_contents($outFile, $output); } + + public function getResult(): string + { + return $this->result; + } } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 4861abe248a..8b9f366449c 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -6,8 +6,8 @@ use Hyde\Framework\Actions\Interfaces\CreateActionInterface; use Hyde\Framework\Concerns\InteractsWithDirectories; -use Illuminate\Support\Str; -use Rgasch\Collection; +use Hyde\HydeHelper; +use Rgasch\Collection\Collection; /** * Scaffold a new Markdown, Blade, or documentation page. @@ -18,31 +18,41 @@ class CreatesNewPublicationTypeSchema implements CreateActionInterface { use InteractsWithDirectories; + protected string $result; + public function __construct( protected string $name, protected Collection $fields, protected string $canonicalField, protected string $sortField, - protected string $sortDirection + protected string $sortDirection, + protected int $pagesize ) { } - public function create(): string|bool + public function create(): bool { - $name = Str::camel($this->name); - @mkdir($name); + $dirName = HydeHelper::formatNameForStorage($this->name); + @mkdir($dirName); $data = []; $data['name'] = $this->name; $data['canonicalField'] = $this->canonicalField; $data['sortField'] = $this->sortField; $data['sortDirection'] = $this->sortDirection; - $data['detailTemplate'] = "{$name}.detail.blade.php"; - $data['listTemplate'] = "{$name}.list.blade.php"; + $data['pagesize'] = $this->pagesize; + $data['detailTemplate'] = "{$dirName}.detail.blade.php"; + $data['listTemplate'] = "{$dirName}.list.blade.php"; $data['fields'] = $this->fields; $json = json_encode($data, JSON_PRETTY_PRINT); + $this->result = $json; + + return (bool)file_put_contents("$dirName/schema.json", $json); + } - return (bool)file_put_contents("$name/schema.json", $json); + public function getResult(): string + { + return $this->result; } } diff --git a/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php index f1fecb0d257..38317bc8e29 100644 --- a/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php +++ b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php @@ -4,5 +4,5 @@ interface CreateActionInterface { - public function create(): string|bool; + public function create(): bool; } \ No newline at end of file diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php new file mode 100644 index 00000000000..67d475212b9 --- /dev/null +++ b/packages/framework/src/HydeHelper.php @@ -0,0 +1,120 @@ +toArray(); + } + + $answer = $command->ask($message, $default); + $factory = app(ValidationFactory::class); + $validator = $factory->make([$name => $answer], [$name => $rules]); + + if ($validator->passes()) { + return $answer; + } + + foreach ($validator->errors()->all() as $error) { + $command->error($error); + } + + return self::askWithValidation($command, $name, $message, $rules); + } + + /** + * Get the available HydeKernel instance. + * + * @return \Hyde\Foundation\HydeKernel + */ + public static function getKernel(): HydeKernel + { + return app(HydeKernel::class); + } + + /** + * Format the publication type name to a suitable representation for file storage + * + * @param string $pubTypeNameRaw + * @return string + */ + public static function formatNameForStorage(string $pubTypeNameRaw) + { + return Str::camel($pubTypeNameRaw); + } + + /** + * Return a collection of all defined publication types, indexed by the + * @return Collection + * @throws \Exception + */ + public static function getPublicationTypes(): Collection + { + $root = base_path(); + $pubTypes = Collection::create(); + $schemaFiles = glob("$root/*/schema.json", GLOB_BRACE); + + foreach ($schemaFiles as $schemaFile) { + $fileData = file_get_contents($schemaFile); + if (!$fileData) { + throw new \Exception("Unable to read schema file [$schemaFile]"); + } + + $schema = Collection::create(json_decode($fileData, true)); + $schema->directory = dirname($schemaFile); + $schema->schemaFile = $schemaFile; + $pubTypes->{$schema->directory} = $schema; + } + + return $pubTypes; + } + + /** + * @param string $pubTypeName + * @param bool $isRaw + * @return bool + * @throws \Exception + */ + public static function publicationTypeExists(string $pubTypeName, bool $isRaw = true): bool + { + if ($isRaw) { + $pubTypeName = self::formatNameForStorage($pubTypeName); + } + + $publicationTypes = self::getPublicationTypes(); + + return self::getPublicationTypes()->has($pubTypeName); + } + + /** + * Remove trailing slashes from the start and end of a string. + * + * @param string $string + * @return string + */ + public static function unslash(string $string): string + { + return trim($string, '/\\'); + } +} From 82bf5f1301ec933fbc92a6326663099f69863541 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 14:54:06 +0100 Subject: [PATCH 10/31] Remove leftover dump() --- .../framework/src/Console/Commands/MakePublicationCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index f390b847215..5001b185914 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -89,7 +89,6 @@ public function handle(): int } } } - dump($fieldRules); $fieldData->{$field->name} = HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules); } From e0e9a55a515852deaa475de31b358ca45eccb74f Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 15:38:56 +0100 Subject: [PATCH 11/31] Print proper error message rather than throwing an exception --- .../src/Console/Commands/MakePublicationCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index 5001b185914..0e35ca82cba 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -30,8 +30,13 @@ public function handle(): int { $this->title('Creating a new Publication Item!'); - $pubType = $this->argument('publicationType'); $pubTypes = HydeHelper::getPublicationTypes(); + if ($pubTypes->isEmpty()) { + $this->output->error("Unable to locate any publication-types ... did you create any?"); + return Command::FAILURE; + } + + $pubType = $this->argument('publicationType'); if (!$pubType) { $this->output->writeln('Now please choose the Publication Type to create an item for:'); $offset = 0; From f3cfd530b868cf1db27db7b0047a8b919773aa6c Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 15:43:29 +0100 Subject: [PATCH 12/31] Added validation for reversed/invalid field lengths --- .../Console/Commands/MakePublicationTypeCommand.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 462c8b986c2..00115fe4a65 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -96,9 +96,16 @@ private function getFieldsDefinitions(): Collection $this->line(' 5 - Datetime'); $this->line(' 6 - URL'); $this->line(' 7 - Text'); - $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,7'], 1); - $field->min = HydeHelper::askWithValidation($this, 'min', 'Min value (for strings, this refers to string length)', ['required', 'string'], 0); - $field->max = HydeHelper::askWithValidation($this, 'max', 'Max value (for strings, this refers to string length)', ['required', 'string'], 0); + $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,7'], 1); + do { + $field->min = HydeHelper::askWithValidation($this, 'min', 'Min value (for strings, this refers to string length)', ['required', 'string'], 0); + $field->max = HydeHelper::askWithValidation($this, 'max', 'Max value (for strings, this refers to string length)', ['required', 'string'], 0); + $lengthsValid = true; + if ($field->max < $field->min) { + $lengthsValid = false; + $this->output->warning("Field length [max] must be [>=] than [min]"); + } + } while (!$lengthsValid); $addAnother = HydeHelper::askWithValidation($this, 'addAnother', 'Add another field (y/n)', ['required', 'string', "in:y,n"], 'y'); // map field choice to actual field type From 208ec48d6343a04846ee7f7c09975084510447d9 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 15:54:18 +0100 Subject: [PATCH 13/31] Minor code cleaup/standardization --- .../Framework/Actions/CreatesNewPublicationFile.php | 11 ++++------- .../Actions/CreatesNewPublicationTypeSchema.php | 5 ++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 43727b31688..9905c7e1734 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -29,12 +29,8 @@ public function __construct( public function create(): bool { - $dir = dirname($this->pubType->schemaFile); - @mkdir($dir); - $slug = Str::of($this->fieldData[$this->pubType->canonicalField]) - ->substr(0, 64) - ->slug() - ->toString(); + $dir = dirname($this->pubType->schemaFile); + $slug = Str::of($this->fieldData[$this->pubType->canonicalField])->substr(0, 64)->slug()->toString(); $fileName = HydeHelper::formatNameForStorage($slug); $outFile = "$dir/$fileName.md"; @@ -60,7 +56,8 @@ public function create(): bool $output .= "Raw MD text ...\n"; $this->result = $output; - print "Saving page data to [$outFile]\n"; + print "Saving publication data to [$outFile]\n"; + return (bool)file_put_contents($outFile, $output); } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 8b9f366449c..a53b3f61a97 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -34,6 +34,7 @@ public function __construct( public function create(): bool { $dirName = HydeHelper::formatNameForStorage($this->name); + $outFile = "$dirName/schema.json"; @mkdir($dirName); $data = []; @@ -48,7 +49,9 @@ public function create(): bool $json = json_encode($data, JSON_PRETTY_PRINT); $this->result = $json; - return (bool)file_put_contents("$dirName/schema.json", $json); + print "Saving publicationType data to [$outFile]\n"; + + return (bool)file_put_contents($outFile, $json); } public function getResult(): string From de473af984358c0116812fbdeae6ca678c55d2a6 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 18:05:45 +0100 Subject: [PATCH 14/31] Adding phpstan.neon file --- phpstan.neon | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000000..01679b5aadc --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,9 @@ +parameters: + level: 6 + paths: + - packages + - tests + +includes: + - vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon + From ca5b2fcfc839a47f3e1e9544906a7f8df1cf3e0a Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 18:05:59 +0100 Subject: [PATCH 15/31] Adding safephp library --- composer.json | 6 +- composer.lock | 198 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 201 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index b3c9012545f..6a855cc93ee 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,10 @@ "require": { "php": "^8.1", "hyde/framework": "dev-master", - "laravel-zero/framework": "^9.1", "illuminate/validation": "^9.0.0", - "rgasch/illuminate-collection-extended": "^1.0" + "laravel-zero/framework": "^9.1", + "rgasch/illuminate-collection-extended": "^1.0", + "thecodingmachine/safe": "^2.4" }, "require-dev": { "driftingly/rector-laravel": "^0.14.0", @@ -35,6 +36,7 @@ "phpstan/phpstan": "^1.8", "rector/rector": "^0.14.6", "squizlabs/php_codesniffer": "^3.7", + "thecodingmachine/phpstan-safe-rule": "^1.2", "vimeo/psalm": "^4.24" }, "autoload": { diff --git a/composer.lock b/composer.lock index 3b94a3362b3..66794ed2645 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4cda7afa468b8dbfe0ad2f7c388c8be8", + "content-hash": "05f4ea5218839f90bfacbc74d44350df", "packages": [ { "name": "brick/math", @@ -5937,6 +5937,145 @@ ], "time": "2022-10-07T08:04:03+00:00" }, + { + "name": "thecodingmachine/safe", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/safe.git", + "reference": "e788f3d09dcd36f806350aedb77eac348fafadd3" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/thecodingmachine/safe/zipball/e788f3d09dcd36f806350aedb77eac348fafadd3", + "reference": "e788f3d09dcd36f806350aedb77eac348fafadd3", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.5", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.2", + "thecodingmachine/phpstan-strict-rules": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "files": [ + "deprecated/apc.php", + "deprecated/array.php", + "deprecated/datetime.php", + "deprecated/libevent.php", + "deprecated/misc.php", + "deprecated/password.php", + "deprecated/mssql.php", + "deprecated/stats.php", + "deprecated/strings.php", + "lib/special_cases.php", + "deprecated/mysqli.php", + "generated/apache.php", + "generated/apcu.php", + "generated/array.php", + "generated/bzip2.php", + "generated/calendar.php", + "generated/classobj.php", + "generated/com.php", + "generated/cubrid.php", + "generated/curl.php", + "generated/datetime.php", + "generated/dir.php", + "generated/eio.php", + "generated/errorfunc.php", + "generated/exec.php", + "generated/fileinfo.php", + "generated/filesystem.php", + "generated/filter.php", + "generated/fpm.php", + "generated/ftp.php", + "generated/funchand.php", + "generated/gettext.php", + "generated/gmp.php", + "generated/gnupg.php", + "generated/hash.php", + "generated/ibase.php", + "generated/ibmDb2.php", + "generated/iconv.php", + "generated/image.php", + "generated/imap.php", + "generated/info.php", + "generated/inotify.php", + "generated/json.php", + "generated/ldap.php", + "generated/libxml.php", + "generated/lzf.php", + "generated/mailparse.php", + "generated/mbstring.php", + "generated/misc.php", + "generated/mysql.php", + "generated/network.php", + "generated/oci8.php", + "generated/opcache.php", + "generated/openssl.php", + "generated/outcontrol.php", + "generated/pcntl.php", + "generated/pcre.php", + "generated/pgsql.php", + "generated/posix.php", + "generated/ps.php", + "generated/pspell.php", + "generated/readline.php", + "generated/rpminfo.php", + "generated/rrd.php", + "generated/sem.php", + "generated/session.php", + "generated/shmop.php", + "generated/sockets.php", + "generated/sodium.php", + "generated/solr.php", + "generated/spl.php", + "generated/sqlsrv.php", + "generated/ssdeep.php", + "generated/ssh2.php", + "generated/stream.php", + "generated/strings.php", + "generated/swoole.php", + "generated/uodbc.php", + "generated/uopz.php", + "generated/url.php", + "generated/var.php", + "generated/xdiff.php", + "generated/xml.php", + "generated/xmlrpc.php", + "generated/yaml.php", + "generated/yaz.php", + "generated/zip.php", + "generated/zlib.php" + ], + "classmap": [ + "lib/DateTime.php", + "lib/DateTimeImmutable.php", + "lib/Exceptions/", + "deprecated/Exceptions/", + "generated/Exceptions/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHP core functions that throw exceptions instead of returning FALSE on error", + "support": { + "issues": "https://github.com/thecodingmachine/safe/issues", + "source": "https://github.com/thecodingmachine/safe/tree/v2.4.0" + }, + "time": "2022-10-07T14:02:17+00:00" + }, { "name": "torchlight/torchlight-commonmark", "version": "v0.5.5", @@ -9823,6 +9962,63 @@ }, "time": "2022-06-18T07:21:10+00:00" }, + { + "name": "thecodingmachine/phpstan-safe-rule", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/phpstan-safe-rule.git", + "reference": "8a7b88e0d54f209a488095085f183e9174c40e1e" + }, + "dist": { + "type": "zip", + "url": "https://github.com/gitapi/repos/thecodingmachine/phpstan-safe-rule/zipball/8a7b88e0d54f209a488095085f183e9174c40e1e", + "reference": "8a7b88e0d54f209a488095085f183e9174c40e1e", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "phpstan/phpstan": "^1.0", + "thecodingmachine/safe": "^1.0 || ^2.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^7.5.2 || ^8.0", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + }, + "phpstan": { + "includes": [ + "phpstan-safe-rule.neon" + ] + } + }, + "autoload": { + "psr-4": { + "TheCodingMachine\\Safe\\PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Négrier", + "email": "d.negrier@thecodingmachine.com" + } + ], + "description": "A PHPStan rule to detect safety issues. Must be used in conjunction with thecodingmachine/safe", + "support": { + "issues": "https://github.com/thecodingmachine/phpstan-safe-rule/issues", + "source": "https://github.com/thecodingmachine/phpstan-safe-rule/tree/v1.2.0" + }, + "time": "2022-01-17T10:12:29+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", From e1f10780f4e007473cb9b2d44c722b146df653c3 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 9 Nov 2022 18:07:02 +0100 Subject: [PATCH 16/31] Adoping safephp library + assorted cleanups. --- .../src/Console/Commands/MakePublicationCommand.php | 9 ++++++--- .../Console/Commands/MakePublicationTypeCommand.php | 7 +++++-- .../Framework/Actions/CreatesNewPublicationFile.php | 7 +++++-- .../Actions/CreatesNewPublicationTypeSchema.php | 10 +++++++--- .../Actions/Interfaces/CreateActionInterface.php | 2 +- packages/framework/src/HydeHelper.php | 6 +++--- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index 0e35ca82cba..de80ed0561c 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -40,7 +40,7 @@ public function handle(): int if (!$pubType) { $this->output->writeln('Now please choose the Publication Type to create an item for:'); $offset = 0; - foreach ($pubTypes as $k => $pubType) { + foreach ($pubTypes as $pubType) { $offset++; $this->line(" $offset: $pubType->name"); } @@ -97,8 +97,11 @@ public function handle(): int $fieldData->{$field->name} = HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules); } - $creator = new CreatesNewPublicationFile($pubType, $fieldData); - if (!$creator->create()) { + try { + $creator = new CreatesNewPublicationFile($pubType, $fieldData); + $creator->create(); + } catch (\Exception $e) { + $this->error("Error: " . $e->getMessage() . " at " . $e->getFile() . ':' . $e->getLine()); return Command::FAILURE; } diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 00115fe4a65..b6e14af3199 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -68,8 +68,11 @@ public function handle(): int $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Canonical field (1-$offset)", ['required', 'integer', "between:1,$offset"], 1); $canonicalField = $fields[$selected - 1]['name']; - $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection, $pagesize); - if (!$creator->create()) { + try { + $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection, $pagesize); + $creator->create(); + } catch (\Exception $e) { + $this->error("Error: " . $e->getMessage() . " at " . $e->getFile() . ':' . $e->getLine()); return Command::FAILURE; } diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 9905c7e1734..9a060b8f4c2 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -10,6 +10,9 @@ use Illuminate\Support\Str; use Rgasch\Collection\Collection; +use function Safe\date; +use function Safe\file_put_contents; + /** * Scaffold a new Markdown, Blade, or documentation page. * @@ -27,7 +30,7 @@ public function __construct( ) { } - public function create(): bool + public function create(): void { $dir = dirname($this->pubType->schemaFile); $slug = Str::of($this->fieldData[$this->pubType->canonicalField])->substr(0, 64)->slug()->toString(); @@ -58,7 +61,7 @@ public function create(): bool $this->result = $output; print "Saving publication data to [$outFile]\n"; - return (bool)file_put_contents($outFile, $output); + file_put_contents($outFile, $output); } public function getResult(): string diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index a53b3f61a97..9c4de719620 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -9,6 +9,10 @@ use Hyde\HydeHelper; use Rgasch\Collection\Collection; +use function Safe\file_put_contents; +use function Safe\json_encode; +use function Safe\mkdir; + /** * Scaffold a new Markdown, Blade, or documentation page. * @@ -31,11 +35,11 @@ public function __construct( } - public function create(): bool + public function create(): void { $dirName = HydeHelper::formatNameForStorage($this->name); $outFile = "$dirName/schema.json"; - @mkdir($dirName); + mkdir($dirName); $data = []; $data['name'] = $this->name; @@ -51,7 +55,7 @@ public function create(): bool print "Saving publicationType data to [$outFile]\n"; - return (bool)file_put_contents($outFile, $json); + file_put_contents($outFile, $json); } public function getResult(): string diff --git a/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php index 38317bc8e29..1ff4f524e93 100644 --- a/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php +++ b/packages/framework/src/Framework/Actions/Interfaces/CreateActionInterface.php @@ -4,5 +4,5 @@ interface CreateActionInterface { - public function create(): bool; + public function create(): void; } \ No newline at end of file diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index 67d475212b9..ef3d68868bc 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -10,6 +10,8 @@ use LaravelZero\Framework\Commands\Command; use Rgasch\Collection\Collection; +use function Safe\file_get_contents; + class HydeHelper { /** @@ -78,7 +80,7 @@ public static function getPublicationTypes(): Collection foreach ($schemaFiles as $schemaFile) { $fileData = file_get_contents($schemaFile); if (!$fileData) { - throw new \Exception("Unable to read schema file [$schemaFile]"); + throw new \Exception("No data read from [$schemaFile]"); } $schema = Collection::create(json_decode($fileData, true)); @@ -102,8 +104,6 @@ public static function publicationTypeExists(string $pubTypeName, bool $isRaw = $pubTypeName = self::formatNameForStorage($pubTypeName); } - $publicationTypes = self::getPublicationTypes(); - return self::getPublicationTypes()->has($pubTypeName); } From c7a0bec6901007bd403b2d27cdcce143605ffce5 Mon Sep 17 00:00:00 2001 From: rgasch Date: Thu, 10 Nov 2022 19:38:55 +0100 Subject: [PATCH 17/31] Added getPublications() method. --- packages/framework/src/HydeHelper.php | 43 +++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index ef3d68868bc..a6709171d5e 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -9,6 +9,7 @@ use Illuminate\Support\Str; use LaravelZero\Framework\Commands\Command; use Rgasch\Collection\Collection; +use Spatie\YamlFrontMatter\YamlFrontMatter; use function Safe\file_get_contents; @@ -67,16 +68,17 @@ public static function formatNameForStorage(string $pubTypeNameRaw) } /** - * Return a collection of all defined publication types, indexed by the + * Return a collection of all defined publication types, indexed by the directory name. + * * @return Collection * @throws \Exception */ public static function getPublicationTypes(): Collection { $root = base_path(); - $pubTypes = Collection::create(); $schemaFiles = glob("$root/*/schema.json", GLOB_BRACE); + $pubTypes = Collection::create(); foreach ($schemaFiles as $schemaFile) { $fileData = file_get_contents($schemaFile); if (!$fileData) { @@ -93,6 +95,43 @@ public static function getPublicationTypes(): Collection } /** + * Return all publications for a given pub type, optionally sorted by the publication's sortField. + * + * @param Collection $pubType + * @return Collection + * @throws \Safe\Exceptions\FilesystemException + */ + public static function getPublications(Collection $pubType, $sort = true): Collection + { + $root = base_path(); + $mdFiles = glob("$root/{$pubType->directory}/*.md"); + + $publications = Collection::create(); + foreach ($mdFiles as $mdFile) { + $fileData = file_get_contents($mdFile); + if (!$fileData) { + throw new \Exception("No data read from [$mdFile]"); + } + + $publication = Collection::create(); + $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); + $publication->matter = $parsedFileData->matter(); + $publication->markdown = $parsedFileData->body(); + $publications->add($publication); + } + + if ($sort) { + return $publications->sortBy(function ($publication) use ($pubType) { + return $publication->matter->{$pubType->sortField}; + }); + } + + return $publications; + } + + /** + * Check whether a given publication type exists. + * * @param string $pubTypeName * @param bool $isRaw * @return bool From 0dbec9eaf80f084773544a3f7043848cdb88f8a7 Mon Sep 17 00:00:00 2001 From: rgasch Date: Thu, 10 Nov 2022 19:39:31 +0100 Subject: [PATCH 18/31] Cleanup --- .../Commands/MakePublicationTypeCommand.php | 17 +++++++++++++++-- .../Actions/CreatesNewPublicationTypeSchema.php | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index b6e14af3199..a4a8d87bfae 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -58,7 +58,20 @@ public function handle(): int 2 => 'DESC', }; - $pagesize = (int)HydeHelper::askWithValidation($this, 'pagesize', "Enter the pagesize (0 for no limit)", ['required', 'integer', 'between:0,100'], 25); + $pagesize = (int)HydeHelper::askWithValidation( + $this, + 'pagesize', + "Enter the pagesize (0 for no limit)", + ['required', 'integer', 'between:0,100'], + 25 + ); + $prevNextLinks = HydeHelper::askWithValidation( + $this, + 'prevNextLinks', + 'Generate previous/next links in detail view (y/n)', + ['required', 'string', "in:y,n"], + 'y' + ); $this->output->writeln('Choose a canonical name field (the values of this field have to be unique!):'); foreach ($fields as $k => $v) { @@ -69,7 +82,7 @@ public function handle(): int $canonicalField = $fields[$selected - 1]['name']; try { - $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection, $pagesize); + $creator = new CreatesNewPublicationTypeSchema($title, $fields, $canonicalField, $sortField, $sortDirection, $pagesize, $prevNextLinks); $creator->create(); } catch (\Exception $e) { $this->error("Error: " . $e->getMessage() . " at " . $e->getFile() . ':' . $e->getLine()); diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 9c4de719620..32329e6821c 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -30,7 +30,8 @@ public function __construct( protected string $canonicalField, protected string $sortField, protected string $sortDirection, - protected int $pagesize + protected int $pagesize, + protected bool $prevNextLinks ) { } @@ -47,6 +48,7 @@ public function create(): void $data['sortField'] = $this->sortField; $data['sortDirection'] = $this->sortDirection; $data['pagesize'] = $this->pagesize; + $data['prevNextLinks'] = $this->prevNextLinks; $data['detailTemplate'] = "{$dirName}.detail.blade.php"; $data['listTemplate'] = "{$dirName}.list.blade.php"; $data['fields'] = $this->fields; From ff042f7aeb1b197b38cbffe829a647086185375f Mon Sep 17 00:00:00 2001 From: rgasch Date: Mon, 14 Nov 2022 22:31:17 +0100 Subject: [PATCH 19/31] Remove slug --- .../src/Framework/Actions/CreatesNewPublicationFile.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 9a060b8f4c2..4795b40e68b 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -40,7 +40,6 @@ public function create(): void $now = date('Y-m-d H:i:s'); $output = "---\n"; $output .= "__canonical: {$fileName}\n"; - $output .= "__slug: {$slug}\n"; $output .= "__createdAt: {$now}\n"; foreach ($this->fieldData as $k => $v) { $field = $this->pubType->fields->where('name', $k)->first(); From 7fa8839fb4b51a3f768a1fe2e07c1af9c4b09b56 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 12:41:44 +0100 Subject: [PATCH 20/31] Added overwrite check/protection for existing files. --- .../Actions/CreatesNewPublicationFile.php | 6 +++- packages/framework/src/HydeHelper.php | 35 +++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index 4795b40e68b..e4ee7dd77af 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -26,7 +26,8 @@ class CreatesNewPublicationFile implements CreateActionInterface public function __construct( protected Collection $pubType, - protected Collection $fieldData + protected Collection $fieldData, + protected bool $force = false ) { } @@ -36,6 +37,9 @@ public function create(): void $slug = Str::of($this->fieldData[$this->pubType->canonicalField])->substr(0, 64)->slug()->toString(); $fileName = HydeHelper::formatNameForStorage($slug); $outFile = "$dir/$fileName.md"; + if (file_exists($outFile) && !$this->force) { + throw new \InvalidArgumentException("File [$outFile] already exists"); + } $now = date('Y-m-d H:i:s'); $output = "---\n"; diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index a6709171d5e..b4346f6e88c 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -101,23 +101,14 @@ public static function getPublicationTypes(): Collection * @return Collection * @throws \Safe\Exceptions\FilesystemException */ - public static function getPublications(Collection $pubType, $sort = true): Collection + public static function getPublicationsForPubType(Collection $pubType, $sort = true): Collection { $root = base_path(); $mdFiles = glob("$root/{$pubType->directory}/*.md"); $publications = Collection::create(); foreach ($mdFiles as $mdFile) { - $fileData = file_get_contents($mdFile); - if (!$fileData) { - throw new \Exception("No data read from [$mdFile]"); - } - - $publication = Collection::create(); - $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); - $publication->matter = $parsedFileData->matter(); - $publication->markdown = $parsedFileData->body(); - $publications->add($publication); + $publications->add(self::getPublicationData($mdFile)); } if ($sort) { @@ -129,6 +120,28 @@ public static function getPublications(Collection $pubType, $sort = true): Colle return $publications; } + + /** + * Read an MD file and return the parsed data. + * + * @param string $fileData + * @return Collection + */ + public static function getPublicationData(string $mdFileName): Collection + { + $fileData = file_get_contents($mdFileName); + if (!$fileData) { + throw new \Exception("No data read from [$mdFileName]"); + } + + $publication = Collection::create(); + $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); + $publication->matter = $parsedFileData->matter(); + $publication->markdown = $parsedFileData->body(); + + return $publication; + } + /** * Check whether a given publication type exists. * From 606dc95f1a23df158b90246ca14acf260bc9d854 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 12:43:19 +0100 Subject: [PATCH 21/31] Added overwrite check/protection for existing files in handler code --- .../Console/Commands/MakePublicationCommand.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index de80ed0561c..ebbeae348f8 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -100,6 +100,21 @@ public function handle(): int try { $creator = new CreatesNewPublicationFile($pubType, $fieldData); $creator->create(); + } catch (\InvalidArgumentException $e) { + $this->output->writeln('A file for this set of data already exists!'); + $overwrite = HydeHelper::askWithValidation( + $this, + 'overwrite', + 'Do you wish to overwrite the existing file (y/n)', + ['required', 'string', "in:y,n"], + 'n' + ); + if (strtolower($overwrite) == 'y') { + $creator = new CreatesNewPublicationFile($pubType, $fieldData, true); + $creator->create(); + } else { + $this->output->writeln('Existing without overwriting existing publication file!'); + } } catch (\Exception $e) { $this->error("Error: " . $e->getMessage() . " at " . $e->getFile() . ':' . $e->getLine()); return Command::FAILURE; From 91ae9e823fb381fe1d7b5ca97ebda3a980a2d456 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 12:44:06 +0100 Subject: [PATCH 22/31] Better hint text + fixed bool/string type error on next/prev links question. --- .../src/Console/Commands/MakePublicationTypeCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index a4a8d87bfae..87a54a62d6b 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -50,8 +50,8 @@ public function handle(): int $sortField = $selected ? $fields[$selected - 1]['name'] : '__createdAt'; $this->output->writeln('Choose the default sort direction:'); - $this->line(' 1 - Ascending (ASC)'); - $this->line(' 2 - Descending (DESC)'); + $this->line(' 1 - Ascending (oldest items first if sorting by dateCreated)'); + $this->line(' 2 - Descending (newest items first if sorting by dateCreated)'); $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Sort field (1-2)", ['required', 'integer', "between:1,2"], 2); $sortDirection = match ($selected) { 1 => 'ASC', @@ -65,7 +65,7 @@ public function handle(): int ['required', 'integer', 'between:0,100'], 25 ); - $prevNextLinks = HydeHelper::askWithValidation( + $prevNextLinks = (bool)HydeHelper::askWithValidation( $this, 'prevNextLinks', 'Generate previous/next links in detail view (y/n)', From ac4e5bef111093641e9cb82b7fcd2019665186e1 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 14:09:14 +0100 Subject: [PATCH 23/31] Use underscore template names to avoid dot confusion --- .../src/Framework/Actions/CreatesNewPublicationTypeSchema.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index 32329e6821c..b55ff06943a 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -49,8 +49,8 @@ public function create(): void $data['sortDirection'] = $this->sortDirection; $data['pagesize'] = $this->pagesize; $data['prevNextLinks'] = $this->prevNextLinks; - $data['detailTemplate'] = "{$dirName}.detail.blade.php"; - $data['listTemplate'] = "{$dirName}.list.blade.php"; + $data['detailTemplate'] = "{$dirName}_detail.blade.php"; + $data['listTemplate'] = "{$dirName}_list.blade.php"; $data['fields'] = $this->fields; $json = json_encode($data, JSON_PRETTY_PRINT); $this->result = $json; From 349c3b0ad0b5b4ba3ca0851d2c782a2e546bf16b Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 14:10:21 +0100 Subject: [PATCH 24/31] Use relative directory name for publication type index + use proper 'matter' + 'markdown' sub-indexes when returning content. --- packages/framework/src/HydeHelper.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index b4346f6e88c..2318d3e1877 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -84,9 +84,9 @@ public static function getPublicationTypes(): Collection if (!$fileData) { throw new \Exception("No data read from [$schemaFile]"); } - + $dirName = Collection::create(explode('/', dirname($schemaFile)))->last(); $schema = Collection::create(json_decode($fileData, true)); - $schema->directory = dirname($schemaFile); + $schema->directory = $dirName; $schema->schemaFile = $schemaFile; $pubTypes->{$schema->directory} = $schema; } @@ -134,12 +134,11 @@ public static function getPublicationData(string $mdFileName): Collection throw new \Exception("No data read from [$mdFileName]"); } - $publication = Collection::create(); - $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); - $publication->matter = $parsedFileData->matter(); - $publication->markdown = $parsedFileData->body(); + $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); + $matter = $parsedFileData->matter(); + $markdown = $parsedFileData->body(); - return $publication; + return Collection::create(['matter' => $matter, 'markdown' => $markdown]); } /** From 81e8b04a62b2a8fc4175725b3bc14d76c7d31b73 Mon Sep 17 00:00:00 2001 From: rgasch Date: Wed, 16 Nov 2022 22:58:06 +0100 Subject: [PATCH 25/31] Syncing up changes for BuildPublicationTypesSiteCommand + related changes (includes "blah" publication type) --- blah/123.md | 8 + blah/aaa.md | 8 + blah/abc.md | 8 + blah/schema.json | 30 +++ .../resources/views/layouts/pubtype.blade.php | 9 + .../views/pubtypes/blah_detail.blade.php | 1 + .../views/pubtypes/blah_list.blade.php | 1 + .../BuildPublicationTypesSiteCommand.php | 195 ++++++++++++++++++ .../Commands/MakePublicationCommand.php | 2 +- .../Console/HydeConsoleServiceProvider.php | 1 + .../CreatesNewPublicationTypeSchema.php | 4 +- 11 files changed, 264 insertions(+), 3 deletions(-) create mode 100644 blah/123.md create mode 100644 blah/aaa.md create mode 100644 blah/abc.md create mode 100644 blah/schema.json create mode 100644 packages/framework/resources/views/layouts/pubtype.blade.php create mode 100644 packages/framework/resources/views/pubtypes/blah_detail.blade.php create mode 100644 packages/framework/resources/views/pubtypes/blah_list.blade.php create mode 100644 packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php diff --git a/blah/123.md b/blah/123.md new file mode 100644 index 00000000000..c1f19b8ab37 --- /dev/null +++ b/blah/123.md @@ -0,0 +1,8 @@ +--- +__canonical: 123 +__createdAt: 2022-11-16 11:32:52 +f1: 123 +f2: 456 +f3: 789 +--- +Raw MD text ... diff --git a/blah/aaa.md b/blah/aaa.md new file mode 100644 index 00000000000..b098ae172e8 --- /dev/null +++ b/blah/aaa.md @@ -0,0 +1,8 @@ +--- +__canonical: aaa +__createdAt: 2022-11-16 11:33:05 +f1: aaa +f2: bbb +f3: ccc +--- +Raw MD text ... diff --git a/blah/abc.md b/blah/abc.md new file mode 100644 index 00000000000..2391eba6522 --- /dev/null +++ b/blah/abc.md @@ -0,0 +1,8 @@ +--- +__canonical: abc +__createdAt: 2022-11-16 11:32:36 +f1: abc +f2: def +f3: ghi +--- +Raw MD text ... diff --git a/blah/schema.json b/blah/schema.json new file mode 100644 index 00000000000..1deae36440d --- /dev/null +++ b/blah/schema.json @@ -0,0 +1,30 @@ +{ + "name": "blah", + "canonicalField": "f1", + "sortField": "__createdAt", + "sortDirection": "DESC", + "pagesize": 0, + "prevNextLinks": true, + "detailTemplate": "blah_detail.blade.php", + "listTemplate": "blah_list.blade.php", + "fields": [ + { + "name": "f1", + "min": "0", + "max": "0", + "type": "string" + }, + { + "name": "f2", + "min": "0", + "max": "0", + "type": "string" + }, + { + "name": "f3", + "min": "0", + "max": "0", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/packages/framework/resources/views/layouts/pubtype.blade.php b/packages/framework/resources/views/layouts/pubtype.blade.php new file mode 100644 index 00000000000..534de34c468 --- /dev/null +++ b/packages/framework/resources/views/layouts/pubtype.blade.php @@ -0,0 +1,9 @@ +{{-- The Post Page Layout --}} +@extends('hyde::layouts.app') +@section('content') + +
+ +
+ +@endsection \ No newline at end of file diff --git a/packages/framework/resources/views/pubtypes/blah_detail.blade.php b/packages/framework/resources/views/pubtypes/blah_detail.blade.php new file mode 100644 index 00000000000..eb16077ef12 --- /dev/null +++ b/packages/framework/resources/views/pubtypes/blah_detail.blade.php @@ -0,0 +1 @@ +It works DETAIL!!!! diff --git a/packages/framework/resources/views/pubtypes/blah_list.blade.php b/packages/framework/resources/views/pubtypes/blah_list.blade.php new file mode 100644 index 00000000000..e8a2a3d418c --- /dev/null +++ b/packages/framework/resources/views/pubtypes/blah_list.blade.php @@ -0,0 +1 @@ +It works LIST!!!! diff --git a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php new file mode 100644 index 00000000000..4b1fb923d79 --- /dev/null +++ b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php @@ -0,0 +1,195 @@ +title('Building your static site!'); + + $this->service = new BuildService($this->output); + + $this->runPreBuildActions(); + + $this->service->cleanOutputDirectory(); + + $this->service->transferMediaAssets(); + + // FIXME: refactor + $this->build(); + + $this->runPostBuildActions(); + + $this->printFinishMessage($time_start); + + return Command::SUCCESS; + } + + // Warning: This is extremely hacky ... + protected function build(): void + { + $pubTypes = HydeHelper::getPublicationTypes(); + //dump($pubTypes); + foreach ($pubTypes as $dir => $pubType) { + $targetDirectory = "_site/$dir"; + @mkdir($targetDirectory); + $publications = HydeHelper::getPublicationsForPubType($pubType); + $this->info("Building [$pubType->name] into [$targetDirectory] ..."); + $this->buildDetailPages($targetDirectory, $pubType, $publications); + $this->buildListPage($targetDirectory, $pubType, $publications); + } + } + + protected function buildDetailPages(string $targetDirectory, Collection $pubType, Collection $publications): void + { + $detailTemplate = "hyde::pubtypes.{$pubType->detailTemplate}"; + foreach ($publications as $publication) { + $canonical = $publication->matter->__canonical; + $this->info(" Building [$canonical] ..."); + $html = view('hyde::layouts.pubtype')->with(['component' => $detailTemplate, 'publication' => $publication])->render(); + file_put_contents("$targetDirectory/$publication->slug.html", $html); + } + } + + protected function buildListPage(string $targetDirectory, Collection $pubType, Collection $publications): void + { + $this->info(" Building list page ..."); + $listTemplate = $pubType->listTemplate; + $html = view($listTemplate)->with('publications', $publications)->render(); + file_put_contents("$targetDirectory/index.html", $html); + } + + protected function runPreBuildActions(): void + { + if ($this->option('no-api')) { + $this->info('Disabling external API calls'); + $this->newLine(); + $config = config('hyde.features'); + unset($config[array_search('torchlight', $config)]); + Config::set(['hyde.features' => $config]); + } + + if ($this->option('pretty-urls')) { + $this->info('Generating site with pretty URLs'); + $this->newLine(); + Config::set(['site.pretty_urls' => true]); + } + } + + public function runPostBuildActions(): void + { + $service = new BuildTaskService($this->output); + + if ($this->option('run-prettier')) { + $this->runNodeCommand( + 'npx prettier ' . Hyde::pathToRelative(Hyde::sitePath()) . '/**/*.html --write --bracket-same-line', + 'Prettifying code!', + 'prettify code' + ); + } + + if ($this->option('run-dev')) { + $this->runNodeCommand('npm run dev', 'Building frontend assets for development!'); + } + + if ($this->option('run-prod')) { + $this->runNodeCommand('npm run prod', 'Building frontend assets for production!'); + } + + $service->runIf(GenerateSitemap::class, $this->canGenerateSitemap()); + $service->runIf(GenerateRssFeed::class, $this->canGenerateFeed()); + $service->runIf(GenerateSearch::class, $this->canGenerateSearch()); + + $service->runPostBuildTasks(); + } + + protected function printFinishMessage(float $time_start): void + { + $execution_time = (microtime(true) - $time_start); + $this->info( + sprintf( + 'All done! Finished in %s seconds. (%sms)', + number_format($execution_time, 2), + number_format($execution_time * 1000, 2) + ) + ); + + $this->info('Congratulations! 🎉 Your static site has been built!'); + $this->line( + 'Your new homepage is stored here -> ' . + DiscoveryService::createClickableFilepath(Hyde::sitePath('index.html')) + ); + } + + protected function runNodeCommand(string $command, string $message, ?string $actionMessage = null): void + { + $this->info($message . ' This may take a second.'); + + $output = shell_exec( + sprintf( + '%s%s', + app()->environment() === 'testing' ? 'echo ' : '', + $command + ) + ); + + $this->line( + $output ?? sprintf( + 'Could not %s! Is NPM installed?', + $actionMessage ?? 'run script' + ) + ); + } + + protected function canGenerateSitemap(): bool + { + return Features::sitemap(); + } + + protected function canGenerateFeed(): bool + { + return Features::rss(); + } + + protected function canGenerateSearch(): bool + { + return Features::hasDocumentationSearch(); + } +} diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index ebbeae348f8..a9f803c1d3f 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -100,7 +100,7 @@ public function handle(): int try { $creator = new CreatesNewPublicationFile($pubType, $fieldData); $creator->create(); - } catch (\InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { // FIXME: provide a properly typed exception $this->output->writeln('A file for this set of data already exists!'); $overwrite = HydeHelper::askWithValidation( $this, diff --git a/packages/framework/src/Console/HydeConsoleServiceProvider.php b/packages/framework/src/Console/HydeConsoleServiceProvider.php index 2a34d84405f..985346481b4 100644 --- a/packages/framework/src/Console/HydeConsoleServiceProvider.php +++ b/packages/framework/src/Console/HydeConsoleServiceProvider.php @@ -18,6 +18,7 @@ public function register(): void { $this->commands( [ + Commands\BuildPublicationTypesSiteCommand::class, Commands\BuildRssFeedCommand::class, Commands\BuildSearchCommand::class, Commands\BuildSiteCommand::class, diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php index b55ff06943a..9d6ff4bdc3f 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationTypeSchema.php @@ -49,8 +49,8 @@ public function create(): void $data['sortDirection'] = $this->sortDirection; $data['pagesize'] = $this->pagesize; $data['prevNextLinks'] = $this->prevNextLinks; - $data['detailTemplate'] = "{$dirName}_detail.blade.php"; - $data['listTemplate'] = "{$dirName}_list.blade.php"; + $data['detailTemplate'] = "{$dirName}_detail"; + $data['listTemplate'] = "{$dirName}_list"; $data['fields'] = $this->fields; $json = json_encode($data, JSON_PRETTY_PRINT); $this->result = $json; From 0ef10bf36f43e004e0a35ece6f6b011b8c349165 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 17 Nov 2022 12:55:20 +0100 Subject: [PATCH 26/31] Fix dynamic Blade includes --- packages/framework/resources/views/layouts/pubtype.blade.php | 2 +- .../src/Console/Commands/BuildPublicationTypesSiteCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/resources/views/layouts/pubtype.blade.php b/packages/framework/resources/views/layouts/pubtype.blade.php index 534de34c468..08f49411951 100644 --- a/packages/framework/resources/views/layouts/pubtype.blade.php +++ b/packages/framework/resources/views/layouts/pubtype.blade.php @@ -3,7 +3,7 @@ @section('content')
- + @include($component, ['publication' => $publication])
@endsection \ No newline at end of file diff --git a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php index 4b1fb923d79..196d22b824d 100644 --- a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php +++ b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php @@ -79,7 +79,7 @@ protected function build(): void protected function buildDetailPages(string $targetDirectory, Collection $pubType, Collection $publications): void { - $detailTemplate = "hyde::pubtypes.{$pubType->detailTemplate}"; + $detailTemplate = "hyde::pubtypes." . basename($pubType->detailTemplate, '.blade.php'); foreach ($publications as $publication) { $canonical = $publication->matter->__canonical; $this->info(" Building [$canonical] ..."); From a3c8ac4c6b23e2da766d8bdd40e7b710ce75df9b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 17 Nov 2022 13:00:10 +0100 Subject: [PATCH 27/31] Mock the current page --- .../Commands/BuildPublicationTypesSiteCommand.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php index 196d22b824d..89ac9bcf8de 100644 --- a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php +++ b/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php @@ -14,6 +14,7 @@ use Hyde\Framework\Services\DiscoveryService; use Hyde\Hyde; use Hyde\HydeHelper; +use Hyde\Pages\MarkdownPage; use Illuminate\Support\Facades\Config; use LaravelZero\Framework\Commands\Command; use Rgasch\Collection\Collection; @@ -79,7 +80,15 @@ protected function build(): void protected function buildDetailPages(string $targetDirectory, Collection $pubType, Collection $publications): void { - $detailTemplate = "hyde::pubtypes." . basename($pubType->detailTemplate, '.blade.php'); + $basename = basename($pubType->detailTemplate, '.blade.php'); + + // Mock a page + $page = new MarkdownPage($basename); + view()->share('page', $page); + view()->share('currentPage', $basename); + view()->share('currentRoute', $page->getRoute()); + + $detailTemplate = "hyde::pubtypes." . $basename; foreach ($publications as $publication) { $canonical = $publication->matter->__canonical; $this->info(" Building [$canonical] ..."); From ac255ed4bb3aa2199a522d1ba739de9b82245415 Mon Sep 17 00:00:00 2001 From: rgasch Date: Thu, 17 Nov 2022 22:09:53 +0100 Subject: [PATCH 28/31] Syncing changes -> pubtype based generation now works. --- ...mmand.php => BuildPublicationsCommand.php} | 25 ++++++++++--------- .../Console/HydeConsoleServiceProvider.php | 2 +- .../Actions/CreatesNewPublicationFile.php | 1 - packages/framework/src/HydeHelper.php | 11 +++++--- 4 files changed, 21 insertions(+), 18 deletions(-) rename packages/framework/src/Console/Commands/{BuildPublicationTypesSiteCommand.php => BuildPublicationsCommand.php} (89%) diff --git a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php b/packages/framework/src/Console/Commands/BuildPublicationsCommand.php similarity index 89% rename from packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php rename to packages/framework/src/Console/Commands/BuildPublicationsCommand.php index 89ac9bcf8de..82c8142963f 100644 --- a/packages/framework/src/Console/Commands/BuildPublicationTypesSiteCommand.php +++ b/packages/framework/src/Console/Commands/BuildPublicationsCommand.php @@ -24,10 +24,10 @@ * * @see \Hyde\Framework\Testing\Feature\StaticSiteServiceTest */ -class BuildPublicationTypesSiteCommand extends Command implements CommandHandleInterface +class BuildPublicationsCommand extends Command implements CommandHandleInterface { /** @var string */ - protected $signature = 'build:publicationTypeSite + protected $signature = 'build:publications {--run-dev : Run the NPM dev script after build} {--run-prod : Run the NPM prod script after build} {--run-prettier : Format the output using NPM Prettier} @@ -60,6 +60,8 @@ public function handle(): int $this->printFinishMessage($time_start); + $this->output->writeln('Max memory used: ' . memory_get_peak_usage() / 1024 / 1024 . ' MB'); + return Command::SUCCESS; } @@ -67,7 +69,6 @@ public function handle(): int protected function build(): void { $pubTypes = HydeHelper::getPublicationTypes(); - //dump($pubTypes); foreach ($pubTypes as $dir => $pubType) { $targetDirectory = "_site/$dir"; @mkdir($targetDirectory); @@ -80,28 +81,28 @@ protected function build(): void protected function buildDetailPages(string $targetDirectory, Collection $pubType, Collection $publications): void { - $basename = basename($pubType->detailTemplate, '.blade.php'); + $template = $pubType->detailTemplate; // Mock a page - $page = new MarkdownPage($basename); + $page = new MarkdownPage($template); view()->share('page', $page); - view()->share('currentPage', $basename); + view()->share('currentPage', $template); view()->share('currentRoute', $page->getRoute()); - $detailTemplate = "hyde::pubtypes." . $basename; + $detailTemplate = "hyde::pubtypes." . $template; foreach ($publications as $publication) { - $canonical = $publication->matter->__canonical; - $this->info(" Building [$canonical] ..."); + $slug = $publication->matter->__slug; + $this->info(" Building [$slug] ..."); $html = view('hyde::layouts.pubtype')->with(['component' => $detailTemplate, 'publication' => $publication])->render(); - file_put_contents("$targetDirectory/$publication->slug.html", $html); + file_put_contents("$targetDirectory/{$slug}.html", $html); } } protected function buildListPage(string $targetDirectory, Collection $pubType, Collection $publications): void { + $template = "hyde::pubtypes." . $pubType->listTemplate; $this->info(" Building list page ..."); - $listTemplate = $pubType->listTemplate; - $html = view($listTemplate)->with('publications', $publications)->render(); + $html = view($template)->with('publications', $publications)->render(); file_put_contents("$targetDirectory/index.html", $html); } diff --git a/packages/framework/src/Console/HydeConsoleServiceProvider.php b/packages/framework/src/Console/HydeConsoleServiceProvider.php index 985346481b4..ff954a4d160 100644 --- a/packages/framework/src/Console/HydeConsoleServiceProvider.php +++ b/packages/framework/src/Console/HydeConsoleServiceProvider.php @@ -18,7 +18,7 @@ public function register(): void { $this->commands( [ - Commands\BuildPublicationTypesSiteCommand::class, + Commands\BuildPublicationsCommand::class, Commands\BuildRssFeedCommand::class, Commands\BuildSearchCommand::class, Commands\BuildSiteCommand::class, diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index e4ee7dd77af..e9383b7960d 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -43,7 +43,6 @@ public function create(): void $now = date('Y-m-d H:i:s'); $output = "---\n"; - $output .= "__canonical: {$fileName}\n"; $output .= "__createdAt: {$now}\n"; foreach ($this->fieldData as $k => $v) { $field = $this->pubType->fields->where('name', $k)->first(); diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index 2318d3e1877..0ca94637461 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -4,6 +4,7 @@ namespace Hyde; +use Carbon\Carbon; use Hyde\Foundation\HydeKernel; use Illuminate\Contracts\Validation\Factory as ValidationFactory; use Illuminate\Support\Str; @@ -64,7 +65,7 @@ public static function getKernel(): HydeKernel */ public static function formatNameForStorage(string $pubTypeNameRaw) { - return Str::camel($pubTypeNameRaw); + return Str::slug($pubTypeNameRaw); } /** @@ -134,9 +135,11 @@ public static function getPublicationData(string $mdFileName): Collection throw new \Exception("No data read from [$mdFileName]"); } - $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); - $matter = $parsedFileData->matter(); - $markdown = $parsedFileData->body(); + $parsedFileData = YamlFrontMatter::markdownCompatibleParse($fileData); + $matter = $parsedFileData->matter(); + $markdown = $parsedFileData->body(); + $matter['__slug'] = basename($mdFileName, '.md'); + $matter['__createdDatetime'] = Carbon::createFromTimestamp($matter['__createdAt']); return Collection::create(['matter' => $matter, 'markdown' => $markdown]); } From a61eb482c835e0418791466484ca606d5f598fa8 Mon Sep 17 00:00:00 2001 From: rgasch Date: Fri, 18 Nov 2022 00:10:59 +0100 Subject: [PATCH 29/31] Implemented Array type for publications --- .../Commands/MakePublicationCommand.php | 126 +++++++++++------- .../Commands/MakePublicationTypeCommand.php | 6 +- .../Actions/CreatesNewPublicationFile.php | 32 +++-- 3 files changed, 107 insertions(+), 57 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index a9f803c1d3f..a7c83411712 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -48,60 +48,20 @@ public function handle(): int $pubType = $pubTypes->{$pubTypes->keys()[$selected - 1]}; } - $rulesPerType = Collection::create( - [ - 'string' => ['required', 'string', 'between'], - 'boolean' => ['required', 'boolean'], - 'integer' => ['required', 'integer', 'between'], - 'float' => ['required', 'numeric', 'between'], - 'datetime' => ['required', 'datetime', 'between'], - 'url' => ['required', 'url'], - 'text' => ['required', 'string', 'between'], - ] - ); - $fieldData = Collection::create(); $this->output->writeln('Now please enter the field data:'); foreach ($pubType->fields as $field) { - // Need to capture text line-by-line - if ($field->type === 'text') { - $lines = []; - $this->output->writeln($field->name . " (end with a line containing only '<<<')"); - do { - $line = Str::replace("\n", '', fgets(STDIN)); - $lines[] = $line; - } while ($line != '<<<'); - - $fieldData->{$field->name} = implode("\n", $lines); - continue; - } - - // Non-text block fields - $fieldRules = $rulesPerType->{$field->type}; - if ($fieldRules->contains('between')) { - $fieldRules->forget($fieldRules->search('between')); - if ($field->min && $field->max) { - switch ($field->type) { - case 'string': - case 'integer': - case 'float': - $fieldRules->add("between:$field->min,$field->max"); - break; - case 'datetime': - $fieldRules->add("after:$field->min"); - $fieldRules->add("before:$field->max"); - break; - } - } - } - $fieldData->{$field->name} = HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules); + $fieldData->{$field->name} = $this->captureFieldInput($field); } try { $creator = new CreatesNewPublicationFile($pubType, $fieldData); $creator->create(); } catch (\InvalidArgumentException $e) { // FIXME: provide a properly typed exception - $this->output->writeln('A file for this set of data already exists!'); + $msg = $e->getMessage(); + // Useful for debugging + //$this->output->writeln("xxx " . $e->getTraceAsString()); + $this->output->writeln("$msg"); $overwrite = HydeHelper::askWithValidation( $this, 'overwrite', @@ -122,4 +82,80 @@ public function handle(): int return Command::SUCCESS; } + + + private function captureFieldInput(Collection $field): string|array + { + $rulesPerType = $this->getValidationRulesPerType(); + + if ($field->type === 'text') { + $lines = []; + $this->output->writeln($field->name . " (end with a line containing only '<<<')"); + do { + $line = Str::replace("\n", '', fgets(STDIN)); + if ($line === '<<<') { + break; + } + $lines[] = $line; + } while (true); + + return implode("\n", $lines); + } + + if ($field->type === 'array') { + $lines = []; + $this->output->writeln($field->name . " (end with an empty line)"); + do { + $line = Str::replace("\n", '', fgets(STDIN)); + if ($line === '') { + break; + } + $lines[] = $line; + } while (true); + + return $lines; + } + + // Fields which are not of type array or text + $fieldRules = $rulesPerType->{$field->type}; + if ($fieldRules->contains('between')) { + $fieldRules->forget($fieldRules->search('between')); + if ($field->min && $field->max) { + switch ($field->type) { + case 'string': + case 'integer': + case 'float': + $fieldRules->add("between:$field->min,$field->max"); + break; + case 'datetime': + $fieldRules->add("after:$field->min"); + $fieldRules->add("before:$field->max"); + break; + } + } + } + + return HydeHelper::askWithValidation($this, $field->name, $field->name, $fieldRules); + } + + + private function getValidationRulesPerType(): Collection + { + static $rulesPerType = null; + if (!$rulesPerType) { + $rulesPerType = Collection::create( + [ + 'string' => ['required', 'string', 'between'], + 'boolean' => ['required', 'boolean'], + 'integer' => ['required', 'integer', 'between'], + 'float' => ['required', 'numeric', 'between'], + 'datetime' => ['required', 'datetime', 'between'], + 'url' => ['required', 'url'], + 'text' => ['required', 'string', 'between'], + ] + ); + } + + return $rulesPerType; + } } diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 87a54a62d6b..84809d76ff5 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -111,7 +111,8 @@ private function getFieldsDefinitions(): Collection $this->line(' 4 - Float'); $this->line(' 5 - Datetime'); $this->line(' 6 - URL'); - $this->line(' 7 - Text'); + $this->line(' 7 - Array'); + $this->line(' 8 - Text'); $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,7'], 1); do { $field->min = HydeHelper::askWithValidation($this, 'min', 'Min value (for strings, this refers to string length)', ['required', 'string'], 0); @@ -132,7 +133,8 @@ private function getFieldsDefinitions(): Collection 4 => 'float', 5 => 'datetime', 6 => 'url', - 7 => 'text', + 7 => 'array', + 8 => 'text', }; $fields->add($field); diff --git a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php index e9383b7960d..6fc4206c359 100644 --- a/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php +++ b/packages/framework/src/Framework/Actions/CreatesNewPublicationFile.php @@ -33,10 +33,14 @@ public function __construct( public function create(): void { - $dir = dirname($this->pubType->schemaFile); - $slug = Str::of($this->fieldData[$this->pubType->canonicalField])->substr(0, 64)->slug()->toString(); - $fileName = HydeHelper::formatNameForStorage($slug); - $outFile = "$dir/$fileName.md"; + $dir = dirname($this->pubType->schemaFile); + $canonicalFieldName = $this->pubType->canonicalField; + $canonicalFieldDef = $this->pubType->fields->filter(fn($f) => $f->name === $canonicalFieldName)->first(); + $canonicalValue = $canonicalFieldDef->type != 'array' ? $this->fieldData->{$canonicalFieldName} : $this->fieldData->{$canonicalFieldName}[0]; + $canonicalStr = Str::of($canonicalValue)->substr(0, 64); + $slug = $canonicalStr->slug()->toString(); + $fileName = HydeHelper::formatNameForStorage($slug); + $outFile = "$dir/$fileName.md"; if (file_exists($outFile) && !$this->force) { throw new \InvalidArgumentException("File [$outFile] already exists"); } @@ -46,16 +50,24 @@ public function create(): void $output .= "__createdAt: {$now}\n"; foreach ($this->fieldData as $k => $v) { $field = $this->pubType->fields->where('name', $k)->first(); - if ($field->type !== 'text') { - $output .= "{$k}: {$v}\n"; + + if ($field->type == 'text') { + $output .= "{$k}: |\n"; + foreach ($v as $line) { + $output .= " $line\n"; + } continue; } - // Text fields have different syntax - $output .= "{$k}: |\n"; - foreach ($v as $line) { - $output .= " $line\n"; + if ($field->type == 'array') { + $output .= "{$k}:\n"; + foreach ($v as $item) { + $output .= " - \"$item\"\n"; + } + continue; } + + $output .= "{$k}: {$v}\n"; } $output .= "---\n"; $output .= "Raw MD text ...\n"; From 13b033fe87260bb776ca156cf4a29d88ba59f3af Mon Sep 17 00:00:00 2001 From: rgasch Date: Fri, 18 Nov 2022 20:30:38 +0100 Subject: [PATCH 30/31] Added support for image fields --- .../Commands/MakePublicationCommand.php | 18 ++++++++-- .../Commands/MakePublicationTypeCommand.php | 14 +++++--- packages/framework/src/HydeHelper.php | 33 ++++++++++++++++--- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index a7c83411712..207d96f2170 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -48,10 +48,11 @@ public function handle(): int $pubType = $pubTypes->{$pubTypes->keys()[$selected - 1]}; } - $fieldData = Collection::create(); + $mediaFiles = HydeHelper::getMediaForPubType($pubType); + $fieldData = Collection::create(); $this->output->writeln('Now please enter the field data:'); foreach ($pubType->fields as $field) { - $fieldData->{$field->name} = $this->captureFieldInput($field); + $fieldData->{$field->name} = $this->captureFieldInput($field, $mediaFiles); } try { @@ -84,7 +85,7 @@ public function handle(): int } - private function captureFieldInput(Collection $field): string|array + private function captureFieldInput(Collection $field, Collection $mediaFiles): string|array { $rulesPerType = $this->getValidationRulesPerType(); @@ -116,6 +117,17 @@ private function captureFieldInput(Collection $field): string|array return $lines; } + if ($field->type === 'image') { + $this->output->writeln($field->name . " (end with an empty line)"); + foreach ($mediaFiles as $k => $file) { + $offset = $k + 1; + $this->output->writeln(" $offset: $file"); + } + $selected = HydeHelper::askWithValidation($this, $field->name, $field->name, ['required', 'integer', "between:1,$offset"]); + $file = $mediaFiles->{$selected - 1}; + return '_media/' . Str::of($file)->after('media/')->toString(); + } + // Fields which are not of type array or text $fieldRules = $rulesPerType->{$field->type}; if ($fieldRules->contains('between')) { diff --git a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php index 84809d76ff5..34bdd4bff06 100644 --- a/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationTypeCommand.php @@ -38,7 +38,7 @@ public function handle(): int } } - $fields = $this->getFieldsDefinitions(); + $fields = $this->captureFieldsDefinitions(); $this->output->writeln('Choose the default field you wish to sort by:'); $this->line(" 0: dateCreated (meta field)"); @@ -75,8 +75,10 @@ public function handle(): int $this->output->writeln('Choose a canonical name field (the values of this field have to be unique!):'); foreach ($fields as $k => $v) { - $offset = $k + 1; - $this->line(" $offset: $v[name]"); + if ($fields->type != 'image') { + $offset = $k + 1; + $this->line(" $offset: $v->name"); + } } $selected = (int)HydeHelper::askWithValidation($this, 'selected', "Canonical field (1-$offset)", ['required', 'integer', "between:1,$offset"], 1); $canonicalField = $fields[$selected - 1]['name']; @@ -93,7 +95,7 @@ public function handle(): int } - private function getFieldsDefinitions(): Collection + private function captureFieldsDefinitions(): Collection { $this->output->writeln('You now need to define the fields in your publication type:'); $count = 1; @@ -113,7 +115,8 @@ private function getFieldsDefinitions(): Collection $this->line(' 6 - URL'); $this->line(' 7 - Array'); $this->line(' 8 - Text'); - $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,7'], 1); + $this->line(' 9 - Local Image'); + $type = (int)HydeHelper::askWithValidation($this, 'type', 'Field type (1-7)', ['required', 'integer', 'between:1,9'], 1); do { $field->min = HydeHelper::askWithValidation($this, 'min', 'Min value (for strings, this refers to string length)', ['required', 'string'], 0); $field->max = HydeHelper::askWithValidation($this, 'max', 'Max value (for strings, this refers to string length)', ['required', 'string'], 0); @@ -135,6 +138,7 @@ private function getFieldsDefinitions(): Collection 6 => 'url', 7 => 'array', 8 => 'text', + 9 => 'image', }; $fields->add($field); diff --git a/packages/framework/src/HydeHelper.php b/packages/framework/src/HydeHelper.php index 0ca94637461..22c8c070835 100644 --- a/packages/framework/src/HydeHelper.php +++ b/packages/framework/src/HydeHelper.php @@ -104,12 +104,12 @@ public static function getPublicationTypes(): Collection */ public static function getPublicationsForPubType(Collection $pubType, $sort = true): Collection { - $root = base_path(); - $mdFiles = glob("$root/{$pubType->directory}/*.md"); + $root = base_path(); + $files = glob("$root/{$pubType->directory}/*.md"); $publications = Collection::create(); - foreach ($mdFiles as $mdFile) { - $publications->add(self::getPublicationData($mdFile)); + foreach ($files as $file) { + $publications->add(self::getPublicationData($file)); } if ($sort) { @@ -122,6 +122,31 @@ public static function getPublicationsForPubType(Collection $pubType, $sort = tr } + /** + * Return all media items for a given publication type + * + * @param Collection $pubType + * @return Collection + * @throws \Safe\Exceptions\FilesystemException + */ + public static function getMediaForPubType(Collection $pubType, $sort = true): Collection + { + $root = base_path(); + $files = glob("$root/_media/{$pubType->directory}/*.{jpg,jpeg,png,gif,pdf}", GLOB_BRACE); + + $media = Collection::create(); + foreach ($files as $file) { + $media->add($file); + } + + if ($sort) { + return $media->sort()->values(); + } + + return $media; + } + + /** * Read an MD file and return the parsed data. * From 93c09128531da9e3cfc884a18b71da33eb67e579 Mon Sep 17 00:00:00 2001 From: rgasch Date: Fri, 18 Nov 2022 20:33:06 +0100 Subject: [PATCH 31/31] Comment fix --- .../framework/src/Console/Commands/MakePublicationCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/src/Console/Commands/MakePublicationCommand.php b/packages/framework/src/Console/Commands/MakePublicationCommand.php index 207d96f2170..777420a2432 100644 --- a/packages/framework/src/Console/Commands/MakePublicationCommand.php +++ b/packages/framework/src/Console/Commands/MakePublicationCommand.php @@ -128,7 +128,7 @@ private function captureFieldInput(Collection $field, Collection $mediaFiles): s return '_media/' . Str::of($file)->after('media/')->toString(); } - // Fields which are not of type array or text + // Fields which are not of type array, text or image $fieldRules = $rulesPerType->{$field->type}; if ($fieldRules->contains('between')) { $fieldRules->forget($fieldRules->search('between'));