Skip to content

Commit

Permalink
Merge branch '3.x' into lazy-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to authored Dec 24, 2024
2 parents e22d11c + 41805fe commit e727a7c
Show file tree
Hide file tree
Showing 36 changed files with 549 additions and 521 deletions.
27 changes: 13 additions & 14 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<!--- Note to EXTERNAL Contributors -->
<!-- Thanks for opening a PR!
If it is a significant code change, please **make sure there is an open issue** for this.
We work best with you when we have accepted the idea first before you code. -->
<!--- Note to EXTERNAL Contributors -->
<!-- Thanks for opening a PR!
If it is a significant code change, please **make sure there is an open issue** for this.
We work best with you when we have accepted the idea first before you code. -->

<!--- For ALL Contributors 👇 -->
<!--- For ALL Contributors 👇 -->

## What was changed
<!-- Describe what has changed in this PR -->

## What was changed
<!-- Describe what has changed in this PR -->
## Why?
<!-- Tell your future self why have you made these changes -->

## Why?
<!-- Tell your future self why have you made these changes -->
## Checklist

## Checklist

- Issue #<!-- add issue number here -->
- Tested
- Issue #<!-- add issue number here -->
- Tested
- [ ] Tested manually
- [ ] Tests added
- [ ] Documentation <!--- Remove if not needed -->
- [ ] Documentation <!--- Remove if not needed -->
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
"illuminate/contracts": "^10|^11",
"illuminate/support": "^10|^11",
"illuminate/view": "^10|^11",
"lee-to/fast-attributes": "^0.1.0",
"lee-to/fast-attributes": "^0.1",
"lee-to/laravel-package-command": "^0.9",
"nyholm/psr7": "^1",
"nyholm/psr7": "^1.8",
"php": "^8.2",
"symfony/psr-http-message-bridge": "^7"
"symfony/psr-http-message-bridge": "^7.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64",
"larastan/larastan": "^2.0",
"moonshine/import-export": "^1.0",
"orchestra/testbench": "^9.0",
"pestphp/pest": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0",
"rector/rector": "^1.0",
"symplify/monorepo-builder": "^11.2",
"larastan/larastan": "^2.0",
"friendsofphp/php-cs-fixer": "^3.64"
"symplify/monorepo-builder": "^11.2"
},
"replace": {
"moonshine/asset-manager": "self.version",
Expand Down Expand Up @@ -102,6 +102,7 @@
"composer install",
"vendor/bin/pest --bail"
],
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"monorepo:merge": "vendor/bin/monorepo-builder merge"
}
}
6 changes: 3 additions & 3 deletions src/Laravel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"ext-curl": "*",
"ext-json": "*",
"lee-to/laravel-package-command": "^0.9",
"lee-to/fast-attributes": "^0.1.0",
"symfony/psr-http-message-bridge": "^7",
"nyholm/psr7": "^1",
"lee-to/fast-attributes": "^0.1",
"symfony/psr-http-message-bridge": "^7.2",
"nyholm/psr7": "^1.8",
"moonshine/contracts": "^3.0",
"moonshine/asset-manager": "^3.0",
"moonshine/color-manager": "^3.0",
Expand Down
17 changes: 12 additions & 5 deletions src/Laravel/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function handle(): int
}

if (! $this->testsMode) {
confirm('Can you quickly star our GitHub repository? 🙏🏻', true);
confirm('Can you quickly star our GitHub repository? 🙏🏻');

$this->components->bulletList([
'Star or contribute to MoonShine: https://github.com/moonshine-software/moonshine',
Expand Down Expand Up @@ -259,7 +259,7 @@ protected function initDirectories(): void
);
}

$this->makeDir($this->getDirectory() . '/Resources');
$this->makeDir($this->getDirectory('/Resources'));

$this->components->task('Resources directory created');
}
Expand All @@ -283,10 +283,14 @@ protected function initDashboard(): void
$this->components->task('Dashboard created');
}


