Skip to content

Commit 226f3dc

Browse files
author
Bram Ceulemans
committed
Merge remote-tracking branch 'origin/main'
2 parents 65f344c + 87ea9f0 commit 226f3dc

File tree

8 files changed

+60
-15
lines changed

8 files changed

+60
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ testbench.yaml
1616
# ide
1717
/.idea
1818
/.vscode
19+
20+
# mac
21+
.DS_Store

.styleci.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased](https://github.com/BlameButton/laravel-changelog/compare/v1.0.1...main)
8+
## [Unreleased](https://github.com/BlameButton/laravel-changelog/compare/v1.0.4...main)
9+
10+
## [v1.0.4](https://github.com/BlameButton/laravel-changelog/compare/v1.0.3...v1.0.4) - 2021-11-05
11+
12+
### Fixed
13+
14+
- Storage facade does not work outside of storage directory
15+
16+
## [v1.0.3](https://github.com/BlameButton/laravel-changelog/compare/v1.0.2...v1.0.3) - 2021-11-05
17+
18+
### Fixed
19+
20+
- Filename is retrieved using the wrong key
921

1022
## [v1.0.2](https://github.com/BlameButton/laravel-changelog/compare/v1.0.1...v1.0.2) - 2021-11-05
1123

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ use BlameButton\Laravel\Changelog\ChangelogFacade;
2424
* Get the raw content of your changelog file.
2525
*/
2626
ChangelogFacade::raw();
27+
28+
/**
29+
* Get the HTML version of your changelog file.
30+
*/
31+
ChangelogFacade::html();
2732
```
2833

2934
### Testing
File renamed without changes.

src/Changelog.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,45 @@
33
namespace BlameButton\Laravel\Changelog;
44

55
use BlameButton\Laravel\Changelog\Exceptions\ChangelogNotFoundException;
6-
use Illuminate\Support\Facades\Storage;
6+
use Illuminate\Mail\Markdown;
7+
use Illuminate\Support\HtmlString;
78

89
class Changelog
910
{
10-
private function getFile(): string
11+
/**
12+
* Get the location of the changelog file.
13+
*
14+
* @return string
15+
*/
16+
public function path(): string
1117
{
12-
return config('config.file', base_path('CHANGELOG.md'));
18+
return config('changelog.file', base_path('CHANGELOG.md'));
1319
}
1420

21+
/**
22+
* Get the raw content of the changelog.
23+
*
24+
* @return string
25+
* @throws ChangelogNotFoundException when the changelog file can not be found.
26+
*/
1527
public function raw(): string
1628
{
17-
$file = $this->getFile();
29+
$file = $this->path();
1830

19-
if (! Storage::exists($file)) {
31+
if (! file_exists($file)) {
2032
throw new ChangelogNotFoundException();
2133
}
2234

23-
return Storage::get($file);
35+
return file_get_contents($file);
36+
}
37+
38+
/**
39+
* Generate a HTML version of your changelog.
40+
*
41+
* @return HtmlString
42+
*/
43+
public function html(): HtmlString
44+
{
45+
return Markdown::parse($this->raw());
2446
}
2547
}

src/ChangelogServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function boot()
2121

2222
if ($this->app->runningInConsole()) {
2323
$this->publishes([
24-
__DIR__.'/../config/config.php' => config_path('changelog.php'),
24+
__DIR__ . '/../config/changelog.php' => config_path('changelog.php'),
2525
], 'config');
2626

2727
// Publishing the views.
@@ -50,7 +50,7 @@ public function boot()
5050
public function register()
5151
{
5252
// Automatically apply the package configuration
53-
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'changelog');
53+
$this->mergeConfigFrom(__DIR__ . '/../config/changelog.php', 'changelog');
5454

5555
// Register the main class to use with the facade
5656
$this->app->singleton('changelog', function () {

tests/ChangelogTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace BlameButton\Laravel\Changelog\Tests;
44

5-
use BlameButton\Laravel\Changelog\ChangelogFacade;
5+
use BlameButton\Laravel\Changelog\Changelog;
66
use BlameButton\Laravel\Changelog\ChangelogServiceProvider;
77
use Illuminate\Support\Facades\Storage;
8+
use Mockery\MockInterface;
89
use Orchestra\Testbench\TestCase;
910

1011
class ChangelogTest extends TestCase
@@ -29,7 +30,13 @@ public function testRaw(): void
2930

3031
Storage::put(base_path('CHANGELOG.md'), $expected);
3132

32-
$content = ChangelogFacade::raw();
33+
/** @var Changelog $changelog */
34+
$changelog = $this->mock(Changelog::class, function (MockInterface $mock) {
35+
$mock->shouldReceive('path')->andReturn(Storage::path(base_path('CHANGELOG.md')));
36+
$mock->shouldReceive('raw')->passthru();
37+
});
38+
39+
$content = $changelog->raw();
3340

3441
self::assertNotNull($content);
3542
self::assertEquals($expected, $content);

0 commit comments

Comments
 (0)