Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"psr/log": "^3.0.0",
"symfony/cache": "^7.3",
"symfony/mailer": "^7.2.6",
"symfony/process": "^7.1.7",
"symfony/process": "^7.3",
"symfony/uid": "^7.1",
"symfony/var-dumper": "^7.1",
"symfony/var-exporter": "^7.1",
Expand Down Expand Up @@ -98,6 +98,7 @@
"tempest/log": "self.version",
"tempest/mail": "self.version",
"tempest/mapper": "self.version",
"tempest/process": "self.version",
"tempest/reflection": "self.version",
"tempest/router": "self.version",
"tempest/storage": "self.version",
Expand Down Expand Up @@ -137,6 +138,7 @@
"Tempest\\Log\\": "packages/log/src",
"Tempest\\Mail\\": "packages/mail/src",
"Tempest\\Mapper\\": "packages/mapper/src",
"Tempest\\Process\\": "packages/process/src",
"Tempest\\Reflection\\": "packages/reflection/src",
"Tempest\\Router\\": "packages/router/src",
"Tempest\\Storage\\": "packages/storage/src",
Expand Down Expand Up @@ -201,6 +203,7 @@
"Tempest\\Log\\Tests\\": "packages/log/tests",
"Tempest\\Mail\\Tests\\": "packages/mail/tests",
"Tempest\\Mapper\\Tests\\": "packages/mapper/tests",
"Tempest\\Process\\Tests\\": "packages/process/tests",
"Tempest\\Reflection\\Tests\\": "packages/reflection/tests",
"Tempest\\Router\\Tests\\": "packages/router/tests",
"Tempest\\Storage\\Tests\\": "packages/storage/tests",
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/console/src/Initializers/SchedulerInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Tempest\Container\Initializer;
use Tempest\Container\Singleton;
use Tempest\Core\Application;
use Tempest\Core\ShellExecutor;
use Tempest\Process\ProcessExecutor;

final readonly class SchedulerInitializer implements Initializer
{
Expand All @@ -30,7 +30,7 @@ public function initialize(Container $container): Scheduler
return new GenericScheduler(
$container->get(SchedulerConfig::class),
$container->get(ConsoleArgumentBag::class),
$container->get(ShellExecutor::class),
$container->get(ProcessExecutor::class),
);
}
}
6 changes: 3 additions & 3 deletions packages/console/src/Scheduler/GenericScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use DateTime;
use Tempest\Console\Input\ConsoleArgumentBag;
use Tempest\Console\Scheduler;
use Tempest\Core\ShellExecutor;
use Tempest\Process\ProcessExecutor;
use Tempest\Support\Filesystem;

use function Tempest\event;
Expand All @@ -18,7 +18,7 @@
public function __construct(
private SchedulerConfig $config,
private ConsoleArgumentBag $argumentBag,
private ShellExecutor $executor,
private ProcessExecutor $executor,
) {}

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

$this->executor->execute($command);
$this->executor->run($command);
}

private function compileInvocation(ScheduledInvocation $invocation): string
Expand Down
21 changes: 10 additions & 11 deletions packages/core/src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

namespace Tempest\Core;

use Tempest\Process\ProcessExecutor;
use Tempest\Support\Arr;
use Tempest\Support\Filesystem;
use Tempest\Support\Json;
use Tempest\Support\Namespace\Psr4Namespace;
use Tempest\Support\Path;
use Tempest\Support\Str;

use function Tempest\Support\arr;
use function Tempest\Support\Arr\wrap;
use function Tempest\Support\Path\normalize;
use function Tempest\Support\Str\ensure_ends_with;
use function Tempest\Support\Str\starts_with;

