Skip to content

Commit

Permalink
Merge pull request #75 from Sammyjo20/feature/upgrade-codebase
Browse files Browse the repository at this point in the history
Feature | Upgrade Codebase & Added Support for PHP 8.3
  • Loading branch information
Sammyjo20 authored Nov 23, 2023
2 parents 954a621 + af63511 commit 3e57cd3
Show file tree
Hide file tree
Showing 70 changed files with 1,070 additions and 1,112 deletions.
7 changes: 5 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
phpunit.xml export-ignore
LICENSE export-ignore
.php-cs-fixer.dist.php export-ignore
package.json export-ignore
webpack.mix.js export-ignore
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Special thanks to @codepotato for the logo! ❤️

## Security

If you find any security related issues, please send me an email to [email protected].
If you find any security related issues, please send an email to **[email protected]**

## And that's it! ✨

Expand Down
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Security Policy

If you discover any security related issues, please email [email protected] instead of using the issue tracker.
If you discover any security related issues, please email **[email protected]** instead of using the issue tracker.
15 changes: 10 additions & 5 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Code Style

on:
pull_request:
branches: [ 'master', 'v2.0', 'v3.0' ]
push:
branches: [ 'master', 'v2.0', 'v3.0' ]
branches:
- 'v3.0'
pull_request:
branches:
- '*'

permissions:
contents: write

jobs:
php-cs-fixer:
Expand All @@ -16,8 +21,8 @@ jobs:
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply Code Style Fixes
commit_message: 🪄 Code Style Fixes
28 changes: 28 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PHPStan

on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan analyse --error-format=github
53 changes: 31 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
name: Tests
name: tests

on: [pull_request, push]
on:
push:
branches:
- 'v3.0'
pull_request:
branches:
- '*'

permissions:
contents: write

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
laravel: [^9.0, ^10.0]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: ^9.0
testbench: ^7.0
- laravel: ^10.0
testbench: ^8.0
os: [ ubuntu-latest, windows-latest ]
php: [ 8.1, 8.2, 8.3 ]
stability: [ prefer-lowest, prefer-stable ]

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, zip, fileinfo
coverage: none

