Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -22,13 +22,16 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, bcmath, intl, iconv
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
vendor
${{ steps.composer-cache-files-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

Expand All @@ -38,11 +41,10 @@ jobs:
run: composer install --no-progress --no-interaction --prefer-dist

- name: Run and publish code coverage
uses: paambaati/codeclimate-action@v5.0.0
uses: paambaati/codeclimate-action@v9.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: vendor/bin/phpunit --coverage-clover ${{ github.workspace }}/clover.xml
debug: true
coverageLocations:
"${{github.workspace}}/clover.xml:clover"
23 changes: 16 additions & 7 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Code Style

on: [ pull_request, push ]
on:
push:
branches:
- main
- 3.x
pull_request:

jobs:
coverage:
Expand All @@ -10,21 +15,25 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, bcmath, intl, iconv
coverage: none

- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
vendor
${{ steps.composer-cache-files-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: PHPUnit

on:
push:
branches:
- main
- 3.x
pull_request:
schedule:
- cron: '0 14 * * 3' # Run Wednesdays at 2pm EST
Expand All @@ -12,13 +15,8 @@ jobs:
matrix:
dependency-version: [ stable, lowest ]
os: [ ubuntu-latest, windows-latest ]
laravel: [ 10.*, 11.*, 12.* ]
php: [ 8.1, 8.2, 8.3, 8.4 ]
exclude:
- php: 8.1
laravel: 11.*
- php: 8.1
laravel: 12.*
laravel: [ 11.*, 12.* ]
php: [ 8.3, 8.4 ]

runs-on: ${{ matrix.os }}
timeout-minutes: 10
Expand All @@ -37,23 +35,22 @@ jobs:
tools: composer:v2

- name: Register composer cache directory
id: composer-cache-files-dir
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
if: ${{ steps.composer-cache.outputs.dir != '' }}
with:
path: |
vendor
${{ steps.composer-cache-files-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer require --no-progress --no-interaction --prefer-dist --update-with-all-dependencies --prefer-${{ matrix.dependency-version }} "illuminate/support:${{ matrix.laravel }}"
composer require --no-interaction --prefer-dist --update-with-all-dependencies --prefer-${{ matrix.dependency-version }} "illuminate/support:${{ matrix.laravel }}"

- name: Execute tests
run: vendor/bin/phpunit
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=8.0",
"php": ">=8.3",
"ext-simplexml": "*",
"ext-dom": "*",
"composer/composer": "^2.1",
"illuminate/support": "^9|^10|^11|^12|13.x-dev|dev-master|dev-main"
"illuminate/support": "^11|^12|13.x-dev|dev-master|dev-main"
},
"require-dev": {
"orchestra/testbench": "^7.52|^8.33|^9.11|^10.0|dev-master|dev-main",
"orchestra/testbench": "^9.11|^10.0|dev-master|dev-main",
"friendsofphp/php-cs-fixer": "^3.14",
"mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.5|^10.5|^11.5",
"phpunit/phpunit": "^10.5|^11.5",
"ext-json": "*",
"livewire/livewire": "^2.5|^3.0"
},
Expand All @@ -48,8 +48,7 @@
"laravel": {
"providers": [
"InterNACHI\\Modular\\Support\\ModularServiceProvider",
"InterNACHI\\Modular\\Support\\ModularizedCommandsServiceProvider",
"InterNACHI\\Modular\\Support\\ModularEventServiceProvider"
"InterNACHI\\Modular\\Support\\ModularizedCommandsServiceProvider"
],
"aliases": {
"Modules": "InterNACHI\\Modular\\Support\\Facades\\Modules"
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions src/Console/Commands/Make/MakeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function handle()
$this->setUpStyles();

$this->newLine();

if ($this->shouldAbortToPublishConfig()) {
return 0;
}

$this->ensureModulesDirectoryExists();

$this->writeStubs();
$this->updateCoreComposerConfig();

Expand All @@ -115,6 +115,11 @@ public function handle()
return 0;
}

public function newLine($count = 1)
{
$this->getOutput()->newLine($count);
}

protected function shouldAbortToPublishConfig(): bool
{
if (
Expand Down Expand Up @@ -315,11 +320,6 @@ protected function title($title)
$this->getOutput()->title($title);
}

public function newLine($count = 1)
{
$this->getOutput()->newLine($count);
}

protected function getStubs(): array
{
if (is_array($custom_stubs = config('app-modules.stubs'))) {
Expand Down
20 changes: 10 additions & 10 deletions src/Console/Commands/Make/Modularize.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ trait Modularize
{
use \InterNACHI\Modular\Console\Commands\Modularize;

public function call($command, array $arguments = [])
{
// Pass the --module flag on to subsequent commands
if ($module = $this->option('module')) {
$arguments['--module'] = $module;
}

return $this->runCommand($command, $arguments, $this->output);
}

protected function getDefaultNamespace($rootNamespace)
{
$namespace = parent::getDefaultNamespace($rootNamespace);
Expand Down Expand Up @@ -80,14 +90,4 @@ protected function getPath($name)

return $path;
}

public function call($command, array $arguments = [])
{
// Pass the --module flag on to subsequent commands
if ($module = $this->option('module')) {
$arguments['--module'] = $module;
}

return $this->runCommand($command, $arguments, $this->output);
}
}
26 changes: 3 additions & 23 deletions src/Console/Commands/ModulesCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,19 @@
namespace InterNACHI\Modular\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use InterNACHI\Modular\Support\ModuleConfig;
use InterNACHI\Modular\Support\ModuleRegistry;
use LogicException;
use Throwable;
use InterNACHI\Modular\Support\AutodiscoveryHelper;

class ModulesCache extends Command
{
protected $signature = 'modules:cache';

protected $description = 'Create a cache file for faster module loading';

public function handle(ModuleRegistry $registry, Filesystem $filesystem)
public function handle(AutodiscoveryHelper $helper)
{
$this->call(ModulesClear::class);

$export = $registry->modules()
->map(function(ModuleConfig $module_config) {
return $module_config->toArray();
})
->toArray();

$cache_path = $registry->getCachePath();
$cache_contents = '<?php return '.var_export($export, true).';'.PHP_EOL;

$filesystem->put($cache_path, $cache_contents);

try {
require $cache_path;
} catch (Throwable $e) {
$filesystem->delete($cache_path);
throw new LogicException('Unable to cache module configuration.', 0, $e);
}
$helper->writeCache($this->getLaravel());

$this->info('Modules cached successfully!');
}
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Commands/ModulesClear.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
namespace InterNACHI\Modular\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use InterNACHI\Modular\Support\ModuleRegistry;
use InterNACHI\Modular\Support\AutodiscoveryHelper;

class ModulesClear extends Command
{
protected $signature = 'modules:clear';

protected $description = 'Remove the module cache file';

public function handle(Filesystem $filesystem, ModuleRegistry $registry)
public function handle(AutodiscoveryHelper $helper)
{
$filesystem->delete($registry->getCachePath());
$helper->clearCache();

$this->info('Module cache cleared!');
}
}
Loading