Compare commits
39 Commits
0.2.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac145dad41 | ||
| 13c4e1baf8 | |||
| ac8c31e525 | |||
| b934c4b5db | |||
| 6f86885c4f | |||
| f1de0abfda | |||
| 5359a608c1 | |||
| d69799f5de | |||
| fcc9a80d50 | |||
| 582a82f3fc | |||
| c4f2bae3c2 | |||
| 0aa71f31b1 | |||
| 9f0b05cbe9 | |||
| 482beb7010 | |||
| 3ab5a91d64 | |||
| 8d456c8e18 | |||
| e9922e2016 | |||
| 3271cb65ba | |||
| 7cbbf2cd88 | |||
| d329257704 | |||
| 1d990608f0 | |||
| 77158e334e | |||
| 9fee520d5d | |||
| ca08a12386 | |||
| 8f5b174ea2 | |||
| e1ade971c7 | |||
| 58410759b5 | |||
| faceddec16 | |||
| 5a0e15d907 | |||
| a5329afd63 | |||
| 668bf757a4 | |||
| 8f01bf32a2 | |||
| bedfc8c559 | |||
| 4d91bd6bf5 | |||
| fa86042253 | |||
| 1159d0b62f | |||
| fa253e60d8 | |||
| 526dd97348 | |||
| fc96ef2f9a |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -12,3 +12,5 @@ Thumbs.db
|
||||
example/
|
||||
vendor/
|
||||
.env
|
||||
/.phpunit.result.cache
|
||||
/build/
|
||||
|
||||
1
app/conf/.gitignore
vendored
1
app/conf/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/dossier_dev.yaml
|
||||
/dossier_prod.yaml
|
||||
/dossier_test.yaml
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
### Settings file for magdev/dossier
|
||||
charset: utf-8
|
||||
docname: dossier
|
||||
|
||||
# Output settings
|
||||
output:
|
||||
path: _output
|
||||
docname: dossier
|
||||
|
||||
# Theme settings
|
||||
theme:
|
||||
start_template: document.html.twig
|
||||
|
||||
# Date formats
|
||||
date:
|
||||
|
||||
@@ -6,6 +6,9 @@ services:
|
||||
|
||||
config:
|
||||
class: '\Magdev\Dossier\Service\ConfigService'
|
||||
|
||||
system:
|
||||
class: '\Magdev\Dossier\Service\SystemService'
|
||||
|
||||
monolog:
|
||||
class: '\Magdev\Dossier\Service\MonologService'
|
||||
@@ -21,7 +24,7 @@ services:
|
||||
|
||||
git:
|
||||
class: '\Magdev\Dossier\Service\GitService'
|
||||
arguments: ['@config', '@monolog']
|
||||
arguments: ['@config', '@monolog', '@system']
|
||||
|
||||
translator:
|
||||
class: '\Magdev\Dossier\Service\TranslatorService'
|
||||
|
||||
2
bin/.gitignore
vendored
2
bin/.gitignore
vendored
@@ -3,3 +3,5 @@ lessc
|
||||
pscss
|
||||
.directory
|
||||
/phpca
|
||||
/phpunit
|
||||
/phing
|
||||
|
||||
@@ -27,19 +27,10 @@
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
require(dirname(__DIR__).'/src/bootstrap.php');
|
||||
define('DOSSIER_LOGO', 'DQogX19fX19fX18gICAgICAgICAgICAgICAgICAgICAgLl9fICAgICAgICAgICAgICANCiBcX19fX19fIFwgICBfX19fICBfX19fX18gX19fX198X198IF9fX19fX19fX19fIA0KICB8ICAgIHwgIFwgLyAgXyBcLyAgX19fLy8gIF9fXy8gIHwvIF9fIFxfICBfXyBcDQogIHwgICAgYCAgICggIDxfPiApX19fIFwgXF9fXyBcfCAgXCAgX19fL3wgIHwgXC8NCiAvX19fX19fXyAgL1xfX19fL19fX18gID5fX19fICA+X198XF9fXyAgPl9ffCAgIA0KICAgICAgICAgXC8gICAgICAgICAgIFwvICAgICBcLyAgICAgICAgXC8gICAgICAgDQo=');
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Command;
|
||||
|
||||
@@ -47,21 +38,21 @@ $app = new Application('dossier.phar', '1.0.0');
|
||||
$app->add(new Command\Dossier\DossierBuildCommand());
|
||||
$app->add(new Command\Dossier\DossierInitCommand());
|
||||
$app->add(new Command\Dossier\DossierStatusCommand());
|
||||
$app->add(new Command\Intro\IntroAddCommand());
|
||||
$app->add(new Command\Intro\IntroEditCommand());
|
||||
$app->add(new Command\Person\PersonAddCommand());
|
||||
$app->add(new Command\Person\PersonEditCommand());
|
||||
$app->add(new Command\Cv\CvAddCommand());
|
||||
$app->add(new Command\Cv\CvEditCommand());
|
||||
|
||||
$app->add(new Command\Create\CreateIntroCommand());
|
||||
$app->add(new Command\Create\CreatePersonCommand());
|
||||
$app->add(new Command\Create\CreateCvCommand());
|
||||
$app->add(new Command\Create\CreateProjectCommand());
|
||||
|
||||
$app->add(new Command\Config\ConfigShowCommand());
|
||||
$app->add(new Command\Config\ConfigGetCommand());
|
||||
$app->add(new Command\Config\ConfigSetCommand());
|
||||
$app->add(new Command\Config\ConfigUnsetCommand());
|
||||
$app->add(new Command\Theme\ThemeListCommand());
|
||||
$app->add(new Command\Theme\ThemeDumpCommand());
|
||||
|
||||
$app->add(new Command\Cache\CacheClearCommand());
|
||||
$app->add(new Command\Server\ServerStartCommand());
|
||||
$app->add(new Command\Dev\PharExtractCommand());
|
||||
|
||||
$app->run();
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "magdev/dossier",
|
||||
"type" : "project",
|
||||
"description" : "Create your dossier from Markdown files",
|
||||
"description" : "Create a personal dossier from Markdown files",
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Marco Grätsch",
|
||||
@@ -13,6 +13,12 @@
|
||||
"Magdev\\Dossier\\" : "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev" : {
|
||||
"psr-4" : {
|
||||
"Magdev\\DossierTests\\" : "tests"
|
||||
}
|
||||
},
|
||||
"minimum-stability" : "stable",
|
||||
"require" : {
|
||||
"php" : "~7.2",
|
||||
"ext-phar" : "*",
|
||||
@@ -28,17 +34,21 @@
|
||||
"symfony/event-dispatcher" : "^4.1",
|
||||
"symfony/process" : "^4.1",
|
||||
"symfony/dotenv" : "^4.1",
|
||||
"twig/twig" : "^2.4",
|
||||
"twig/twig" : "^3.11",
|
||||
"mnapoli/front-yaml" : "^1.6",
|
||||
"oyejorge/less.php" : "v1.7.0.14",
|
||||
"erusev/parsedown-extra" : "^0.7.1",
|
||||
"leafo/scssphp" : "^0.7.6",
|
||||
"adbario/php-dot-notation" : "^2.0",
|
||||
"magdev/console-form" : "^0.0.7",
|
||||
"magdev/console-form" : "dev-master",
|
||||
"monolog/monolog" : "^1.23",
|
||||
"pdfshift/pdfshift-php" : "~1.0.2",
|
||||
"raivisdejus/html-minifier" : "~0.5"
|
||||
},
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0",
|
||||
"phpunit/phpunit" : "~8.1"
|
||||
},
|
||||
"config" : {
|
||||
"bin-dir" : "bin"
|
||||
},
|
||||
@@ -58,14 +68,5 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"repositories" : [{
|
||||
"type" : "git",
|
||||
"url" : "git@github.com:magdev/console-form.git",
|
||||
"name" : "magdev/console-form"
|
||||
}
|
||||
],
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0"
|
||||
}
|
||||
}
|
||||
2300
composer.lock
generated
2300
composer.lock
generated
File diff suppressed because it is too large
Load Diff
21
phpunit.xml
Normal file
21
phpunit.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<phpunit
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="src/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="dossier">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<php>
|
||||
<env name="APP_ENV" value="test"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Cv;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -43,7 +43,7 @@ use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class CvAddCommand extends BaseCommand
|
||||
final class CreateCvCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* TheCV Form
|
||||
@@ -58,7 +58,7 @@ final class CvAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cv:add')
|
||||
$this->setName('create:cv')
|
||||
->setDescription('Write a new CV entry')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'Choose the name of the entry')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
@@ -72,7 +72,12 @@ final class CvAddCommand extends BaseCommand
|
||||
* @see \Magdev\Dossier\Command\BaseCommand::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
if (file_exists(PROJECT_ROOT.'/cv/'.$name.'.md')) {
|
||||
throw new \RuntimeException('File cv/'.$name.'.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')->getFormByName('form.cv', $input, $output);
|
||||
parent::initialize($input, $output);
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Intro;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -37,7 +37,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
final class IntroAddCommand extends BaseCommand
|
||||
final class CreateIntroCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The IntroForm
|
||||
@@ -52,7 +52,7 @@ final class IntroAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('intro:add')
|
||||
$this->setName('create:intro')
|
||||
->setDescription('Write the Intro page')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
@@ -68,6 +68,10 @@ final class IntroAddCommand extends BaseCommand
|
||||
{
|
||||
parent::initialize($input, $output);
|
||||
|
||||
if (file_exists(PROJECT_ROOT.'/intro.md')) {
|
||||
throw new \RuntimeException('File intro.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')
|
||||
->getFormByName('form.intro', $input, $output);
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Person;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -37,7 +37,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
final class PersonAddCommand extends BaseCommand
|
||||
final class CreatePersonCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The IntroForm
|
||||
@@ -52,7 +52,7 @@ final class PersonAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('person:add')
|
||||
$this->setName('create:person')
|
||||
->setDescription('Write the Person page')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
@@ -68,6 +68,10 @@ final class PersonAddCommand extends BaseCommand
|
||||
{
|
||||
parent::initialize($input, $output);
|
||||
|
||||
if (file_exists(PROJECT_ROOT.'/person.md')) {
|
||||
throw new \RuntimeException('File person.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')
|
||||
->getFormByName('form.person', $input, $output);
|
||||
129
src/Command/Create/CreateProjectCommand.php
Normal file
129
src/Command/Create/CreateProjectCommand.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
/**
|
||||
* Write a new project
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class CreateProjectCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* TheCV Form
|
||||
* @var \Magdev\Dossier\Form\Extension\Form
|
||||
*/
|
||||
protected $form = null;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('create:project')
|
||||
->setDescription('Write a new project file')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'Choose the name of the entry')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Command\BaseCommand::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
if (file_exists(PROJECT_ROOT.'/projects/'.$name.'.md')) {
|
||||
throw new \RuntimeException('File projects/'.$name.'.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')->getFormByName('form.project', $input, $output);
|
||||
parent::initialize($input, $output);
|
||||
} catch (FormException $fe) {
|
||||
throw new RuntimeException(get_class($fe).': '.$fe->getMessage(), $fe->getCode(), $fe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::interact()
|
||||
*/
|
||||
protected function interact(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->io->title($this->translator->trans('form.project.header.add'));
|
||||
$this->io->newLine();
|
||||
$this->form->process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if ($this->form->isProcessed()) {
|
||||
$markdown = $this->getService('markdown');
|
||||
/* @var $markdown \Magdev\Dossier\Service\MarkdownService */
|
||||
|
||||
try {
|
||||
$text = $this->form->stripData('text', '');
|
||||
$name = $input->getArgument('name');
|
||||
|
||||
$markdown->save(PROJECT_ROOT.'/projects/'.$name.'.md', $this->form->getResults(), $text, false);
|
||||
$this->io->success($this->translator->trans('message.write.success', array(
|
||||
'%name%' => 'Project/'.ucfirst($name)
|
||||
)));
|
||||
|
||||
if ($input->getOption('review') != false) {
|
||||
$this->getService('uri_helper')->openFileInEditor(PROJECT_ROOT.'/projects/'.$name.'.md');
|
||||
}
|
||||
} catch (FormException $fe) {
|
||||
throw new RuntimeException(get_class($fe).': '.$fe->getMessage(), $fe->getCode(), $fe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Cv;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
class CvEditCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cv:edit')
|
||||
->setDescription('Edit a CV entry in your default editor')
|
||||
->addArgument('file', InputArgument::REQUIRED, 'Filename of the entry w/o extension');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$file = PROJECT_ROOT.'/cv/'.$input->getArgument('file').'.md';
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ use Magdev\Dossier\Model\Intro;
|
||||
use Magdev\Dossier\Model\Letter;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use Magdev\Dossier\Util\DataCollector;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/**
|
||||
* Generate your dossier
|
||||
@@ -62,6 +63,7 @@ final class DossierBuildCommand extends BaseCommand
|
||||
->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'Set the locale', 'de')
|
||||
->addOption('sort', 's', InputOption::VALUE_OPTIONAL, 'Set the sort direction for the CV', CurriculumVitae::SORT_DESC)
|
||||
->addOption('theme', 't', InputOption::VALUE_OPTIONAL, 'Select the theme', 'print')
|
||||
->addOption('start-template', 'i', InputOption::VALUE_OPTIONAL, 'The name of the start-template', '')
|
||||
->addOption('docname', 'd', InputOption::VALUE_OPTIONAL, 'Set the name for the output document (w/o extension)', '')
|
||||
|
||||
->addOption('no-cover', null, InputOption::VALUE_NONE, 'Suppress the cover')
|
||||
@@ -97,6 +99,7 @@ final class DossierBuildCommand extends BaseCommand
|
||||
$cssproc = $this->getService('cssproc');
|
||||
/* @var $cssroc \Magdev\Dossier\Service\StylesheetProcessorService */
|
||||
|
||||
$startTemplate = $input->getOption('start-template') ?: $this->config->get('theme.start_template');
|
||||
$name = $input->getOption('docname') ?: $this->getService('git')->getCurrentBranchName();
|
||||
try {
|
||||
$data = new DataCollector(array(
|
||||
@@ -113,7 +116,7 @@ final class DossierBuildCommand extends BaseCommand
|
||||
$models = $this->getService('markdown')->getFileSet($input->getOption('sort'));
|
||||
$data->merge($models);
|
||||
|
||||
$outputFile = $tpl->render('document.html.twig', $data, PROJECT_ROOT.'/_output');
|
||||
$outputFile = $tpl->render($startTemplate, $data, PROJECT_ROOT.'/'.$this->config->get('output.path'));
|
||||
if ($input->getOption('pdf')) {
|
||||
$outputFile = $this->getService('pdf')->createPdf($outputFile);
|
||||
}
|
||||
|
||||
@@ -102,17 +102,17 @@ class DossierStatusCommand extends BaseCommand
|
||||
);
|
||||
$status[] = new TableSeparator();
|
||||
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $markdown->getDocument($file->getPathname());
|
||||
$entry = new Entry($document);
|
||||
$status[] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$status[$entry->getStartDate()->format('Ymd')] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$this->io->align($this->io->bool($entry->useInResume()), 9, DossierStyle::ALIGN_CENTER),
|
||||
$this->io->align($this->io->percent($analyzer->analyze($entry), $thresholds), 6, DossierStyle::ALIGN_RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
ksort($status);
|
||||
$this->io->table(array('Model', 'File',
|
||||
$this->io->align('In Resume', 9),
|
||||
$this->io->align('Status', 6, DossierStyle::ALIGN_RIGHT)
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Theme;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
/**
|
||||
* Create a local copy of a template
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class ThemeDumpCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* Phar helper service
|
||||
* @var \Magdev\Dossier\Service\PharHelperService
|
||||
*/
|
||||
private $pharHelper = null;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('theme:dump')
|
||||
->setDescription('Create a local copy of a theme')
|
||||
|
||||
->addArgument('theme', InputArgument::REQUIRED, 'The name of the theme')
|
||||
->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'Set the locale', 'de')
|
||||
->addOption('rename', 'r', InputOption::VALUE_OPTIONAL, 'Rename the theme', '')
|
||||
->addOption('output', 'o', InputOption::VALUE_OPTIONAL, 'Output folder', getenv('HOME').'/.dossier/tpl');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->pharHelper = $this->getService('phar_helper');
|
||||
|
||||
parent::initialize($input, $output);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$theme = $input->getArgument('theme');
|
||||
$outDir = $input->getOption('output');
|
||||
$newName = $input->getOption('rename');
|
||||
|
||||
$themeDir = 'app/tpl/'.$theme;
|
||||
$targetDir = !$newName ? $outDir.'/'.$theme : $outDir.'/'.$newName;
|
||||
$this->pharHelper->copyDir($themeDir, $targetDir);
|
||||
|
||||
$this->io->success($this->translator->trans('message.dump.success', array('%theme%' => $theme)));
|
||||
/*
|
||||
if ($outDir != getenv('HOME').'/.dossier/tpl') {
|
||||
$output->writeln('<fg=cyan> '.$this->translator->trans('message.export.template_dir').'</>');
|
||||
$output->writeln('<fg=blue> '.$this->translator->trans('message.export.code.template_environment', array('%path%' => $outDir)).'</>');
|
||||
} else {
|
||||
$output->writeln('<fg=cyan> '.$this->translator->trans('message.export.template_homedir').'</>');
|
||||
}*/
|
||||
$this->io->newLine();
|
||||
}
|
||||
}
|
||||
|
||||
77
src/Form/ProjectFormBuilder.php
Normal file
77
src/Form/ProjectFormBuilder.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Form;
|
||||
|
||||
use Magdev\Dossier\Form\Extension\Form;
|
||||
use Magdev\Dossier\Form\Field\SelectField;
|
||||
use Magdev\Dossier\Form\Field\TextField;
|
||||
use Magdev\Dossier\Form\Field\BooleanField;
|
||||
|
||||
/**
|
||||
* EntryFormBuilder
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class ProjectFormBuilder extends Base\BaseFormBuilder implements Base\FormBuilderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Droath\ConsoleForm\FormInterface::getName()
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'form.project';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Droath\ConsoleForm\FormInterface::buildForm()
|
||||
*/
|
||||
public function buildForm()
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setLabelPrefix($this->config->get('form.label.prefix'))
|
||||
->setLabelLength($this->config->get('form.label.length'))
|
||||
->addFormLoadCallback($this->getUnflattenCallback())
|
||||
->addFormResultsCallback($this->getFlattenCallback());
|
||||
|
||||
$form->addField(new TextField('name', $this->translator->trans('form.project.name')));
|
||||
$form->addField(new TextField('shortDescription', $this->translator->trans('form.project.short_description')));
|
||||
$form->addField(new TextField('stack', $this->translator->trans('form.project.stack')));
|
||||
$form->addField(new TextField('status', $this->translator->trans('form.project.status')));
|
||||
$form->addField(new BooleanField('active', $this->translator->trans('form.project.active')));
|
||||
$this->addFlatGroupField($form, 'urls', false, 'project');
|
||||
$form->addField(new TextField('text', $this->translator->trans('form.project.text'), false));
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterfa
|
||||
|
||||
|
||||
/**
|
||||
* Constrctor
|
||||
* Constructor
|
||||
*
|
||||
* @param \Mni\FrontYAML\Document $document
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Magdev\Dossier\Model;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
|
||||
/**
|
||||
* Model for projects page
|
||||
@@ -42,6 +43,7 @@ use Mni\FrontYAML\Document;
|
||||
class Project extends BaseModel
|
||||
{
|
||||
use ToggableTrait;
|
||||
use PhotoTrait;
|
||||
|
||||
/**
|
||||
* Project name
|
||||
@@ -67,11 +69,22 @@ class Project extends BaseModel
|
||||
*/
|
||||
protected $stack = '';
|
||||
|
||||
/**
|
||||
* Project status
|
||||
* @var string
|
||||
*/
|
||||
protected $status = '';
|
||||
|
||||
|
||||
public function getStack(): string
|
||||
{
|
||||
return $this->stack;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
// git branch | grep \* | cut -d ' ' -f2
|
||||
|
||||
class GitService
|
||||
{
|
||||
/**
|
||||
@@ -46,17 +44,25 @@ class GitService
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
/**
|
||||
* System service
|
||||
* @var \Magdev\Dossier\Service\SystemService
|
||||
*/
|
||||
protected $system = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magdev\Dossier\Service\ConfigService $config
|
||||
* @param \Magdev\Dossier\Service\MonologService $logger
|
||||
* @param \Magdev\Dossier\Service\SystemService $system
|
||||
*/
|
||||
public function __construct(ConfigService $config, MonologService $logger)
|
||||
public function __construct(ConfigService $config, MonologService $logger, SystemService $system)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +74,7 @@ class GitService
|
||||
public function init(): bool
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
$this->exec('git init');
|
||||
$this->system->exec('git init');
|
||||
}
|
||||
return $this->isGitRepository();
|
||||
}
|
||||
@@ -82,10 +88,9 @@ class GitService
|
||||
public function getCurrentBranchName(): string
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
return $this->config->get('docname');
|
||||
return $this->config->get('output.docname');
|
||||
}
|
||||
$output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2');
|
||||
return $output[0];
|
||||
return $this->system->exec('git branch | grep \\\* | cut -d \' \' -f2', SystemService::MODE_LASTLINE);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,20 +101,6 @@ class GitService
|
||||
*/
|
||||
public function isGitRepository(): bool
|
||||
{
|
||||
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/config');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a system command
|
||||
*
|
||||
* @param string $cmd
|
||||
* @return array
|
||||
*/
|
||||
protected function exec(string $cmd): array
|
||||
{
|
||||
$output = array();
|
||||
exec($cmd, $output);
|
||||
return $output;
|
||||
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/HEAD');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ class MarkdownService
|
||||
$intro = new Intro($this->getDocument(PROJECT_ROOT.'/intro.md'));
|
||||
|
||||
$cv = new CurriculumVitae($this->formatter);
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,50 +23,37 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Theme;
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
/**
|
||||
* Create a local copy of a template
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class ThemeListCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('theme:list')
|
||||
->setDescription('List available themes')
|
||||
->addOption('all', 'a', InputOption::VALUE_NONE, 'List all themes, icluding the overridden ones');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
class SystemService
|
||||
{
|
||||
const MODE_OUTPUT = 1;
|
||||
const MODE_RETURN = 2;
|
||||
const MODE_LASTLINE = 3;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
* Execute a system command
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param int $mode
|
||||
* @param array $output
|
||||
* @param int $return
|
||||
* @return string|int|array
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function exec(string $cmd, int $mode = self::MODE_OUTPUT, &$output = array(), int &$return = 0)
|
||||
{
|
||||
$all = (bool) $input->getOption('all');
|
||||
$helper = $this->getHelper('export');
|
||||
/* @var $helper \Magdev\Dossier\Helper\ExportHelper */
|
||||
|
||||
$themes = $this->config->findThemes($all);
|
||||
$lastline = exec($cmd, $output, $return);
|
||||
switch ($mode) {
|
||||
case self::MODE_LASTLINE: return $lastline;
|
||||
case self::MODE_RETURN: return $return;
|
||||
default:
|
||||
case self::MODE_OUTPUT: return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class DataCollector implements DataCollectorInterface
|
||||
*/
|
||||
public function hasData(): bool
|
||||
{
|
||||
return sizeof($this->data) > o ? true : false;
|
||||
return sizeof($this->data) > 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
src/bootstrap.php
Normal file
41
src/bootstrap.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,47 +23,49 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Intro;
|
||||
namespace Magdev\DossierTests;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Service\GitService;
|
||||
|
||||
class IntroEditCommand extends BaseCommand
|
||||
class ApplicationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @var \Magdev\Dossier\Application
|
||||
*/
|
||||
protected function configure()
|
||||
private $app = null;
|
||||
|
||||
|
||||
/**
|
||||
* Setup TestCase
|
||||
*/
|
||||
public function setup(): void
|
||||
{
|
||||
$this->setName('intro:edit')
|
||||
->setDescription('Edit the intro in your default editor');
|
||||
|
||||
parent::configure();
|
||||
$this->app = new Application();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @group core
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function testGetContainer()
|
||||
{
|
||||
$file = PROJECT_ROOT.'/intro.md';
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
$this->assertInstanceOf(ContainerBuilder::class, $this->app->getContainer());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group core
|
||||
*/
|
||||
public function testGetValidService()
|
||||
{
|
||||
$this->assertInstanceOf(GitService::class, $this->app->getService('git'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,47 +23,51 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Person;
|
||||
namespace Magdev\DossierTests\Util;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magdev\Dossier\Util\DataCollector;
|
||||
|
||||
class PersonEditCommand extends BaseCommand
|
||||
class DataCollectorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @var array
|
||||
*/
|
||||
protected function configure()
|
||||
private $initData = ['foo'];
|
||||
|
||||
|
||||
/**
|
||||
* @group core
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::addData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::hasData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::setData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::getData()
|
||||
*/
|
||||
public function testSetGetData()
|
||||
{
|
||||
$this->setName('person:edit')
|
||||
->setDescription('Edit personal data in your default editor');
|
||||
$data = new DataCollector($this->initData);
|
||||
$this->assertEquals(true, $data->hasData());
|
||||
|
||||
parent::configure();
|
||||
$data->setData(1, 'bar');
|
||||
$this->assertEquals(['foo', 'bar'], $data->getData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @group core
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::merge()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function testMergeData()
|
||||
{
|
||||
$file = PROJECT_ROOT.'/person.md';
|
||||
$data = new DataCollector($this->initData);
|
||||
$data2 = new DataCollector(['bar']);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
$data->merge($data2);
|
||||
$this->assertEquals(['foo', 'bar'], $data->getData());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user