Skip to content

Commit

Permalink
chore(configuration): add php-cs-fixer and others configurations comm…
Browse files Browse the repository at this point in the history
…itlint, version, ctv-updater
  • Loading branch information
pedrosalpr committed Feb 10, 2024
1 parent 549ac9d commit 504d49a
Show file tree
Hide file tree
Showing 7 changed files with 5,190 additions and 17 deletions.
73 changes: 73 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

$config = new PhpCsFixer\Config();
return $config->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@PhpCsFixer' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => ['statements' => []],
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'control_structure_braces' => true,
'control_structure_continuation_position' => ['position' => 'same_line'],
'braces_position' => true,
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
'type_declaration_spaces' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'new_with_parentheses' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'break',
'case',
'continue',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'switch',
'throw',
'use'
]
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiple_statements_per_line' => true,
'no_trailing_comma_in_singleline' => [ 'elements' => [
'arguments',
'array_destructuring',
'array',
'group_import',
]],
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
'php_unit_internal_class' => [],
'php_unit_test_class_requires_covers' => false,
'phpdoc_summary' => false,
'return_assignment' => false,
'return_type_declaration' => ['space_before' => 'none'],
'single_import_per_statement' => false,
'single_space_around_construct' => true,
'single_trait_insert_per_statement' => false,
'statement_indentation' => true,
'trailing_comma_in_multiline' => [],
'no_superfluous_phpdoc_tags' => false,
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
'less_and_greater' => null
]
])->setFinder(
PhpCsFixer\Finder::create()
->exclude(['bootstrap', 'storage', 'vendor'])
->notName(['_*.php'])
->in(__DIR__)
);
27 changes: 27 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"types": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "chore", "section": "Chore" },
{ "type": "build", "section": "Build" },
{ "type": "docs", "section": "Docs" },
{ "type": "style", "section": "Style" },
{ "type": "refactor", "section": "Refactor" },
{ "type": "perf", "section": "Performance" },
{ "type": "test", "section": "Test" }
],
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/{{previousTag}}...{{currentTag}}",
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"noVerify": true,
"infile": "CHANGELOG.md",
"silent": false,
"tagPrefix": "",
"dryRun": false,
"bumpFiles": [
{
"filename": "composer.json",
"updater": "ctv-updater"
}
]
}
36 changes: 36 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
],
}
};
37 changes: 20 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": ":vendor_slug/:package_slug",
"description": ":package_description",
"name": "pedrosalpr/laravel-api-problem",
"description": "This is my package laravel-api-problem",
"keywords": [
":vendor_name",
"pedrosalpr",
"laravel",
":package_slug"
"laravel-api-problem"
],
"homepage": "https://github.com/:vendor_slug/:package_slug",
"homepage": "https://github.com/pedrosalpr/laravel-api-problem",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": "author@domain.com",
"name": "Leandro Pedrosa Rodrigues",
"email": "pedrosalpr@gmail.com",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.47",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.8",
"larastan/larastan": "^2.0.1",
Expand All @@ -35,19 +36,17 @@
},
"autoload": {
"psr-4": {
"VendorName\\Skeleton\\": "src/",
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
"Pedrosalpr\\LaravelApiProblem\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"VendorName\\Skeleton\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/"
"Pedrosalpr\\LaravelApiProblem\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"clear": "@php vendor/bin/testbench package:purge-laravel-api-problem --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
Expand All @@ -61,7 +60,11 @@
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
"format": "vendor/bin/pint",
"lint-diff": "vendor/bin/php-cs-fixer fix -vvv --config .php-cs-fixer.php --dry-run --using-cache no --path-mode=intersection $(git diff --name-only --diff-filter=ACMRTUXB | grep .php)",
"lint-diff-staged": "vendor/bin/php-cs-fixer fix -vvv --config .php-cs-fixer.php --dry-run --using-cache no --path-mode=intersection $(git diff --name-only --staged --diff-filter=ACMRTUXB | grep .php)",
"lint-fix": "vendor/bin/php-cs-fixer fix -vvv --config .php-cs-fixer.php --using-cache no --path-mode=intersection $(git diff --name-only --diff-filter=ACMRTUXB | grep .php)",
"lint-fix-staged": "vendor/bin/php-cs-fixer fix -vvv --config .php-cs-fixer.php --using-cache no --path-mode=intersection $(git diff --name-only --staged --diff-filter=ACMRTUXB | grep .php)"
},
"config": {
"sort-packages": true,
Expand All @@ -73,10 +76,10 @@
"extra": {
"laravel": {
"providers": [
"VendorName\\Skeleton\\SkeletonServiceProvider"
"Pedrosalpr\\LaravelApiProblem\\LaravelApiProblemServiceProvider"
],
"aliases": {
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
"LaravelApiProblem": "Pedrosalpr\\LaravelApiProblem\\Facades\\LaravelApiProblem"
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions ctv-updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// commit-and-tag-version-updater.js
const stringifyPackage = require("stringify-package");
const detectIndent = require("detect-indent");
const detectNewline = require("detect-newline");

module.exports.readVersion = function (contents) {
return JSON.parse(contents).version;
};

module.exports.writeVersion = function (contents, version) {
const json = JSON.parse(contents);
let indent = detectIndent(contents).indent;
let newline = detectNewline(contents);
json.version = version;
return stringifyPackage(json, indent, newline);
};
Loading

0 comments on commit 504d49a

Please sign in to comment.