mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 09:25:35 +08:00
Enhance package management in CraftCommand by merging craft-level packages and shared extensions into build options
This commit is contained in:
@@ -23,6 +23,9 @@ class PackageBuilder
|
||||
/** @var int make jobs count */
|
||||
public readonly int $concurrency;
|
||||
|
||||
/** @var array<string, mixed> Build arguments */
|
||||
protected array $arguments = [];
|
||||
|
||||
/**
|
||||
* @param array $options Builder options
|
||||
*/
|
||||
@@ -101,6 +104,16 @@ class PackageBuilder
|
||||
return $this->options[$key] ?? $default;
|
||||
}
|
||||
|
||||
public function setArgument(string $key, mixed $value): void
|
||||
{
|
||||
$this->arguments[$key] = $value;
|
||||
}
|
||||
|
||||
public function getArgument(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return $this->arguments[$key] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy the binary file from src to dst.
|
||||
*/
|
||||
|
||||
@@ -106,6 +106,14 @@ class TargetPackage extends LibraryPackage
|
||||
if ($input !== null && $input->hasArgument($key)) {
|
||||
return $input->getArgument($key);
|
||||
}
|
||||
|
||||
// fallback to builder arguments (set programmatically, e.g. from CraftCommand)
|
||||
$builder = ApplicationContext::has(PackageBuilder::class)
|
||||
? ApplicationContext::get(PackageBuilder::class)
|
||||
: null;
|
||||
if ($builder !== null && ($arg = $builder->getArgument($key)) !== null) {
|
||||
return $arg;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user