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
5 changes: 5 additions & 0 deletions dload.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
<xs:documentation>Repository name</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="replace" type="xs:string">
<xs:annotation>
<xs:documentation>Replacement source for the plugin (e.g., local path or alternative repository for Go module replacement)</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
Expand Down
6 changes: 4 additions & 2 deletions src/Module/Common/FileSystem/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Module/Config/Schema/Action/Velox/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
Loading