Skip to content

Commit d16ffe1

Browse files
committed
Merge pull request #96 from aequasi/96-allow-profile-inheritance
Allow Profile Inheritance
2 parents 9cbf159 + 2b9a484 commit d16ffe1

File tree

7 files changed

+45
-15
lines changed

7 files changed

+45
-15
lines changed

.bldr.yml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ imports:
55
bldr:
66
name: bldr-io/bldr
77
description: The PHP Task Runner you've been waiting for
8-
9-
#blocks:
10-
# - Bldr\Block\Watch\WatchBlock

.bldr/tasks.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,16 @@ bldr:
7575
seconds: 1
7676
-
7777
type: filesystem:remove
78+
failOnError: false
7879
files: [build/coverage, build/logs]
7980
-
8081
type: filesystem:mkdir
81-
failOnError: true
8282
files: [build/coverage, build/logs]
8383
-
8484
type: filesystem:touch
85-
failOnError: true
8685
files: [build/coverage/index.html]
8786
-
8887
type: exec
89-
failOnError: true
9088
executable: composer
9189
arguments: [install, --prefer-dist]
9290
-
@@ -97,7 +95,6 @@ bldr:
9795
calls:
9896
-
9997
type: apply
100-
failOnError: true
10198
src:
10299
- { path: [src, tests], files: *.php, recursive: true }
103100
output: /dev/null
@@ -131,7 +128,6 @@ bldr:
131128
calls:
132129
-
133130
type: exec
134-
failOnError: true
135131
executable: php
136132
arguments:
137133
- bin/phpunit

docs/usage.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@ Create a ``.bldr.yml(.dist)`` file:
1717
description: Gets ran when `./bldr.phar build someTask` is called
1818
tasks:
1919
- foo
20+
someOtherTask:
21+
tasks:
22+
- bar
23+
inheritanceExample:
24+
description: Will run the tasks from `someTask` and then `someOtherTask`.
25+
uses:
26+
before: [someTask]
27+
after: [someOtherTask]
2028
tasks:
2129
foo:
22-
description: FooBar task
30+
description: Foo task
2331
calls:
2432
-
2533
type: exec
2634
executable: echo
2735
arguments: [Hello World]
36+
bar:
37+
description: Bar task
38+
calls:
39+
-
40+
type: exec
41+
executable: sleep
42+
arguments: [1]
2843
2944
To view a list of available call types, run:
3045

src/Block/Core/Configuration.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ private function getProfilesNode()
5858
->scalarNode('description')
5959
->defaultValue('')
6060
->end()
61+
->arrayNode('uses')
62+
->children()
63+
->arrayNode('before')
64+
->prototype('scalar')->end()
65+
->end()
66+
->arrayNode('after')
67+
->prototype('scalar')->end()
68+
->end()
69+
->end()
70+
->end()
6171
->arrayNode('tasks')
6272
->prototype('scalar')->end()
6373
->end()

src/Command/BuildCommand.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function doExecute($profileName = null, array $tasks = [])
128128
]
129129
);
130130

131-
$this->fetchTasks($profileName);
131+
$this->fetchTasks($profile);
132132
$this->addEvent(Event::PRE_PROFILE, new Events\ProfileEvent($this, true));
133133
} else {
134134
$this->buildTasks($tasks);
@@ -157,12 +157,23 @@ private function formatBlock($output, $background, $foreground)
157157
}
158158

159159
/**
160-
* @param string $profileName
160+
* @param array $profile
161161
*/
162-
private function fetchTasks($profileName)
162+
private function fetchTasks(array $profile)
163163
{
164-
$profile = $this->container->getParameter('profiles')[$profileName];
164+
if (!empty($profile['uses']) && !empty($profile['uses']['before'])) {
165+
foreach ($profile['uses']['before'] as $name) {
166+
$this->buildTasks($this->getProfile($name));
167+
}
168+
}
169+
165170
$this->buildTasks($profile['tasks']);
171+
172+
if (!empty($profile['uses']) && !empty($profile['uses']['after'])) {
173+
foreach ($profile['uses']['after'] as $name) {
174+
$this->buildTasks($this->getProfile($name));
175+
}
176+
}
166177
}
167178

168179
/**

src/Command/Task/InfoCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
5252
{
5353
$service = $this->findService($input->getArgument('task'));
5454

55+
$description = ($service->getDescription() !== '' ? $service->getDescription() : 'No Description');
5556
$output->writeln(
5657
[
5758
"",
5859
'<fg=green>Task Name</fg=green>: '.$service->getName(),
59-
'<fg=green>Task Description</fg=green>: '.($service->getDescription() !== '' ? $service->getDescription() : 'No Description'),
60+
'<fg=green>Task Description</fg=green>: '.$description,
6061
"",
6162
"<fg=green>Options:</fg=green>"
6263
]

tests/Model/CallTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testConstructor()
2424

2525
$this->assertEquals('mock', $call->getType());
2626
$this->assertEmpty($call->getOptions());
27-
$this->assertFalse($call->getFailOnError());
27+
$this->assertTrue($call->getFailOnError());
2828
$this->assertEquals([0], $call->getSuccessCodes());
2929
}
3030
}

0 commit comments

Comments
 (0)