Remove legacy phar file build and update composer tooling (#63)

Simplify the build tooling:
* Remove phar build, update tooling to composer
* Remove legacy version tagging system
* Fix incorrect readme generation
This commit is contained in:
Craig Davis 2017-10-19 16:42:54 -07:00 committed by GitHub
parent b687052273
commit 1686262960
14 changed files with 230 additions and 1019 deletions

View File

@ -9,4 +9,4 @@ install:
- travis_retry composer install --prefer-source --no-interaction --dev
script:
- ./vendor/bin/pake test
- composer test

View File

@ -15,6 +15,14 @@ at the [blog post for the project][blog].
* You can now version control and branch your resume.
## Install
#### OSX
The simplest installation of the requirements is via [Homebrew Cask](https://caskroom.github.io/)
```bash
brew cask install wkhtmltopdf
```
#### Debian
```bash
sudo apt install php7.0-mbstring wkhtmltopdf
@ -27,8 +35,6 @@ sudo dnf install php-mbstring wkhtmltopdf
## Quickstart
There is no installation or need to run composer. Just download and [run the phar file](https://github.com/there4/markdown-resume/raw/master/bin/md2resume):
```
./bin/md2resume html examples/source/sample.md examples/output/
./bin/md2resume pdf examples/source/sample.md examples/output/
@ -36,7 +42,7 @@ sudo dnf install php-mbstring wkhtmltopdf
## Help
```
Markdown Resume Generator version 2.0.10 by Craig Davis
Markdown Resume Generator version 2.1.0 by Craig Davis
Usage:
[options] command [arguments]
@ -51,14 +57,13 @@ Options:
--no-interaction -n Do not ask any interactive question.
Available commands:
help Displays help for a command
html Generate an HTML resume from a markdown file
list Lists commands
pdf Generate a PDF from a markdown file
selfupdate Updates md2resume.phar to the latest version.
stats Generate a word frequency analysis of your resume
templates List available templates
version Show current version information
help Displays help for a command
html Generate an HTML resume from a markdown file
list Lists commands
pdf Generate a PDF from a markdown file
stats Generate a word frequency analysis of your resume
templates List available templates
version Show current version information
```
## Examples
@ -89,15 +94,8 @@ and then use CSS rules to display a nicely formatted resume. Note that because
we have very few ways to nest or identify elements that many of the css rules
are based on descendant and adjacent selectors.
__PLEASE NOTE__: The templates are compiled into the phar archive in the `./bin`
folder. If you intend to edit the templates or add new ones, you'll need to run
this application in the dev mode. See below for more information about doing
this.
## Feature Development
The application is deployed as a compiled phar file. In order to add new
commands, you'll need to first install the dependencies:
In order to add new commands, you'll need to first install the dependencies:
* `composer install`
@ -105,16 +103,10 @@ After that, you can run the `md2resume_dev.php` file from the command line.
## Building a Release
1. Tag the repo with the new build number. This will be picked up for both
the `version` file used by the self update command and placed into the
phar file.
2. Run `pake build`.
1. Tag the repo with the new build number.
2. Run `composer build`.
3. Push both the tag and the code.
Check out the pake tooling for more information about the build. Pake will be
installed to `./vendor/bin/pake`. So for instance a complete phar file build
looks like `./vendor/bin/pake build`.
## Acknowledgments
The initial inspiration is from the [Sample Resume Template][srt].
@ -124,6 +116,7 @@ are a more comfortable with html than markdown, you should use it.
## Changelog
* __2.2.0__ : Dropped phar file distribution, removed Pake and migrated to composer commands
* __2.1.0__ : Dropped PHP5 support
* __2.0.12__ : Added new `Roboto` template from [@ejwaibel](https://github.com/ejwaibel)
* __2.0.10__ : Updated spacing in moder template with commites from [@501st-alpha1](https://github.com/501st-alpha1)
@ -157,3 +150,4 @@ are a more comfortable with html than markdown, you should use it.
[pake]: https://github.com/indeyets/pake/wiki/Installing-Pake
[wkhtmltopdf]: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF
[console]: http://symfony.com/doc/current/components/console/introduction.html
HELLO

Binary file not shown.

View File

@ -1,496 +0,0 @@
#!/usr/bin/env php
<?php
/*
* Empir
*
Copyright (c) 2010 Jeremy Perret <j.perret.27@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
//if colors make any damages on your terminal deactivate them by setting to false this option
define('ACTIVATE_COLORS', true);
//only run Empir automatically when this file is called directly from the command line
if (isset($argv[0])) {
if (version_compare(phpversion(), '5.3.0', '<')) {
echo "ERROR: Empir require php >= 5.3.0 (Your PHP version: ".phpversion().")\n";
exit(1);
}
$empir = new Empir($argv);
exit($empir->run());
}
/**
* Command line interface Helper.
*
* @package Empir
* @author Jeremy Perret <j.perret.27@gmail.com>
*/
class CLI_Interface
{
protected function execCommand()
{
if (isset($this->commands[$this->command])) {
$method = $this->commands[$this->command];
$rcode = $this->$method();
}else
$rcode = $this->error("Command <$this->command> doesn't exist. Try <help>");
return ($rcode == null) ? 0 : $rcode;
}
protected function gopt($no)
{
if(isset($this->options[$no]))
return $this->options[$no];
return null;
}
protected function glopt($opt)
{
foreach ($this->options as $option) {
if(strpos($option, "--$opt=") !== false)
return trim(end(explode('=', $option)), '"');
}
return null;
}
protected function reqopt($no, $name)
{
if($this->gopt($no) == null)
exit($this->error("Param $name is required. Try <help>"));
return $this->gopt($no);
}
protected function error($message = '', $errno = 1)
{
if($message != '')
echo Color::str("ERROR: $message\n", Empir::ERR_COLOR);
return $errno;
}
protected function success($message)
{
echo Color::str("$message\n", Empir::SUCCESS_COLOR);
}
protected function makeAbsolut($path='')
{
$current = getcwd().'/';
if($path == "" || $path == false)
$absolut_path = $current;
elseif(substr($path, 0, 2) == './')
$absolut_path = $current.substr($path,2);
elseif(strpos($path, ':') !== false || substr($path, 0, 2) == '\\\\' || substr($path, 0, 1) == '/')
$absolut_path = $path;
else
$absolut_path = $current.$path;
$absolut_path = str_replace('\\', '/', $absolut_path);
$absolut_path = rtrim($absolut_path, '/');
return $absolut_path;
}
private function find_opt($opt)
{
}
}
/**
* Manage phar
*
* @package Empir
* @author Jeremy Perret <j.perret.27@gmail.com>
*/
class Empir extends CLI_Interface
{
const VERSION = '1.0.0';
const ERR_COLOR = 'red';
const HELP_COLOR = 'green';
const PARAM_COLOR = 'purple';
const SUCCESS_COLOR = 'green';
public $options = array();
public $command;
public $commands = array(
'help' => 'help',
'?' => 'help',
'-h' => 'help',
'make' => 'make',
'convert' => 'convert',
'extract' => 'extract'
);
public $compression_types = array('gz', 'bz2', 'no');
public $format_types = array('phar', 'tar', 'zip');
public function __construct($argv)
{
$this->options = array_slice($argv, 1);
$vars = array(
'gz' => array(
'name' => 'gz',
'extension' => 'zlib',
'mime' => '.gz',
'int_value' => Phar::GZ,
),
'bz2' => array(
'name' => 'bz2',
'extension' => 'bzip2',
'mime' => '.bz2',
'int_value' => Phar::BZ2,
),
'no' => array(
'name' => 'no',
'extension' => 'not',
'mime' => '',
'int_value' => Phar::NONE,
),
'phar' => array(
'name' => 'phar',
'mime' => '.phar',
'int_value' => Phar::PHAR,
'compression' => true
),
'tar' => array(
'name' => 'tar',
'mime' => '.tar',
'int_value' => Phar::TAR,
'compression' => true
),
'zip' => array(
'name' => 'zip',
'mime' => '.zip',
'int_value' => Phar::ZIP,
'compression' => false
)
);
foreach($vars as $name => $attrs)
$this->$name = $this->array_to_object($attrs);
}
public function run()
{
$this->command = ($this->gopt(0) != null) ? $this->gopt(0) : 'help';
$this->options = array_slice($this->options, 1);
return $this->execCommand();
}
public function make()
{
$this->_is_phar_writable();
$phar = $this->makeAbsolut($this->reqopt(0, 'phar filename'));
$phar_name = end(explode('/', $phar));
$stub_file = trim($this->reqopt(1, 'stub file'), '/');
$root_app = $this->makeAbsolut($this->reqopt(2, 'root dir of your app'));
$_compression = $this->glopt('compress') ?: 'no';
$_format = $this->glopt('format') ?: 'phar';
$_exclude = $this->glopt('exclude');
$_fexclude = $this->glopt('fexclude');
if(!file_exists($root_app)) return $this->error("Root dir of your app doesn't exist.");
if(!empty($_compression) && !in_array($_compression, $this->compression_types)) return $this->error("Unrecognized compression: $_compression");
if(!empty($_format) && !in_array($_format, $this->format_types)) return $this->error("Unrecognized format: $_format");
if (!empty($_fexclude)) {
$_fexclude = $this->makeAbsolut($_fexclude);
if(!file_exists($_fexclude)) return $this->error("Exclude file: $_fexclude not found.");
$_fexclude = file_get_contents($_fexclude);
}
$shell_masks = explode('|', $_exclude);
$shell_masks = array_merge($shell_masks, explode("\n", $_fexclude));
$c = $this->get_var($_compression);
$f = $this->get_var($_format);
if (file_exists($phar)) {
unlink($phar);
}
try {
$p = new Phar($phar, Phar::CURRENT_AS_FILEINFO | Phar::KEY_AS_FILENAME, $phar_name);
echo "Make $phar_name : \n===================\n";
$project = json_decode(file_get_contents('composer.json'));
$p->setStub(
"#!/usr/bin/env php \n"
. "<?php\n"
. 'define("IN_PHAR", true);' . "\n"
. '$project = (object) array(' . "\n"
. " 'description' => '$project->description', " . "\n"
. " 'version' => '$project->version'," . "\n"
. " 'selfupdatepath' => '$project->selfupdatepath'," . "\n"
. " 'selfupdateversion' => '$project->selfupdateversion'," . "\n"
. ");" . "\n"
. "Phar::mapPhar(); " . "\n"
. "include 'phar://".$phar_name."/".$stub_file."'; " . "\n"
. "__HALT_COMPILER(); " . "\n"
. "?>" . "\n"
);
$files = $this->_scandir($root_app);
$i=0;
foreach ($files as $file) {
$file_buff = $file;
$file = str_replace('\\', '/', $file);
$file = str_replace($root_app.'/', '', $file);
if (!$this->_exclude($file, $shell_masks) && !$this->_exclude($file, array('*/'.$phar_name, $phar_name))) {
echo "add $file\n";
//$p[$file] = php_strip_whitespace($file_buff);
$p[$file] = file_get_contents($file_buff);
$i++;
}
}
echo "\nTotal: $i files added\n";
if ($f->name == 'phar' && $c->name='no') {
$this->success("CREATE $phar");
return;
}
if(!Phar::canCompress($c->int_value)) return $this->error("Unable to compress the phar with $c->name, extension $c->extension not found. But $phar is created.");
if(!$f->compression) $c->int_value = Phar::NONE;
$phar_copy = $phar.$f->mime.$c->mime;
@unlink($phar_copy);
$p = $p->convertToExecutable($f->int_value, $c->int_value);
$this->success("CREATE $phar_copy");
@unlink($phar);
} catch (Exception $e) {
return $this->error($e->getMessage());
}
}
public function help()
{
$help = new Help();
$command = $this->gopt(0);
if(empty($command)) return $help->main();
switch ($command) {
case 'make': $help->make(); break;
default: return $this->error("Command: $command doesn't exist."); break;
}
}
private function _is_phar_writable()
{
if(!Phar::canWrite()) exit($this->error("Unable to write phar, phar.readonly must be set to zero in your php.ini otherwise use: $ php -dphar.readonly=0 empir <command> ..."));
}
private function get_var($var)
{
if (is_string($var)) {
if(isset($this->$var))
return $this->$var;
} else {
foreach (array_merge($this->compression_types, $this->format_types) as $v) {
if($this->$v->int_value == $var)
return $this->$v;
}
}
}
private function _exclude($file, $shell_masks)
{
if (!empty($shell_masks)) {
foreach ($shell_masks as $mask) {
if(fnmatch(trim($mask), $file))
return true;
}
}
return false;
}
private function _scandir($path)
{
$items = array();
$path = rtrim($path, '/');
if (!$current_dir = opendir($path))
return $items;
while (false !== ($filename = readdir($current_dir))) {
if ($filename != "." && $filename != "..") {
if (is_dir($path.'/'.$filename)) {
$items = array_merge($items, $this->_scandir($path.'/'.$filename));
} else
$items[] = $path.'/'.$filename;
}
}
closedir($current_dir);
return $items;
}
private function array_to_object($array)
{
$object = new stdClass();
foreach ($array as $name => $value) {
$name = strtolower(trim($name));
if (!empty($name))
$object->$name = $value;
}
return $object;
}
}
/**
* Colorizer
*
* @package Empir
* @author Jeremy Perret <j.perret.27@gmail.com>
*/
class Color
{
public static $foreground_colors = array(
'black' => '0;30',
'dark_gray' => '1;30',
'blue' => '0;34',
'light_blue' => '1;34',
'green' => '0;32',
'light_green' => '1;32',
'cyan' => '0;36',
'light_cyan' => '1;36',
'red' => '0;31',
'light_red' => '1;31',
'purple' => '0;35',
'light_purple' => '1;35',
'brown' => '0;33',
'yellow' => '1;33',
'light_gray' => '0;37',
'white' => '1;37'
);
public static $background_colors = array(
'black' => '40',
'red' => '41',
'green' => '42',
'yellow' => '43',
'blue' => '44',
'magenta' => '45',
'cyan' => '46',
'light_gray' => '47'
);
public static function str($string, $foreground_color = null, $background_color = null)
{
if(!self::isTermSupportColor()) return $string;
$colored_string = "";
if (isset(self::$foreground_colors[$foreground_color])) {
$colored_string .= "\033[".self::$foreground_colors[$foreground_color]."m";
}
if (isset(self::$background_colors[$background_color])) {
$colored_string .= "\033[".self::$background_colors[$background_color]."m";
}
$colored_string .= $string."\033[0m";
return $colored_string;
}
public static function random($string)
{
$index_foreground = array_rand(self::$foreground_colors, 1);
$index_background= array_rand(self::$background_colors, 1);
return self::str($string, $index_foreground, $index_background);
}
public static function isTermSupportColor()
{
$term = getenv('TERM');
if($term && ACTIVATE_COLORS) return true;
return false;
}
}
/**
* All differents helps.
*
* @package Empir
* @author Jeremy Perret <j.perret.27@gmail.com>
*/
class Help
{
public function main()
{
echo "Empir v".Empir::VERSION." 2010 (c) Jeremy Perret <j.perret.27@gmail.com>
Empir is a php tool to manage phar.
The setting phar.readonly must be 0 in your php.ini,
otherwise use $ php -dphar.readonly=0 empir <command> ...
If you use Empir from PEAR installation don't care about this php option,
it used directly in the executable file.
".Color::str('Usage', Empir::HELP_COLOR).":
$ php empir <command> <parameters> [options]
".Color::str('Commands', Empir::HELP_COLOR).":
".Color::str('make', Empir::PARAM_COLOR)." Create a phar from an entire php application.
For more help on a command use 'empir help <command>'
";
}
public function make()
{
echo "Command make allows to create a phar file from an entire php application from its root directory.
".Color::str('Usage', Empir::HELP_COLOR).":
$ php empir make <phar_file> <stub_file> <root_app> [options]
".Color::str('Parameters', Empir::HELP_COLOR).":
".Color::str('phar_file', Empir::PARAM_COLOR)." Phar file that will be created, accept absolute or relative path.
".Color::str('stub_file', Empir::PARAM_COLOR)." Bootstrap file of your application, from your root app folder.
".Color::str('root_app', Empir::PARAM_COLOR)." Root folder of your application, accept absolute or relative path.
".Color::str('Options', Empir::HELP_COLOR).":
".Color::str('--exclude=PATTERN', Empir::PARAM_COLOR)." Exclude files match PATTERN, seperate several patterns with a pipe.
".Color::str('--fexclude=FILE', Empir::PARAM_COLOR)." Exclude patterns listed in FILE. One pattern per line.
".Color::str('--format=FORMAT', Empir::PARAM_COLOR)." Special phar format, FORMAT can be tar or zip. Don't specify format to keep normal phar.
".Color::str('--compress=TYPE', Empir::PARAM_COLOR)." Specify the phar compression type. TYPE can be gz or bz2.
";
}
}

View File

@ -1,150 +0,0 @@
#!/usr/bin/php
<?php
// ===========
// = Globals =
// ===========
$count = 0; // total files checked
$errors = array();
$options = setOptions(array(
'quiet' => false,
'recurse' => false,
));
if ($options['quiet']) {
ob_start();
}
// =============
// = Scan path =
// =============
$files = getPipedFiles();
$path = $_SERVER['PWD']; // Default to execution directory
// Piped files present
if ($files) {
foreach ($files as $file) {
checkFile("$path/$file");
}
}
// Use arguments
else {
if ($_SERVER['argc'] > 1) {
$last = end($_SERVER['argv']);
if (substr($last, 0, 1) != '-') {
$path = $last; // snag last argument, if it wasn't an option switch
}
}
if (is_dir($path)) {
checkDirectoryContents($path);
}
elseif (is_file($path)) {
checkFile($path);
}
else {
echo "$path is not a file or directory.\n";
showHelp() AND exit(1);
}
}
if ($options['quiet']) {
ob_end_clean();
}
echo "\n$count files checked, " . count($errors) . ' errors.';
echo "\n", implode($errors,'');
function checkDirectoryContents($dir) {
global $options, $i, $errors, $count;
$contents = scandir($dir);
foreach($contents as $content) {
if ($content == '.' || $content == '..') {
continue;
}
$path = "$dir/$content";
// Recurse into directories
if (is_dir($path) && $options['recurse']) {
checkDirectoryContents($path);
} // if is_dir
else {
checkFile($path);
} // !is_dir
} // foreach
} // function checkDirectoryContents
function checkFile($path) {
global $count, $errors;
// echo "$path\n";
// Skip non-php files
if (substr($path, -4) != '.php') {
return false;
}
if (($count % 60 == 0)) {
echo "\n";
}
$error = `php -l $path 2>&1 1> /dev/null`;
if ($error) {
$errors[] = $error;
echo 'E';
}
else {
echo '.';
}
$count++;
}
function getPipedFiles() {
$files = array();
stream_set_blocking(STDIN,FALSE);
while ($line = trim(fgets(STDIN))) {
$files[] = $line;
}
return $files;
}
function setOptions($options) {
$args = array_keys(getopt('qRh', array('quiet', 'recursive', 'help')));
foreach ($args as $arg) {
switch ($arg) {
case 'q':
case 'quiet':
$options['quiet'] = true;
break;
case 'R':
case 'recursive':
$options['recurse'] = true;
break;
case 'h':
case 'help':
default:
showHelp() AND exit(0);
} // Switch
} // Foreach args
return $options;
} // function setOptions
function showHelp() {
echo <<<HELP
usage: lint [-qR] [path]
options:
-q, --quiet: disable verbose output
-R, --recursive: recurse into subdirectories
-h, --help: display this help screen
HELP;
return true;
}

20
build/update_readme.php Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php
/**
* Run the markdown resume and update the readme with the generated help
*/
$baseDir = dirname(__DIR__);
$startPoint = '## Help';
$endPoint = '## Examples';
$readme = file_get_contents('README.md');
$help = shell_exec('php '.$baseDir.'/bin/md2resume list --no-interaction');
$output = preg_replace(
'/('.preg_quote($startPoint).')(.*)('.preg_quote($endPoint).')/si',
"$1\n```\n" . $help . "\n```\n$3",
$readme
);
file_put_contents($baseDir.'/README.md', $output);
/* End of file updated_readme.php */

View File

@ -8,9 +8,6 @@
"html5"
],
"license": "MIT",
"version": "2.0.10",
"selfupdatepath": "://github.com/there4/markdown-resume/raw/master/bin/md2resume",
"selfupdateversion": "://github.com/there4/markdown-resume/raw/master/version",
"authors": [
{
"name": "Craig Davis",
@ -47,7 +44,6 @@
"minimum-stability": "dev",
"require": {
"php": ">=7.1",
"indeyets/pake": "~1.99",
"kriswallsmith/assetic": "1.1.2",
"leafo/lessphp": "v0.4.0",
"michelf/php-markdown": "1.4.0",
@ -66,6 +62,22 @@
],
"require-dev": {
"phpunit/phpunit": "^6.2",
"squizlabs/php_codesniffer": "^3.0@dev"
"squizlabs/php_codesniffer": "^3.0@dev",
"jakub-onderka/php-parallel-lint": "dev-master",
"jakub-onderka/php-console-highlighter": "dev-master"
},
"scripts": {
"build": [
"@lint",
"@format",
"@sniff",
"@test",
"@readme"
],
"lint": "vendor/bin/parallel-lint --exclude app --exclude vendor .",
"sniff": "vendor/bin/phpcs --standard=PSR2 -n --extensions=php src",
"format": "vendor/bin/phpcbf --standard=PSR2 --extensions=php src",
"readme": "build/update_readme.php",
"test": "vendor/bin/phpunit"
}
}

266
composer.lock generated
View File

@ -4,74 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "15554f44b07621461cf4609cdcfe6c8d",
"content-hash": "d37fc3196f27bfdaa99fe21fb0f7e3ab",
"packages": [
{
"name": "indeyets/pake",
"version": "1.99.3",
"source": {
"type": "git",
"url": "https://github.com/indeyets/pake.git",
"reference": "410d0d5c18bb3438d323570fdb502402aa7a1aba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/indeyets/pake/zipball/410d0d5c18bb3438d323570fdb502402aa7a1aba",
"reference": "410d0d5c18bb3438d323570fdb502402aa7a1aba",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.2.1"
},
"require-dev": {
"simpletest/simpletest": "1.1.*"
},
"suggest": {
"ext-bz2": "*",
"ext-pcntl": "*",
"ext-phar": "*",
"ext-posix": "*",
"ext-zlib": "*",
"phing/phing": "2.4.*",
"simpletest/simpletest": "1.1.*"
},
"bin": [
"bin/pake"
],
"type": "library",
"autoload": {
"files": [
"lib/pake/autoload.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien.potencier@symfony-project.org",
"homepage": "http://fabien.potencier.org/",
"role": "Developer"
},
{
"name": "Alexey Zakhlestin",
"email": "indeyets@gmail.com",
"homepage": "https://indeyets.ru/",
"role": "Developer"
}
],
"description": "PHP automation tool inspired by Rake",
"homepage": "https://github.com/indeyets/pake/wiki",
"keywords": [
"automation",
"build",
"task"
],
"time": "2013-11-04T08:29:46+00:00"
},
{
"name": "kriswallsmith/assetic",
"version": "v1.1.2",
@ -234,7 +168,7 @@
"scss",
"stylesheet"
],
"time": "2017-10-14 18:48:01"
"time": "2017-10-14T18:48:01+00:00"
},
{
"name": "michelf/php-markdown",
@ -587,7 +521,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2017-10-10 11:05:33"
"time": "2017-10-10T11:05:33+00:00"
},
{
"name": "symfony/filesystem",
@ -636,7 +570,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2017-10-02 08:46:46"
"time": "2017-10-02T08:46:46+00:00"
},
{
"name": "symfony/process",
@ -685,7 +619,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-10-01 21:00:16"
"time": "2017-10-01T21:00:16+00:00"
},
{
"name": "symfony/yaml",
@ -835,7 +769,143 @@
"constructor",
"instantiate"
],
"time": "2017-09-19 12:41:22"
"time": "2017-09-19T12:41:22+00:00"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Color.git",
"reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1",
"reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"jakub-onderka/php-code-style": "1.0",
"jakub-onderka/php-parallel-lint": "0.*",
"jakub-onderka/php-var-dump-check": "0.*",
"phpunit/phpunit": "3.7.*",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-0": {
"JakubOnderka\\PhpConsoleColor": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "jakub.onderka@gmail.com",
"homepage": "http://www.acci.cz"
}
],
"time": "2014-04-08T15:00:19+00:00"
},
{
"name": "jakub-onderka/php-console-highlighter",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git",
"reference": "014bfec858ada1b1334f9a4ca1f81a8090c1c327"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/014bfec858ada1b1334f9a4ca1f81a8090c1c327",
"reference": "014bfec858ada1b1334f9a4ca1f81a8090c1c327",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"jakub-onderka/php-console-color": "~0.1",
"php": ">=5.3.0"
},
"require-dev": {
"jakub-onderka/php-code-style": "~1.0",
"jakub-onderka/php-parallel-lint": "~0.5",
"jakub-onderka/php-var-dump-check": "~0.1",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"autoload": {
"psr-4": {
"JakubOnderka\\PhpConsoleHighlighter\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "acci@acci.cz",
"homepage": "http://www.acci.cz/"
}
],
"time": "2017-01-30T18:30:32+00:00"
},
{
"name": "jakub-onderka/php-parallel-lint",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git",
"reference": "a5c54939792e87b1db67ff88ed657c6bef9db190"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/a5c54939792e87b1db67ff88ed657c6bef9db190",
"reference": "a5c54939792e87b1db67ff88ed657c6bef9db190",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"jakub-onderka/php-console-highlighter": "~0.3",
"nette/tester": "~1.3",
"squizlabs/php_codesniffer": "~2.7"
},
"suggest": {
"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"
},
"bin": [
"parallel-lint"
],
"type": "library",
"autoload": {
"classmap": [
"./"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "ahoj@jakubonderka.cz"
}
],
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
"time": "2017-05-27T10:22:07+00:00"
},
{
"name": "myclabs/deep-copy",
@ -880,7 +950,7 @@
"object",
"object graph"
],
"time": "2017-10-16 22:02:21"
"time": "2017-10-16T22:02:21+00:00"
},
{
"name": "phar-io/manifest",
@ -935,7 +1005,7 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"time": "2017-04-07 07:07:10"
"time": "2017-04-07T07:07:10+00:00"
},
{
"name": "phar-io/version",
@ -1036,7 +1106,7 @@
"reflection",
"static analysis"
],
"time": "2017-09-11 18:02:19"
"time": "2017-09-11T18:02:19+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -1191,7 +1261,7 @@
"spy",
"stub"
],
"time": "2017-09-04 11:05:03"
"time": "2017-09-04T11:05:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -1255,7 +1325,7 @@
"testing",
"xunit"
],
"time": "2017-08-25 06:32:04"
"time": "2017-08-25T06:32:04+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -1302,7 +1372,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03 07:40:28"
"time": "2016-10-03T07:40:28+00:00"
},
{
"name": "phpunit/php-text-template",
@ -1392,7 +1462,7 @@
"keywords": [
"timer"
],
"time": "2017-03-07 15:42:04"
"time": "2017-03-07T15:42:04+00:00"
},
{
"name": "phpunit/php-token-stream",
@ -1441,7 +1511,7 @@
"keywords": [
"tokenizer"
],
"time": "2017-08-20 05:47:52"
"time": "2017-08-20T05:47:52+00:00"
},
{
"name": "phpunit/phpunit",
@ -1525,7 +1595,7 @@
"testing",
"xunit"
],
"time": "2017-10-16 13:19:53"
"time": "2017-10-16T13:19:53+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -1584,7 +1654,7 @@
"mock",
"xunit"
],
"time": "2017-08-03 14:08:16"
"time": "2017-08-03T14:08:16+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -1629,7 +1699,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04 10:23:55"
"time": "2017-03-04T10:23:55+00:00"
},
{
"name": "sebastian/comparator",
@ -1693,7 +1763,7 @@
"compare",
"equality"
],
"time": "2017-10-16 04:35:48"
"time": "2017-10-16T04:35:48+00:00"
},
{
"name": "sebastian/diff",
@ -1745,7 +1815,7 @@
"keywords": [
"diff"
],
"time": "2017-10-05 13:24:46"
"time": "2017-10-05T13:24:46+00:00"
},
{
"name": "sebastian/environment",
@ -1795,7 +1865,7 @@
"environment",
"hhvm"
],
"time": "2017-07-01 08:51:00"
"time": "2017-07-01T08:51:00+00:00"
},
{
"name": "sebastian/exporter",
@ -1862,7 +1932,7 @@
"export",
"exporter"
],
"time": "2017-04-03 13:19:02"
"time": "2017-04-03T13:19:02+00:00"
},
{
"name": "sebastian/global-state",
@ -1913,7 +1983,7 @@
"keywords": [
"global state"
],
"time": "2017-04-27 15:39:26"
"time": "2017-04-27T15:39:26+00:00"
},
{
"name": "sebastian/object-enumerator",
@ -1960,7 +2030,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-08-03 12:35:26"
"time": "2017-08-03T12:35:26+00:00"
},
{
"name": "sebastian/object-reflector",
@ -2005,7 +2075,7 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"time": "2017-03-29 09:07:27"
"time": "2017-03-29T09:07:27+00:00"
},
{
"name": "sebastian/recursion-context",
@ -2058,7 +2128,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2017-03-07 15:09:59"
"time": "2017-03-07T15:09:59+00:00"
},
{
"name": "sebastian/resource-operations",
@ -2100,7 +2170,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2016-10-03 07:43:09"
"time": "2016-10-03T07:43:09+00:00"
},
{
"name": "sebastian/version",
@ -2143,7 +2213,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03 07:35:21"
"time": "2016-10-03T07:35:21+00:00"
},
{
"name": "squizlabs/php_codesniffer",
@ -2194,7 +2264,7 @@
"phpcs",
"standards"
],
"time": "2017-10-16 22:40:25"
"time": "2017-10-16T22:40:25+00:00"
},
{
"name": "theseer/tokenizer",
@ -2284,7 +2354,7 @@
"check",
"validate"
],
"time": "2016-11-23 20:04:41"
"time": "2016-11-23T20:04:41+00:00"
}
],
"aliases": [],
@ -2292,12 +2362,14 @@
"stability-flags": {
"symfony/event-dispatcher": 20,
"leafo/scssphp": 20,
"squizlabs/php_codesniffer": 20
"squizlabs/php_codesniffer": 20,
"jakub-onderka/php-parallel-lint": 20,
"jakub-onderka/php-console-highlighter": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.0"
"php": ">=7.1"
},
"platform-dev": []
}

