Skip to content

Commit 504d49a

Browse files
committed
chore(configuration): add php-cs-fixer and others configurations commitlint, version, ctv-updater
1 parent 549ac9d commit 504d49a

File tree

7 files changed

+5190
-17
lines changed

7 files changed

+5190
-17
lines changed

.php-cs-fixer.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
$config = new PhpCsFixer\Config();
4+
return $config->setUsingCache(false)
5+
->setRiskyAllowed(true)
6+
->setRules([
7+
'@PSR12' => true,
8+
'@PhpCsFixer' => true,
9+
'blank_line_after_opening_tag' => true,
10+
'blank_line_before_statement' => ['statements' => []],
11+
'compact_nullable_type_declaration' => true,
12+
'concat_space' => ['spacing' => 'one'],
13+
'control_structure_braces' => true,
14+
'control_structure_continuation_position' => ['position' => 'same_line'],
15+
'braces_position' => true,
16+
'declare_equal_normalize' => ['space' => 'none'],
17+
'declare_parentheses' => true,
18+
'declare_strict_types' => true,
19+
'type_declaration_spaces' => true,
20+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
21+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
22+
'new_with_parentheses' => true,
23+
'no_empty_statement' => true,
24+
'no_extra_blank_lines' => [
25+
'tokens' => [
26+
'break',
27+
'case',
28+
'continue',
29+
'curly_brace_block',
30+
'default',
31+
'extra',
32+
'parenthesis_brace_block',
33+
'return',
34+
'square_brace_block',
35+
'switch',
36+
'throw',
37+
'use'
38+
]
39+
],
40+
'no_leading_import_slash' => true,
41+
'no_leading_namespace_whitespace' => true,
42+
'no_multiple_statements_per_line' => true,
43+
'no_trailing_comma_in_singleline' => [ 'elements' => [
44+
'arguments',
45+
'array_destructuring',
46+
'array',
47+
'group_import',
48+
]],
49+
'no_unused_imports' => true,
50+
'no_whitespace_in_blank_line' => true,
51+
'php_unit_internal_class' => [],
52+
'php_unit_test_class_requires_covers' => false,
53+
'phpdoc_summary' => false,
54+
'return_assignment' => false,
55+
'return_type_declaration' => ['space_before' => 'none'],
56+
'single_import_per_statement' => false,
57+
'single_space_around_construct' => true,
58+
'single_trait_insert_per_statement' => false,
59+
'statement_indentation' => true,
60+
'trailing_comma_in_multiline' => [],
61+
'no_superfluous_phpdoc_tags' => false,
62+
'yoda_style' => [
63+
'always_move_variable' => false,
64+
'equal' => false,
65+
'identical' => false,
66+
'less_and_greater' => null
67+
]
68+
])->setFinder(
69+
PhpCsFixer\Finder::create()
70+
->exclude(['bootstrap', 'storage', 'vendor'])
71+
->notName(['_*.php'])
72+
->in(__DIR__)
73+
);

.versionrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"types": [
3+
{ "type": "feat", "section": "Features" },
4+
{ "type": "fix", "section": "Bug Fixes" },
5+
{ "type": "chore", "section": "Chore" },
6+
{ "type": "build", "section": "Build" },
7+
{ "type": "docs", "section": "Docs" },
8+
{ "type": "style", "section": "Style" },
9+
{ "type": "refactor", "section": "Refactor" },
10+
{ "type": "perf", "section": "Performance" },
11+
{ "type": "test", "section": "Test" }
12+
],
13+
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
14+
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/{{previousTag}}...{{currentTag}}",
15+
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
16+
"noVerify": true,
17+
"infile": "CHANGELOG.md",
18+
"silent": false,
19+
"tagPrefix": "",
20+
"dryRun": false,
21+
"bumpFiles": [
22+
{
23+
"filename": "composer.json",
24+
"updater": "ctv-updater"
25+
}
26+
]
27+
}

commitlint.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
parserPreset: 'conventional-changelog-conventionalcommits',
3+
rules: {
4+
'body-leading-blank': [1, 'always'],
5+
'body-max-line-length': [2, 'always', 100],
6+
'footer-leading-blank': [1, 'always'],
7+
'footer-max-line-length': [2, 'always', 100],
8+
'header-max-length': [2, 'always', 100],
9+
'subject-case': [
10+
2,
11+
'never',
12+
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
13+
],
14+
'subject-empty': [2, 'never'],
15+
'subject-full-stop': [2, 'never', '.'],
16+
'type-case': [2, 'always', 'lower-case'],
17+
'type-empty': [2, 'never'],
18+
'type-enum': [
19+
2,
20+
'always',
21+
[
22+
'build',
23+
'chore',
24+
'ci',
25+
'docs',
26+
'feat',
27+
'fix',
28+
'perf',
29+
'refactor',
30+
'revert',
31+
'style',
32+
'test',
33+
],
34+
],
35+
}
36+
};

