Skip to content

Commit 76e5159

Browse files
authored
Merge pull request #22638 from abpframework/auto-merge/rel-9-2/3634
Merge branch dev with rel-9.2
2 parents 0e084d4 + 710cf67 commit 76e5159

File tree

4 files changed

+87
-26
lines changed

4 files changed

+87
-26
lines changed

docs/en/cli/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ Note that this command can upgrade your solution from a previous version, and al
342342
* `--solution-name` or `-sn`: Specify the solution name. Search `*.sln` files in the directory by default.
343343
* `--check-all`: Check the new version of each package separately. Default is `false`.
344344
* `--version` or `-v`: Specifies the version to use for update. If not specified, latest version is used.
345+
* * `--leptonx-version` or `-lv`: Specifies the LeptonX version to use for update. If not specified, latest version or the version that is compatible with `--version` argument is used.
345346

346347
### clean
347348

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,25 @@ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
3838
var directory = commandLineArgs.Options.GetOrNull(Options.SolutionPath.Short, Options.SolutionPath.Long) ??
3939
Directory.GetCurrentDirectory();
4040
var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long);
41+
var leptonXVersion = commandLineArgs.Options.GetOrNull(Options.LeptonXVersion.Short, Options.LeptonXVersion.Long);
4142

4243
if (updateNuget || !updateNpm)
4344
{
44-
await UpdateNugetPackages(commandLineArgs, directory, version);
45+
await UpdateNugetPackages(commandLineArgs, directory, version, leptonXVersion);
4546
}
4647

4748
if (updateNpm || !updateNuget)
4849
{
49-
await UpdateNpmPackages(directory, version);
50+
await UpdateNpmPackages(directory, version, leptonXVersion);
5051
}
5152
}
5253

53-
private async Task UpdateNpmPackages(string directory, string version)
54+
private async Task UpdateNpmPackages(string directory, string version, string leptonXVersion)
5455
{
55-
await _npmPackagesUpdater.Update(directory, version: version);
56+
await _npmPackagesUpdater.Update(directory, version: version, leptonXVersion: leptonXVersion);
5657
}
5758

