From 76f12bb0a3e4c546fd06ae82d9a1541233b47015 Mon Sep 17 00:00:00 2001 From: Netkas Date: Wed, 25 Oct 2023 17:57:51 -0400 Subject: [PATCH] Fixed issue where all development dependencies were not correctly being added to debug builds in composer projects, instead these dependencies were added globally to the build configuration. This issue was fixed by adding all the development dependencies to the debug build configurations only. This commit revises the handling of composer dependencies in 'ProjectManager.php'. A problem was encountered where software development dependencies were added globally to the build configuration, rather than exclusively to debug builds. By reassigning these dependencies to the debug configuration, this issue has been remedied. Additionally, a bug-fix in 'PackageReader.php' has been implemented to validate the package file by checking the data length. If the file is discovered to be invalid (data length is null or zero), an IOException is triggered. These changes enhance the accuracy of dependency management and improve the robustness of package validation. --- CHANGELOG.md | 5 ++++- src/ncc/Classes/PackageReader.php | 2 +- src/ncc/Managers/ProjectManager.php | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f69d8e0..e37f803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ This update introduces minor bug fixes. - Set default process timeouts to null - Fixed issue where a newline is sometimes added to the end of a download output due to how short the download process was, mitigated the issue by enforcing a "done" update at the end of the download process + - Fixed issue where all development dependencies were not correctly being added to debug builds in composer projects, + instead these dependencies were added globally to the build configuration. This issue was fixed by adding all the + development dependencies to the debug build configurations only. ## [2.0.3] - 2023-10-17 @@ -38,7 +41,7 @@ The changes improve the system's efficiency, error resilience, and user experien - Implemented support in the AST traversal for the PHP statements `include`, `include_once`, `require`, and `require_once`. These statements are transformed into function calls. With this change, ncc can correctly handle and import files from system packages or direct binary package files. - - Added new `ConsoleProgressBar` class for UI improvement, imrpoved the CLI Progress Bar inspired by + - Added new `ConsoleProgressBar` class for UI improvement, improved the CLI Progress Bar inspired by [pacman](https://wiki.archlinux.org/title/pacman) ### Fixed diff --git a/src/ncc/Classes/PackageReader.php b/src/ncc/Classes/PackageReader.php index d42c760..814f253 100644 --- a/src/ncc/Classes/PackageReader.php +++ b/src/ncc/Classes/PackageReader.php @@ -195,7 +195,7 @@ } } - if($this->data_length === null) + if($this->data_length === null || $this->data_length === 0) { throw new IOException(sprintf('File \'%s\' is not a valid package file (missing end of package)', $file_path)); } diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 6e55750..5366593 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -496,6 +496,7 @@ // Create the build configuration $build = new ProjectConfiguration\Build('auto_src'); $build->setDefaultConfiguration('release_ncc'); + $require_dev = []; // Process dependencies if($composer_json->getRequire() !== null) @@ -516,7 +517,6 @@ } // Process developer dependencies - $require_dev = []; if($composer_json->getRequireDev() !== null) { /** @var ComposerJson\PackageLink $package_link */ @@ -528,10 +528,9 @@ } $source = sprintf('%s=%s@packagist', $package_link->getPackageName(), $package_link->getVersion()); - $build->addDependency(new ProjectConfiguration\Dependency( + $require_dev[] = new ProjectConfiguration\Dependency( Resolver::composerNameToPackage($package_link->getPackageName()), $source, $package_link->getVersion() - )); - $require_dev[] = $package_link->getPackageName(); + ); } }