From 2d4a27b7bcef81c9987b86d1a16a544615fbaef3 Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Tue, 14 Jan 2025 11:25:42 +0100 Subject: [PATCH] alternative way to support private packages --- src/Commands/BundleCommand.php | 40 +++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Commands/BundleCommand.php b/src/Commands/BundleCommand.php index ac49ed9..74b6520 100644 --- a/src/Commands/BundleCommand.php +++ b/src/Commands/BundleCommand.php @@ -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 { @@ -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'));