Skip to content

Commit 76b99be

Browse files
author
Greg Bowler
committed
Upgrade to phpgt/daemon's new process model
1 parent 28a1b75 commit 76b99be

10 files changed

Lines changed: 66 additions & 96 deletions

bin/gt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Gt\Cli\Argument\ArgumentList;
66
use Gt\Installer\Command\BuildCommand;
77
use Gt\Installer\Command\CreateCommand;
88
use Gt\Installer\Command\CronCommand;
9+
use Gt\Installer\Command\MigrateCommand;
910
use Gt\Installer\Command\RunCommand;
1011
use Gt\Installer\Command\ServeCommand;
1112

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77

88
"require": {
9-
"php": ">=7.2",
9+
"php": ">=7.4",
1010
"phpgt/cli": "*",
1111
"phpgt/daemon": "*",
1212
"phpgt/cron": "*",

composer.lock

Lines changed: 47 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command/AbstractWebEngineCommand.php

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,66 +11,37 @@
1111
abstract class AbstractWebEngineCommand extends Command {
1212
public function executeScript(
1313
ArgumentValueList $arguments = null,
14-
string...$scriptsToRun
14+
array...$scriptsToRun
1515
):void {
16-
$argString = "";
17-
18-
foreach($arguments as $arg) {
19-
$key = $arg->getKey();
20-
21-
if($key !== Argument::USER_DATA) {
22-
$argString .= " ";
23-
$argString .= "--";
24-
$argString .= $key;
25-
}
26-
27-
$value = $arg->get();
28-
if(!empty($value)) {
29-
$argString .= " ";
30-
$argString .= $value;
31-
}
32-
}
33-
3416
$processPool = new Pool();
3517

36-
foreach($scriptsToRun as $scriptName) {
18+
foreach($scriptsToRun as $scriptParts) {
19+
$scriptName = array_shift($scriptParts);
20+
3721
$gtCommand = implode(DIRECTORY_SEPARATOR, [
3822
"vendor",
3923
"bin",
4024
$scriptName,
4125
]);
4226

43-
$spacePos = strpos($gtCommand, " ");
44-
$gtCommandWithoutArguments = $gtCommand;
45-
if($spacePos > 0) {
46-
$gtCommandWithoutArguments = substr(
47-
$gtCommand,
48-
0,
49-
$spacePos
50-
);
51-
}
52-
if(!file_exists($gtCommandWithoutArguments)) {
27+
if(!file_exists($gtCommand)) {
5328
$this->writeLine(
5429
"The current directory is not a WebEngine application.",
5530
Stream::ERROR
5631
);
5732
return;
5833
}
5934

60-
if(!empty($argString)) {
61-
$gtCommand .= $argString;
62-
}
63-
64-
$friendlyScriptName = $gtCommandWithoutArguments;
65-
$slashPos = strrpos($gtCommandWithoutArguments, "/");
35+
$friendlyScriptName = $gtCommand;
36+
$slashPos = strrpos($friendlyScriptName, "/");
6637
if($slashPos > 0) {
6738
$friendlyScriptName = substr(
68-
$gtCommandWithoutArguments,
39+
$friendlyScriptName,
6940
$slashPos + 1
7041
);
7142
}
7243

73-
$process = new Process($gtCommand);
44+
$process = new Process($gtCommand, ...$scriptParts);
7445
$processPool->add($friendlyScriptName, $process);
7546
}
7647

src/Command/BuildCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class BuildCommand extends AbstractWebEngineCommand {
99
public function run(ArgumentValueList $arguments = null):void {
10-
$this->executeScript($arguments, "build");
10+
$this->executeScript($arguments, ["build"]);
1111
}
1212

1313
public function getName():string {

src/Command/CreateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function run(ArgumentValueList $arguments = null):void {
3131
"Using blueprint: $blueprint"
3232
);
3333

34-
$process = new Process("composer create-project --remove-vcs webengine-blueprints/$blueprint:dev-master $appDir");
34+
$process = new Process("composer", "create-project", "--remove-vcs", "webengine-blueprints/$blueprint:dev-master", $appDir);
3535
$process->exec();
3636

3737
$this->write("Installing");

src/Command/CronCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CronCommand extends AbstractWebEngineCommand {
1111
public function run(ArgumentValueList $arguments = null):void {
12-
$this->executeScript($arguments, "cron");
12+
$this->executeScript($arguments, ["cron"]);
1313
}
1414

1515
public function getName():string {

src/Command/MigrateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MigrateCommand extends AbstractWebEngineCommand {
99
public function run(ArgumentValueList $arguments = null):void {
1010
$this->executeScript(
1111
$arguments,
12-
"db-migrate"
12+
["db-migrate"]
1313
);
1414
}
1515

0 commit comments

Comments
 (0)