diff --git a/dload.xsd b/dload.xsd index a73eac3..7c79880 100644 --- a/dload.xsd +++ b/dload.xsd @@ -95,6 +95,11 @@ Repository name + + + Replacement source for the plugin (e.g., local path or alternative repository for Go module replacement) + + diff --git a/src/Module/Common/FileSystem/Path.php b/src/Module/Common/FileSystem/Path.php index 57447ef..59fd588 100644 --- a/src/Module/Common/FileSystem/Path.php +++ b/src/Module/Common/FileSystem/Path.php @@ -184,14 +184,16 @@ public function isFile(): bool /** * Return a normalized absolute version of this path + * + * @param non-empty-string|null $cwd Current working directory to resolve relative paths against. */ - public function absolute(): self + public function absolute(?string $cwd = null): self { if ($this->isAbsolute()) { return $this; } - $cwd = \getcwd(); + $cwd ??= \getcwd(); $cwd === false and throw new \RuntimeException('Cannot get current working directory.'); return self::create($cwd . self::DS . $this->path); } diff --git a/src/Module/Config/Schema/Action/Velox/Plugin.php b/src/Module/Config/Schema/Action/Velox/Plugin.php index a69f978..09542c9 100644 --- a/src/Module/Config/Schema/Action/Velox/Plugin.php +++ b/src/Module/Config/Schema/Action/Velox/Plugin.php @@ -34,4 +34,8 @@ final class Plugin /** @var non-empty-string|null $repository Repository name */ #[XPath('@repository')] public ?string $repository = null; + + /** @var non-empty-string|null $replace Replacement source */ + #[XPath('@replace')] + public ?string $replace = null; } diff --git a/src/Module/Velox/Internal/Config/Pipeline/Processor/BuildMixinsProcessor.php b/src/Module/Velox/Internal/Config/Pipeline/Processor/BuildMixinsProcessor.php index 020737a..fc12249 100644 --- a/src/Module/Velox/Internal/Config/Pipeline/Processor/BuildMixinsProcessor.php +++ b/src/Module/Velox/Internal/Config/Pipeline/Processor/BuildMixinsProcessor.php @@ -4,6 +4,7 @@ namespace Internal\DLoad\Module\Velox\Internal\Config\Pipeline\Processor; +use Internal\DLoad\Module\Common\FileSystem\Path; use Internal\DLoad\Module\Velox\Internal\Config\Pipeline\ConfigContext; use Internal\DLoad\Module\Velox\Internal\Config\Pipeline\ConfigProcessor; @@ -27,10 +28,28 @@ public function __invoke(ConfigContext $context): ConfigContext $appliedMixins[] = 'roadrunner_ref'; } + // Merge replacements + foreach ($context->action->plugins as $plugin) { + if ($plugin->replace === null) { + continue; + } + + + $tomlData = $tomlData->set( + 'github.plugins.' . $plugin->name . '.replace', + \str_starts_with($plugin->replace, 'github.com/') + ? $plugin->replace + : Path::create($plugin->replace)->absolute()->__toString(), + ); + } + + $tomlData = $tomlData->set('debug.enabled', $context->action->debug); $appliedMixins[] = 'debug_enabled'; + $tomlData->toToml(); - return $context->withTomlData($tomlData) + return $context + ->withTomlData($tomlData) ->addMetadata('build_mixins_applied', true) ->addMetadata('applied_mixins', $appliedMixins); }