diff --git a/.gitignore b/.gitignore index 94a5ebb..23a0311 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Github/Database/.DS_Store Jira/* +vendor \ No newline at end of file diff --git a/Github/Config/config.php b/Config/config.php similarity index 100% rename from Github/Config/config.php rename to Config/config.php diff --git a/Console/InstallCommand.php b/Console/InstallCommand.php new file mode 100644 index 0000000..a3598aa --- /dev/null +++ b/Console/InstallCommand.php @@ -0,0 +1,70 @@ +error('The GitHub module is not registered.'); + + return 1; + } + + $this->info('Running migrations for the GitHub module...'); + + $parameters = ['module' => $moduleName]; + + $force = $this->option('force'); + + if ($force) { + $parameters['--force'] = true; + } + + try { + $exitCode = $this->call('module:migrate', $parameters); + } catch (\Throwable $exception) { + $this->error('Running GitHub module migrations failed: '.$exception->getMessage()); + Helper::logException($exception, '[GitHub] install command'); + + return 1; + } + + if ($exitCode === 0) { + $this->info('GitHub module migrations completed successfully.'); + } else { + $this->error('GitHub module migrations finished with errors.'); + } + + return $exitCode; + } +} + diff --git a/Github/Database/Migrations/2024_01_01_000001_create_github_issues_table.php b/Database/Migrations/2024_01_01_000001_create_github_issues_table.php similarity index 100% rename from Github/Database/Migrations/2024_01_01_000001_create_github_issues_table.php rename to Database/Migrations/2024_01_01_000001_create_github_issues_table.php diff --git a/Github/Database/Migrations/2024_01_01_000002_create_github_issue_conversation_table.php b/Database/Migrations/2024_01_01_000002_create_github_issue_conversation_table.php similarity index 100% rename from Github/Database/Migrations/2024_01_01_000002_create_github_issue_conversation_table.php rename to Database/Migrations/2024_01_01_000002_create_github_issue_conversation_table.php diff --git a/Github/Database/Migrations/2024_01_01_000003_create_github_label_mappings_table.php b/Database/Migrations/2024_01_01_000003_create_github_label_mappings_table.php similarity index 100% rename from Github/Database/Migrations/2024_01_01_000003_create_github_label_mappings_table.php rename to Database/Migrations/2024_01_01_000003_create_github_label_mappings_table.php diff --git a/Github/Entities/GithubIssue.php b/Entities/GithubIssue.php similarity index 100% rename from Github/Entities/GithubIssue.php rename to Entities/GithubIssue.php diff --git a/Github/Entities/GithubIssueConversation.php b/Entities/GithubIssueConversation.php similarity index 100% rename from Github/Entities/GithubIssueConversation.php rename to Entities/GithubIssueConversation.php diff --git a/Github/Entities/GithubLabelMapping.php b/Entities/GithubLabelMapping.php similarity index 100% rename from Github/Entities/GithubLabelMapping.php rename to Entities/GithubLabelMapping.php diff --git a/Github/Http/Controllers/GithubController.php b/Http/Controllers/GithubController.php similarity index 100% rename from Github/Http/Controllers/GithubController.php rename to Http/Controllers/GithubController.php diff --git a/Github/Http/routes.php b/Http/routes.php similarity index 100% rename from Github/Http/routes.php rename to Http/routes.php diff --git a/Github/Providers/GithubServiceProvider.php b/Providers/GithubServiceProvider.php similarity index 83% rename from Github/Providers/GithubServiceProvider.php rename to Providers/GithubServiceProvider.php index d8adf85..a384341 100644 --- a/Github/Providers/GithubServiceProvider.php +++ b/Providers/GithubServiceProvider.php @@ -3,7 +3,7 @@ namespace Modules\Github\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Facades\Route; +use Modules\Github\Console\InstallCommand; // Module alias define('GITHUB_MODULE', 'github'); @@ -23,6 +23,10 @@ public function boot() $this->loadMigrations(); $this->registerHooks(); $this->loadAssets(); + + if ($this->app->runningInConsole()) { + $this->registerCommands(); + } } /** @@ -88,14 +92,30 @@ protected function registerHooks() { // Add module's CSS file to the application layout \Eventy::addFilter('stylesheets', function($styles) { - $styles[] = \Module::getPublicPath(GITHUB_MODULE).'/css/module.css'; + $cssPath = \Module::getPublicPath(GITHUB_MODULE).'/css/module.css'; + if (file_exists(public_path($cssPath))) { + $styles[] = $cssPath; + } else { + \Log::warning('[GitHub] Public CSS asset not found: '.public_path($cssPath)); + } return $styles; }); // Add module's JS file to the application layout \Eventy::addFilter('javascripts', function($javascripts) { - $javascripts[] = \Module::getPublicPath(GITHUB_MODULE).'/js/laroute.js'; - $javascripts[] = \Module::getPublicPath(GITHUB_MODULE).'/js/module.js'; + $jsFiles = [ + \Module::getPublicPath(GITHUB_MODULE).'/js/laroute.js', + \Module::getPublicPath(GITHUB_MODULE).'/js/module.js', + ]; + + foreach ($jsFiles as $jsPath) { + if (file_exists(public_path($jsPath))) { + $javascripts[] = $jsPath; + } else { + \Log::warning('[GitHub] Public JS asset not found: '.public_path($jsPath)); + } + } + return $javascripts; }); @@ -187,4 +207,16 @@ protected function loadAssets() { // Assets are loaded via Eventy filters in registerHooks() } + + /** + * Register Artisan commands provided by the module. + * + * @return void + */ + protected function registerCommands() + { + $this->commands([ + InstallCommand::class, + ]); + } } \ No newline at end of file diff --git a/Github/Public/css/module.css b/Public/css/module.css similarity index 100% rename from Github/Public/css/module.css rename to Public/css/module.css diff --git a/Github/Public/js/laroute.js b/Public/js/laroute.js similarity index 100% rename from Github/Public/js/laroute.js rename to Public/js/laroute.js diff --git a/Github/Public/js/module.js b/Public/js/module.js similarity index 100% rename from Github/Public/js/module.js rename to Public/js/module.js diff --git a/README.md b/README.md index 6cb6436..cabd2b6 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,27 @@ A comprehensive GitHub integration module for FreeScout that enables support tea composer install --no-dev ``` -3. **Run database migrations**: +3. **Enable the module** (from your FreeScout project root). Skip if already enabled in the UI: ```bash - php artisan migrate + php artisan module:enable Github ``` -4. **Configure the module** via FreeScout Admin → Settings → GitHub +4. **Refresh FreeScout caches** so the module command is registered: + ```bash + php artisan freescout:clear-cache + ``` + +5. **Clear application cache** so Laravel registers the Github commands + ```bash + php artisan cache:clear + ``` + +6. **Run the module installation command** to execute this module's migrations: + ```bash + php artisan freescout-github:install + ``` + +7. **Configure the module** via FreeScout Admin → Settings → GitHub ## ⚙️ Configuration diff --git a/Github/Resources/views/partials/sidebar.blade.php b/Resources/views/partials/sidebar.blade.php similarity index 100% rename from Github/Resources/views/partials/sidebar.blade.php rename to Resources/views/partials/sidebar.blade.php diff --git a/Github/Resources/views/settings.blade.php b/Resources/views/settings.blade.php similarity index 100% rename from Github/Resources/views/settings.blade.php rename to Resources/views/settings.blade.php diff --git a/Github/Services/GithubApiClient.php b/Services/GithubApiClient.php similarity index 100% rename from Github/Services/GithubApiClient.php rename to Services/GithubApiClient.php diff --git a/Github/Services/IssueContentGenerator.php b/Services/IssueContentGenerator.php similarity index 100% rename from Github/Services/IssueContentGenerator.php rename to Services/IssueContentGenerator.php diff --git a/Github/Services/LabelAssignmentService.php b/Services/LabelAssignmentService.php similarity index 100% rename from Github/Services/LabelAssignmentService.php rename to Services/LabelAssignmentService.php diff --git a/Github/composer.json b/composer.json similarity index 100% rename from Github/composer.json rename to composer.json diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..52f7f8a --- /dev/null +++ b/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "a4d8d2cdb9b16cab2a6a81d63921e117", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/Github/module.json b/module.json similarity index 100% rename from Github/module.json rename to module.json diff --git a/Github/start.php b/start.php similarity index 76% rename from Github/start.php rename to start.php index c8ac61a..115abf2 100644 --- a/Github/start.php +++ b/start.php @@ -7,11 +7,6 @@ * to create, link, and track GitHub issues directly from support conversations. */ -// Register the module with FreeScout -if (!defined('GITHUB_MODULE')) { - define('GITHUB_MODULE', true); -} - // Load module routes when running as a standalone FreeScout module if (class_exists('\Route')) { require __DIR__ . '/Http/routes.php';