Skip to content

Commit 70bc5f8

Browse files
authored
feat(process): introduce process component (#1326)
1 parent 830e27b commit 70bc5f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2272
-129
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"psr/log": "^3.0.0",
3535
"symfony/cache": "^7.3",
3636
"symfony/mailer": "^7.2.6",
37-
"symfony/process": "^7.1.7",
37+
"symfony/process": "^7.3",
3838
"symfony/uid": "^7.1",
3939
"symfony/var-dumper": "^7.1",
4040
"symfony/var-exporter": "^7.1",
@@ -98,6 +98,7 @@
9898
"tempest/log": "self.version",
9999
"tempest/mail": "self.version",
100100
"tempest/mapper": "self.version",
101+
"tempest/process": "self.version",
101102
"tempest/reflection": "self.version",
102103
"tempest/router": "self.version",
103104
"tempest/storage": "self.version",
@@ -137,6 +138,7 @@
137138
"Tempest\\Log\\": "packages/log/src",
138139
"Tempest\\Mail\\": "packages/mail/src",
139140
"Tempest\\Mapper\\": "packages/mapper/src",
141+
"Tempest\\Process\\": "packages/process/src",
140142
"Tempest\\Reflection\\": "packages/reflection/src",
141143
"Tempest\\Router\\": "packages/router/src",
142144
"Tempest\\Storage\\": "packages/storage/src",
@@ -201,6 +203,7 @@
201203
"Tempest\\Log\\Tests\\": "packages/log/tests",
202204
"Tempest\\Mail\\Tests\\": "packages/mail/tests",
203205
"Tempest\\Mapper\\Tests\\": "packages/mapper/tests",
206+
"Tempest\\Process\\Tests\\": "packages/process/tests",
204207
"Tempest\\Reflection\\Tests\\": "packages/reflection/tests",
205208
"Tempest\\Router\\Tests\\": "packages/router/tests",
206209
"Tempest\\Storage\\Tests\\": "packages/storage/tests",

packages/console/src/Initializers/InvocationExecutorInitializer.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/console/src/Initializers/SchedulerInitializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Tempest\Container\Initializer;
1515
use Tempest\Container\Singleton;
1616
use Tempest\Core\Application;
17-
use Tempest\Core\ShellExecutor;
17+
use Tempest\Process\ProcessExecutor;
1818

1919
final readonly class SchedulerInitializer implements Initializer
2020
{
@@ -30,7 +30,7 @@ public function initialize(Container $container): Scheduler
3030
return new GenericScheduler(
3131
$container->get(SchedulerConfig::class),
3232
$container->get(ConsoleArgumentBag::class),
33-
$container->get(ShellExecutor::class),
33+
$container->get(ProcessExecutor::class),
3434
);
3535
}
3636
}

packages/console/src/Scheduler/GenericScheduler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use DateTime;
88
use Tempest\Console\Input\ConsoleArgumentBag;
99
use Tempest\Console\Scheduler;
10-
use Tempest\Core\ShellExecutor;
10+
use Tempest\Process\ProcessExecutor;
1111
use Tempest\Support\Filesystem;
1212

1313
use function Tempest\event;
@@ -18,7 +18,7 @@
1818
public function __construct(
1919
private SchedulerConfig $config,
2020
private ConsoleArgumentBag $argumentBag,
21-
private ShellExecutor $executor,
21+
private ProcessExecutor $executor,
2222
) {}
2323

2424
public static function getCachePath(): string
@@ -43,7 +43,7 @@ private function execute(ScheduledInvocation $invocation): void
4343
{
4444
$command = $this->compileInvocation($invocation);
4545

46-
$this->executor->execute($command);
46+
$this->executor->run($command);
4747
}
4848

4949
private function compileInvocation(ScheduledInvocation $invocation): string

packages/core/src/Composer.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
namespace Tempest\Core;
66

