From b9f10fc2da37fabc9c9c4c014b96272da32947d2 Mon Sep 17 00:00:00 2001 From: enisn Date: Fri, 14 Aug 2026 14:36:35 +0300 Subject: [PATCH] Update React dependencies with ABP CLI --- .../PackageJsonFileFinder.cs | 4 +- .../PackageJsonFileFinder_Tests.cs | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder_Tests.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder.cs index a280f55ca0..2dc6ec31ea 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder.cs @@ -33,6 +33,8 @@ public class PackageJsonFileFinder : ITransientDependency return Directory.GetFiles(directory, "*.csproj", searchOption: SearchOption.TopDirectoryOnly).Any() || - File.Exists(Path.Combine(directory, "angular.json")); + File.Exists(Path.Combine(directory, "angular.json")) || + File.Exists(Path.Combine(directory, "vite.config.ts")) || + File.Exists(Path.Combine(directory, "next.config.ts")); } } diff --git a/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder_Tests.cs b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder_Tests.cs new file mode 100644 index 0000000000..5eabaf8f5d --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectModification/PackageJsonFileFinder_Tests.cs @@ -0,0 +1,41 @@ +using System; +using System.IO; +using Shouldly; +using Volo.Abp.Cli.ProjectModification; +using Xunit; + +namespace Volo.Abp.Cli; + +public class PackageJsonFileFinder_Tests +{ + [Theory] + [InlineData("Test.csproj", true)] + [InlineData("angular.json", true)] + [InlineData("vite.config.ts", true)] + [InlineData("next.config.ts", true)] + [InlineData("", false)] + public void Should_Find_Package_Json_For_Supported_Project_Types(string projectFileName, bool expected) + { + var testDirectory = Path.Combine(Path.GetTempPath(), "abp-cli-tests", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(testDirectory); + + try + { + var packageJsonPath = Path.Combine(testDirectory, "package.json"); + File.WriteAllText(packageJsonPath, "{}"); + + if (!projectFileName.IsNullOrEmpty()) + { + File.WriteAllText(Path.Combine(testDirectory, projectFileName), string.Empty); + } + + var result = new PackageJsonFileFinder().Find(testDirectory); + + result.Contains(packageJsonPath).ShouldBe(expected); + } + finally + { + Directory.Delete(testDirectory, recursive: true); + } + } +}