-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallAndBuildProcess.php
More file actions
92 lines (78 loc) · 2.71 KB
/
InstallAndBuildProcess.php
File metadata and controls
92 lines (78 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
declare(strict_types=1);
namespace Php\Pie\ComposerIntegration;
use Composer\Package\CompletePackageInterface;
use Composer\PartialComposer;
use Php\Pie\Building\Build;
use Php\Pie\Building\PlaceholderReplacer;
use Php\Pie\DependencyResolver\Package;
use Php\Pie\Downloading\DownloadedPackage;
use Php\Pie\Installing\Install;
use function sprintf;
/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
class InstallAndBuildProcess
{
public function __construct(
private readonly Build $pieBuild,
private readonly Install $pieInstall,
private readonly InstalledJsonMetadata $installedJsonMetadata,
private readonly PlaceholderReplacer $placeholderReplacer,
) {
}
public function __invoke(
PartialComposer $composer,
PieComposerRequest $composerRequest,
CompletePackageInterface $composerPackage,
string $installPath,
): void {
$io = $composerRequest->pieOutput;
$downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath(
Package::fromComposerCompletePackage($composerPackage),
$installPath,
);
$io->write(sprintf(
'<info>Extracted %s source to:</info> %s',
$downloadedPackage->package->prettyNameAndVersion(),
$downloadedPackage->extractedSourcePath,
));
$this->placeholderReplacer->replacePlaceholdersWithPlaceholderReplacements(
$io,
$composerRequest->targetPlatform,
$downloadedPackage,
);
$this->installedJsonMetadata->addDownloadMetadata(
$composer,
$composerRequest,
$composerPackage,
);
$builtBinaryFile = null;
if ($composerRequest->operation->shouldBuild()) {
$builtBinaryFile = ($this->pieBuild)(
$downloadedPackage,
$composerRequest->targetPlatform,
$composerRequest->configureOptions,
$io,
);
$this->installedJsonMetadata->addBuildMetadata(
$composer,
$composerRequest,
$composerPackage,
$builtBinaryFile,
);
}
if (! $composerRequest->operation->shouldInstall()) {
return;
}
$this->installedJsonMetadata->addInstallMetadata(
$composer,
$composerPackage,
($this->pieInstall)(
$downloadedPackage,
$composerRequest->targetPlatform,
$builtBinaryFile,
$io,
$composerRequest->attemptToSetupIniFile,
),
);
}
}