-
Notifications
You must be signed in to change notification settings - Fork 4
/
pakefile
115 lines (90 loc) · 2.85 KB
/
pakefile
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
105
106
107
108
109
110
111
112
113
114
115
<?php
pake_desc('Run the unit tests');
pake_task('test');
pake_desc('Check the code for psr2 standards');
pake_task('sniff');
pake_desc('Run php-cs-fixer on the src directory');
pake_task('fixer');
pake_desc('Update the README with the latest command output');
pake_task('readme');
pake_desc('Build phar file');
pake_task('phar');
pake_desc('PHP Lint the src folder');
pake_task('lint');
pake_desc('Display the version');
pake_task('version');
pake_desc('Create the selfupdate version file');
pake_task('version_file');
pake_desc('Copy to ~/bin');
pake_task('mv');
pake_desc('Build the app for deployment');
pake_task('build', 'version', 'version_file', 'readme', 'lint', 'fixer', 'sniff', 'phar');
pake_alias('default', 'build');
function run_build() {}
function run_test() {
passthru("phpunit");
}
function run_version() {
$composer = json_decode(file_get_contents('composer.json'));
echo "\n Building FogBugz Command Line Client version " . $composer->version . "\n";
echo str_repeat("=", 80) . "\n";
}
function run_version_file() {
$composer = json_decode(file_get_contents('composer.json'));
file_put_contents('./version', $composer->version);
}
function run_lint() {
echo "\n * Linting files\n";
passthru("./build/lint -R ./src");
}
function run_phar()
{
echo " * Construction phar and moving to fb\n";
$command =
'rm -f fb && rm -f fb.phar &&'
. 'php -dphar.readonly=0 build/empir make fb.phar working.php . --exclude="'
. '*.git/*|*.gitignore|*test*|*Tests*|*.md|*/doc/*|*.lock|*token.txt|pakefile'
. '|.*|build/*|*.markdown|*.phar|*LICENSE|*AUTHORS|*CHANGELOG|*.dist|*.tpl'
. '" && chmod a+x fb.phar'
. ' && mv fb.phar fb';
passthru($command);
}
function run_sniff()
{
echo " * Checking files for PSR2\n";
passthru("phpcs -p --standard=PSR2 ./src/ ./working.php");
}
function run_fixer()
{
echo "\n * Running php-cs-fixer\n";
passthru(
"php-cs-fixer fix ./working.php"
. " && php-cs-fixer fix ./src/FogBugz/Cli/"
. " && php-cs-fixer fix ./src/FogBugz/Command/"
);
}
function run_readme()
{
echo " * Updating README documentation\n";
$readme = file("README.md");
$help = explode("\n", shell_exec("php ./working.php list --no-interaction"));
$helpStart = $helpEnd = 0;
foreach ($readme as $lineNumber => $line) {
if (trim($line) == "## Help") {
$helpStart = $lineNumber;
continue;
}
if ($helpStart && (substr(trim($line), 0, 2) == "##")) {
$helpEnd = $lineNumber;
break;
}
}
$output = join(array_slice($readme, 0, $helpStart + 1));
$output .= "\n " . implode("\n ", $help) . "\n";
$output .= join(array_slice($readme, $helpEnd));
file_put_contents("README.md", $output);
}
function run_mv() {
exec('cp ./fb ~/bin/fb');
}
/* End of pakefile */