58-
private async Task UpdateNugetPackages(CommandLineArgs commandLineArgs, string directory, string version)
59+
private async Task UpdateNugetPackages(CommandLineArgs commandLineArgs, string directory, string version, string leptonXVersion)
5960
{
6061
var solutions = new List<string>();
6162
var givenSolution = commandLineArgs.Options.GetOrNull(Options.SolutionName.Short, Options.SolutionName.Long);
@@ -77,7 +78,7 @@ private async Task UpdateNugetPackages(CommandLineArgs commandLineArgs, string d
7778
{
7879
var solutionName = Path.GetFileName(solution).RemovePostFix(".sln");
7980

80-
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(solution, checkAll: checkAll, version: version);
81+
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(solution, checkAll: checkAll, version: version, leptonXVersion: leptonXVersion);
8182

8283
Logger.LogInformation("Volo packages are updated in {SolutionName} solution", solutionName);
8384
}
@@ -90,7 +91,7 @@ private async Task UpdateNugetPackages(CommandLineArgs commandLineArgs, string d
9091
{
9192
var projectName = Path.GetFileName(project).RemovePostFix(".csproj");
9293

93-
await _nugetPackagesVersionUpdater.UpdateProjectAsync(project, checkAll: checkAll, version: version);
94+
await _nugetPackagesVersionUpdater.UpdateProjectAsync(project, checkAll: checkAll, version: version, leptonXVersion: leptonXVersion);
9495

9596
Logger.LogInformation("Volo packages are updated in {ProjectName} project", projectName);
9697
return;
@@ -120,6 +121,7 @@ public string GetUsageInfo()
120121
sb.AppendLine("-sn|--solution-name (Specify the solution name)");
121122
sb.AppendLine("--check-all (Check the new version of each package separately)");
122123
sb.AppendLine("-v|--version <version> (default: latest version)");
124+
sb.AppendLine("-lv|--leptonx-version <version> (default: latest LeptonX version)");
123125
sb.AppendLine("");
124126
sb.AppendLine("Some examples:");
125127
sb.AppendLine("");
@@ -167,5 +169,11 @@ public static class Version
167169
public const string Short = "v";
168170
public const string Long = "version";
169171
}
172+
173+
public static class LeptonXVersion
174+
{
175+
public const string Short = "lv";
176+
public const string Long = "leptonx-version";
177+
}
170178
}
171179
}

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public NpmPackagesUpdater(
5050

5151
public async Task Update(string rootDirectory, bool includePreviews = false,
5252
bool includeReleaseCandidates = false,
53-
bool switchToStable = false, string version = null, bool includePreRc = false)
53+
bool switchToStable = false, string version = null, string leptonXVersion = null, bool includePreRc = false)
5454
{
5555
var fileList = _packageJsonFileFinder.Find(rootDirectory);
5656

@@ -80,6 +80,7 @@ async Task UpdateAsync(string file)
8080
var updated = await UpdatePackagesInFile(file, includePreviews, includeReleaseCandidates,
8181
switchToStable,
8282
version,
83+
leptonXVersion,
8384
includePreRc);
8485

8586
packagesUpdated.TryAdd(file, updated);
@@ -162,6 +163,7 @@ protected virtual async Task<bool> UpdatePackagesInFile(
162163
bool includeReleaseCandidates = false,
163164
bool switchToStable = false,
164165
string specifiedVersion = null,
166+
string specifiedLeptonXVersion = null,
165167
bool includePreRc = false)
166168
{
167169
var packagesUpdated = false;
@@ -177,7 +179,7 @@ protected virtual async Task<bool> UpdatePackagesInFile(
177179
foreach (var abpPackage in abpPackages)
178180
{
179181
var updated = await TryUpdatingPackage(filePath, abpPackage, includePreviews, includeReleaseCandidates,
180-
switchToStable, specifiedVersion, includePreRc);
182+
switchToStable, specifiedVersion, specifiedLeptonXVersion, includePreRc);
181183

182184
if (updated)
183185
{
@@ -188,7 +190,7 @@ protected virtual async Task<bool> UpdatePackagesInFile(
188190
var updatedContent = packageJson.ToString(Formatting.Indented);
189191

190192
File.WriteAllText(filePath, updatedContent);
191-
193+
192194
return packagesUpdated;
193195
}
194196

@@ -199,6 +201,7 @@ protected virtual async Task<bool> TryUpdatingPackage(
199201
bool includeReleaseCandidates = false,
200202
bool switchToStable = false,
201203
string specifiedVersion = null,
204+
string specifiedLeptonXVersion = null,
202205
bool includePreRc = false)
203206
{
204207
var currentVersion = (string)package.Value;
@@ -207,18 +210,36 @@ protected virtual async Task<bool> TryUpdatingPackage(
207210

208211
if (!specifiedVersion.IsNullOrWhiteSpace())
209212
{
210-
if (!SpecifiedVersionExists(specifiedVersion, package))
213+
if (package.Name.IndexOf("leptonx", StringComparison.InvariantCultureIgnoreCase) > 0 && !specifiedLeptonXVersion.IsNullOrWhiteSpace())
211214
{
212-
return false;
213-
}
215+
if (!SpecifiedVersionExists(specifiedLeptonXVersion, package))
216+
{
217+
return false;
218+
}
214219

215-
if (SemanticVersion.Parse(specifiedVersion) <=
216-
SemanticVersion.Parse(currentVersion.RemovePreFix("~", "^")))
217-
{
218-
return false;
220+
if (SemanticVersion.Parse(specifiedLeptonXVersion) <=
221+
SemanticVersion.Parse(currentVersion.RemovePreFix("~", "^")))
222+
{
223+
return false;
224+
}
225+
226+
version = specifiedLeptonXVersion.EnsureStartsWith('^');
219227
}
228+
else
229+
{
230+
if (!SpecifiedVersionExists(specifiedVersion, package))
231+
{
232+
return false;
233+
}
220234

221-
version = specifiedVersion.EnsureStartsWith('^');
235+
if (SemanticVersion.Parse(specifiedVersion) <=
236+
SemanticVersion.Parse(currentVersion.RemovePreFix("~", "^")))
237+
{
238+
return false;
239+
}
240+
241+
version = specifiedVersion.EnsureStartsWith('^');
242+
}
222243
}
223244
else
224245
{

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ public VoloNugetPackagesVersionUpdater(PackageVersionCheckerService packageVersi
2727
Logger = NullLogger<VoloNugetPackagesVersionUpdater>.Instance;
2828
}
2929

30-
public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, bool checkAll = false, string version = null)
30+
public async Task UpdateSolutionAsync(
31+
string solutionPath,
32+
bool includePreviews = false,
33+
bool includeReleaseCandidates = false,
34+
bool switchToStable = false,
35+
bool checkAll = false,
36+
string version = null,
37+
string leptonXVersion = null)
3138
{
3239
var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);
3340

@@ -58,6 +65,7 @@ async Task UpdateAsync(string filePath)
5865
latestReleaseCandidateVersionInfo.Version,
5966
latestVersionFromMyGet,
6067
version,
68+
leptonXVersion,
6169
latestStableVersions: latestStableVersions);
6270

6371
fs.Seek(0, SeekOrigin.Begin);
@@ -75,7 +83,14 @@ async Task UpdateAsync(string filePath)
7583
}
7684
}
7785

78-
public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, bool checkAll = false, string version = null)
86+
public async Task UpdateProjectAsync(
87+
string projectPath,
88+
bool includeNightlyPreviews = false,
89+
bool includeReleaseCandidates = false,
90+
bool switchToStable = false,
91+
bool checkAll = false,
92+
string version = null,
93+
string leptonXVersion = null)
7994
{
8095
if (checkAll && version.IsNullOrWhiteSpace())
8196
{
@@ -102,6 +117,7 @@ public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPrev
102117
latestReleaseCandidateVersionInfo.Version,
103118
latestVersionFromMyGet,
104119
version,
120+
leptonXVersion,
105121
latestStableVersions: latestStableVersions);
106122

107123
fs.Seek(0, SeekOrigin.Begin);
@@ -166,6 +182,7 @@ private async Task<string> UpdateVoloPackagesAsync(string content,
166182
SemanticVersion latestNugetReleaseCandidateVersion = null,
167183
string latestMyGetVersion = null,
168184
string specifiedVersion = null,
185+
string specifiedLeptonXVersion = null,
169186
List<PackageVersionCheckerService.LatestStableVersionResult> latestStableVersions = null)
170187
{
171188
string packageId = null;
@@ -222,21 +239,35 @@ private async Task<string> UpdateVoloPackagesAsync(string content,
222239
var leptonXPackageVersion = latestStableVersions?
223240
.FirstOrDefault(v => v.Version.Equals(specifiedVersion, StringComparison.InvariantCultureIgnoreCase))?.LeptonX?.Version;
224241

225-
if ((isLeptonXPackage && string.IsNullOrWhiteSpace(leptonXPackageVersion)) || isStudioPackage)
242+
if ((isLeptonXPackage && string.IsNullOrWhiteSpace(leptonXPackageVersion) && specifiedLeptonXVersion.IsNullOrWhiteSpace()) || isStudioPackage)
226243
{
227244
Logger.LogWarning("Package: {PackageId} could not be updated. Please manually update the package version yourself to prevent version mismatches!", packageId);
228245
continue;
229246
}
230247

231-
var isLeptonXPackageWithVersion = isLeptonXPackage && !string.IsNullOrWhiteSpace(leptonXPackageVersion);
232-
233-
if (isLeptonXPackageWithVersion || await SpecifiedVersionExists(specifiedVersion, packageId))
248+
if (isLeptonXPackage)
234249
{
235-
TryUpdatingPackage(isLeptonXPackageWithVersion ? leptonXPackageVersion : specifiedVersion);
250+
var isLeptonXPackageWithVersion = isLeptonXPackage && !string.IsNullOrWhiteSpace(leptonXPackageVersion);
251+
252+
if (isLeptonXPackageWithVersion || await SpecifiedVersionExists(specifiedLeptonXVersion, packageId))
253+
{
254+
TryUpdatingPackage(specifiedLeptonXVersion ?? leptonXPackageVersion);
255+
}
256+
else
257+
{
258+
Logger.LogWarning($"Package \"{packageId}\" specified version v{specifiedLeptonXVersion} does not exist!");
259+
}
236260
}
237261
else
238262
{
239-
Logger.LogWarning("Package \"{PackageId}\" specified version v{SpecifiedVersion} does not exist!", packageId, specifiedVersion);
263+
if (await SpecifiedVersionExists(specifiedVersion, packageId))
264+
{
265+
TryUpdatingPackage(specifiedVersion);
266+
}
267+
else
268+
{
269+
Logger.LogWarning($"Package \"{packageId}\" specified version v{specifiedVersion} does not exist!");
270+
}
240271
}
241272

242273
void TryUpdatingPackage(string versionToUpdate)

0 commit comments

Comments
 (0)