From c736a896fb69fea3e407f989a85d3633011aff3b Mon Sep 17 00:00:00 2001 From: Netkas Date: Fri, 13 Oct 2023 09:41:39 -0400 Subject: [PATCH] When finding package versions in the package lock, ncc will try to find a satisfying version rather than the exact version, this is to prevent errors when the package lock contains a version that is not available in the repository. --- CHANGELOG.md | 7 +++++++ src/ncc/Managers/ProjectManager.php | 9 ++++++++- src/ncc/Objects/PackageLock/PackageEntry.php | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c80d45b..35c1fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.3] - Unreleased + +### Fixed + - When finding package versions in the package lock, ncc will try to find a satisfying version rather than the exact + version, this is to prevent errors when the package lock contains a version that is not available in the repository. + + ## [2.0.2] - 2023-10-13 In this new update, the software introduces a feature for importing static packages without extra dependencies and diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 3b5d443..6e55750 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -681,7 +681,14 @@ $path = substr($path, 0, -1); } - $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $path); + if($path === '') + { + $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $project_path); + } + else + { + $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $path); + } if(is_file($source_path)) { diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index a541fc7..5206743 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -259,6 +259,11 @@ { return $version_entry; } + + if(Semver::satisfies($version_entry->getVersion(), $version)) + { + return $version_entry; + } } throw new InvalidArgumentException(sprintf('Version %s does not exist in package %s', $version, $this->name));