Skip to content

Commit 1cb93da

Browse files
authored
Merge pull request #1 from abachmann/master
Make directory and decision record template configurable via yaml config file
2 parents baf2827 + 6889a89 commit 1cb93da

22 files changed

+522
-280
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ After of install this project you may execute the binary `phpadr` in your termin
3232

3333
If to execute the command above, it will be showd a list of all avaliable tool commands.
3434

35-
By default the records will be stored in `docs/arch`, to change this workspace use the option `--directory` with the path of the new workspace.
35+
By default the records will be stored in `docs/arch`, to change this workspace use the option `--config` with the path of the config file.
3636

3737
### Create a new ADR
3838

3939
You may use the `make:decision` command:
4040

4141
```
42-
./vendor/bin/phpadr make:decision <title> [<status="Accepted">] [--directory="docs/arch"]
42+
./vendor/bin/phpadr make:decision <title> [<status="Accepted">] [--config="adr.yml"]
4343
```
4444

4545
### Count the ADRs
4646

4747
You may use the `workspace:count` command:
4848

4949
```
50-
./vendor/bin/phpadr workspace:count [--directory="docs/arch"]
50+
./vendor/bin/phpadr workspace:count [--config="adr.yml"]
5151
```
5252

5353
### List the ADRs
5454

5555
You may use the `workspace:list` command:
5656

5757
```
58-
./vendor/bin/phpadr workspace:list [--directory="docs/arch"]
58+
./vendor/bin/phpadr workspace:list [--config="adr.yml"]
5959
```
6060

6161
### Help

adr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
directory: docs/arch
2+
template:
3+
decision-record: template/skeleton.md

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"require": {
2020
"php": "^7.1.3",
2121
"ext-mbstring": "*",
22-
"symfony/console": "^4.0"
22+
"symfony/console": "^4.0",
23+
"symfony/yaml": "^4.2@dev"
2324
},
2425
"require-dev": {
2526
"phpunit/phpunit": "^7.0.1",

composer.lock

Lines changed: 121 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/arch/0005-phpunit-as-testing-framework.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ It will be used the [PHPUnit](https://phpunit.de/) as testing framework.
1616

1717
## Consequences
1818

19-
Use unit testing for ensure that the code is working as expected and that changes don't break existing funcionality.
19+
Use unit testing for ensure that the code is working as expected and that changes don't break existing functionality.
2020

2121
Allow to use Test-Driven Development (TDD) that is an evolutionary approach to development which combines test-first development.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 6. YAML as configuration file
2+
3+
Date: 2018-06-30
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
In order to use a custom ADR template, it must be possible to configure the path to it. The same template must be used so that all ADR`s are structured in the same way.
12+
13+
## Decision
14+
15+
The template path can be defined via a [YAML](http://yaml.org/) configuration file.
16+
17+
## Consequences
18+
19+
We need to add [symfony/yaml](https://github.com/symfony/yaml) as a dependency to the project.
20+
21+
To have a single place of truth the "directory" option must be removed from all console commands, because the directory can be defined in the configuration file.

src/Command/MakeDecisionCommand.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
namespace ADR\Command;
44

5+
use ADR\Domain\DecisionContent;
6+
use ADR\Domain\DecisionRecord;
7+
use ADR\Domain\Sequence;
8+
use ADR\Filesystem\Config;
9+
use ADR\Filesystem\Workspace;
510
use Symfony\Component\Console\Command\Command;
611
use Symfony\Component\Console\Input\InputArgument;
712
use Symfony\Component\Console\Input\InputInterface;
8-
use Symfony\Component\Console\Output\OutputInterface;
913
use Symfony\Component\Console\Input\InputOption;
10-
use ADR\Filesystem\Workspace;
11-
use ADR\Domain\Sequence;
12-
use ADR\Domain\DecisionRecord;
13-
use ADR\Domain\DecisionContent;
14+
use Symfony\Component\Console\Output\OutputInterface;
1415

1516
/**
1617
* Command to make ADRs
@@ -44,17 +45,17 @@ protected function configure()
4445
'status',
4546
InputArgument::OPTIONAL,
4647
sprintf(
47-
'The status of the ADR, avaliable options: [%s]',
48+
'The status of the ADR, available options: [%s]',
4849
implode(', ', $options)
4950
),
5051
DecisionContent::STATUS_ACCEPTED
5152
)
5253
->addOption(
53-
'directory',
54+
'config',
5455
null,
5556
InputOption::VALUE_REQUIRED,
56-
'Workspace that store the ADRs',
57-
'docs/arch'
57+
'Config file',
58+
'adr.yml'
5859
);
5960
}
6061

@@ -66,10 +67,11 @@ protected function configure()
6667
*/
6768
protected function execute(InputInterface $input, OutputInterface $output)
6869
{
69-
$workspace = new Workspace($input->getOption('directory'));
70+
$config = new Config($input->getOption('config'));
71+
$workspace = new Workspace($config->directory());
7072
$sequence = new Sequence($workspace);
7173
$content = new DecisionContent($sequence->next(), $input->getArgument('title'), $input->getArgument('status'));
72-
$record = new DecisionRecord($content);
74+
$record = new DecisionRecord($content, $config);
7375

7476
$workspace->add($record);
7577

0 commit comments

Comments
 (0)