Skip to content

Commit

Permalink
Update Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Feb 9, 2023
1 parent 15102f0 commit 3d7d06b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(UnsupportedArgument);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateAllArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateNotApplicable);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateNotApplicableReason);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateNoPackagesFound);
WINGET_DEFINE_RESOURCE_STRINGID(UpdateNoPackagesFoundReason);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeAvailableForPinned);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(UpgradeCommandShortDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ namespace AppInstaller::CLI::Workflow

if (!installItem)
{
context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl;
context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl
<< Resource::String::UpdateNotApplicableReason << std::endl;
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}

Expand Down
23 changes: 21 additions & 2 deletions src/AppInstallerCLICore/Workflows/UpdateFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ namespace AppInstaller::CLI::Workflow

// The version keys should have already been sorted by version
const auto& versionKeys = package->GetAvailableVersionKeys();
// Assume that no update versions are applicable
bool upgradeVersionApplicable = false;
for (const auto& key : versionKeys)
{
// Check Applicable Version
if (!isUpgrade || IsUpdateVersionApplicable(installedVersion, Utility::Version(key.Version)))
{
// The only way to enter this portion of the statement with isUpgrade is if the version is applicable
if (isUpgrade)
{
upgradeVersionApplicable = true;
}
auto packageVersion = package->GetAvailableVersion(key);
auto manifest = packageVersion->GetManifest();

Expand Down Expand Up @@ -124,7 +131,18 @@ namespace AppInstaller::CLI::Workflow
}
else if (isUpgrade)
{
context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl;
if (!upgradeVersionApplicable)
{
// This is the case when no newer versions are available in a configured source
context.Reporter.Info() << Resource::String::UpdateNoPackagesFound << std::endl
<< Resource::String::UpdateNoPackagesFoundReason << std::endl;
}
else
{
// This is the case when newer versions are available in a configured source, but none are applicable due to OS Version, user requirement, etc.
context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl
<< Resource::String::UpdateNotApplicableReason << std::endl;
}
}
else
{
Expand All @@ -144,7 +162,8 @@ namespace AppInstaller::CLI::Workflow

if (!IsUpdateVersionApplicable(installedVersion, updateVersion))
{
context.Reporter.Info() << Resource::String::UpdateNotApplicable << std::endl;
context.Reporter.Info() << Resource::String::UpdateNoPackagesFound << std::endl
<< Resource::String::UpdateNoPackagesFoundReason << std::endl;
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/AppInstallerCLICore/Workflows/WorkflowBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,8 @@ namespace AppInstaller::CLI::Workflow
context.Reporter.Info() << Resource::String::NoInstalledPackageFound << std::endl;
break;
case SearchPurpose::Upgrade:
context.Reporter.Info() << Resource::String::UpdateNoPackagesFound << std::endl;
context.Reporter.Info() << Resource::String::UpdateNoPackagesFound << std::endl
<< Resource::String::UpdateNoPackagesFoundReason << std::endl;
break;
case SearchPurpose::Completion:
case SearchPurpose::Install:
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,15 @@ They can be configured through the settings file 'winget settings'.</value>
<data name="UpdateNotApplicable" xml:space="preserve">
<value>No applicable upgrade found.</value>
</data>
<data name="UpdateNotApplicableReason" xml:space="preserve">
<value>A newer package version is available in a configured source, but it does not apply to your system or requirements.</value>
</data>
<data name="UpdateNoPackagesFound" xml:space="preserve">
<value>No available upgrades found.</value>
</data>
<data name="UpdateNoPackagesFoundReason" xml:space="preserve">
<value>No newer package versions are available from the configured sources.</value>
</data>
<data name="UpgradeCommandLongDescription" xml:space="preserve">
<value>Upgrades the selected package, either found by searching the installed packages list or directly from a manifest. By default, the query must case-insensitively match the id, name, or moniker of the package. Other fields can be used by passing their appropriate option. When no arguments are given, shows the packages with upgrades available</value>
<comment>id, name, and moniker are all named values in our context, and may benefit from not being translated. The match must be for any of them, with comparison ignoring case.</comment>
Expand Down
6 changes: 5 additions & 1 deletion src/AppInstallerCLITests/UpdateFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ TEST_CASE("UpdateFlow_UpdateWithManifestVersionAlreadyInstalled", "[UpdateFlow][
// Verify Installer is not called.
REQUIRE(!std::filesystem::exists(updateResultPath.GetPath()));
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicable).get()) != std::string::npos);
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicableReason).get()) != std::string::npos);
REQUIRE(context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}

Expand Down Expand Up @@ -403,7 +404,8 @@ TEST_CASE("UpdateFlow_UpdateExeLatestAlreadyInstalled", "[UpdateFlow][workflow]"

// Verify Installer is not called.
REQUIRE(!std::filesystem::exists(updateResultPath.GetPath()));
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicable).get()) != std::string::npos);
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNoPackagesFound).get()) != std::string::npos);
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNoPackagesFoundReason).get()) != std::string::npos);
REQUIRE(context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}

Expand Down Expand Up @@ -508,6 +510,7 @@ TEST_CASE("UpdateFlow_UpdateExeSpecificVersionNotApplicable", "[UpdateFlow][work
// Verify Installer is not called.
REQUIRE(!std::filesystem::exists(updateResultPath.GetPath()));
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicable).get()) != std::string::npos);
REQUIRE(updateOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicableReason).get()) != std::string::npos);
REQUIRE(context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}

Expand Down Expand Up @@ -907,6 +910,7 @@ TEST_CASE("InstallFlow_FoundInstalledAndUpgradeNotAvailable", "[UpdateFlow][work
// Verify Installer is not called.
REQUIRE(!std::filesystem::exists(installResultPath.GetPath()));
REQUIRE(installOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicable).get()) != std::string::npos);
REQUIRE(installOutput.str().find(Resource::LocString(Resource::String::UpdateNotApplicableReason).get()) != std::string::npos);
REQUIRE(context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE);
}

Expand Down

0 comments on commit 3d7d06b

Please sign in to comment.