protected function initLayout(): void
{
$compact = $this->confirmAction('Want to use a minimalist theme?', skipOption: 'default-layout', autoEnable: $this->testsMode, default: false);
$compact = $this->confirmAction(
'Want to use a minimalist theme?',
skipOption: 'default-layout',
autoEnable: $this->testsMode,
default: false,
);

$this->call(MakeLayoutCommand::class, [
'className' => 'MoonShineLayout',
Expand Down Expand Up @@ -323,7 +327,10 @@ private function confirmAction(

private function registerServiceProvider(): void
{
if (method_exists(ServiceProvider::class, 'addProviderToBootstrapFile') && file_exists(base_path('bootstrap/app.php'))) {
if (
method_exists(ServiceProvider::class, 'addProviderToBootstrapFile')
&& file_exists(base_path('bootstrap/app.php'))
) {
// @phpstan-ignore-next-line
ServiceProvider::addProviderToBootstrapFile(\App\Providers\MoonShineServiceProvider::class);

Expand Down
16 changes: 5 additions & 11 deletions src/Laravel/src/Commands/MakeApplyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

use Illuminate\Contracts\Filesystem\FileNotFoundException;

use function Laravel\Prompts\outro;
use function Laravel\Prompts\text;
use function Laravel\Prompts\{outro, text};

use Symfony\Component\Console\Attribute\AsCommand;

Expand All @@ -28,23 +27,18 @@ public function handle(): int
required: true
);

$apply = $this->getDirectory() . "/Applies/$className.php";
$appliesDir = $this->getDirectory('/Applies');
$apply = "$appliesDir/$className.php";

if (! is_dir($this->getDirectory() . '/Applies')) {
$this->makeDir($this->getDirectory() . '/Applies');
}
$this->makeDir($appliesDir);

$this->copyStub('Apply', $apply, [
'{namespace}' => moonshineConfig()->getNamespace('\Applies'),
'DummyClass' => $className,
]);

outro(
"$className was created: " . str_replace(
base_path(),
'',
$apply
)
"$className was created: " . $this->getRelativePath($apply)
);

return self::SUCCESS;
Expand Down
30 changes: 10 additions & 20 deletions src/Laravel/src/Commands/MakeComponentCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

use Illuminate\Contracts\Filesystem\FileNotFoundException;

use function Laravel\Prompts\outro;
use function Laravel\Prompts\text;
use function Laravel\Prompts\{outro, text};

use Symfony\Component\Console\Attribute\AsCommand;

Expand Down Expand Up @@ -41,42 +40,33 @@ public function handle(): int
required: true
);

$component = $this->getDirectory() . "/Components/$className.php";
$componentsDir = $this->getDirectory('/Components');
$componentPath = "$componentsDir/$className.php";

if (! is_dir($this->getDirectory() . '/Components')) {
$this->makeDir($this->getDirectory() . '/Components');
}
$this->makeDir($componentsDir);

$view = str_replace('.blade.php', '', $view);
$viewPath = resource_path('views/' . str_replace('.', DIRECTORY_SEPARATOR, $view));
$viewPath .= '.blade.php';

if (! is_dir(\dirname($viewPath))) {
$this->makeDir(\dirname($viewPath));
}
$this->makeDir(
\dirname($viewPath)
);

$this->copyStub('view', $viewPath);

$this->copyStub('Component', $component, [
$this->copyStub('Component', $componentPath, [
'{namespace}' => moonshineConfig()->getNamespace('\Components'),
'{view}' => $view,
'DummyClass' => $className,
]);

outro(
"$className was created: " . str_replace(
base_path(),
'',
$component
)
"$className was created: " . $this->getRelativePath($componentPath)
);

outro(
"View was created: " . str_replace(
base_path(),
'',
$viewPath
)
"View was created: " . $this->getRelativePath($viewPath)
);

return self::SUCCESS;
Expand Down
24 changes: 9 additions & 15 deletions src/Laravel/src/Commands/MakeControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

use Illuminate\Contracts\Filesystem\FileNotFoundException;

use function Laravel\Prompts\outro;
use function Laravel\Prompts\text;
use function Laravel\Prompts\{outro, text};

use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'moonshine:controller')]
class MakeControllerCommand extends MoonShineCommand
{
protected $signature = 'moonshine:controller {className?}';
protected $signature = 'moonshine:controller {name?}';

protected $description = 'Create controller';

Expand All @@ -23,28 +22,23 @@ class MakeControllerCommand extends MoonShineCommand
*/
public function handle(): int
{
$className = $this->argument('className') ?? text(
$name = $this->argument('name') ?? text(
'Class name',
required: true
);

$controller = $this->getDirectory() . "/Controllers/$className.php";
$controllersDir = $this->getDirectory('/Controllers');
$controllerPath = "$controllersDir/$name.php";

if (! is_dir($this->getDirectory() . '/Controllers')) {
$this->makeDir($this->getDirectory() . '/Controllers');
}
$this->makeDir($controllersDir);

$this->copyStub('Controller', $controller, [
$this->copyStub('Controller', $controllerPath, [
'{namespace}' => moonshineConfig()->getNamespace('\Controllers'),
'DummyClass' => $className,
'DummyClass' => $name,
]);

outro(
"$className was created: " . str_replace(
base_path(),
'',
$controller
)
"$name was created: " . $this->getRelativePath($controllerPath)
);

return self::SUCCESS;
Expand Down
31 changes: 10 additions & 21 deletions src/Laravel/src/Commands/MakeFieldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Facades\File;

use function Laravel\Prompts\outro;
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;
use function Laravel\Prompts\{outro, select, text};

use MoonShine\UI\Fields\Field;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down Expand Up @@ -61,13 +59,12 @@ public function handle(): int
Field::class
);

$field = $this->getDirectory() . "/Fields/$className.php";
$fieldsDir = $this->getDirectory('/Fields');
$fieldPath = "$fieldsDir/$className.php";

if (! is_dir($this->getDirectory() . '/Fields')) {
$this->makeDir($this->getDirectory() . '/Fields');
}
$this->makeDir($fieldsDir);

$this->copyStub('Field', $field, [
$this->copyStub('Field', $fieldPath, [
'{namespace}' => moonshineConfig()->getNamespace('\Fields'),
'{view}' => $view,
'{extend}' => $extends,
Expand All @@ -79,26 +76,18 @@ public function handle(): int
$viewPath = resource_path('views/' . str_replace('.', DIRECTORY_SEPARATOR, $view));
$viewPath .= '.blade.php';

if (! is_dir(\dirname($viewPath))) {
$this->makeDir(\dirname($viewPath));
}
$this->makeDir(
\dirname($viewPath)
);

$this->copyStub('view', $viewPath);

outro(
"$className was created: " . str_replace(
base_path(),
'',
$field
)
"$className was created: " . $this->getRelativePath($fieldPath)
);

outro(
"View was created: " . str_replace(
base_path(),
'',
$viewPath
)
"View was created: " . $this->getRelativePath($viewPath)
);

return self::SUCCESS;
Expand Down
15 changes: 5 additions & 10 deletions src/Laravel/src/Commands/MakeHandlerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,18 @@ public function handle(): int
required: true
);

$path = $this->getDirectory() . "/Handlers/$className.php";
$handlersDir = $this->getDirectory() . '/Handlers';
$handlerPath = "$handlersDir/$className.php";

if (! is_dir($this->getDirectory() . '/Handlers')) {
$this->makeDir($this->getDirectory() . '/Handlers');
}
$this->makeDir($handlersDir);

$this->copyStub('Handler', $path, [
$this->copyStub('Handler', $handlerPath, [
'{namespace}' => moonshineConfig()->getNamespace('\Handlers'),
'DummyHandler' => $className,
]);

outro(
"$className was created: " . str_replace(
base_path(),
'',
$path
)
"$className was created: " . $this->getRelativePath($handlerPath)
);

return self::SUCCESS;
Expand Down
Loading

0 comments on commit e727a7c

Please sign in to comment.