View File

@ -1,32 +0,0 @@
<?php
error_reporting(E_ALL | E_STRICT);
// If the dependencies aren't installed, we have to bail and offer some help.
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
exit("\nPlease run `composer install` to install dependencies.\n\n");
}
// Bootstrap our application with the Composer autoloader
$app = include __DIR__ . '/vendor/autoload.php';
// Setup the namespace for our own namespace
$app->add('Resume', __DIR__ . '/src');
// Instantiate our Console application
$console = new Resume\Cli\Resume();
// If we're running from phar, we get these values from the stub
if (!defined('IN_PHAR')) {
$project = json_decode(file_get_contents(__DIR__ . '/composer.json'));
}
$templatePath = __DIR__ . '/templates';
$consoleTemplatePath = __DIR__ . '/src/Resume/Templates';
// Init the app with these params
$console->initialize($templatePath, $consoleTemplatePath, $project);
// Execute the console app.
$console->run();
/* End of resume.php */

121
pakefile
View File

@ -1,121 +0,0 @@
<?php
pake_desc('Run the unit tests');
pake_task('test');
pake_desc('Check the code for psr2 standards');
pake_task('sniff');
pake_desc('Run phpcbf 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()
{
// Used only for naming a string of dependencies.
}
function run_test()
{
pake_sh('./vendor/bin/phpunit', true);
}
function run_version()
{
$composer = json_decode(file_get_contents('composer.json'));
pake_echo_comment("Building Markdown Resume Builder version " . $composer->version);
}
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()
{
pake_echo_comment('Linting files');
pake_sh('./build/lint -R ./src', true);
}
function run_phar()
{
pake_echo_comment('Construction phar and moving to ./bin/md2resume');
$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';
pake_sh($command, true);
}
function run_sniff()
{
pake_echo_comment('Checking files for PSR2');
pake_sh('./vendor/bin/phpcs -p --standard=PSR2 ./src/ ./md2resume_dev.php', true);
}
function run_fixer()
{
pake_echo_comment('Running phpcbf');
pake_sh(
'./vendor/bin/phpcbf --standard=PSR2 ./md2resume_dev.php'
. ' && ./vendor/bin/phpcbf --standard=PSR2 ./src/Resume/Cli/'
. ' && ./vendor/bin/phpcbf --standard=PSR2 ./src/Resume/Command/',
true
);
}
function run_readme()
{
pake_echo_comment('Updating README documentation');
$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()
{
pake_sh('cp ./bin/md2resume ~/bin/md2resume', true);
}
/* End of pakefile */

View File

@ -18,8 +18,6 @@ class Resume extends Application
public function initialize($templatePath, $consoleTemplatePath, $project)
{
$runSetup = false;
// Add the composer information for use in version info and such.
$this->project = $project;
@ -40,7 +38,6 @@ class Resume extends Application
// Load our commands into the application
$this->add(new Command\HtmlCommand());
$this->add(new Command\PdfCommand());
$this->add(new Command\SelfUpdateCommand());
$this->add(new Command\StatsCommand());
$this->add(new Command\TemplatesCommand());
$this->add(new Command\VersionCommand());

View File

@ -1,86 +0,0 @@
<?php
namespace Resume\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SelfUpdateCommand extends Command
{
protected function configure()
{
$this
->setName('selfupdate')
->setDescription('Updates md2resume.phar to the latest version.')
->setHelp(
<<<EOT
The <info>self-update</info> command checks github for newer
versions of the command line client and if found, installs the latest.
EOT
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->app = $this->getApplication();
$localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
$tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar').'-temp.phar';
if (substr($localFilename, -4) === '.php') {
throw new \Exception('You must run this from the compiled phar file.');
}
// check for permissions in local filesystem before start connection process
if (!is_writable($tempDirectory = dirname($tempFilename))) {
throw new \Exception(
'Self update failed: the "' . $tempDirectory
. '" directory used to download the temp file could not be written'
);
}
if (!is_writable($localFilename)) {
throw new \Exception(
'Self update failed: the "' . $localFilename . '" file could not be written'
);
}
$protocol = extension_loaded('openssl') ? 'https' : 'http';
$latest = trim(file_get_contents($protocol . $this->app->project->selfupdateversion, false));
if ($this->app->project->version !== $latest) {
$output->writeln(sprintf("Updating to version <info>%s</info>.", $latest));
$remoteFilename = $protocol . $this->app->project->selfupdatepath;
$phar = file_get_contents($remoteFilename);
file_put_contents($tempFilename, $phar);
if (!file_exists($tempFilename)) {
$output->writeln('<error>The download of the new version failed for an unexpected reason</error>');
return 1;
}
try {
@chmod($tempFilename, 0777 & ~umask());
// test the phar validity
$phar = new \Phar($tempFilename);
// free the variable to unlock the file
unset($phar);
rename($tempFilename, $localFilename);
} catch (\Exception $e) {
@unlink($tempFilename);
if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
throw $e;
}
$output->writeln('<error>The download is corrupted ('.$e->getMessage().').</error>');
$output->writeln('<error>Please re-run the self-update command to try again.</error>');
}
} else {
$output->writeln("<info>You are using the latest version.</info>");
}
}
}
/* End of file SelfUpdateCommand.php */

View File

@ -15,6 +15,8 @@ class ResumeTest extends TestCase
$templatePath = realpath(__DIR__ . '/../templates/');
$consoleTemplatePath = realpath(__DIR__ . '/../src/Resume/Templates');
$project = json_decode(file_get_contents(__DIR__ . '/../composer.json'));
$project->version = 0;
$this->console = new Resume();
$this->console->initialize($templatePath, $consoleTemplatePath, $project);
}

View File

@ -1 +0,0 @@
2.0.10