7+
use Tempest\Process\ProcessExecutor;
8+
use Tempest\Support\Arr;
79
use Tempest\Support\Filesystem;
8-
use Tempest\Support\Json;
910
use Tempest\Support\Namespace\Psr4Namespace;
11+
use Tempest\Support\Path;
12+
use Tempest\Support\Str;
1013

1114
use function Tempest\Support\arr;
12-
use function Tempest\Support\Arr\wrap;
13-
use function Tempest\Support\Path\normalize;
14-
use function Tempest\Support\Str\ensure_ends_with;
15-
use function Tempest\Support\Str\starts_with;
1615

1716
final class Composer
1817
{
@@ -27,12 +26,12 @@ final class Composer
2726

2827
public function __construct(
2928
private readonly string $root,
30-
private ShellExecutor $executor,
29+
private ProcessExecutor $executor,
3130
) {}
3231

3332
public function load(): self
3433
{
35-
$this->composerPath = normalize($this->root, 'composer.json');
34+
$this->composerPath = Path\normalize($this->root, 'composer.json');
3635
$this->composer = $this->loadComposerFile($this->composerPath);
3736
$this->namespaces = arr($this->composer)
3837
->get('autoload.psr-4', default: arr())
@@ -42,7 +41,7 @@ public function load(): self
4241
->toArray();
4342

4443
foreach ($this->namespaces as $namespace) {
45-
if (starts_with(ensure_ends_with($namespace->path, '/'), ['app/', 'src/', 'source/', 'lib/'])) {
44+
if (Str\starts_with(Str\ensure_ends_with($namespace->path, '/'), ['app/', 'src/', 'source/', 'lib/'])) {
4645
$this->mainNamespace = $namespace;
4746

4847
break;
@@ -73,12 +72,12 @@ public function setMainNamespace(Psr4Namespace $namespace): self
7372

7473
public function setNamespaces(Psr4Namespace|array $namespaces): self
7574
{
76-
$this->namespaces = wrap($namespaces);
75+
$this->namespaces = Arr\wrap($namespaces);
7776

7877
return $this;
7978
}
8079

81-
public function setShellExecutor(ShellExecutor $executor): self
80+
public function setProcessExecutor(ProcessExecutor $executor): self
8281
{
8382
$this->executor = $executor;
8483

@@ -103,7 +102,7 @@ public function save(): self
103102

104103
public function executeUpdate(): self
105104
{
106-
$this->executor->execute('composer up');
105+
$this->executor->run('composer up');
107106

108107
return $this;
109108
}

packages/core/src/FrameworkKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use Tempest\Core\Kernel\LoadDiscoveryClasses;
1313
use Tempest\Core\Kernel\LoadDiscoveryLocations;
1414
use Tempest\Core\Kernel\RegisterEmergencyExceptionHandler;
15-
use Tempest\Core\ShellExecutors\GenericShellExecutor;
1615
use Tempest\EventBus\EventBus;
16+
use Tempest\Process\GenericProcessExecutor;
1717

1818
final class FrameworkKernel implements Kernel
1919
{
@@ -98,7 +98,7 @@ public function loadComposer(): self
9898
{
9999
$composer = new Composer(
100100
root: $this->root,
101-
executor: new GenericShellExecutor(),
101+
executor: new GenericProcessExecutor(),
102102
)->load();
103103

104104
$this->container->singleton(Composer::class, $composer);

packages/core/src/ShellExecutor.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/core/src/ShellExecutors/GenericShellExecutor.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/core/src/ShellExecutors/NullShellExecutor.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/process/.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Exclude build/test files from the release
2+
.github/ export-ignore
3+
tests/ export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
phpunit.xml export-ignore
7+
README.md export-ignore
8+
9+
# Configure diff output
10+
*.view.php diff=html
11+
*.php diff=php
12+
*.css diff=css
13+
*.html diff=html
14+
*.md diff=markdown

0 commit comments

Comments
 (0)