Skip to content

Commit bcd4f32

Browse files
Merge pull request #11 from codenamephp/feature/9-add-before-to-deployer-functions
Added before function
2 parents 330520e + 43c4996 commit bcd4f32

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

MIGRATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Migration
22

3+
## 2.x -> 3.x
4+
5+
The iAll interface was extended with the iBefore interface. If you created your own implementation of iAll you need to implement the iBefore interface as well.
6+
If you use the All class you don't need to do anything.
7+
38
## 1.x -> 2.x
49

510
The ssh connection string is now part of `\Deployer\Host\Host`. This means the

src/functions/All.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use Closure;
2121
use de\codenamephp\deployer\base\MissingConfigurationException;
22+
use de\codenamephp\deployer\base\task\iTask;
2223
use de\codenamephp\deployer\base\task\iTaskWithDescription;
2324
use de\codenamephp\deployer\base\task\iTaskWithName;
2425
use Deployer\Deployer;
@@ -29,6 +30,7 @@
2930
use Symfony\Component\Console\Input\InputArgument;
3031
use function Deployer\add;
3132
use function Deployer\after;
33+
use function Deployer\before;
3234
use function Deployer\currentHost;
3335
use function Deployer\download;
3436
use function Deployer\get;
@@ -50,10 +52,14 @@ public function add(string $name, array $array) : void {
5052
add($name, $array);
5153
}
5254

53-
public function after(string $task, callable|\de\codenamephp\deployer\base\task\iTask|string $do) : ?Task {
55+
public function after(string $task, callable|iTask|string $do) : ?Task {
5456
return after($task, $do);
5557
}
5658

59+
public function before(string $task, callable|iTask|string $do) : ?Task {
60+
return before($task, $do);
61+
}
62+
5763
public function currentHost() : Host {
5864
return currentHost();
5965
}
@@ -151,7 +157,7 @@ public function set(string $name, mixed $value) : void {
151157
set($name, $value);
152158
}
153159

154-
public function task(string $name, callable|array|\de\codenamephp\deployer\base\task\iTask|null $body = null) : Task {
160+
public function task(string $name, callable|array|iTask|null $body = null) : Task {
155161
return \Deployer\task($name, $body);
156162
}
157163

src/functions/iAll.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
*
2323
* The idea is to provide a stable, typed API and also a level of abstraction to the global deployer functions so testing is easier.
2424
*/
25-
interface iAll extends iAdd, iAfter, iCurrentHost, iDownload, iGet, iHost, iInput, iLocalhost, iOn, iParse, iRun, iSet, iTask, iUpload {
25+
interface iAll extends iAdd, iAfter, iBefore, iCurrentHost, iDownload, iGet, iHost, iInput, iLocalhost, iOn, iParse, iRun, iSet, iTask, iUpload {
2626

2727
}

src/functions/iBefore.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2023 Bastian Schwarz <[email protected]>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\base\functions;
19+
20+
use de\codenamephp\deployer\base\task\iTask;
21+
use Deployer\Task\Task;
22+
23+
/**
24+
* Interface for the Deployer\before function
25+
*/
26+
interface iBefore {
27+
28+
/**
29+
* Registers a task to be executed before another task
30+
*
31+
* @param string $task The name of the task the given task should be executed before
32+
* @param callable():void|iTask|string $do The task to execute before the given task name
33+
* @return Task|null The added task or null if no task was added
34+
*/
35+
public function before(string $task, iTask|string|callable $do) : ?Task;
36+
}

0 commit comments

Comments
 (0)