Add dump license files after installing

This commit is contained in:
crazywhalecc 2026-02-02 16:53:28 +08:00
parent 19e11caa83
commit a6c79e30a8
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680

View File

@ -17,6 +17,7 @@ use StaticPHP\Util\DependencyResolver;
use StaticPHP\Util\FileSystem; use StaticPHP\Util\FileSystem;
use StaticPHP\Util\GlobalEnvManager; use StaticPHP\Util\GlobalEnvManager;
use StaticPHP\Util\InteractiveTerm; use StaticPHP\Util\InteractiveTerm;
use StaticPHP\Util\LicenseDumper;
use StaticPHP\Util\V2CompatLayer; use StaticPHP\Util\V2CompatLayer;
use ZM\Logger\ConsoleColor; use ZM\Logger\ConsoleColor;
@ -208,6 +209,11 @@ class PackageInstaller
} }
} }
} }
$this->dumpLicenseFiles($this->packages);
if ($interactive) {
InteractiveTerm::success('Exported package licenses', true);
}
} }
public function isBuildPackage(Package|string $package): bool public function isBuildPackage(Package|string $package): bool
@ -460,6 +466,21 @@ class PackageInstaller
return null; return null;
} }
/**
* @param Package[] $packages
*/
private function dumpLicenseFiles(array $packages): void
{
$dumper = new LicenseDumper();
foreach ($packages as $package) {
$artifact = $package->getArtifact();
if ($artifact !== null) {
$dumper->addArtifacts([$artifact->getName()]);
}
}
$dumper->dump(BUILD_ROOT_PATH . '/license');
}
/** /**
* Validate that a package has required artifacts. * Validate that a package has required artifacts.
*/ */