diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml new file mode 100644 index 0000000..b245281 --- /dev/null +++ b/.forgejo/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Test +on: + push: + branches: + - '*' + +jobs: + test_all: + runs-on: ubuntu-22.04 + container: git.gertjankrol.nl/docker/php-toolkit:latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + - name: composer install + run: composer install --profile + - name: phpunit + run: composer unit + - name: phplint + run: composer lint + - name: phpcs + run: composer style + - name: composer require check + run: composer require-check + - name: composer security check + run: composer security-check + - name: composer unused package check + run: composer unused-check + - name: composer normalize check + run: composer normalize --dry-run \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9c00e42..403dc62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ /.idea/ +/node_modules/ /vendor/ composer.lock +package-lock.json *cache* *.log *.tmp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 69f458f..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -stages: - - prepare - - test - -prepare:composer-install: - stage: prepare - tags: - - prepare - image: composer:2.4 - script: - - echo "Start composer install" - - composer install --no-scripts --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader - artifacts: - expire_in: 1h - paths: - - composer.lock - - vendor/ - interruptible: true - -test:composer-security-check: - stage: test - tags: - - test - needs: - - job: prepare:composer-install - artifacts: true - image: composer:2.4 - script: - - echo "Start package security check" - - composer security-checker - allow_failure: true - interruptible: true - -test:php-codesniffer: - stage: test - tags: - - test - needs: - - job: prepare:composer-install - artifacts: true - image: composer:2.4 - script: - - echo "Start PHP code sniffer" - - composer style - interruptible: true - -# https://github.com/overtrue/phplint -test:php-lint: - stage: test - tags: - - test - needs: - - job: prepare:composer-install - artifacts: true - image: composer:2.4 - script: - - composer lint - interruptible: true - except: - - /^v\d+\.\d+\.\d+$/ - -test:phpunit-tests: - stage: test - tags: - - test - needs: - - job: prepare:composer-install - artifacts: true - image: composer:2.4 - script: - - echo "Start PHPUnit tests" - - composer test - interruptible: true - -test:composer-require-checker: - stage: test - tags: - - test - needs: - - job: prepare:composer-install - artifacts: true - image: composer:2.4 - script: - - echo "Downloading Composer require checker" - - curl -OL https://github.com/maglnet/ComposerRequireChecker/releases/download/4.0.0/composer-require-checker.phar - - echo "Start Composer require checker" - - php composer-require-checker.phar check composer.json - interruptible: true diff --git a/LICENSE.md b/LICENSE.md index e344d12..40ded4e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) Author +Copyright (c) 2023 - Gertjan Krol Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 62da0a6..4c8f6b6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ composer require gkrol/skeleton ``` ### Testing +- Run PHPUnit: `composer unit` +- Run PHPLint: `composer lint` +- Run PHPCS/PHPCBF: `composer style`/`composer fix-style` +- Run require checker: `composer require-check` +- Run security checker: `composer security-check` +- Check for unused packages: `composer unused-check` +- **Run all tests: `composer test-all`** ```bash composer test diff --git a/composer.json b/composer.json index 1990b08..891435a 100644 --- a/composer.json +++ b/composer.json @@ -1,30 +1,33 @@ { "name": "gkrol/skeleton", "description": "Laravel package skeleton", + "license": "MIT", + "type": "library", "keywords": [ "gkrol", "skeleton" ], - "homepage": "https://git.gertjankrol.nl/gertjan/gkrol-laravel-package-skeleton", - "license": "MIT", - "type": "library", "authors": [ { "name": "Gertjan Krol", "email": "hello@gertjankrol.nl" } ], + "homepage": "https://git.gertjankrol.nl/gertjan/gkrol-laravel-package-skeleton", "require": { "php": "^8.1", - "illuminate/support": "^8.0" + "laravel/framework": "^10.0" }, "require-dev": { - "orchestra/testbench": "^6.24", + "crawl/coding-standard": "^1.1", "enlightn/security-checker": "^1.10", - "crawl/coding-standard": "^1.0", + "ergebnis/composer-normalize": "^2.31", + "icanhazstring/composer-unused": "^0.8.8", + "maglnet/composer-require-checker": "^4.6", "mockery/mockery": "^1.5", - "overtrue/phplint": "^4.3", - "phpunit/phpunit": "^9.5" + "orchestra/testbench": "^8.5", + "overtrue/phplint": "^9.0", + "phpunit/phpunit": "^10.1" }, "autoload": { "psr-4": { @@ -36,28 +39,40 @@ "GKrol\\Skeleton\\Tests\\": "tests" } }, - "scripts": { - "lint": "vendor/bin/phplint ./ --exclude=vendor", - "style": "vendor/bin/phpcs --standard=phpcs.xml", - "fix-style": "vendor/bin/phpcbf --standard=phpcs.xml", - "security-checker": "vendor/bin/security-checker security:check composer.lock", - "test": "vendor/bin/phpunit --configuration phpunit.xml --colors=never" - }, "config": { - "optimize-autoloader": true, - "sort-packages": true, "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true - } + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true + }, + "optimize-autoloader": true, + "sort-packages": true }, "extra": { "laravel": { - "providers": [ - "GKrol\\Skeleton\\SkeletonServiceProvider" - ], "aliases": { "Skeleton": "GKrol\\Skeleton\\SkeletonFacade" - } + }, + "providers": [ + "GKrol\\Skeleton\\SkeletonServiceProvider" + ] } + }, + "scripts": { + "fix-style": "vendor/bin/phpcbf --standard=phpcs.xml", + "lint": "vendor/bin/phplint ./ --exclude=vendor", + "require-check": "vendor/bin/composer-require-checker check composer.json", + "security-check": "vendor/bin/security-checker security:check composer.lock", + "style": "vendor/bin/phpcs --standard=phpcs.xml", + "test-all": [ + "composer unit", + "composer lint", + "composer style", + "composer require-check", + "composer security-check", + "composer unused-check", + "composer normalize --dry-run" + ], + "unit": "vendor/bin/phpunit --configuration phpunit.xml --colors=never", + "unused-check": "vendor/bin/composer-unused" } } diff --git a/resources/assets/css/pkg-name.css b/docs/.gitkeep similarity index 100% rename from resources/assets/css/pkg-name.css rename to docs/.gitkeep diff --git a/package.json b/package.json new file mode 100644 index 0000000..9eb0870 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "private": true, + "scripts": { + "build": "vite build" + }, + "devDependencies": { + "laravel-vite-plugin": "^0.7", + "sass": "^1.62", + "vite": "^4.3" + } +} diff --git a/phpunit.xml b/phpunit.xml index f466529..f26461a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,10 +1,6 @@ - - - - ./src - - + + ./tests/ @@ -13,4 +9,9 @@ + + + ./src + + diff --git a/resources/assets/js/pkg-name.js b/public/app.css similarity index 100% rename from resources/assets/js/pkg-name.js rename to public/app.css diff --git a/public/app.js b/public/app.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/public/app.js @@ -0,0 +1 @@ + diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..37da698 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,12 @@ +{ + "resources/js/app.js": { + "file": "app.js", + "isEntry": true, + "src": "resources/js/app.js" + }, + "resources/sass/app.scss": { + "file": "app.css", + "isEntry": true, + "src": "resources/sass/app.scss" + } +} \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js new file mode 100644 index 0000000..33f2668 --- /dev/null +++ b/resources/js/app.js @@ -0,0 +1 @@ +/** Package JS goes here */ diff --git a/resources/sass/app.scss b/resources/sass/app.scss new file mode 100644 index 0000000..1f86393 --- /dev/null +++ b/resources/sass/app.scss @@ -0,0 +1 @@ +/** Package CSS goes here */ diff --git a/src/Skeleton.php b/src/Skeleton.php index edda21b..a4ecf4c 100644 --- a/src/Skeleton.php +++ b/src/Skeleton.php @@ -4,7 +4,10 @@ declare(strict_types=1); namespace GKrol\Skeleton; -class Skeleton +final class Skeleton { + public const PACKAGE_VENDOR = 'gkrol'; + public const PACKAGE_NAME = 'skeleton'; + // Build your next great package. } diff --git a/src/SkeletonFacade.php b/src/SkeletonFacade.php index f12359f..d61f11f 100644 --- a/src/SkeletonFacade.php +++ b/src/SkeletonFacade.php @@ -7,7 +7,7 @@ namespace GKrol\Skeleton; use Illuminate\Support\Facades\Facade; /** - * @see \GKrol\Skeleton\Skeleton + * @see Skeleton */ class SkeletonFacade extends Facade { @@ -16,6 +16,6 @@ class SkeletonFacade extends Facade */ protected static function getFacadeAccessor(): string { - return SkeletonServiceProvider::PACKAGE_NAME; + return Skeleton::PACKAGE_NAME; } } diff --git a/src/SkeletonServiceProvider.php b/src/SkeletonServiceProvider.php index c75f2d4..7c2d934 100644 --- a/src/SkeletonServiceProvider.php +++ b/src/SkeletonServiceProvider.php @@ -6,14 +6,9 @@ namespace GKrol\Skeleton; use Illuminate\Support\ServiceProvider; -class SkeletonServiceProvider extends ServiceProvider +final class SkeletonServiceProvider extends ServiceProvider { - public const PACKAGE_VENDOR = 'gkrol'; - public const PACKAGE_NAME = 'skeleton'; - - private const COMMANDS = [ - - ]; + private const COMMANDS = []; /** * Bootstrap the application services. @@ -21,30 +16,30 @@ class SkeletonServiceProvider extends ServiceProvider public function boot(): void { // Optional methods to load package assets - //$this->loadMigrationsFrom($this->getPackagePath() . '/database/migrations'); - //$this->loadRoutesFrom($this->getPackagePath() . '/routes.php'); - //$this->loadTranslationsFrom($this->getPackagePath() . '/resources/lang', self::PACKAGE_NAME); - //$this->loadViewsFrom($this->getPackagePath() . '/resources/views', self::PACKAGE_NAME); + //$this->loadMigrationsFrom($this->packageRoot() . '/database/migrations'); + //$this->loadRoutesFrom($this->packageRoot() . '/routes.php'); + //$this->loadTranslationsFrom($this->packageRoot() . '/resources/lang', Skeleton::PACKAGE_NAME); + //$this->loadViewsFrom($this->packageRoot() . '/resources/views', Skeleton::PACKAGE_NAME); if ($this->app->runningInConsole()) { // Publish config $this->publishes([ - $this->getPackagePath() . '/config/config.php' => config_path(self::PACKAGE_NAME . '.php'), + $this->packageRoot() . '/config/config.php' => config_path(Skeleton::PACKAGE_NAME . '.php'), ], 'config'); // Publish assets //$this->publishes([ - // $this->getPackagePath() . '/resources/assets' => public_path('vendor/' . self::PACKAGE_NAME), + // $this->packageRoot() . '/public' => public_path('vendor/' . Skeleton::PACKAGE_NAME), //], ['assets', 'public']); // Publishing translation files //$this->publishes([ - // $this->getPackagePath() . '/resources/lang' => resource_path('lang/vendor/' . self::PACKAGE_NAME), + // $this->packageRoot() . '/resources/lang' => resource_path('lang/vendor/' . Skeleton::PACKAGE_NAME), //], 'lang'); // Publishing views //$this->publishes([ - // $this->getPackagePath() . '/resources/views' => resource_path('views/vendor/' . self::PACKAGE_NAME), + // $this->packageRoot() . '/resources/views' => resource_path('views/vendor/' . Skeleton::PACKAGE_NAME), //], 'views'); // Registering package commands @@ -58,15 +53,15 @@ class SkeletonServiceProvider extends ServiceProvider public function register(): void { // Automatically apply the package configuration - $this->mergeConfigFrom($this->getPackagePath() . '/config/config.php', self::PACKAGE_NAME); + $this->mergeConfigFrom($this->packageRoot() . '/config/config.php', Skeleton::PACKAGE_NAME); // Register the main class to use with the facade - $this->app->singleton(self::PACKAGE_NAME, static function () { + $this->app->singleton(Skeleton::PACKAGE_NAME, static function () { return new Skeleton(); }); } - private function getPackagePath(): string + private function packageRoot(): string { return realpath(__DIR__ . '/..'); } diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..8ba9147 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,23 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + build: { + outDir: 'public', + rollupOptions: { + output: { + entryFileNames: `[name].js`, + assetFileNames: `[name].[ext]` + }, + }, + }, + plugins: [ + laravel({ + input: [ + 'resources/sass/app.scss', + 'resources/js/app.js', + ], + refresh: false, + }), + ], +});