1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Changelog keeper |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/chkipper |
6
|
|
|
* @package chkipper |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hiqdev\chkipper\console; |
12
|
|
|
|
13
|
|
|
use Exception; |
14
|
|
|
use hiqdev\chkipper\changelog\MarkdownRenderer as ChangelogMarkdownRenderer; |
15
|
|
|
use hiqdev\chkipper\helpers\File; |
16
|
|
|
use hiqdev\chkipper\history\GitLogParser; |
17
|
|
|
use hiqdev\chkipper\history\MarkdownParser; |
18
|
|
|
use hiqdev\chkipper\history\MarkdownRenderer; |
19
|
|
|
use Yii; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Bump Controller. |
23
|
|
|
* |
24
|
|
|
* @author Andrii Vasyliev <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class BumpController extends \yii\console\Controller |
27
|
|
|
{ |
28
|
|
|
public function actionIndex($version = null) |
29
|
|
|
{ |
30
|
|
|
$config = Yii::$app->config; |
31
|
|
|
$historyFile = $config->historyFile; |
32
|
|
|
$changelogFile = $config->changelogFile; |
33
|
|
|
$parser = Yii::createObject(MarkdownParser::class); |
34
|
|
|
$history = $parser->parsePath($historyFile); |
35
|
|
|
$gitlog = Yii::createObject(GitLogParser::class); |
36
|
|
|
$gitlog->parseGitLog(); |
37
|
|
|
$history->merge($gitlog->getHistory(), true); |
38
|
|
|
$history->normalize(); |
39
|
|
|
|
40
|
|
|
if ($version) { |
41
|
|
|
if ($version === 'dev') { |
42
|
|
|
$version = $history->lastTag; |
43
|
|
|
} |
44
|
|
|
$history->setFirstTag($version); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$historyRenderer = Yii::createObject(MarkdownRenderer::class); |
48
|
|
|
$changelogRenderer = Yii::createObject(ChangelogMarkdownRenderer::class); |
49
|
|
|
File::write($historyFile, $historyRenderer->render($history)); |
50
|
|
|
File::write($changelogFile, $changelogRenderer->render($history)); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function actionParse($path) |
54
|
|
|
{ |
55
|
|
|
if (!file_exists($path)) { |
56
|
|
|
throw new Exception('wrong path: ' . $path); |
57
|
|
|
} |
58
|
|
|
$parser = new MarkdownParser(); |
|
|
|
|
59
|
|
|
$history = $parser->parsePath($path); |
60
|
|
|
var_dump($history->getTags()); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check looks for function calls that miss required arguments.