Skip to content

Refactor dependency management logic for consistency and separation from UI#7

Merged
niezbop merged 4 commits intoDragonBox:masterfrom
niezbop:fix/update_window
Nov 7, 2017
Merged

Refactor dependency management logic for consistency and separation from UI#7
niezbop merged 4 commits intoDragonBox:masterfrom
niezbop:fix/update_window

Conversation

@niezbop
Copy link
Copy Markdown
Member

@niezbop niezbop commented Nov 7, 2017

This makes sure that the dependency state is being kept tracked of in a consistent way, as well as keeping the lockfile udpated along update operations.

Improvements:

  • Extract logic from Uplift > Check Dependencies and the UpdateUtility window to only keep display role, and move that logic to the UpliftManager in GetDependenciesState().

  • Use the LogAggregator in Uplift > Check Dependencies so that it doesn't flood the console.

Fixes:

  • Previously mentionned refactoring made sure that the logic is consistent with the project requirements and the Update window will no longer allow to update to conflicting requirements.

  • InstallPackage has been lightly modified to make sure that Update actions will keep the lockfile updated.

Both of these fixes address #5

- Adds a method to the UpliftManager to keep track of the dependencies in
  your project, and what state they are in.

- Use this method to improve consistency in the menu Check Dependencies

- Use this method to improve consistency in the Update Window
return dependenciesState.ToArray();
}

public void AppendDependencyState(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make non public?

Upbring upbring = Upbring.Instance();
PackageRepo[] targets = GetTargets(GetDependencySolver(), InstallStrategy.UPDATE_LOCKFILE);

bool any_installed =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyInstalled?

GUI.enabled = true;
if(!definition.Requirement.IsMetBy(installed.Version))
EditorGUILayout.HelpBox(
"The version of the package currently installed does not match the requirements of your project!",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe display the version and the requirements?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this is not necessary as it is displayed just above:
capture d ecran 9

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still display it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine as is.

snapshot.installableDependencies[index].Package = package;
else
{
PackageRepo[] temp = snapshot.installableDependencies;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work?

snapshot.installableDependencies = Array.Resize<PackageRepo[]>(snapshot.installableDependencies, snapshot.installableDependencies.Length + 1);
snapshot.installableDependencies[snapshot.installableDependencies.Length] = = new PackageRepo { Package = package };

);

if(state.transitive)
message = "`--> " + string.Join(" \n", message.Split('\n'));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was the ` character expected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so this looks a bit like an arrow going down. I think it looks good, but we can remove it if you want

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‎________$$$$
_______$$__$
_______$___$$
_______$___$$
_______$$___$$
________$____$$
________$$____$$$
_________$$_____$$
_________$$______$$
__________$_______$$
____$$$$$$$________$$
__$$$_______________$$$$$$
_$$____$$$$____________$$$
_$___$$$__$$$____________$$
_$$________$$$____________$
__$$____$$$$$$____________$
__$$$$$$$____$$___________$
__$$_______$$$$___________$
___$$$$$$$$$__$$_________$$
____$________$$$$_____$$$$
____$$____$$$$$$____$$$$$$
_____$$$$$$____$$__$$
_______$_____$$$_$$$
________$$$$$$$$$$

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing though, do you approve, or do you think we should indeed remove it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep it

InstallPackages(targets);
}

public DependencyState[] GetDependenciesState(bool refresh = false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add the install strategy argument as in the above method's API? Adding it later would make them "out of order".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: we want to be sure that the install strategy is InstallStrategy.UPDATE_LOCKFILE to be sure that we get all the best targets that could update the packages.

ref List<DependencyState> dependenciesState,
DependencyDefinition definition,
PackageRepo[] targets,
bool any_installed,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyInstalled?

latest = PackageList.Instance().GetLatestPackage(definition.Name)
};

state.bestMatch = targets.First(pr => pr.Package.PackageName == definition.Name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we just refreshed, could that fail? I.e. targets.First return null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. We go through the dependencies as does the targets, so there should not be an issue. We can still check for null though, but what behaviour should we have then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep it as is

@niezbop niezbop changed the title Refactor dependency consistency Refactor dependency management logic for consistency and separation from UI Nov 7, 2017
@niezbop niezbop merged commit 0d59fb4 into DragonBox:master Nov 7, 2017
@niezbop niezbop deleted the fix/update_window branch November 7, 2017 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants