mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 15:25:41 +08:00
refactor lock file constant out
This commit is contained in:
@@ -12,6 +12,7 @@ use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\Downloader;
|
||||
use SPC\store\LockFile;
|
||||
use SPC\util\DependencyUtil;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -301,7 +302,7 @@ class DownloadCommand extends BaseCommand
|
||||
throw new WrongUsageException('Windows currently does not support --from-zip !');
|
||||
}
|
||||
|
||||
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
|
||||
if (!file_exists(LockFile::LOCK_FILE)) {
|
||||
throw new RuntimeException('.lock.json not exist in "downloads/"');
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
|
||||
@@ -10,7 +10,7 @@ use SPC\exception\WrongUsageException;
|
||||
|
||||
class LockFile
|
||||
{
|
||||
private const string LOCK_FILE = DOWNLOAD_PATH . '/.lock.json';
|
||||
public const string LOCK_FILE = DOWNLOAD_PATH . '/.lock.json';
|
||||
|
||||
private static ?array $lock_file_content = null;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace SPC\store\pkg;
|
||||
|
||||
use SPC\store\Downloader;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\LockFile;
|
||||
|
||||
class GoModFrankenphp extends CustomPackage
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class GoModFrankenphp extends CustomPackage
|
||||
public function extract(string $name): void
|
||||
{
|
||||
$pkgroot = PKG_ROOT_PATH;
|
||||
$lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true);
|
||||
$lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true);
|
||||
$source_type = $lock[$name]['source_type'];
|
||||
$filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']);
|
||||
$extract = $lock[$name]['move_path'] === null ? "{$pkgroot}/{$name}" : $lock[$name]['move_path'];
|
||||
|
||||
Reference in New Issue
Block a user