Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #110

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/Actions/PublishesHydeViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ class PublishesHydeViews implements ActionContract
'layouts' => [
'name' => 'Blade Layouts',
'path' => 'resources/views/layouts',
'destination' => 'resources/views/vendor/hyde/layouts',
'destination' => 'resources/views/vendor/hyde/layouts',
'description' => 'Shared layout views, such as the app layout, navigation menu, and Markdown page templates.',
],
'components' => [
'name' => 'Blade Components',
'path' => 'resources/views/components',
'destination' => 'resources/views/vendor/hyde/components',
'destination' => 'resources/views/vendor/hyde/components',
'description' => 'More or less self contained components, extracted for customizability and DRY code.',
],
'404' => [
'name' => '404 Page',
'path' => 'resources/views/pages/404.blade.php',
'destination' => '_pages/404.blade.php',
'destination' => '_pages/404.blade.php',
'description' => 'A beautiful 404 error page by the Laravel Collective.',
],
];
Expand All @@ -41,17 +41,16 @@ public function execute()
return 404;
}

if (is_dir(Hyde::vendorPath(static::$options[$this->selected]['path']))) {
return File::copyDirectory(
Hyde::vendorPath(static::$options[$this->selected]['path']),
Hyde::path(static::$options[$this->selected]['destination'])
);
}

return File::copy(
Hyde::vendorPath(static::$options[$this->selected]['path']),
Hyde::path(static::$options[$this->selected]['destination'])
);
if (is_dir(Hyde::vendorPath(static::$options[$this->selected]['path']))) {
return File::copyDirectory(
Hyde::vendorPath(static::$options[$this->selected]['path']),
Hyde::path(static::$options[$this->selected]['destination'])
);
}

}
return File::copy(
Hyde::vendorPath(static::$options[$this->selected]['path']),
Hyde::path(static::$options[$this->selected]['destination'])
);
}
}
2 changes: 1 addition & 1 deletion src/Commands/HydePublishHomepageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(): int
$this->canExistingIndexFileBeOverwritten()
))->execute();

// @deprecated version 0.10.0, can be removed as it should not be possible to select a homepage that does not exist, and we can make a pre-check for 409 case.
// @deprecated version 0.10.0, can be removed as it should not be possible to select a homepage that does not exist, and we can make a pre-check for 409 case.
if ($returnValue === true) {
$this->info('Homepage published successfully!');
} else {
Expand Down
38 changes: 19 additions & 19 deletions src/Commands/HydePublishViewsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@ public function handle(): int
{
$this->selected = $this->argument('category') ?? $this->promptForCategory();

if ($this->selected === 'all' || $this->selected === '') {
foreach (PublishesHydeViews::$options as $key => $value) {
$this->publishOption($key);
}
} else {
$this->publishOption($this->selected);
}
if ($this->selected === 'all' || $this->selected === '') {
foreach (PublishesHydeViews::$options as $key => $value) {
$this->publishOption($key);
}
} else {
$this->publishOption($this->selected);
}

return 0;
}

protected function publishOption($selected) {
(new PublishesHydeViews($selected))->execute();
protected function publishOption($selected)
{
(new PublishesHydeViews($selected))->execute();

$from = Hyde::vendorPath(PublishesHydeViews::$options[$selected]['path']);
$from = substr($from, strpos($from, 'vendor'));
$from = Hyde::vendorPath(PublishesHydeViews::$options[$selected]['path']);
$from = substr($from, strpos($from, 'vendor'));

$to = (PublishesHydeViews::$options[$selected]['destination']);
$to = (PublishesHydeViews::$options[$selected]['destination']);

$this->line('<info>Copied</info> [' . "<comment>$from</comment>" . '] <info>to</info> [' . "<comment>$to</comment>" . ']');
}
$this->line('<info>Copied</info> ['."<comment>$from</comment>".'] <info>to</info> ['."<comment>$to</comment>".']');
}

protected function promptForCategory(): string
{
Expand All @@ -50,7 +51,7 @@ protected function promptForCategory(): string

$choice = $this->parseChoiceIntoKey($choice);

$this->line("<info>Selected category</info> [<comment>".(empty($choice) ? 'all' : $choice)."</comment>]");
$this->line('<info>Selected category</info> [<comment>'.(empty($choice) ? 'all' : $choice).'</comment>]');
$this->newLine();

return $choice;
Expand All @@ -59,8 +60,8 @@ protected function promptForCategory(): string
protected function formatPublishableChoices(): array
{
$keys = [];
$keys[] = 'Publish all categories listed below';
foreach (PublishesHydeViews::$options as $key => $value) {
$keys[] = 'Publish all categories listed below';
foreach (PublishesHydeViews::$options as $key => $value) {
$keys[] = "<comment>$key</comment>: {$value['description']}";
}

Expand All @@ -71,5 +72,4 @@ protected function parseChoiceIntoKey(string $choice): string
{
return strstr(str_replace(['<comment>', '</comment>'], '', $choice), ':', true);
}

}
2 changes: 1 addition & 1 deletion src/Commands/Traits/AsksToRebuildSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ protected function askToRebuildSite()
$this->line('Okay, you can always run the build later!');
}
}
}
}
5 changes: 3 additions & 2 deletions src/StaticPageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ private function compileView(): string
/**
* Make sure the config defined directory for outputting the
* documentation files exists by creating it if it doesn't.
*
* @return void
*/
protected function makeSureDocsDirectoryExists(): void
{
if (!file_exists(Hyde::path('_site/' . Hyde::docsDirectory()))) {
mkdir(Hyde::path('_site/' . Hyde::docsDirectory()), recursive: true);
if (! file_exists(Hyde::path('_site/'.Hyde::docsDirectory()))) {
mkdir(Hyde::path('_site/'.Hyde::docsDirectory()), recursive: true);
}
}
}