Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only outputWarning for templates. #19095

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,61 +93,63 @@
version = latestVersion;
}

var currentCliVersion = await CliVersionService.GetCurrentCliVersionAsync();
var templateVersion = SemanticVersion.Parse(version);

var outputWarning = false;
if (!trustUserVersion)
if (type == SourceCodeTypes.Template)
{
if (currentCliVersion.Major != templateVersion.Major || currentCliVersion.Minor != templateVersion.Minor)
{
// major and minor version are different
outputWarning = true;
}
else if (currentCliVersion.Major == templateVersion.Major &&
currentCliVersion.Minor == templateVersion.Minor &&
currentCliVersion.Patch < templateVersion.Patch)
{
// major and minor version are same but patch version is lower
outputWarning = true;
}
else if(currentCliVersion.Major == templateVersion.Major &&
currentCliVersion.Minor == templateVersion.Minor &&
currentCliVersion.Patch == templateVersion.Patch &&
currentCliVersion.IsPrerelease && templateVersion.IsPrerelease)
var currentCliVersion = await CliVersionService.GetCurrentCliVersionAsync();
var templateVersion = SemanticVersion.Parse(version);

Check warning on line 99 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L98-L99

Added lines #L98 - L99 were not covered by tests

var outputWarning = false;

Check warning on line 101 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L101

Added line #L101 was not covered by tests
if (!trustUserVersion)
{
// major and minor and patch version are same but prerelease version may be lower
var cliRcVersion = currentCliVersion.ReleaseLabels.LastOrDefault();
var templateRcVersion = templateVersion.ReleaseLabels.LastOrDefault();
if (cliRcVersion != null && templateRcVersion != null)
if (currentCliVersion.Major != templateVersion.Major || currentCliVersion.Minor != templateVersion.Minor)
{

Check warning on line 105 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L105

Added line #L105 was not covered by tests
// major and minor version are different
outputWarning = true;
}

Check warning on line 108 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L107-L108

Added lines #L107 - L108 were not covered by tests
else if (currentCliVersion.Major == templateVersion.Major &&
currentCliVersion.Minor == templateVersion.Minor &&
currentCliVersion.Patch < templateVersion.Patch)
{

Check warning on line 112 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L110-L112

Added lines #L110 - L112 were not covered by tests
// major and minor version are same but patch version is lower
outputWarning = true;
}

Check warning on line 115 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L114-L115

Added lines #L114 - L115 were not covered by tests
else if(currentCliVersion.Major == templateVersion.Major &&
currentCliVersion.Minor == templateVersion.Minor &&
currentCliVersion.Patch == templateVersion.Patch &&
currentCliVersion.IsPrerelease && templateVersion.IsPrerelease)

Check warning on line 119 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L117-L119

Added lines #L117 - L119 were not covered by tests
{
if (int.TryParse(cliRcVersion, out var cliRcVersionNumber) && int.TryParse(templateRcVersion, out var templateRcVersionNumber))
// major and minor and patch version are same but prerelease version may be lower
var cliRcVersion = currentCliVersion.ReleaseLabels.LastOrDefault();
var templateRcVersion = templateVersion.ReleaseLabels.LastOrDefault();

Check warning on line 123 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L122-L123

Added lines #L122 - L123 were not covered by tests
if (cliRcVersion != null && templateRcVersion != null)
{
if (cliRcVersionNumber < templateRcVersionNumber)
if (int.TryParse(cliRcVersion, out var cliRcVersionNumber) && int.TryParse(templateRcVersion, out var templateRcVersionNumber))
{
outputWarning = true;
if (cliRcVersionNumber < templateRcVersionNumber)
{
outputWarning = true;
}

Check warning on line 131 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L129-L131

Added lines #L129 - L131 were not covered by tests
}
}
}
}
}

if (outputWarning)
{
version = currentCliVersion.ToString();
Logger.LogWarning(userSpecifiedVersion
? $"The specified template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues."
: $"The latest template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues.");
Logger.LogWarning("Please upgrade/downgrade the CLI version to the template version.");
Logger.LogWarning($"> dotnet tool uninstall -g volo.abp.cli");
Logger.LogWarning(!templateVersion.IsPrerelease
? $"> dotnet tool install -g volo.abp.cli --version \"{templateVersion.Major}.{templateVersion.Minor}.*\""
: $"> dotnet tool install -g volo.abp.cli --version {templateVersion}");

if (userSpecifiedVersion)
if (outputWarning)
{
Logger.LogWarning($"We have changed the template version as the cli version.");
Logger.LogWarning($"New version: {version}");
Logger.LogWarning(userSpecifiedVersion
? $"The specified template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues."
: $"The latest template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues.");
Logger.LogWarning("Please upgrade/downgrade the CLI version to the template version.");
Logger.LogWarning($"> dotnet tool uninstall -g volo.abp.cli");

Check warning on line 143 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L140-L143

Added lines #L140 - L143 were not covered by tests
Logger.LogWarning(!templateVersion.IsPrerelease
? $"> dotnet tool install -g volo.abp.cli --version \"{templateVersion.Major}.{templateVersion.Minor}.*\""
: $"> dotnet tool install -g volo.abp.cli --version {templateVersion}");

Check warning on line 146 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L145-L146

Added lines #L145 - L146 were not covered by tests

if (userSpecifiedVersion)
{
Logger.LogWarning($"We have changed the template version as the cli version.");
Logger.LogWarning($"New version: {version}");
}

Check warning on line 152 in framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

View check run for this annotation

Codecov / codecov/patch

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs#L149-L152

Added lines #L149 - L152 were not covered by tests
}
}

Expand Down