info('Pushing Flux assets to CDN...'); $assets = $flux->getCdnAssetPaths(); if (empty($assets)) { $this->warn('No Flux assets found to push.'); return self::SUCCESS; } $dryRun = $this->option('dry-run'); foreach ($assets as $sourcePath => $cdnPath) { if (! file_exists($sourcePath)) { $this->warn("Source file not found: {$sourcePath}"); continue; } $size = $this->formatBytes(filesize($sourcePath)); if ($dryRun) { $this->line(" [DRY-RUN] Would upload: {$cdnPath} ({$size})"); continue; } $this->line(" Uploading: {$cdnPath} ({$size})"); $contents = file_get_contents($sourcePath); $success = $cdn->storePublic($cdnPath, $contents, pushToCdn: true); if ($success) { $this->info(' ✓ Uploaded to CDN'); } else { $this->error(' ✗ Failed to upload'); } } if (! $dryRun) { $this->newLine(); $this->info('Flux assets pushed to CDN successfully.'); $this->line('CDN URL: '.config('cdn.urls.cdn').'/flux/'); } return self::SUCCESS; } protected function formatBytes(int $bytes): string { if ($bytes >= 1048576) { return round($bytes / 1048576, 2).' MB'; } if ($bytes >= 1024) { return round($bytes / 1024, 2).' KB'; } return $bytes.' bytes'; } }