Skip to content

Commit a488999

Browse files
committed
feat: add support for console apps in create command
1 parent 8b1f827 commit a488999

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require": {
2424
"ext-json": "*",
2525
"leafs/fs": "^4.1",
26-
"leafs/sprout": "*",
26+
"leafs/sprout": "^0.7.0",
2727
"psy/psysh": "*"
2828
},
2929
"bin": [

src/CreateCommand.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ protected function handle(): int
9191
['title' => 'Basic Leaf app', 'value' => 'basic'],
9292
['title' => 'Full-stack MVC app', 'value' => 'mvc'],
9393
['title' => 'Leaf MVC API app', 'value' => 'api'],
94+
['title' => 'Console app', 'value' => 'console'],
9495
],
9596
],
9697
]);
@@ -124,6 +125,9 @@ protected function handle(): int
124125

125126
$commands[] = "cd \"$directory\"";
126127
$commands[] = 'composer install --ansi';
128+
} else if ($this->projectType === 'console') {
129+
$commands[] = "composer create-project leafs/sprout-app \"$directory\" --ansi";
130+
$commands[] = "cd \"$directory\"";
127131
} else {
128132
$commands[] = "composer create-project leafs/mvc \"$directory\" --ansi";
129133
$commands[] = "cd \"$directory\"";
@@ -142,6 +146,19 @@ protected function handle(): int
142146
}
143147

144148
if (sprout()->process(implode(' && ', $commands))->setTimeout(null)->run() === 0) {
149+
if ($this->projectType === 'console') {
150+
\Leaf\FS\File::move("$directory/bin/sprout", "$directory/bin/" . basename($directory));
151+
152+
$this->writeln("\n🚀 Successfully created project " . basename($directory) . "\n");
153+
$this->writeln('👉 Get started with the following commands:');
154+
$this->writeln("\n cd " . basename($directory));
155+
$this->writeln(" php ./bin/" . basename($directory));
156+
157+
$this->writeln("\n🍁 Happy gardening!\n");
158+
159+
return 0;
160+
}
161+
145162
if ($this->projectType === 'api') {
146163
if (\Leaf\FS\File::exists("$directory/vite.config.js")) {
147164
\Leaf\FS\File::delete("$directory/vite.config.js");

0 commit comments

Comments
 (0)