Skip to content

Commit

Permalink
Moox core init
Browse files Browse the repository at this point in the history
  • Loading branch information
adrolli committed Feb 14, 2024
1 parent ef99954 commit f9a7cfa
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/monorepo-split-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
package:
- core
- builder
- jobs
- press
Expand Down
Binary file added art/banner/core.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions packages/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Environment
.env
.env.backup

# Composer
/vendor
composer.lock
auth.json

# NPM / Node
/node_modules
npm-debug.log
package-lock.json

# Laravel
/public/hot
/public/storage
/storage/*.key

# PHPUnit
.phpunit.result.cache
phpunit.xml

# Yarn
yarn-error.log

# PHPStan
/build
phpstan.neon

# Testbench
testbench.yaml

# PHP CS Fixer
.php-cs-fixer.cache

# Homestead
Homestead.json
Homestead.yaml

# IDEs
/.idea
/.vscode

# MacOS
.DS_Store

# Windows
Thumbs.db
1 change: 1 addition & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
21 changes: 21 additions & 0 deletions packages/core/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Moox <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
41 changes: 41 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
![Moox Core](https://github.com/mooxphp/moox/raw/main/_other/art/banner/core.jpg)

# Moox Core

The Moox Core package cares for many common features. It is required by all Moox packages.

## Quick Installation

These two commmands are all you need to install the package:

```bash
composer require moox/core
php artisan mooxcore:install
```

Curious what the install command does? See manual installation below.

## Manual Installation

Instead of using the install-command `php artisan mooxcore:install` you are able to install this package manually step by step:

```bash
// Publish the config file with:
php artisan vendor:publish --tag="core-config"
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Security Vulnerabilities

Please review [our security policy](https://github.com/mooxphp/moox/security/policy) on how to report security vulnerabilities.

## Credits

- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
13 changes: 13 additions & 0 deletions packages/core/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Security Policy

## Supported Versions

We maintain the current version of `Moox Core` actively.

Do not expect security fixes for older versions.

## Reporting a Vulnerability

If you find any security-related bug, please report it to [email protected].

Please do not use Github issues, to give us enough time to review and fix the issue, before others can use it, to do stupid things.
41 changes: 41 additions & 0 deletions packages/core/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "moox/core",
"description": "The Moox Core package cares for many common features. It is required by all Moox packages.",
"keywords": [
"Laravel",
"Filament",
"Filament plugin",
"Laravel package"
],
"homepage": "https://moox.org/",
"license": "MIT",
"authors": [
{
"name": "Moox Developer",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": "^8.1.0",
"spatie/laravel-package-tools": "^1.13.0",
"filament/filament": "^3.2",
"invaders-xx/filament-jsoneditor": "^3.0",
"leandrocfe/filament-apex-charts": "^3.1",
"ryangjchandler/filament-progress-column": "*"
},
"autoload": {
"psr-4": {
"Moox\\Core\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"Moox\\Core\\CoreServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
5 changes: 5 additions & 0 deletions packages/core/config/core.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
// No config atm
];
8 changes: 8 additions & 0 deletions packages/core/resources/lang/de/translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'breadcrumb' => 'Core',
'title' => 'Core',
'navigation_label' => 'Core',
'navigation_group' => 'Moox Core',
];
8 changes: 8 additions & 0 deletions packages/core/resources/lang/en/translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'breadcrumb' => 'Core',
'title' => 'Core',
'navigation_label' => 'Core',
'navigation_group' => 'Moox Core',
];
8 changes: 8 additions & 0 deletions packages/core/resources/lang/es/translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'breadcrumb' => 'Core',
'title' => 'Core',
'navigation_label' => 'Core',
'navigation_group' => 'Moox Core',
];
8 changes: 8 additions & 0 deletions packages/core/resources/lang/nb_NO/translations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'breadcrumb' => 'Core',
'title' => 'Core',
'navigation_label' => 'Core',
'navigation_group' => 'Moox Core',
];
134 changes: 134 additions & 0 deletions packages/core/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

namespace Moox\Core\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\error;
use function Laravel\Prompts\info;
use function Laravel\Prompts\note;
use function Laravel\Prompts\warning;

class InstallCommand extends Command
{
protected $signature = 'mooxcore:install';

protected $description = 'Install Moox Core and register all needed plugins.';

protected $providerPath;

public function __construct()
{
parent::__construct();
$this->providerPath = app_path('Providers/Filament/AdminPanelProvider.php');
}

public function handle(): void
{
$this->art();
$this->welcome();
$this->checkForFilament();
$this->registerPlugins();
$this->sayGoodbye();
}

public function art(): void
{
info('
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓
▓▓▒░░▒▓▓▒▒░░░░░░▒▒▓▓▓▒░░░░░░░▒▓▓ ▓▓▓▓▒░░░░░░░▒▓▓▓▓ ▓▓▓▓▓▒░░░░░░░▒▒▓▓▓▓▓▒▒▒▒▓▓ ▓▓▓▒▒▒▒▓▓
▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▒░░░░░░░░░░░░░▒▓▓▓ ▓▓▓▓▒░░░░░░░░░░░░░▒▓▓▓░░░░░▒▓▓ ▓▓▒░░░░░▓▓
▓▒░░░░░░▒▓▓▓▓▒░░░░░░░▒▓▓▓▓░░░░░▒▓▓▓░░░░░▒▓▓▓▓▒░░░░░░░▓▓▓▓░░░░░░▒▓▓▓▓▓░░░░░░▒▓▓░░░░░▒▓▓▓▓▓░░░░░▒▓▓
▓▒░░░░▓▓▓▓ ▓▓░░░░░▓▓▓ ▓▓▓░░░░▒▓▓░░░░▒▓▓▓ ▓▓▓▓░░░░░▓░░░░░░▓▓▓▓ ▓▓▓▒░░░░▓▓▓▒░░░░░▓▓▓░░░░░▓▓▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓░░░░▒▓▓ ▓▓▓░░▒░░░░░▓▓▓ ▓▓░░░░▒▓▓▓▓░░░░░░░░░░░▓▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓░░░░▒▓ ▓▓▓░░░░░▒▓▓ ▓▓▒░░░░▓ ▓▓▓░░░░░░░░░▓▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓░░░░▒▓▓ ▓▓▒░░░░░▒░░▒▓▓ ▓▓░░░░▒▓▓▓▒░░░░░▒░░░░░▒▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓▓░░░░▒▓▓▓ ▓▓▓▒░░░░░▒▒░░░░░▒▓▓▓ ▓▓▓░░░░░▓▓▓░░░░░▒▓▓▓░░░░░▒▓▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓▓▓░░░░░░▒▒▓▓▒░░░░░░▒▓▓▓▓░░░░░░░▒▒▓▓▒░░░░░░▓▓▓░░░░░▒▓▓▓▓▓▒░░░░░▓▓
▓▒░░░░▒▓ ▓▓░░░░░▓▓ ▓▓░░░░▒▓▓▓▓▒░░░░░░░░░░░░░▒▓▓▓ ▓▓▓▓▒░░░░░░░░░░░░░▒▓▓▒░░░░░▓▓▓ ▓▓▒░░░░░▒▓
▓▓░░░▒▓▓ ▓▓▒░░░▒▓▓ ▓▓░░░░▓▓ ▓▓▓▓▒░░░░░░▒▒▓▓▓▓ ▓▓▓▓▓▒▒░░░░░▒▒▓▓▓▓▓░░░░▒▓▓ ▓▓▓░░░░▒▓
▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓
');
}

public function welcome(): void
{
note('Welcome to the Moox Core installer');
}

public function checkForFilament(): void
{
if (! File::exists($this->providerPath)) {
error('The Filament AdminPanelProvider.php or FilamentServiceProvider.php file does not exist.');
info(' ');
warning('You should install FilamentPHP first, see https://filamentphp.com/docs/panels/installation');
info(' ');
if (confirm('Do you want to install Filament now?', true)) {
info('Starting Filament installer...');
$this->call('filament:install', ['--panels' => true]);
}
}

if (! File::exists($this->providerPath)) {
if (! confirm('Filament is not installed properly. Do you want to proceed anyway?', false)) {
info('Installation cancelled.');

return; // cancel installation
}
}
}

public function registerPlugins(): void
{
note('Registering Moox Core Plugins...');

if (File::exists($this->providerPath)) {
$content = File::get($this->providerPath);
$intend = ' ';

$pluginsToAdd = ['Leandrocfe\FilamentApexCharts\FilamentApexChartsPlugin'];

$function = '::make(),';

$pattern = '/->plugins\(\[([\s\S]*?)\]\);/';
$newPlugins = '';

foreach ($pluginsToAdd as $plugin) {
$pluginParts = explode('\\', $plugin);
$pluginName = $pluginParts[2];
$searchPlugin = '/'.$pluginName.'/';
if (preg_match($searchPlugin, $content)) {
info("$pluginName already registered.");
} else {
$newPlugins .= $intend.$plugin.$function."\n";
}
}

if ($newPlugins) {
if (preg_match($pattern, $content)) {
info('Plugins section found. Adding new plugins...');

$replacement = "->plugins([$1\n$newPlugins\n ]);";
$newContent = preg_replace($pattern, $replacement, $content);
} else {
info('Plugins section created. Adding new plugins...');

$pluginsSection = " ->plugins([\n$newPlugins\n ]);";
$placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s';
$replacement = "$1\n".$pluginsSection;
$newContent = preg_replace($placeholderPattern, $replacement, $content, 1);
}
File::put($this->providerPath, $newContent);
}
}
}

public function sayGoodbye(): void
{
note('Moox Core installed successfully. Enjoy!');
}
}
21 changes: 21 additions & 0 deletions packages/core/src/CoreServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Moox\Core;

use Moox\Core\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class CoreServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
$package
->name('core')
->hasConfigFile()
->hasTranslations()
->hasCommand(InstallCommand::class);
}
}
7 changes: 2 additions & 5 deletions packages/jobs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
}
],
"require": {
"php": "^8.0.2",
"spatie/laravel-package-tools": "^1.9.2",
"invaders-xx/filament-jsoneditor": "^3.0",
"filament/filament": "^3.0"
"moox/core": "^1.0"
},
"require-dev": {},
"autoload": {
Expand All @@ -48,4 +45,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

0 comments on commit f9a7cfa

Please sign in to comment.