Skip to content

Commit a133ea0

Browse files
committed
feat: call mvc console version of command if available
1 parent ec1de2d commit a133ea0

File tree

4 files changed

+142
-263
lines changed

4 files changed

+142
-263
lines changed

src/CreateCommand.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
157157
$testing = $this->getAppTestPreset($input, $output);
158158

159159
if ($testing) {
160-
$commands[] = "$composer require leafs/alchemy --dev";
160+
$commands[] = "$composer require leafs/alchemy --dev --ansi";
161161
$commands[] = "./vendor/bin/alchemy setup --$testing";
162162
}
163163

@@ -169,10 +169,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
169169
null
170170
);
171171

172-
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
173-
$process->setTty(true);
174-
}
175-
176172
echo "\n";
177173

178174
$process->run(function ($type, $line) use ($output) {
@@ -255,17 +251,13 @@ protected function buildLeafApp($input, $output, $directory): int
255251
}
256252

257253
$process = Process::fromShellCommandline(
258-
implode(' && ', $commands),
254+
implode(' && ', $commands) . ' --ansi',
259255
$directory,
260256
null,
261257
null,
262258
null
263259
);
264260

265-
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
266-
$process->setTty(true);
267-
}
268-
269261
$process->run(function ($type, $line) use ($output) {
270262
$output->write($line);
271263
});

src/ServeCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ protected function configure()
3131

3232
protected function execute(InputInterface $input, OutputInterface $output): int
3333
{
34+
if ($this->isMVCApp()) {
35+
return (int) Utils\Core::run("php leaf serve --ansi", $output);
36+
}
37+
3438
$vendorPath = getcwd() . '/vendor';
3539
$composerJsonPath = getcwd() . '/composer.json';
3640

@@ -148,4 +152,11 @@ protected function startServer(InputInterface $input, OutputInterface $output):
148152
}
149153
});
150154
}
155+
156+
protected function isMVCApp()
157+
{
158+
$directory = getcwd();
159+
160+
return is_dir("$directory/app/views") && file_exists("$directory/leaf") && is_dir("$directory/public");
161+
}
151162
}

src/Utils/Core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ public static function isMVCProject($directory = null)
160160
{
161161
$directory = $directory ?? getcwd();
162162

163-
return is_dir("$directory/app/views") && file_exists("$directory/config/paths.php") && is_dir("$directory/public");
163+
return is_dir("$directory/app/views") && file_exists("$directory/leaf") && is_dir("$directory/public");
164164
}
165165
}

0 commit comments

Comments
 (0)