Skip to content

Commit

Permalink
alternative way to support private packages
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Jan 14, 2025
1 parent 26477cd commit 2d4a27b
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/Commands/BundleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,30 @@ private function checkComposerJson(): bool
$this->error('Symlinked packages are not supported. Please remove them from your composer.json.');

return false;
} elseif ($repository['type'] === 'composer') {
if (! $this->checkComposerPackageAuth($repository['url'])) {
$this->error('Cannot authenticate with '.$repository['url'].'.');
$this->error('Go to '.$this->baseUrl().' and add your credentials for '.$repository['url'].'.');

return false;
}
}
// elseif ($repository['type'] === 'composer') {
// if (! $this->checkComposerPackageAuth($repository['url'])) {
// $this->error('Cannot authenticate with '.$repository['url'].'.');
// $this->error('Go to '.$this->baseUrl().' and add your composer package credentials.');
//
// return false;
// }
// }
}

return true;
}

private function checkComposerPackageAuth(string $repositoryUrl): bool
{
$host = parse_url($repositoryUrl, PHP_URL_HOST);
$this->line('Checking '.$host.' authentication…');

return Http::acceptJson()
->withToken(config('nativephp-internal.zephpyr.token'))
->get($this->baseUrl().'api/v1/project/'.$this->key.'/composer/auth/'.$host)
->successful();
}
// private function checkComposerPackageAuth(string $repositoryUrl): bool
// {
// $host = parse_url($repositoryUrl, PHP_URL_HOST);
// $this->line('Checking '.$host.' authentication…');
//
// return Http::acceptJson()
// ->withToken(config('nativephp-internal.zephpyr.token'))
// ->get($this->baseUrl().'api/v1/project/'.$this->key.'/composer/auth/'.$host)
// ->successful();
// }

private function addFilesToZip(ZipArchive $zip): void
{
Expand All @@ -165,9 +166,12 @@ private function addFilesToZip(ZipArchive $zip): void

$this->finderToZip($app, $zip);

// Add .env file
// Add .env file manually because Finder ignores hidden files
$zip->addFile(base_path('.env'), '.env');

// Add auth.json file to support private packages
$zip->addFile(base_path('auth.json'), 'auth.json');

// Custom binaries
$binaryPath = Str::replaceStart(base_path('vendor'), '', config('nativephp.binary_path'));

Expand Down

0 comments on commit 2d4a27b

Please sign in to comment.