From 25ffc28157969352382e25efa30bf7703c3f4ffc Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 22 Jun 2020 16:38:16 +0300 Subject: [PATCH 1/2] projectbuilding: change environments folder location in angular resolves https://github.com/abpframework/abp/issues/4458 --- .../Volo/Abp/Cli/Commands/GenerateProxyCommand.cs | 12 ++++++------ ...tFilePortChangeForSeparatedIdentityServersStep.cs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs index 2b524d9272..d148346836 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs @@ -51,7 +51,7 @@ namespace Volo.Abp.Cli.Commands var apiUrl = commandLineArgs.Options.GetOrNull(Options.ApiUrl.Short, Options.ApiUrl.Long); if (string.IsNullOrWhiteSpace(apiUrl)) { - var environmentJson = File.ReadAllText("src/environments/environment.ts").Split("export const environment = ")[1].Replace(";", " "); + var environmentJson = File.ReadAllText("projects/dev-app/src/environments/environment.ts").Split("export const environment = ")[1].Replace(";", " "); var environment = JObject.Parse(environmentJson); apiUrl = environment["apis"]["default"]["url"].ToString(); } @@ -61,7 +61,7 @@ namespace Volo.Abp.Cli.Commands output = commandLineArgs.Options.GetOrNull(Options.Output.Short, Options.Output.Long); if (!string.IsNullOrWhiteSpace(output) && !(output.EndsWith("/") || output.EndsWith("\\"))) - { + { output += "/"; } @@ -110,7 +110,7 @@ namespace Volo.Abp.Cli.Commands if (rootPath != "app") { Logger.LogInformation($"{rootPath} directory is creating"); - } + } if (rootPath == "app") { @@ -536,7 +536,7 @@ namespace Volo.Abp.Cli.Commands modelFileText.AppendLine(Environment.NewLine); modelFileText.AppendLine($"import {{ {baseTypeName} }} from '{baseTypeKebabCase}';"); - + extends = "extends " + (!string.IsNullOrWhiteSpace(customBaseTypeName) ? customBaseTypeName : baseTypeName); var modelIndex = CreateType(data, baseType, rootPath, modelIndexList, controllerPathName); @@ -628,7 +628,7 @@ namespace Volo.Abp.Cli.Commands { from = "./" + propertyTypeKebabCase; } - + modelFileText.Insert(0, $"import {{ {propertyType} }} from '{from}';"); modelFileText.Insert(0, Environment.NewLine); modelIndexList.Add(modelIndex); @@ -816,4 +816,4 @@ namespace Volo.Abp.Cli.Commands public bool IsOptional { get; set; } public string BindingSourceId { get; set; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs index 9a76f9ee21..b69ce479ac 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep.cs @@ -10,9 +10,9 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App { var fileEntries = context.Files.Where(x => !x.IsDirectory && - (x.Name.EndsWith("angular/src/environments/environment.ts", StringComparison.InvariantCultureIgnoreCase) || - x.Name.EndsWith("angular/src/environments/environment.hmr.ts", StringComparison.InvariantCultureIgnoreCase) || - x.Name.EndsWith("angular/src/environments/environment.prod.ts", StringComparison.InvariantCultureIgnoreCase)) + (x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.ts", StringComparison.InvariantCultureIgnoreCase) || + x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.hmr.ts", StringComparison.InvariantCultureIgnoreCase) || + x.Name.EndsWith("angular/projects/dev-app/src/environments/environment.prod.ts", StringComparison.InvariantCultureIgnoreCase)) ) .ToList(); From d8a8d0f1e45548341093d2014f386076e8da6c49 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 25 Jun 2020 10:03:30 +0300 Subject: [PATCH 2/2] fix Cli Switch-to-preview resolves https://github.com/abpframework/abp/issues/4391 --- .../ProjectModification/NpmPackagesUpdater.cs | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs index 02ae0040bc..752adad54e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs @@ -54,11 +54,12 @@ namespace Volo.Abp.Cli.ProjectModification _npmGlobalPackagesChecker.Check(); var packagesUpdated = new ConcurrentDictionary(); + async Task UpdateAsync(string file) { var updated = await UpdatePackagesInFile(file, includePreviews, switchToStable); packagesUpdated.TryAdd(file, updated); - }; + } Task.WaitAll(fileList.Select(UpdateAsync).ToArray()); @@ -66,23 +67,20 @@ namespace Volo.Abp.Cli.ProjectModification { var fileDirectory = Path.GetDirectoryName(file.Key).EnsureEndsWith(Path.DirectorySeparatorChar); - if (IsAngularProject(fileDirectory)) + if (includePreviews) { - if (includePreviews) - { - await CreateNpmrcFileAsync(Path.GetDirectoryName(file.Key)); - } - else if (switchToStable) - { - await DeleteNpmrcFileAsync(Path.GetDirectoryName(file.Key)); - } + await CreateNpmrcFileAsync(Path.GetDirectoryName(file.Key)); + RunNpmInstall(fileDirectory); + } + else if (switchToStable) + { + await DeleteNpmrcFileAsync(Path.GetDirectoryName(file.Key)); + RunYarn(fileDirectory); } - - RunYarn(fileDirectory); if (!IsAngularProject(fileDirectory)) { - Thread.Sleep(500); + Thread.Sleep(1000); RunGulp(fileDirectory); } } @@ -166,7 +164,8 @@ namespace Volo.Abp.Cli.ProjectModification return File.Exists(Path.Combine(fileDirectory, "angular.json")); } - protected virtual async Task UpdatePackagesInFile(string filePath, bool includePreviews = false, bool switchToStable = false) + protected virtual async Task UpdatePackagesInFile(string filePath, bool includePreviews = false, + bool switchToStable = false) { var packagesUpdated = false; var fileContent = File.ReadAllText(filePath); @@ -201,7 +200,7 @@ namespace Volo.Abp.Cli.ProjectModification bool includePreviews = false, bool switchToStable = false) { - var currentVersion = (string)package.Value; + var currentVersion = (string) package.Value; var version = await GetLatestVersion(package, currentVersion, includePreviews, switchToStable); @@ -214,7 +213,8 @@ namespace Volo.Abp.Cli.ProjectModification package.Value.Replace(versionWithPrefix); - Logger.LogInformation($"Updated {package.Name} to {version} in {filePath.Replace(Directory.GetCurrentDirectory(), "")}."); + Logger.LogInformation( + $"Updated {package.Name} to {version} in {filePath.Replace(Directory.GetCurrentDirectory(), "")}."); return true; } @@ -256,12 +256,12 @@ namespace Volo.Abp.Cli.ProjectModification protected virtual List GetAbpPackagesFromPackageJson(JObject fileObject) { - var dependencyList = new[] { "dependencies", "devDependencies", "peerDependencies" }; + var dependencyList = new[] {"dependencies", "devDependencies", "peerDependencies"}; var abpPackages = new List(); foreach (var dependencyListName in dependencyList) { - var dependencies = (JObject)fileObject[dependencyListName]; + var dependencies = (JObject) fileObject[dependencyListName]; if (dependencies == null) { @@ -269,7 +269,8 @@ namespace Volo.Abp.Cli.ProjectModification } var properties = dependencies.Properties().ToList(); - abpPackages.AddRange(properties.Where(p => p.Name.StartsWith("@abp/") || p.Name.StartsWith("@volo/")).ToList()); + abpPackages.AddRange(properties.Where(p => p.Name.StartsWith("@abp/") || p.Name.StartsWith("@volo/")) + .ToList()); } return abpPackages; @@ -286,5 +287,11 @@ namespace Volo.Abp.Cli.ProjectModification Logger.LogInformation($"Running Yarn on {fileDirectory}"); CmdHelper.RunCmd($"cd {fileDirectory} && yarn"); } + + protected virtual void RunNpmInstall(string fileDirectory) + { + Logger.LogInformation($"Running npm install on {fileDirectory}"); + CmdHelper.RunCmd($"cd {fileDirectory} && npm install"); + } } }