Skip to content

Commit dfc1f45

Browse files
committed
Enhance maml template generation with annotated comments and update maml/maml to v3.2
1 parent bdaef77 commit dfc1f45

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
],
4343
"require": {
4444
"php": "^8.3",
45-
"maml/maml": "^3.1",
45+
"maml/maml": "^3.2",
4646
"symfony/console": "^7.4.0 || ^8.0.0",
4747
"symfony/process": "^7.4.0 || ^8.0.0",
4848
"symfony/yaml": "^7.4.0 || ^8.0.0"

src/Command/InitCommand.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Deployer\Command;
1212

1313
use Deployer\Deployer;
14+
use Maml\Annotated;
1415
use Maml\Maml;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputInterface;
@@ -168,20 +169,27 @@ private function php(string $template, string $project, string $repository, arra
168169
private function maml(string $template, string $project, string $repository, array $hosts): string
169170
{
170171
$recipe = [
171-
"import" => [
172+
"import" => Annotated::with([
172173
"recipe/$template.php",
173-
],
174-
"config" => [
174+
])->comment(
175+
' You can import other php or maml recipes.',
176+
' Import recipes directly from recipe/ folder.',
177+
),
178+
"config" => Annotated::with([
175179
"repository" => "$repository",
176-
],
180+
])->emptyLineBefore(),
177181
"hosts" => [],
178-
"tasks" => [
182+
"tasks" => Annotated::with([
179183
"example" => [
180184
[
181185
"run" => "date",
186+
"cwd" => "~",
182187
],
183188
],
184-
],
189+
])->emptyLineBefore()->comment(
190+
' Define tasks as list of steps to run,',
191+
' or use array to strings to define group task.',
192+
),
185193
];
186194

187195
foreach ($hosts as $host) {
@@ -191,6 +199,12 @@ private function maml(string $template, string $project, string $repository, arr
191199
];
192200
}
193201

202+
$recipe['hosts'] = Annotated::with($recipe['hosts'])
203+
->emptyLineBefore()
204+
->comment(
205+
' Hosts',
206+
);
207+
194208
return Maml::stringify($recipe);
195209
}
196210

0 commit comments

Comments
 (0)