Refactor lock component to a single class (#773)

This commit is contained in:
Jerry Ma
2025-06-18 14:05:43 +08:00
committed by GitHub
parent 1c439a01a1
commit ba0ea5b40a
10 changed files with 284 additions and 147 deletions

View File

@@ -33,10 +33,11 @@ class PackageManager
// Download package
Downloader::downloadPackage($pkg_name, $config, $force);
// After download, read lock file name
$lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true);
$source_type = $lock[$pkg_name]['source_type'];
$filename = DOWNLOAD_PATH . '/' . ($lock[$pkg_name]['filename'] ?? $lock[$pkg_name]['dirname']);
$extract = $lock[$pkg_name]['move_path'] === null ? (PKG_ROOT_PATH . '/' . $pkg_name) : $lock[$pkg_name]['move_path'];
$lock = LockFile::get($pkg_name);
$source_type = $lock['source_type'];
$filename = LockFile::getLockFullPath($lock);
$extract = LockFile::getExtractPath($pkg_name, PKG_ROOT_PATH . '/' . $pkg_name);
FileSystem::extractPackage($pkg_name, $source_type, $filename, $extract);
// if contains extract-files, we just move this file to destination, and remove extract dir