Adjust console output and PHPDoc

This commit is contained in:
crazywhalecc 2025-03-30 15:17:09 +08:00
parent 2c0bb1f7ba
commit 5648681ecc
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 37 additions and 8 deletions

View File

@ -212,7 +212,7 @@ class DownloadCommand extends BaseCommand
if (isset($config['filename'])) {
$new_config['filename'] = $config['filename'];
}
logger()->info("Fetching source {$source} from custom url [{$ni}/{$cnt}]");
logger()->info("[{$ni}/{$cnt}] Downloading source {$source} from custom url: {$new_config['url']}");
Downloader::downloadSource($source, $new_config, true);
} elseif (isset($custom_gits[$source])) {
$config = Config::getSource($source);
@ -224,7 +224,7 @@ class DownloadCommand extends BaseCommand
if (isset($config['path'])) {
$new_config['path'] = $config['path'];
}
logger()->info("Fetching source {$source} from custom git [{$ni}/{$cnt}]");
logger()->info("[{$ni}/{$cnt}] Downloading source {$source} from custom git: {$new_config['url']}");
Downloader::downloadSource($source, $new_config, true);
} else {
$config = Config::getSource($source);
@ -234,13 +234,13 @@ class DownloadCommand extends BaseCommand
$find = str_replace(['{name}', '{arch}', '{os}'], [$source, arch2gnu(php_uname('m')), strtolower(PHP_OS_FAMILY)], Config::getPreBuilt('match-pattern'));
// find filename in asset list
if (($url = $this->findPreBuilt($pre_built_libs, $find)) !== null) {
logger()->info("Fetching pre-built content {$source} [{$ni}/{$cnt}]");
logger()->info("[{$ni}/{$cnt}] Downloading pre-built content {$source}");
Downloader::downloadSource($source, ['type' => 'url', 'url' => $url], $force_all || in_array($source, $force_list), SPC_LOCK_PRE_BUILT);
continue;
}
logger()->warning("Pre-built content not found for {$source}, fallback to source download");
}
logger()->info("Fetching source {$source} [{$ni}/{$cnt}]");
logger()->info("[{$ni}/{$cnt}] Downloading source {$source}");
Downloader::downloadSource($source, $config, $force_all || in_array($source, $force_list));
}
}

View File

@ -284,8 +284,22 @@ class Downloader
}
/**
* @param string $name Package name
* @param null|array{
* type: string,
* repo: ?string,
* url: ?string,
* rev: ?string,
* path: ?string,
* filename: ?string,
* match: ?string,
* prefer-stable: ?bool,
* extract-files: ?array<string, string>
* } $pkg Package config
* @param bool $force Download all the time even if it exists
* @throws DownloaderException
* @throws FileSystemException
* @throws WrongUsageException
*/
public static function downloadPackage(string $name, ?array $pkg = null, bool $force = false): void
{
@ -383,8 +397,23 @@ class Downloader
/**
* Download source by name and meta.
*
* @param string $name source name
* @param null|array $source source meta info: [type, path, rev, url, filename, regex, license]
* @param string $name source name
* @param null|array{
* type: string,
* repo: ?string,
* url: ?string,
* rev: ?string,
* path: ?string,
* filename: ?string,
* match: ?string,
* prefer-stable: ?bool,
* provide-pre-built: ?bool,
* license: array{
* type: string,
* path: ?string,
* text: ?string
* }
* } $source source meta info: [type, path, rev, url, filename, regex, license]
* @param bool $force Whether to force download (default: false)
* @param int $lock_as Lock source type (default: SPC_LOCK_SOURCE)
* @throws DownloaderException
@ -415,11 +444,11 @@ class Downloader
// If lock file exists, skip downloading
if (isset($lock[$name]) && !$force && ($lock[$name]['lock_as'] ?? SPC_LOCK_SOURCE) === $lock_as) {
if ($lock[$name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename'])) {
logger()->notice("source [{$name}] already downloaded: " . $lock[$name]['filename']);
logger()->notice("Source [{$name}] already downloaded: " . $lock[$name]['filename']);
return;
}
if ($lock[$name]['source_type'] === 'dir' && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname'])) {
logger()->notice("source [{$name}] already downloaded: " . $lock[$name]['dirname']);
logger()->notice("Source [{$name}] already downloaded: " . $lock[$name]['dirname']);
return;
}
}