- name: Install composer dependencies
- name: Install Node Dependencies
run: |
npm install
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: composer test
run: ./vendor/bin/pest
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ composer.lock
node_modules
vendor
.php-cs-fixer.cache
package-lock.json
tests/Fixtures/Cloud
tests/Fixtures/Public
lasso-bundle.json
.lasso
8 changes: 8 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@
'return_type_declaration' => [
'space_before' => 'none'
],
'declare_strict_types' => true,
'blank_line_after_opening_tag' => true,
'single_import_per_statement' => true,
'mb_str_functions' => true,
'no_superfluous_phpdoc_tags' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'phpdoc_trim' => true,
])->setFinder($finder);
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Sam Carré
Copyright (c) 2023 Sam Carré

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"authors": [
{
"name": "Sam Carré",
"email": "[email protected]"
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
Expand All @@ -21,11 +22,11 @@
"league/flysystem": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"orchestra/testbench": "^7.0 || ^8.0",
"friendsofphp/php-cs-fixer": "^3.1.0",
"spatie/ray": "^1.33",
"pestphp/pest": "^1.21"
"pestphp/pest": "^2.25",
"phpstan/phpstan": "^1.10"
},
"extra": {
"laravel": {
Expand All @@ -45,7 +46,10 @@
"./vendor/bin/pest"
],
"fix-code": [
"./vendor/bin/php-cs-fixer fix"
"./vendor/bin/php-cs-fixer fix --allow-risky=yes"
],
"pstan": [
"./vendor/bin/phpstan analyse"
]
},
"minimum-stability": "stable",
Expand Down
3 changes: 2 additions & 1 deletion config/lasso.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

return [
declare(strict_types=1);

return [
'compiler' => [

/*
Expand Down
4 changes: 4 additions & 0 deletions mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/tests/Fixtures/Public/app.css": "/tests/Fixtures/Public/app.css",
"/tests/Fixtures/Public/lasso-logo.png": "/tests/Fixtures/Public/lasso-logo.png"
}
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "lasso",
"version": "1.0.0",
"description": "Yeehaw",
"scripts": {
"production": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"laravel-mix": "^6.0.49"
}
}
14 changes: 14 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#############################################################################################
# Don't edit this config file directly. #
# For temporary, or local overrides, create a file named 'phpstan.neon' alongside this one. #
#############################################################################################

parameters:
# Add one of the editorUrl's in your phpstan.neon file for direct editor/IDE links in the terminal.
#editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
#editorUrl: 'vscode://file/%%file%%:%%line%%'

level: 7

paths:
- src
8 changes: 8 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Lasso Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
</phpunit>
12 changes: 0 additions & 12 deletions phpunit.xml.dist

This file was deleted.

18 changes: 8 additions & 10 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
<?php

declare(strict_types=1);

namespace Sammyjo20\Lasso\Commands;

use Illuminate\Console\Command;
use Sammyjo20\Lasso\Container\Artisan;
use Sammyjo20\Lasso\Helpers\Filesystem;

class BaseCommand extends Command
abstract class BaseCommand extends Command
{
/**
* Configure the Artisan console and the Filesystem, ready for publishing.
*
* @param Artisan $artisan
* @param Filesystem $filesystem
* @param bool $checkFilesystem
*/
protected function configureApplication(Artisan $artisan, Filesystem $filesystem, bool $checkFilesystem = false): void
{
$noPrompt = $this->option('silent') === true;
$lassoEnvironment = config('lasso.storage.environment', null);
$silent = $this->option('silent') === true;
$environment = config('lasso.storage.environment');

$artisan->setCommand($this);

if ($noPrompt) {
if ($silent) {
$artisan->silent();
}

if ($checkFilesystem === true && $noPrompt === false && ! is_null($lassoEnvironment)) {
$definedEnv = $this->ask('🐎 Which Lasso environment would you like to publish to?', $lassoEnvironment);
if ($checkFilesystem === true && $silent === false && ! is_null($environment)) {
$definedEnv = $this->ask('🐎 Which Lasso environment would you like to publish to?', $environment);

$filesystem->setLassoEnvironment($definedEnv);
}
Expand Down
14 changes: 6 additions & 8 deletions src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Sammyjo20\Lasso\Commands;

use Sammyjo20\Lasso\Container\Artisan;
Expand All @@ -26,21 +28,17 @@ final class PublishCommand extends BaseCommand
/**
* Execute the console command.
*
* @param Artisan $artisan
* @param Filesystem $filesystem
* @return int
* @throws \Sammyjo20\Lasso\Exceptions\ConfigFailedValidation
*/
public function handle(Artisan $artisan, Filesystem $filesystem): int
{
(new ConfigValidator())->validate();
(new ConfigValidator)->validate();

$this->configureApplication($artisan, $filesystem, true);

$dontUseGit = $this->option('no-git') === true;
$useCommit = $this->option('use-commit') === true;
$withCommit = $this->option('with-commit');
$this->configureApplication($artisan, $filesystem);

$job = new PublishJob;

Expand All @@ -52,8 +50,8 @@ public function handle(Artisan $artisan, Filesystem $filesystem): int
$job->useCommit();
}

if ($withCommit) {
$job->withCommit($withCommit);
if (is_string($withCommit)) {
$job->withCommit(mb_substr($withCommit, 0, 12));
}

$artisan->note(sprintf(
Expand All @@ -68,6 +66,6 @@ public function handle(Artisan $artisan, Filesystem $filesystem): int
$filesystem->getCloudDisk()
));

return 0;
return self::SUCCESS;
}
}
Loading

0 comments on commit 3e57cd3

Please sign in to comment.