Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Sep 20, 2023
1 parent c6e81d3 commit 3c9b735
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 7.0.1

* Fix issue where dependencies installed in ways other then box.json would be overwritten when marked as a dependency of another extension. Causing issues with the wrong versions of software being installed.

## 7.0.0

Rewrite of core commands to bring up to date with latest changes and approaches from Commandbox. We now use cfconfig
Expand Down
47 changes: 29 additions & 18 deletions interceptors/PresideCommandsPostInstallInterceptor.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ component {

for( var dependencySlug in dependencies ) {
var dependency = dependencies[ dependencySlug ]
if ( !_dependencyAlreadyInstalled( dependencySlug, dependency, containerBoxJson, packageSlug ) ) {
if ( !_dependencyAlreadyInstalled( dependencySlug, dependency, containerBoxJson, packageSlug, arguments.installDirectory ) ) {
var installVersion = dependency.installVersion ?: dependencySlug;
if ( !installVersion contains dependencySlug && !installVersion contains "@" ) {
installVersion = dependencySlug & "@" & installVersion;
Expand All @@ -104,27 +104,38 @@ component {
}
}

private boolean function _dependencyAlreadyInstalled( required string dependencySlug, required struct dependencyInfo, required struct containerBoxJson, required string packageSlug ) {
private boolean function _dependencyAlreadyInstalled( required string dependencySlug, required struct dependencyInfo, required struct containerBoxJson, required string packageSlug, required string installDirectory ) {
var hasMinVer = Len( Trim( dependencyInfo.minVersion ?: "" ) );
var hasMaxVer = Len( Trim( dependencyInfo.maxVersion ?: "" ) );
var versionInstalled = "";
var depBoxJsonLocation = arguments.installDirectory & "/#dependencySlug#/box.json";

if ( StructKeyExists( containerBoxJson.dependencies, dependencySlug ) ) {
var hasMinVer = Len( Trim( dependencyInfo.minVersion ?: "" ) );
var hasMaxVer = Len( Trim( dependencyInfo.maxVersion ?: "" ) );
versionInstalled = containerBoxJson.dependencies[ dependencySlug ];
} else if ( FileExists( depBoxJsonLocation ) ) {
try {
var depboxjson = DeserializeJson( FileRead( depBoxJsonLocation ) );
} catch( any e ) {
return false;
}

if ( hasMinVer || hasMaxVer ) {
var installedVersionRange = containerBoxJson.dependencies[ dependencySlug ];
if ( ListLen( installedVersionRange, "##@" ) == 2 ) {
installedVersionRange = ListRest( installedVersionRange, "##@" );
}
if ( ListLen( installedVersionRange, "-" ) > 1 ) {
installedVersionRange = ListFirst( installedVersionRange, "-" );
}
versionInstalled = depboxjson.version ?: "";
}

if ( hasMinVer && semanticVersion.compare( dependencyInfo.minVersion, installedVersionRange ) == 1 ) {
throw( type="preside.extension.dependency.version.mismatch", message="The already installed dependency [#dependencySlug#] of package [#packageSlug#] does not meet the minimum version requirement of [#dependencyInfo.minVersion#]. Please upgrade your [#dependencySlug#] extension to continue." );
}
if ( Len( Trim( versionInstalled ) ) && ( hasMinVer || hasMaxVer ) ) {
if ( ListLen( versionInstalled, "##@" ) == 2 ) {
versionInstalled = ListRest( versionInstalled, "##@" );
}
if ( ListLen( versionInstalled, "-" ) > 1 ) {
versionInstalled = ListFirst( versionInstalled, "-" );
}

if ( hasMaxVer && semanticVersion.compare( installedVersionRange, dependencyInfo.maxVersion ) == 1 ) {
throw( type="preside.extension.dependency.version.mismatch", message="The already installed dependency [#dependencySlug#] of package [#packageSlug#] exceeds the maximum version requirement of [#dependencyInfo.maxVersion#]. You will need to manually resolve this situation by either downgrading [#dependencySlug#], installing a later version of [#packageSlug#], or getting the package maintainers of [#packageSlug#] to update the package to be compatible with later versions of [#dependencySlug#]." );
}
if ( hasMinVer && semanticVersion.compare( dependencyInfo.minVersion, versionInstalled ) == 1 ) {
throw( type="preside.extension.dependency.version.mismatch", message="The already installed dependency [#dependencySlug#] of package [#packageSlug#] does not meet the minimum version requirement of [#dependencyInfo.minVersion#]. Please upgrade your [#dependencySlug#] extension to continue." );
}

if ( hasMaxVer && semanticVersion.compare( versionInstalled, dependencyInfo.maxVersion ) == 1 ) {
throw( type="preside.extension.dependency.version.mismatch", message="The already installed dependency [#dependencySlug#] of package [#packageSlug#] exceeds the maximum version requirement of [#dependencyInfo.maxVersion#]. You will need to manually resolve this situation by either downgrading [#dependencySlug#], installing a later version of [#packageSlug#], or getting the package maintainers of [#packageSlug#] to update the package to be compatible with later versions of [#dependencySlug#]." );
}

return true;
Expand Down

0 comments on commit 3c9b735

Please sign in to comment.