final class Composer
{
Expand All @@ -27,12 +26,12 @@ final class Composer

public function __construct(
private readonly string $root,
private ShellExecutor $executor,
private ProcessExecutor $executor,
) {}

public function load(): self
{
$this->composerPath = normalize($this->root, 'composer.json');
$this->composerPath = Path\normalize($this->root, 'composer.json');
$this->composer = $this->loadComposerFile($this->composerPath);
$this->namespaces = arr($this->composer)
->get('autoload.psr-4', default: arr())
Expand All @@ -42,7 +41,7 @@ public function load(): self
->toArray();

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

break;
Expand Down Expand Up @@ -73,12 +72,12 @@ public function setMainNamespace(Psr4Namespace $namespace): self

public function setNamespaces(Psr4Namespace|array $namespaces): self
{
$this->namespaces = wrap($namespaces);
$this->namespaces = Arr\wrap($namespaces);

return $this;
}

public function setShellExecutor(ShellExecutor $executor): self
public function setProcessExecutor(ProcessExecutor $executor): self
{
$this->executor = $executor;

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

public function executeUpdate(): self
{
$this->executor->execute('composer up');
$this->executor->run('composer up');

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/FrameworkKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Tempest\Core\Kernel\LoadDiscoveryClasses;
use Tempest\Core\Kernel\LoadDiscoveryLocations;
use Tempest\Core\Kernel\RegisterEmergencyExceptionHandler;
use Tempest\Core\ShellExecutors\GenericShellExecutor;
use Tempest\EventBus\EventBus;
use Tempest\Process\GenericProcessExecutor;

final class FrameworkKernel implements Kernel
{
Expand Down Expand Up @@ -98,7 +98,7 @@ public function loadComposer(): self
{
$composer = new Composer(
root: $this->root,
executor: new GenericShellExecutor(),
executor: new GenericProcessExecutor(),
)->load();

$this->container->singleton(Composer::class, $composer);
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/ShellExecutor.php

This file was deleted.

15 changes: 0 additions & 15 deletions packages/core/src/ShellExecutors/GenericShellExecutor.php

This file was deleted.

17 changes: 0 additions & 17 deletions packages/core/src/ShellExecutors/NullShellExecutor.php

This file was deleted.

14 changes: 14 additions & 0 deletions packages/process/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Exclude build/test files from the release
.github/ export-ignore
tests/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml export-ignore
README.md export-ignore

# Configure diff output
*.view.php diff=html
*.php diff=php
*.css diff=css
*.html diff=html
*.md diff=markdown
9 changes: 9 additions & 0 deletions packages/process/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2024 Brent Roose [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 changes: 23 additions & 0 deletions packages/process/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "tempest/process",
"description": "A component for working with processes.",
"license": "MIT",
"minimum-stability": "dev",
"require": {
"php": "^8.4",
"symfony/process": "^7.3",
"tempest/container": "dev-main",
"tempest/support": "dev-main",
"tempest/datetime": "dev-main"
},
"autoload": {
"psr-4": {
"Tempest\\Process\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tempest\\Process\\Tests\\": "tests"
}
}
}
23 changes: 23 additions & 0 deletions packages/process/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
displayDetailsOnPhpunitDeprecations="true"
failOnPhpunitDeprecation="false"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="Tempest Process">
<directory>tests</directory>
</testsuite>
</testsuites>
<source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
9 changes: 9 additions & 0 deletions packages/process/src/Exceptions/ProcessException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Tempest\Process\Exceptions;

use Throwable;

interface ProcessException extends Throwable
{
}
17 changes: 17 additions & 0 deletions packages/process/src/Exceptions/ProcessHasTimedOut.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Tempest\Process\Exceptions;

use Exception;
use Symfony\Component\Process\Exception\ProcessTimedOutException as SymfonyProcessTimedOutException;
use Tempest\Process\ProcessResult;

final class ProcessHasTimedOut extends Exception implements ProcessException
{
public function __construct(
public readonly ProcessResult $result,
public readonly SymfonyProcessTimedOutException $original,
) {
parent::__construct($original->getMessage(), $original->getCode(), $original);
}
}
Loading
Loading