From 4aea949c5f0bf57d80e8e7ef368b454d32772758 Mon Sep 17 00:00:00 2001 From: Oskars Germovs Date: Fri, 13 Sep 2024 18:58:19 +0300 Subject: [PATCH 1/3] 1.) added: standartized package skeleton Signed-off-by: Oskars Germovs --- .editorconfig | 18 ++++++++++++++++++ .eslintrc.js | 20 ++++++++++++++++++++ .gitattributes | 16 ++++++++++++++++ .gitignore | 13 +++++++++++++ phpstan-baseline.neon | 2 ++ phpstan.neon.dist | 14 ++++++++++++++ phpunit.xml.dist | 17 +++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist create mode 100644 phpunit.xml.dist diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f0de65 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..782c426 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'esnext', + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, + settings: { + react: { + version: 'detect', + }, + }, + extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended'], + rules: { + // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs + // e.g. "@typescript-eslint/explicit-function-return-type": "off", + }, +}; diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..da7c3a5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/art export-ignore +/docs export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.php_cs.dist.php export-ignore +/phpstan* export-ignore +/CHANGELOG.md export-ignore +/CONTRIBUTING.md export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d197a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +vendor +composer.lock +.idea/ +.DS_Store +.phpunit.result.cache +node_modules/ +images/ +packages/* +build +.idea +.phpunit.cache +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..364905f --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..788c98d --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,14 @@ +includes: + - ./vendor/larastan/larastan/extension.neon + - phpstan-baseline.neon + +parameters: + level: 9 + paths: + - src + - config + tmpDir: build/phpstan + checkOctaneCompatibility: true + + ignoreErrors: + - '#Unsafe usage of new static#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..83fb5d5 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + src/ + + + + + tests + + + From 346afe9204d96822e1566f8d5e37cc9d329fa407 Mon Sep 17 00:00:00 2001 From: Oskars Germovs Date: Fri, 18 Oct 2024 19:48:08 +0300 Subject: [PATCH 2/3] 1.) added: DeferrableProvider 2.) added: standardization 3.) added: code format Signed-off-by: Oskars Germovs --- src/ReComposer.php | 2 +- src/ReComposerServiceProvider.php | 48 ++++++++++++++++++------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/ReComposer.php b/src/ReComposer.php index d2e6984..412d4e2 100755 --- a/src/ReComposer.php +++ b/src/ReComposer.php @@ -50,7 +50,7 @@ public function __construct() { $this->composer = $this->composerJson(); $this->packages = $this->packagesWithDependencies(); - $this->packageName = ReComposerServiceProvider::$namespaceSuffix . '/' . ReComposerServiceProvider::$alias; + $this->packageName = 'solumdesignum/recomposer'; } /** diff --git a/src/ReComposerServiceProvider.php b/src/ReComposerServiceProvider.php index 5b8e4c8..892d30d 100755 --- a/src/ReComposerServiceProvider.php +++ b/src/ReComposerServiceProvider.php @@ -4,20 +4,11 @@ namespace SolumDeSignum\ReComposer; +use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; -class ReComposerServiceProvider extends ServiceProvider +class ReComposerServiceProvider extends ServiceProvider implements DeferrableProvider { - /** - * @var string - */ - public static string $alias = 'recomposer'; - - /** - * @var string - */ - public static string $namespaceSuffix = 'solumdesignum'; - /** * Boot up the package. Load the views from the correct directory. */ @@ -25,18 +16,12 @@ public function boot(): void { $this->loadViewsFrom( __DIR__ . '/../resources/views', - self::$namespaceSuffix . '/' . self::$alias + 'solumdesignum/recomposer' ); + // Publishing is only necessary when using the CLI. if ($this->app->runningInConsole()) { - $this->publishes( - [ - __DIR__ . '/../config/recomposer.php' => config_path( - 'recomposer.php' - ), - ], - 'config' - ); + $this->bootForConsole(); } } @@ -47,4 +32,27 @@ public function register(): void 'recomposer' ); } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides(): array + { + return parent::provides(); + } + + protected function bootForConsole(): void + { + // Publishing the configuration file. + $this->publishes( + [ + __DIR__ . '/../config/recomposer.php' => config_path( + 'recomposer.php' + ), + ], + 'config' + ); + } } From 5d6648547e6125907c88195a86f5368cb6324e28 Mon Sep 17 00:00:00 2001 From: Oskars Germovs Date: Fri, 18 Oct 2024 20:05:02 +0300 Subject: [PATCH 3/3] 1.) added: better names on publishing 2.) added: code format Signed-off-by: Oskars Germovs --- src/ReComposerServiceProvider.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ReComposerServiceProvider.php b/src/ReComposerServiceProvider.php index 892d30d..a996539 100755 --- a/src/ReComposerServiceProvider.php +++ b/src/ReComposerServiceProvider.php @@ -46,13 +46,10 @@ public function provides(): array protected function bootForConsole(): void { // Publishing the configuration file. - $this->publishes( - [ - __DIR__ . '/../config/recomposer.php' => config_path( - 'recomposer.php' - ), - ], - 'config' + $this->publishes([ + __DIR__ . '/../config/recomposer.php' => config_path('recomposer.php'), + ], + 'recomposer.config' ); } }