forked from consolidation/robo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboFile.php
104 lines (91 loc) · 3.21 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
class Robofile
{
use Robo\Output;
use Robo\Task\GitHub;
use Robo\Task\Development;
use Robo\Task\Watch;
use Robo\Task\Git;
use Robo\Task\FileSystem;
use Robo\Task\Composer;
use Robo\Task\PhpServer;
use Robo\Task\SymfonyCommand;
use Robo\Task\Exec;
use Robo\Task\PackPhar;
public function release()
{
$this->say("Releasing Robo");
$changelog = $this->taskChangelog()
->version(\Robo\Runner::VERSION)
->askForChanges()
->run();
if (!$changelog->wasSuccessful()) exit(1);
$this->taskGit()
->add('CHANGELOG.md')
->commit('updated changelog')
->push()
->run();
$this->taskGitHubRelease(\Robo\Runner::VERSION)
->uri('Codegyre/Robo')
->askDescription()
->changes($changelog->getData())
->run();
}
public function added($addition)
{
$this->taskChangelog()
->version(\Robo\Runner::VERSION)
->change($addition)
->run();
}
public function versionBump($version = null)
{
if (!$version) {
$versionParts = explode('.', \Robo\Runner::VERSION);
$versionParts[count($versionParts)-1]++;
$version = implode('.', $versionParts);
}
$this->taskReplaceInFile(__DIR__.'/src/Runner.php')
->from("VERSION = '".\Robo\Runner::VERSION."'")
->to("VERSION = '".$version."'")
->run();
}
// publish docs
public function docs()
{
$docs = [];
foreach (get_declared_classes() as $task) {
if (!preg_match('~Robo\\\Task.*?Task$~', $task)) continue;
$docs[basename((new ReflectionClass($task))->getFileName(),'.php')][] = $task;
}
ksort($docs);
$taskGenerator = $this->taskGenDoc('docs/tasks.md')->filterClasses(function (\ReflectionClass $r) {
return !$r->isAbstract() or $r->isTrait();
})->prepend("# Tasks");
foreach ($docs as $file => $classes) {
$taskGenerator->docClass("Robo\\Task\\$file");
foreach ($classes as $task) {
$taskGenerator->docClass($task);
}
}
$taskGenerator->filterMethods(function(\ReflectionMethod $m) {
if ($m->isConstructor() or $m->isDestructor()) return false;
return $m->name != 'run' and $m->name != '__call' and $m->isPublic(); // methods are not documented
})->processMethod(function (\ReflectionMethod $m, $text) {
return "* " . $m->name . '('.implode(', ', $m->getParameters()).")\n";
})->processClass(function(\ReflectionClass $refl, $text) {
$text = str_replace("@method ".$refl->getShortName(),'*',$text);
if ($refl->isTrait()) {
return "## ".$refl->getShortName()."\n\n``` use ".$refl->getName().";```\n$text";
} else {
return "### ".$refl->getShortName()."\n".$text;
}
})->run();
}
public function watch()
{
$this->taskWatch()->monitor('composer.json', function() {
$this->taskComposerUpdate()->run();
})->run();
}
}