Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"require": {
"php": ">=8.2",
"phpgt/cli": "^1.3",
"phpgt/server": "^1.1",
"phpgt/server": "dev-master as v1.2.3",
"phpgt/cron": "^1.0",
"phpgt/database": "^1.6",
"phpgt/build": "^1.0"
Expand All @@ -30,6 +30,17 @@
}
},

"scripts": {
"phpstan": "vendor/bin/phpstan analyse --level 6 src --memory-limit 256M",
"phpcs": "vendor/bin/phpcs src --standard=phpcs.xml",
"phpmd": "vendor/bin/phpmd src/ text phpmd.xml",
"test": [
"@phpstan",
"@phpcs",
"@phpmd"
]
},

"funding": [
{
"type": "github",
Expand Down
122 changes: 69 additions & 53 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 23 additions & 4 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Gt\Cli\Stream;
use Gt\Daemon\Pool;
use Gt\Daemon\Process;
use Gt\GtCommand\UI\Egg\RandomStartingMessage;

class RunCommand extends Command {
/**
Expand Down Expand Up @@ -40,7 +41,7 @@ public function run(?ArgumentValueList $arguments = null):void {
$processList["build"] = new Process($argv[0], "build", "--watch");
}

if(!$arguments->contains("no-cron")) {
if(!$arguments->contains("no-cron") && is_file("crontab")) {
$processList["cron"] = new Process($argv[0], "cron", "--watch");
}

Expand All @@ -64,20 +65,38 @@ public function run(?ArgumentValueList $arguments = null):void {
$localUrl .= ":$portValue";
}

usleep(100_000);
$this->write("Starting WebEngine...");
usleep(500_000);
if($processList["serve"]->isRunning()) {
$this->writeLine("To view your application in your "
$this->writeLine(" ✅");
usleep(500_000);
$this->writeLine();
$this->writeLine("To view your application in your"
. " browser, visit: $localUrl");
$this->writeLine("To stop running, press [CTRL]+[C].");
$this->writeLine();
usleep(500_000);
}
else {
$this->writeLine(" ❌");
$this->write($processList["serve"]->getOutput(Process::PIPE_ERROR), Stream::ERROR);
return;
}

$this->write($processList["serve"]->getOutput());
$this->write($processList["serve"]->getOutput(Process::PIPE_ERROR), Stream::ERROR);

do {
$this->write($pool->read());
$this->write($pool->read(Process::PIPE_ERROR), Stream::ERROR);
usleep(100_000);
/** @var bool $isRunning
* @noinspection PhpRedundantVariableDocTypeInspection
* This is necessary to suppress "Do-while loop condition is always true" error from phpstan. Bug with stan?
*/
$isRunning = $processList["serve"]->isRunning();
}
while($processList["serve"]->isRunning());
while($isRunning);
$this->writeLine("The server process has ended.");
}

Expand Down
Loading