From bca40a9241b114c243747ba0d60055203b61edec Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Thu, 13 Nov 2025 15:25:19 +0200 Subject: [PATCH 1/5] Move files to root folder --- {Github/Config => Config}/config.php | 0 .../Migrations/2024_01_01_000001_create_github_issues_table.php | 0 .../2024_01_01_000002_create_github_issue_conversation_table.php | 0 .../2024_01_01_000003_create_github_label_mappings_table.php | 0 {Github/Entities => Entities}/GithubIssue.php | 0 {Github/Entities => Entities}/GithubIssueConversation.php | 0 {Github/Entities => Entities}/GithubLabelMapping.php | 0 {Github/Http => Http}/Controllers/GithubController.php | 0 {Github/Http => Http}/routes.php | 0 {Github/Providers => Providers}/GithubServiceProvider.php | 0 {Github/Public => Public}/css/module.css | 0 {Github/Public => Public}/js/laroute.js | 0 {Github/Public => Public}/js/module.js | 0 {Github/Resources => Resources}/views/partials/sidebar.blade.php | 0 {Github/Resources => Resources}/views/settings.blade.php | 0 {Github/Services => Services}/GithubApiClient.php | 0 {Github/Services => Services}/IssueContentGenerator.php | 0 {Github/Services => Services}/LabelAssignmentService.php | 0 Github/composer.json => composer.json | 0 Github/module.json => module.json | 0 Github/start.php => start.php | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename {Github/Config => Config}/config.php (100%) rename {Github/Database => Database}/Migrations/2024_01_01_000001_create_github_issues_table.php (100%) rename {Github/Database => Database}/Migrations/2024_01_01_000002_create_github_issue_conversation_table.php (100%) rename {Github/Database => Database}/Migrations/2024_01_01_000003_create_github_label_mappings_table.php (100%) rename {Github/Entities => Entities}/GithubIssue.php (100%) rename {Github/Entities => Entities}/GithubIssueConversation.php (100%) rename {Github/Entities => Entities}/GithubLabelMapping.php (100%) rename {Github/Http => Http}/Controllers/GithubController.php (100%) rename {Github/Http => Http}/routes.php (100%) rename {Github/Providers => Providers}/GithubServiceProvider.php (100%) rename {Github/Public => Public}/css/module.css (100%) rename {Github/Public => Public}/js/laroute.js (100%) rename {Github/Public => Public}/js/module.js (100%) rename {Github/Resources => Resources}/views/partials/sidebar.blade.php (100%) rename {Github/Resources => Resources}/views/settings.blade.php (100%) rename {Github/Services => Services}/GithubApiClient.php (100%) rename {Github/Services => Services}/IssueContentGenerator.php (100%) rename {Github/Services => Services}/LabelAssignmentService.php (100%) rename Github/composer.json => composer.json (100%) rename Github/module.json => module.json (100%) rename Github/start.php => start.php (100%) 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/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 100% rename from Github/Providers/GithubServiceProvider.php rename to Providers/GithubServiceProvider.php 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/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/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 100% rename from Github/start.php rename to start.php From 3d31f01d65d76e23e11a7ff276e0cc7ce9c4a9a3 Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Thu, 13 Nov 2025 15:46:11 +0200 Subject: [PATCH 2/5] Ad install command and improve docs --- .gitignore | 1 + Console/InstallCommand.php | 70 +++++++++++++++++++++++++++++ Providers/GithubServiceProvider.php | 18 +++++++- README.md | 16 +++++-- composer.lock | 18 ++++++++ 5 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 Console/InstallCommand.php create mode 100644 composer.lock 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/Console/InstallCommand.php b/Console/InstallCommand.php new file mode 100644 index 0000000..db384e3 --- /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') || $this->getLaravel()->environment('production'); + + 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/Providers/GithubServiceProvider.php b/Providers/GithubServiceProvider.php index d8adf85..67687ae 100644 --- a/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(); + } } /** @@ -187,4 +191,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/README.md b/README.md index 6cb6436..fcba258 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,22 @@ 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. **Run the module installation command** to execute this module's migrations: + ```bash + php artisan freescout-github:install + ``` + +6. **Configure the module** via FreeScout Admin → Settings → GitHub ## ⚙️ Configuration 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" +} From 62d60071ca50318f200af77f9c3940055fbf4950 Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Thu, 13 Nov 2025 15:50:02 +0200 Subject: [PATCH 3/5] Fix force issue --- Console/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Console/InstallCommand.php b/Console/InstallCommand.php index db384e3..a3598aa 100644 --- a/Console/InstallCommand.php +++ b/Console/InstallCommand.php @@ -43,7 +43,7 @@ public function handle() $parameters = ['module' => $moduleName]; - $force = $this->option('force') || $this->getLaravel()->environment('production'); + $force = $this->option('force'); if ($force) { $parameters['--force'] = true; From f8b9008893e14c4da3d56062763d6b20d596e37e Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Fri, 14 Nov 2025 15:39:59 +0200 Subject: [PATCH 4/5] fix CSS not loading --- Providers/GithubServiceProvider.php | 22 +++++++++++++++++++--- start.php | 5 ----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Providers/GithubServiceProvider.php b/Providers/GithubServiceProvider.php index 67687ae..a384341 100644 --- a/Providers/GithubServiceProvider.php +++ b/Providers/GithubServiceProvider.php @@ -92,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; }); diff --git a/start.php b/start.php index c8ac61a..115abf2 100644 --- a/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'; From a765f38e86b2acbf651e3ce40e80f247942ae23a Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Fri, 14 Nov 2025 15:41:46 +0200 Subject: [PATCH 5/5] Add cache clear to readme --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcba258..cabd2b6 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,17 @@ A comprehensive GitHub integration module for FreeScout that enables support tea php artisan freescout:clear-cache ``` -5. **Run the module installation command** to execute this module's migrations: +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 ``` -6. **Configure the module** via FreeScout Admin → Settings → GitHub +7. **Configure the module** via FreeScout Admin → Settings → GitHub ## ⚙️ Configuration