diff --git a/Modules/M3/Config/config.php b/Modules/M3/Config/config.php index ed8568b4..02891d9d 100644 --- a/Modules/M3/Config/config.php +++ b/Modules/M3/Config/config.php @@ -2,7 +2,6 @@ return [ 'name' => 'M3', - 'features' => - [ - ], + 'features' => [ + ], ]; diff --git a/Modules/M3/Database/Seeders/M3DatabaseSeeder.php b/Modules/M3/Database/Seeders/M3DatabaseSeeder.php index 5d9bcb93..e8a769f3 100644 --- a/Modules/M3/Database/Seeders/M3DatabaseSeeder.php +++ b/Modules/M3/Database/Seeders/M3DatabaseSeeder.php @@ -2,8 +2,8 @@ namespace Modules\M3\Database\Seeders; -use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Seeder; class M3DatabaseSeeder extends Seeder { diff --git a/Modules/M3/Helpers/Helper.php b/Modules/M3/Helpers/Helper.php index 71681133..a50232f3 100644 --- a/Modules/M3/Helpers/Helper.php +++ b/Modules/M3/Helpers/Helper.php @@ -1,4 +1,5 @@ registerTranslations(); $this->registerConfig(); @@ -63,34 +61,35 @@ class M3ServiceProvider extends ServiceProvider */ protected function registerHelpers(): void { - foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) { + foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) { require_once $filename; } } - /** + /** * Dynamically Register Commands. * * @return void */ public function registerCommands(): void - { - if (!$this->app->runningInConsole()) { - return; - } - $commandPath = __DIR__ . '/../Console'; - $commands = collect(File::allFiles($commandPath)) - ->map(function ($file) { - $class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension(); - return $class; - }) - ->filter(function ($class) { - return class_exists($class); - }) - ->values() - ->all(); - $this->commands($commands); + { + if (! $this->app->runningInConsole()) { + return; } + $commandPath = __DIR__ . '/../Console'; + $commands = collect(File::allFiles($commandPath)) + ->map(function ($file) { + $class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension(); + + return $class; + }) + ->filter(function ($class) { + return class_exists($class); + }) + ->values() + ->all(); + $this->commands($commands); + } /** * Register config. @@ -100,10 +99,11 @@ class M3ServiceProvider extends ServiceProvider protected function registerConfig(): void { $this->publishes([ - module_path(ModuleInfo::name(), 'Config/config.php') => config_path( ModuleInfo::nameLower(). '.php'), + module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'), ], 'config'); $this->mergeConfigFrom( - module_path(ModuleInfo::name(), 'Config/config.php'), ModuleInfo::nameLower() + module_path(ModuleInfo::name(), 'Config/config.php'), + ModuleInfo::nameLower(), ); } @@ -117,9 +117,9 @@ class M3ServiceProvider extends ServiceProvider $viewPath = resource_path('views/modules/' . ModuleInfo::nameLower()); $sourcePath = module_path(ModuleInfo::name(), 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath + $sourcePath => $viewPath, ], ['views', ModuleInfo::nameLower() . '-module-views']); - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower()); + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower()); } /** @@ -129,10 +129,10 @@ class M3ServiceProvider extends ServiceProvider */ public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . ModuleInfo::nameLower()); + $langPath = resource_path('lang/modules/' . ModuleInfo::nameLower()); if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, ModuleInfo::nameLower()); + $this->loadTranslationsFrom($langPath, ModuleInfo::nameLower()); } else { $this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower()); } @@ -140,6 +140,7 @@ class M3ServiceProvider extends ServiceProvider /** * Regsiter View Paths + * * @return array */ private function getPublishableViewPaths(): array @@ -150,6 +151,7 @@ class M3ServiceProvider extends ServiceProvider $paths[] = $path . '/modules/' . ModuleInfo::nameLower(); } } + return $paths; } } diff --git a/Modules/M3/Providers/RouteServiceProvider.php b/Modules/M3/Providers/RouteServiceProvider.php index 07019db8..0ce1a895 100644 --- a/Modules/M3/Providers/RouteServiceProvider.php +++ b/Modules/M3/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace Modules\M3\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/Modules/M3/Routes/api.php b/Modules/M3/Routes/api.php index c421f8a5..f7fe8c57 100644 --- a/Modules/M3/Routes/api.php +++ b/Modules/M3/Routes/api.php @@ -15,4 +15,4 @@ use Illuminate\Http\Request; Route::middleware('auth:api')->get('/m3', function (Request $request) { return $request->user(); -}); \ No newline at end of file +}); diff --git a/Modules/M3/Routes/web.php b/Modules/M3/Routes/web.php index 128ef230..9b533358 100644 --- a/Modules/M3/Routes/web.php +++ b/Modules/M3/Routes/web.php @@ -11,6 +11,6 @@ | */ -Route::prefix('m3')->group(function() { +Route::prefix('m3')->group(function () { Route::get('/', 'M3Controller@index'); }); diff --git a/Modules/M3/Support/ModuleInfo.php b/Modules/M3/Support/ModuleInfo.php index b5f72af9..5e6903a1 100644 --- a/Modules/M3/Support/ModuleInfo.php +++ b/Modules/M3/Support/ModuleInfo.php @@ -4,10 +4,11 @@ namespace Modules\M3\Support; class ModuleInfo { - protected static string $moduleName = 'M3'; + protected static string $moduleName = 'M3'; /** * defines the Module Name + * * @return string */ public static function name(): string @@ -17,6 +18,7 @@ class ModuleInfo /** * define the lowercase version + * * @return string */ public static function nameLower(): string diff --git a/Modules/OTM/Config/config.php b/Modules/OTM/Config/config.php index b8f6fa2c..777fb768 100644 --- a/Modules/OTM/Config/config.php +++ b/Modules/OTM/Config/config.php @@ -2,7 +2,6 @@ return [ 'name' => 'OTM', - 'features' => - [ - ], + 'features' => [ + ], ]; diff --git a/Modules/OTM/Database/Seeders/OTMDatabaseSeeder.php b/Modules/OTM/Database/Seeders/OTMDatabaseSeeder.php index 350cc60c..45e30e7a 100644 --- a/Modules/OTM/Database/Seeders/OTMDatabaseSeeder.php +++ b/Modules/OTM/Database/Seeders/OTMDatabaseSeeder.php @@ -2,8 +2,8 @@ namespace Modules\OTM\Database\Seeders; -use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Seeder; class OTMDatabaseSeeder extends Seeder { diff --git a/Modules/OTM/Helpers/Helper.php b/Modules/OTM/Helpers/Helper.php index 6c1fee50..a4a392c7 100644 --- a/Modules/OTM/Helpers/Helper.php +++ b/Modules/OTM/Helpers/Helper.php @@ -1,4 +1,5 @@ registerTranslations(); $this->registerConfig(); @@ -63,34 +61,35 @@ class OTMServiceProvider extends ServiceProvider */ protected function registerHelpers(): void { - foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) { + foreach (glob(__DIR__ . '/../Helpers/*.php') as $filename) { require_once $filename; } } - /** + /** * Dynamically Register Commands. * * @return void */ public function registerCommands(): void - { - if (!$this->app->runningInConsole()) { - return; - } - $commandPath = __DIR__ . '/../Console'; - $commands = collect(File::allFiles($commandPath)) - ->map(function ($file) { - $class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension(); - return $class; - }) - ->filter(function ($class) { - return class_exists($class); - }) - ->values() - ->all(); - $this->commands($commands); + { + if (! $this->app->runningInConsole()) { + return; } + $commandPath = __DIR__ . '/../Console'; + $commands = collect(File::allFiles($commandPath)) + ->map(function ($file) { + $class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension(); + + return $class; + }) + ->filter(function ($class) { + return class_exists($class); + }) + ->values() + ->all(); + $this->commands($commands); + } /** * Register config. @@ -100,10 +99,11 @@ class OTMServiceProvider extends ServiceProvider protected function registerConfig(): void { $this->publishes([ - module_path(ModuleInfo::name(), 'Config/config.php') => config_path( ModuleInfo::nameLower(). '.php'), + module_path(ModuleInfo::name(), 'Config/config.php') => config_path(ModuleInfo::nameLower() . '.php'), ], 'config'); $this->mergeConfigFrom( - module_path(ModuleInfo::name(), 'Config/config.php'), ModuleInfo::nameLower() + module_path(ModuleInfo::name(), 'Config/config.php'), + ModuleInfo::nameLower(), ); } @@ -117,9 +117,9 @@ class OTMServiceProvider extends ServiceProvider $viewPath = resource_path('views/modules/' . ModuleInfo::nameLower()); $sourcePath = module_path(ModuleInfo::name(), 'Resources/views'); $this->publishes([ - $sourcePath => $viewPath + $sourcePath => $viewPath, ], ['views', ModuleInfo::nameLower() . '-module-views']); - $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower()); + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower()); } /** @@ -129,10 +129,10 @@ class OTMServiceProvider extends ServiceProvider */ public function registerTranslations(): void { - $langPath = resource_path('lang/modules/' . ModuleInfo::nameLower()); + $langPath = resource_path('lang/modules/' . ModuleInfo::nameLower()); if (is_dir($langPath)) { - $this->loadTranslationsFrom($langPath, ModuleInfo::nameLower()); + $this->loadTranslationsFrom($langPath, ModuleInfo::nameLower()); } else { $this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower()); } @@ -140,6 +140,7 @@ class OTMServiceProvider extends ServiceProvider /** * Regsiter View Paths + * * @return array */ private function getPublishableViewPaths(): array @@ -150,6 +151,7 @@ class OTMServiceProvider extends ServiceProvider $paths[] = $path . '/modules/' . ModuleInfo::nameLower(); } } + return $paths; } } diff --git a/Modules/OTM/Providers/RouteServiceProvider.php b/Modules/OTM/Providers/RouteServiceProvider.php index 90c1b80a..1ddee08b 100644 --- a/Modules/OTM/Providers/RouteServiceProvider.php +++ b/Modules/OTM/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace Modules\OTM\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/Modules/OTM/Routes/api.php b/Modules/OTM/Routes/api.php index 11cc6ffd..f399c285 100644 --- a/Modules/OTM/Routes/api.php +++ b/Modules/OTM/Routes/api.php @@ -15,4 +15,4 @@ use Illuminate\Http\Request; Route::middleware('auth:api')->get('/otm', function (Request $request) { return $request->user(); -}); \ No newline at end of file +}); diff --git a/Modules/OTM/Routes/web.php b/Modules/OTM/Routes/web.php index 671307a1..2c0dfc52 100644 --- a/Modules/OTM/Routes/web.php +++ b/Modules/OTM/Routes/web.php @@ -11,6 +11,6 @@ | */ -Route::prefix('otm')->group(function() { +Route::prefix('otm')->group(function () { Route::get('/', 'OTMController@index'); }); diff --git a/Modules/OTM/Support/ModuleInfo.php b/Modules/OTM/Support/ModuleInfo.php index 2a7ade2d..21bee6c8 100644 --- a/Modules/OTM/Support/ModuleInfo.php +++ b/Modules/OTM/Support/ModuleInfo.php @@ -4,10 +4,11 @@ namespace Modules\OTM\Support; class ModuleInfo { - protected static string $moduleName = 'OTM'; + protected static string $moduleName = 'OTM'; /** * defines the Module Name + * * @return string */ public static function name(): string @@ -17,6 +18,7 @@ class ModuleInfo /** * define the lowercase version + * * @return string */ public static function nameLower(): string diff --git a/app/Console/Commands/DatabaseStage.php b/app/Console/Commands/DatabaseStage.php index 04aa2b9e..3b62e180 100644 --- a/app/Console/Commands/DatabaseStage.php +++ b/app/Console/Commands/DatabaseStage.php @@ -40,11 +40,11 @@ class DatabaseStage extends Command ]; foreach ([ - 'STAGE_SSH_HOST' => $stage['ssh_host'], - 'STAGE_SSH_USER' => $stage['ssh_user'], - 'STAGE_DB_DATABASE' => $stage['database'], - 'STAGE_DB_USERNAME' => $stage['username'], - ] as $name => $value) { + 'STAGE_SSH_HOST' => $stage['ssh_host'], + 'STAGE_SSH_USER' => $stage['ssh_user'], + 'STAGE_DB_DATABASE' => $stage['database'], + 'STAGE_DB_USERNAME' => $stage['username'], + ] as $name => $value) { if (! $value) { $this->error("Missing {$name}."); @@ -69,14 +69,14 @@ class DatabaseStage extends Command ['Stage server', "{$stage['ssh_user']}@{$stage['ssh_host']}"], ['Stage database', $stage['database']], ['Stage owner', $stage['username']], - ] + ], ); if ( ! $this->option('force') && ! $this->confirm( "This will DROP and completely RECREATE '{$stage['database']}'. Continue?", - false + false, ) ) { $this->warn('Cancelled.'); @@ -110,9 +110,9 @@ class DatabaseStage extends Command 'PGPASSWORD' => $local['password'], ])->timeout(3600)->run([ 'pg_dump', - '--host='.$local['host'], - '--port='.$local['port'], - '--username='.$local['username'], + '--host=' . $local['host'], + '--port=' . $local['port'], + '--username=' . $local['username'], // Custom archive format. '--format=custom', @@ -127,14 +127,14 @@ class DatabaseStage extends Command '--no-acl', // Include everything in the database. - '--file='.$localDump, + '--file=' . $localDump, $local['database'], ]); if ($result->failed()) { throw new RuntimeException( - "pg_dump failed:\n".$result->errorOutput() + "pg_dump failed:\n" . $result->errorOutput(), ); } @@ -143,7 +143,7 @@ class DatabaseStage extends Command } return true; - } + }, ); $dumpSize = $this->formatBytes(filesize($localDump)); @@ -167,12 +167,12 @@ class DatabaseStage extends Command if ($result->failed()) { throw new RuntimeException( - "Invalid PostgreSQL archive:\n".$result->errorOutput() + "Invalid PostgreSQL archive:\n" . $result->errorOutput(), ); } return true; - } + }, ); /* @@ -194,12 +194,12 @@ class DatabaseStage extends Command if ($result->failed()) { throw new RuntimeException( - "Upload failed:\n".$result->errorOutput() + "Upload failed:\n" . $result->errorOutput(), ); } return true; - } + }, ); /* @@ -220,7 +220,7 @@ class DatabaseStage extends Command $terminateDatabase = str_replace( "'", "''", - $stage['database'] + $stage['database'], ); $sql = <<failed()) { throw new RuntimeException( - "Unable to recreate stage database:\n". - $result->errorOutput() + "Unable to recreate stage database:\n" . + $result->errorOutput(), ); } return true; - } + }, ); /* @@ -272,15 +272,15 @@ SQL; 'Restoring complete stage database', function () use ($stage, $remoteDump) { $restore = sprintf( - 'PGPASSWORD=%s pg_restore '. - '--host=%s '. - '--port=%s '. - '--username=%s '. - '--dbname=%s '. - '--no-owner '. - '--no-acl '. - '--exit-on-error '. - '--verbose '. + 'PGPASSWORD=%s pg_restore ' . + '--host=%s ' . + '--port=%s ' . + '--username=%s ' . + '--dbname=%s ' . + '--no-owner ' . + '--no-acl ' . + '--exit-on-error ' . + '--verbose ' . '%s', escapeshellarg($stage['password']), escapeshellarg($stage['db_host']), @@ -300,13 +300,13 @@ SQL; if ($result->failed()) { throw new RuntimeException( - "Database restore failed:\n". - $result->errorOutput() + "Database restore failed:\n" . + $result->errorOutput(), ); } return true; - } + }, ); /* @@ -319,12 +319,12 @@ SQL; 'Verifying restored database', function () use ($stage) { $command = sprintf( - 'PGPASSWORD=%s psql '. - '--host=%s '. - '--port=%s '. - '--username=%s '. - '--dbname=%s '. - '--tuples-only '. + 'PGPASSWORD=%s psql ' . + '--host=%s ' . + '--port=%s ' . + '--username=%s ' . + '--dbname=%s ' . + '--tuples-only ' . '--command=%s', escapeshellarg($stage['password']), escapeshellarg($stage['db_host']), @@ -332,7 +332,7 @@ SQL; escapeshellarg($stage['username']), escapeshellarg($stage['database']), escapeshellarg( - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public';" + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public';", ), ); @@ -346,8 +346,8 @@ SQL; if ($result->failed()) { throw new RuntimeException( - "Database verification failed:\n". - $result->errorOutput() + "Database verification failed:\n" . + $result->errorOutput(), ); } @@ -356,7 +356,7 @@ SQL; $this->line(" Stage public tables: {$count}"); return true; - } + }, ); /* @@ -381,11 +381,11 @@ SQL; $this->newLine(); $this->components->info( - 'Stage PostgreSQL database cloned successfully.' + 'Stage PostgreSQL database cloned successfully.', ); $this->line( - "Local {$local['database']} → Stage {$stage['database']}" + "Local {$local['database']} → Stage {$stage['database']}", ); return self::SUCCESS; @@ -396,7 +396,7 @@ SQL; $this->newLine(); $this->warn( - "The dump may still exist at {$localDump} and/or {$remoteDump}." + "The dump may still exist at {$localDump} and/or {$remoteDump}.", ); return self::FAILURE; @@ -405,7 +405,7 @@ SQL; private function quoteSqlIdentifier(string $identifier): string { - return '"'.str_replace('"', '""', $identifier).'"'; + return '"' . str_replace('"', '""', $identifier) . '"'; } private function formatBytes(int $bytes): string @@ -418,8 +418,8 @@ SQL; : 0; return number_format( - $bytes / (1024 ** $power), - $power === 0 ? 0 : 2 - ).' '.$units[$power]; + $bytes / (1024 ** $power), + $power === 0 ? 0 : 2, + ) . ' ' . $units[$power]; } } diff --git a/deploy.php b/deploy.php index 264d4d6d..db5a15ba 100644 --- a/deploy.php +++ b/deploy.php @@ -41,31 +41,31 @@ host('stage') */ task('build', function (): void { $node = 'export NVM_DIR="$HOME/.nvm"' - .' && [ -s "$NVM_DIR/nvm.sh" ]' - .' && . "$NVM_DIR/nvm.sh"' - .' && nvm use {{node_version}}'; + . ' && [ -s "$NVM_DIR/nvm.sh" ]' + . ' && . "$NVM_DIR/nvm.sh"' + . ' && nvm use {{node_version}}'; run( $node - .' && cd {{release_path}}' - .' && npm ci --no-audit --no-fund' + . ' && cd {{release_path}}' + . ' && npm ci --no-audit --no-fund', ); run( $node - .' && cd {{release_path}}' - .' && for lock in Modules/*/package-lock.json; do' - .' [ -f "$lock" ] || continue;' - .' module_dir="$(dirname "$lock")";' - .' echo "[Modules] npm ci: $module_dir";' - .' (cd "$module_dir" && npm ci --no-audit --no-fund);' - .' done' + . ' && cd {{release_path}}' + . ' && for lock in Modules/*/package-lock.json; do' + . ' [ -f "$lock" ] || continue;' + . ' module_dir="$(dirname "$lock")";' + . ' echo "[Modules] npm ci: $module_dir";' + . ' (cd "$module_dir" && npm ci --no-audit --no-fund);' + . ' done', ); run( $node - .' && cd {{release_path}}' - .' && npm run build' + . ' && cd {{release_path}}' + . ' && npm run build', ); });