-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Sánchez
committed
Mar 7, 2023
0 parents
commit 9a43797
Showing
29 changed files
with
708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# 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 | ||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.php_cs.dist export-ignore | ||
/psalm.xml export-ignore | ||
/psalm.xml.dist export-ignore | ||
/testbench.yaml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.idea | ||
.php_cs | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
build | ||
composer.lock | ||
coverage | ||
docs | ||
phpunit.xml | ||
psalm.xml | ||
testbench.yaml | ||
vendor | ||
node_modules | ||
.php-cs-fixer.cache | ||
/auth.json | ||
/cache/ | ||
/phpcs-report.json | ||
/junit.xml | ||
/report.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
If you encounter yourself dealing with conflicts in changelog you have come to the right place. | ||
|
||
Enter Changelog manager :) | ||
|
||
### Changelog generator command: | ||
``` | ||
php artisan changelog:generate | ||
``` | ||
The options for the command are: | ||
- delete-files : in case you want to delete the yaml files afterwards. | ||
- changelog-version : it will be in the file generated along with the date. For instance, '1.1.2'. | ||
|
||
|
||
This will generate a markdown file with the changelog. | ||
|
||
### YAML files: | ||
```yaml | ||
type: | ||
- '#PR-id Explanation' | ||
``` | ||
This is the structure you need to follow: for each PR you create a yaml file | ||
under a folder (by default 'changelogs' in the root but can be customize in the config file). | ||
'type' is also customizable in case you have more types of changes. By default we provide: | ||
'added', 'changed', 'deprecated', 'fixed' and 'removed'. | ||
### Add changelog command: | ||
``` | ||
php artisan changelog:add | ||
``` | ||
This command will ask some questions and generate the yaml file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "konigbach/changelog-manager", | ||
"description": "Manages changelog avoiding git conflicts", | ||
"require": { | ||
"php": "^8.2", | ||
"illuminate/contracts": "^9.0 || ^10.0", | ||
"illuminate/support": "^9.0 || ^10.0", | ||
"symfony/yaml": "^6.2" | ||
}, | ||
"require-dev": { | ||
"laravel/pint": "^1.6", | ||
"nunomaduro/collision": "^6.1", | ||
"nunomaduro/larastan": "^2.0", | ||
"orchestra/testbench": "^7.1", | ||
"phpunit/phpunit": "^9.5.0", | ||
"roave/security-advisories": "dev-master" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Konigbach\\ChangelogManager\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Konigbach\\ChangelogManager\\Tests\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Konigbach\\ChangelogManager\\ChangelogManagerServiceProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "stable", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
return [ | ||
'directory' => env('BITPANDA_CHANGELOG_GENERATOR_DIRECTORY', app_path('../changelog/')), | ||
'allowed_types' => [ | ||
'added', | ||
'changed', | ||
'deprecated', | ||
'fixed', | ||
'removed', | ||
], | ||
'markdown_title_tag_and_time' => '###', | ||
'markdown_title_type' => '####' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
includes: | ||
- ./vendor/nunomaduro/larastan/extension.neon | ||
parameters: | ||
level: max | ||
paths: | ||
- src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="all"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"preset": "psr12", | ||
"rules": { | ||
"psr_autoloading": true, | ||
"array_syntax": { | ||
"syntax": "short" | ||
}, | ||
"binary_operator_spaces": { | ||
"default": "single_space", | ||
"operators": { | ||
"|": "no_space" | ||
} | ||
}, | ||
"blank_line_before_statement": { | ||
"statements": [ | ||
"declare", | ||
"return" | ||
] | ||
}, | ||
"blank_line_after_opening_tag": true, | ||
"cast_spaces": { | ||
"space": "single" | ||
}, | ||
"class_attributes_separation": { | ||
"elements": { | ||
"trait_import": "none" | ||
} | ||
}, | ||
"compact_nullable_typehint": true, | ||
"concat_space": { | ||
"spacing": "one" | ||
}, | ||
"linebreak_after_opening_tag": true, | ||
"native_function_invocation": { | ||
"include": [ | ||
"@compiler_optimized" | ||
] | ||
}, | ||
"no_blank_lines_after_class_opening": true, | ||
"no_extra_blank_lines": { | ||
"tokens": [ | ||
"extra", | ||
"continue", | ||
"curly_brace_block", | ||
"parenthesis_brace_block", | ||
"return", | ||
"square_brace_block", | ||
"throw", | ||
"use", | ||
"switch", | ||
"case", | ||
"default" | ||
] | ||
}, | ||
"no_unused_imports": true, | ||
"no_useless_else": true, | ||
"no_whitespace_in_blank_line": true, | ||
"not_operator_with_successor_space": false, | ||
"object_operator_without_whitespace": true, | ||
"ordered_imports": true, | ||
"ordered_traits": true, | ||
"phpdoc_order": true, | ||
"return_type_declaration": { | ||
"space_before": "none" | ||
}, | ||
"single_line_after_imports": true, | ||
"single_quote": true, | ||
"single_trait_insert_per_statement": true, | ||
"strict_comparison": true, | ||
"ternary_operator_spaces": true, | ||
"ternary_to_null_coalescing": true, | ||
"unary_operator_spaces": true, | ||
"global_namespace_import": { | ||
"import_classes": true, | ||
"import_constants": false, | ||
"import_functions": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{ $changelogType }}: | ||
- "#{{ $taskNumber }}: {{ $taskDescription }}" |
6 changes: 6 additions & 0 deletions
6
resources/views/changelog-manager/changelog_template.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ config('changelog-manager.markdown_title_tag_and_time') }} [{{ $version }}] - {{ \Carbon\Carbon::now()->format('Y-m-d') }} | ||
@foreach(config('changelog-manager.allowed_types') as $type) | ||
@if($lines[$type] ?? false) | ||
@include('changelog-manager::changelog-manager.changelog_type', ['type' => $type, 'lines' => $lines[$type]]) | ||
@endif | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@if(count($lines) > 0) | ||
{{ config('changelog-manager.markdown_title_type') }} {{ \Illuminate\Support\Str::title($type) }} | ||
@foreach($lines as $line) | ||
- "{{ $line }}" | ||
@endforeach | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Konigbach\ChangelogManager; | ||
|
||
use Illuminate\Support\Facades\File; | ||
use Konigbach\ChangelogManager\Exceptions\NotFilesFoundException; | ||
use Konigbach\ChangelogManager\Exceptions\ParsedFileContentIsNotArrayException; | ||
use SplFileInfo; | ||
use Symfony\Component\Yaml\Yaml; | ||
use TypeError; | ||
|
||
class ChangelogGenerator | ||
{ | ||
public function make(?string $version): void | ||
{ | ||
$lines = []; | ||
$files = $this->files(); | ||
|
||
if (\count($files) === 0) { | ||
throw new NotFilesFoundException(); | ||
} | ||
|
||
foreach ($files as $file) { | ||
$parsedFile = Yaml::parseFile($file); | ||
if (!\is_array($parsedFile)) { | ||
throw new ParsedFileContentIsNotArrayException($file); | ||
} | ||
$fileContent = collect($parsedFile); | ||
|
||
foreach ($this->allowedTypes() as $allowedType) { | ||
if ($fileContent->keys()->contains($allowedType)) { | ||
$lines[$allowedType][] = $fileContent->get($allowedType)[0]; | ||
} | ||
} | ||
} | ||
|
||
$view = view('changelog-manager::changelog-manager.changelog_template', compact('lines', 'version')); | ||
|
||
File::put('changelog_.md', $view->render()); | ||
} | ||
|
||
/** | ||
* @return array<SplFileInfo> | ||
*/ | ||
protected function files(): array | ||
{ | ||
$directory = $this->directory(); | ||
|
||
return File::allFiles($directory); | ||
} | ||
|
||
protected function directory(): string | ||
{ | ||
$directory = config('changelog-manager.directory'); | ||
|
||
if (!\is_string($directory)) { | ||
throw new TypeError(); | ||
} | ||
|
||
return $directory; | ||
} | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
protected function allowedTypes(): array | ||
{ | ||
$allowedTypes = config('changelog-manager.allowed_types'); | ||
|
||
if (!\is_array($allowedTypes)) { | ||
throw new TypeError(); | ||
} | ||
|
||
return $allowedTypes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Konigbach\ChangelogManager; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Konigbach\ChangelogManager\Commands\AddChangelogCommand; | ||
use Konigbach\ChangelogManager\Commands\ChangelogGenerateCommand; | ||
|
||
class ChangelogManagerServiceProvider extends ServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'changelog-manager'); | ||
|
||
if ($this->isNotLumen()) { | ||
$this->publishes([ | ||
__DIR__ . '/../config/changelog-manager.php' => config_path('changelog-manager.php'), | ||
], 'changelog-generator'); | ||
|
||
$this->publishes([ | ||
__DIR__ . '/../resources/views/changelog-manager' => resource_path('views/vendor/changelog-manager'), | ||
]); | ||
} | ||
} | ||
|
||
public function register(): void | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
$this->commands([ | ||
AddChangelogCommand::class, | ||
ChangelogGenerateCommand::class, | ||
]); | ||
} | ||
} | ||
|
||
protected function isNotLumen(): bool | ||
{ | ||
return stripos(app()->version(), 'lumen') === false; | ||
} | ||
} |
Oops, something went wrong.