markdown-resume/pakefile

114 lines
3.2 KiB
Plaintext
Raw Normal View History

<?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 Markdown Resume Builder version " . $composer->version . "\n";
echo str_repeat("=", 80) . "\n";
}
function run_version_file() {
// Find the latest tag
$version = trim(shell_exec('git describe --abbrev=0 --tags'));
// Write it to the version file for the self update command
file_put_contents('./version', $version);
// Write it to the composer.json file as well
$config = json_decode(file_get_contents('composer.json'));
$config->version = $version;
file_put_contents('composer.json', json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
function run_lint() {
echo "\n * Linting files\n";
passthru("./build/lint -R ./src");
}
function run_phar()
{
echo " * Construction phar and moving to ./bin/md2resume\n";
$command =
'rm -f ./bin/md2resume && rm -f ./bin/md2resume.phar &&'
. 'php -dphar.readonly=0 build/empir make ./bin/md2resume.phar md2resume_dev.php . --exclude="'
. '*.git/*|*.gitignore|*test*|*Tests*|*.md|*/doc/*|*.lock|*token.txt|pakefile'
. '|.*|build/*|*.markdown|*.phar|*LICENSE|*AUTHORS|*CHANGELOG|*.dist|*.tpl|.travis.yml'
. '|*squizlabs*|*fabpot*'
. '" && chmod a+x ./bin/md2resume.phar'
. ' && mv ./bin/md2resume.phar ./bin/md2resume';
passthru($command);
}
function run_sniff()
{
echo " * Checking files for PSR2\n";
passthru("./vendor/bin/phpcs -p --standard=PSR2 ./src/ ./md2resume_dev.php");
}
function run_fixer()
{
echo "\n * Running php-cs-fixer\n";
passthru(
"./vendor/bin/php-cs-fixer fix ./md2resume_dev.php"
. " && ./vendor/bin/php-cs-fixer fix ./src/Resume/Cli/"
. " && ./vendor/bin/php-cs-fixer fix ./src/Resume/Command/"
);
}
function run_readme()
{
echo " * Updating README documentation\n";
$startPoint = '## Help';
$endPoint = '## Examples';
$readme = file_get_contents("README.md");
$help = shell_exec("php ./md2resume_dev.php list --no-interaction");
$output = preg_replace(
'/('.preg_quote($startPoint).')(.*)('.preg_quote($endPoint).')/si',
"$1\n```\n" . $help . "\n```\n$3",
$readme
);
file_put_contents("README.md", $output);
}
function run_mv() {
exec('cp ./bin/md2resume ~/bin/md2resume');
}
/* End of pakefile */