composer.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
2-
"name": ":vendor_slug/:package_slug",
3-
"description": ":package_description",
2+
"name": "pedrosalpr/laravel-api-problem",
3+
"description": "This is my package laravel-api-problem",
44
"keywords": [
5-
":vendor_name",
5+
"pedrosalpr",
66
"laravel",
7-
":package_slug"
7+
"laravel-api-problem"
88
],
9-
"homepage": "https://github.com/:vendor_slug/:package_slug",
9+
"homepage": "https://github.com/pedrosalpr/laravel-api-problem",
1010
"license": "MIT",
1111
"authors": [
1212
{
13-
"name": ":author_name",
14-
"email": "author@domain.com",
13+
"name": "Leandro Pedrosa Rodrigues",
14+
"email": "pedrosalpr@gmail.com",
1515
"role": "Developer"
1616
}
1717
],
1818
"require": {
1919
"php": "^8.1",
20-
"spatie/laravel-package-tools": "^1.14.0",
21-
"illuminate/contracts": "^10.0"
20+
"illuminate/contracts": "^10.0",
21+
"spatie/laravel-package-tools": "^1.14.0"
2222
},
2323
"require-dev": {
24+
"friendsofphp/php-cs-fixer": "^3.47",
2425
"laravel/pint": "^1.0",
2526
"nunomaduro/collision": "^7.8",
2627
"larastan/larastan": "^2.0.1",
@@ -35,19 +36,17 @@
3536
},
3637
"autoload": {
3738
"psr-4": {
38-
"VendorName\\Skeleton\\": "src/",
39-
"VendorName\\Skeleton\\Database\\Factories\\": "database/factories/"
39+
"Pedrosalpr\\LaravelApiProblem\\": "src/"
4040
}
4141
},
4242
"autoload-dev": {
4343
"psr-4": {
44-
"VendorName\\Skeleton\\Tests\\": "tests/",
45-
"Workbench\\App\\": "workbench/app/"
44+
"Pedrosalpr\\LaravelApiProblem\\Tests\\": "tests/"
4645
}
4746
},
4847
"scripts": {
4948
"post-autoload-dump": "@composer run prepare",
50-
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
49+
"clear": "@php vendor/bin/testbench package:purge-laravel-api-problem --ansi",
5150
"prepare": "@php vendor/bin/testbench package:discover --ansi",
5251
"build": [
5352
"@composer run prepare",
@@ -61,7 +60,11 @@
6160
"analyse": "vendor/bin/phpstan analyse",
6261
"test": "vendor/bin/pest",
6362
"test-coverage": "vendor/bin/pest --coverage",
64-
"format": "vendor/bin/pint"
63+
"format": "vendor/bin/pint",
64+
"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)",
65+
"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)",
66+
"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)",
67+
"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)"
6568
},
6669
"config": {
6770
"sort-packages": true,
@@ -73,10 +76,10 @@
7376
"extra": {
7477
"laravel": {
7578
"providers": [
76-
"VendorName\\Skeleton\\SkeletonServiceProvider"
79+
"Pedrosalpr\\LaravelApiProblem\\LaravelApiProblemServiceProvider"
7780
],
7881
"aliases": {
79-
"Skeleton": "VendorName\\Skeleton\\Facades\\Skeleton"
82+
"LaravelApiProblem": "Pedrosalpr\\LaravelApiProblem\\Facades\\LaravelApiProblem"
8083
}
8184
}
8285
},

ctv-updater.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// commit-and-tag-version-updater.js
2+
const stringifyPackage = require("stringify-package");
3+
const detectIndent = require("detect-indent");
4+
const detectNewline = require("detect-newline");
5+
6+
module.exports.readVersion = function (contents) {
7+
return JSON.parse(contents).version;
8+
};
9+
10+
module.exports.writeVersion = function (contents, version) {
11+
const json = JSON.parse(contents);
12+
let indent = detectIndent(contents).indent;
13+
let newline = detectNewline(contents);
14+
json.version = version;
15+
return stringifyPackage(json, indent, newline);
16+
};

0 commit comments

Comments
 (0)